[FFmpeg-devel] [PATCH 1/2] lavu/pix_fmt: add pixel format for x2bgr10

Manuel Stoeckl code at mstoeckl.com
Sat Sep 18 21:55:33 EEST 2021


The new format (given in big/little endian forms) matches the
existing X2RGB10 format, except with B and R channels switched.

AV_PIX_FMT_X2BGR10 data often is created by OpenGL programs
whose buffers use the GL_RGB10 internal format.

Signed-off-by: Manuel Stoeckl <code at mstoeckl.com>
---
 doc/APIchanges                   |  3 +++
 libavutil/pixdesc.c              | 24 ++++++++++++++++++++++++
 libavutil/pixfmt.h               |  3 +++
 libavutil/version.h              |  4 ++--
 tests/ref/fate/imgutils          |  2 ++
 tests/ref/fate/sws-pixdesc-query | 11 +++++++++++
 6 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cf6105c99e..0ae6495b4d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2021-09-18 - xxxxxxxxxx - lavu 57.6.100 - pixfmt.h
+  Add AV_PIX_FMT_X2BGR10.
+
 2021-09-17 - xxxxxxxxxx - lavu 57.5.101 - buffer.h
   Constified the input parameters in av_buffer_replace(), av_buffer_ref(),
   and av_buffer_pool_buffer_get_opaque().
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 2346138d04..69cb198646 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -272,6 +272,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         },
         .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
     },
+    [AV_PIX_FMT_X2BGR10LE] = {
+        .name = "x2bgr10le",
+        .nb_components= 3,
+        .log2_chroma_w= 0,
+        .log2_chroma_h= 0,
+        .comp = {
+            { 0, 4, 0, 0, 10 },       /* R */
+            { 0, 4, 1, 2, 10 },       /* G */
+            { 0, 4, 2, 4, 10 },       /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_RGB,
+    },
+    [AV_PIX_FMT_X2BGR10BE] = {
+        .name = "x2bgr10be",
+        .nb_components= 3,
+        .log2_chroma_w= 0,
+        .log2_chroma_h= 0,
+        .comp = {
+            { 0, 4, 2, 0, 10 },       /* R */
+            { 0, 4, 1, 2, 10 },       /* G */
+            { 0, 4, 0, 4, 10 },       /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
+    },
     [AV_PIX_FMT_YUV422P] = {
         .name = "yuv422p",
         .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 5814f3f3da..53bdecfcb7 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -350,6 +350,8 @@ enum AVPixelFormat {
 
     AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined
     AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined
+    AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
+    AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined
     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
 };
 
@@ -440,6 +442,7 @@ enum AVPixelFormat {
 
 #define AV_PIX_FMT_Y210       AV_PIX_FMT_NE(Y210BE,  Y210LE)
 #define AV_PIX_FMT_X2RGB10    AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE)
+#define AV_PIX_FMT_X2BGR10    AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE)
 
 /**
   * Chromaticity coordinates of the source primaries.
diff --git a/libavutil/version.h b/libavutil/version.h
index 1e6a80f86e..2b5ac540a4 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR   5
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR   6
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f510150ea1..495bbd46f0 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -236,3 +236,5 @@ y210be          planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0
 y210le          planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0     0     0, plane_offsets:     0     0     0, total_size: 12288
 x2rgb10le       planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0     0     0, plane_offsets:     0     0     0, total_size: 12288
 x2rgb10be       planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0     0     0, plane_offsets:     0     0     0, total_size: 12288
+x2bgr10le       planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0     0     0, plane_offsets:     0     0     0, total_size: 12288
+x2bgr10be       planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288     0     0     0, plane_offsets:     0     0     0, total_size: 12288
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index c3cccfa492..a74109c3d7 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -57,6 +57,8 @@ isNBPS:
   nv20le
   p010be
   p010le
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le
   xyz12be
@@ -143,6 +145,7 @@ isBE:
   rgb555be
   rgb565be
   rgba64be
+  x2bgr10be
   x2rgb10be
   xyz12be
   y210be
@@ -439,6 +442,8 @@ isRGB:
   rgb8
   rgba64be
   rgba64le
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le
 
@@ -587,6 +592,8 @@ AnyRGB:
   rgb8
   rgba64be
   rgba64le
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le
 
@@ -696,6 +703,8 @@ Packed:
   rgba64le
   uyvy422
   uyyvyy411
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le
   xyz12be
@@ -862,6 +871,8 @@ PackedRGB:
   rgb8
   rgba64be
   rgba64le
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le
 
-- 
2.33.0



More information about the ffmpeg-devel mailing list