[FFmpeg-devel,1/3] Add single precision planar RGB pixel formats

Submitted by Vittorio Giovara on Aug. 11, 2017, 2:11 p.m.

Details

Message ID 20170811141106.85652-2-vittorio.giovara@gmail.com
State New
Headers show

Commit Message

Vittorio Giovara Aug. 11, 2017, 2:11 p.m.
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
---
 libavutil/pixdesc.c              | 54 ++++++++++++++++++++++++++++++++++++++++
 libavutil/pixdesc.h              |  5 ++++
 libavutil/pixfmt.h               |  7 ++++++
 tests/ref/fate/sws-pixdesc-query | 20 +++++++++++++++
 4 files changed, 86 insertions(+)

Comments

Carl Eugen Hoyos Aug. 14, 2017, 12:05 p.m.
2017-08-11 16:11 GMT+02:00 Vittorio Giovara <vittorio.giovara@gmail.com>:

> [...]

Can't you use the functions from FFmpeg's exr implementation to provide
basic libswscale support?

Carl Eugen
Paul B Mahol Aug. 14, 2017, 2:27 p.m.
On 8/11/17, Vittorio Giovara <vittorio.giovara@gmail.com> wrote:
> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
> ---
>  libavutil/pixdesc.c              | 54
> ++++++++++++++++++++++++++++++++++++++++
>  libavutil/pixdesc.h              |  5 ++++
>  libavutil/pixfmt.h               |  7 ++++++
>  tests/ref/fate/sws-pixdesc-query | 20 +++++++++++++++
>  4 files changed, 86 insertions(+)
>

LGTM

Patch hide | download patch | download mbox

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 59587328ea..d45eae5772 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2183,6 +2183,60 @@  static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         .name = "d3d11",
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
     },
+    [AV_PIX_FMT_GBRPF32BE] = {
+        .name = "gbrpf32be",
+        .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_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_GBRPF32LE] = {
+        .name = "gbrpf32le",
+        .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_FLOAT | AV_PIX_FMT_FLAG_RGB,
+    },
+    [AV_PIX_FMT_GBRAPF32BE] = {
+        .name = "gbrapf32be",
+        .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_ALPHA | AV_PIX_FMT_FLAG_RGB |
+                 AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_GBRAPF32LE] = {
+        .name = "gbrapf32le",
+        .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_ALPHA |
+                 AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
+    },
 };
 #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 d4a39dcc01..6012bcebde 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -329,6 +329,11 @@  enum AVPixelFormat {
     AV_PIX_FMT_GRAY9BE,   ///<        Y        , 9bpp, big-endian
     AV_PIX_FMT_GRAY9LE,   ///<        Y        , 9bpp, little-endian
 
+    AV_PIX_FMT_GBRPF32BE,  ///< IEEE-754 single precision planar GBR 4:4:4,    96bpp, big-endian
+    AV_PIX_FMT_GBRPF32LE,  ///< IEEE-754 single precision planar GBR 4:4:4,    96bpp, little-endian
+    AV_PIX_FMT_GBRAPF32BE, ///< IEEE-754 single precision planar GBR 4:4:4:4, 128bpp, big-endian
+    AV_PIX_FMT_GBRAPF32LE, ///< IEEE-754 single precision planar GBR 4:4:4:4, 128bpp, 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
 };
 
@@ -393,6 +398,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_GBRPF32    AV_PIX_FMT_NE(GBRPF32BE,  GBRPF32LE)
+#define AV_PIX_FMT_GBRAPF32   AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE)
 
 #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/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index 9510b4ee0e..0adfdcaf98 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -112,11 +112,13 @@  isBE:
   gbrap10be
   gbrap12be
   gbrap16be
+  gbrapf32be
   gbrp10be
   gbrp12be
   gbrp14be
   gbrp16be
   gbrp9be
+  gbrpf32be
   gray10be
   gray12be
   gray16be
@@ -362,6 +364,8 @@  isRGB:
   gbrap12le
   gbrap16be
   gbrap16le
+  gbrapf32be
+  gbrapf32le
   gbrp
   gbrp10be
   gbrp10le
@@ -373,6 +377,8 @@  isRGB:
   gbrp16le
   gbrp9be
   gbrp9le
+  gbrpf32be
+  gbrpf32le
   rgb0
   rgb24
   rgb32
@@ -498,6 +504,8 @@  AnyRGB:
   gbrap12le
   gbrap16be
   gbrap16le
+  gbrapf32be
+  gbrapf32le
   gbrp
   gbrp10be
   gbrp10le
@@ -509,6 +517,8 @@  AnyRGB:
   gbrp16le
   gbrp9be
   gbrp9le
+  gbrpf32be
+  gbrpf32le
   monob
   monow
   rgb0
@@ -543,6 +553,8 @@  ALPHA:
   gbrap12le
   gbrap16be
   gbrap16le
+  gbrapf32be
+  gbrapf32le
   pal8
   rgb32
   rgb32_1
@@ -645,6 +657,8 @@  Planar:
   gbrap12le
   gbrap16be
   gbrap16le
+  gbrapf32be
+  gbrapf32le
   gbrp
   gbrp10be
   gbrp10le
@@ -656,6 +670,8 @@  Planar:
   gbrp16le
   gbrp9be
   gbrp9le
+  gbrpf32be
+  gbrpf32le
   nv12
   nv16
   nv20be
@@ -790,6 +806,8 @@  PlanarRGB:
   gbrap12le
   gbrap16be
   gbrap16le
+  gbrapf32be
+  gbrapf32le
   gbrp
   gbrp10be
   gbrp10le
@@ -801,6 +819,8 @@  PlanarRGB:
   gbrp16le
   gbrp9be
   gbrp9le
+  gbrpf32be
+  gbrpf32le
 
 usePal:
   bgr4_byte