diff mbox series

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

Message ID 1587870176-1441-1-git-send-email-fei.w.wang@intel.com
State New
Headers show
Series [FFmpeg-devel,1/2] lavfi/vaapi: check avaliable before set color properties
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Fei Wang April 26, 2020, 3:02 a.m. UTC
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@intel.com>
---
 libavfilter/vaapi_vpp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Mark Thompson April 26, 2020, 6:09 p.m. UTC | #1
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@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
diff mbox series

Patch

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