[FFmpeg-devel] [PATCH] Add YUV-based floating-point pixel formats.

Andrew Sun adsun701 at gmail.com
Sat Jul 28 02:05:01 EEST 2018


This commit adds support for 32-bpc YUV-based floating-point pixel formats.
---
 doc/APIchanges      |  2 ++
 libavutil/pixdesc.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/pixfmt.h  | 11 ++++++++
 libavutil/version.h |  2 +-
 4 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4effbf9364..980b6e01bf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,8 @@ libavutil:     2015-08-28
 
 
 API changes, most recent first:
+2017-09-01 - xxxxxxx - lavu 57.82.100 - pixfmt.h
+  Add YUV-based floating-point pixel formats.
 
 2017-09-01 - xxxxxxx - lavf 57.81.100 - avio.h
   Add avio_read_partial().
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index d45eae5772..d954866470 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2237,6 +2237,81 @@ 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_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
     },
+    [AV_PIX_FMT_YUV420PF32BE] = {
+        .name = "yuv420pf32be",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
+                 AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV420PF32LE] = {
+        .name = "yuv420pf32le",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV422PF32BE] = {
+        .name = "yuv422pf32be",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
+                 AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV422PF32LE] = {
+        .name = "yuv422pf32le",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV444PF32BE] = {
+        .name = "yuv444pf32be",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR |
+                 AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_YUV444PF32LE] = {
+        .name = "yuv444pf32le",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 4, 0, 0, 32, 3, 31, 1 },        /* R */
+            { 1, 4, 0, 0, 32, 3, 31, 1 },        /* G */
+            { 2, 4, 0, 0, 32, 3, 31, 1 },        /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_FLOAT,
+    },
 };
 #if FF_API_PLUS1_MINUS1
 FF_ENABLE_DEPRECATION_WARNINGS
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 6dd094376f..3863e1c9a9 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -334,6 +334,13 @@ enum AVPixelFormat {
     AV_PIX_FMT_GBRAPF32BE, ///< IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian
     AV_PIX_FMT_GBRAPF32LE, ///< IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian
 
+    AV_PIX_FMT_YUV420PF32BE, ///< IEEE-754 single precision planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples),   48bpp, big-endian
+    AV_PIX_FMT_YUV420PF32LE, ///< IEEE-754 single precision planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples),   48bpp, little-endian
+    AV_PIX_FMT_YUV422PF32BE, ///< IEEE-754 single precision planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples),   64bpp, big-endian
+    AV_PIX_FMT_YUV422PF32LE, ///< IEEE-754 single precision planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples),   64bpp, little-endian
+    AV_PIX_FMT_YUV444PF32BE, ///< IEEE-754 single precision planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples),   96bpp, big-endian
+    AV_PIX_FMT_YUV444PF32LE, ///< IEEE-754 single precision planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples),   96bpp, little-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
 };
 
@@ -401,6 +408,10 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_GBRPF32    AV_PIX_FMT_NE(GBRPF32BE,  GBRPF32LE)
 #define AV_PIX_FMT_GBRAPF32   AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE)
 
+#define AV_PIX_FMT_YUV420PF32 AV_PIX_FMT_NE(YUV420PF32BE, YUV420PF32LE)
+#define AV_PIX_FMT_YUV422PF32 AV_PIX_FMT_NE(YUV422PF32BE, YUV422PF32LE)
+#define AV_PIX_FMT_YUV444PF32 AV_PIX_FMT_NE(YUV444PF32BE, YUV444PF32LE)
+
 #define AV_PIX_FMT_YUVA420P9  AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
 #define AV_PIX_FMT_YUVA422P9  AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
 #define AV_PIX_FMT_YUVA444P9  AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
diff --git a/libavutil/version.h b/libavutil/version.h
index 6e25b4690c..d99eff5d15 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
 
 
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR  74
+#define LIBAVUTIL_VERSION_MINOR  75
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.14.1



More information about the ffmpeg-devel mailing list