[FFmpeg-devel] [PATCH 1/5] Add YUV444 32bit floating point pixel format

Vittorio Giovara vittorio.giovara at gmail.com
Tue Jul 18 16:50:11 EEST 2017


With and without alpha.
---
TODO: version bump

I am aware support for bpp > 2 is not present but the scope
of these formats is limited to a specific usecase, and contained
in libavfilter only.
Suggestions for reflecting this in documentation are welcome.

Cheers,
    Vittorio

 libavutil/pixdesc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/pixdesc.h |  5 +++++
 libavutil/pixfmt.h  |  7 +++++++
 libswscale/utils.c  |  4 ++++
 4 files changed, 67 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 46a7eff06d..a61ce3c5ac 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2162,6 +2162,57 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         .name = "d3d11",
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
     },
+    [AV_PIX_FMT_YUV444F32LE] = {
+        .name = "yuv444f32le",
+        .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 | AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV444F32BE] = {
+        .name = "yuv444f32be",
+        .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_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUVA444F32LE] = {
+        .name = "yuva444f32le",
+        .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_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+    },
+    [AV_PIX_FMT_YUVA444F32BE] = {
+        .name = "yuva444f32be",
+        .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_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+    },
 };
 #if FF_API_PLUS1_MINUS1
 FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index c3a6f27f49..294555260a 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -178,6 +178,11 @@ typedef struct AVPixFmtDescriptor {
 #define AV_PIX_FMT_FLAG_BAYER        (1 << 8)
 
 /**
+ * The pixel format contains IEEE-754 single precision floating point values.
+ */
+#define AV_PIX_FMT_FLAG_FLOAT        (1 << 10)
+
+/**
  * Return the number of bits per pixel used by the pixel format
  * described by pixdesc. Note that this is not the same as the number
  * of bits per sample.
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index e1e4074bee..d6a874da15 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -326,6 +326,11 @@ enum AVPixelFormat {
      */
     AV_PIX_FMT_D3D11,
 
+    AV_PIX_FMT_YUV444F32LE,  ///< IEEE-754 single precision planar YUV 4:4:4,  96bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
+    AV_PIX_FMT_YUV444F32BE,  ///< IEEE-754 single precision planar YUV 4:4:4,  96bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
+    AV_PIX_FMT_YUVA444F32LE, ///< IEEE-754 single precision planar YUV 4:4:4, 128bpp, (1 Cr & Cb sample per 1x1 Y & A sample), little-endian
+    AV_PIX_FMT_YUVA444F32BE, ///< IEEE-754 single precision planar YUV 4:4:4, 128bpp, (1 Cr & Cb sample per 1x1 Y & A sample), 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
 };
 
@@ -389,6 +394,8 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_BAYER_GBRG16 AV_PIX_FMT_NE(BAYER_GBRG16BE,    BAYER_GBRG16LE)
 #define AV_PIX_FMT_BAYER_GRBG16 AV_PIX_FMT_NE(BAYER_GRBG16BE,    BAYER_GRBG16LE)
 
+#define AV_PIX_FMT_YUV444F32  AV_PIX_FMT_NE(YUV444F32BE,  YUV444F32LE)
+#define AV_PIX_FMT_YUVA444F32 AV_PIX_FMT_NE(YUVA444F32BE, YUVA444F32LE)
 
 #define AV_PIX_FMT_YUVA420P9  AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
 #define AV_PIX_FMT_YUVA422P9  AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 17c996734a..892b219049 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -254,6 +254,10 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_P010BE]      = { 1, 1 },
     [AV_PIX_FMT_P016LE]      = { 1, 0 },
     [AV_PIX_FMT_P016BE]      = { 1, 0 },
+    [AV_PIX_FMT_YUV444F32LE]  = { 0, 0 },
+    [AV_PIX_FMT_YUV444F32BE]  = { 0, 0 },
+    [AV_PIX_FMT_YUVA444F32LE] = { 0, 0 },
+    [AV_PIX_FMT_YUVA444F32BE] = { 0, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
2.13.2



More information about the ffmpeg-devel mailing list