Skip to content

Commit

Permalink
vc_copylineToUYVY709: use global coefficients
Browse files Browse the repository at this point in the history
do not hard code them
  • Loading branch information
MartinPulec committed Sep 24, 2024
1 parent 39de4c1 commit 9ca21df
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/pixfmt_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ void vc_copylineRGBtoRGBA(unsigned char * __restrict dst, const unsigned char *
* @param[in] pix_size source pixel size (3 for RGB, 4 for RGBA)
*/
#define vc_copylineToUYVY709(dst, src, dst_len, roff, goff, boff, pix_size) {\
const struct color_coeffs *cfs = get_color_coeffs(DEPTH8); \
register uint32_t *d = (uint32_t *)(void *) dst;\
OPTIMIZED_FOR (int x = 0; x <= (dst_len) - 4; x += 4) {\
int r, g, b;\
Expand All @@ -989,23 +990,21 @@ void vc_copylineRGBtoRGBA(unsigned char * __restrict dst, const unsigned char *
g = src[goff];\
b = src[boff];\
src += pix_size;\
y1 = 11993 * r + 40239 * g + 4063 * b + (1<<20);\
u = -6619 * r -22151 * g + 28770 * b;\
v = 28770 * r - 26149 * g - 2621 * b;\
y1 = (RGB_TO_Y(cfs, r, g, b) >> COMP_BASE) + 16;\
u = RGB_TO_CB(cfs, r, g, b);\
v = RGB_TO_CR(cfs, r, g, b);\
r = src[roff];\
g = src[goff];\
b = src[boff];\
src += pix_size;\
y2 = 11993 * r + 40239 * g + 4063 * b + (1<<20);\
u += -6619 * r -22151 * g + 28770 * b;\
v += 28770 * r - 26149 * g - 2621 * b;\
u = u / 2 + (1<<23);\
v = v / 2 + (1<<23);\
y2 = (RGB_TO_Y(cfs, r, g, b) >> COMP_BASE) + 16;\
u += RGB_TO_CB(cfs, r, g, b);\
v += RGB_TO_CR(cfs, r, g, b);\
u = ((u / 2) >> COMP_BASE) + 128;\
v = ((v / 2) >> COMP_BASE) + 128;\
\
*d++ = (CLAMP(y2, 0, (1<<24)-1) >> 16) << 24 |\
(CLAMP(v, 0, (1<<24)-1) >> 16) << 16 |\
(CLAMP(y1, 0, (1<<24)-1) >> 16) << 8 |\
(CLAMP(u, 0, (1<<24)-1) >> 16);\
*d++ = ((y2 & 0xFF) << 24) | ((v & 0xFF) << 16) | \
((y1 & 0xFF) << 8) | (u & 0xFF); \
}\
}

Expand Down

0 comments on commit 9ca21df

Please sign in to comment.