[vlc-commits] [Git][videolan/vlc][master] modules: reset mask after format copy+chroma change

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 24 11:44:34 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
50687096 by Steve Lhomme at 2023-08-24T11:05:01+00:00
modules: reset mask after format copy+chroma change

The original format may be using a chroma that relies on the RGB masks.
Since we change the chroma we should not reuse the mask from the previous
chroma.

- - - - -


15 changed files:

- modules/codec/arib/libaribcaption.c
- modules/codec/avcodec/d3d11va.c
- modules/codec/avcodec/dxva2.c
- modules/codec/avcodec/encoder.c
- modules/codec/avcodec/video.c
- modules/codec/jpeg.c
- modules/codec/oggspots.c
- modules/codec/png.c
- modules/codec/qsv.c
- modules/codec/rtp-rawvid.c
- modules/hw/d3d9/dxa9.c
- modules/hw/nvdec/nvdec.c
- modules/hw/nvdec/nvdec_gl.c
- modules/stream_out/mosaic_bridge.c
- modules/stream_out/renderer_common.cpp


Changes:

=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -164,6 +164,9 @@ static void SubpictureUpdate(subpicture_t *p_subpic,
 
     video_format_t  fmt = *p_dst_format;
     fmt.i_chroma         = VLC_CODEC_RGBA;
+    fmt.i_rmask          = 0;
+    fmt.i_gmask          = 0;
+    fmt.i_bmask          = 0;
     fmt.i_bits_per_pixel = 0;
     fmt.i_x_offset       = 0;
     fmt.i_y_offset       = 0;


=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -283,6 +283,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt, con
     }
 
     final_fmt.i_chroma = sys->render_fmt->fourcc;
+    final_fmt.i_rmask = final_fmt.i_gmask = final_fmt.i_bmask = 0;
+    video_format_FixRgb(&final_fmt);
     err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &final_fmt, sys->hw.surface_count);
     if (err != VLC_SUCCESS)
         goto error;


=====================================
modules/codec/avcodec/dxva2.c
=====================================
@@ -303,6 +303,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum AVPixelFormat hwfmt, con
         final_fmt.i_chroma = VLC_CODEC_D3D9_OPAQUE_10B;
     else
         final_fmt.i_chroma = VLC_CODEC_D3D9_OPAQUE;
+    final_fmt.i_rmask = final_fmt.i_gmask = final_fmt.i_bmask = 0;
     err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &final_fmt, sys->hw.surface_count);
     if (err != VLC_SUCCESS)
         goto error;


=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -559,13 +559,19 @@ int InitVideoEnc( vlc_object_t *p_this )
                    p_enc->fmt_in.video.i_sar_den, 1 << 30 );
 
 
-        p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+        p_enc->fmt_in.i_codec =
+        p_enc->fmt_in.video.i_chroma = VLC_CODEC_I420;
+        p_enc->fmt_in.video.i_rmask = 0;
+        p_enc->fmt_in.video.i_gmask = 0;
+        p_enc->fmt_in.video.i_bmask = 0;
 
         /* Very few application support YUV in TIFF, not even VLC */
         if( p_enc->fmt_out.i_codec == VLC_CODEC_TIFF )
-            p_enc->fmt_in.i_codec = VLC_CODEC_RGB24;
+        {
+            p_enc->fmt_in.i_codec =
+            p_enc->fmt_in.video.i_chroma = VLC_CODEC_RGB24;
+        }
 
-        p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec;
         p_context->pix_fmt = GetFfmpegChroma( &p_enc->fmt_in.video );
 
         if( p_codec->pix_fmts )


=====================================
modules/codec/avcodec/video.c
=====================================
@@ -1459,6 +1459,9 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             assert( frame->data[1] != NULL );
             lavc_Frame8PaletteCopy( p_palette, frame->data[1] );
             p_dec->fmt_out.video.i_chroma = VLC_CODEC_RGBP;
