[FFmpeg-cvslog] pixfmt: Add yuv420p12 pixel format

Luca Barbato git at videolan.org
Tue Mar 21 13:51:09 EET 2017


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sat Sep 24 22:48:48 2016 +0200| [85406e7a8d5ad12db15ef9d713d0bc3d870fafee] | committer: Luca Barbato

pixfmt: Add yuv420p12 pixel format

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85406e7a8d5ad12db15ef9d713d0bc3d870fafee
---

 libavutil/pixdesc.c                       | 25 +++++++++++++++++++++++++
 libavutil/pixfmt.h                        |  4 ++++
 libswscale/input.c                        |  4 ++++
 libswscale/output.c                       |  9 ++++++++-
 libswscale/swscale_unscaled.c             |  4 +++-
 libswscale/utils.c                        |  2 ++
 tests/ref/fate/filter-pixdesc-yuv420p12be |  1 +
 tests/ref/fate/filter-pixdesc-yuv420p12le |  1 +
 tests/ref/fate/filter-pixfmts-copy        |  2 ++
 tests/ref/fate/filter-pixfmts-null        |  2 ++
 tests/ref/fate/filter-pixfmts-scale       |  2 ++
 tests/ref/fate/filter-pixfmts-vflip       |  2 ++
 12 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index cf2ea9c..8f116fc 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1174,6 +1174,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         },
         .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
     },
