20 #include <freerdp/config.h>
22 #include <freerdp/types.h>
23 #include <freerdp/primitives.h>
25 #include "prim_internal.h"
26 #include "prim_YCoCg.h"
30 static INT16 convert(UINT8 raw,
int shift)
32 const int cll = shift - 1;
33 return (INT16)((INT8)(raw << cll));
37 static pstatus_t general_YCoCgToRGB_8u_AC4R(
const BYTE* pSrc, INT32 srcStep, BYTE* pDst,
38 UINT32 DstFormat, INT32 dstStep, UINT32 width,
39 UINT32 height, UINT8 shift, BOOL withAlpha)
41 const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
42 fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE);
44 for (
size_t y = 0; y < height; y++)
46 const BYTE* sptr = &pSrc[y * srcStep];
47 BYTE* dptr = &pDst[y * dstStep];
48 for (
size_t x = 0; x < width; x++)
51 const INT16 Cg = convert(*sptr++, shift);
52 const INT16 Co = convert(*sptr++, shift);
53 const INT16 Y = *sptr++;
54 const INT16 T = (INT16)(Y - Cg);
55 const INT16 B = (INT16)(T + Co);
56 const INT16 G = (INT16)(Y + Cg);
57 const INT16 R = (INT16)(T - Co);
63 dptr = writePixel(dptr, formatSize, DstFormat, CLIP(R), CLIP(G), CLIP(B), A);
67 return PRIMITIVES_SUCCESS;
71 void primitives_init_YCoCg(
primitives_t* WINPR_RESTRICT prims)
73 prims->YCoCgToRGB_8u_AC4R = general_YCoCgToRGB_8u_AC4R;
76 void primitives_init_YCoCg_opt(
primitives_t* WINPR_RESTRICT prims)
78 primitives_init_YCoCg_ssse3(prims);
79 primitives_init_YCoCg_neon(prims);