[vlc-devel] [PATCH 2/4] fourcc: define NV12 as semiplanar with the width multiplied and divided by two

Steve Lhomme robux4 at ycbcr.xyz
Tue Apr 17 14:57:01 CEST 2018


This way we know from the description that the combined UV plane needs to be a
multiple of 2 and we have the proper width for the line (2/2 instead of 1/1 of
the original size)
---
 src/misc/fourcc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index 1b8682af13..e0c15328d2 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -669,6 +669,13 @@ bool vlc_fourcc_IsYUV(vlc_fourcc_t fcc)
 #define PLANAR_8(n, w_den, h_den)        PLANAR(n, w_den, h_den, 1, 8)
 #define PLANAR_16(n, w_den, h_den, bits) PLANAR(n, w_den, h_den, 2, bits)
 
+#define SEMIPLANAR(w_den, h_den, size, bits) \
+    { .plane_count = 2, \
+      .p = { {.w = {1,    1}, .h = {1,    1}}, \
+             {.w = {2,w_den}, .h = {1,h_den}} }, \
+      .pixel_size = size, \
+      .pixel_bits = bits }
+
 #define PACKED_FMT(size, bits) \
     { .plane_count = 1, \
       .p = { {.w = {1,1}, .h = {1,1}} }, \
@@ -690,7 +697,7 @@ static const struct
     { { VLC_CODEC_I411 },                      PLANAR_8(3, 4, 1) },
     { { VLC_CODEC_YUV_PLANAR_410 },            PLANAR_8(3, 4, 4) },
     { { VLC_CODEC_YUV_PLANAR_420 },            PLANAR_8(3, 2, 2) },
-    { { VLC_CODEC_NV12, VLC_CODEC_NV21 },      PLANAR_8(2, 1, 2) },
+    { { VLC_CODEC_NV12, VLC_CODEC_NV21 },      SEMIPLANAR(2, 2, 1, 8) },
     { { VLC_CODEC_YUV_PLANAR_422 },            PLANAR_8(3, 2, 1) },
     { { VLC_CODEC_NV16, VLC_CODEC_NV61 },      PLANAR_8(2, 1, 1) },
     { { VLC_CODEC_YUV_PLANAR_440 },            PLANAR_8(3, 1, 2) },
@@ -731,7 +738,7 @@ static const struct
         VLC_CODEC_I444_16B },                  PLANAR_16(3, 1, 1, 16) },
     { { VLC_CODEC_YUVA_444_10L,
         VLC_CODEC_YUVA_444_10B },              PLANAR_16(4, 1, 1, 10) },
-    { { VLC_CODEC_P010 },                      PLANAR_16(2, 1, 2, 10) },
+    { { VLC_CODEC_P010 },                      SEMIPLANAR(2, 2, 2, 10) },
 
     { { VLC_CODEC_YUV_PACKED },                PACKED_FMT(2, 16) },
     { { VLC_CODEC_RGB8, VLC_CODEC_GREY,
-- 
2.16.2



More information about the vlc-devel mailing list