[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 15:02:15 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 +++++++++--
src/misc/picture.c | 2 +-
2 files changed, 10 insertions(+), 3 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,
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 7506e47725..8608e552e0 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -156,7 +156,7 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
/* A plane cannot be over-sampled. This could lead to overflow. */
assert(h->den >= h->num);
- assert(w->den >= w->num);
+ assert(p_dsc->plane_count == 2 || w->den >= w->num);
p->i_lines = height * h->num / h->den;
p->i_visible_lines = fmt->i_visible_height * h->num / h->den;
--
2.16.2
More information about the vlc-devel
mailing list