[vlc-commits] [Git][videolan/vlc][master] 16 commits: direct3d11: use the picture format of SPU when dealing with colorimetry and buffers

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Feb 11 08:44:15 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d14eadc2 by Steve Lhomme at 2024-02-11T08:15:42+00:00
direct3d11: use the picture format of SPU when dealing with colorimetry and buffers

We map the picture to a texture that is rendered with the appropriate colorimetry.
The other format is mostly used for positioning.

- - - - -
3a11609c by Steve Lhomme at 2024-02-11T08:15:42+00:00
direct3d9: use the picture format of SPU when dealing with buffer mapping

We map the picture to a texture that is rendered  using the buffer dimensions.
The other format is mostly used for positioning.

- - - - -
a1c8e5b5 by Steve Lhomme at 2024-02-11T08:15:42+00:00
libplacebo: use the picture format of SPU when dealing with colorimetry

The other format is mostly used for positioning.

- - - - -
7b011e4c by Steve Lhomme at 2024-02-11T08:15:42+00:00
xcb: use the picture format of SPU when dealing with buffer mapping

We map the picture to a texture that is rendered  using the buffer dimensions.
The other format is mostly used for positioning.

- - - - -
4f37f30c by Steve Lhomme at 2024-02-11T08:15:42+00:00
VLCSampleBufferDisplay: use the picture format of SPU when dealing with buffer mapping

We already use the picture pitch.

We map the picture to a texture that is rendered  using the buffer dimensions.
The other format is mostly used for positioning.

- - - - -
0c394948 by Steve Lhomme at 2024-02-11T08:15:42+00:00
bluray: use the region picture for chroma/buffer dimensions/palette

Rather than the attached format used for cropping.

- - - - -
89ef6049 by Steve Lhomme at 2024-02-11T08:15:42+00:00
spudec: fill the palette in the region picture

Rather than the attached format used for cropping.

- - - - -
bf85b72b by Steve Lhomme at 2024-02-11T08:15:42+00:00
dvbsub: use the region picture for chroma/buffer dimensions/palette

Rather than the attached format used for cropping.

- - - - -
ed2123d8 by Steve Lhomme at 2024-02-11T08:15:42+00:00
dvbsub: group code handling non-text regions

- - - - -
2ea36534 by Steve Lhomme at 2024-02-11T08:15:42+00:00
libass: use the region dimensions to draw

Rather than the attached format used for cropping.

- - - - -
f6550e27 by Steve Lhomme at 2024-02-11T08:15:42+00:00
zvbi: use the region dimensions to get the pitch

Rather than the attached format used for cropping.

- - - - -
ceb3725d by Steve Lhomme at 2024-02-11T08:15:42+00:00
zvbi: only set the original dimensions for non-text subpictures

The value was 0 for text regions, no need to force it again.

- - - - -
e5cebd78 by Steve Lhomme at 2024-02-11T08:15:42+00:00
freetype: use the YUVP region picture for palette/buffer handling

Rather than the attached format used for cropping.

- - - - -
6f64a977 by Steve Lhomme at 2024-02-11T08:15:42+00:00
freetype: set the colorimetry on the region picture

Rather than the attached format used for cropping.

- - - - -
1b5faa0f by Steve Lhomme at 2024-02-11T08:15:42+00:00
subpicture: set the missing YUVP/RGBP palette in the picture format

Rather than the attached format used for cropping.

Ultimately we should assert that the incoming format is clean.

- - - - -
ff385bcb by Steve Lhomme at 2024-02-11T08:15:42+00:00
vout_subpictures: use the region picture for chroma/palette

Rather than the attached format used for cropping.

- - - - -


13 changed files:

- modules/access/bluray.c
- modules/codec/dvbsub.c
- modules/codec/libass.c
- modules/codec/spudec/parse.c
- modules/codec/zvbi.c
- modules/text_renderer/freetype/freetype.c
- modules/video_output/apple/VLCSampleBufferDisplay.m
- modules/video_output/libplacebo/display.c
- modules/video_output/win32/direct3d11.cpp
- modules/video_output/win32/direct3d9.c
- modules/video_output/xcb/render.c
- src/misc/subpicture.c
- src/video_output/vout_subpictures.c