+            p_dec->fmt_out.video.i_rmask = 0;
+            p_dec->fmt_out.video.i_gmask = 0;
+            p_dec->fmt_out.video.i_bmask = 0;
             if( decoder_UpdateVideoFormat( p_dec ) )
             {
                 vlc_mutex_unlock(&p_sys->lock);


=====================================
modules/codec/jpeg.c
=====================================
@@ -186,13 +186,16 @@ static int OpenDecoder(vlc_object_t *p_this)
     /* Set callbacks */
     p_dec->pf_decode = DecodeBlock;
 
-    p_dec->fmt_out.video.i_chroma =
-    p_dec->fmt_out.i_codec = VLC_CODEC_RGB24;
+    p_dec->fmt_out.i_codec =
+    p_dec->fmt_out.video.i_chroma = VLC_CODEC_RGB24;
+    p_dec->fmt_out.video.i_rmask = 0;
+    p_dec->fmt_out.video.i_gmask = 0;
+    p_dec->fmt_out.video.i_bmask = 0;
+    video_format_FixRgb(&p_dec->fmt_out.video);
     p_dec->fmt_out.video.transfer  = TRANSFER_FUNC_SRGB;
     p_dec->fmt_out.video.space     = COLOR_SPACE_SRGB;
     p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_SRGB;
     p_dec->fmt_out.video.color_range = COLOR_RANGE_FULL;
-    video_format_FixRgb(&p_dec->fmt_out.video);
 
     return VLC_SUCCESS;
 }


