Skip to content

Commit 86a53f9

Browse files
committed
pixfmt_conv: additional convs from YUVA
1 parent 4fad1e7 commit 86a53f9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/pixfmt_conv.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,47 @@ vc_copylineVUYAtoY416(unsigned char *__restrict dst,
26742674
}
26752675
}
26762676

2677+
static void
2678+
vc_copylineVUYAtoUYVY(unsigned char *__restrict dst,
2679+
const unsigned char *__restrict src, int dst_len,
2680+
int rshift, int gshift, int bshift)
2681+
{
2682+
(void) rshift, (void) gshift, (void) bshift;
2683+
const int dst_bs = get_pf_block_bytes(UYVY); // 4
2684+
while (dst_len > dst_bs - 1) {
2685+
*dst++ = (src[1] + src[5]) / 2; // U
2686+
*dst++ = src[2]; // Y0
2687+
*dst++ = (src[0] + src[4]) / 2; // V
2688+
*dst++ = src[7]; // Y1
2689+
src += 8;
2690+
dst_len -= dst_bs;
2691+
}
2692+
}
2693+
2694+
static void
2695+
vc_copylineVUYAtoRGB(unsigned char *__restrict dst,
2696+
const unsigned char *__restrict src, int dst_len,
2697+
int rshift, int gshift, int bshift)
2698+
{
2699+
(void) rshift, (void) gshift, (void) bshift;
2700+
enum {
2701+
S_DEPTH = 8,
2702+
};
2703+
const struct color_coeffs cfs = *get_color_coeffs(CS_DFL, S_DEPTH);
2704+
OPTIMIZED_FOR (int x = 0; x < dst_len; x += 4) {
2705+
comp_type_t v = *src++ - (1 << (S_DEPTH - 1));
2706+
comp_type_t u = *src++ - (1 << (S_DEPTH - 1));
2707+
comp_type_t y = cfs.y_scale * (*src++ - (1 << (S_DEPTH - 4)));
2708+
src++; // alpha
2709+
comp_type_t r = YCBCR_TO_R(cfs, y, u, v) >> COMP_BASE;
2710+
comp_type_t g = YCBCR_TO_G(cfs, y, u, v) >> COMP_BASE;
2711+
comp_type_t b = YCBCR_TO_B(cfs, y, u, v) >> COMP_BASE;
2712+
*dst++ = CLAMP_FULL(r, 8);
2713+
*dst++ = CLAMP_FULL(g, 8);
2714+
*dst++ = CLAMP_FULL(b, 8);
2715+
}
2716+
}
2717+
26772718
static void vc_copylineY216toUYVY(unsigned char * __restrict dst, const unsigned char * __restrict src, int dst_len, int rshift,
26782719
int gshift, int bshift)
26792720
{
@@ -3034,6 +3075,8 @@ static const struct decoder_item decoders[] = {
30343075
{ vc_copylineUYVYtoY216, UYVY, Y216 },
30353076
{ vc_copylineUYVYtoY416, UYVY, Y416 },
30363077
{ vc_copylineVUYAtoY416, VUYA, Y416 },
3078+
{ vc_copylineVUYAtoUYVY, VUYA, UYVY },
3079+
{ vc_copylineVUYAtoRGB, VUYA, RGB },
30373080
{ vc_copylineY216toUYVY, Y216, UYVY },
30383081
{ vc_copylineY216toV210, Y216, v210 },
30393082
{ vc_copylineY416toUYVY, Y416, UYVY },

0 commit comments

Comments
 (0)