[FFmpeg-devel] [PATCH]lavu/pixfmt: Add GRAY10

Carl Eugen Hoyos cehoyos at ag.or.at
Mon Nov 14 02:59:06 EET 2016


Hi!

Attached patches are a requirement to fix two tickets.

Please review, Carl Eugen
-------------- next part --------------
From 64541da83bf85110a8cab5805a8425e632f560ee Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Mon, 14 Nov 2016 01:43:40 +0100
Subject: [PATCH 1/2] lavu/pixfmt: Add GRAY10

Based on 7471352f by Luca Barbato.
---
 libavutil/pixdesc.c |   21 +++++++++++++++++++++
 libavutil/pixfmt.h  |    3 +++
 libavutil/version.h |    2 +-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 73474be..f8092ef 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -560,6 +560,27 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         },
         .flags = AV_PIX_FMT_FLAG_RGB,
     },
+    [AV_PIX_FMT_GRAY10BE] = {
+        .name = "gray10be",
+        .nb_components = 1,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 2, 0, 0, 10, 1, 9, 1 },       /* Y */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE,
+        .alias = "y10be",
+    },
+    [AV_PIX_FMT_GRAY10LE] = {
+        .name = "gray10le",
+        .nb_components = 1,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 2, 0, 0, 10, 1, 9, 1 },       /* Y */
+        },
+        .alias = "y10le",
+    },
     [AV_PIX_FMT_GRAY12BE] = {
         .name = "gray12be",
         .nb_components = 1,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 9de4eaf..96860ce 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -308,6 +308,8 @@ enum AVPixelFormat {
 
     AV_PIX_FMT_GRAY12BE,   ///<        Y        , 12bpp, big-endian
     AV_PIX_FMT_GRAY12LE,   ///<        Y        , 12bpp, little-endian
+    AV_PIX_FMT_GRAY10BE,   ///<        Y        , 10bpp, big-endian
+    AV_PIX_FMT_GRAY10LE,   ///<        Y        , 10bpp, 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
 };
@@ -325,6 +327,7 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_0RGB32  AV_PIX_FMT_NE(0RGB, BGR0)
 #define AV_PIX_FMT_0BGR32  AV_PIX_FMT_NE(0BGR, RGB0)
 
+#define AV_PIX_FMT_GRAY10 AV_PIX_FMT_NE(GRAY10BE, GRAY10LE)
 #define AV_PIX_FMT_GRAY12 AV_PIX_FMT_NE(GRAY12BE, GRAY12LE)
 #define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE)
 #define AV_PIX_FMT_YA16   AV_PIX_FMT_NE(YA16BE,   YA16LE)
diff --git a/libavutil/version.h b/libavutil/version.h
index 6d68051..471d968 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR  39
+#define LIBAVUTIL_VERSION_MINOR  40
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
1.7.10.4

-------------- next part --------------
From f8b8721913a486f206bf13aace66f2572763600e Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Mon, 14 Nov 2016 01:55:49 +0100
Subject: [PATCH 2/2] lsws: Add GRAY10 conversion.

Based on ab839054 by Luca Barbato.
---
 libswscale/input.c                       |    2 ++
 libswscale/swscale_internal.h            |    2 ++
 libswscale/swscale_unscaled.c            |    1 +
 libswscale/utils.c                       |    2 ++
 tests/ref/fate/filter-pixdesc-gray10be   |    1 +
 tests/ref/fate/filter-pixdesc-gray10le   |    1 +
 tests/ref/fate/filter-pixfmts-copy       |    2 ++
 tests/ref/fate/filter-pixfmts-crop       |    2 ++
 tests/ref/fate/filter-pixfmts-field      |    2 ++
 tests/ref/fate/filter-pixfmts-fieldorder |    2 ++
 tests/ref/fate/filter-pixfmts-hflip      |    2 ++
 tests/ref/fate/filter-pixfmts-il         |    2 ++
 tests/ref/fate/filter-pixfmts-null       |    2 ++
 tests/ref/fate/filter-pixfmts-pad        |    1 +
 tests/ref/fate/filter-pixfmts-scale      |    2 ++
 tests/ref/fate/filter-pixfmts-vflip      |    2 ++
 16 files changed, 28 insertions(+)
 create mode 100644 tests/ref/fate/filter-pixdesc-gray10be
 create mode 100644 tests/ref/fate/filter-pixdesc-gray10le

diff --git a/libswscale/input.c b/libswscale/input.c
index 28f0baf..1f4ea18 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1323,6 +1323,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV422P16LE:
     case AV_PIX_FMT_YUV444P16LE:
 
+    case AV_PIX_FMT_GRAY10LE:
     case AV_PIX_FMT_GRAY12LE:
     case AV_PIX_FMT_GRAY16LE:
         c->lumToYV12 = bswap16Y_c;
@@ -1358,6 +1359,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV422P16BE:
     case AV_PIX_FMT_YUV444P16BE:
 
+    case AV_PIX_FMT_GRAY10BE:
     case AV_PIX_FMT_GRAY12BE:
     case AV_PIX_FMT_GRAY16BE:
         c->lumToYV12 = bswap16Y_c;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 9368832..af82396 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -695,6 +695,8 @@ static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
 #define isGray(x)                      \
     ((x) == AV_PIX_FMT_GRAY8       ||  \
      (x) == AV_PIX_FMT_YA8         ||  \
+     (x) == AV_PIX_FMT_GRAY10BE    ||  \
+     (x) == AV_PIX_FMT_GRAY10LE    ||  \
      (x) == AV_PIX_FMT_GRAY12BE    ||  \
      (x) == AV_PIX_FMT_GRAY12LE    ||  \
      (x) == AV_PIX_FMT_GRAY16BE    ||  \
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 6a09281..b2bfc40 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -1796,6 +1796,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
+        IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY10) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY12) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
         IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16)   ||
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a1d791b..15cc56d 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -131,6 +131,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_RGB0]        = { 1, 1 },
     [AV_PIX_FMT_0BGR]        = { 1, 1 },
     [AV_PIX_FMT_BGR0]        = { 1, 1 },
