[FFmpeg-devel] [PATCH 2/3] hwcontext_vaapi: Return error if can not find a VA RT format

Mark Thompson sw at jkqxz.net
Mon May 7 23:48:06 EEST 2018


On 04/05/18 15:41, Haihao Xiang wrote:
> Otherwise va_rt_format might be unitialized
> 
> Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
> ---
>  libavutil/hwcontext_vaapi.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 7daaa951cc..e59042487d 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1028,6 +1028,11 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst,
>              va_rt_format = vaapi_format_map[i].rt_format;
>      }
>  
> +    if (i >= FF_ARRAY_ELEMS(vaapi_format_map)) {
> +        av_log(dst_fc, AV_LOG_ERROR, "No matching VA RT format \n");
> +        return AVERROR(EINVAL);
> +    }
> +
>      buffer_handle = desc->objects[0].fd;
>      buffer_desc.pixel_format = va_fourcc;
>      buffer_desc.width        = src_fc->width;
> 

How would you hit this case?  Every fourcc in vaapi_drm_format_map is also present in vaapi_format_map.

- Mark


More information about the ffmpeg-devel mailing list