Skip to content

Commit 9b418ea

Browse files
committed
added vc_copylineV210toRG48
Mostly copied from vc_copylineV210toRGB, with obviously different output format. For computation it uses whole 10 bit YUV while the former loads just 8 (most significant) bits directly. refers to GH-356
1 parent a5dabb2 commit 9b418ea

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/pixfmt_conv.c

+62
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,67 @@ static void vc_copylineV210toRGB(unsigned char * __restrict dst, const unsigned
26242624
#undef DECLARE_LOAD_V210_COMPONENTS
26252625
}
26262626

2627+
static void
2628+
vc_copylineV210toRG48(unsigned char *__restrict d,
2629+
const unsigned char *__restrict src, int dst_len,
2630+
int rshift, int gshift, int bshift)
2631+
{
2632+
uint16_t *dst = (void *) d;
2633+
enum {
2634+
IDEPTH = 10,
2635+
Y_SHIFT = 1 << (IDEPTH - 4),
2636+
C_SHIFT = 1 << (IDEPTH - 1),
2637+
ODEPTH = 16,
2638+
DIFF_BPP = ODEPTH - IDEPTH,
2639+
PIX_COUNT = 6,
2640+
RG48_BPP = 6,
2641+
OUT_BL_SZ = PIX_COUNT * RG48_BPP,
2642+
};
2643+
UNUSED(rshift), UNUSED(gshift), UNUSED(bshift);
2644+
#define WRITE_YUV_AS_RGB(y, u, v) \
2645+
(y) = Y_SCALE * ((y) - Y_SHIFT); \
2646+
val = (YCBCR_TO_R_709_SCALED((y), (u), (v)) >> (COMP_BASE - DIFF_BPP)); \
2647+
*(dst++) = CLAMP_FULL(val, ODEPTH); \
2648+
val = (YCBCR_TO_G_709_SCALED((y), (u), (v)) >> (COMP_BASE - DIFF_BPP)); \
2649+
*(dst++) = CLAMP_FULL(val, ODEPTH); \
2650+
val = (YCBCR_TO_B_709_SCALED((y), (u), (v)) >> (COMP_BASE - DIFF_BPP)); \
2651+
*(dst++) = CLAMP_FULL(val, ODEPTH);
2652+
2653+
// read 8 bits from v210 directly
2654+
#define DECLARE_LOAD_V210_COMPONENTS(a, b, c) \
2655+
comp_type_t a = (src[1] & 0x3) << 8 | src[0];\
2656+
comp_type_t b = (src[2] & 0xF) << 6 | src[1] >> 2;\
2657+
comp_type_t c = (src[3] & 0x3F) << 4 | src[2] >> 4;\
2658+
2659+
OPTIMIZED_FOR (int x = 0; x < dst_len; x += OUT_BL_SZ){
2660+
DECLARE_LOAD_V210_COMPONENTS(u01, y0, v01);
2661+
src += 4;
2662+
DECLARE_LOAD_V210_COMPONENTS(y1, u23, y2);
2663+
src += 4;
2664+
DECLARE_LOAD_V210_COMPONENTS(v23, y3, u45);
2665+
src += 4;
2666+
DECLARE_LOAD_V210_COMPONENTS(y4, v45, y5);
2667+
src += 4;
2668+
2669+
comp_type_t val = 0;
2670+
2671+
u01 -= C_SHIFT;
2672+
v01 -= C_SHIFT;
2673+
u23 -= C_SHIFT;
2674+
v23 -= C_SHIFT;
2675+
u45 -= C_SHIFT;
2676+
v45 -= C_SHIFT;
2677+
WRITE_YUV_AS_RGB(y0, u01, v01);
2678+
WRITE_YUV_AS_RGB(y1, u01, v01);
2679+
WRITE_YUV_AS_RGB(y2, u23, v23);
2680+
WRITE_YUV_AS_RGB(y3, u23, v23);
2681+
WRITE_YUV_AS_RGB(y4, u45, v45);
2682+
WRITE_YUV_AS_RGB(y5, u45, v45);
2683+
}
2684+
#undef WRITE_YUV_AS_RGB
2685+
#undef DECLARE_LOAD_V210_COMPONENTS
2686+
}
2687+
26272688
static void vc_copylineY416toV210(unsigned char * __restrict dst, const unsigned char * __restrict src, int dst_len, int rshift,
26282689
int gshift, int bshift)
26292690
{
@@ -2718,6 +2779,7 @@ static const struct decoder_item decoders[] = {
27182779
{ vc_copylineV210toY216, v210, Y216 },
27192780
{ vc_copylineV210toY416, v210, Y416 },
27202781
{ vc_copylineV210toRGB, v210, RGB },
2782+
{ vc_copylineV210toRG48, v210, RG48 },
27212783
};
27222784

27232785
/**

0 commit comments

Comments
 (0)