[FFmpeg-devel] [PATCH] avutil: add AV_PIX_FMT_GBR(A)P32F?E & AV_PIX_FMT_YUV(A)P32?E

Michael Niedermayer michael at niedermayer.cc
Thu Feb 11 00:17:29 CET 2016


On Wed, Feb 10, 2016 at 05:23:04PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Wed, Feb 10, 2016 at 5:12 PM, wm4 <nfxjfg at googlemail.com> wrote:
> 
> > On Wed, 10 Feb 2016 23:00:00 +0100
> > Michael Niedermayer <michael at niedermayer.cc> wrote:
> >
> > > On Wed, Feb 10, 2016 at 10:21:34PM +0100, wm4 wrote:
> > > > On Wed, 10 Feb 2016 21:56:07 +0100
> > > > Michael Niedermayer <michael at niedermayer.cc> wrote:
> > > >
> > > > > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > > > > ---
> > > > >  libavutil/pixdesc.c |  105
> > +++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > >  libavutil/pixfmt.h  |   13 +++++++
> > > > >  2 files changed, 118 insertions(+)
> > > > >
> > > > > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> > > > > index 58833cf..5fda5bd 100644
> > > > > --- a/libavutil/pixdesc.c
> > > > > +++ b/libavutil/pixdesc.c
> > > > > @@ -926,6 +926,57 @@ static const AVPixFmtDescriptor
> > av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
> > > > >          },
> > > > >          .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
> > > > >      },
> > > > > +    [AV_PIX_FMT_YUVA444P32FBE] = {
> > > > > +        .name = "yuva444p32fbe",
> > > > > +        .nb_components = 4,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* Y */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* U */
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* V */
> > > > > +            { 3, 4, 0, 0, 32, 3, 31, 1 },        /* A */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
> > AV_PIX_FMT_FLAG_ALPHA,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_YUVA444P32FLE] = {
> > > > > +        .name = "yuva444p32fle",
> > > > > +        .nb_components = 4,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* Y */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* U */
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* V */
> > > > > +            { 3, 4, 0, 0, 32, 3, 31, 1 },        /* A */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_YUV444P32FBE] = {
> > > > > +        .name = "yuv444p32fbe",
> > > > > +        .nb_components = 3,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* Y */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* U */
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* V */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_YUV444P32FLE] = {
> > > > > +        .name = "yuv444p32fle",
> > > > > +        .nb_components = 3,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* Y */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* U */
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* V */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_PLANAR,
> > > > > +    },
> > > > > +
> > > > >  #if FF_API_VDPAU
> > > > >      [AV_PIX_FMT_VDPAU_H264] = {
> > > > >          .name = "vdpau_h264",
> > > > > @@ -1819,6 +1870,60 @@ static const AVPixFmtDescriptor
> > av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
> > > > >          .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
> > > > >                   AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
> > > > >      },
> > > > > +    [AV_PIX_FMT_GBRAP32FLE] = {
> > > > > +        .name = "gbrap32fle",
> > > > > +        .nb_components = 4,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },       /* R */
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },       /* G */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },       /* B */
> > > > > +            { 3, 4, 0, 0, 32, 3, 31, 1 },       /* A */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_PLANAR |
> > > > > +                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_GBRAP32FBE] = {
> > > > > +        .name = "gbrap32fbe",
> > > > > +        .nb_components = 4,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },       /* R */
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },       /* G */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },       /* B */
> > > > > +            { 3, 4, 0, 0, 32, 3, 31, 1 },       /* A */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
> > > > > +                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_GBRP32FLE] = {
> > > > > +        .name = "gbrp32fle",
> > > > > +        .nb_components = 3,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },       /* R */
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },       /* G */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },       /* B */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_PLANAR |
> > > > > +                 AV_PIX_FMT_FLAG_RGB,
> > > > > +    },
> > > > > +    [AV_PIX_FMT_GBRP32FBE] = {
> > > > > +        .name = "gbrp32fbe",
> > > > > +        .nb_components = 3,
> > > > > +        .log2_chroma_w = 0,
> > > > > +        .log2_chroma_h = 0,
> > > > > +        .comp = {
> > > > > +            { 2, 4, 0, 0, 32, 3, 31, 1 },       /* R */
> > > > > +            { 0, 4, 0, 0, 32, 3, 31, 1 },       /* G */
> > > > > +            { 1, 4, 0, 0, 32, 3, 31, 1 },       /* B */
> > > > > +        },
> > > > > +        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
> > > > > +                 AV_PIX_FMT_FLAG_RGB,
> > > > > +    },
> > > > >      [AV_PIX_FMT_VDPAU] = {
> > > > >          .name = "vdpau",
> > > > >          .log2_chroma_w = 1,
> > > > > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> > > > > index c01c057..24110f6 100644
> > > > > --- a/libavutil/pixfmt.h
> > > > > +++ b/libavutil/pixfmt.h
> > > > > @@ -292,6 +292,15 @@ enum AVPixelFormat {
> > > > >      AV_PIX_FMT_P010LE, ///< like NV12, with 10bpp per component,
> > data in the high bits, zeros in the low bits, little-endian
> > > > >      AV_PIX_FMT_P010BE, ///< like NV12, with 10bpp per component,
> > data in the high bits, zeros in the low bits, big-endian
> > > > >
> > > > > +    AV_PIX_FMT_YUV444P32FLE,  ///< planar YUV 4:4:4 96bpp, (1 Cr &
> > Cb sample per 1x1 Y samples, float little-endian)
> > > > > +    AV_PIX_FMT_YUV444P32FBE,  ///< planar YUV 4:4:4 96bpp, (1 Cr &
> > Cb sample per 1x1 Y samples, float big-endian)
> > > > > +    AV_PIX_FMT_YUVA444P32FLE, ///< planar YUVA 4:4:4 128bpp, (1 Cr
> > & Cb sample per 1x1 Y & A samples, float little-endian)
> > > > > +    AV_PIX_FMT_YUVA444P32FBE, ///< planar YUVA 4:4:4 128bpp, (1 Cr
> > & Cb sample per 1x1 Y & A samples, float big-endian)
> > > > > +    AV_PIX_FMT_GBRP32FLE,     ///< planar GBR 4:4:4 96bpp, float
> > little-endian
> > > > > +    AV_PIX_FMT_GBRP32FBE,     ///< planar GBR 4:4:4 96bpp, float
> > big-endian
> > > > > +    AV_PIX_FMT_GBRAP32FLE,    ///< planar GBRA 4:4:4 128bpp, float
> > little-endian
> > > > > +    AV_PIX_FMT_GBRAP32FBE,    ///< planar GBRA 4:4:4 128bpp, float
> > big-endian
> > > > > +
> > > > >      AV_PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE
> > THIS if you want to link with shared libav* because the number of formats
> > might differ between versions
> > > > >  };
> > > > >
> > > > > @@ -348,6 +357,8 @@ enum AVPixelFormat {
> > > > >  #define AV_PIX_FMT_GBRP14    AV_PIX_FMT_NE(GBRP14BE,    GBRP14LE)
> > > > >  #define AV_PIX_FMT_GBRP16    AV_PIX_FMT_NE(GBRP16BE,    GBRP16LE)
> > > > >  #define AV_PIX_FMT_GBRAP16   AV_PIX_FMT_NE(GBRAP16BE,   GBRAP16LE)
> > > > > +#define AV_PIX_FMT_GBRP32F   AV_PIX_FMT_NE(GBRP32FBE,   GBRP32FLE)
> > > > > +#define AV_PIX_FMT_GBRAP32F  AV_PIX_FMT_NE(GBRAP32FBE,  GBRAP32FLE)
> > > > >
> > > > >  #define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE,
> > BAYER_BGGR16LE)
> > > > >  #define AV_PIX_FMT_BAYER_RGGB16 AV_PIX_FMT_NE(BAYER_RGGB16BE,
> > BAYER_RGGB16LE)
> > > > > @@ -364,6 +375,8 @@ enum AVPixelFormat {
> > > > >  #define AV_PIX_FMT_YUVA420P16 AV_PIX_FMT_NE(YUVA420P16BE,
> > YUVA420P16LE)
> > > > >  #define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE,
> > YUVA422P16LE)
> > > > >  #define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE,
> > YUVA444P16LE)
> > > > > +#define AV_PIX_FMT_YUV444P32F AV_PIX_FMT_NE(YUV444P32FBE,
> > YUV444P32FLE)
> > > > > +#define AV_PIX_FMT_YUVA444P32F AV_PIX_FMT_NE(YUVA444P32FBE,
> > YUVA444P32FLE)
> > > > >
> > > > >  #define AV_PIX_FMT_XYZ12      AV_PIX_FMT_NE(XYZ12BE, XYZ12LE)
> > > > >  #define AV_PIX_FMT_NV20       AV_PIX_FMT_NE(NV20BE,  NV20LE)
> > > >
> > > > I don't think this is going to fly without some sort of
> > > > AV_PIX_FMT_FLAG_FLOAT16/32.
> > >
> > > locally added
> > >
> > >
> > > >
> > > > Also, can we stop adding meaningless LE/BE alternatives?
> > >
> > > the rawvideo stored in containers has a endiannes,
> > > if pix_fmt represents that unchanged rawvideo then
> > > it has to contain endianness information. Thats how the other pixel
> > > formats work too.
> > >
> > > [...]
> >
> > If we get any raw float formats, we should swap in the decoder/encoder.
> > Preserving the endianness has no advantages at all because there are
> > generally no filters which work on non-native endian. And if you want
> > to merely copy the video, codec copy will still work without swapping.
> 
> 
> +1, I think this is a good lesson from mistakes we made in
> P9/10/12/etc.LE/BE design... It's not like it's killing us, but it adds
> complexity and I truly don't believe it ever has been of any use in
> practice, so let's not make it worse by doing it for the float world also.

i faintly remember some arguing for pixel formats
to each mean a byte per byte specified format from the past ...
now everyone agrees that it should be only native endian.

iam fine with either, but i dislike having to deal with special
cases and mixed semantics about what a pix_fmt exactly specifies

Either way, how should it be done in practice ?
If we bswap in the rawvideo decoder and encoder, how does the
encoder know if it should bswap ?
for other pixel formats its set by -pix_fmt but that wouldnt work
if theres just one for 2 endian variants.
always selecting native wont work for regression tests and may fail
for a container which requires a specific endianness

also we would need speciial casing for codec_tag<->pixel format
mappings as the codec_tag would be endian specific

also some avfilter fate tests would i think fail as they are purely
running over all supported pixel formats and expect them to be the
same on big and little endian. this would require another exception
of some kind

not sure if thats all special casing needed

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160211/c4164b74/attachment.sig>


More information about the ffmpeg-devel mailing list