[FFmpeg-devel,1/5] lavu/pixfmt: add Y210/AYUV/Y410 pixel formats

Submitted by Linjie Fu on June 28, 2019, 2:26 a.m.

Details

Message ID 1561688806-32187-1-git-send-email-linjie.fu@intel.com
State New
Headers show

Commit Message

Linjie Fu June 28, 2019, 2:26 a.m.
Previously, media driver provided planar format(like 420 8 bit), but
for HEVC Range Extension (422/444 8/10 bit), the decoded image is
produced in packed format.

Y210/AYUV/Y410 are packed formats which are needed in HEVC Rext decoding
for both VAAPI and QSV:
    - Y210: 422 10 BIT
    - AYUV: 444  8 BIT
    - Y410: 444 10 BIT

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavutil/pixdesc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/pixfmt.h  |  6 ++++++
 libavutil/version.h |  2 +-
 3 files changed, 69 insertions(+), 1 deletion(-)

Comments

James Almer June 27, 2019, 2:33 p.m.
On 6/27/2019 11:26 PM, Linjie Fu wrote:
> Previously, media driver provided planar format(like 420 8 bit), but
> for HEVC Range Extension (422/444 8/10 bit), the decoded image is
> produced in packed format.
> 
> Y210/AYUV/Y410 are packed formats which are needed in HEVC Rext decoding
> for both VAAPI and QSV:
>     - Y210: 422 10 BIT
>     - AYUV: 444  8 BIT
>     - Y410: 444 10 BIT
> 
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
>  libavutil/pixdesc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/pixfmt.h  |  6 ++++++
>  libavutil/version.h |  2 +-
>  3 files changed, 69 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index b97b066..bde49f9 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -205,6 +205,68 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
>              { 0, 4, 1, 0, 8, 3, 7, 2 },        /* V */
>          },
>      },
> +    [AV_PIX_FMT_Y210LE] = {
> +        .name = "y210le",
> +        .nb_components = 3,
> +        .log2_chroma_w = 1,
> +        .log2_chroma_h = 0,
> +        .comp = {
> +            { 0, 4, 0, 6, 10, 1, 9, 1 },        /* Y */
> +            { 0, 8, 1, 6, 10, 3, 9, 2 },        /* U */
> +            { 0, 8, 3, 6, 10, 3, 9, 4 },        /* V */
> +        },
> +        .flags = AV_PIX_FMT_FLAG_ALPHA,
> +    },
> +    [AV_PIX_FMT_Y210BE] = {
> +        .name = "y210be",
> +        .nb_components = 3,
> +        .log2_chroma_w = 1,
> +        .log2_chroma_h = 0,
> +        .comp = {
> +            { 0, 4, 0, 6, 10, 1, 9, 1 },        /* Y */
> +            { 0, 8, 1, 6, 10, 3, 9, 2 },        /* U */
> +            { 0, 8, 3, 6, 10, 3, 9, 4 },        /* V */
> +        },
> +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
> +    },
> +    [AV_PIX_FMT_AYUV] = {
> +        .name = "ayuv",
> +        .nb_components = 4,
> +        .log2_chroma_w = 0,
> +        .log2_chroma_h = 0,
> +        .comp = {
> +            { 0, 4, 1, 0, 8, 3, 7, 2 },        /* Y */
> +            { 0, 4, 2, 0, 8, 3, 7, 1 },        /* U */
> +            { 0, 4, 3, 0, 8, 3, 7, 3 },        /* V */
> +            { 0, 4, 0, 0, 8, 3, 7, 4 },        /* A */
> +        },
> +    },
> +    [AV_PIX_FMT_Y410LE] = {
> +        .name = "y410le",
> +        .nb_components = 4,
> +        .log2_chroma_w = 0,
> +        .log2_chroma_h = 0,
> +        .comp = {
> +            { 0, 4, 1, 0, 10, 3, 9, 2 },        /* Y */
> +            { 0, 4, 0, 0, 10, 3, 9, 1 },        /* U */
> +            { 0, 4, 2, 0, 10, 3, 9, 3 },        /* V */
> +            { 0, 4, 3, 0,  2, 3, 1, 4 },        /* A */
> +        },
> +        .flags = AV_PIX_FMT_FLAG_ALPHA,
> +    },
> +    [AV_PIX_FMT_Y410BE] = {
> +        .name = "y410be",
> +        .nb_components = 4,
> +        .log2_chroma_w = 0,
> +        .log2_chroma_h = 0,
> +        .comp = {
> +            { 0, 4, 1, 0, 10, 3, 9, 2 },        /* Y */
> +            { 0, 4, 0, 0, 10, 3, 9, 1 },        /* U */
> +            { 0, 4, 2, 0, 10, 3, 9, 3 },        /* V */
> +            { 0, 4, 3, 0,  2, 3, 1, 4 },        /* A */
> +        },
> +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
> +    },
>      [AV_PIX_FMT_RGB24] = {
>          .name = "rgb24",
>          .nb_components = 3,
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 8b54c94..6a6a36a 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -209,6 +209,12 @@ enum AVPixelFormat {
>  
>      AV_PIX_FMT_YVYU422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
>  
> +    AV_PIX_FMT_Y210LE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, little-endian
> +    AV_PIX_FMT_Y210BE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-endian
> +    AV_PIX_FMT_AYUV,      ///< packed YUV 4:4:4, 32bpp,  A Y Cb Cr
> +    AV_PIX_FMT_Y410LE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, little-endian
> +    AV_PIX_FMT_Y410BE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, big-endian

This is an ABI break, as you're shifting the enum values for every entry
under these.

You need to add new values at the end, right above AV_PIX_FMT_NB.

> +
>      AV_PIX_FMT_YA16BE,       ///< 16 bits gray, 16 bits alpha (big-endian)
>      AV_PIX_FMT_YA16LE,       ///< 16 bits gray, 16 bits alpha (little-endian)
>  
> diff --git a/libavutil/version.h b/libavutil/version.h
> index dccbb38..e16b93e 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  29
> +#define LIBAVUTIL_VERSION_MINOR  30
>  #define LIBAVUTIL_VERSION_MICRO 100
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
>
Linjie Fu June 27, 2019, 2:41 p.m.
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of James Almer

> Sent: Thursday, June 27, 2019 22:33

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH 1/5] lavu/pixfmt: add Y210/AYUV/Y410

> pixel formats

> 

> > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h

> > index 8b54c94..6a6a36a 100644

> > --- a/libavutil/pixfmt.h

> > +++ b/libavutil/pixfmt.h

> > @@ -209,6 +209,12 @@ enum AVPixelFormat {

> >

> >      AV_PIX_FMT_YVYU422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb

> >

> > +    AV_PIX_FMT_Y210LE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, little-

> endian

> > +    AV_PIX_FMT_Y210BE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-

> endian

> > +    AV_PIX_FMT_AYUV,      ///< packed YUV 4:4:4, 32bpp,  A Y Cb Cr

> > +    AV_PIX_FMT_Y410LE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, little-

> endian

> > +    AV_PIX_FMT_Y410BE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, big-

> endian

> 

> This is an ABI break, as you're shifting the enum values for every entry

> under these.

> 

> You need to add new values at the end, right above AV_PIX_FMT_NB.

> 

Oh yes ABI break.
will follow, thanks.
Carl Eugen Hoyos June 27, 2019, 6:40 p.m.
Am Do., 27. Juni 2019 um 16:28 Uhr schrieb Linjie Fu <linjie.fu@intel.com>:
>
> Previously, media driver provided planar format(like 420 8 bit), but
> for HEVC Range Extension (422/444 8/10 bit), the decoded image
> is produced in packed format.

(The question "why" and the answer "because Windows expects it"
come to mind.)

> Y210/AYUV/Y410 are packed formats which are needed in HEVC
> Rext decoding for both VAAPI and QSV:
>     - Y210: 422 10 BIT
>     - AYUV: 444  8 BIT
>     - Y410: 444 10 BIT

Could you explain the relation between an alpha channel and hevc?

Imo, for this patch to be acceptable, a conversion function in
libswscale is needed.

Thank you, Carl Eugen
James Darnley June 27, 2019, 11:19 p.m.
On 2019-06-28 04:26, Linjie Fu wrote:
> Previously, media driver provided planar format(like 420 8 bit), but
> for HEVC Range Extension (422/444 8/10 bit), the decoded image is
> produced in packed format.
> 
> Y210/AYUV/Y410 are packed formats which are needed in HEVC Rext decoding
> for both VAAPI and QSV:
>     - Y210: 422 10 BIT
>     - AYUV: 444  8 BIT
>     - Y410: 444 10 BIT
> 


Why am I suspicious that at least one of those is a re-ordered v210?  I
seem to recall that we rejected adding v210 to this list.  Either they
don't belong in this list or they don't belong because libavcodec has a
proper decoder (at least for v210).

This might be the thread I was remembering but March seems too recent
> https://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/241549.html

No real conclusion was reached there.

Do bit-packed formats belong in an AVPixelFormat?
Hendrik Leppkes June 28, 2019, 1:03 a.m.
On Fri, Jun 28, 2019 at 1:26 AM James Darnley <james.darnley@gmail.com> wrote:
>
> On 2019-06-28 04:26, Linjie Fu wrote:
> > Previously, media driver provided planar format(like 420 8 bit), but
> > for HEVC Range Extension (422/444 8/10 bit), the decoded image is
> > produced in packed format.
> >
> > Y210/AYUV/Y410 are packed formats which are needed in HEVC Rext decoding
> > for both VAAPI and QSV:
> >     - Y210: 422 10 BIT
> >     - AYUV: 444  8 BIT
> >     - Y410: 444 10 BIT
> >
>
>
> Why am I suspicious that at least one of those is a re-ordered v210?  I
> seem to recall that we rejected adding v210 to this list.  Either they
> don't belong in this list or they don't belong because libavcodec has a
> proper decoder (at least for v210).
>

They are not quite as bad as v210 (and not related).

Microsoft documents them here as the recommended formats to be used on Windows:
https://docs.microsoft.com/en-us/windows/desktop/medfound/recommended-8-bit-yuv-formats-for-video-rendering#444-formats-32-bits-per-pixel
https://docs.microsoft.com/en-us/windows/desktop/medfound/10-bit-and-16-bit-yuv-video-formats

- Hendrik
James Darnley June 28, 2019, 9:47 a.m.
On 2019-06-28 03:03, Hendrik Leppkes wrote:
> On Fri, Jun 28, 2019 at 1:26 AM James Darnley <james.darnley@gmail.com> wrote:
>>
>> On 2019-06-28 04:26, Linjie Fu wrote:
>>> Previously, media driver provided planar format(like 420 8 bit), but
>>> for HEVC Range Extension (422/444 8/10 bit), the decoded image is
>>> produced in packed format.
>>>
>>> Y210/AYUV/Y410 are packed formats which are needed in HEVC Rext decoding
>>> for both VAAPI and QSV:
>>>     - Y210: 422 10 BIT
>>>     - AYUV: 444  8 BIT
>>>     - Y410: 444 10 BIT
>>>
>>
>>
>> Why am I suspicious that at least one of those is a re-ordered v210?  I
>> seem to recall that we rejected adding v210 to this list.  Either they
>> don't belong in this list or they don't belong because libavcodec has a
>> proper decoder (at least for v210).
>>
> 
> They are not quite as bad as v210 (and not related).
> 
> Microsoft documents them here as the recommended formats to be used on Windows:
> https://docs.microsoft.com/en-us/windows/desktop/medfound/recommended-8-bit-yuv-formats-for-video-rendering#444-formats-32-bits-per-pixel
> https://docs.microsoft.com/en-us/windows/desktop/medfound/10-bit-and-16-bit-yuv-video-formats
> 
> - Hendrik

Okay y410 and y210 use the highest 10 bits in each 16-bit word.  I
apologise for jumping to that conclusion.

Patch hide | download patch | download mbox

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index b97b066..bde49f9 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -205,6 +205,68 @@  static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
             { 0, 4, 1, 0, 8, 3, 7, 2 },        /* V */
         },
     },
