]> git.sesse.net Git - ffmpeg/commitdiff
avutil: Add NV24 and NV42 pixel formats
authorPhilip Langdale <philipl@overt.org>
Tue, 7 May 2019 03:39:39 +0000 (20:39 -0700)
committerPhilip Langdale <philipl@overt.org>
Sun, 12 May 2019 14:51:02 +0000 (07:51 -0700)
These are the 4:4:4 variants of the semi-planar NV12/NV21 formats.

These formats are not used much, so we've never had a reason to add
them until now. VDPAU recently added support HEVC 4:4:4 content
and when you use the OpenGL interop, the returned surfaces are in
NV24 format, so we need the pixel format for media players, even
if there's no direct use within ffmpeg.

Separately, there are apparently webcams that use NV24, but I've
never seen one.

libavutil/pixdesc.c
libavutil/pixfmt.h
libavutil/tests/pixfmt_best.c
libavutil/version.h
tests/ref/fate/pixfmt_best

index fe38344d732eff99e6efddec0332d8464eb4c9cf..b97b0665b0a3aa0f354576b50c90f85cf30887aa 100644 (file)
@@ -2320,6 +2320,30 @@ 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_NV24] = {
+        .name = "nv24",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 1, 0, 0, 8, 0, 7, 1 },        /* Y */
+            { 1, 2, 0, 0, 8, 1, 7, 1 },        /* U */
+            { 1, 2, 1, 0, 8, 1, 7, 2 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR,
+    },
+    [AV_PIX_FMT_NV42] = {
+        .name = "nv42",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 1, 0, 0, 8, 0, 7, 1 },        /* Y */
+            { 1, 2, 1, 0, 8, 1, 7, 2 },        /* U */
+            { 1, 2, 0, 0, 8, 1, 7, 1 },        /* V */
+        },
+        .flags = AV_PIX_FMT_FLAG_PLANAR,
+    },
 };
 #if FF_API_PLUS1_MINUS1
 FF_ENABLE_DEPRECATION_WARNINGS
index 24d1b7e415388af895ad96c7556412b023d43a2d..8b54c9415bbe9ebf874f9c9516befe0229e2f1d7 100644 (file)
@@ -345,6 +345,9 @@ enum AVPixelFormat {
     AV_PIX_FMT_YUVA444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian
     AV_PIX_FMT_YUVA444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian
 
+    AV_PIX_FMT_NV24,      ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
+    AV_PIX_FMT_NV42,      ///< as above, but U and V bytes are swapped
+
     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
 };
 
index e98fcc19a50b61544b52f87dcf7b1770828ded47..53f72642073a6c72911f320b7cdecc53e2846ffd 100644 (file)
@@ -76,6 +76,7 @@ int main(void)
     TEST(AV_PIX_FMT_P010,      AV_PIX_FMT_YUV420P10);
     TEST(AV_PIX_FMT_P016,      AV_PIX_FMT_YUV420P16);
     TEST(AV_PIX_FMT_NV16,      AV_PIX_FMT_YUV422P);
+    TEST(AV_PIX_FMT_NV24,      AV_PIX_FMT_YUV444P);
     TEST(AV_PIX_FMT_YUYV422,   AV_PIX_FMT_YUV422P);
     TEST(AV_PIX_FMT_UYVY422,   AV_PIX_FMT_YUV422P);
     TEST(AV_PIX_FMT_BGR565,    AV_PIX_FMT_RGB565);
index c0968de621d26569bcbd9acaf947f0a125410535..12b4f9fc3ab3c2000c735c724061fc585b94c641 100644 (file)
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  26
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  27
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
index 699e2e4213c8373b79aea0ce6ec1f25d06af145c..5f51e2d84562658b9a0fde64aaa7bec3ef562d1d 100644 (file)
@@ -1 +1 @@
-72 tests passed, 0 tests failed.
+73 tests passed, 0 tests failed.