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"
27 static 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);
33 static 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;
47 static INLINE pstatus_t general_lShiftC_16s(
const INT16* pSrc, UINT32 val, INT16* pDst, UINT32 len)
50 return PRIMITIVES_SUCCESS;
54 for (UINT32 x = 0; x < len; x++)
55 pDst[x] = shift(pSrc[x], val);
57 return PRIMITIVES_SUCCESS;
61 static INLINE pstatus_t general_rShiftC_16s(
const INT16* pSrc, UINT32 val, INT16* pDst, UINT32 len)
64 return PRIMITIVES_SUCCESS;
68 for (UINT32 x = 0; x < len; x++)
69 pDst[x] = WINPR_ASSERTING_INT_CAST(int16_t, pSrc[x] >> val);
71 return PRIMITIVES_SUCCESS;
75 static INLINE pstatus_t general_lShiftC_16u(
const UINT16* pSrc, UINT32 val, UINT16* pDst,
79 return PRIMITIVES_SUCCESS;
83 for (UINT32 x = 0; x < len; x++)
84 pDst[x] = WINPR_ASSERTING_INT_CAST(UINT16, ((pSrc[x] << val) & 0xFFFF));
86 return PRIMITIVES_SUCCESS;
90 static INLINE pstatus_t general_rShiftC_16u(
const UINT16* pSrc, UINT32 val, UINT16* pDst,
94 return PRIMITIVES_SUCCESS;
98 for (UINT32 x = 0; x < len; x++)
99 pDst[x] = pSrc[x] >> val;
101 return PRIMITIVES_SUCCESS;
105 static INLINE pstatus_t general_shiftC_16s(
const INT16* pSrc, INT32 val, INT16* pDst, UINT32 len)
108 return PRIMITIVES_SUCCESS;
111 return general_rShiftC_16s(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, -val), pDst, len);
113 return general_lShiftC_16s(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, val), pDst, len);
117 static INLINE pstatus_t general_shiftC_16u(
const UINT16* pSrc, INT32 val, UINT16* pDst, UINT32 len)
120 return PRIMITIVES_SUCCESS;
123 return general_rShiftC_16u(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, -val), pDst, len);
125 return general_lShiftC_16u(pSrc, WINPR_ASSERTING_INT_CAST(UINT32, val), pDst, len);
129 void primitives_init_shift(
primitives_t* WINPR_RESTRICT prims)
132 prims->lShiftC_16s_inplace = general_lShiftC_16s_inplace;
133 prims->lShiftC_16s = general_lShiftC_16s;
134 prims->rShiftC_16s = general_rShiftC_16s;
135 prims->lShiftC_16u = general_lShiftC_16u;
136 prims->rShiftC_16u = general_rShiftC_16u;
138 prims->shiftC_16s = general_shiftC_16s;
139 prims->shiftC_16u = general_shiftC_16u;
142 void primitives_init_shift_opt(
primitives_t* WINPR_RESTRICT prims)
144 primitives_init_shift_sse3(prims);