+    [AV_PIX_FMT_Y210LE] = {
+        .name = "y210le",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 6, 10, 1, 9, 1 },        /* Y */
+            { 0, 8, 1, 6, 10, 3, 9, 2 },        /* U */
+            { 0, 8, 3, 6, 10, 3, 9, 4 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_ALPHA,
+    },
+    [AV_PIX_FMT_Y210BE] = {
+        .name = "y210be",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 6, 10, 1, 9, 1 },        /* Y */
+            { 0, 8, 1, 6, 10, 3, 9, 2 },        /* U */
+            { 0, 8, 3, 6, 10, 3, 9, 4 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
+    },
+    [AV_PIX_FMT_AYUV] = {
+        .name = "ayuv",
+        .nb_components = 4,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 1, 0, 8, 3, 7, 2 },        /* Y */
+            { 0, 4, 2, 0, 8, 3, 7, 1 },        /* U */
+            { 0, 4, 3, 0, 8, 3, 7, 3 },        /* V */
+            { 0, 4, 0, 0, 8, 3, 7, 4 },        /* A */
+        },
+    },
+    [AV_PIX_FMT_Y410LE] = {
+        .name = "y410le",
+        .nb_components = 4,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 1, 0, 10, 3, 9, 2 },        /* Y */
+            { 0, 4, 0, 0, 10, 3, 9, 1 },        /* U */
+            { 0, 4, 2, 0, 10, 3, 9, 3 },        /* V */
+            { 0, 4, 3, 0,  2, 3, 1, 4 },        /* A */
+        },
+        .flags = AV_PIX_FMT_FLAG_ALPHA,
+    },
+    [AV_PIX_FMT_Y410BE] = {
+        .name = "y410be",
+        .nb_components = 4,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 1, 0, 10, 3, 9, 2 },        /* Y */
+            { 0, 4, 0, 0, 10, 3, 9, 1 },        /* U */
+            { 0, 4, 2, 0, 10, 3, 9, 3 },        /* V */
+            { 0, 4, 3, 0,  2, 3, 1, 4 },        /* A */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA,
+    },
     [AV_PIX_FMT_RGB24] = {
         .name = "rgb24",
         .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 8b54c94..6a6a36a 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -209,6 +209,12 @@  enum AVPixelFormat {
 
     AV_PIX_FMT_YVYU422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
 
+    AV_PIX_FMT_Y210LE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, little-endian
+    AV_PIX_FMT_Y210BE,    ///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-endian
+    AV_PIX_FMT_AYUV,      ///< packed YUV 4:4:4, 32bpp,  A Y Cb Cr
+    AV_PIX_FMT_Y410LE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, little-endian
+    AV_PIX_FMT_Y410BE,    ///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, big-endian
+
     AV_PIX_FMT_YA16BE,       ///< 16 bits gray, 16 bits alpha (big-endian)
     AV_PIX_FMT_YA16LE,       ///< 16 bits gray, 16 bits alpha (little-endian)
 
diff --git a/libavutil/version.h b/libavutil/version.h
index dccbb38..e16b93e 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  29
+#define LIBAVUTIL_VERSION_MINOR  30
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \