16#include <freerdp/config.h>
17#include <winpr/assert.h>
18#include <winpr/cast.h>
20#include <freerdp/types.h>
21#include <freerdp/primitives.h>
23#include "prim_internal.h"
24#include "prim_shift.h"
27static INLINE INT16 shift(INT16 val, UINT32 sh)
29 const INT16 rc = (int16_t)(((UINT32)val << sh) & 0xFFFF);
30 return WINPR_ASSERTING_INT_CAST(INT16, rc);
33static INLINE pstatus_t general_lShiftC_16s_inplace(INT16* WINPR_RESTRICT pSrcDst, UINT32 val,
37 return PRIMITIVES_SUCCESS;
41 for (UINT32 x = 0; x < len; x++)
42 pSrcDst[x] = shift(pSrcDst[x], val);
44 return PRIMITIVES_SUCCESS;
47static INLINE pstatus_t general_lShiftC_16s(
const INT16* WINPR_RESTRICT pSrc, UINT32 val,
48 INT16* WINPR_RESTRICT pDst, UINT32 len)
51 return PRIMITIVES_SUCCESS;
55 for (UINT32 x = 0; x < len; x++)
56 pDst[x] = shift(pSrc[x], val);
58 return PRIMITIVES_SUCCESS;
62static INLINE pstatus_t general_rShiftC_16s(
const INT16* WINPR_RESTRICT pSrc, UINT32 val,
63 INT16* WINPR_RESTRICT pDst, UINT32 len)
66 return PRIMITIVES_SUCCESS;
70 for (UINT32 x = 0; x < len; x++)
71 pDst[x] = WINPR_ASSERTING_INT_CAST(int16_t, pSrc[x] >> val);
73 return PRIMITIVES_SUCCESS;
77static INLINE pstatus_t general_lShiftC_16u(
const UINT16* WINPR_RESTRICT pSrc, UINT32 val,
78 UINT16* WINPR_RESTRICT pDst, UINT32 len)
81 return PRIMITIVES_SUCCESS;
85 for (UINT32 x = 0; x < len; x++)
86 pDst[x] = WINPR_ASSERTING_INT_CAST(UINT16, ((pSrc[x] << val) & 0xFFFF));
88 return PRIMITIVES_SUCCESS;
92static INLINE pstatus_t general_rShiftC_16u(
const UINT16* WINPR_RESTRICT pSrc, UINT32 val,
93 UINT16* WINPR_RESTRICT pDst, UINT32 len)
96 return PRIMITIVES_SUCCESS;
100 for (UINT32 x = 0; x < len; x++)
101 pDst[x] = pSrc[x] >> val;
103 return PRIMITIVES_SUCCESS;
107static INLINE pstatus_t general_shiftC_16s(
const INT16* WINPR_RESTRICT pSrc, INT32 val,
108 INT16* WINPR_RESTRICT pDst, UINT32 len)
111 return PRIMITIVES_SUCCESS;
114 return general_rShiftC_16s(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, -val), pDst, len);
116 return general_lShiftC_16s(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, val), pDst, len);
120static INLINE pstatus_t general_shiftC_16u(
const UINT16* WINPR_RESTRICT pSrc, INT32 val,
121 UINT16* WINPR_RESTRICT pDst, UINT32 len)
124 return PRIMITIVES_SUCCESS;
127 return general_rShiftC_16u(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, -val), pDst, len);
129 return general_lShiftC_16u(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, val), pDst, len);
133void primitives_init_shift(
primitives_t* WINPR_RESTRICT prims)
136 prims->lShiftC_16s_inplace = general_lShiftC_16s_inplace;
137 prims->lShiftC_16s = general_lShiftC_16s;
138 prims->rShiftC_16s = general_rShiftC_16s;
139 prims->lShiftC_16u = general_lShiftC_16u;
140 prims->rShiftC_16u = general_rShiftC_16u;
142 prims->shiftC_16s = general_shiftC_16s;
143 prims->shiftC_16u = general_shiftC_16u;
146void primitives_init_shift_opt(
primitives_t* WINPR_RESTRICT prims)
148 primitives_init_shift(prims);
149 primitives_init_shift_sse3(prims);