[vlc-commits] [Git][videolan/vlc][master] 7 commits: subsusf: simplify format usage

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Oct 29 14:57:26 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
e5d5228b by Steve Lhomme at 2023-10-29T14:38:00+00:00
subsusf: simplify format usage

The region is created with fmt_out. The region format is the same.

- - - - -
f8ee1015 by Steve Lhomme at 2023-10-29T14:38:00+00:00
dvbsub: remove always true tests

We test the subpicture is not NULL before.

- - - - -
c7c6942d by Steve Lhomme at 2023-10-29T14:38:00+00:00
zvbi: get the region format after the SPU is created

- - - - -
5dcd9975 by Steve Lhomme at 2023-10-29T14:38:00+00:00
cvdsub: directly pass the picture to render into

- - - - -
b9ae92cd by Steve Lhomme at 2023-10-29T14:38:00+00:00
svcdsub: directly pass the picture to render into

- - - - -
21ce9e90 by Steve Lhomme at 2023-10-29T14:38:00+00:00
aribcaption: directly pass the picture to render into

- - - - -
55fecf72 by Steve Lhomme at 2023-10-29T14:38:00+00:00
vout_subpictures: don't copy a whole video format when we only need the SAR

- - - - -


7 changed files:

- modules/codec/arib/libaribcaption.c
- modules/codec/cvdsub.c
- modules/codec/dvbsub.c
- modules/codec/subsusf.c
- modules/codec/svcdsub.c
- modules/codec/zvbi.c
- src/video_output/vout_subpictures.c


Changes:

=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -139,12 +139,12 @@ static int SubpictureValidate(subpicture_t *p_subpic,
     return VLC_EGENERIC;
 }
 
-static void CopyImageToRegion(subpicture_region_t *p_region, const aribcc_image_t *image)
+static void CopyImageToRegion(picture_t *dst_pic, const aribcc_image_t *image)
 {
     if(image->pixel_format != ARIBCC_PIXELFORMAT_RGBA8888)
         return;
 
-    plane_t *p_dstplane = &p_region->p_picture->p[0];
+    plane_t *p_dstplane = &dst_pic->p[0];
     plane_t srcplane;
     srcplane.i_lines = image->height;
     srcplane.i_pitch = image->stride;
@@ -201,7 +201,7 @@ static void SubpictureUpdate(subpicture_t *p_subpic,
         region->i_y = image->dst_y;
         region->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
 
-        CopyImageToRegion(region, image);
+        CopyImageToRegion(region->p_picture, image);
 
         *pp_region_last = region;
         pp_region_last = &region->p_next;


=====================================
modules/codec/cvdsub.c
=====================================
@@ -67,7 +67,7 @@ static block_t *Reassemble ( decoder_t *, block_t * );
 static void ParseMetaInfo  ( decoder_t *, block_t * );
 static void ParseHeader    ( decoder_t *, block_t * );
 static subpicture_t *DecodePacket( decoder_t *, block_t * );
-static void RenderImage( decoder_t *, block_t *, subpicture_region_t * );
+static void RenderImage( decoder_t *, block_t *, picture_t * );
 
 #define SUBTITLE_BLOCK_EMPTY 0
 #define SUBTITLE_BLOCK_PARTIAL 1
@@ -550,7 +550,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     p_region->i_x = p_region->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */
     p_region->i_y = p_sys->i_y_start;
 
-    RenderImage( p_dec, p_data, p_region );
+    RenderImage( p_dec, p_data, p_region->p_picture );
 
     return p_spu;
 }
@@ -579,10 +579,10 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
 
  *****************************************************************************/
 static void RenderImage( decoder_t *p_dec, block_t *p_data,
-                         subpicture_region_t *p_region )
+                         picture_t *dst_pic )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    uint8_t *p_dest = p_region->p_picture->Y_PIXELS;
+    uint8_t *p_dest = dst_pic->Y_PIXELS;
     int i_field;            /* The subtitles are interlaced */
     int i_row, i_column;    /* scanline row/column number */
     uint8_t i_color, i_count;
@@ -604,7 +604,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
                     /* Fill the rest of the line with next color */
                     i_color = bs_read( &bs, 4 );
 
-                    memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
+                    memset( &p_dest[i_row * dst_pic->Y_PITCH +
                                     i_column], i_color,
                             p_sys->i_width - i_column );
                     i_column = p_sys->i_width;
@@ -618,7 +618,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
 
                     i_count = __MIN( i_count, p_sys->i_width - i_column );
 
