diff mbox

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

Message ID 20171124005134.5683-16-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson Nov. 24, 2017, 12:51 a.m. UTC
In particular, avoid selecting YV12/YV16 when I420/422H are available.
---
 libavutil/hwcontext_vaapi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jun Zhao Nov. 24, 2017, 8:28 a.m. UTC | #1
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 ?     
>  #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),
Mark Thompson Nov. 24, 2017, 1:06 p.m. UTC | #2
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
Carl Eugen Hoyos Nov. 24, 2017, 1:43 p.m. UTC | #3
2017-11-24 14:06 GMT+01:00 Mark Thompson <sw@jkqxz.net>:
> 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).

Is it not enough to set the codec_tag?

Carl Eugen
diff mbox

Patch

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),
 #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),