[vlc-commits] [Git][videolan/vlc][master] 2 commits: spudec: use video_format_Setup() for the local picture format

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 28 07:19:10 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
39a35762 by Steve Lhomme at 2024-06-28T07:06:27+00:00
spudec: use video_format_Setup() for the local picture format

It will be copied with the palette in subpicture_region_New().

- - - - -
e1c739ae by Steve Lhomme at 2024-06-28T07:06:27+00:00
spudec: clean the local format early

So we don't have to do the call twice.

- - - - -


1 changed file:

- modules/codec/spudec/parse.c


Changes:

=====================================
modules/codec/spudec/parse.c
=====================================
@@ -842,15 +842,15 @@ static int Render( decoder_t *p_dec, subpicture_t *p_spu,
     const uint16_t *p_source = p_pixeldata;
     video_format_t fmt;
     video_palette_t palette;
+    const int width = p_spu_properties->i_width;
+    const int height = p_spu_properties->i_height -
+        p_spu_data->i_y_top_offset - p_spu_data->i_y_bottom_offset;
 
     /* Create a new subpicture region */
     video_format_Init( &fmt, VLC_CODEC_YUVP );
-    fmt.i_sar_num = 0; /* 0 means use aspect ratio of background video */
-    fmt.i_sar_den = 1;
-    fmt.i_width = fmt.i_visible_width = p_spu_properties->i_width;
-    fmt.i_height = fmt.i_visible_height = p_spu_properties->i_height -
-        p_spu_data->i_y_top_offset - p_spu_data->i_y_bottom_offset;
-    fmt.i_x_offset = fmt.i_y_offset = 0;
+    video_format_Setup( &fmt, VLC_CODEC_YUVP, width, height, width, height,
+                        0, /* 0 means use aspect ratio of background video */
+                        1 );
     fmt.p_palette = &palette;
     fmt.p_palette->i_entries = 4;
     for( i_x = 0; i_x < fmt.p_palette->i_entries; i_x++ )
@@ -862,10 +862,10 @@ static int Render( decoder_t *p_dec, subpicture_t *p_spu,
     }
 
     subpicture_region_t *p_region = subpicture_region_New( &fmt );
+    fmt.p_palette = NULL;
+    video_format_Clean( &fmt );
     if( !p_region )
     {
-        fmt.p_palette = NULL;
-        video_format_Clean( &fmt );
         msg_Err( p_dec, "cannot allocate SPU region" );
         return VLC_EGENERIC;
     }
@@ -878,10 +878,10 @@ static int Render( decoder_t *p_dec, subpicture_t *p_spu,
     i_pitch = p_region->p_picture->p->i_pitch;
 
     /* Draw until we reach the bottom of the subtitle */
-    for( i_y = 0; i_y < (int)fmt.i_height * i_pitch; i_y += i_pitch )
+    for( i_y = 0; i_y < height * i_pitch; i_y += i_pitch )
     {
         /* Draw until we reach the end of the line */
-        for( i_x = 0 ; i_x < (int)fmt.i_width; i_x += i_len )
+        for( i_x = 0 ; i_x < width; i_x += i_len )
         {
             /* Get the RLE part, then draw the line */
             i_color = *p_source & 0x3;
@@ -890,8 +890,5 @@ static int Render( decoder_t *p_dec, subpicture_t *p_spu,
         }
     }
 
-    fmt.p_palette = NULL;
-    video_format_Clean( &fmt );
-
     return VLC_SUCCESS;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/163c786896c5c99a4c2af7dff191473902453d56...e1c739aedabe8f1398dd3bd995980d4ce54b64c0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/163c786896c5c99a4c2af7dff191473902453d56...e1c739aedabe8f1398dd3bd995980d4ce54b64c0
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