-                    memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
+                    memset( &p_dest[i_row * dst_pic->Y_PITCH +
                                     i_column], i_color, i_count );
                     i_column += i_count - 1;
                     continue;


=====================================
modules/codec/dvbsub.c
=====================================
@@ -1739,8 +1739,6 @@ static void YuvaYuvp( subpicture_t *p_subpic )
 {
     subpicture_region_t *p_region = NULL;
 
-    if( !p_subpic ) return;
-
     for( p_region = p_subpic->p_region; p_region; p_region = p_region->p_next )
     {
         video_format_t *p_fmt = &p_region->fmt;
@@ -1948,11 +1946,6 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
     p_region = p_subpic->p_region;
     if( p_region->fmt.i_chroma == VLC_CODEC_YUVA )
     {
-        if( !p_subpic )
-        {
-            msg_Err( p_enc, "no picture in subpicture" );
-            return NULL;
-        }
         YuvaYuvp( p_subpic );
     }
 


=====================================
modules/codec/subsusf.c
=====================================
@@ -1155,10 +1155,9 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
         int i_u =   ( ( -38 * i_r -  74 * i_g + 112 * i_b + 128 ) >> 8 ) + 128 ;
         int i_v =   ( ( 112 * i_r -  94 * i_g -  18 * i_b + 128 ) >> 8 ) + 128 ;
 
-        assert( p_region->fmt.i_chroma == VLC_CODEC_YUVA );
-        for( unsigned int y = 0; y < p_region->fmt.i_height; y++ )
+        for( unsigned int y = 0; y < fmt_out.i_height; y++ )
         {
-            for( unsigned int x = 0; x < p_region->fmt.i_width; x++ )
+            for( unsigned int x = 0; x < fmt_out.i_width; x++ )
             {
                 if( p_region->p_picture->Y_PIXELS[y*p_region->p_picture->Y_PITCH + x] != i_y ||
                     p_region->p_picture->U_PIXELS[y*p_region->p_picture->U_PITCH + x] != i_u ||


=====================================
modules/codec/svcdsub.c
=====================================
@@ -65,7 +65,7 @@ static block_t *Packetize  ( decoder_t *, block_t ** );
 static block_t *Reassemble ( decoder_t *, block_t * );
 static void ParseHeader( decoder_t *, block_t * );
 static subpicture_t *DecodePacket( decoder_t *, block_t * );
-static void SVCDSubRenderImage( decoder_t *, block_t *, subpicture_region_t * );
+static void SVCDSubRenderImage( decoder_t *, block_t *, picture_t * );
 
 #define GETINT16(p) GetWBE(p)  ; p +=2;
 
@@ -500,7 +500,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     p_region->i_x = p_sys->i_x_start;
     p_region->i_y = p_sys->i_y_start;
 
-    SVCDSubRenderImage( p_dec, p_data, p_region );
+    SVCDSubRenderImage( p_dec, p_data, p_region->p_picture );
 
     return p_spu;
 }
@@ -524,10 +524,10 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
  interlacing will also be removed.
  *****************************************************************************/
 static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
-                subpicture_region_t *p_region )
+                                picture_t *dst_pic )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    uint8_t *p_dest = p_region->p_picture->Y_PIXELS;
+    uint8_t *p_dest = dst_pic->Y_PIXELS;
     int i_field;            /* The subtitles are interlaced */
     int i_row, i_column;    /* scanline row/column number */
     uint8_t i_color, i_count;
@@ -546,13 +546,13 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
                 if( i_color == 0 && (i_count = bs_read( &bs, 2 )) )
                 {
                     i_count = __MIN( i_count, p_sys->i_width - i_column );
-                    memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
+                    memset( &p_dest[i_row * dst_pic->Y_PITCH +
                                     i_column], 0, i_count + 1 );
                     i_column += i_count;
                     continue;
                 }
 
-                p_dest[i_row * p_region->p_picture->Y_PITCH + i_column] = i_color;
+                p_dest[i_row * dst_pic->Y_PITCH + i_column] = i_color;
             }
 
             bs_align( &bs );


=====================================
modules/codec/zvbi.c
=====================================
@@ -174,7 +174,7 @@ typedef struct
 
 static int Decode( decoder_t *, block_t * );
 
-static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
+static subpicture_t *Subpicture( decoder_t *p_dec,
                                  bool b_text,
                                  int i_columns, int i_rows,
                                  int i_align, vlc_tick_t i_pts );
@@ -385,12 +385,14 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
         if( p_sys->b_text && p_sys->i_last_page != i_wanted_page )
         {
             /* We need to reset the subtitle */
-            p_spu = Subpicture( p_dec, &fmt, true,
+            p_spu = Subpicture( p_dec, true,
                                 p_page.columns, p_page.rows,
                                 i_align, p_block->i_pts );
             if( !p_spu )
                 goto error;
 
+            fmt = p_spu->p_region->fmt;
+
             p_sys->b_update = true;
             p_sys->i_last_page = i_wanted_page;
             goto exit;
@@ -421,12 +423,14 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
 
     /* If there is a page or sub to render, then we do that here */
     /* Create the subpicture unit */
-    p_spu = Subpicture( p_dec, &fmt, p_sys->b_text,
+    p_spu = Subpicture( p_dec, p_sys->b_text,
                         p_page.columns, __MAX(i_num_rows, 1),
                         i_align, p_block->i_pts );
     if( !p_spu )
         goto error;
 
+    fmt = p_spu->p_region->fmt;
+
     if( !p_sys->b_text && i_num_rows == 0 )
     {
         p_spu->b_ephemer = false;
@@ -517,7 +521,7 @@ error:
     return VLCDEC_SUCCESS;
 }
 
-static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
+static subpicture_t *Subpicture( decoder_t *p_dec,
                                  bool b_text,
                                  int i_columns, int i_rows, int i_align,
                                  vlc_tick_t i_pts )
@@ -570,8 +574,6 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
     p_spu->i_original_picture_width = p_spu->p_region->fmt.i_width;
     p_spu->i_original_picture_height = p_spu->p_region->fmt.i_height;
 
-    /* */
-    *p_fmt = p_spu->p_region->fmt;
     return p_spu;
 }
 


=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -1210,28 +1210,31 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
             spu_area_t area;
 
             /* Compute region scale AR */
-            video_format_t region_fmt = region->fmt;
-            if (region_fmt.i_sar_num <= 0 || region_fmt.i_sar_den <= 0) {
+            vlc_rational_t region_sar = (vlc_rational_t) {
+                .num = region->fmt.i_sar_num,
+                .den = region->fmt.i_sar_den
+            };
+            if (region_sar.num <= 0 || region_sar.den <= 0) {
 
                 const uint64_t i_sar_num = (uint64_t)fmt_dst->i_visible_width  *
                                            fmt_dst->i_sar_num * subpic->i_original_picture_height;
                 const uint64_t i_sar_den = (uint64_t)fmt_dst->i_visible_height *
                                            fmt_dst->i_sar_den * subpic->i_original_picture_width;
 
-                vlc_ureduce(&region_fmt.i_sar_num, &region_fmt.i_sar_den,
+                vlc_ureduce(&region_sar.num, &region_sar.den,
                             i_sar_num, i_sar_den, 65536);
             }
 
             /* Compute scaling from original size to destination size */
             // ensures that the heights match, the width being cropped.
-            spu_scale_t scale_h = spu_scale_createq((uint64_t)fmt_dst->i_visible_height         * fmt_dst->i_sar_den * region_fmt.i_sar_num,
-                                                  (uint64_t)subpic->i_original_picture_height * fmt_dst->i_sar_num * region_fmt.i_sar_den,
+            spu_scale_t scale_h = spu_scale_createq((uint64_t)fmt_dst->i_visible_height         * fmt_dst->i_sar_den * region_sar.num,
+                                                  (uint64_t)subpic->i_original_picture_height * fmt_dst->i_sar_num * region_sar.den,
                                                   fmt_dst->i_visible_height,
                                                   subpic->i_original_picture_height);
 
             // ensures that the widths match, the height being cropped.
-            spu_scale_t scale_w = spu_scale_createq((uint64_t)fmt_dst->i_visible_width         * fmt_dst->i_sar_den * region_fmt.i_sar_num,
-                                      (uint64_t)subpic->i_original_picture_width * fmt_dst->i_sar_num * region_fmt.i_sar_den,
+            spu_scale_t scale_w = spu_scale_createq((uint64_t)fmt_dst->i_visible_width         * fmt_dst->i_sar_den * region_sar.num,
+                                      (uint64_t)subpic->i_original_picture_width * fmt_dst->i_sar_num * region_sar.den,
                                       fmt_dst->i_visible_width,
                                       subpic->i_original_picture_width);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/16c952f0df0b52e827ae9d8c94e934430859e0c0...55fecf7229b1cc79cb2897927c8368058a2a3260

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/16c952f0df0b52e827ae9d8c94e934430859e0c0...55fecf7229b1cc79cb2897927c8368058a2a3260
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