[vlc-devel] [PATCH 4/4] color extraction: add YUV 420 10b support
victorien.lecouviour.tuffet at gmail.com
victorien.lecouviour.tuffet at gmail.com
Tue Apr 4 18:52:47 CEST 2017
From: Victorien Le Couviour--Tuffet <victorien.lecouviour-tuffet at epitech.eu>
---
modules/video_filter/extract.c | 71 +++++++++++++++++++++++++++++++-----------
1 file changed, 52 insertions(+), 19 deletions(-)
diff --git a/modules/video_filter/extract.c b/modules/video_filter/extract.c
index a2b37fd4e1..55d312b78c 100644
--- a/modules/video_filter/extract.c
+++ b/modules/video_filter/extract.c
@@ -100,6 +100,8 @@ static int Create( vlc_object_t *p_this )
switch( p_filter->fmt_in.video.i_chroma )
{
case VLC_CODEC_I420:
+ case VLC_CODEC_I420_10L:
+ case VLC_CODEC_I420_10B:
case VLC_CODEC_J420:
case VLC_CODEC_YV12:
@@ -181,12 +183,12 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
case VLC_CODEC_I420:
case VLC_CODEC_J420:
+ case VLC_CODEC_I420_10L:
+ case VLC_CODEC_I420_10B:
case VLC_CODEC_YV12:
case VLC_CODEC_I422:
case VLC_CODEC_J422:
- get_custom_from_yuv(p_pic, p_outpic,
- Y_PLANE, U_PLANE, V_PLANE,
- p_sys->projection_matrix);
+ get_custom_from_yuv(p_pic, p_outpic, Y_PLANE, U_PLANE, V_PLANE, p_sys->projection_matrix);
break;
CASE_PACKED_YUV_422
@@ -206,8 +208,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return CopyInfoAndRelease( p_outpic, p_pic );
}
-#define U 128
-#define V 128
+#define U8 128 // 2^8 / 2
+#define V8 128
+
+#define U10 512 // 2^10 / 2
+#define V10 512
static void mmult( double *res, double *a, double *b )
{
@@ -266,6 +271,39 @@ static void make_projection_matrix( filter_t *p_filter, int color, int *matrix )
msg_Dbg( p_filter, "%6d %6d %6d", matrix[6], matrix[7], matrix[8] );
}
+#define IS_420_10(fmt) (fmt == VLC_CODEC_I420_10L || fmt == VLC_CODEC_I420_10B)
+
+#define GET_OUT \
+ do \
+ { \
+ *(*u_out)++ = range((*y_in[0] * m[3] + (**u_in - u) * m[4] + (**v_in - v) * m[5]) / 65536 + u); \
+ *(*v_out)++ = range((*y_in[0] * m[6] + (**u_in - u) * m[7] + (**v_in - v) * m[8]) / 65536 + v); \
+ *y_out[0]++ = range((*y_in[0]++ * m[0] + (**u_in - u) * m[1] + (**v_in - v) * m[2]) / 65536); \
+ *y_out[0]++ = range((*y_in[0]++ * m[0] + (**u_in - u) * m[1] + (**v_in - v) * m[2]) / 65536); \
+ *y_out[1]++ = range((*y_in[1]++ * m[0] + (**u_in - u) * m[1] + (**v_in - v) * m[2]) / 65536); \
+ *y_out[1]++ = range((*y_in[1]++ * m[0] + (*(*u_in)++ - u) * m[1] + (*(*v_in)++ - v) * m[2]) / 65536); \
+ } while (0);
+
+static inline void
+get_out_yuv_8b(uint8_t *y_in[2], uint8_t *y_out[2],
+ uint8_t **u_in, uint8_t **u_out,
+ uint8_t **v_in, uint8_t **v_out,
+ uint16_t const u, uint16_t const v,
+ int const *m, uint16_t(*range)(int))
+{
+ GET_OUT;
+}
+
+static inline void
+get_out_yuv_10b(uint16_t *y_in[2], uint16_t *y_out[2],
+ uint16_t **u_in, uint16_t **u_out,
+ uint16_t **v_in, uint16_t **v_out,
+ uint16_t const u, uint16_t const v,
+ int const *m, uint16_t(*range)(int))
+{
+ GET_OUT;
+}
+
static void
get_custom_from_yuv(picture_t *p_inpic, picture_t *p_outpic,
int yp, int up, int vp, int const *m)
@@ -288,14 +326,9 @@ get_custom_from_yuv(picture_t *p_inpic, picture_t *p_outpic,
y_in[1] = y_in[0] + i_in_pitch;
y_out[1] = y_out[0] + i_out_pitch;
for (void *const y_row_end = y_in[0] + i_visible_pitch; y_in[0] < y_row_end; )
- {
- *u_out++ = vlc_uint8((*y_in[0] * m[3] + (*u_in - U) * m[4] + (*v_in - V) * m[5]) / 65536 + U); \
- *v_out++ = vlc_uint8((*y_in[0] * m[6] + (*u_in - U) * m[7] + (*v_in - V) * m[8]) / 65536 + V); \
- *y_out[0]++ = vlc_uint8((*y_in[0]++ * m[0] + (*u_in - U) * m[1] + (*v_in - V) * m[2]) / 65536); \
- *y_out[0]++ = vlc_uint8((*y_in[0]++ * m[0] + (*u_in - U) * m[1] + (*v_in - V) * m[2]) / 65536); \
- *y_out[1]++ = vlc_uint8((*y_in[1]++ * m[0] + (*u_in - U) * m[1] + (*v_in - V) * m[2]) / 65536); \
- *y_out[1]++ = vlc_uint8((*y_in[1]++ * m[0] + (*u_in++ - U) * m[1] + (*v_in++ - V) * m[2]) / 65536); \
- }
+ !IS_420_10(p_inpic->format.i_chroma)
+ ? get_out_yuv_8b(y_in, y_out, &u_in, &u_out, &v_in, &v_out, U8, V8, m, &vlc_uint8)
+ : get_out_yuv_10b(y_in, y_out, &u_in, &u_out, &v_in, &v_out, U10, V10, m, &vlc_uint10);
y_in[0] += 2 * i_in_pitch - i_visible_pitch;
y_out[0] += 2 * i_out_pitch - i_visible_pitch;
u_in += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
@@ -333,17 +366,17 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic,
const uint8_t *ylend = yin + i_visible_pitch;
while( yin < ylend )
{
- *uout = vlc_uint8( (*yin * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
- / 65536 + U );
+ *uout = vlc_uint8( (*yin * m[3] + (*uin-U8) * m[4] + (*vin-V8) * m[5])
+ / 65536 + U8 );
uout += 4;
- *vout = vlc_uint8( (*yin * m[6] + (*uin-U) * m[7] + (*vin-V) * m[8])
- / 65536 + V );
+ *vout = vlc_uint8( (*yin * m[6] + (*uin-U8) * m[7] + (*vin-V8) * m[8])
+ / 65536 + V8 );
vout += 4;
- *yout = vlc_uint8( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
+ *yout = vlc_uint8( (*yin * m[0] + (*uin-U8) * m[1] + (*vin-V8) * m[2])
/ 65536 );
yin += 2;
yout += 2;
- *yout = vlc_uint8( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
+ *yout = vlc_uint8( (*yin * m[0] + (*uin-U8) * m[1] + (*vin-V8) * m[2])
/ 65536 );
yin += 2;
yout += 2;
--
2.12.0
More information about the vlc-devel
mailing list