FreeRDP
Loading...
Searching...
No Matches
primitives.h
1/* primitives.h
2 * vi:ts=4 sw=4
3 *
4 * (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing
12 * permissions and limitations under the License. Algorithms used by
13 * this code may be covered by patents by HP, Microsoft, or other parties.
14 */
15
16#ifdef __GNUC__
17#pragma once
18#endif
19
20#ifndef FREERDP_PRIMITIVES_H
21#define FREERDP_PRIMITIVES_H
22
23#include <winpr/wtypes.h>
24
25#include <freerdp/api.h>
26#include <freerdp/types.h>
27#include <freerdp/codec/color.h>
28
29#include <winpr/platform.h>
30
31#ifdef __cplusplus
32extern "C"
33{
34#endif
35
36 typedef INT32 pstatus_t; /* match IppStatus. */
37#define PRIMITIVES_SUCCESS (0) /* match ippStsNoErr */
38
39/* Simple macro for address of an x,y location in 2d 4-byte memory block */
40#define PIXMAP4_ADDR(_dst_, _x_, _y_, _span_) \
41 ((void*)(((BYTE*)(_dst_)) + (((_x_) + (_y_) * (_span_)) << 2)))
42
43#define PRIM_X86_MMX_AVAILABLE (1U << 0)
44#define PRIM_X86_3DNOW_AVAILABLE (1U << 1)
45#define PRIM_X86_3DNOW_PREFETCH_AVAILABLE (1U << 2)
46#define PRIM_X86_SSE_AVAILABLE (1U << 3)
47#define PRIM_X86_SSE2_AVAILABLE (1U << 4)
48#define PRIM_X86_SSE3_AVAILABLE (1U << 5)
49#define PRIM_X86_SSSE3_AVAILABLE (1U << 6)
50#define PRIM_X86_SSE41_AVAILABLE (1U << 7)
51#define PRIM_X86_SSE42_AVAILABLE (1U << 8)
52#define PRIM_X86_AVX_AVAILABLE (1U << 9)
53#define PRIM_X86_FMA_AVAILABLE (1U << 10)
54#define PRIM_X86_AVX_AES_AVAILABLE (1U << 11)
55#define PRIM_X86_AVX2_AVAILABLE (1U << 12)
56
57#define PRIM_ARM_VFP1_AVAILABLE (1U << 0)
58#define PRIM_ARM_VFP2_AVAILABLE (1U << 1)
59#define PRIM_ARM_VFP3_AVAILABLE (1U << 2)
60#define PRIM_ARM_VFP4_AVAILABLE (1U << 3)
61#define PRIM_ARM_FPA_AVAILABLE (1U << 4)
62#define PRIM_ARM_FPE_AVAILABLE (1U << 5)
63#define PRIM_ARM_IWMMXT_AVAILABLE (1U << 6)
64#define PRIM_ARM_NEON_AVAILABLE (1U << 7)
65
67enum
68{
69 PRIM_FLAGS_HAVE_EXTCPU = (1U << 0), /* primitives are using CPU extensions */
70 PRIM_FLAGS_HAVE_EXTGPU = (1U << 1), /* primitives are using the GPU */
71};
72
73typedef struct
74{
75 UINT32 width;
76 UINT32 height;
78
79typedef enum
80{
81 AVC444_LUMA,
82 AVC444_CHROMAv1,
83 AVC444_CHROMAv2
84} avc444_frame_type;
85
86/* Function prototypes for all of the supported primitives. */
87typedef pstatus_t (*fn_copy_t)(const void* WINPR_RESTRICT pSrc, void* WINPR_RESTRICT pDst,
88 INT32 bytes);
89typedef pstatus_t (*fn_copy_8u_t)(const BYTE* WINPR_RESTRICT pSrc, BYTE* WINPR_RESTRICT pDst,
90 INT32 len);
91typedef pstatus_t (*fn_copy_8u_AC4r_t)(const BYTE* WINPR_RESTRICT pSrc, INT32 srcStep, /* bytes */
92 BYTE* WINPR_RESTRICT pDst, INT32 dstStep, /* bytes */
93 INT32 width, INT32 height); /* pixels */
94typedef pstatus_t (*fn_set_8u_t)(BYTE val, BYTE* WINPR_RESTRICT pDst, UINT32 len);
95typedef pstatus_t (*fn_set_32s_t)(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 len);
96typedef pstatus_t (*fn_set_32u_t)(UINT32 val, UINT32* WINPR_RESTRICT pDst, UINT32 len);
97typedef pstatus_t (*fn_zero_t)(void* WINPR_RESTRICT pDst, size_t bytes);
98typedef pstatus_t (*fn_alphaComp_argb_t)(const BYTE* WINPR_RESTRICT pSrc1, UINT32 src1Step,
99 const BYTE* WINPR_RESTRICT pSrc2, UINT32 src2Step,
100 BYTE* WINPR_RESTRICT pDst, UINT32 dstStep, UINT32 width,
101 UINT32 height);
102typedef pstatus_t (*fn_add_16s_t)(const INT16* WINPR_RESTRICT pSrc1,
103 const INT16* WINPR_RESTRICT pSrc2, INT16* WINPR_RESTRICT pDst,
104 UINT32 len);
113typedef pstatus_t (*fn_add_16s_inplace_t)(INT16* WINPR_RESTRICT pSrcDst1,
114 INT16* WINPR_RESTRICT pSrcDst2, UINT32 len);
115
136typedef pstatus_t (*fn_copy_no_overlap_t)(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat,
137 UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
138 UINT32 nWidth, UINT32 nHeight,
139 const BYTE* WINPR_RESTRICT pSrcData, DWORD SrcFormat,
140 UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
141 const gdiPalette* WINPR_RESTRICT palette, UINT32 flags);
142typedef pstatus_t (*fn_lShiftC_16s_inplace_t)(INT16* WINPR_RESTRICT pSrcDst, UINT32 val,
143 UINT32 len);
144typedef pstatus_t (*fn_lShiftC_16s_t)(const INT16* WINPR_RESTRICT pSrc, UINT32 val,
145 INT16* WINPR_RESTRICT pSrcDst, UINT32 len);
146typedef pstatus_t (*fn_lShiftC_16u_t)(const UINT16* WINPR_RESTRICT pSrc, UINT32 val,
147 UINT16* WINPR_RESTRICT pSrcDst, UINT32 len);
148typedef pstatus_t (*fn_rShiftC_16s_t)(const INT16* WINPR_RESTRICT pSrc, UINT32 val,
149 INT16* WINPR_RESTRICT pSrcDst, UINT32 len);
150typedef pstatus_t (*fn_rShiftC_16u_t)(const UINT16* WINPR_RESTRICT pSrc, UINT32 val,
151 UINT16* WINPR_RESTRICT pSrcDst, UINT32 len);
152typedef pstatus_t (*fn_shiftC_16s_t)(const INT16* WINPR_RESTRICT pSrc, INT32 val,
153 INT16* WINPR_RESTRICT pSrcDst, UINT32 len);
154typedef pstatus_t (*fn_shiftC_16u_t)(const UINT16* WINPR_RESTRICT pSrc, INT32 val,
155 UINT16* WINPR_RESTRICT pSrcDst, UINT32 len);
156typedef pstatus_t (*fn_sign_16s_t)(const INT16* WINPR_RESTRICT pSrc, INT16* WINPR_RESTRICT pSrcDst,
157 UINT32 len);
158typedef pstatus_t (*fn_yCbCrToRGB_16s8u_P3AC4R_t)(const INT16* WINPR_RESTRICT pSrc[3],
159 UINT32 srcStep, BYTE* WINPR_RESTRICT pDst,
160 UINT32 dstStep, UINT32 DstFormat,
161 const prim_size_t* WINPR_RESTRICT roi);
162typedef pstatus_t (*fn_yCbCrToRGB_16s16s_P3P3_t)(const INT16* WINPR_RESTRICT pSrc[3], INT32 srcStep,
163 INT16* WINPR_RESTRICT pDst[3], INT32 dstStep,
164 const prim_size_t* WINPR_RESTRICT roi);
165typedef pstatus_t (*fn_RGBToYCbCr_16s16s_P3P3_t)(const INT16* WINPR_RESTRICT pSrc[3], INT32 srcStep,
166 INT16* WINPR_RESTRICT pDst[3], INT32 dstStep,
167 const prim_size_t* WINPR_RESTRICT roi);
168typedef pstatus_t (*fn_RGBToRGB_16s8u_P3AC4R_t)(const INT16* WINPR_RESTRICT pSrc[3], UINT32 srcStep,
169 BYTE* WINPR_RESTRICT pDst, UINT32 dstStep,
170 UINT32 DstFormat,
171 const prim_size_t* WINPR_RESTRICT roi);
172typedef pstatus_t (*fn_YCoCgToRGB_8u_AC4R_t)(const BYTE* WINPR_RESTRICT pSrc, INT32 srcStep,
173 BYTE* WINPR_RESTRICT pDst, UINT32 DstFormat,
174 INT32 dstStep, UINT32 width, UINT32 height,
175 UINT8 shift, BOOL withAlpha);
176typedef pstatus_t (*fn_RGB565ToARGB_16u32u_C3C4_t)(const UINT16* WINPR_RESTRICT pSrc, INT32 srcStep,
177 UINT32* WINPR_RESTRICT pDst, INT32 dstStep,
178 UINT32 width, UINT32 height, UINT32 format);
179typedef pstatus_t (*fn_YUV420ToRGB_8u_P3AC4R_t)(const BYTE* WINPR_RESTRICT pSrc[3],
180 const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDst,
181 UINT32 dstStep, UINT32 DstFormat,
182 const prim_size_t* WINPR_RESTRICT roi);
183typedef pstatus_t (*fn_YUV444ToRGB_8u_P3AC4R_t)(const BYTE* WINPR_RESTRICT pSrc[3],
184 const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDst,
185 UINT32 dstStep, UINT32 DstFormat,
186 const prim_size_t* WINPR_RESTRICT roi);
187typedef pstatus_t (*fn_RGBToYUV420_8u_P3AC4R_t)(const BYTE* WINPR_RESTRICT pSrc, UINT32 SrcFormat,
188 UINT32 srcStep, BYTE* WINPR_RESTRICT pDst[3],
189 const UINT32 dstStep[3],
190 const prim_size_t* WINPR_RESTRICT roi);
191typedef pstatus_t (*fn_RGBToYUV444_8u_P3AC4R_t)(const BYTE* WINPR_RESTRICT pSrc, UINT32 SrcFormat,
192 UINT32 srcStep, BYTE* WINPR_RESTRICT pDst[3],
193 const UINT32 dstStep[3],
194 const prim_size_t* WINPR_RESTRICT roi);
195typedef pstatus_t (*fn_YUV420CombineToYUV444_t)(avc444_frame_type type,
196 const BYTE* WINPR_RESTRICT pSrc[3],
197 const UINT32 srcStep[3], UINT32 nWidth,
198 UINT32 nHeight, BYTE* WINPR_RESTRICT pDst[3],
199 const UINT32 dstStep[3],
200 const RECTANGLE_16* WINPR_RESTRICT roi);
201typedef pstatus_t (*fn_YUV444SplitToYUV420_t)(
202 const BYTE* WINPR_RESTRICT pSrc[3], const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pMainDst[3],
203 const UINT32 dstMainStep[3], BYTE* WINPR_RESTRICT pAuxDst[3], const UINT32 srcAuxStep[3],
204 const prim_size_t* WINPR_RESTRICT roi);
205typedef pstatus_t (*fn_RGBToAVC444YUV_t)(const BYTE* WINPR_RESTRICT pSrc, UINT32 srcFormat,
206 UINT32 srcStep, BYTE* WINPR_RESTRICT pMainDst[3],
207 const UINT32 dstMainStep[3],
208 BYTE* WINPR_RESTRICT pAuxDst[3],
209 const UINT32 dstAuxStep[3],
210 const prim_size_t* WINPR_RESTRICT roi);
211typedef pstatus_t (*fn_andC_32u_t)(const UINT32* WINPR_RESTRICT pSrc, UINT32 val,
212 UINT32* WINPR_RESTRICT pDst, INT32 len);
213typedef pstatus_t (*fn_orC_32u_t)(const UINT32* WINPR_RESTRICT pSrc, UINT32 val,
214 UINT32* WINPR_RESTRICT pDst, INT32 len);
215typedef pstatus_t (*primitives_uninit_t)(void);
216
217#if defined(WITH_FREERDP_3x_DEPRECATED)
218typedef fn_copy_t __copy_t;
219typedef fn_copy_8u_t __copy_8u_t;
220typedef fn_copy_8u_AC4r_t __copy_8u_AC4r_t;
221typedef fn_set_8u_t __set_8u_t;
222typedef fn_set_32s_t __set_32s_t;
223typedef fn_set_32u_t __set_32u_t;
224typedef fn_zero_t __zero_t;
225typedef fn_alphaComp_argb_t __alphaComp_argb_t;
226typedef fn_add_16s_t __add_16s_t;
227typedef fn_add_16s_inplace_t __add_16s_inplace_t;
228typedef fn_copy_no_overlap_t __copy_no_overlap_t;
229typedef fn_lShiftC_16s_inplace_t __lShiftC_16s_inplace_t;
230typedef fn_lShiftC_16s_t __lShiftC_16s_t;
231typedef fn_lShiftC_16u_t __lShiftC_16u_t;
232typedef fn_rShiftC_16s_t __rShiftC_16s_t;
233typedef fn_rShiftC_16u_t __rShiftC_16u_t;
234typedef fn_shiftC_16s_t __shiftC_16s_t;
235typedef fn_shiftC_16u_t __shiftC_16u_t;
236typedef fn_sign_16s_t __sign_16s_t;
237typedef fn_yCbCrToRGB_16s8u_P3AC4R_t __yCbCrToRGB_16s8u_P3AC4R_t;
238typedef fn_yCbCrToRGB_16s16s_P3P3_t __yCbCrToRGB_16s16s_P3P3_t;
239typedef fn_RGBToYCbCr_16s16s_P3P3_t __RGBToYCbCr_16s16s_P3P3_t;
240typedef fn_RGBToRGB_16s8u_P3AC4R_t __RGBToRGB_16s8u_P3AC4R_t;
241typedef fn_YCoCgToRGB_8u_AC4R_t __YCoCgToRGB_8u_AC4R_t;
242typedef fn_RGB565ToARGB_16u32u_C3C4_t __RGB565ToARGB_16u32u_C3C4_t;
243typedef fn_YUV420ToRGB_8u_P3AC4R_t __YUV420ToRGB_8u_P3AC4R_t;
244typedef fn_YUV444ToRGB_8u_P3AC4R_t __YUV444ToRGB_8u_P3AC4R_t;
245typedef fn_RGBToYUV420_8u_P3AC4R_t __RGBToYUV420_8u_P3AC4R_t;
246typedef fn_RGBToYUV444_8u_P3AC4R_t __RGBToYUV444_8u_P3AC4R_t;
247typedef fn_YUV420CombineToYUV444_t __YUV420CombineToYUV444_t;
248typedef fn_YUV444SplitToYUV420_t __YUV444SplitToYUV420_t;
249typedef fn_RGBToAVC444YUV_t __RGBToAVC444YUV_t;
250typedef fn_andC_32u_t __andC_32u_t;
251typedef fn_orC_32u_t __orC_32u_t;
252#endif
253
254typedef struct
255{
256 /* Memory-to-memory copy routines */
257 fn_copy_t copy; /* memcpy/memmove, basically */
258 fn_copy_8u_t copy_8u; /* more strongly typed */
259 fn_copy_8u_AC4r_t copy_8u_AC4r; /* pixel copy function */
260 /* Memory setting routines */
261 fn_set_8u_t set_8u; /* memset, basically */
262 fn_set_32s_t set_32s;
263 fn_set_32u_t set_32u;
264 fn_zero_t zero; /* bzero or faster */
265 /* Arithmetic functions */
266 fn_add_16s_t add_16s;
267 /* And/or */
268 fn_andC_32u_t andC_32u;
269 fn_orC_32u_t orC_32u;
270 /* Shifts */
271 fn_lShiftC_16s_t lShiftC_16s;
272 fn_lShiftC_16u_t lShiftC_16u;
273 fn_rShiftC_16s_t rShiftC_16s;
274 fn_rShiftC_16u_t rShiftC_16u;
275 fn_shiftC_16s_t shiftC_16s;
276 fn_shiftC_16u_t shiftC_16u;
277 /* Alpha Composition */
278 fn_alphaComp_argb_t alphaComp_argb;
279 /* Sign */
280 fn_sign_16s_t sign_16s;
281 /* Color conversions */
282 fn_yCbCrToRGB_16s8u_P3AC4R_t yCbCrToRGB_16s8u_P3AC4R;
283 fn_yCbCrToRGB_16s16s_P3P3_t yCbCrToRGB_16s16s_P3P3;
284 fn_RGBToYCbCr_16s16s_P3P3_t RGBToYCbCr_16s16s_P3P3;
285 fn_RGBToRGB_16s8u_P3AC4R_t RGBToRGB_16s8u_P3AC4R;
286 fn_YCoCgToRGB_8u_AC4R_t YCoCgToRGB_8u_AC4R;
287 fn_YUV420ToRGB_8u_P3AC4R_t YUV420ToRGB_8u_P3AC4R;
288 fn_RGBToYUV420_8u_P3AC4R_t RGBToYUV420_8u_P3AC4R;
289 fn_RGBToYUV444_8u_P3AC4R_t RGBToYUV444_8u_P3AC4R;
290 fn_YUV420CombineToYUV444_t YUV420CombineToYUV444;
291 fn_YUV444SplitToYUV420_t YUV444SplitToYUV420;
292 fn_YUV444ToRGB_8u_P3AC4R_t YUV444ToRGB_8u_P3AC4R;
293 fn_RGBToAVC444YUV_t RGBToAVC444YUV;
294 fn_RGBToAVC444YUV_t RGBToAVC444YUVv2;
295 /* flags */
296 DWORD flags;
297 primitives_uninit_t uninit;
298
302 fn_add_16s_inplace_t add_16s_inplace;
303 fn_lShiftC_16s_inplace_t lShiftC_16s_inplace;
304 fn_copy_no_overlap_t copy_no_overlap;
306
307typedef enum
308{
309 PRIMITIVES_PURE_SOFT,
310 PRIMITIVES_ONLY_CPU,
311 PRIMITIVES_ONLY_GPU,
312 PRIMITIVES_AUTODETECT
313} primitive_hints;
314
315 FREERDP_API primitives_t* primitives_get(void);
316 FREERDP_API void primitives_set_hints(primitive_hints hints);
317 FREERDP_API primitive_hints primitives_get_hints(void);
318 FREERDP_API primitives_t* primitives_get_generic(void);
319 FREERDP_API DWORD primitives_flags(primitives_t* p);
320 FREERDP_API BOOL primitives_init(primitives_t* p, primitive_hints hints);
321 FREERDP_API void primitives_uninit(void);
322
333 FREERDP_API primitives_t* primitives_get_by_type(primitive_hints type);
334
341 FREERDP_API const char* primitives_avc444_frame_type_str(avc444_frame_type type);
342
349 FREERDP_API const char* primtives_hint_str(primitive_hints hint);
350
351#ifdef __cplusplus
352}
353#endif
354
355#endif /* FREERDP_PRIMITIVES_H */
fn_add_16s_inplace_t add_16s_inplace
Do vecotor addition, store result in both input buffers pSrcDst1 = pSrcDst2 = pSrcDst1 + pSrcDst2.
Definition primitives.h:302
fn_copy_no_overlap_t copy_no_overlap
Definition primitives.h:304
fn_lShiftC_16s_inplace_t lShiftC_16s_inplace
Definition primitives.h:303