/src/FreeRDP/libfreerdp/codec/yuv.c
Line | Count | Source |
1 | | #include <winpr/sysinfo.h> |
2 | | #include <winpr/assert.h> |
3 | | #include <winpr/cast.h> |
4 | | #include <winpr/pool.h> |
5 | | |
6 | | #include <freerdp/settings.h> |
7 | | #include <freerdp/codec/region.h> |
8 | | #include <freerdp/primitives.h> |
9 | | #include <freerdp/log.h> |
10 | | #include <freerdp/codec/yuv.h> |
11 | | |
12 | | #define TAG FREERDP_TAG("codec") |
13 | | |
14 | 0 | #define TILE_SIZE 64 |
15 | | |
16 | | typedef struct |
17 | | { |
18 | | YUV_CONTEXT* context; |
19 | | const BYTE* pYUVData[3]; |
20 | | UINT32 iStride[3]; |
21 | | DWORD DstFormat; |
22 | | BYTE* dest; |
23 | | UINT32 nDstStep; |
24 | | RECTANGLE_16 rect; |
25 | | } YUV_PROCESS_WORK_PARAM; |
26 | | |
27 | | typedef struct |
28 | | { |
29 | | YUV_CONTEXT* context; |
30 | | const BYTE* pYUVData[3]; |
31 | | UINT32 iStride[3]; |
32 | | BYTE* pYUVDstData[3]; |
33 | | UINT32 iDstStride[3]; |
34 | | RECTANGLE_16 rect; |
35 | | avc444_frame_type type; |
36 | | } YUV_COMBINE_WORK_PARAM; |
37 | | |
38 | | typedef struct |
39 | | { |
40 | | YUV_CONTEXT* context; |
41 | | const BYTE* pSrcData; |
42 | | |
43 | | DWORD SrcFormat; |
44 | | UINT32 nSrcStep; |
45 | | RECTANGLE_16 rect; |
46 | | BYTE version; |
47 | | |
48 | | BYTE* pYUVLumaData[3]; |
49 | | BYTE* pYUVChromaData[3]; |
50 | | UINT32 iStride[3]; |
51 | | } YUV_ENCODE_WORK_PARAM; |
52 | | |
53 | | struct S_YUV_CONTEXT |
54 | | { |
55 | | UINT32 width, height; |
56 | | BOOL useThreads; |
57 | | BOOL encoder; |
58 | | UINT32 heightStep; |
59 | | |
60 | | UINT32 work_object_count; |
61 | | PTP_WORK* work_objects; |
62 | | YUV_ENCODE_WORK_PARAM* work_enc_params; |
63 | | YUV_PROCESS_WORK_PARAM* work_dec_params; |
64 | | YUV_COMBINE_WORK_PARAM* work_combined_params; |
65 | | }; |
66 | | |
67 | | static inline BOOL avc420_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3], |
68 | | const UINT32 iStride[3], |
69 | | const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstStep, |
70 | | BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat) |
71 | 0 | { |
72 | 0 | primitives_t* prims = primitives_get(); |
73 | 0 | prim_size_t roi; |
74 | 0 | const BYTE* pYUVPoint[3]; |
75 | |
|
76 | 0 | WINPR_ASSERT(pYUVData); |
77 | 0 | WINPR_ASSERT(iStride); |
78 | 0 | WINPR_ASSERT(rect); |
79 | 0 | WINPR_ASSERT(pDstData); |
80 | |
|
81 | 0 | const INT32 width = rect->right - rect->left; |
82 | 0 | const INT32 height = rect->bottom - rect->top; |
83 | 0 | BYTE* pDstPoint = pDstData + 1ULL * rect->top * nDstStep + |
84 | 0 | 1ULL * rect->left * FreeRDPGetBytesPerPixel(DstFormat); |
85 | |
|
86 | 0 | pYUVPoint[0] = pYUVData[0] + 1ULL * rect->top * iStride[0] + rect->left; |
87 | 0 | pYUVPoint[1] = pYUVData[1] + 1ULL * rect->top / 2 * iStride[1] + rect->left / 2; |
88 | 0 | pYUVPoint[2] = pYUVData[2] + 1ULL * rect->top / 2 * iStride[2] + rect->left / 2; |
89 | |
|
90 | 0 | roi.width = WINPR_ASSERTING_INT_CAST(uint32_t, width); |
91 | 0 | roi.height = WINPR_ASSERTING_INT_CAST(uint32_t, height); |
92 | |
|
93 | 0 | if (prims->YUV420ToRGB_8u_P3AC4R(pYUVPoint, iStride, pDstPoint, nDstStep, DstFormat, &roi) != |
94 | 0 | PRIMITIVES_SUCCESS) |
95 | 0 | return FALSE; |
96 | | |
97 | 0 | return TRUE; |
98 | 0 | } |
99 | | |
100 | | static inline BOOL avc444_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3], |
101 | | const UINT32 iStride[3], |
102 | | const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstStep, |
103 | | BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat) |
104 | 0 | { |
105 | 0 | primitives_t* prims = primitives_get(); |
106 | 0 | prim_size_t roi; |
107 | 0 | const BYTE* pYUVPoint[3]; |
108 | |
|
109 | 0 | WINPR_ASSERT(pYUVData); |
110 | 0 | WINPR_ASSERT(iStride); |
111 | 0 | WINPR_ASSERT(rect); |
112 | 0 | WINPR_ASSERT(pDstData); |
113 | |
|
114 | 0 | const INT32 width = rect->right - rect->left; |
115 | 0 | const INT32 height = rect->bottom - rect->top; |
116 | 0 | BYTE* pDstPoint = pDstData + 1ULL * rect->top * nDstStep + |
117 | 0 | 1ULL * rect->left * FreeRDPGetBytesPerPixel(DstFormat); |
118 | |
|
119 | 0 | pYUVPoint[0] = pYUVData[0] + 1ULL * rect->top * iStride[0] + rect->left; |
120 | 0 | pYUVPoint[1] = pYUVData[1] + 1ULL * rect->top * iStride[1] + rect->left; |
121 | 0 | pYUVPoint[2] = pYUVData[2] + 1ULL * rect->top * iStride[2] + rect->left; |
122 | |
|
123 | 0 | roi.width = WINPR_ASSERTING_INT_CAST(uint32_t, width); |
124 | 0 | roi.height = WINPR_ASSERTING_INT_CAST(uint32_t, height); |
125 | |
|
126 | 0 | if (prims->YUV444ToRGB_8u_P3AC4R(pYUVPoint, iStride, pDstPoint, nDstStep, DstFormat, &roi) != |
127 | 0 | PRIMITIVES_SUCCESS) |
128 | 0 | return FALSE; |
129 | | |
130 | 0 | return TRUE; |
131 | 0 | } |
132 | | |
133 | | static void CALLBACK yuv420_process_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
134 | | PTP_WORK work) |
135 | 0 | { |
136 | 0 | YUV_PROCESS_WORK_PARAM* param = (YUV_PROCESS_WORK_PARAM*)context; |
137 | 0 | WINPR_UNUSED(instance); |
138 | 0 | WINPR_UNUSED(work); |
139 | 0 | WINPR_ASSERT(param); |
140 | |
|
141 | 0 | if (!avc420_yuv_to_rgb(param->pYUVData, param->iStride, ¶m->rect, param->nDstStep, |
142 | 0 | param->dest, param->DstFormat)) |
143 | 0 | WLog_WARN(TAG, "avc420_yuv_to_rgb failed"); |
144 | 0 | } |
145 | | |
146 | | static void CALLBACK yuv444_process_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
147 | | PTP_WORK work) |
148 | 0 | { |
149 | 0 | YUV_PROCESS_WORK_PARAM* param = (YUV_PROCESS_WORK_PARAM*)context; |
150 | 0 | WINPR_UNUSED(instance); |
151 | 0 | WINPR_UNUSED(work); |
152 | 0 | WINPR_ASSERT(param); |
153 | |
|
154 | 0 | if (!avc444_yuv_to_rgb(param->pYUVData, param->iStride, ¶m->rect, param->nDstStep, |
155 | 0 | param->dest, param->DstFormat)) |
156 | 0 | WLog_WARN(TAG, "avc444_yuv_to_rgb failed"); |
157 | 0 | } |
158 | | |
159 | | BOOL yuv_context_reset(YUV_CONTEXT* WINPR_RESTRICT context, UINT32 width, UINT32 height) |
160 | 0 | { |
161 | 0 | BOOL rc = FALSE; |
162 | 0 | WINPR_ASSERT(context); |
163 | |
|
164 | 0 | context->width = width; |
165 | 0 | context->height = height; |
166 | |
|
167 | 0 | context->heightStep = height; |
168 | |
|
169 | 0 | if (context->useThreads) |
170 | 0 | { |
171 | 0 | context->heightStep = 16; |
172 | | /* Preallocate workers for 16x16 tiles. |
173 | | * this is overallocation for most cases. |
174 | | * |
175 | | * ~2MB total for a 4k resolution, so negligible. |
176 | | */ |
177 | 0 | const size_t pw = (width + TILE_SIZE - width % TILE_SIZE) / 16; |
178 | 0 | const size_t ph = (height + TILE_SIZE - height % TILE_SIZE) / 16; |
179 | |
|
180 | 0 | const size_t count = pw * ph; |
181 | |
|
182 | 0 | context->work_object_count = 0; |
183 | 0 | if (context->encoder) |
184 | 0 | { |
185 | 0 | void* tmp = winpr_aligned_recalloc(context->work_enc_params, count, |
186 | 0 | sizeof(YUV_ENCODE_WORK_PARAM), 32); |
187 | 0 | if (!tmp) |
188 | 0 | goto fail; |
189 | 0 | memset(tmp, 0, count * sizeof(YUV_ENCODE_WORK_PARAM)); |
190 | |
|
191 | 0 | context->work_enc_params = tmp; |
192 | 0 | } |
193 | 0 | else |
194 | 0 | { |
195 | 0 | void* tmp = winpr_aligned_recalloc(context->work_dec_params, count, |
196 | 0 | sizeof(YUV_PROCESS_WORK_PARAM), 32); |
197 | 0 | if (!tmp) |
198 | 0 | goto fail; |
199 | 0 | memset(tmp, 0, count * sizeof(YUV_PROCESS_WORK_PARAM)); |
200 | |
|
201 | 0 | context->work_dec_params = tmp; |
202 | |
|
203 | 0 | void* ctmp = winpr_aligned_recalloc(context->work_combined_params, count, |
204 | 0 | sizeof(YUV_COMBINE_WORK_PARAM), 32); |
205 | 0 | if (!ctmp) |
206 | 0 | goto fail; |
207 | 0 | memset(ctmp, 0, count * sizeof(YUV_COMBINE_WORK_PARAM)); |
208 | |
|
209 | 0 | context->work_combined_params = ctmp; |
210 | 0 | } |
211 | | |
212 | 0 | void* wtmp = |
213 | 0 | winpr_aligned_recalloc((void*)context->work_objects, count, sizeof(PTP_WORK), 32); |
214 | 0 | if (!wtmp) |
215 | 0 | goto fail; |
216 | 0 | memset(wtmp, 0, count * sizeof(PTP_WORK)); |
217 | |
|
218 | 0 | context->work_objects = (PTP_WORK*)wtmp; |
219 | 0 | context->work_object_count = WINPR_ASSERTING_INT_CAST(uint32_t, count); |
220 | 0 | } |
221 | 0 | rc = TRUE; |
222 | 0 | fail: |
223 | 0 | return rc; |
224 | 0 | } |
225 | | |
226 | | YUV_CONTEXT* yuv_context_new(BOOL encoder, UINT32 ThreadingFlags) |
227 | 0 | { |
228 | 0 | SYSTEM_INFO sysInfos = WINPR_C_ARRAY_INIT; |
229 | | /** do it here to avoid a race condition between threads */ |
230 | 0 | if (!primitives_get()) |
231 | 0 | return NULL; |
232 | | |
233 | 0 | YUV_CONTEXT* ret = winpr_aligned_calloc(1, sizeof(*ret), 32); |
234 | 0 | if (!ret) |
235 | 0 | return NULL; |
236 | | |
237 | 0 | ret->encoder = encoder; |
238 | 0 | if (!(ThreadingFlags & THREADING_FLAGS_DISABLE_THREADS)) |
239 | 0 | { |
240 | 0 | GetNativeSystemInfo(&sysInfos); |
241 | 0 | ret->useThreads = (sysInfos.dwNumberOfProcessors > 1); |
242 | 0 | } |
243 | |
|
244 | 0 | return ret; |
245 | 0 | } |
246 | | |
247 | | void yuv_context_free(YUV_CONTEXT* context) |
248 | 0 | { |
249 | 0 | if (!context) |
250 | 0 | return; |
251 | 0 | if (context->useThreads) |
252 | 0 | { |
253 | 0 | winpr_aligned_free((void*)context->work_objects); |
254 | 0 | winpr_aligned_free(context->work_combined_params); |
255 | 0 | winpr_aligned_free(context->work_enc_params); |
256 | 0 | winpr_aligned_free(context->work_dec_params); |
257 | 0 | } |
258 | 0 | winpr_aligned_free(context); |
259 | 0 | } |
260 | | |
261 | | static inline YUV_PROCESS_WORK_PARAM pool_decode_param(const RECTANGLE_16* WINPR_RESTRICT rect, |
262 | | YUV_CONTEXT* WINPR_RESTRICT context, |
263 | | const BYTE* WINPR_RESTRICT pYUVData[3], |
264 | | const UINT32 iStride[3], UINT32 DstFormat, |
265 | | BYTE* WINPR_RESTRICT dest, UINT32 nDstStep) |
266 | 0 | { |
267 | 0 | YUV_PROCESS_WORK_PARAM current = WINPR_C_ARRAY_INIT; |
268 | |
|
269 | 0 | WINPR_ASSERT(rect); |
270 | 0 | WINPR_ASSERT(context); |
271 | 0 | WINPR_ASSERT(pYUVData); |
272 | 0 | WINPR_ASSERT(iStride); |
273 | 0 | WINPR_ASSERT(dest); |
274 | |
|
275 | 0 | current.context = context; |
276 | 0 | current.DstFormat = DstFormat; |
277 | 0 | current.pYUVData[0] = pYUVData[0]; |
278 | 0 | current.pYUVData[1] = pYUVData[1]; |
279 | 0 | current.pYUVData[2] = pYUVData[2]; |
280 | 0 | current.iStride[0] = iStride[0]; |
281 | 0 | current.iStride[1] = iStride[1]; |
282 | 0 | current.iStride[2] = iStride[2]; |
283 | 0 | current.nDstStep = nDstStep; |
284 | 0 | current.dest = dest; |
285 | 0 | current.rect = *rect; |
286 | 0 | return current; |
287 | 0 | } |
288 | | |
289 | | static BOOL submit_object(PTP_WORK* WINPR_RESTRICT work_object, PTP_WORK_CALLBACK cb, |
290 | | const void* WINPR_RESTRICT param, YUV_CONTEXT* WINPR_RESTRICT context) |
291 | 0 | { |
292 | 0 | union |
293 | 0 | { |
294 | 0 | const void* cpv; |
295 | 0 | void* pv; |
296 | 0 | } cnv; |
297 | |
|
298 | 0 | cnv.cpv = param; |
299 | |
|
300 | 0 | if (!work_object) |
301 | 0 | return FALSE; |
302 | | |
303 | 0 | *work_object = NULL; |
304 | |
|
305 | 0 | if (!param || !context) |
306 | 0 | return FALSE; |
307 | | |
308 | 0 | *work_object = CreateThreadpoolWork(cb, cnv.pv, NULL); |
309 | 0 | if (!*work_object) |
310 | 0 | return FALSE; |
311 | | |
312 | 0 | SubmitThreadpoolWork(*work_object); |
313 | 0 | return TRUE; |
314 | 0 | } |
315 | | |
316 | | static void free_objects(PTP_WORK* work_objects, UINT32 waitCount) |
317 | 0 | { |
318 | 0 | WINPR_ASSERT(work_objects || (waitCount == 0)); |
319 | |
|
320 | 0 | for (UINT32 i = 0; i < waitCount; i++) |
321 | 0 | { |
322 | 0 | PTP_WORK cur = work_objects[i]; |
323 | 0 | work_objects[i] = NULL; |
324 | |
|
325 | 0 | if (!cur) |
326 | 0 | continue; |
327 | | |
328 | 0 | WaitForThreadpoolWorkCallbacks(cur, FALSE); |
329 | 0 | CloseThreadpoolWork(cur); |
330 | 0 | } |
331 | 0 | } |
332 | | |
333 | | static BOOL intersects(UINT32 pos, const RECTANGLE_16* WINPR_RESTRICT regionRects, |
334 | | UINT32 numRegionRects) |
335 | 0 | { |
336 | 0 | WINPR_ASSERT(regionRects || (numRegionRects == 0)); |
337 | |
|
338 | 0 | for (UINT32 x = pos + 1; x < numRegionRects; x++) |
339 | 0 | { |
340 | 0 | const RECTANGLE_16* what = ®ionRects[pos]; |
341 | 0 | const RECTANGLE_16* rect = ®ionRects[x]; |
342 | |
|
343 | 0 | if (rectangles_intersects(what, rect)) |
344 | 0 | { |
345 | 0 | WLog_WARN(TAG, "YUV decoder: intersecting rectangles, aborting"); |
346 | 0 | return TRUE; |
347 | 0 | } |
348 | 0 | } |
349 | | |
350 | 0 | return FALSE; |
351 | 0 | } |
352 | | |
353 | | static RECTANGLE_16 clamp(YUV_CONTEXT* WINPR_RESTRICT context, |
354 | | const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 srcHeight) |
355 | 0 | { |
356 | 0 | WINPR_ASSERT(context); |
357 | 0 | WINPR_ASSERT(rect); |
358 | |
|
359 | 0 | RECTANGLE_16 c = *rect; |
360 | 0 | const UINT32 height = MIN(context->height, srcHeight); |
361 | 0 | if (c.top > height) |
362 | 0 | c.top = WINPR_ASSERTING_INT_CAST(UINT16, height); |
363 | 0 | if (c.bottom > height) |
364 | 0 | c.bottom = WINPR_ASSERTING_INT_CAST(UINT16, height); |
365 | 0 | return c; |
366 | 0 | } |
367 | | |
368 | | static BOOL pool_decode(YUV_CONTEXT* WINPR_RESTRICT context, PTP_WORK_CALLBACK cb, |
369 | | const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3], |
370 | | UINT32 yuvHeight, UINT32 DstFormat, BYTE* WINPR_RESTRICT dest, |
371 | | UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects, |
372 | | UINT32 numRegionRects) |
373 | 0 | { |
374 | 0 | BOOL rc = FALSE; |
375 | 0 | UINT32 waitCount = 0; |
376 | 0 | primitives_t* prims = primitives_get(); |
377 | |
|
378 | 0 | WINPR_ASSERT(context); |
379 | 0 | WINPR_ASSERT(cb); |
380 | 0 | WINPR_ASSERT(pYUVData); |
381 | 0 | WINPR_ASSERT(iStride); |
382 | 0 | WINPR_ASSERT(dest); |
383 | 0 | WINPR_ASSERT(regionRects || (numRegionRects == 0)); |
384 | |
|
385 | 0 | if (context->encoder) |
386 | 0 | { |
387 | 0 | WLog_ERR(TAG, "YUV context set up for encoding, can not decode with it, aborting"); |
388 | 0 | return FALSE; |
389 | 0 | } |
390 | | |
391 | 0 | if (!context->useThreads || (primitives_flags(prims) & PRIM_FLAGS_HAVE_EXTGPU)) |
392 | 0 | { |
393 | 0 | for (UINT32 y = 0; y < numRegionRects; y++) |
394 | 0 | { |
395 | 0 | const RECTANGLE_16 rect = clamp(context, ®ionRects[y], yuvHeight); |
396 | 0 | YUV_PROCESS_WORK_PARAM current = |
397 | 0 | pool_decode_param(&rect, context, pYUVData, iStride, DstFormat, dest, nDstStep); |
398 | 0 | cb(NULL, ¤t, NULL); |
399 | 0 | } |
400 | 0 | return TRUE; |
401 | 0 | } |
402 | | |
403 | | /* case where we use threads */ |
404 | 0 | for (UINT32 x = 0; x < numRegionRects; x++) |
405 | 0 | { |
406 | 0 | RECTANGLE_16 r = clamp(context, ®ionRects[x], yuvHeight); |
407 | |
|
408 | 0 | if (intersects(x, regionRects, numRegionRects)) |
409 | 0 | continue; |
410 | | |
411 | 0 | while (r.left < r.right) |
412 | 0 | { |
413 | 0 | RECTANGLE_16 y = r; |
414 | 0 | y.right = MIN(r.right, r.left + TILE_SIZE); |
415 | |
|
416 | 0 | while (y.top < y.bottom) |
417 | 0 | { |
418 | 0 | RECTANGLE_16 z = y; |
419 | |
|
420 | 0 | if (context->work_object_count <= waitCount) |
421 | 0 | { |
422 | 0 | free_objects(context->work_objects, context->work_object_count); |
423 | 0 | waitCount = 0; |
424 | 0 | } |
425 | |
|
426 | 0 | YUV_PROCESS_WORK_PARAM* cur = &context->work_dec_params[waitCount]; |
427 | 0 | z.bottom = MIN(z.bottom, z.top + TILE_SIZE); |
428 | 0 | if (rectangle_is_empty(&z)) |
429 | 0 | continue; |
430 | 0 | *cur = pool_decode_param(&z, context, pYUVData, iStride, DstFormat, dest, nDstStep); |
431 | 0 | if (!submit_object(&context->work_objects[waitCount], cb, cur, context)) |
432 | 0 | goto fail; |
433 | 0 | waitCount++; |
434 | 0 | y.top += TILE_SIZE; |
435 | 0 | } |
436 | | |
437 | 0 | r.left += TILE_SIZE; |
438 | 0 | } |
439 | 0 | } |
440 | 0 | rc = TRUE; |
441 | 0 | fail: |
442 | 0 | free_objects(context->work_objects, context->work_object_count); |
443 | 0 | return rc; |
444 | 0 | } |
445 | | |
446 | | static inline BOOL check_rect(const YUV_CONTEXT* WINPR_RESTRICT yuv, |
447 | | const RECTANGLE_16* WINPR_RESTRICT rect, UINT32 nDstWidth, |
448 | | UINT32 nDstHeight) |
449 | 0 | { |
450 | 0 | WINPR_ASSERT(yuv); |
451 | 0 | WINPR_ASSERT(rect); |
452 | | |
453 | | /* Check, if the output rectangle is valid in decoded h264 frame. */ |
454 | 0 | if ((rect->right > yuv->width) || (rect->left > yuv->width)) |
455 | 0 | return FALSE; |
456 | | |
457 | 0 | if ((rect->top > yuv->height) || (rect->bottom > yuv->height)) |
458 | 0 | return FALSE; |
459 | | |
460 | | /* Check, if the output rectangle is valid in destination buffer. */ |
461 | 0 | if ((rect->right > nDstWidth) || (rect->left > nDstWidth)) |
462 | 0 | return FALSE; |
463 | | |
464 | 0 | if ((rect->bottom > nDstHeight) || (rect->top > nDstHeight)) |
465 | 0 | return FALSE; |
466 | | |
467 | 0 | return TRUE; |
468 | 0 | } |
469 | | |
470 | | static void CALLBACK yuv444_combine_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
471 | | PTP_WORK work) |
472 | 0 | { |
473 | 0 | YUV_COMBINE_WORK_PARAM* param = (YUV_COMBINE_WORK_PARAM*)context; |
474 | 0 | primitives_t* prims = primitives_get(); |
475 | |
|
476 | 0 | WINPR_ASSERT(param); |
477 | 0 | YUV_CONTEXT* yuv = param->context; |
478 | 0 | WINPR_ASSERT(yuv); |
479 | |
|
480 | 0 | const RECTANGLE_16* rect = ¶m->rect; |
481 | 0 | WINPR_ASSERT(rect); |
482 | |
|
483 | 0 | const UINT32 alignedWidth = yuv->width + ((yuv->width % 32 != 0) ? 32 - yuv->width % 32 : 0); |
484 | 0 | const UINT32 alignedHeight = |
485 | 0 | yuv->height + ((yuv->height % 16 != 0) ? 16 - yuv->height % 16 : 0); |
486 | |
|
487 | 0 | WINPR_UNUSED(instance); |
488 | 0 | WINPR_UNUSED(work); |
489 | |
|
490 | 0 | if (!check_rect(param->context, rect, yuv->width, yuv->height)) |
491 | 0 | return; |
492 | | |
493 | 0 | if (prims->YUV420CombineToYUV444(param->type, param->pYUVData, param->iStride, alignedWidth, |
494 | 0 | alignedHeight, param->pYUVDstData, param->iDstStride, |
495 | 0 | rect) != PRIMITIVES_SUCCESS) |
496 | 0 | WLog_WARN(TAG, "YUV420CombineToYUV444 failed"); |
497 | 0 | } |
498 | | |
499 | | static inline YUV_COMBINE_WORK_PARAM |
500 | | pool_decode_rect_param(const RECTANGLE_16* WINPR_RESTRICT rect, YUV_CONTEXT* WINPR_RESTRICT context, |
501 | | BYTE type, const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3], |
502 | | BYTE* WINPR_RESTRICT pYUVDstData[3], const UINT32 iDstStride[3]) |
503 | 0 | { |
504 | 0 | YUV_COMBINE_WORK_PARAM current = WINPR_C_ARRAY_INIT; |
505 | |
|
506 | 0 | WINPR_ASSERT(rect); |
507 | 0 | WINPR_ASSERT(context); |
508 | 0 | WINPR_ASSERT(pYUVData); |
509 | 0 | WINPR_ASSERT(iStride); |
510 | 0 | WINPR_ASSERT(pYUVDstData); |
511 | 0 | WINPR_ASSERT(iDstStride); |
512 | |
|
513 | 0 | current.context = context; |
514 | 0 | current.pYUVData[0] = pYUVData[0]; |
515 | 0 | current.pYUVData[1] = pYUVData[1]; |
516 | 0 | current.pYUVData[2] = pYUVData[2]; |
517 | 0 | current.pYUVDstData[0] = pYUVDstData[0]; |
518 | 0 | current.pYUVDstData[1] = pYUVDstData[1]; |
519 | 0 | current.pYUVDstData[2] = pYUVDstData[2]; |
520 | 0 | current.iStride[0] = iStride[0]; |
521 | 0 | current.iStride[1] = iStride[1]; |
522 | 0 | current.iStride[2] = iStride[2]; |
523 | 0 | current.iDstStride[0] = iDstStride[0]; |
524 | 0 | current.iDstStride[1] = iDstStride[1]; |
525 | 0 | current.iDstStride[2] = iDstStride[2]; |
526 | 0 | current.type = WINPR_ASSERTING_INT_CAST(avc444_frame_type, type); |
527 | 0 | current.rect = *rect; |
528 | 0 | return current; |
529 | 0 | } |
530 | | |
531 | | static BOOL pool_decode_rect(YUV_CONTEXT* WINPR_RESTRICT context, BYTE type, |
532 | | const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3], |
533 | | BYTE* WINPR_RESTRICT pYUVDstData[3], const UINT32 iDstStride[3], |
534 | | const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects) |
535 | 0 | { |
536 | 0 | BOOL rc = FALSE; |
537 | 0 | UINT32 waitCount = 0; |
538 | 0 | PTP_WORK_CALLBACK cb = yuv444_combine_work_callback; |
539 | 0 | primitives_t* prims = primitives_get(); |
540 | |
|
541 | 0 | WINPR_ASSERT(context); |
542 | 0 | WINPR_ASSERT(pYUVData); |
543 | 0 | WINPR_ASSERT(iStride); |
544 | 0 | WINPR_ASSERT(pYUVDstData); |
545 | 0 | WINPR_ASSERT(iDstStride); |
546 | 0 | WINPR_ASSERT(regionRects || (numRegionRects == 0)); |
547 | |
|
548 | 0 | if (!context->useThreads || (primitives_flags(prims) & PRIM_FLAGS_HAVE_EXTGPU)) |
549 | 0 | { |
550 | 0 | for (UINT32 y = 0; y < numRegionRects; y++) |
551 | 0 | { |
552 | 0 | YUV_COMBINE_WORK_PARAM current = pool_decode_rect_param( |
553 | 0 | ®ionRects[y], context, type, pYUVData, iStride, pYUVDstData, iDstStride); |
554 | 0 | cb(NULL, ¤t, NULL); |
555 | 0 | } |
556 | 0 | return TRUE; |
557 | 0 | } |
558 | | |
559 | | /* case where we use threads */ |
560 | 0 | for (waitCount = 0; waitCount < numRegionRects; waitCount++) |
561 | 0 | { |
562 | 0 | YUV_COMBINE_WORK_PARAM* current = NULL; |
563 | |
|
564 | 0 | if (context->work_object_count <= waitCount) |
565 | 0 | { |
566 | 0 | free_objects(context->work_objects, context->work_object_count); |
567 | 0 | waitCount = 0; |
568 | 0 | } |
569 | 0 | current = &context->work_combined_params[waitCount]; |
570 | 0 | *current = pool_decode_rect_param(®ionRects[waitCount], context, type, pYUVData, iStride, |
571 | 0 | pYUVDstData, iDstStride); |
572 | |
|
573 | 0 | if (!submit_object(&context->work_objects[waitCount], cb, current, context)) |
574 | 0 | goto fail; |
575 | 0 | } |
576 | | |
577 | 0 | rc = TRUE; |
578 | 0 | fail: |
579 | 0 | free_objects(context->work_objects, context->work_object_count); |
580 | 0 | return rc; |
581 | 0 | } |
582 | | |
583 | | BOOL yuv444_context_decode(YUV_CONTEXT* WINPR_RESTRICT context, BYTE type, |
584 | | const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3], |
585 | | UINT32 srcYuvHeight, BYTE* WINPR_RESTRICT pYUVDstData[3], |
586 | | const UINT32 iDstStride[3], DWORD DstFormat, BYTE* WINPR_RESTRICT dest, |
587 | | UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects, |
588 | | UINT32 numRegionRects) |
589 | 0 | { |
590 | 0 | const BYTE* pYUVCDstData[3]; |
591 | |
|
592 | 0 | WINPR_ASSERT(context); |
593 | 0 | WINPR_ASSERT(pYUVData); |
594 | 0 | WINPR_ASSERT(iStride); |
595 | 0 | WINPR_ASSERT(pYUVDstData); |
596 | 0 | WINPR_ASSERT(iDstStride); |
597 | 0 | WINPR_ASSERT(dest); |
598 | 0 | WINPR_ASSERT(regionRects || (numRegionRects == 0)); |
599 | |
|
600 | 0 | if (context->encoder) |
601 | 0 | { |
602 | 0 | WLog_ERR(TAG, "YUV context set up for encoding, can not decode with it, aborting"); |
603 | 0 | return FALSE; |
604 | 0 | } |
605 | 0 | if (!pool_decode_rect(context, type, pYUVData, iStride, pYUVDstData, iDstStride, regionRects, |
606 | 0 | numRegionRects)) |
607 | 0 | return FALSE; |
608 | | |
609 | 0 | pYUVCDstData[0] = pYUVDstData[0]; |
610 | 0 | pYUVCDstData[1] = pYUVDstData[1]; |
611 | 0 | pYUVCDstData[2] = pYUVDstData[2]; |
612 | 0 | return pool_decode(context, yuv444_process_work_callback, pYUVCDstData, iDstStride, |
613 | 0 | srcYuvHeight, DstFormat, dest, nDstStep, regionRects, numRegionRects); |
614 | 0 | } |
615 | | |
616 | | BOOL yuv420_context_decode(YUV_CONTEXT* WINPR_RESTRICT context, |
617 | | const BYTE* WINPR_RESTRICT pYUVData[3], const UINT32 iStride[3], |
618 | | UINT32 yuvHeight, DWORD DstFormat, BYTE* WINPR_RESTRICT dest, |
619 | | UINT32 nDstStep, const RECTANGLE_16* WINPR_RESTRICT regionRects, |
620 | | UINT32 numRegionRects) |
621 | 0 | { |
622 | 0 | return pool_decode(context, yuv420_process_work_callback, pYUVData, iStride, yuvHeight, |
623 | 0 | DstFormat, dest, nDstStep, regionRects, numRegionRects); |
624 | 0 | } |
625 | | |
626 | | static void CALLBACK yuv420_encode_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
627 | | PTP_WORK work) |
628 | 0 | { |
629 | 0 | prim_size_t roi; |
630 | 0 | YUV_ENCODE_WORK_PARAM* param = (YUV_ENCODE_WORK_PARAM*)context; |
631 | 0 | primitives_t* prims = primitives_get(); |
632 | 0 | BYTE* pYUVData[3]; |
633 | 0 | const BYTE* src = NULL; |
634 | |
|
635 | 0 | WINPR_UNUSED(instance); |
636 | 0 | WINPR_UNUSED(work); |
637 | 0 | WINPR_ASSERT(param); |
638 | |
|
639 | 0 | roi.width = param->rect.right - param->rect.left; |
640 | 0 | roi.height = param->rect.bottom - param->rect.top; |
641 | 0 | src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + |
642 | 0 | 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); |
643 | 0 | pYUVData[0] = |
644 | 0 | param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; |
645 | 0 | pYUVData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + |
646 | 0 | param->rect.left / 2; |
647 | 0 | pYUVData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + |
648 | 0 | param->rect.left / 2; |
649 | |
|
650 | 0 | if (prims->RGBToYUV420_8u_P3AC4R(src, param->SrcFormat, param->nSrcStep, pYUVData, |
651 | 0 | param->iStride, &roi) != PRIMITIVES_SUCCESS) |
652 | 0 | { |
653 | 0 | WLog_ERR(TAG, "error when decoding lines"); |
654 | 0 | } |
655 | 0 | } |
656 | | |
657 | | static void CALLBACK yuv444v1_encode_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
658 | | PTP_WORK work) |
659 | 0 | { |
660 | 0 | prim_size_t roi; |
661 | 0 | YUV_ENCODE_WORK_PARAM* param = (YUV_ENCODE_WORK_PARAM*)context; |
662 | 0 | primitives_t* prims = primitives_get(); |
663 | 0 | BYTE* pYUVLumaData[3]; |
664 | 0 | BYTE* pYUVChromaData[3]; |
665 | 0 | const BYTE* src = NULL; |
666 | |
|
667 | 0 | WINPR_UNUSED(instance); |
668 | 0 | WINPR_UNUSED(work); |
669 | 0 | WINPR_ASSERT(param); |
670 | |
|
671 | 0 | roi.width = param->rect.right - param->rect.left; |
672 | 0 | roi.height = param->rect.bottom - param->rect.top; |
673 | 0 | src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + |
674 | 0 | 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); |
675 | 0 | pYUVLumaData[0] = |
676 | 0 | param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; |
677 | 0 | pYUVLumaData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + |
678 | 0 | param->rect.left / 2; |
679 | 0 | pYUVLumaData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + |
680 | 0 | param->rect.left / 2; |
681 | 0 | pYUVChromaData[0] = |
682 | 0 | param->pYUVChromaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; |
683 | 0 | pYUVChromaData[1] = param->pYUVChromaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + |
684 | 0 | param->rect.left / 2; |
685 | 0 | pYUVChromaData[2] = param->pYUVChromaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + |
686 | 0 | param->rect.left / 2; |
687 | 0 | if (prims->RGBToAVC444YUV(src, param->SrcFormat, param->nSrcStep, pYUVLumaData, param->iStride, |
688 | 0 | pYUVChromaData, param->iStride, &roi) != PRIMITIVES_SUCCESS) |
689 | 0 | { |
690 | 0 | WLog_ERR(TAG, "error when decoding lines"); |
691 | 0 | } |
692 | 0 | } |
693 | | |
694 | | static void CALLBACK yuv444v2_encode_work_callback(PTP_CALLBACK_INSTANCE instance, void* context, |
695 | | PTP_WORK work) |
696 | 0 | { |
697 | 0 | prim_size_t roi; |
698 | 0 | YUV_ENCODE_WORK_PARAM* param = (YUV_ENCODE_WORK_PARAM*)context; |
699 | 0 | primitives_t* prims = primitives_get(); |
700 | 0 | BYTE* pYUVLumaData[3]; |
701 | 0 | BYTE* pYUVChromaData[3]; |
702 | 0 | const BYTE* src = NULL; |
703 | |
|
704 | 0 | WINPR_UNUSED(instance); |
705 | 0 | WINPR_UNUSED(work); |
706 | 0 | WINPR_ASSERT(param); |
707 | |
|
708 | 0 | roi.width = param->rect.right - param->rect.left; |
709 | 0 | roi.height = param->rect.bottom - param->rect.top; |
710 | 0 | src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + |
711 | 0 | 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); |
712 | 0 | pYUVLumaData[0] = |
713 | 0 | param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; |
714 | 0 | pYUVLumaData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + |
715 | 0 | param->rect.left / 2; |
716 | 0 | pYUVLumaData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + |
717 | 0 | param->rect.left / 2; |
718 | 0 | pYUVChromaData[0] = |
719 | 0 | param->pYUVChromaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; |
720 | 0 | pYUVChromaData[1] = param->pYUVChromaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + |
721 | 0 | param->rect.left / 2; |
722 | 0 | pYUVChromaData[2] = param->pYUVChromaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + |
723 | 0 | param->rect.left / 2; |
724 | 0 | if (prims->RGBToAVC444YUVv2(src, param->SrcFormat, param->nSrcStep, pYUVLumaData, |
725 | 0 | param->iStride, pYUVChromaData, param->iStride, |
726 | 0 | &roi) != PRIMITIVES_SUCCESS) |
727 | 0 | { |
728 | 0 | WLog_ERR(TAG, "error when decoding lines"); |
729 | 0 | } |
730 | 0 | } |
731 | | |
732 | | static inline YUV_ENCODE_WORK_PARAM |
733 | | pool_encode_fill(const RECTANGLE_16* WINPR_RESTRICT rect, YUV_CONTEXT* WINPR_RESTRICT context, |
734 | | const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat, |
735 | | const UINT32 iStride[], BYTE* WINPR_RESTRICT pYUVLumaData[], |
736 | | BYTE* WINPR_RESTRICT pYUVChromaData[]) |
737 | 0 | { |
738 | 0 | YUV_ENCODE_WORK_PARAM current = WINPR_C_ARRAY_INIT; |
739 | |
|
740 | 0 | WINPR_ASSERT(rect); |
741 | 0 | WINPR_ASSERT(context); |
742 | 0 | WINPR_ASSERT(pSrcData); |
743 | 0 | WINPR_ASSERT(iStride); |
744 | 0 | WINPR_ASSERT(pYUVLumaData); |
745 | |
|
746 | 0 | current.context = context; |
747 | 0 | current.pSrcData = pSrcData; |
748 | 0 | current.SrcFormat = SrcFormat; |
749 | 0 | current.nSrcStep = nSrcStep; |
750 | 0 | current.pYUVLumaData[0] = pYUVLumaData[0]; |
751 | 0 | current.pYUVLumaData[1] = pYUVLumaData[1]; |
752 | 0 | current.pYUVLumaData[2] = pYUVLumaData[2]; |
753 | 0 | if (pYUVChromaData) |
754 | 0 | { |
755 | 0 | current.pYUVChromaData[0] = pYUVChromaData[0]; |
756 | 0 | current.pYUVChromaData[1] = pYUVChromaData[1]; |
757 | 0 | current.pYUVChromaData[2] = pYUVChromaData[2]; |
758 | 0 | } |
759 | 0 | current.iStride[0] = iStride[0]; |
760 | 0 | current.iStride[1] = iStride[1]; |
761 | 0 | current.iStride[2] = iStride[2]; |
762 | |
|
763 | 0 | current.rect = *rect; |
764 | |
|
765 | 0 | return current; |
766 | 0 | } |
767 | | |
768 | | static uint32_t getSteps(uint32_t height, uint32_t step) |
769 | 0 | { |
770 | 0 | const uint32_t steps = (height + step / 2 + 1) / step; |
771 | 0 | if (steps < 1) |
772 | 0 | return 1; |
773 | 0 | return steps; |
774 | 0 | } |
775 | | |
776 | | static BOOL pool_encode(YUV_CONTEXT* WINPR_RESTRICT context, PTP_WORK_CALLBACK cb, |
777 | | const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat, |
778 | | const UINT32 iStride[], BYTE* WINPR_RESTRICT pYUVLumaData[], |
779 | | BYTE* WINPR_RESTRICT pYUVChromaData[], |
780 | | const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects) |
781 | 0 | { |
782 | 0 | BOOL rc = FALSE; |
783 | 0 | primitives_t* prims = primitives_get(); |
784 | 0 | UINT32 waitCount = 0; |
785 | |
|
786 | 0 | WINPR_ASSERT(context); |
787 | 0 | WINPR_ASSERT(cb); |
788 | 0 | WINPR_ASSERT(pSrcData); |
789 | 0 | WINPR_ASSERT(iStride); |
790 | 0 | WINPR_ASSERT(regionRects || (numRegionRects == 0)); |
791 | |
|
792 | 0 | if (!context->encoder) |
793 | 0 | { |
794 | |
|
795 | 0 | WLog_ERR(TAG, "YUV context set up for decoding, can not encode with it, aborting"); |
796 | 0 | return FALSE; |
797 | 0 | } |
798 | | |
799 | 0 | if (!context->useThreads || (primitives_flags(prims) & PRIM_FLAGS_HAVE_EXTGPU)) |
800 | 0 | { |
801 | 0 | for (UINT32 x = 0; x < numRegionRects; x++) |
802 | 0 | { |
803 | 0 | YUV_ENCODE_WORK_PARAM current = |
804 | 0 | pool_encode_fill(®ionRects[x], context, pSrcData, nSrcStep, SrcFormat, iStride, |
805 | 0 | pYUVLumaData, pYUVChromaData); |
806 | 0 | cb(NULL, ¤t, NULL); |
807 | 0 | } |
808 | 0 | return TRUE; |
809 | 0 | } |
810 | | |
811 | | /* case where we use threads */ |
812 | 0 | for (UINT32 x = 0; x < numRegionRects; x++) |
813 | 0 | { |
814 | 0 | const RECTANGLE_16* rect = ®ionRects[x]; |
815 | 0 | const UINT32 height = rect->bottom - rect->top; |
816 | 0 | const UINT32 steps = getSteps(height, context->heightStep); |
817 | |
|
818 | 0 | waitCount += steps; |
819 | 0 | } |
820 | |
|
821 | 0 | for (UINT32 x = 0; x < numRegionRects; x++) |
822 | 0 | { |
823 | 0 | const RECTANGLE_16* rect = ®ionRects[x]; |
824 | 0 | const UINT32 height = rect->bottom - rect->top; |
825 | 0 | const UINT32 steps = getSteps(height, context->heightStep); |
826 | |
|
827 | 0 | for (UINT32 y = 0; y < steps; y++) |
828 | 0 | { |
829 | 0 | RECTANGLE_16 r = *rect; |
830 | 0 | YUV_ENCODE_WORK_PARAM* current = NULL; |
831 | |
|
832 | 0 | if (context->work_object_count <= waitCount) |
833 | 0 | { |
834 | 0 | free_objects(context->work_objects, context->work_object_count); |
835 | 0 | waitCount = 0; |
836 | 0 | } |
837 | |
|
838 | 0 | current = &context->work_enc_params[waitCount]; |
839 | 0 | r.top += y * context->heightStep; |
840 | 0 | *current = pool_encode_fill(&r, context, pSrcData, nSrcStep, SrcFormat, iStride, |
841 | 0 | pYUVLumaData, pYUVChromaData); |
842 | 0 | if (!submit_object(&context->work_objects[waitCount], cb, current, context)) |
843 | 0 | goto fail; |
844 | 0 | waitCount++; |
845 | 0 | } |
846 | 0 | } |
847 | | |
848 | 0 | rc = TRUE; |
849 | 0 | fail: |
850 | 0 | free_objects(context->work_objects, context->work_object_count); |
851 | 0 | return rc; |
852 | 0 | } |
853 | | |
854 | | BOOL yuv420_context_encode(YUV_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT pSrcData, |
855 | | UINT32 nSrcStep, UINT32 SrcFormat, const UINT32 iStride[3], |
856 | | BYTE* WINPR_RESTRICT pYUVData[3], |
857 | | const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects) |
858 | 0 | { |
859 | 0 | if (!context || !pSrcData || !iStride || !pYUVData || !regionRects) |
860 | 0 | return FALSE; |
861 | | |
862 | 0 | return pool_encode(context, yuv420_encode_work_callback, pSrcData, nSrcStep, SrcFormat, iStride, |
863 | 0 | pYUVData, NULL, regionRects, numRegionRects); |
864 | 0 | } |
865 | | |
866 | | BOOL yuv444_context_encode(YUV_CONTEXT* WINPR_RESTRICT context, BYTE version, |
867 | | const BYTE* WINPR_RESTRICT pSrcData, UINT32 nSrcStep, UINT32 SrcFormat, |
868 | | const UINT32 iStride[3], BYTE* WINPR_RESTRICT pYUVLumaData[3], |
869 | | BYTE* WINPR_RESTRICT pYUVChromaData[3], |
870 | | const RECTANGLE_16* WINPR_RESTRICT regionRects, UINT32 numRegionRects) |
871 | 0 | { |
872 | 0 | PTP_WORK_CALLBACK cb = NULL; |
873 | 0 | switch (version) |
874 | 0 | { |
875 | 0 | case 1: |
876 | 0 | cb = yuv444v1_encode_work_callback; |
877 | 0 | break; |
878 | 0 | case 2: |
879 | 0 | cb = yuv444v2_encode_work_callback; |
880 | 0 | break; |
881 | 0 | default: |
882 | 0 | return FALSE; |
883 | 0 | } |
884 | | |
885 | 0 | return pool_encode(context, cb, pSrcData, nSrcStep, SrcFormat, iStride, pYUVLumaData, |
886 | 0 | pYUVChromaData, regionRects, numRegionRects); |
887 | 0 | } |