+    [AV_PIX_FMT_YUV420P12LE] = {
+        .name = "yuv420p12le",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .comp = {
+            { 0, 2, 0, 0, 12, 1, 11, 1 },        /* Y */
+            { 1, 2, 0, 0, 12, 1, 11, 1 },        /* U */
+            { 2, 2, 0, 0, 12, 1, 11, 1 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR,
+    },
+    [AV_PIX_FMT_YUV420P12BE] = {
+        .name = "yuv420p12be",
+        .nb_components = 3,
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .comp = {
+            { 0, 2, 0, 0, 12, 1, 11, 1 },        /* Y */
+            { 1, 2, 0, 0, 12, 1, 11, 1 },        /* U */
+            { 2, 2, 0, 0, 12, 1, 11, 1 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR,
+    },
     [AV_PIX_FMT_YUV420P16LE] = {
         .name = "yuv420p16le",
         .nb_components = 3,
@@ -1842,6 +1866,7 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
     PIX_FMT_SWAP_ENDIANNESS(YUV420P10);
     PIX_FMT_SWAP_ENDIANNESS(YUV422P10);
     PIX_FMT_SWAP_ENDIANNESS(YUV444P10);
+    PIX_FMT_SWAP_ENDIANNESS(YUV420P12);
     PIX_FMT_SWAP_ENDIANNESS(YUV420P16);
     PIX_FMT_SWAP_ENDIANNESS(YUV422P16);
     PIX_FMT_SWAP_ENDIANNESS(YUV444P16);
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 8a8d624..658d5bf 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -230,6 +230,9 @@ enum AVPixelFormat {
     AV_PIX_FMT_P010LE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
     AV_PIX_FMT_P010BE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian
 
+    AV_PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0, 18bpp, (1 Cr & Cb sample per 2x2 Y), big-endian
+    AV_PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0, 18bpp, (1 Cr & Cb sample per 2x2 Y), 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
 };
 
@@ -263,6 +266,7 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
 #define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
 #define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
+#define AV_PIX_FMT_YUV420P12 AV_PIX_FMT_NE(YUV420P12BE, YUV420P12LE)
 #define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
 #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
 #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
diff --git a/libswscale/input.c b/libswscale/input.c
index 69c6729..9c0a32c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -815,6 +815,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV420P10LE:
     case AV_PIX_FMT_YUV422P10LE:
     case AV_PIX_FMT_YUV444P10LE:
+    case AV_PIX_FMT_YUV420P12LE:
     case AV_PIX_FMT_YUV420P16LE:
     case AV_PIX_FMT_YUV422P16LE:
     case AV_PIX_FMT_YUV444P16LE:
@@ -836,6 +837,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV420P10BE:
     case AV_PIX_FMT_YUV422P10BE:
     case AV_PIX_FMT_YUV444P10BE:
+    case AV_PIX_FMT_YUV420P12BE:
     case AV_PIX_FMT_YUV420P16BE:
     case AV_PIX_FMT_YUV422P16BE:
     case AV_PIX_FMT_YUV444P16BE:
@@ -1033,6 +1035,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV420P10LE:
     case AV_PIX_FMT_YUV422P10LE:
     case AV_PIX_FMT_YUV444P10LE:
+    case AV_PIX_FMT_YUV420P12LE:
     case AV_PIX_FMT_YUV420P16LE:
     case AV_PIX_FMT_YUV422P16LE:
     case AV_PIX_FMT_YUV444P16LE:
@@ -1058,6 +1061,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YUV420P10BE:
     case AV_PIX_FMT_YUV422P10BE:
     case AV_PIX_FMT_YUV444P10BE:
+    case AV_PIX_FMT_YUV420P12BE:
     case AV_PIX_FMT_YUV420P16BE:
     case AV_PIX_FMT_YUV422P16BE:
     case AV_PIX_FMT_YUV444P16BE:
diff --git a/libswscale/output.c b/libswscale/output.c
index 6a51bb9..78ebbc6 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -231,6 +231,8 @@ yuv2NBPS( 9, BE, 1, 10, int16_t)
 yuv2NBPS( 9, LE, 0, 10, int16_t)
 yuv2NBPS(10, BE, 1, 10, int16_t)
 yuv2NBPS(10, LE, 0, 10, int16_t)
+yuv2NBPS(12, BE, 1, 10, int16_t)
+yuv2NBPS(12, LE, 0, 10, int16_t)
 yuv2NBPS(16, BE, 1, 16, int32_t)
 yuv2NBPS(16, LE, 0, 16, int32_t)
 
@@ -1368,9 +1370,14 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
         if (desc->comp[0].depth == 9) {
             *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c  : yuv2planeX_9LE_c;
             *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c  : yuv2plane1_9LE_c;
-        } else {
+        } else if (desc->comp[0].depth == 10) {
             *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c  : yuv2planeX_10LE_c;
             *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c  : yuv2plane1_10LE_c;
+        } else if (desc->comp[0].depth == 12) {
+            *yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_c  : yuv2planeX_12LE_c;
+            *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_c  : yuv2plane1_12LE_c;
+        } else {
+            assert(0);
         }
     } else {
         *yuv2plane1 = yuv2plane1_8_c;
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index fbdc2af..87331ae 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -1157,8 +1157,10 @@ void ff_get_unscaled_swscale(SwsContext *c)
          c->chrDstVSubSample == c->chrSrcVSubSample &&
          dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
          dstFormat != AV_PIX_FMT_P010LE && dstFormat != AV_PIX_FMT_P010BE &&
+         dstFormat != AV_PIX_FMT_YUV420P12LE && dstFormat != AV_PIX_FMT_YUV420P12BE &&
          srcFormat != AV_PIX_FMT_NV12 && srcFormat != AV_PIX_FMT_NV21 &&
-         srcFormat != AV_PIX_FMT_P010LE && srcFormat != AV_PIX_FMT_P010BE))
+         srcFormat != AV_PIX_FMT_P010LE && srcFormat != AV_PIX_FMT_P010BE &&
+         srcFormat != AV_PIX_FMT_YUV420P12LE && srcFormat != AV_PIX_FMT_YUV420P12BE))
     {
         if (isPacked(c->srcFormat))
             c->swscale = packedCopyWrapper;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c4fb745..06b9c1c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -165,6 +165,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_YUV420P9LE]  = { 1, 1 },
     [AV_PIX_FMT_YUV420P10BE] = { 1, 1 },
     [AV_PIX_FMT_YUV420P10LE] = { 1, 1 },
+    [AV_PIX_FMT_YUV420P12BE] = { 1, 1 },
+    [AV_PIX_FMT_YUV420P12LE] = { 1, 1 },
     [AV_PIX_FMT_YUV422P9BE]  = { 1, 1 },
     [AV_PIX_FMT_YUV422P9LE]  = { 1, 1 },
     [AV_PIX_FMT_YUV422P10BE] = { 1, 1 },
diff --git a/tests/ref/fate/filter-pixdesc-yuv420p12be b/tests/ref/fate/filter-pixdesc-yuv420p12be
new file mode 100644
index 0000000..77cc341
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-yuv420p12be
@@ -0,0 +1 @@
+pixdesc-yuv420p12be 6d665168703a982178ac395de9be422f
diff --git a/tests/ref/fate/filter-pixdesc-yuv420p12le b/tests/ref/fate/filter-pixdesc-yuv420p12le
new file mode 100644
index 0000000..8ef325a
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-yuv420p12le
@@ -0,0 +1 @@
+pixdesc-yuv420p12le 0898b89cc0e0aec143fea7d3ecec991b
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index 2f6a71e..cc1e595 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -43,6 +43,8 @@ yuv411p             fc2f303b20ae610dce86dae4a6671881
 yuv420p             a2117c3c5d4533dca311dc94a3d157bc
 yuv420p10be         7756ef359f79d63ef6f983caeaba5c51
 yuv420p10le         aa8abcc05010b4b0df7d924fd5887291
+yuv420p12be         f93fea0e8e10e9f2d006e8f8be5b8938
+yuv420p12le         5d2810e2112328dd88ffddfb486df060
 yuv420p16be         7a708532d8ac26d598ac7332e38dd2de
 yuv420p16le         6b868d3b0c44c6b04f39415890d6ee0b
 yuv420p9be          11ffb289661f4f55347d60e99dcef632
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index 2f6a71e..cc1e595 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -43,6 +43,8 @@ yuv411p             fc2f303b20ae610dce86dae4a6671881
 yuv420p             a2117c3c5d4533dca311dc94a3d157bc
 yuv420p10be         7756ef359f79d63ef6f983caeaba5c51
 yuv420p10le         aa8abcc05010b4b0df7d924fd5887291
+yuv420p12be         f93fea0e8e10e9f2d006e8f8be5b8938
+yuv420p12le         5d2810e2112328dd88ffddfb486df060
 yuv420p16be         7a708532d8ac26d598ac7332e38dd2de
 yuv420p16le         6b868d3b0c44c6b04f39415890d6ee0b
 yuv420p9be          11ffb289661f4f55347d60e99dcef632
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index fbbc1c9..aa54675 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -43,6 +43,8 @@ yuv411p             091777fdfffa2dccbfd75769d1a402c7
 yuv420p             4f0105b3f2008bff284de251fe61ce06
 yuv420p10be         caaee5d071cccf50cc51c70f7a233024
 yuv420p10le         06c47286459599c62b25466e2ee3c91d
+yuv420p12be         b549289c041b852f0fec07d2cca5fb16
+yuv420p12le         df151f2b0a8bb7062d35b515cdffca3b
 yuv420p16be         10ba255f3901b5d47d3ac803fb787bcf
 yuv420p16le         38c42f658cad8546bfc465b72f6312ab
 yuv420p9be          17cd0ca2d12fd972045271e06a14b711
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index da13b16..29689db 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -43,6 +43,8 @@ yuv411p             a97d81c8a515965209127cfdc718f899
 yuv420p             daed3fd5e1980ccc4d4409320f16fbf6
 yuv420p10be         f434af8526dcda2988f15a08cdc4bf98
 yuv420p10le         9dcbdb0206713a90fd03b313d99e9ff9
+yuv420p12be         5c3b2cbbb97c38b763f3da61ba5152d2
+yuv420p12le         88e20b45556294e7ca64b323cf115ceb
 yuv420p16be         b8f1a0e4ef98903e2ef8dbce7bc812e2
 yuv420p16le         3be4223322a9d904caa2ad7d4ccf3c6a
 yuv420p9be          34346f74216be11c38cdaeffaba250cc



More information about the ffmpeg-cvslog mailing list