[vlc-devel] [PATCH 1/2] packetizer: av1: provide the OBU chroma

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 10 11:19:46 CEST 2020


Forgot to add the v2.

Changes in v2:
- remove the bitdepth callback
- combine the subsampling and bitdepth into the proper VLC chroma
- call decoder_UpdateVideoFormat() in Open if we could determine the 
proper chroma

On 2020-09-10 11:17, Steve Lhomme wrote:
> The VLC chroma contains both the subsampling and the bitdepth.
> 
> VLC_CODEC_GREY* is used for monochrome.
> ---
>   modules/packetizer/av1_obu.c | 61 ++++++++++++++++++++++++++++++++++++
>   modules/packetizer/av1_obu.h |  1 +
>   2 files changed, 62 insertions(+)
> 
> diff --git a/modules/packetizer/av1_obu.c b/modules/packetizer/av1_obu.c
> index 9778beb2123..e99172bc23f 100644
> --- a/modules/packetizer/av1_obu.c
> +++ b/modules/packetizer/av1_obu.c
> @@ -158,6 +158,8 @@ struct av1_color_config_s
>       obu_u1_t subsampling_y;
>       obu_u2_t chroma_sample_position;
>       obu_u1_t separate_uv_delta_q;
> +
> +    vlc_fourcc_t i_chroma;
>   };
>   
>   static bool av1_parse_color_config(bs_t *p_bs,
> @@ -191,12 +193,14 @@ static bool av1_parse_color_config(bs_t *p_bs,
>       if(p_cc->mono_chrome)
>       {
>           p_cc->color_range = bs_read1(p_bs) ? COLOR_RANGE_FULL : COLOR_RANGE_LIMITED;
> +        p_cc->i_chroma = VLC_CODEC_GREY;
>       }
>       else if( p_cc->color_primaries == 1 &&
>                p_cc->transfer_characteristics == 13 &&
>                p_cc->matrix_coefficients == 0 )
>       {
>           p_cc->color_range = COLOR_RANGE_FULL;
> +        p_cc->i_chroma = VLC_CODEC_I444;
>       }
>       else
>       {
> @@ -213,7 +217,16 @@ static bool av1_parse_color_config(bs_t *p_bs,
>               {
>                   p_cc->subsampling_x = 1;
>               }
> +            p_cc->i_chroma = p_cc->subsampling_x ?
> +                             p_cc->subsampling_y ? VLC_CODEC_I420 :
> +                                                   VLC_CODEC_I422 :
> +                                                   VLC_CODEC_I444;
>           }
> +        else if(seq_profile == 1)
> +            p_cc->i_chroma = VLC_CODEC_I444;
> +        else
> +            p_cc->i_chroma = VLC_CODEC_I420;
> +
>           if(p_cc->subsampling_x && p_cc->subsampling_y)
>               p_cc->chroma_sample_position = bs_read(p_bs, 2);
>       }
> @@ -544,6 +557,54 @@ bool AV1_get_colorimetry(const av1_OBU_sequence_header_t *p_seq,
>       return true;
>   }
>   
> +vlc_fourcc_t AV1_get_chroma(const av1_OBU_sequence_header_t *p_seq)
> +{
> +    switch (p_seq->color_config.i_chroma)
> +    {
> +        case VLC_CODEC_GREY:
> +            switch (p_seq->color_config.high_bitdepth + p_seq->color_config.twelve_bit)
> +            {
> +                case 0: return VLC_CODEC_GREY;
> +                case 1: return VLC_CODEC_GREY_10L;
> +                case 2: return VLC_CODEC_GREY_12L;
> +                default:
> +                    vlc_assert_unreachable();
> +            }
> +            break;
> +        case VLC_CODEC_I420:
> +            switch (p_seq->color_config.high_bitdepth + p_seq->color_config.twelve_bit)
> +            {
> +                case 0: return VLC_CODEC_I420;
> +                case 1: return VLC_CODEC_I420_10L;
> +                case 2: return VLC_CODEC_I420_12L;
> +                default:
> +                    vlc_assert_unreachable();
> +            }
> +            break;
> +        case VLC_CODEC_I422:
> +            switch (p_seq->color_config.high_bitdepth + p_seq->color_config.twelve_bit)
> +            {
> +                case 0: return VLC_CODEC_I422;
> +                case 1: return VLC_CODEC_I422_10L;
> +                case 2: return VLC_CODEC_I422_12L;
> +                default:
> +                    vlc_assert_unreachable();
> +            }
> +            break;
> +        case VLC_CODEC_I444:
> +            switch (p_seq->color_config.high_bitdepth + p_seq->color_config.twelve_bit)
> +            {
> +                case 0: return VLC_CODEC_I444;
> +                case 1: return VLC_CODEC_I444_10L;
> +                case 2: return VLC_CODEC_I444_12L;
> +                default:
> +                    vlc_assert_unreachable();
> +            }
> +        default:
> +            vlc_assert_unreachable();
> +    }
> +}
> +
>   size_t AV1_create_DecoderConfigurationRecord(uint8_t **pp_buffer,
>                                                const av1_OBU_sequence_header_t *p_seq,
>                                                size_t i_obu, const uint8_t *p_obus[],
> diff --git a/modules/packetizer/av1_obu.h b/modules/packetizer/av1_obu.h
> index b3082a759d2..0debe0db576 100644
> --- a/modules/packetizer/av1_obu.h
> +++ b/modules/packetizer/av1_obu.h
> @@ -167,6 +167,7 @@ bool AV1_get_colorimetry( const av1_OBU_sequence_header_t *,
>                             video_color_primaries_t *, video_transfer_func_t *,
>                             video_color_space_t *, video_color_range_t *);
>   bool AV1_get_frame_rate(const av1_OBU_sequence_header_t *, unsigned *, unsigned *);
> +vlc_fourcc_t AV1_get_chroma(const av1_OBU_sequence_header_t *);
>   
>   
>   
> -- 
> 2.26.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list