+    [AV_PIX_FMT_GRAY10BE]    = { 1, 1 },
+    [AV_PIX_FMT_GRAY10LE]    = { 1, 1 },
     [AV_PIX_FMT_GRAY12BE]    = { 1, 1 },
     [AV_PIX_FMT_GRAY12LE]    = { 1, 1 },
     [AV_PIX_FMT_GRAY16BE]    = { 1, 1 },
diff --git a/tests/ref/fate/filter-pixdesc-gray10be b/tests/ref/fate/filter-pixdesc-gray10be
new file mode 100644
index 0000000..81540c8
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-gray10be
@@ -0,0 +1 @@
+pixdesc-gray10be    d4b84689e79b1d014c7a599a49b40b4d
diff --git a/tests/ref/fate/filter-pixdesc-gray10le b/tests/ref/fate/filter-pixdesc-gray10le
new file mode 100644
index 0000000..c47b183
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-gray10le
@@ -0,0 +1 @@
+pixdesc-gray10le    f1b0e53b9d6e63af70dc8f2b5a14cb4b
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index c39ea51..1ae4469 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -33,6 +33,8 @@ gbrp14le            1607f5c8f13360b53b8186f523996b1b
 gbrp9be             a4dc6f6f9bb051de2dc348b592ad4282
 gbrp9le             699da3a3b324f3fd001a56aee9683384
 gray                188590b1231afd231ea910815aef2b25
+gray10be            8d594f0c6e886cce760689868f2523d4
+gray10le            a42744450d83943a7fa85fe179501548
 gray12be            fb9c00496453d233d2f0f0f81141bc31
 gray12le            c3cccaeb21ed9b894f9ef99ebebaf1cd
 gray16be            08d997a3faa25a3db9d6be272d282eef
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop
index d4319b8..7abdccc 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -33,6 +33,8 @@ gbrp14le            d4764dba3c3efd1263c2c8e0f5ac9f6a
 gbrp9be             4af43999e5e9742992b6550ea5ad9b23
 gbrp9le             b4cbfa7878706a14295f09212e41f7fe
 gray                0d70b54b4b888ec4dbd89713620ac1ee
+gray10be            3e8dcfad8f30743a33d19349ba914a88
+gray10le            9a72da3e6a31a53ecde9b54bb2627e0c
 gray12be            ffc8ec5de51e2998d666a5e209d1f7f5
 gray12le            548dc0885922d2f5898a904b40287b92
 gray16be            38f599da990224de86e3dc7a543121a9
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index 380a53b..0225c15 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -33,6 +33,8 @@ gbrp14le            ed9ccbc7a4f3e269a2ec37d210359fd8
 gbrp9be             170da3a8644cbea61c3caeadc45354c5
 gbrp9le             da5d80e6f12cabaa7081bb85d3b7fd30
 gray                57fd8e6e00f6be8752726005974cce1b
+gray10be            0f75355ec8be3e0787e27c5656fedfc7
+gray10le            28433b6788c33f9db70f84d927a3a77e
 gray12be            cb75ba58b07cdf33fb3a75f6c1f139eb
 gray12le            a243f45461d946e70c5a7f3f8eff37f1
 gray16be            e1700e056de9917744a7ff4ab2ca63fd
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index 6170916..1cc8e5b 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -33,6 +33,8 @@ gbrp14le            b01b1a05d8de36f51a133d25102fe1f3
 gbrp9be             b8d294d4bc81ceef1fb529e917c02e48
 gbrp9le             0d42cc9e222d806c33172781b45cb3e3
 gray                d96e0f1c73d3f0b9506d691b5cd36c73