Changes:

=====================================
modules/access/bluray.c
=====================================
@@ -1896,9 +1896,9 @@ static void blurayDrawOverlay(demux_t *p_demux, const BD_OVERLAY* const eventov)
     vlc_spu_regions_foreach(p_reg, &ov->regions) {
         if (p_reg->i_x == eventov->x &&
             p_reg->i_y == eventov->y &&
-            p_reg->fmt.i_width == eventov->w &&
-            p_reg->fmt.i_height == eventov->h &&
-            p_reg->fmt.i_chroma == VLC_CODEC_YUVP)
+            p_reg->p_picture->format.i_width == eventov->w &&
+            p_reg->p_picture->format.i_height == eventov->h &&
+            p_reg->p_picture->format.i_chroma == VLC_CODEC_YUVP)
             break;
     }
 
@@ -1943,12 +1943,12 @@ static void blurayDrawOverlay(demux_t *p_demux, const BD_OVERLAY* const eventov)
         }
 
     if (eventov->palette) {
-        p_reg->fmt.p_palette->i_entries = 256;
+        p_reg->p_picture->format.p_palette->i_entries = 256;
         for (int i = 0; i < 256; ++i) {
-            p_reg->fmt.p_palette->palette[i][0] = eventov->palette[i].Y;
-            p_reg->fmt.p_palette->palette[i][1] = eventov->palette[i].Cb;
-            p_reg->fmt.p_palette->palette[i][2] = eventov->palette[i].Cr;
-            p_reg->fmt.p_palette->palette[i][3] = eventov->palette[i].T;
+            p_reg->p_picture->format.p_palette->palette[i][0] = eventov->palette[i].Y;
+            p_reg->p_picture->format.p_palette->palette[i][1] = eventov->palette[i].Cb;
+            p_reg->p_picture->format.p_palette->palette[i][2] = eventov->palette[i].Cr;
+            p_reg->p_picture->format.p_palette->palette[i][3] = eventov->palette[i].T;
         }
     }
 
@@ -2044,7 +2044,7 @@ static void blurayDrawArgbOverlay(demux_t *p_demux, const BD_ARGB_OVERLAY* const
     }
 
     /* Find a region to update */
