[vlc-commits] [Git][videolan/vlc][master] 5 commits: subpicture: fix missing+leaking region in subpicture_NewFromPicture()

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Nov 9 11:56:41 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6170c3e5 by Steve Lhomme at 2023-11-09T10:40:44+00:00
subpicture: fix missing+leaking region in subpicture_NewFromPicture()

Consecutive to 3d610be9f02f58af4b3ba8831a151ab3e091a83a

- - - - -
9918facc by Steve Lhomme at 2023-11-09T10:40:44+00:00
vout_subpictures: fix positioning of subtitles

Consecutive to 3d610be9f02f58af4b3ba8831a151ab3e091a83a.

- - - - -
6c529ae8 by Steve Lhomme at 2023-11-09T10:40:44+00:00
vout_subpictures: don't handle the region any longer if it's not rendered

- - - - -
f3196c60 by Steve Lhomme at 2023-11-09T10:40:44+00:00
vout_subpicture: document the reason why we overwrite the region position

- - - - -
5f449148 by Steve Lhomme at 2023-11-09T10:40:44+00:00
dvbsub: fix handling of empty regions to encode

Consecutive to 3d610be9f02f58af4b3ba8831a151ab3e091a83a.

- - - - -


3 changed files:

- modules/codec/dvbsub.c
- src/misc/subpicture.c
- src/video_output/vout_subpictures.c


Changes:

=====================================
modules/codec/dvbsub.c
=====================================
@@ -1937,7 +1937,7 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
     bs_t bits, *s = &bits;
     block_t *p_block;
 
-    if( !p_subpic || !vlc_spu_regions_is_empty(&p_subpic->regions) ) return NULL;
+    if( !p_subpic || vlc_spu_regions_is_empty(&p_subpic->regions) ) return NULL;
 
     /* FIXME: this is a hack to convert VLC_CODEC_YUVA into
      *  VLC_CODEC_YUVP


=====================================
src/misc/subpicture.c
=====================================
@@ -156,9 +156,10 @@ subpicture_t *subpicture_NewFromPicture( vlc_object_t *p_obj,
     if (likely(p_region == NULL))
     {
         subpicture_Delete(p_subpic);
-        p_subpic = NULL;
+        return NULL;
     }
 
+    vlc_spu_regions_push( &p_subpic->regions, p_region );
     return p_subpic;
 }
 


=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -1261,28 +1261,31 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
                             i_original_width, i_original_height,
                             subtitle_area, subtitle_area_count,
                             subpic->b_subtitle ? render_subtitle_date : system_now);
-            if (output_last_ptr)
+            if (unlikely(output_last_ptr == NULL))
+                continue;
+
+            if (do_external_scale)
             {
-                if (do_external_scale)
+                if (scale.h != SCALE_UNIT)
                 {
-                    if (scale.h != SCALE_UNIT)
-                    {
-                        output_last_ptr->zoom_v.num = scale.h;
-                        output_last_ptr->zoom_v.den = SCALE_UNIT;
-                    }
-                    if (scale.w != SCALE_UNIT)
-                    {
-                        output_last_ptr->zoom_h.num = scale.w;
-                        output_last_ptr->zoom_h.den = SCALE_UNIT;
-                    }
+                    output_last_ptr->zoom_v.num = scale.h;
+                    output_last_ptr->zoom_v.den = SCALE_UNIT;
+                }
+                if (scale.w != SCALE_UNIT)
+                {
+                    output_last_ptr->zoom_h.num = scale.w;
+                    output_last_ptr->zoom_h.den = SCALE_UNIT;
                 }
-
-                vlc_spu_regions_push(&output->regions, output_last_ptr);
             }
 
+            vlc_spu_regions_push(&output->regions, output_last_ptr);
+
             if (subpic->b_subtitle) {
                 area = spu_area_unscaled(area, scale);
                 if (!subpic->b_absolute && area.width > 0 && area.height > 0) {
+                    // keep the non-absolute region position that doesn't overlap
+                    // with other regions, the output subpicture will become
+                    // absolute and this won't change later
                     region->i_x = area.x;
                     region->i_y = area.y;
                 }
@@ -1290,7 +1293,7 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
                     subtitle_area[subtitle_area_count++] = area;
             }
         }
-        if (subpic->b_subtitle && vlc_spu_regions_is_empty(&subpic->regions))
+        if (subpic->b_subtitle && !vlc_spu_regions_is_empty(&subpic->regions))
             subpic->b_absolute = true;
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6cef23c3400c683e1ac225575a72a1606124fad6...5f449148afe3cea25a369c039bbad8b5c60dbe1c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6cef23c3400c683e1ac225575a72a1606124fad6...5f449148afe3cea25a369c039bbad8b5c60dbe1c
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list