+gray10be            3a460e670ebcf2373be499e15fe25843
+gray10le            74f61da347023482c36986c279b92df6
 gray12be            37950a95be3ada46b6404b1e1860fd93
 gray12le            c7431f01abd6e639bab036a46a18e423
 gray16be            293a36548ce16543494790f8f7f76a05
diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip
index 1bde49c..762995a 100644
--- a/tests/ref/fate/filter-pixfmts-hflip
+++ b/tests/ref/fate/filter-pixfmts-hflip
@@ -33,6 +33,8 @@ gbrp14le            91bb636f4e1f5d50312b136c185542e9
 gbrp9be             174de037c2a9f2b6fb4d9444ae0ff82f
 gbrp9le             ba7c2631fb2967aa909c66509bd243fe
 gray                8bd4ece1dbf89b20ee785e0515356e07
+gray10be            b75156463e3799e8eac19ca36032f4a2
+gray10le            e3f834c845d7060c71a3f1585437944c
 gray12be            aff18f944e023a767c59357eb362fab2
 gray12le            6a50f886754a32a01254bddbb0823880
 gray16be            cf7294d9aa23e1b838692ec01ade587b
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index 431a2a9..2b673b1 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -33,6 +33,8 @@ gbrp14le            bf3d5dec9b58cecd4ca1c5d3a4d57c31
 gbrp9be             f029d87fa642f4261160471ad27fd53f
 gbrp9le             b310d3cf37f7b41d706155993f8f0584
 gray                52ae18648161ac43144f5c9cd2127786
+gray10be            a71bf7a7317f4a1d195e5c9a9757934f
+gray10le            99fcbb9b5de29abccef4ffb0905cb528
 gray12be            cbff647cbf9693e95ce67ee663447afa
 gray12le            e44a1ed1755441ecf07ad7dbe2e033fa
 gray16be            92c3b09f371b610cc1b6a9776034f4d0
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index c39ea51..1ae4469 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -33,6 +33,8 @@ gbrp14le            1607f5c8f13360b53b8186f523996b1b
 gbrp9be             a4dc6f6f9bb051de2dc348b592ad4282
 gbrp9le             699da3a3b324f3fd001a56aee9683384
 gray                188590b1231afd231ea910815aef2b25
+gray10be            8d594f0c6e886cce760689868f2523d4
+gray10le            a42744450d83943a7fa85fe179501548
 gray12be            fb9c00496453d233d2f0f0f81141bc31
 gray12le            c3cccaeb21ed9b894f9ef99ebebaf1cd
 gray16be            08d997a3faa25a3db9d6be272d282eef
diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad
index 4bef06c..c133536 100644
--- a/tests/ref/fate/filter-pixfmts-pad
+++ b/tests/ref/fate/filter-pixfmts-pad
@@ -14,6 +14,7 @@ gbrp12le            91fdad0d1edf7bfa2805e2041e8da3cd
 gbrp14le            deb2c3af6b48faa52f6a1f6590a0cdf7
 gbrp9le             9e827f438e081d334a6cae7e282698b0
 gray                ddc663a0491df3959d9c5795dceaa72e
+gray10le            32ca617a9ffda4bdbdef9a058f60e828
 gray12le            94b3d77e56b5a094720842fea6138cb1
 gray16le            468bda6155bdc7a7a20c34d6e599fd16
 nv12                381574979cb04be10c9168540310afad
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index 05f3512..b6bcad0 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -33,6 +33,8 @@ gbrp14le            456f7d1ff5990aa6379137d84dd63862
 gbrp9be             d9c88968001e1452ff31fbc8d16b18a0
 gbrp9le             2ccfed0816bf6bd4bb3a5b7591d9603a
 gray                221201cc7cfc4964eacd8b3e426fd276
+gray10be            83b90b7dc2aa60352ad13fd45ed6ed6f
+gray10le            38334597d352b2117e6e3a012272ab4b
 gray12be            7ae04a6e966d23df34f95dc66507d334
 gray12le            255a75f40496c3adcd07700441dfc307
 gray16be            32891cb0928b1119d8d43a6e1bef0e2b
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index ed423fc..8de061f 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -33,6 +33,8 @@ gbrp14le            6e93b87047e433995111eb5397751c3f
 gbrp9be             99c694dd47d12ae48fc8f47a0c410333
 gbrp9le             26e103a4ab99fb3f58667df490997a36
 gray                41811422d5819ed69389357294384c10
+gray10be            c29ddfe5615423296f089187752d763b
+gray10le            e2ecc50fff1cf4a8d7afe2e9beb1b8c5
 gray12be            29dd81b58b749d0037ba28430df77ded
 gray12le            989cb5cefd6aff20b732068e15ad2a88
 gray16be            29f24ba7cb0fc4fd2ae78963d008f6e6
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list