=====================================
modules/codec/oggspots.c
=====================================
@@ -354,9 +354,15 @@ static picture_t* DecodePacket(decoder_t* p_dec, block_t* p_block)
     es_format_t fmt_in = *p_dec->fmt_in;
     if ( !memcmp(&p_block->p_buffer[4], "PNG", 3) ) {
         fmt_in.video.i_chroma = VLC_CODEC_PNG;
+        fmt_in.video.i_rmask = 0;
+        fmt_in.video.i_gmask = 0;
+        fmt_in.video.i_bmask = 0;
     }
     else if ( !memcmp(&p_block->p_buffer[4], "JPEG", 4) ) {
         fmt_in.video.i_chroma = VLC_CODEC_JPEG;
+        fmt_in.video.i_rmask = 0;
+        fmt_in.video.i_gmask = 0;
+        fmt_in.video.i_bmask = 0;
     }
     else {
         char psz_image_type[8+1];


=====================================
modules/codec/png.c
=====================================
@@ -428,7 +428,10 @@ static int OpenEncoder(vlc_object_t *p_this)
     p_sys->i_blocksize = 3 * p_enc->fmt_in.video.i_visible_width *
         p_enc->fmt_in.video.i_visible_height;
 
-    p_enc->fmt_in.i_codec = VLC_CODEC_RGB24;
+    p_enc->fmt_in.i_codec =
+    p_enc->fmt_in.video.i_chroma =  VLC_CODEC_RGB24;
+    p_enc->fmt_in.video.i_rmask = 0;
+    p_enc->fmt_in.video.i_gmask = 0;
     p_enc->fmt_in.video.i_bmask = 0;
     video_format_FixRgb( &p_enc->fmt_in.video );
 


=====================================
modules/codec/qsv.c
=====================================
@@ -617,8 +617,11 @@ static int Open(vlc_object_t *this)
     sys->async_depth = sys->params.AsyncDepth;
 
     /* Vlc module configuration */
-    enc->fmt_in.i_codec                = VLC_CODEC_NV12; // Intel Media SDK requirement
-    enc->fmt_in.video.i_chroma         = VLC_CODEC_NV12;
+    enc->fmt_in.i_codec =
+    enc->fmt_in.video.i_chroma  = VLC_CODEC_NV12; // Intel Media SDK requirement
+    enc->fmt_in.video.i_rmask = 0;
+    enc->fmt_in.video.i_gmask = 0;
+    enc->fmt_in.video.i_bmask = 0;
     enc->fmt_in.video.i_bits_per_pixel = 12;
     // require aligned pictures on input, a filter may be added before the encoder
     enc->fmt_in.video.i_width          = sys->params.mfx.FrameInfo.Width;


=====================================
modules/codec/rtp-rawvid.c
=====================================
@@ -839,6 +839,9 @@ static int Open(vlc_object_t *obj)
     es_format_Copy(&dec->fmt_out, dec->fmt_in);
     dec->fmt_out.i_codec = format->fourcc;
     dec->fmt_out.video.i_chroma = format->fourcc;
+    dec->fmt_out.video.i_rmask = 0;
+    dec->fmt_out.video.i_gmask = 0;
+    dec->fmt_out.video.i_bmask = 0;
 
     int ret = decoder_UpdateVideoFormat(dec);
     if (ret != VLC_SUCCESS)


=====================================
modules/hw/d3d9/dxa9.c
=====================================
@@ -212,6 +212,9 @@ static filter_t *CreateFilter( filter_t *p_this, const es_format_t *p_fmt_in,
     es_format_InitFromVideo( &p_filter->fmt_in,  &p_fmt_in->video );
     es_format_InitFromVideo( &p_filter->fmt_out, &p_fmt_in->video );
     p_filter->fmt_out.i_codec = p_filter->fmt_out.video.i_chroma = dst_chroma;
+    p_filter->fmt_out.video.i_rmask = 0;
+    p_filter->fmt_out.video.i_gmask = 0;
+    p_filter->fmt_out.video.i_bmask = 0;
     p_filter->p_module = module_need( p_filter, "video converter", NULL, false );
 
     if( !p_filter->p_module )
@@ -350,6 +353,7 @@ static picture_t *AllocateCPUtoGPUTexture(filter_t *p_filter)
 
     video_format_Copy(&fmt_staging, &p_filter->fmt_out.video);
     fmt_staging.i_chroma = format;
+    fmt_staging.i_rmask = fmt_staging.i_gmask = fmt_staging.i_bmask = 0;
 
     picture_resource_t dummy_res = { .p_sys = NULL };
     picture_t *p_dst = picture_NewFromResource(&fmt_staging, &dummy_res);


=====================================
modules/hw/nvdec/nvdec.c
=====================================
@@ -1000,6 +1000,9 @@ static int OpenDecoder(vlc_object_t *p_this)
     for (chroma_idx = 0; output_chromas[chroma_idx] != 0; chroma_idx++)
     {
         p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma = output_chromas[chroma_idx];
+        p_dec->fmt_out.video.i_rmask = 0;
+        p_dec->fmt_out.video.i_gmask = 0;
+        p_dec->fmt_out.video.i_bmask = 0;
         result = decoder_UpdateVideoOutput(p_dec, p_sys->vctx_out);
         if (result == 0)
         {


=====================================
modules/hw/nvdec/nvdec_gl.c
=====================================
@@ -290,6 +290,9 @@ static int Open(vlc_object_t *obj)
     }
 
     interop->fmt_out.i_chroma = render_chroma;
+    interop->fmt_out.i_rmask = 0;
+    interop->fmt_out.i_gmask = 0;
+    interop->fmt_out.i_bmask = 0;
     interop->fmt_out.space = interop->fmt_in.space;
 
     static const struct vlc_gl_interop_ops ops = {


=====================================
modules/stream_out/mosaic_bridge.c
=====================================
@@ -641,6 +641,8 @@ static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vct
             if( p_sys->i_chroma )
             {
                 fmt.video.i_chroma = p_sys->i_chroma;
+                fmt.video.i_rmask = fmt.video.i_gmask = fmt.video.i_bmask = 0;
+                video_format_FixRgb( &fmt.video );
                 vctx = NULL; // CPU chroma, no video context
             }
             filter_chain_Reset( p_sys->p_vf2, &fmt, vctx, &fmt );


=====================================
modules/stream_out/renderer_common.cpp
=====================================
@@ -112,7 +112,9 @@ GetVencOption( sout_stream_t *p_stream, std::vector<vlc_fourcc_t> codecs,
 
                 es_format_t fmt;
                 es_format_InitFromVideo( &fmt, p_vid );
-                fmt.i_codec = fmt.video.i_chroma = VLC_CODEC_I420;
+                fmt.i_codec =
+                fmt.video.i_chroma = VLC_CODEC_I420;
+                fmt.video.i_rmask = fmt.video.i_gmask = fmt.video.i_bmask = 0;
 
                 /* Test the maximum size/fps we will encode */
                 fmt.video.i_visible_width = fmt.video.i_width = 1920;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/50687096c20fbeb79bd1f689a0b901e87acc1afc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/50687096c20fbeb79bd1f689a0b901e87acc1afc
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