-    if (p_reg->fmt.i_chroma != rgbchroma) {
+    if (p_reg->p_picture->format.i_chroma != rgbchroma) {
         vlc_mutex_unlock(&ov->lock);
         return;
     }


=====================================
modules/codec/dvbsub.c
=====================================
@@ -1740,7 +1740,7 @@ static void YuvaYuvp( subpicture_t *p_subpic )
 
     vlc_spu_regions_foreach(p_region, &p_subpic->regions)
     {
-        video_format_t *p_fmt = &p_region->fmt;
+        video_format_t *p_fmt = &p_region->p_picture->format;
         int i = 0, j = 0, n = 0, p = 0;
         int i_max_entries = 256;
 
@@ -1943,34 +1943,36 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
      *  VLC_CODEC_YUVP
      */
     p_region = vlc_spu_regions_first_or_null(&p_subpic->regions);
-    if( p_region->fmt.i_chroma == VLC_CODEC_YUVA )
-    {
-        YuvaYuvp( p_subpic );
-    }
-
     /* Sanity check */
     if( !p_region ) return NULL;
 
-    if( (!subpicture_region_IsText( p_region )) &&
-        ( p_region->fmt.i_chroma != VLC_CODEC_YUVP ) )
+    if( !subpicture_region_IsText( p_region ) )
     {
-        msg_Err( p_enc, "chroma %4.4s not supported", (char *)&p_region->fmt.i_chroma );
-        return NULL;
-    }
+        if( p_region->p_picture->format.i_chroma == VLC_CODEC_YUVA )
+        {
+            YuvaYuvp( p_subpic );
+        }
 
-    if( p_region->fmt.p_palette )
-    {
-        switch( p_region->fmt.p_palette->i_entries )
+        if( p_region->p_picture->format.i_chroma != VLC_CODEC_YUVP )
         {
-            case 0:
-            case 4:
-            case 16:
-            case 256:
-                break;
-            default:
-                msg_Err( p_enc, "subpicture palette (%d) not handled",
-                            p_region->fmt.p_palette->i_entries );
-                return NULL;
+            msg_Err( p_enc, "chroma %4.4s not supported", (char *)&p_region->p_picture->format.i_chroma );
+            return NULL;
+        }
+
+        if( p_region->p_picture->format.p_palette )
+        {
+            switch( p_region->p_picture->format.p_palette->i_entries )
+            {
+                case 0:
+                case 4:
+                case 16:
+                case 256:
+                    break;
+                default:
+                    msg_Err( p_enc, "subpicture palette (%d) not handled",
+                                p_region->p_picture->format.p_palette->i_entries );
+                    return NULL;
+            }
         }
     }
     /* End of hack */
@@ -2134,9 +2136,9 @@ static void encode_clut( encoder_t *p_enc, bs_t *s, subpicture_region_t *p_regio
     /* Sanity check */
     if( !p_region ) return;
 
-    if( p_region->fmt.i_chroma == VLC_CODEC_YUVP )
+    if( !subpicture_region_IsText( p_region ) && p_region->p_picture->format.i_chroma == VLC_CODEC_YUVP )
     {
-        p_pal = p_region->fmt.p_palette;
+        p_pal = p_region->p_picture->format.p_palette;
     }
     else
         p_pal = &empty_palette;
@@ -2181,7 +2183,7 @@ static void encode_region_composition( encoder_t *p_enc, bs_t *s,
 
         if( !b_text )
         {
-            video_palette_t *p_pal = p_region->fmt.p_palette;
+            video_palette_t *p_pal = p_region->p_picture->format.p_palette;
 
             if( !p_pal )
             {
@@ -2264,12 +2266,12 @@ static void encode_object( encoder_t *p_enc, bs_t *s, subpicture_t *p_subpic )
         /* object coding method */
         if (subpicture_region_IsText( p_region ))
             bs_write( s, 2, 1 );
-        else if ( p_region->fmt.i_chroma == VLC_CODEC_YUVP )
+        else if ( p_region->p_picture->format.i_chroma == VLC_CODEC_YUVP )
             bs_write( s, 2, 0 );
         else
         {
             msg_Err( p_enc, "FOURCC %4.4s not supported by encoder.",
-                     (const char*)&p_region->fmt.i_chroma );
+                     (const char*)&p_region->p_picture->format.i_chroma );
             i_region++;
             continue;
         }
@@ -2341,14 +2343,11 @@ static void encode_pixel_data( encoder_t *p_enc, bs_t *s,
 {
     unsigned int i_line;
 
-    /* Sanity check */
-    if( p_region->fmt.i_chroma != VLC_CODEC_YUVP ) return;
-
     /* Encode line by line */
     for( i_line = !b_top; i_line < p_region->fmt.i_visible_height;
          i_line += 2 )
     {
-        switch( p_region->fmt.p_palette->i_entries )
+        switch( p_region->p_picture->format.p_palette->i_entries )
         {
         case 0:
             break;
@@ -2370,7 +2369,7 @@ static void encode_pixel_data( encoder_t *p_enc, bs_t *s,
 
         default:
             msg_Err( p_enc, "subpicture palette (%i) not handled",
-                     p_region->fmt.p_palette->i_entries );
+                     p_region->p_picture->format.p_palette->i_entries );
             break;
         }
 


=====================================
modules/codec/libass.c
=====================================
@@ -679,8 +679,8 @@ static void RegionDraw( subpicture_region_t *p_region, ASS_Image *p_img )
     const plane_t *p = &p_region->p_picture->p[0];
     const int i_x = p_region->i_x;
     const int i_y = p_region->i_y;
-    const int i_width  = p_region->fmt.i_width;
-    const int i_height = p_region->fmt.i_height;
+    const int i_width  = p_region->p_picture->format.i_width;
+    const int i_height = p_region->p_picture->format.i_height;
 
     memset( p->p_pixels, 0x00, p->i_pitch * p->i_visible_lines );
     for( ; p_img != NULL; p_img = p_img->next )


=====================================
modules/codec/spudec/parse.c
=====================================
@@ -108,7 +108,7 @@ static void ParsePXCTLI( decoder_t *p_dec, const subpicture_data_t *p_spu_data,
                          subpicture_region_t *p_region )
 {
     plane_t *p_plane = &p_region->p_picture->p[0];
-    video_palette_t *p_palette = p_region->fmt.p_palette;
+    video_palette_t *p_palette = p_region->p_picture->format.p_palette;
 
     if( !p_dec->fmt_in->subs.spu.b_palette )
         return;


=====================================
modules/codec/zvbi.c
=====================================
@@ -483,7 +483,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
         picture_t *p_pic = p_region->p_picture;
 
         /* ZVBI is stupid enough to assume pitch == width */
-        p_pic->p->i_pitch = 4 * p_region->fmt.i_width;
+        p_pic->p->i_pitch = 4 * p_region->p_picture->format.i_width;
 
         /* Maintain subtitle position */
         p_region->i_y = i_first_row*10;
@@ -546,6 +546,9 @@ static subpicture_t *Subpicture( decoder_t *p_dec,
         fmt.i_height = fmt.i_visible_height = i_rows * 10;
         fmt.i_sar_num = fmt.i_sar_den = 0; /* let the vout set the correct AR */
         p_region = subpicture_region_New( &fmt );
+
+        p_spu->i_original_picture_width = fmt.i_visible_width;
+        p_spu->i_original_picture_height = fmt.i_visible_height;
     }
     else
     {
@@ -567,8 +570,6 @@ static subpicture_t *Subpicture( decoder_t *p_dec,
 
     if( !b_text )
         p_region->i_align = i_align;
-    p_spu->i_original_picture_width = p_region->fmt.i_width;
-    p_spu->i_original_picture_height = p_region->fmt.i_height;
 
     return p_spu;
 }


=====================================
modules/text_renderer/freetype/freetype.c
=====================================
@@ -363,27 +363,27 @@ static void RenderYUVP( const subpicture_region_t *p_region_in,
     YUVFromXRGB( p_line->p_character[0].p_style->i_font_color, &i_y, &i_u, &i_v );
 
     /* Build palette */
-    p_region->fmt.p_palette->i_entries = 16;
+    p_region->p_picture->format.p_palette->i_entries = 16;
     for( i = 0; i < 8; i++ )
     {
-        p_region->fmt.p_palette->palette[i][0] = 0;
-        p_region->fmt.p_palette->palette[i][1] = 0x80;
-        p_region->fmt.p_palette->palette[i][2] = 0x80;
-        p_region->fmt.p_palette->palette[i][3] = (int)pi_gamma[i] * i_alpha / 255;
+        p_region->p_picture->format.p_palette->palette[i][0] = 0;
+        p_region->p_picture->format.p_palette->palette[i][1] = 0x80;
+        p_region->p_picture->format.p_palette->palette[i][2] = 0x80;
+        p_region->p_picture->format.p_palette->palette[i][3] = (int)pi_gamma[i] * i_alpha / 255;
     }
-    for( i = 8; i < p_region->fmt.p_palette->i_entries; i++ )
+    for( i = 8; i < p_region->p_picture->format.p_palette->i_entries; i++ )
     {
-        p_region->fmt.p_palette->palette[i][0] = i * 16 * i_y / 256;
-        p_region->fmt.p_palette->palette[i][1] = i_u;
-        p_region->fmt.p_palette->palette[i][2] = i_v;
-        p_region->fmt.p_palette->palette[i][3] = (int)pi_gamma[i] * i_alpha / 255;
+        p_region->p_picture->format.p_palette->palette[i][0] = i * 16 * i_y / 256;
+        p_region->p_picture->format.p_palette->palette[i][1] = i_u;
+        p_region->p_picture->format.p_palette->palette[i][2] = i_v;
+        p_region->p_picture->format.p_palette->palette[i][3] = (int)pi_gamma[i] * i_alpha / 255;
     }
 
     p_dst = p_region->p_picture->Y_PIXELS;
     i_pitch = p_region->p_picture->Y_PITCH;
 
     /* Initialize the region pixels */
-    memset( p_dst, 0, i_pitch * p_region->fmt.i_height );
+    memset( p_dst, 0, i_pitch * p_region->p_picture->format.i_height );
 
     for( ; p_line != NULL; p_line = p_line->p_next )
     {
@@ -416,13 +416,13 @@ static void RenderYUVP( const subpicture_region_t *p_region_in,
         uint8_t *p_top = p_dst; /* Use 1st line as a cache */
         uint8_t left, current;
 
-        for( y = 1; y < p_region->fmt.i_height - 1; y++ )
+        for( y = 1; y < p_region->p_picture->format.i_height - 1; y++ )
         {
-            if( y > 1 ) memcpy( p_top, p_dst, p_region->fmt.i_width );
+            if( y > 1 ) memcpy( p_top, p_dst, p_region->p_picture->format.i_width );
             p_dst += p_region->p_picture->Y_PITCH;
             left = 0;
 
-            for( x = 1; x < p_region->fmt.i_width - 1; x++ )
+            for( x = 1; x < p_region->p_picture->format.i_width - 1; x++ )
             {
                 current = p_dst[x];
                 p_dst[x] = ( 8 * (int)p_dst[x] + left + p_dst[x+1] + p_top[x -1]+ p_top[x] + p_top[x+1] +
@@ -430,7 +430,7 @@ static void RenderYUVP( const subpicture_region_t *p_region_in,
                 left = current;
             }
         }
-        memset( p_top, 0, p_region->fmt.i_width );
+        memset( p_top, 0, p_region->p_picture->format.i_width );
     }
 }
 
@@ -1075,10 +1075,6 @@ static subpicture_region_t *Render( filter_t *p_filter,
     fmt.i_height         =
     fmt.i_visible_height = regionbbox.yMax - regionbbox.yMin;
     fmt.i_sar_num = fmt.i_sar_den = 1;
-    fmt.transfer  = p_region_in->fmt.transfer;
-    fmt.primaries = p_region_in->fmt.primaries;
-    fmt.space     = p_region_in->fmt.space;
-    fmt.mastering = p_region_in->fmt.mastering;
 
     for( const vlc_fourcc_t *p_chroma = p_chroma_list; *p_chroma != 0; p_chroma++ )
     {
@@ -1088,6 +1084,11 @@ static subpicture_region_t *Render( filter_t *p_filter,
         if (unlikely(region == NULL))
             continue;
 
+        region->p_picture->format.transfer  = p_region_in->fmt.transfer;
+        region->p_picture->format.primaries = p_region_in->fmt.primaries;
+        region->p_picture->format.space     = p_region_in->fmt.space;
+        region->p_picture->format.mastering = p_region_in->fmt.mastering;
+
         region->fmt.i_sar_num = p_region_in->fmt.i_sar_num;
         region->fmt.i_sar_den = p_region_in->fmt.i_sar_den;
 


=====================================
modules/video_output/apple/VLCSampleBufferDisplay.m
=====================================
@@ -434,7 +434,7 @@ static void UpdateSubpictureRegions(vout_display_t *vd,
     CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
     const subpicture_region_t *r;
     vlc_spu_regions_foreach_const(r, &subpicture->regions) {
-        CFIndex length = r->fmt.i_height * r->p_picture->p->i_pitch;
+        CFIndex length = r->p_picture->format.i_height * r->p_picture->p->i_pitch;
         const size_t pixels_offset =
                 r->fmt.i_y_offset * r->p_picture->p->i_pitch +
                 r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;


=====================================
modules/video_output/libplacebo/display.c
=====================================
@@ -405,8 +405,8 @@ static void PictureRender(vout_display_t *vd, picture_t *pic,
             sys->overlays[i] = (struct pl_overlay) {
                 .tex   = sys->overlay_tex[i],
                 .mode  = PL_OVERLAY_NORMAL,
-                .color = vlc_placebo_ColorSpace(&r->fmt),
-                .repr  = vlc_placebo_ColorRepr(&r->fmt),
+                .color = vlc_placebo_ColorSpace(&r->p_picture->format),
+                .repr  = vlc_placebo_ColorRepr(&r->p_picture->format),
                 .parts = &sys->overlay_parts[i],
                 .num_parts = 1,
             };


=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -1349,8 +1349,8 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
                 i++;
                 continue;
             }
-            d3dquad->generic.i_width  = r->fmt.i_width;
-            d3dquad->generic.i_height = r->fmt.i_height;
+            d3dquad->generic.i_width  = r->p_picture->format.i_width;
+            d3dquad->generic.i_height = r->p_picture->format.i_height;
 
             d3dquad->generic.textureFormat = sys->regionQuad.generic.textureFormat;
             err = D3D11_AllocateQuad(vd, sys->d3d_dev, PROJECTION_MODE_RECTANGULAR, d3dquad);
@@ -1363,7 +1363,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
                 continue;
             }
 
-            err = D3D11_SetupQuad( vd, sys->d3d_dev, &r->fmt, d3dquad, &sys->display );
+            err = D3D11_SetupQuad( vd, sys->d3d_dev, &r->p_picture->format, d3dquad, &sys->display );
             if (err != VLC_SUCCESS) {
                 msg_Err(vd, "Failed to setup %dx%d quad for OSD",
                         r->fmt.i_visible_width, r->fmt.i_visible_height);
@@ -1380,7 +1380,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
             (*region)[i] = picture_NewFromResource(&r->p_picture->format, &picres);
             if ((*region)[i] == NULL) {
                 msg_Err(vd, "Failed to create %dx%d picture for OSD",
-                        r->fmt.i_width, r->fmt.i_height);
+                        r->p_picture->format.i_width, r->p_picture->format.i_height);
                 d3dquad->Reset();
                 i++;
                 continue;


=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -894,8 +894,8 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
             d3d_region_t *cache = &sys->d3dregion[j];
             if (cache->texture &&
                 cache->format == sys->d3dregion_format &&
-                cache->width  == r->fmt.i_width &&
-                cache->height == r->fmt.i_height) {
+                cache->width  == r->p_picture->format.i_width &&
+                cache->height == r->p_picture->format.i_height) {
                 *d3dr = *cache;
                 memset(cache, 0, sizeof(*cache));
                 break;
@@ -903,8 +903,8 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
         }
         if (!d3dr->texture) {
             d3dr->format = sys->d3dregion_format;
-            d3dr->width  = r->fmt.i_width;
-            d3dr->height = r->fmt.i_height;
+            d3dr->width  = r->p_picture->format.i_width;
+            d3dr->height = r->p_picture->format.i_height;
             hr = IDirect3DDevice9_CreateTexture(sys->d3d9_device->d3ddev.dev,
                                                 d3dr->width, d3dr->height,
                                                 1,
@@ -922,7 +922,7 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
             }
 #ifndef NDEBUG
             msg_Dbg(vd, "Created %dx%d texture for OSD",
-                    r->fmt.i_width, r->fmt.i_height);
+                    r->p_picture->format.i_width, r->p_picture->format.i_height);
 #endif
         }
 
@@ -936,16 +936,16 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
 
             if (d3dr->format == D3DFMT_A8B8G8R8) {
                 if (dst_pitch == r->p_picture->p->i_pitch) {
-                    memcpy(dst_data, src_data, r->fmt.i_height * dst_pitch);
+                    memcpy(dst_data, src_data, r->p_picture->format.i_height * dst_pitch);
                 } else {
                     int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_pitch);
-                    for (unsigned y = 0; y < r->fmt.i_height; y++) {
+                    for (unsigned y = 0; y < r->p_picture->format.i_height; y++) {
                         memcpy(&dst_data[y * dst_pitch], &src_data[y * src_pitch], copy_pitch);
                     }
                 }
             } else {
                 int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_pitch);
-                for (unsigned y = 0; y < r->fmt.i_height; y++) {
+                for (unsigned y = 0; y < r->p_picture->format.i_height; y++) {
                     for (int x = 0; x < copy_pitch; x += 4) {
                         dst_data[y * dst_pitch + x + 0] = src_data[y * src_pitch + x + 2];
                         dst_data[y * dst_pitch + x + 1] = src_data[y * src_pitch + x + 1];
@@ -978,9 +978,9 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
 
         RECT texture_rect;
         texture_rect.left   = 0;
-        texture_rect.right  = r->fmt.i_width;
+        texture_rect.right  = r->p_picture->format.i_width;
         texture_rect.top    = 0;
-        texture_rect.bottom = r->fmt.i_height;
+        texture_rect.bottom = r->p_picture->format.i_height;
 
         RECT texture_visible_rect;
         texture_visible_rect.left   = r->fmt.i_x_offset;


=====================================
modules/video_output/xcb/render.c
=====================================
@@ -118,8 +118,8 @@ static void RenderRegion(vout_display_t *vd, const vlc_render_subpicture *subpic
     xcb_connection_t *conn = sys->conn;
     const vout_display_place_t *place = &sys->place;
     picture_t *pic = reg->p_picture;
-    unsigned sw = reg->fmt.i_width;
-    unsigned sh = reg->fmt.i_height;
+    unsigned sw = pic->format.i_width;
+    unsigned sh = pic->format.i_height;
     xcb_rectangle_t rects[] = { { 0, 0, sw, sh }, };
 
     xcb_create_pixmap(conn, 32, sys->drawable.subpic, sys->root, sw, sh);


=====================================
src/misc/subpicture.c
=====================================
@@ -234,15 +234,24 @@ subpicture_region_t *subpicture_region_New( const video_format_t *p_fmt )
         return NULL;
 
     video_format_Copy( &p_region->fmt, p_fmt );
+    p_region->p_picture = picture_NewFromFormat( p_fmt );
+    if( !p_region->p_picture )
+    {
+        video_format_Clean( &p_region->fmt );
+        free( p_region );
+        return NULL;
+    }
+
     if ( p_fmt->i_chroma == VLC_CODEC_YUVP || p_fmt->i_chroma == VLC_CODEC_RGBP )
     {
         /* YUVP/RGBP should have a palette */
-        if( p_region->fmt.p_palette == NULL )
+        if( p_region->p_picture->format.p_palette == NULL )
         {
-            p_region->fmt.p_palette = calloc( 1, sizeof(*p_region->fmt.p_palette) );
-            if( p_region->fmt.p_palette == NULL )
+            p_region->p_picture->format.p_palette = calloc( 1, sizeof(*p_region->p_picture->format.p_palette) );
+            if( p_region->p_picture->format.p_palette == NULL )
             {
                 video_format_Clean( &p_region->fmt );
+                picture_Release( p_region->p_picture );
                 free( p_region );
                 return NULL;
             }
@@ -253,14 +262,6 @@ subpicture_region_t *subpicture_region_New( const video_format_t *p_fmt )
         assert(p_fmt->p_palette == NULL);
     }
 
-    p_region->p_picture = picture_NewFromFormat( p_fmt );
-    if( !p_region->p_picture )
-    {
-        video_format_Clean( &p_region->fmt );
-        free( p_region );
-        return NULL;
-    }
-
     return p_region;
 }
 
@@ -291,15 +292,15 @@ subpicture_region_t *subpicture_region_ForPicture( const video_format_t *p_fmt,
         p_fmt = &pic->format;
 
     video_format_Copy( &p_region->fmt, p_fmt );
-    if ( p_fmt->i_chroma == VLC_CODEC_YUVP || p_fmt->i_chroma == VLC_CODEC_RGBP )
+    if ( pic->format.i_chroma == VLC_CODEC_YUVP || pic->format.i_chroma == VLC_CODEC_RGBP )
     {
         /* YUVP/RGBP should have a palette */
-        if( p_region->fmt.p_palette == NULL )
+        if( pic->format.p_palette == NULL )
         {
-            p_region->fmt.p_palette = calloc( 1, sizeof(*p_region->fmt.p_palette) );
-            if( p_region->fmt.p_palette == NULL )
+            pic->format.p_palette = calloc( 1, sizeof(*pic->format.p_palette) );
+            if( pic->format.p_palette == NULL )
             {
-                video_format_Clean( &p_region->fmt );
+                video_format_Clean( &pic->format );
                 free( p_region );
                 return NULL;
             }
@@ -307,7 +308,7 @@ subpicture_region_t *subpicture_region_ForPicture( const video_format_t *p_fmt,
     }
     else
     {
-        assert(p_fmt->p_palette == NULL);
+        assert(pic->format.p_palette == NULL);
     }
 
     p_region->p_picture = picture_Hold(pic);
@@ -353,8 +354,17 @@ unsigned picture_BlendSubpicture(picture_t *dst,
     subpicture_region_t *r;
     vlc_spu_regions_foreach(r, &src->regions) {
         assert(r->p_picture && r->i_align == 0);
+
+        video_format_t blend_fmt = r->p_picture->format;
+        blend_fmt.i_x_offset = r->fmt.i_x_offset;
+        blend_fmt.i_y_offset = r->fmt.i_y_offset;
+        blend_fmt.i_visible_width = r->fmt.i_visible_width;
+        blend_fmt.i_visible_height = r->fmt.i_visible_height;
+        blend_fmt.i_sar_num = r->fmt.i_sar_num;
+        blend_fmt.i_sar_den = r->fmt.i_sar_den;
+
         if (filter_ConfigureBlend(blend, dst->format.i_width,
-                                  dst->format.i_height,  &r->fmt)
+                                  dst->format.i_height,  &blend_fmt)
          || filter_Blend(blend, dst, r->i_x, r->i_y, r->p_picture,
                          src->i_alpha * r->i_alpha / 255))
             msg_Err(blend, "blending %4.4s to %4.4s failed",


=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -863,7 +863,7 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
      * FIXME b_force_palette and force_crop are applied to all subpictures using palette
      * instead of only the right one (being the dvd spu).
      */
-    const bool using_palette = region->fmt.i_chroma == VLC_CODEC_YUVP;
+    const bool using_palette = region->p_picture->format.i_chroma == VLC_CODEC_YUVP;
     const bool force_palette = using_palette && sys->palette.i_entries > 0;
     const bool crop_requested = (force_palette && sys->force_crop) ||
                                 region->i_max_width || region->i_max_height;
@@ -942,10 +942,9 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
     if (unlikely(dst_width == 0 || dst_height == 0))
         return NULL;
 
-
     /* */
     if (force_palette) {
-        video_palette_t *old_palette = region->fmt.p_palette;
+        video_palette_t *old_palette = region->p_picture->format.p_palette;
         video_palette_t new_palette;
         bool b_opaque = false;
         bool b_old_opaque = false;
@@ -995,7 +994,7 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
 
     bool convert_chroma = true;
     for (int i = 0; chroma_list[i] && convert_chroma; i++) {
-        if (region->fmt.i_chroma == chroma_list[i])
+        if (region->p_picture->format.i_chroma == chroma_list[i])
             convert_chroma = false;
     }
 
@@ -1036,9 +1035,9 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
             if (using_palette) {
                 filter_t *scale_yuvp = sys->scale_yuvp;
 
-                scale_yuvp->fmt_in.video = region->fmt;
+                scale_yuvp->fmt_in.video = region->p_picture->format;
 
-                scale_yuvp->fmt_out.video = region->fmt;
+                scale_yuvp->fmt_out.video = region->p_picture->format;
                 scale_yuvp->fmt_out.video.i_chroma = chroma_list[0];
                 scale_yuvp->fmt_out.video.p_palette = NULL;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cea7e52bc1675ce15555819e9eecb9ac9a3f4cd2...ff385bcbab0ceddb2c9bdfd4c398b669da93a2a5

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