[vlc-commits] [Git][videolan/vlc][master] 2 commits: encoders: fill missing input format video chroma

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Dec 5 16:53:28 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b752a903 by Alaric Senat at 2023-12-05T16:28:45+00:00
encoders: fill missing input format video chroma

If an encoder requires a specific input chroma, it needs to be specified
in both the codec and the chroma field of the input format. The encoder
creators currently fix the input format themselves when an encoder does
not provide any chroma.

This input format fix was legitimately removed from VLC core's image API
which was causing regressions with the chroma converter attachment.

- - - - -
13c9d668 by Alaric Senat at 2023-12-05T16:28:45+00:00
daala: enc: remove redundant chroma initialization

The chroma is already setup later in the `Open` function.

- - - - -


11 changed files:

- modules/codec/daala.c
- modules/codec/dmo/dmo.c
- modules/codec/jpeg.c
- modules/codec/omxil/omxil.c
- modules/codec/rav1e.c
- modules/codec/rtpvideo.c
- modules/codec/schroedinger.c
- modules/codec/theora.c
- modules/codec/vpx.c
- modules/codec/x264.c
- modules/codec/x265.c


Changes:

=====================================
modules/codec/daala.c
=====================================
@@ -602,7 +602,6 @@ static int OpenEncoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
     p_enc->p_sys = p_sys;
 
-    p_enc->fmt_in.i_codec = VLC_CODEC_I420;
     p_enc->fmt_out.i_codec = VLC_CODEC_DAALA;
 
     config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );


=====================================
modules/codec/dmo/dmo.c
=====================================
@@ -1211,7 +1211,7 @@ static int EncoderSetVideoType( encoder_t *p_enc, IMediaObject *p_dmo )
 
     i_err = IMediaObject_SetOutputType( p_dmo, 0, &dmo_type, 0 );
 
-    p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+    p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = VLC_CODEC_I420;
 
     DMOFreeMediaType( &dmo_type );
     if( i_err )


=====================================
modules/codec/jpeg.c
=====================================
@@ -633,7 +633,7 @@ static int OpenEncoder(vlc_object_t *p_this)
     p_sys->i_quality = var_GetInteger(p_enc, ENC_CFG_PREFIX "quality");
     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_I420;
+    p_enc->fmt_in.i_codec = p_enc->fmt_in.video.i_chroma = VLC_CODEC_I420;
     p_enc->fmt_in.video.color_range = COLOR_RANGE_FULL;
 
     static const struct vlc_encoder_operations ops =


