[FFmpeg-devel] [PATCH 24/31] av1/h264_metadata: Don't reinitialize data

Mark Thompson sw at jkqxz.net
Sun Jul 28 20:27:49 EEST 2019


On 20/06/2019 00:45, Andreas Rheinhardt wrote:
> If the relevant elements (the color description elements for AV1 and the
> VUI elements in general for H.264 (since 1156b507)) are absent, then their
> correct values (usually meaning unknown) have already been inferred by
> the reading process, so that it is unnecessary to initialize them again
> in the av1/h264_metadata filters even when they were initially absent.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/av1_metadata_bsf.c  |  7 +------
>  libavcodec/h264_metadata_bsf.c | 37 ++++++++++------------------------
>  2 files changed, 12 insertions(+), 32 deletions(-)
> 
> diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
> index 9345095277..7d9d15b1a0 100644
> --- a/libavcodec/av1_metadata_bsf.c
> +++ b/libavcodec/av1_metadata_bsf.c
> @@ -61,12 +61,7 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf,
>      if (ctx->color_primaries >= 0          ||
>          ctx->transfer_characteristics >= 0 ||
>          ctx->matrix_coefficients >= 0) {
> -        if (!clc->color_description_present_flag) {
> -            clc->color_description_present_flag = 1;
> -            clc->color_primaries          = AVCOL_PRI_UNSPECIFIED;
> -            clc->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
> -            clc->matrix_coefficients      = AVCOL_SPC_UNSPECIFIED;
> -        }
> +        clc->color_description_present_flag = 1;
>  
>          if (ctx->color_primaries >= 0)
>              clc->color_primaries = ctx->color_primaries;
> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
> index d760ee3182..40886bdde0 100644
> --- a/libavcodec/h264_metadata_bsf.c
> +++ b/libavcodec/h264_metadata_bsf.c
> @@ -122,13 +122,12 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
>          need_vui = 1;
>      }
>  
> -#define SET_OR_INFER(field, value, present_flag, infer) do { \
> -        if (value >= 0) { \
> -            field = value; \
> +#define SET_IF_SET(field) do { \

The name SET_IF_SET felt unnecessarily confusing, so I changed it to SET_VUI_FIELD.

Applied along with 20-22.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list