[FFmpeg-devel] [PATCH 16/17] hwcontext_vaapi: Move better-matching surface formats earlier

Mark Thompson sw at jkqxz.net
Fri Nov 24 15:06:53 EET 2017


On 24/11/17 08:28, Jun Zhao wrote:
> On 2017/11/24 8:51, Mark Thompson wrote:
>> In particular, avoid selecting YV12/YV16 when I420/422H are available.
>> ---
>>  libavutil/hwcontext_vaapi.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
>> index fcff25dc9b..2f47162a0d 100644
>> --- a/libavutil/hwcontext_vaapi.c
>> +++ b/libavutil/hwcontext_vaapi.c
>> @@ -99,15 +99,15 @@ static const struct {
>>      enum AVPixelFormat pix_fmt;
>>  } vaapi_format_map[] = {
>>      MAP(NV12, YUV420,  NV12),
>> -    MAP(YV12, YUV420,  YUV420P), // With U/V planes swapped.
>> -    MAP(IYUV, YUV420,  YUV420P),
>>  #ifdef VA_FOURCC_I420
>>      MAP(I420, YUV420,  YUV420P),
>>  #endif
>> +    MAP(YV12, YUV420,  YUV420P), // With U/V planes swapped.
>> +    MAP(IYUV, YUV420,  YUV420P),
>> +    MAP(422H, YUV422,  YUV422P),
> Can we give a flag or other field to identify the map priority, not use
> the hard code array index order ?

Well, really we need to add some way to control the layout for formats which are identical from the point of view of the CPU (that is, have the same enum AVPixelFormat).  The 4:2:2 cases make at least a little bit of sense like this, but more is definitely needed to distinguish all the IMC* formats for YUV420P.  A priority wouldn't change that.

(This is primarily intended as a simple hack to make 4:2:2 MJPEG decode work on Intel - it needs to choose 422H rather than YV16 for YUV422P.)

>>  #ifdef VA_FOURCC_YV16
>>      MAP(YV16, YUV422,  YUV422P), // With U/V planes swapped.
>>  #endif
>> -    MAP(422H, YUV422,  YUV422P),
>>      MAP(UYVY, YUV422,  UYVY422),
>>      MAP(YUY2, YUV422,  YUYV422),
>>      MAP(Y800, YUV400,  GRAY8),
> 

Thanks,

- Mark


More information about the ffmpeg-devel mailing list