=====================================
modules/codec/omxil/omxil.c
=====================================
@@ -133,7 +133,8 @@ static OMX_ERRORTYPE ImplementationSpecificWorkarounds(decoder_t *p_dec,
         {
             /* I420 xvideo is slow on OMAP */
             def->format.video.eColorFormat = OMX_COLOR_FormatCbYCrY;
-            p_fmt->i_codec = GetVlcChromaFormat( def->format.video.eColorFormat );
+            p_fmt->i_codec =
+                p_fmt->video.i_chroma = GetVlcChromaFormat( def->format.video.eColorFormat );
             GetVlcChromaSizes( p_fmt->i_codec,
                                def->format.video.nFrameWidth,
                                def->format.video.nFrameHeight,


=====================================
modules/codec/rav1e.c
=====================================
@@ -221,18 +221,19 @@ static int OpenEncoder(vlc_object_t *this)
     {
         case 2:
             chroma_sampling = RA_CHROMA_SAMPLING_CS422;
-            enc->fmt_in.i_codec = bitdepth == 8 ? VLC_CODEC_I422 : VLC_CODEC_I422_10L;
+            enc->fmt_in.video.i_chroma = bitdepth == 8 ? VLC_CODEC_I422 : VLC_CODEC_I422_10L;
             break;
         case 1:
             chroma_sampling = RA_CHROMA_SAMPLING_CS444;
-            enc->fmt_in.i_codec = bitdepth == 8 ? VLC_CODEC_I444 : VLC_CODEC_I444_10L;
+            enc->fmt_in.video.i_chroma = bitdepth == 8 ? VLC_CODEC_I444 : VLC_CODEC_I444_10L;
             break;
         default:
         case 0:
             chroma_sampling = RA_CHROMA_SAMPLING_CS420;
-            enc->fmt_in.i_codec = bitdepth == 8 ? VLC_CODEC_I420 : VLC_CODEC_I420_10L;
+            enc->fmt_in.video.i_chroma = bitdepth == 8 ? VLC_CODEC_I420 : VLC_CODEC_I420_10L;
             break;
     }
+    enc->fmt_in.i_codec = enc->fmt_in.video.i_chroma;
 
     RaChromaSamplePosition sample_pos;
     switch (enc->fmt_in.video.chroma_location)


=====================================
modules/codec/rtpvideo.c
=====================================
@@ -54,7 +54,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     if( p_enc->fmt_out.i_codec != VLC_CODEC_R420 && !p_enc->obj.force )
         return VLC_EGENERIC;
 
-    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_out.i_codec = VLC_CODEC_R420;
 
     static const struct vlc_encoder_operations ops =


=====================================
modules/codec/schroedinger.c
=====================================
@@ -1014,21 +1014,21 @@ static inline bool SchroSetEnum( encoder_t *p_enc, int i_list_size, const char *
     return false;
 }
 
-static bool SetEncChromaFormat( encoder_t *p_enc, vlc_fourcc_t i_codec )
+static bool SetEncChromaFormat( encoder_t *p_enc, vlc_fourcc_t chroma )
 {
     encoder_sys_t *p_sys = p_enc->p_sys;
 
-    switch( i_codec ) {
+    switch( chroma ) {
     case VLC_CODEC_I420:
-        p_enc->fmt_in.i_codec = i_codec;
+        p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = chroma;
         p_sys->p_format->chroma_format = SCHRO_CHROMA_420;
         break;
     case VLC_CODEC_I422:
-        p_enc->fmt_in.i_codec = i_codec;
+        p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = chroma;
         p_sys->p_format->chroma_format = SCHRO_CHROMA_422;
         break;
     case VLC_CODEC_I444:
-        p_enc->fmt_in.i_codec = i_codec;
+        p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = chroma;
         p_sys->p_format->chroma_format = SCHRO_CHROMA_444;
         break;
     default:


=====================================
modules/codec/theora.c
=====================================
@@ -689,7 +689,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     if( ( p_sys = malloc(sizeof(encoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
 
-    p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+    p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = VLC_CODEC_I420;
     p_enc->fmt_out.i_codec = VLC_CODEC_THEORA;
 
     config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );


=====================================
modules/codec/vpx.c
=====================================
@@ -440,7 +440,7 @@ static int OpenEncoder(vlc_object_t *p_this)
         goto error;
     }
 
-    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;
     config_ChainParse(p_enc, ENC_CFG_PREFIX, ppsz_sout_options, p_enc->p_cfg);
 
     /* Deadline (in ms) to spend in encoder */


=====================================
modules/codec/x264.c
=====================================
@@ -808,17 +808,17 @@ static int  Open ( vlc_object_t *p_this )
 
         if( !strcmp( psz_profile, "high10" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I420_10L : VLC_CODEC_I420;
+            p_enc->fmt_in.video.i_chroma = mask ? VLC_CODEC_I420_10L : VLC_CODEC_I420;
             p_sys->i_colorspace = X264_CSP_I420 | mask;
         }
         else if( !strcmp( psz_profile, "high422" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I422_10L : VLC_CODEC_I422;
+            p_enc->fmt_in.video.i_chroma = mask ? VLC_CODEC_I422_10L : VLC_CODEC_I422;
             p_sys->i_colorspace = X264_CSP_I422 | mask;
         }
         else if( !strcmp( psz_profile, "high444" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I444_10L : VLC_CODEC_I444;
+            p_enc->fmt_in.video.i_chroma = mask ? VLC_CODEC_I444_10L : VLC_CODEC_I444;
             p_sys->i_colorspace = X264_CSP_I444 | mask;
         }
         else
@@ -828,7 +828,7 @@ static int  Open ( vlc_object_t *p_this )
             free( psz_profile );
             return VLC_EGENERIC;
 # else
-            p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+            p_enc->fmt_in.video.i_chroma = VLC_CODEC_I420;
             p_sys->i_colorspace = X264_CSP_I420;
 # endif
         }
@@ -840,11 +840,13 @@ static int  Open ( vlc_object_t *p_this )
         msg_Err( p_enc, "Only high-profiles and 10-bit are supported");
         return VLC_EGENERIC;
 # else
-        p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+        p_enc->fmt_in.video.i_chroma = VLC_CODEC_I420;
         p_sys->i_colorspace = X264_CSP_I420;
 # endif
     }
 
+    p_enc->fmt_in.i_codec = p_enc->fmt_in.video.i_chroma;
+
     p_sys->psz_stat_name = NULL;
     p_sys->i_sei_size = 0;
     p_sys->p_sei = NULL;


=====================================
modules/codec/x265.c
=====================================
@@ -147,7 +147,7 @@ static int  Open (vlc_object_t *p_this)
     if (!p_sys)
         return VLC_ENOMEM;
 
-    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;
 
     x265_param *param = &p_sys->param;
     x265_param_default(param);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/45c94e816731034117830a7e77784a49a1df1f66...13c9d6687e60f45d8f083c4f80e2e817519b2820

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/45c94e816731034117830a7e77784a49a1df1f66...13c9d6687e60f45d8f083c4f80e2e817519b2820
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