[FFmpeg-devel] [PATCH 1/2] lavfi/vaapi: check avaliable before set color properties

Mark Thompson sw at jkqxz.net
Sun Apr 26 21:09:31 EEST 2020


On 26/04/2020 04:02, Fei Wang wrote:
> If the color proerties is UNSPECIFIED(enum value is 2), do not pass
> the invalid value to driver.
> 
> Signed-off-by: Fei Wang <fei.w.wang at intel.com>
> ---
>  libavfilter/vaapi_vpp.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> index b5b245c..6ffc09d 100644
> --- a/libavfilter/vaapi_vpp.c
> +++ b/libavfilter/vaapi_vpp.c
> @@ -493,18 +493,18 @@ static int vaapi_vpp_colour_properties(AVFilterContext *avctx,
>          .chroma_sample_location   = input_props.va_chroma_sample_location,
>          .color_range              = input_props.va_color_range,
>  #if VA_CHECK_VERSION(1, 3, 0)
> -        .colour_primaries         = input_props.color_primaries,
> -        .transfer_characteristics = input_props.color_trc,
> -        .matrix_coefficients      = input_props.colorspace,
> +        .colour_primaries         = (input_props.color_primaries == AVCOL_PRI_UNSPECIFIED ? 0 : input_props.color_primaries),
> +        .transfer_characteristics = (input_props.color_trc == AVCOL_TRC_UNSPECIFIED ? 0 : input_props.color_trc),
> +        .matrix_coefficients      = (input_props.colorspace == AVCOL_SPC_UNSPECIFIED ? 0 : input_props.colorspace),
>  #endif
>      };
>      params->output_color_properties = (VAProcColorProperties) {
>          .chroma_sample_location   = output_props.va_chroma_sample_location,
>          .color_range              = output_props.va_color_range,
>  #if VA_CHECK_VERSION(1, 3, 0)
> -        .colour_primaries         = output_props.color_primaries,
> -        .transfer_characteristics = output_props.color_trc,
> -        .matrix_coefficients      = output_props.colorspace,
> +        .colour_primaries         = (input_props.color_primaries == AVCOL_PRI_UNSPECIFIED ? 0 : input_props.color_primaries),
> +        .transfer_characteristics = (input_props.color_trc == AVCOL_TRC_UNSPECIFIED ? 0 : input_props.color_trc),
> +        .matrix_coefficients      = (input_props.colorspace == AVCOL_SPC_UNSPECIFIED ? 0 : input_props.colorspace),
>  #endif
>      };
>  #endif

Um, unspecified (that is, 2) should be exactly what we want when we don't know what it should be?  Zero is reserved for future use by H.273 / ISO-whatever-it-is, so zero is not valid.

- Mark


More information about the ffmpeg-devel mailing list