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"
30static INT16 convert(UINT8 raw,
int shift)
32 const int cll = shift - 1;
33 return (INT16)((INT8)(raw << cll));
37static pstatus_t general_YCoCgToRGB_8u_AC4R(
const BYTE* WINPR_RESTRICT pSrc, INT32 srcStep,
38 BYTE* WINPR_RESTRICT pDst, UINT32 DstFormat,
39 INT32 dstStep, UINT32 width, UINT32 height, UINT8 shift,
42 const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat);
43 fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE);
45 for (
size_t y = 0; y < height; y++)
47 const BYTE* sptr = &pSrc[y * WINPR_ASSERTING_INT_CAST(uint32_t, srcStep)];
48 BYTE* dptr = &pDst[y * WINPR_ASSERTING_INT_CAST(uint32_t, dstStep)];
49 for (
size_t x = 0; x < width; x++)
52 const INT16 Cg = convert(*sptr++, shift);
53 const INT16 Co = convert(*sptr++, shift);
54 const INT16 Y = *sptr++;
55 const INT16 T = (INT16)(Y - Cg);
56 const INT16 B = (INT16)(T + Co);
57 const INT16 G = (INT16)(Y + Cg);
58 const INT16 R = (INT16)(T - Co);
64 dptr = writePixel(dptr, formatSize, DstFormat, CLIP(R), CLIP(G), CLIP(B), A);
68 return PRIMITIVES_SUCCESS;
72void primitives_init_YCoCg(
primitives_t* WINPR_RESTRICT prims)
74 prims->YCoCgToRGB_8u_AC4R = general_YCoCgToRGB_8u_AC4R;
77void primitives_init_YCoCg_opt(
primitives_t* WINPR_RESTRICT prims)
79 primitives_init_YCoCg(prims);
80 primitives_init_YCoCg_ssse3(prims);
81 primitives_init_YCoCg_neon(prims);