/src/libhevc/decoder/ihevcd_fmt_conv.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ******************************************************************************/ |
18 | | /** |
19 | | ******************************************************************************* |
20 | | * @file |
21 | | * ihevcd_fmt_conv.c |
22 | | * |
23 | | * @brief |
24 | | * Contains functions for format conversion or frame copy of output buffer |
25 | | * |
26 | | * @author |
27 | | * Harish |
28 | | * |
29 | | * @par List of Functions: |
30 | | * |
31 | | * @remarks |
32 | | * None |
33 | | * |
34 | | ******************************************************************************* |
35 | | */ |
36 | | /*****************************************************************************/ |
37 | | /* File Includes */ |
38 | | /*****************************************************************************/ |
39 | | #include <stdio.h> |
40 | | #include <stddef.h> |
41 | | #include <stdlib.h> |
42 | | #include <string.h> |
43 | | #include <assert.h> |
44 | | |
45 | | #include "ihevc_typedefs.h" |
46 | | #include "iv.h" |
47 | | #include "ivd.h" |
48 | | #include "ihevcd_cxa.h" |
49 | | #include "ithread.h" |
50 | | |
51 | | #include "ihevc_defs.h" |
52 | | #include "ihevc_debug.h" |
53 | | #include "ihevc_structs.h" |
54 | | #include "ihevc_macros.h" |
55 | | #include "ihevc_platform_macros.h" |
56 | | #include "ihevc_cabac_tables.h" |
57 | | #include "ihevc_disp_mgr.h" |
58 | | |
59 | | #include "ihevcd_defs.h" |
60 | | #include "ihevcd_function_selector.h" |
61 | | #include "ihevcd_structs.h" |
62 | | #include "ihevcd_error.h" |
63 | | #include "ihevcd_nal.h" |
64 | | #include "ihevcd_bitstream.h" |
65 | | #include "ihevcd_fmt_conv.h" |
66 | | #include "ihevcd_profile.h" |
67 | | |
68 | | /* SIMD variants of format conversion modules do not support width less than 32 */ |
69 | 309k | #define MIN_FMT_CONV_SIMD_WIDTH 32 |
70 | | /** |
71 | | ******************************************************************************* |
72 | | * |
73 | | * @brief Function used from copying a 420SP buffer |
74 | | * |
75 | | * @par Description |
76 | | * Function used from copying a 420SP buffer |
77 | | * |
78 | | * @param[in] pu1_y_src |
79 | | * Input Y pointer |
80 | | * |
81 | | * @param[in] pu1_uv_src |
82 | | * Input UV pointer (UV is interleaved either in UV or VU format) |
83 | | * |
84 | | * @param[in] pu1_y_dst |
85 | | * Output Y pointer |
86 | | * |
87 | | * @param[in] pu1_uv_dst |
88 | | * Output UV pointer (UV is interleaved in the same format as that of input) |
89 | | * |
90 | | * @param[in] wd |
91 | | * Width |
92 | | * |
93 | | * @param[in] ht |
94 | | * Height |
95 | | * |
96 | | * @param[in] src_y_strd |
97 | | * Input Y Stride |
98 | | * |
99 | | * @param[in] src_uv_strd |
100 | | * Input UV stride |
101 | | * |
102 | | * @param[in] dst_y_strd |
103 | | * Output Y stride |
104 | | * |
105 | | * @param[in] dst_uv_strd |
106 | | * Output UV stride |
107 | | * |
108 | | * @returns None |
109 | | * |
110 | | * @remarks In case there is a need to perform partial frame copy then |
111 | | * by passion appropriate source and destination pointers and appropriate |
112 | | * values for wd and ht it can be done |
113 | | * |
114 | | ******************************************************************************* |
115 | | */ |
116 | | |
117 | | void ihevcd_fmt_conv_420sp_to_420sp(UWORD8 *pu1_y_src, |
118 | | UWORD8 *pu1_uv_src, |
119 | | UWORD8 *pu1_y_dst, |
120 | | UWORD8 *pu1_uv_dst, |
121 | | WORD32 wd, |
122 | | WORD32 ht, |
123 | | WORD32 src_y_strd, |
124 | | WORD32 src_uv_strd, |
125 | | WORD32 dst_y_strd, |
126 | | WORD32 dst_uv_strd) |
127 | 179k | { |
128 | 179k | UWORD8 *pu1_src, *pu1_dst; |
129 | 179k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
130 | 179k | WORD32 i; |
131 | | |
132 | | /* copy luma */ |
133 | 179k | pu1_src = (UWORD8 *)pu1_y_src; |
134 | 179k | pu1_dst = (UWORD8 *)pu1_y_dst; |
135 | | |
136 | 179k | num_rows = ht; |
137 | 179k | num_cols = wd; |
138 | | |
139 | 179k | src_strd = src_y_strd; |
140 | 179k | dst_strd = dst_y_strd; |
141 | | |
142 | 7.60M | for(i = 0; i < num_rows; i++) |
143 | 7.42M | { |
144 | 7.42M | memcpy(pu1_dst, pu1_src, num_cols); |
145 | 7.42M | pu1_dst += dst_strd; |
146 | 7.42M | pu1_src += src_strd; |
147 | 7.42M | } |
148 | | |
149 | | /* copy U and V */ |
150 | 179k | pu1_src = (UWORD8 *)pu1_uv_src; |
151 | 179k | pu1_dst = (UWORD8 *)pu1_uv_dst; |
152 | | |
153 | 179k | num_rows = ht >> 1; |
154 | 179k | num_cols = wd; |
155 | | |
156 | 179k | src_strd = src_uv_strd; |
157 | 179k | dst_strd = dst_uv_strd; |
158 | | |
159 | 4.18M | for(i = 0; i < num_rows; i++) |
160 | 4.00M | { |
161 | 4.00M | memcpy(pu1_dst, pu1_src, num_cols); |
162 | 4.00M | pu1_dst += dst_strd; |
163 | 4.00M | pu1_src += src_strd; |
164 | 4.00M | } |
165 | 179k | return; |
166 | 179k | } |
167 | | |
168 | | void ihevcd_hbd_fmt_conv_420sp_to_420sp(UWORD16 *pu2_y_src, |
169 | | UWORD16 *pu2_uv_src, |
170 | | UWORD16 *pu2_y_dst, |
171 | | UWORD16 *pu2_uv_dst, |
172 | | WORD32 wd, |
173 | | WORD32 ht, |
174 | | WORD32 src_y_strd, |
175 | | WORD32 src_uv_strd, |
176 | | WORD32 dst_y_strd, |
177 | | WORD32 dst_uv_strd) |
178 | 25.4k | { |
179 | 25.4k | UWORD8 *pu1_src, *pu1_dst; |
180 | 25.4k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
181 | 25.4k | WORD32 i; |
182 | | |
183 | | /* copy luma */ |
184 | 25.4k | pu1_src = (UWORD8 *)pu2_y_src; |
185 | 25.4k | pu1_dst = (UWORD8 *)pu2_y_dst; |
186 | | |
187 | 25.4k | num_rows = ht; |
188 | 25.4k | num_cols = wd * sizeof(UWORD16); |
189 | | |
190 | 25.4k | src_strd = src_y_strd * sizeof(UWORD16); |
191 | 25.4k | dst_strd = dst_y_strd * sizeof(UWORD16); |
192 | | |
193 | 1.54M | for(i = 0; i < num_rows; i++) |
194 | 1.51M | { |
195 | 1.51M | memcpy(pu1_dst, pu1_src, num_cols); |
196 | 1.51M | pu1_dst += dst_strd; |
197 | 1.51M | pu1_src += src_strd; |
198 | 1.51M | } |
199 | | |
200 | | /* copy U and V */ |
201 | 25.4k | pu1_src = (UWORD8 *)pu2_uv_src; |
202 | 25.4k | pu1_dst = (UWORD8 *)pu2_uv_dst; |
203 | | |
204 | 25.4k | num_rows = ht >> 1; |
205 | 25.4k | num_cols = wd * sizeof(UWORD16); |
206 | | |
207 | 25.4k | src_strd = src_uv_strd * sizeof(UWORD16); |
208 | 25.4k | dst_strd = dst_uv_strd * sizeof(UWORD16); |
209 | | |
210 | 803k | for(i = 0; i < num_rows; i++) |
211 | 777k | { |
212 | 777k | memcpy(pu1_dst, pu1_src, num_cols); |
213 | 777k | pu1_dst += dst_strd; |
214 | 777k | pu1_src += src_strd; |
215 | 777k | } |
216 | 25.4k | return; |
217 | 25.4k | } |
218 | | |
219 | | /** |
220 | | ******************************************************************************* |
221 | | * |
222 | | * @brief Function used from copying a 400 buffer |
223 | | * |
224 | | * @par Description |
225 | | * Function used from copying a 400 buffer |
226 | | * |
227 | | * @param[in] pu1_y_src |
228 | | * Input Y pointer |
229 | | * |
230 | | * @param[in] pu1_y_dst |
231 | | * Output Y pointer |
232 | | * |
233 | | * @param[in] wd |
234 | | * Width |
235 | | * |
236 | | * @param[in] ht |
237 | | * Height |
238 | | * |
239 | | * @param[in] src_y_strd |
240 | | * Input Y Stride |
241 | | * |
242 | | * @param[in] dst_y_strd |
243 | | * Output Y stride |
244 | | * |
245 | | * @returns None |
246 | | * |
247 | | * @remarks In case there is a need to perform partial frame copy then |
248 | | * by passion appropriate source and destination pointers and appropriate |
249 | | * values for wd and ht it can be done |
250 | | * |
251 | | ******************************************************************************* |
252 | | */ |
253 | | |
254 | | void ihevcd_fmt_conv_luma_copy(UWORD8 *pu1_y_src, |
255 | | UWORD8 *pu1_y_dst, |
256 | | WORD32 wd, |
257 | | WORD32 ht, |
258 | | WORD32 src_y_strd, |
259 | | WORD32 dst_y_strd) |
260 | 234k | { |
261 | 234k | UWORD8 *pu1_src, *pu1_dst; |
262 | 234k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
263 | 234k | WORD32 i; |
264 | | |
265 | | /* copy luma */ |
266 | 234k | pu1_src = (UWORD8 *)pu1_y_src; |
267 | 234k | pu1_dst = (UWORD8 *)pu1_y_dst; |
268 | | |
269 | 234k | num_rows = ht; |
270 | 234k | num_cols = wd; |
271 | | |
272 | 234k | src_strd = src_y_strd; |
273 | 234k | dst_strd = dst_y_strd; |
274 | | |
275 | 7.72M | for(i = 0; i < num_rows; i++) |
276 | 7.48M | { |
277 | 7.48M | memcpy(pu1_dst, pu1_src, num_cols); |
278 | 7.48M | pu1_dst += dst_strd; |
279 | 7.48M | pu1_src += src_strd; |
280 | 7.48M | } |
281 | 234k | return; |
282 | 234k | } |
283 | | |
284 | | /** |
285 | | ******************************************************************************* |
286 | | * |
287 | | * @brief Function to convert a YUV 4:0:0 buffer to YUV 4:2:0 buffer |
288 | | * |
289 | | * @par Description |
290 | | * This function handles the format conversion from a 4:0:0 input buffer to a |
291 | | * 4:2:0 output buffer. It copies the Luma (Y) plane directly and synthesizes |
292 | | * the Chroma (U and V) planes by initializing them to a neutral gray value (128). |
293 | | * |
294 | | * @param[in] pu1_y_src |
295 | | * Input Y pointer |
296 | | * |
297 | | * @param[out] pu1_y_dst_tmp |
298 | | * Output Y pointer |
299 | | * |
300 | | * @param[out] pu1_u_dst_tmp |
301 | | * Output Chroma U pointer |
302 | | * |
303 | | * @param[out] pu1_v_dst_tmp |
304 | | * Output Chroma V pointer |
305 | | * |
306 | | * @param[in] ps_codec |
307 | | * Pointer to the codec structure |
308 | | * |
309 | | * @param[in] num_rows |
310 | | * Number of rows (height) to process. |
311 | | * |
312 | | * @returns None |
313 | | * |
314 | | * @remarks The Chroma (U and V) planes are initialized to 128, which represents |
315 | | * a neutral gray in 8-bit YUV, effectively 'zeroing out' the color information |
316 | | * present in the 4:0:0 (grayscale) source. The Luma plane is copied using |
317 | | * ihevcd_fmt_conv_400_to_400. |
318 | | * |
319 | | ******************************************************************************* |
320 | | */ |
321 | | void ihevcd_fmt_conv_400_to_420p(UWORD8 *pu1_y_src, |
322 | | UWORD8 *pu1_y_dst, |
323 | | UWORD8 *pu1_u_dst, |
324 | | UWORD8 *pu1_v_dst, |
325 | | WORD32 wd, |
326 | | WORD32 ht, |
327 | | WORD32 src_y_strd, |
328 | | WORD32 dst_y_strd, |
329 | | WORD32 dst_uv_strd) |
330 | 2.02k | { |
331 | 2.02k | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
332 | 58.7k | for(int i = 0; i < ALIGN2(ht) / 2; i++) |
333 | 56.7k | { |
334 | 56.7k | memset(pu1_u_dst, 128, ALIGN2(wd) / 2); |
335 | 56.7k | memset(pu1_v_dst, 128, ALIGN2(wd) / 2); |
336 | 56.7k | pu1_u_dst += dst_uv_strd; |
337 | 56.7k | pu1_v_dst += dst_uv_strd; |
338 | 56.7k | } |
339 | 2.02k | return; |
340 | 2.02k | } |
341 | | |
342 | | void ihevcd_fmt_conv_400_to_420sp(UWORD8 *pu1_y_src, |
343 | | UWORD8 *pu1_y_dst, |
344 | | UWORD8 *pu1_uv_dst, |
345 | | WORD32 wd, |
346 | | WORD32 ht, |
347 | | WORD32 src_y_strd, |
348 | | WORD32 dst_y_strd, |
349 | | WORD32 dst_uv_strd) |
350 | 0 | { |
351 | 0 | WORD32 i; |
352 | |
|
353 | 0 | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
354 | 0 | for(i = 0; i < ALIGN2(ht) / 2; i++) |
355 | 0 | { |
356 | 0 | memset(pu1_uv_dst, 128, ALIGN2(wd)); |
357 | 0 | pu1_uv_dst += dst_uv_strd; |
358 | 0 | } |
359 | 0 | return; |
360 | 0 | } |
361 | | |
362 | | void ihevcd_hbd_fmt_conv_400_to_420p(UWORD16 *pu2_y_src, |
363 | | UWORD16 *pu2_y_dst, |
364 | | UWORD16 *pu2_u_dst, |
365 | | UWORD16 *pu2_v_dst, |
366 | | WORD32 wd, |
367 | | WORD32 ht, |
368 | | WORD32 src_y_strd, |
369 | | WORD32 dst_y_strd, |
370 | | WORD32 dst_uv_strd, |
371 | | WORD32 bit_depth) |
372 | 866 | { |
373 | 866 | UWORD16 *pu2_src = pu2_y_src; |
374 | 866 | UWORD16 *pu2_dst = pu2_y_dst; |
375 | 866 | WORD32 num_rows = ht; |
376 | 866 | WORD32 num_cols = wd; |
377 | 866 | WORD32 src_strd = src_y_strd; |
378 | 866 | WORD32 dst_strd = dst_y_strd; |
379 | 866 | WORD32 i, j; |
380 | 866 | UWORD16 neutral; |
381 | | |
382 | 57.1k | for(i = 0; i < num_rows; i++) |
383 | 56.3k | { |
384 | 56.3k | memcpy(pu2_dst, pu2_src, num_cols * sizeof(UWORD16)); |
385 | 56.3k | pu2_dst += dst_strd; |
386 | 56.3k | pu2_src += src_strd; |
387 | 56.3k | } |
388 | | |
389 | 866 | neutral = (UWORD16)(1 << (bit_depth - 1)); |
390 | 31.0k | for(i = 0; i < ALIGN2(ht) / 2; i++) |
391 | 30.1k | { |
392 | 1.51M | for(j = 0; j < ALIGN2(wd) / 2; j++) |
393 | 1.48M | { |
394 | 1.48M | pu2_u_dst[j] = neutral; |
395 | 1.48M | pu2_v_dst[j] = neutral; |
396 | 1.48M | } |
397 | 30.1k | pu2_u_dst += dst_uv_strd; |
398 | 30.1k | pu2_v_dst += dst_uv_strd; |
399 | 30.1k | } |
400 | 866 | return; |
401 | 866 | } |
402 | | |
403 | | void ihevcd_hbd_fmt_conv_400_to_420sp(UWORD16 *pu2_y_src, |
404 | | UWORD16 *pu2_y_dst, |
405 | | UWORD16 *pu2_uv_dst, |
406 | | WORD32 wd, |
407 | | WORD32 ht, |
408 | | WORD32 src_y_strd, |
409 | | WORD32 dst_y_strd, |
410 | | WORD32 dst_uv_strd, |
411 | | WORD32 bit_depth) |
412 | 0 | { |
413 | 0 | UWORD16 *pu2_src = pu2_y_src; |
414 | 0 | UWORD16 *pu2_dst = pu2_y_dst; |
415 | 0 | WORD32 num_rows = ht; |
416 | 0 | WORD32 num_cols = wd; |
417 | 0 | WORD32 src_strd = src_y_strd; |
418 | 0 | WORD32 dst_strd = dst_y_strd; |
419 | 0 | WORD32 i, j; |
420 | 0 | UWORD16 neutral; |
421 | |
|
422 | 0 | for(i = 0; i < num_rows; i++) |
423 | 0 | { |
424 | 0 | memcpy(pu2_dst, pu2_src, num_cols * sizeof(UWORD16)); |
425 | 0 | pu2_dst += dst_strd; |
426 | 0 | pu2_src += src_strd; |
427 | 0 | } |
428 | |
|
429 | 0 | neutral = (UWORD16)(1 << (bit_depth - 1)); |
430 | 0 | for(i = 0; i < ALIGN2(ht) / 2; i++) |
431 | 0 | { |
432 | 0 | for(j = 0; j < ALIGN2(wd); j++) |
433 | 0 | { |
434 | 0 | pu2_uv_dst[j] = neutral; |
435 | 0 | } |
436 | 0 | pu2_uv_dst += dst_uv_strd; |
437 | 0 | } |
438 | 0 | return; |
439 | 0 | } |
440 | | |
441 | | /** |
442 | | ******************************************************************************* |
443 | | * |
444 | | * @brief Function used from copying a 420SP buffer |
445 | | * |
446 | | * @par Description |
447 | | * Function used from copying a 420SP buffer |
448 | | * |
449 | | * @param[in] pu1_y_src |
450 | | * Input Y pointer |
451 | | * |
452 | | * @param[in] pu1_uv_src |
453 | | * Input UV pointer (UV is interleaved either in UV or VU format) |
454 | | * |
455 | | * @param[in] pu1_y_dst |
456 | | * Output Y pointer |
457 | | * |
458 | | * @param[in] pu1_uv_dst |
459 | | * Output UV pointer (UV is interleaved in the same format as that of input) |
460 | | * |
461 | | * @param[in] wd |
462 | | * Width |
463 | | * |
464 | | * @param[in] ht |
465 | | * Height |
466 | | * |
467 | | * @param[in] src_y_strd |
468 | | * Input Y Stride |
469 | | * |
470 | | * @param[in] src_uv_strd |
471 | | * Input UV stride |
472 | | * |
473 | | * @param[in] dst_y_strd |
474 | | * Output Y stride |
475 | | * |
476 | | * @param[in] dst_uv_strd |
477 | | * Output UV stride |
478 | | * |
479 | | * @returns None |
480 | | * |
481 | | * @remarks In case there is a need to perform partial frame copy then |
482 | | * by passion appropriate source and destination pointers and appropriate |
483 | | * values for wd and ht it can be done |
484 | | * |
485 | | ******************************************************************************* |
486 | | */ |
487 | | void ihevcd_fmt_conv_420sp_to_420sp_swap_uv(UWORD8 *pu1_y_src, |
488 | | UWORD8 *pu1_uv_src, |
489 | | UWORD8 *pu1_y_dst, |
490 | | UWORD8 *pu1_uv_dst, |
491 | | WORD32 wd, |
492 | | WORD32 ht, |
493 | | WORD32 src_y_strd, |
494 | | WORD32 src_uv_strd, |
495 | | WORD32 dst_y_strd, |
496 | | WORD32 dst_uv_strd) |
497 | 0 | { |
498 | 0 | UWORD8 *pu1_src, *pu1_dst; |
499 | 0 | WORD32 num_rows, num_cols, src_strd, dst_strd; |
500 | 0 | WORD32 i; |
501 | | |
502 | | /* copy luma */ |
503 | 0 | pu1_src = (UWORD8 *)pu1_y_src; |
504 | 0 | pu1_dst = (UWORD8 *)pu1_y_dst; |
505 | |
|
506 | 0 | num_rows = ht; |
507 | 0 | num_cols = wd; |
508 | |
|
509 | 0 | src_strd = src_y_strd; |
510 | 0 | dst_strd = dst_y_strd; |
511 | |
|
512 | 0 | for(i = 0; i < num_rows; i++) |
513 | 0 | { |
514 | 0 | memcpy(pu1_dst, pu1_src, num_cols); |
515 | 0 | pu1_dst += dst_strd; |
516 | 0 | pu1_src += src_strd; |
517 | 0 | } |
518 | | |
519 | | /* copy U and V */ |
520 | 0 | pu1_src = (UWORD8 *)pu1_uv_src; |
521 | 0 | pu1_dst = (UWORD8 *)pu1_uv_dst; |
522 | |
|
523 | 0 | num_rows = ht >> 1; |
524 | 0 | num_cols = wd; |
525 | |
|
526 | 0 | src_strd = src_uv_strd; |
527 | 0 | dst_strd = dst_uv_strd; |
528 | |
|
529 | 0 | for(i = 0; i < num_rows; i++) |
530 | 0 | { |
531 | 0 | WORD32 j; |
532 | 0 | for(j = 0; j < num_cols; j += 2) |
533 | 0 | { |
534 | 0 | pu1_dst[j + 0] = pu1_src[j + 1]; |
535 | 0 | pu1_dst[j + 1] = pu1_src[j + 0]; |
536 | 0 | } |
537 | 0 | pu1_dst += dst_strd; |
538 | 0 | pu1_src += src_strd; |
539 | 0 | } |
540 | 0 | return; |
541 | 0 | } |
542 | | /** |
543 | | ******************************************************************************* |
544 | | * |
545 | | * @brief Function used from copying a 420SP buffer |
546 | | * |
547 | | * @par Description |
548 | | * Function used from copying a 420SP buffer |
549 | | * |
550 | | * @param[in] pu1_y_src |
551 | | * Input Y pointer |
552 | | * |
553 | | * @param[in] pu1_uv_src |
554 | | * Input UV pointer (UV is interleaved either in UV or VU format) |
555 | | * |
556 | | * @param[in] pu1_y_dst |
557 | | * Output Y pointer |
558 | | * |
559 | | * @param[in] pu1_u_dst |
560 | | * Output U pointer |
561 | | * |
562 | | * @param[in] pu1_v_dst |
563 | | * Output V pointer |
564 | | * |
565 | | * @param[in] wd |
566 | | * Width |
567 | | * |
568 | | * @param[in] ht |
569 | | * Height |
570 | | * |
571 | | * @param[in] src_y_strd |
572 | | * Input Y Stride |
573 | | * |
574 | | * @param[in] src_uv_strd |
575 | | * Input UV stride |
576 | | * |
577 | | * @param[in] dst_y_strd |
578 | | * Output Y stride |
579 | | * |
580 | | * @param[in] dst_uv_strd |
581 | | * Output UV stride |
582 | | * |
583 | | * @param[in] is_u_first |
584 | | * Flag to indicate if U is the first byte in input chroma part |
585 | | * |
586 | | * @returns none |
587 | | * |
588 | | * @remarks In case there is a need to perform partial frame copy then |
589 | | * by passion appropriate source and destination pointers and appropriate |
590 | | * values for wd and ht it can be done |
591 | | * |
592 | | ******************************************************************************* |
593 | | */ |
594 | | |
595 | | |
596 | | void ihevcd_fmt_conv_420sp_to_420p(UWORD8 *pu1_y_src, |
597 | | UWORD8 *pu1_uv_src, |
598 | | UWORD8 *pu1_y_dst, |
599 | | UWORD8 *pu1_u_dst, |
600 | | UWORD8 *pu1_v_dst, |
601 | | WORD32 wd, |
602 | | WORD32 ht, |
603 | | WORD32 src_y_strd, |
604 | | WORD32 src_uv_strd, |
605 | | WORD32 dst_y_strd, |
606 | | WORD32 dst_uv_strd, |
607 | | WORD32 is_u_first, |
608 | | WORD32 disable_luma_copy) |
609 | 95.8k | { |
610 | 95.8k | UWORD8 *pu1_src, *pu1_dst; |
611 | 95.8k | UWORD8 *pu1_u_src, *pu1_v_src; |
612 | 95.8k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
613 | 95.8k | WORD32 i, j; |
614 | | |
615 | 95.8k | if(0 == disable_luma_copy) |
616 | 0 | { |
617 | | /* copy luma */ |
618 | 0 | pu1_src = (UWORD8 *)pu1_y_src; |
619 | 0 | pu1_dst = (UWORD8 *)pu1_y_dst; |
620 | |
|
621 | 0 | num_rows = ht; |
622 | 0 | num_cols = wd; |
623 | |
|
624 | 0 | src_strd = src_y_strd; |
625 | 0 | dst_strd = dst_y_strd; |
626 | |
|
627 | 0 | for(i = 0; i < num_rows; i++) |
628 | 0 | { |
629 | 0 | memcpy(pu1_dst, pu1_src, num_cols); |
630 | 0 | pu1_dst += dst_strd; |
631 | 0 | pu1_src += src_strd; |
632 | 0 | } |
633 | 0 | } |
634 | | /* de-interleave U and V and copy to destination */ |
635 | 95.8k | if(is_u_first) |
636 | 95.6k | { |
637 | 95.6k | pu1_u_src = (UWORD8 *)pu1_uv_src; |
638 | 95.6k | pu1_v_src = (UWORD8 *)pu1_uv_src + 1; |
639 | 95.6k | } |
640 | 191 | else |
641 | 191 | { |
642 | 191 | pu1_u_src = (UWORD8 *)pu1_uv_src + 1; |
643 | 191 | pu1_v_src = (UWORD8 *)pu1_uv_src; |
644 | 191 | } |
645 | | |
646 | | |
647 | 95.8k | num_rows = ht >> 1; |
648 | 95.8k | num_cols = wd >> 1; |
649 | | |
650 | 95.8k | src_strd = src_uv_strd; |
651 | 95.8k | dst_strd = dst_uv_strd; |
652 | | |
653 | 3.36M | for(i = 0; i < num_rows; i++) |
654 | 3.27M | { |
655 | 701M | for(j = 0; j < num_cols; j++) |
656 | 698M | { |
657 | 698M | pu1_u_dst[j] = pu1_u_src[j * 2]; |
658 | 698M | pu1_v_dst[j] = pu1_v_src[j * 2]; |
659 | 698M | } |
660 | | |
661 | 3.27M | pu1_u_dst += dst_strd; |
662 | 3.27M | pu1_v_dst += dst_strd; |
663 | 3.27M | pu1_u_src += src_strd; |
664 | 3.27M | pu1_v_src += src_strd; |
665 | 3.27M | } |
666 | 95.8k | return; |
667 | 95.8k | } |
668 | | |
669 | | /** |
670 | | ******************************************************************************* |
671 | | * |
672 | | * @brief Function to convert a YUV 4:4:4 sp buffer to YUV 4:4:4 planar buffer |
673 | | * |
674 | | * @par Description |
675 | | * This function handles the format conversion from a 4:4:4 semi planar input buffer |
676 | | * to a 4:4:4 planar output buffer. |
677 | | * |
678 | | * @param[in] pu1_y_src |
679 | | * Input Y pointer |
680 | | * |
681 | | * @param[in] pu1_uv_src |
682 | | * Input UV pointer (UV is interleaved) |
683 | | * |
684 | | * @param[in] pu1_y_dst |
685 | | * Output Y pointer |
686 | | * |
687 | | * @param[in] pu1_u_dst |
688 | | * Output U pointer |
689 | | * |
690 | | * @param[in] pu1_v_dst |
691 | | * Output V pointer |
692 | | * |
693 | | * @param[in] wd |
694 | | * Width |
695 | | * |
696 | | * @param[in] ht |
697 | | * Height |
698 | | * |
699 | | * @param[in] src_y_strd |
700 | | * Input Y Stride |
701 | | * |
702 | | * @param[in] src_uv_strd |
703 | | * Input UV stride |
704 | | * |
705 | | * @param[in] dst_y_strd |
706 | | * Output Y stride |
707 | | * |
708 | | * @param[in] dst_uv_strd |
709 | | * Output U or V stride |
710 | | * |
711 | | * @returns none |
712 | | * |
713 | | * @remarks none |
714 | | * |
715 | | ******************************************************************************* |
716 | | */ |
717 | | void ihevcd_fmt_conv_444sp_to_444p(UWORD8 *pu1_y_src, |
718 | | UWORD8 *pu1_uv_src, |
719 | | UWORD8 *pu1_y_dst, |
720 | | UWORD8 *pu1_u_dst, |
721 | | UWORD8 *pu1_v_dst, |
722 | | WORD32 wd, |
723 | | WORD32 ht, |
724 | | WORD32 src_y_strd, |
725 | | WORD32 src_uv_strd, |
726 | | WORD32 dst_y_strd, |
727 | | WORD32 dst_uv_strd) |
728 | 0 | { |
729 | 0 | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
730 | | |
731 | | /* de-interleave U and V and copy to destination */ |
732 | 0 | UWORD8 *pu1_u_src = (UWORD8*)pu1_uv_src; |
733 | 0 | UWORD8 *pu1_v_src = (UWORD8*)pu1_uv_src + 1; |
734 | |
|
735 | 0 | for(WORD32 i = 0; i < ht; i++) |
736 | 0 | { |
737 | 0 | for(WORD32 j = 0; j < wd; j++) |
738 | 0 | { |
739 | 0 | pu1_u_dst[j] = pu1_u_src[j * 2]; |
740 | 0 | pu1_v_dst[j] = pu1_v_src[j * 2]; |
741 | 0 | } |
742 | 0 | pu1_u_dst += dst_uv_strd; |
743 | 0 | pu1_v_dst += dst_uv_strd; |
744 | 0 | pu1_u_src += src_uv_strd; |
745 | 0 | pu1_v_src += src_uv_strd; |
746 | 0 | } |
747 | 0 | return; |
748 | 0 | } |
749 | | |
750 | | void ihevcd_fmt_conv_hbd_444sp_to_444p(UWORD16 *pu2_y_src, |
751 | | UWORD16 *pu2_uv_src, |
752 | | UWORD16 *pu2_y_dst, |
753 | | UWORD16 *pu2_u_dst, |
754 | | UWORD16 *pu2_v_dst, |
755 | | WORD32 wd, |
756 | | WORD32 ht, |
757 | | WORD32 src_y_strd, |
758 | | WORD32 src_uv_strd, |
759 | | WORD32 dst_y_strd, |
760 | | WORD32 dst_uv_strd) |
761 | 0 | { |
762 | 0 | UWORD16 *pu2_u_src; |
763 | 0 | UWORD16 *pu2_v_src; |
764 | 0 | WORD32 i, j; |
765 | |
|
766 | 0 | ihevcd_fmt_conv_luma_copy((UWORD8 *)pu2_y_src, (UWORD8 *)pu2_y_dst, wd * 2, ht, src_y_strd * 2, dst_y_strd * 2); |
767 | | |
768 | | /* de-interleave U and V and copy to destination */ |
769 | 0 | pu2_u_src = (UWORD16 *)pu2_uv_src; |
770 | 0 | pu2_v_src = (UWORD16 *)pu2_uv_src + 1; |
771 | |
|
772 | 0 | for(i = 0; i < ht; i++) |
773 | 0 | { |
774 | 0 | for(j = 0; j < wd; j++) |
775 | 0 | { |
776 | 0 | pu2_u_dst[j] = pu2_u_src[j * 2]; |
777 | 0 | pu2_v_dst[j] = pu2_v_src[j * 2]; |
778 | 0 | } |
779 | 0 | pu2_u_dst += dst_uv_strd; |
780 | 0 | pu2_v_dst += dst_uv_strd; |
781 | 0 | pu2_u_src += src_uv_strd; |
782 | 0 | pu2_v_src += src_uv_strd; |
783 | 0 | } |
784 | 0 | return; |
785 | 0 | } |
786 | | |
787 | | void ihevcd_fmt_conv_444sp_to_420p(UWORD8 *pu1_y_src, |
788 | | UWORD8 *pu1_uv_src, |
789 | | UWORD8 *pu1_y_dst, |
790 | | UWORD8 *pu1_u_dst, |
791 | | UWORD8 *pu1_v_dst, |
792 | | WORD32 wd, |
793 | | WORD32 ht, |
794 | | WORD32 src_y_strd, |
795 | | WORD32 src_uv_strd, |
796 | | WORD32 dst_y_strd, |
797 | | WORD32 dst_uv_strd) |
798 | 0 | { |
799 | 0 | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
800 | |
|
801 | 0 | for(WORD32 i = 0; i < ht; i += 2) |
802 | 0 | { |
803 | 0 | for(WORD32 j = 0; j < wd; j += 2) |
804 | 0 | { |
805 | 0 | WORD32 cb_sum = pu1_uv_src[j * 2]; |
806 | 0 | WORD32 cr_sum = pu1_uv_src[j * 2 + 1]; |
807 | 0 | WORD32 count = 1; |
808 | |
|
809 | 0 | if((j + 1) < wd) |
810 | 0 | { |
811 | 0 | cb_sum += pu1_uv_src[(j + 1) * 2]; |
812 | 0 | cr_sum += pu1_uv_src[(j + 1) * 2 + 1]; |
813 | 0 | count++; |
814 | 0 | } |
815 | 0 | if((i + 1) < ht) |
816 | 0 | { |
817 | 0 | cb_sum += pu1_uv_src[j * 2 + src_uv_strd]; |
818 | 0 | cr_sum += pu1_uv_src[j * 2 + src_uv_strd + 1]; |
819 | 0 | count++; |
820 | 0 | } |
821 | 0 | if((j + 1) < wd && (i + 1) < ht) |
822 | 0 | { |
823 | 0 | cb_sum += pu1_uv_src[(j + 1) * 2 + src_uv_strd]; |
824 | 0 | cr_sum += pu1_uv_src[(j + 1) * 2 + src_uv_strd + 1]; |
825 | 0 | count++; |
826 | 0 | } |
827 | 0 | pu1_u_dst[j / 2] = (cb_sum + (count >> 1)) / count; |
828 | 0 | pu1_v_dst[j / 2] = (cr_sum + (count >> 1)) / count; |
829 | 0 | } |
830 | 0 | pu1_u_dst += dst_uv_strd; |
831 | 0 | pu1_v_dst += dst_uv_strd; |
832 | 0 | pu1_uv_src += (src_uv_strd * 2); |
833 | 0 | } |
834 | 0 | return; |
835 | 0 | } |
836 | | |
837 | | void ihevcd_hbd_fmt_conv_444sp_to_420p(UWORD16 *pu2_y_src, |
838 | | UWORD16 *pu2_uv_src, |
839 | | UWORD16 *pu2_y_dst, |
840 | | UWORD16 *pu2_u_dst, |
841 | | UWORD16 *pu2_v_dst, |
842 | | WORD32 wd, |
843 | | WORD32 ht, |
844 | | WORD32 src_y_strd, |
845 | | WORD32 src_uv_strd, |
846 | | WORD32 dst_y_strd, |
847 | | WORD32 dst_uv_strd, |
848 | | WORD32 is_u_first, |
849 | | WORD32 disable_luma_copy) |
850 | 0 | { |
851 | 0 | UWORD16 *pu2_src, *pu2_dst; |
852 | 0 | UWORD16 *pu2_u_src, *pu2_v_src; |
853 | 0 | WORD32 i, j; |
854 | 0 | WORD32 cb_sum, cr_sum, count; |
855 | |
|
856 | 0 | if(0 == disable_luma_copy) |
857 | 0 | { |
858 | | /* copy luma */ |
859 | 0 | pu2_src = pu2_y_src; |
860 | 0 | pu2_dst = pu2_y_dst; |
861 | |
|
862 | 0 | for(i = 0; i < ht; i++) |
863 | 0 | { |
864 | 0 | memcpy(pu2_dst, pu2_src, wd * sizeof(UWORD16)); |
865 | 0 | pu2_dst += dst_y_strd; |
866 | 0 | pu2_src += src_y_strd; |
867 | 0 | } |
868 | 0 | } |
869 | | |
870 | | /* de-interleave U and V, downsample horizontally and vertically, and copy to destination */ |
871 | 0 | if(is_u_first) |
872 | 0 | { |
873 | 0 | pu2_u_src = pu2_uv_src; |
874 | 0 | pu2_v_src = pu2_uv_src + 1; |
875 | 0 | } |
876 | 0 | else |
877 | 0 | { |
878 | 0 | pu2_u_src = pu2_uv_src + 1; |
879 | 0 | pu2_v_src = pu2_uv_src; |
880 | 0 | } |
881 | |
|
882 | 0 | for(i = 0; i < ht; i += 2) |
883 | 0 | { |
884 | 0 | for(j = 0; j < wd; j += 2) |
885 | 0 | { |
886 | 0 | cb_sum = pu2_u_src[j * 2]; |
887 | 0 | cr_sum = pu2_v_src[j * 2]; |
888 | 0 | count = 1; |
889 | |
|
890 | 0 | if((j + 1) < wd) |
891 | 0 | { |
892 | 0 | cb_sum += pu2_u_src[(j + 1) * 2]; |
893 | 0 | cr_sum += pu2_v_src[(j + 1) * 2]; |
894 | 0 | count++; |
895 | 0 | } |
896 | 0 | if((i + 1) < ht) |
897 | 0 | { |
898 | 0 | cb_sum += pu2_u_src[j * 2 + src_uv_strd]; |
899 | 0 | cr_sum += pu2_v_src[j * 2 + src_uv_strd]; |
900 | 0 | count++; |
901 | 0 | } |
902 | 0 | if((j + 1) < wd && (i + 1) < ht) |
903 | 0 | { |
904 | 0 | cb_sum += pu2_u_src[(j + 1) * 2 + src_uv_strd]; |
905 | 0 | cr_sum += pu2_v_src[(j + 1) * 2 + src_uv_strd]; |
906 | 0 | count++; |
907 | 0 | } |
908 | 0 | pu2_u_dst[j / 2] = (cb_sum + (count >> 1)) / count; |
909 | 0 | pu2_v_dst[j / 2] = (cr_sum + (count >> 1)) / count; |
910 | 0 | } |
911 | 0 | pu2_u_dst += dst_uv_strd; |
912 | 0 | pu2_v_dst += dst_uv_strd; |
913 | 0 | pu2_u_src += (src_uv_strd * 2); |
914 | 0 | pu2_v_src += (src_uv_strd * 2); |
915 | 0 | } |
916 | 0 | return; |
917 | 0 | } |
918 | | |
919 | | void ihevcd_fmt_conv_422sp_to_422p(UWORD8 *pu1_y_src, |
920 | | UWORD8 *pu1_uv_src, |
921 | | UWORD8 *pu1_y_dst, |
922 | | UWORD8 *pu1_u_dst, |
923 | | UWORD8 *pu1_v_dst, |
924 | | WORD32 wd, |
925 | | WORD32 ht, |
926 | | WORD32 src_y_strd, |
927 | | WORD32 src_uv_strd, |
928 | | WORD32 dst_y_strd, |
929 | | WORD32 dst_uv_strd) |
930 | 13.4k | { |
931 | 13.4k | UWORD8 *pu1_u_src, *pu1_v_src; |
932 | 13.4k | WORD32 i, j; |
933 | | |
934 | 13.4k | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
935 | | |
936 | 13.4k | pu1_u_src = (UWORD8 *)pu1_uv_src; |
937 | 13.4k | pu1_v_src = (UWORD8 *)pu1_uv_src + 1; |
938 | | |
939 | 428k | for(i = 0; i < ht; i++) |
940 | 415k | { |
941 | 25.3M | for(j = 0; j < (wd >> 1); j++) |
942 | 24.9M | { |
943 | 24.9M | pu1_u_dst[j] = pu1_u_src[j * 2]; |
944 | 24.9M | pu1_v_dst[j] = pu1_v_src[j * 2]; |
945 | 24.9M | } |
946 | | |
947 | 415k | pu1_u_dst += dst_uv_strd; |
948 | 415k | pu1_v_dst += dst_uv_strd; |
949 | 415k | pu1_u_src += src_uv_strd; |
950 | 415k | pu1_v_src += src_uv_strd; |
951 | 415k | } |
952 | 13.4k | return; |
953 | 13.4k | } |
954 | | |
955 | | void ihevcd_fmt_conv_422sp_to_420p(UWORD8 *pu1_y_src, |
956 | | UWORD8 *pu1_uv_src, |
957 | | UWORD8 *pu1_y_dst, |
958 | | UWORD8 *pu1_u_dst, |
959 | | UWORD8 *pu1_v_dst, |
960 | | WORD32 wd, |
961 | | WORD32 ht, |
962 | | WORD32 src_y_strd, |
963 | | WORD32 src_uv_strd, |
964 | | WORD32 dst_y_strd, |
965 | | WORD32 dst_uv_strd) |
966 | 16.6k | { |
967 | 16.6k | ihevcd_fmt_conv_luma_copy(pu1_y_src, pu1_y_dst, wd, ht, src_y_strd, dst_y_strd); |
968 | | |
969 | 417k | for(WORD32 i = 0; i < ht; i += 2) |
970 | 400k | { |
971 | 26.2M | for(WORD32 j = 0; j < wd; j += 2) |
972 | 25.8M | { |
973 | 25.8M | WORD32 cb_sum = pu1_uv_src[j]; |
974 | 25.8M | WORD32 cr_sum = pu1_uv_src[j + 1]; |
975 | | |
976 | 25.8M | if((i + 1) < ht) |
977 | 25.8M | { |
978 | 25.8M | cb_sum += pu1_uv_src[j + src_uv_strd] + 1; |
979 | 25.8M | cr_sum += pu1_uv_src[j + 1 + src_uv_strd] + 1; |
980 | | |
981 | 25.8M | cb_sum >>= 1; |
982 | 25.8M | cr_sum >>= 1; |
983 | 25.8M | } |
984 | 25.8M | pu1_u_dst[j / 2] = cb_sum; |
985 | 25.8M | pu1_v_dst[j / 2] = cr_sum; |
986 | 25.8M | } |
987 | 400k | pu1_u_dst += dst_uv_strd; |
988 | 400k | pu1_v_dst += dst_uv_strd; |
989 | 400k | pu1_uv_src += (src_uv_strd * 2); |
990 | 400k | } |
991 | 16.6k | return; |
992 | 16.6k | } |
993 | | |
994 | | void ihevcd_hbd_fmt_conv_422sp_to_422p(UWORD16 *pu2_y_src, |
995 | | UWORD16 *pu2_uv_src, |
996 | | UWORD16 *pu2_y_dst, |
997 | | UWORD16 *pu2_u_dst, |
998 | | UWORD16 *pu2_v_dst, |
999 | | WORD32 wd, |
1000 | | WORD32 ht, |
1001 | | WORD32 src_y_strd, |
1002 | | WORD32 src_uv_strd, |
1003 | | WORD32 dst_y_strd, |
1004 | | WORD32 dst_uv_strd, |
1005 | | WORD32 is_u_first, |
1006 | | WORD32 disable_luma_copy) |
1007 | 5.66k | { |
1008 | 5.66k | UWORD16 *pu2_src, *pu2_dst; |
1009 | 5.66k | UWORD16 *pu2_u_src, *pu2_v_src; |
1010 | 5.66k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
1011 | 5.66k | WORD32 i, j; |
1012 | | |
1013 | 5.66k | if(0 == disable_luma_copy) |
1014 | 5.67k | { |
1015 | | /* copy luma */ |
1016 | 5.67k | pu2_src = (UWORD16 *)pu2_y_src; |
1017 | 5.67k | pu2_dst = (UWORD16 *)pu2_y_dst; |
1018 | | |
1019 | 5.67k | num_rows = ht; |
1020 | 5.67k | num_cols = wd; |
1021 | | |
1022 | 5.67k | src_strd = src_y_strd; |
1023 | 5.67k | dst_strd = dst_y_strd; |
1024 | | |
1025 | 204k | for(i = 0; i < num_rows; i++) |
1026 | 198k | { |
1027 | 198k | memcpy(pu2_dst, pu2_src, num_cols * sizeof(UWORD16)); |
1028 | 198k | pu2_dst += dst_strd; |
1029 | 198k | pu2_src += src_strd; |
1030 | 198k | } |
1031 | 5.67k | } |
1032 | | /* de-interleave U and V and copy to destination */ |
1033 | 5.66k | if(is_u_first) |
1034 | 5.71k | { |
1035 | 5.71k | pu2_u_src = (UWORD16 *)pu2_uv_src; |
1036 | 5.71k | pu2_v_src = (UWORD16 *)pu2_uv_src + 1; |
1037 | 5.71k | } |
1038 | 18.4E | else |
1039 | 18.4E | { |
1040 | 18.4E | pu2_u_src = (UWORD16 *)pu2_uv_src + 1; |
1041 | 18.4E | pu2_v_src = (UWORD16 *)pu2_uv_src; |
1042 | 18.4E | } |
1043 | | |
1044 | 5.66k | num_rows = ht; |
1045 | 5.66k | num_cols = wd >> 1; |
1046 | | |
1047 | 5.66k | src_strd = src_uv_strd; |
1048 | 5.66k | dst_strd = dst_uv_strd; |
1049 | | |
1050 | 213k | for(i = 0; i < num_rows; i++) |
1051 | 208k | { |
1052 | 79.7M | for(j = 0; j < num_cols; j++) |
1053 | 79.5M | { |
1054 | 79.5M | pu2_u_dst[j] = pu2_u_src[j * 2]; |
1055 | 79.5M | pu2_v_dst[j] = pu2_v_src[j * 2]; |
1056 | 79.5M | } |
1057 | | |
1058 | 208k | pu2_u_dst += dst_strd; |
1059 | 208k | pu2_v_dst += dst_strd; |
1060 | 208k | pu2_u_src += src_strd; |
1061 | 208k | pu2_v_src += src_strd; |
1062 | 208k | } |
1063 | 5.66k | return; |
1064 | 5.66k | } |
1065 | | |
1066 | | void ihevcd_hbd_fmt_conv_422sp_to_420p(UWORD16 *pu2_y_src, |
1067 | | UWORD16 *pu2_uv_src, |
1068 | | UWORD16 *pu2_y_dst, |
1069 | | UWORD16 *pu2_u_dst, |
1070 | | UWORD16 *pu2_v_dst, |
1071 | | WORD32 wd, |
1072 | | WORD32 ht, |
1073 | | WORD32 src_y_strd, |
1074 | | WORD32 src_uv_strd, |
1075 | | WORD32 dst_y_strd, |
1076 | | WORD32 dst_uv_strd, |
1077 | | WORD32 is_u_first, |
1078 | | WORD32 disable_luma_copy) |
1079 | 63.4k | { |
1080 | 63.4k | UWORD16 *pu2_src, *pu2_dst; |
1081 | 63.4k | UWORD16 *pu2_u_src, *pu2_v_src; |
1082 | 63.4k | WORD32 num_rows, num_cols; |
1083 | 63.4k | WORD32 i, j; |
1084 | 63.4k | WORD32 cb_sum, cr_sum; |
1085 | | |
1086 | 63.4k | if(0 == disable_luma_copy) |
1087 | 63.4k | { |
1088 | | /* copy luma */ |
1089 | 63.4k | pu2_src = (UWORD16 *)pu2_y_src; |
1090 | 63.4k | pu2_dst = (UWORD16 *)pu2_y_dst; |
1091 | | |
1092 | 63.4k | num_rows = ht; |
1093 | 63.4k | num_cols = wd; |
1094 | | |
1095 | 3.32M | for(i = 0; i < num_rows; i++) |
1096 | 3.25M | { |
1097 | 3.25M | memcpy(pu2_dst, pu2_src, num_cols * sizeof(UWORD16)); |
1098 | 3.25M | pu2_dst += dst_y_strd; |
1099 | 3.25M | pu2_src += src_y_strd; |
1100 | 3.25M | } |
1101 | 63.4k | } |
1102 | | |
1103 | | /* de-interleave U and V, downsample vertically and copy to destination */ |
1104 | 63.4k | if(is_u_first) |
1105 | 65.4k | { |
1106 | 65.4k | pu2_u_src = (UWORD16 *)pu2_uv_src; |
1107 | 65.4k | pu2_v_src = (UWORD16 *)pu2_uv_src + 1; |
1108 | 65.4k | } |
1109 | 18.4E | else |
1110 | 18.4E | { |
1111 | 18.4E | pu2_u_src = (UWORD16 *)pu2_uv_src + 1; |
1112 | 18.4E | pu2_v_src = (UWORD16 *)pu2_uv_src; |
1113 | 18.4E | } |
1114 | | |
1115 | 63.4k | num_rows = ht; |
1116 | 63.4k | num_cols = wd >> 1; |
1117 | | |
1118 | 1.95M | for(i = 0; i < num_rows; i += 2) |
1119 | 1.88M | { |
1120 | 646M | for(j = 0; j < num_cols; j++) |
1121 | 644M | { |
1122 | 644M | cb_sum = pu2_u_src[j * 2]; |
1123 | 644M | cr_sum = pu2_v_src[j * 2]; |
1124 | | |
1125 | 644M | if((i + 1) < num_rows) |
1126 | 644M | { |
1127 | 644M | cb_sum += pu2_u_src[j * 2 + src_uv_strd] + 1; |
1128 | 644M | cr_sum += pu2_v_src[j * 2 + src_uv_strd] + 1; |
1129 | | |
1130 | 644M | cb_sum >>= 1; |
1131 | 644M | cr_sum >>= 1; |
1132 | 644M | } |
1133 | 644M | pu2_u_dst[j] = cb_sum; |
1134 | 644M | pu2_v_dst[j] = cr_sum; |
1135 | 644M | } |
1136 | | |
1137 | 1.88M | pu2_u_dst += dst_uv_strd; |
1138 | 1.88M | pu2_v_dst += dst_uv_strd; |
1139 | 1.88M | pu2_u_src += (src_uv_strd * 2); |
1140 | 1.88M | pu2_v_src += (src_uv_strd * 2); |
1141 | 1.88M | } |
1142 | 63.4k | return; |
1143 | 63.4k | } |
1144 | | |
1145 | | void ihevcd_hbd_fmt_conv_420sp_to_420p(UWORD16 *pu2_y_src, |
1146 | | UWORD16 *pu2_uv_src, |
1147 | | UWORD16 *pu2_y_dst, |
1148 | | UWORD16 *pu2_u_dst, |
1149 | | UWORD16 *pu2_v_dst, |
1150 | | WORD32 wd, |
1151 | | WORD32 ht, |
1152 | | WORD32 src_y_strd, |
1153 | | WORD32 src_uv_strd, |
1154 | | WORD32 dst_y_strd, |
1155 | | WORD32 dst_uv_strd, |
1156 | | WORD32 is_u_first, |
1157 | | WORD32 disable_luma_copy) |
1158 | 15.4k | { |
1159 | 15.4k | UWORD16 *pu2_src, *pu2_dst; |
1160 | 15.4k | UWORD16 *pu2_u_src, *pu2_v_src; |
1161 | 15.4k | WORD32 num_rows, num_cols, src_strd, dst_strd; |
1162 | 15.4k | WORD32 i, j; |
1163 | | |
1164 | 15.4k | if(0 == disable_luma_copy) |
1165 | 0 | { |
1166 | | /* copy luma */ |
1167 | 0 | pu2_src = (UWORD16 *)pu2_y_src; |
1168 | 0 | pu2_dst = (UWORD16 *)pu2_y_dst; |
1169 | |
|
1170 | 0 | num_rows = ht; |
1171 | 0 | num_cols = wd; |
1172 | |
|
1173 | 0 | src_strd = src_y_strd; |
1174 | 0 | dst_strd = dst_y_strd; |
1175 | |
|
1176 | 0 | for(i = 0; i < num_rows; i++) |
1177 | 0 | { |
1178 | 0 | memcpy(pu2_dst, pu2_src, num_cols * sizeof(UWORD16)); |
1179 | 0 | pu2_dst += dst_strd; |
1180 | 0 | pu2_src += src_strd; |
1181 | 0 | } |
1182 | 0 | } |
1183 | | /* de-interleave U and V and copy to destination */ |
1184 | 15.4k | if(is_u_first) |
1185 | 15.4k | { |
1186 | 15.4k | pu2_u_src = (UWORD16 *)pu2_uv_src; |
1187 | 15.4k | pu2_v_src = (UWORD16 *)pu2_uv_src + 1; |
1188 | 15.4k | } |
1189 | 18.4E | else |
1190 | 18.4E | { |
1191 | 18.4E | pu2_u_src = (UWORD16 *)pu2_uv_src + 1; |
1192 | 18.4E | pu2_v_src = (UWORD16 *)pu2_uv_src; |
1193 | 18.4E | } |
1194 | | |
1195 | | |
1196 | 15.4k | num_rows = ht >> 1; |
1197 | 15.4k | num_cols = wd >> 1; |
1198 | | |
1199 | 15.4k | src_strd = src_uv_strd; |
1200 | 15.4k | dst_strd = dst_uv_strd; |
1201 | | |
1202 | 375k | for(i = 0; i < num_rows; i++) |
1203 | 359k | { |
1204 | 28.0M | for(j = 0; j < num_cols; j++) |
1205 | 27.6M | { |
1206 | 27.6M | pu2_u_dst[j] = pu2_u_src[j * 2]; |
1207 | 27.6M | pu2_v_dst[j] = pu2_v_src[j * 2]; |
1208 | 27.6M | } |
1209 | | |
1210 | 359k | pu2_u_dst += dst_strd; |
1211 | 359k | pu2_v_dst += dst_strd; |
1212 | 359k | pu2_u_src += src_strd; |
1213 | 359k | pu2_v_src += src_strd; |
1214 | 359k | } |
1215 | 15.4k | return; |
1216 | 15.4k | } |
1217 | | |
1218 | | |
1219 | | /** |
1220 | | ******************************************************************************* |
1221 | | * |
1222 | | * @brief Function used from format conversion or frame copy |
1223 | | * |
1224 | | * @par Description |
1225 | | * Function used from copying or converting a reference frame to display buffer |
1226 | | * in non shared mode |
1227 | | * |
1228 | | * @param[in] pu1_y_dst |
1229 | | * Output Y pointer |
1230 | | * |
1231 | | * @param[in] pu1_u_dst |
1232 | | * Output U/UV pointer ( UV is interleaved in the same format as that of input) |
1233 | | * |
1234 | | * @param[in] pu1_v_dst |
1235 | | * Output V pointer ( used in 420P output case) |
1236 | | * |
1237 | | * @param[in] blocking |
1238 | | * To indicate whether format conversion should wait till frame is reconstructed |
1239 | | * and then return after complete copy is done. To be set to 1 when called at the |
1240 | | * end of frame processing and set to 0 when called between frame processing modules |
1241 | | * in order to utilize available MCPS |
1242 | | * |
1243 | | * @returns Error from IHEVCD_ERROR_T |
1244 | | * |
1245 | | ******************************************************************************* |
1246 | | */ |
1247 | | IHEVCD_ERROR_T ihevcd_fmt_conv(codec_t *ps_codec, |
1248 | | process_ctxt_t *ps_proc, |
1249 | | UWORD8 *pu1_y_dst, |
1250 | | UWORD8 *pu1_u_dst, |
1251 | | UWORD8 *pu1_v_dst, |
1252 | | WORD32 cur_row, |
1253 | | WORD32 num_rows) |
1254 | 655k | { |
1255 | 655k | IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; |
1256 | 655k | pic_buf_t *ps_disp_pic; |
1257 | 655k | UWORD8 *pu1_y_src, *pu1_uv_src; |
1258 | 655k | UWORD8 *pu1_y_dst_tmp, *pu1_uv_dst_tmp; |
1259 | 655k | UWORD8 *pu1_u_dst_tmp, *pu1_v_dst_tmp; |
1260 | 655k | WORD32 is_u_first; |
1261 | 655k | UWORD8 *pu1_luma; |
1262 | 655k | UWORD8 *pu1_chroma; |
1263 | 655k | sps_t *ps_sps; |
1264 | 655k | WORD32 disable_luma_copy; |
1265 | 655k | WORD32 crop_unit_x, crop_unit_y; |
1266 | 655k | WORD32 h_samp_factor, v_samp_factor; |
1267 | 655k | WORD32 src_chroma_pixel_strd = 2; |
1268 | 655k | WORD32 src_chroma_row_stride; |
1269 | | |
1270 | 655k | if(0 == num_rows) |
1271 | 1.59k | return ret; |
1272 | | |
1273 | | /* In case processing is disabled, then no need to format convert/copy */ |
1274 | 653k | PROFILE_DISABLE_FMT_CONV(); |
1275 | 653k | ps_sps = ps_proc->ps_sps; |
1276 | | |
1277 | 653k | h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2; |
1278 | 653k | v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1; |
1279 | | |
1280 | 653k | crop_unit_x = 1; |
1281 | 653k | crop_unit_y = 1; |
1282 | | |
1283 | 653k | if(CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) |
1284 | 532k | { |
1285 | 532k | crop_unit_x = 2; |
1286 | 532k | crop_unit_y = 2; |
1287 | 532k | } |
1288 | 121k | else if(CHROMA_FMT_IDC_YUV422 == ps_sps->i1_chroma_format_idc) |
1289 | 117k | { |
1290 | 117k | crop_unit_x = 2; |
1291 | 117k | crop_unit_y = 1; |
1292 | 117k | } |
1293 | | |
1294 | 653k | ps_disp_pic = ps_codec->ps_disp_buf; |
1295 | 653k | pu1_luma = ps_disp_pic->pu1_luma; |
1296 | 653k | if(CHROMA_FMT_IDC_MONOCHROME != ps_sps->i1_chroma_format_idc) |
1297 | 649k | { |
1298 | 649k | pu1_chroma = ps_disp_pic->pu1_chroma; |
1299 | 649k | } |
1300 | | |
1301 | | |
1302 | | /* Take care of cropping */ |
1303 | 653k | pu1_luma += |
1304 | 653k | (ps_codec->i4_strd * ps_sps->i2_pic_crop_top_offset * crop_unit_y + ps_sps->i2_pic_crop_left_offset * crop_unit_x) * |
1305 | 653k | ps_codec->i4_pixel_size_y; |
1306 | | |
1307 | 653k | src_chroma_row_stride = (ps_codec->i4_strd * src_chroma_pixel_strd / h_samp_factor); |
1308 | 653k | if(CHROMA_FMT_IDC_MONOCHROME != ps_sps->i1_chroma_format_idc) |
1309 | 649k | { |
1310 | 649k | pu1_chroma += ((ps_sps->i2_pic_crop_top_offset * src_chroma_row_stride) |
1311 | 649k | + ps_sps->i2_pic_crop_left_offset * src_chroma_pixel_strd) * ps_codec->i4_pixel_size_uv; |
1312 | 649k | } |
1313 | 653k | is_u_first = (IV_YUV_420SP_UV == ps_codec->e_ref_chroma_fmt) ? 1 : 0; |
1314 | | |
1315 | | /* In case of 420P output luma copy is disabled for shared mode */ |
1316 | 653k | disable_luma_copy = 0; |
1317 | 653k | if(1 == ps_codec->i4_share_disp_buf) |
1318 | 0 | { |
1319 | 0 | disable_luma_copy = 1; |
1320 | 0 | } |
1321 | | |
1322 | | |
1323 | | |
1324 | 653k | { |
1325 | 653k | pu1_y_src = pu1_luma + cur_row * ps_codec->i4_strd * ps_codec->i4_pixel_size_y; |
1326 | 653k | if(CHROMA_FMT_IDC_MONOCHROME != ps_sps->i1_chroma_format_idc) |
1327 | 648k | { |
1328 | 648k | pu1_uv_src = pu1_chroma + (((cur_row / v_samp_factor) * src_chroma_row_stride) * ps_codec->i4_pixel_size_uv); |
1329 | 648k | } |
1330 | | |
1331 | | /* In case of shared mode, with 420P output, get chroma destination */ |
1332 | 653k | if((1 == ps_codec->i4_share_disp_buf) && (IV_YUV_420P == ps_codec->e_chroma_fmt)) |
1333 | 0 | { |
1334 | 0 | WORD32 i; |
1335 | 0 | for(i = 0; i < ps_codec->i4_share_disp_buf_cnt; i++) |
1336 | 0 | { |
1337 | 0 | WORD32 diff = ps_disp_pic->pu1_luma - ps_codec->s_disp_buffer[i].pu1_bufs[0]; |
1338 | 0 | if(diff == (ps_codec->i4_strd * PAD_TOP + PAD_LEFT)) |
1339 | 0 | { |
1340 | 0 | pu1_u_dst = ps_codec->s_disp_buffer[i].pu1_bufs[1]; |
1341 | 0 | pu1_u_dst += (ps_codec->i4_strd * PAD_TOP) / 4 + (PAD_LEFT / 2); |
1342 | |
|
1343 | 0 | pu1_v_dst = ps_codec->s_disp_buffer[i].pu1_bufs[2]; |
1344 | 0 | pu1_v_dst += (ps_codec->i4_strd * PAD_TOP) / 4 + (PAD_LEFT / 2); |
1345 | 0 | break; |
1346 | 0 | } |
1347 | 0 | } |
1348 | 0 | } |
1349 | 653k | pu1_y_dst_tmp = pu1_y_dst + cur_row * ps_codec->i4_disp_strd * ps_codec->i4_pixel_size_y; |
1350 | 653k | if(IV_YUV_444P == ps_codec->e_chroma_fmt) |
1351 | 0 | { |
1352 | 0 | pu1_u_dst_tmp = pu1_u_dst + cur_row * ps_codec->i4_disp_strd * ps_codec->i4_pixel_size_uv; |
1353 | 0 | pu1_v_dst_tmp = pu1_v_dst + cur_row * ps_codec->i4_disp_strd * ps_codec->i4_pixel_size_uv; |
1354 | 0 | } |
1355 | 653k | else if(IV_YUV_422P == ps_codec->e_chroma_fmt) |
1356 | 19.7k | { |
1357 | 19.7k | pu1_u_dst_tmp = pu1_u_dst + cur_row * ((ps_codec->i4_disp_strd + 1) / 2) * ps_codec->i4_pixel_size_uv; |
1358 | 19.7k | pu1_v_dst_tmp = pu1_v_dst + cur_row * ((ps_codec->i4_disp_strd + 1) / 2) * ps_codec->i4_pixel_size_uv; |
1359 | 19.7k | } |
1360 | 633k | else if(IV_YUV_420P == ps_codec->e_chroma_fmt) |
1361 | 215k | { |
1362 | 215k | pu1_u_dst_tmp = pu1_u_dst + ((cur_row + 1) / 2) * ((ps_codec->i4_disp_strd + 1) / 2) * ps_codec->i4_pixel_size_uv; |
1363 | 215k | pu1_v_dst_tmp = pu1_v_dst + ((cur_row + 1) / 2) * ((ps_codec->i4_disp_strd + 1) / 2) * ps_codec->i4_pixel_size_uv; |
1364 | 215k | } |
1365 | 418k | else if(IV_YUV_420SP_UV == ps_codec->e_chroma_fmt |
1366 | 295k | || IV_YUV_420SP_VU == ps_codec->e_chroma_fmt) |
1367 | 208k | { |
1368 | 208k | pu1_uv_dst_tmp = pu1_u_dst + ((cur_row + 1) / 2) * ALIGN2(ps_codec->i4_disp_strd) * ps_codec->i4_pixel_size_uv; |
1369 | 208k | } |
1370 | | |
1371 | | /* In case of multi threaded implementation, format conversion might be called |
1372 | | * before reconstruction is completed. If the frame being converted/copied |
1373 | | * is same as the frame being reconstructed, |
1374 | | * Check how many rows can be format converted |
1375 | | * Convert those many rows and then check for remaining rows and so on |
1376 | | */ |
1377 | | |
1378 | 653k | if((0 == ps_codec->i4_flush_mode) && (ps_codec->i4_disp_buf_id == ps_proc->i4_cur_pic_buf_id) && (1 < ps_codec->i4_num_cores)) |
1379 | 612k | { |
1380 | 612k | WORD32 idx; |
1381 | 612k | UWORD8 *pu1_buf; |
1382 | 612k | WORD32 status; |
1383 | 612k | WORD32 last_row = cur_row + num_rows; |
1384 | 612k | WORD32 last_ctb_y; |
1385 | 612k | UWORD32 ctb_in_row; |
1386 | | |
1387 | 23.9M | while(1) |
1388 | 23.9M | { |
1389 | 23.9M | last_row = cur_row + MAX(num_rows, (1 << ps_sps->i1_log2_ctb_size)) + |
1390 | 23.9M | ps_sps->i2_pic_crop_top_offset * crop_unit_y; |
1391 | 23.9M | last_ctb_y = (last_row >> ps_sps->i1_log2_ctb_size) - 1; |
1392 | | /* Since deblocking works with a shift of -4, -4 ,wait till next CTB row is processed */ |
1393 | 23.9M | last_ctb_y++; |
1394 | | /* In case of a conformance window, an extra wait of one row might be needed */ |
1395 | 23.9M | last_ctb_y++; |
1396 | 23.9M | last_ctb_y = MIN(last_ctb_y, (ps_sps->i2_pic_ht_in_ctb - 1)); |
1397 | | |
1398 | 23.9M | idx = (last_ctb_y * ps_sps->i2_pic_wd_in_ctb); |
1399 | | |
1400 | | /*Check if the row below is completely processed before proceeding with format conversion*/ |
1401 | 23.9M | status = 1; |
1402 | 917M | for(ctb_in_row = 0; (WORD32)ctb_in_row < ps_sps->i2_pic_wd_in_ctb; ctb_in_row++) |
1403 | 893M | { |
1404 | 893M | pu1_buf = (ps_codec->pu1_proc_map + idx + ctb_in_row); |
1405 | 893M | status &= *pu1_buf; |
1406 | 893M | } |
1407 | | |
1408 | 23.9M | if(status) |
1409 | 607k | { |
1410 | 607k | break; |
1411 | 607k | } |
1412 | 23.3M | else |
1413 | 23.3M | { |
1414 | 23.3M | ithread_yield(); |
1415 | 23.3M | } |
1416 | 23.9M | } |
1417 | 612k | } |
1418 | | |
1419 | 653k | if((IV_YUV_420SP_UV == ps_codec->e_chroma_fmt) || (IV_YUV_420SP_VU == ps_codec->e_chroma_fmt)) |
1420 | 207k | { |
1421 | 207k | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) |
1422 | 207k | { |
1423 | 207k | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1424 | 181k | { |
1425 | 181k | ihevcd_fmt_conv_420sp_to_420sp_ft *fmt_conv_fptr; |
1426 | 181k | if(ps_codec->i4_disp_wd >= MIN_FMT_CONV_SIMD_WIDTH) |
1427 | 166k | { |
1428 | 166k | fmt_conv_fptr = ps_codec->s_func_selector.ihevcd_fmt_conv_420sp_to_420sp_fptr; |
1429 | 166k | } |
1430 | 15.5k | else |
1431 | 15.5k | { |
1432 | 15.5k | fmt_conv_fptr = ihevcd_fmt_conv_420sp_to_420sp; |
1433 | 15.5k | } |
1434 | 181k | fmt_conv_fptr(pu1_y_src, pu1_uv_src, |
1435 | 181k | pu1_y_dst_tmp, pu1_uv_dst_tmp, |
1436 | 181k | ps_codec->i4_disp_wd, num_rows, |
1437 | 181k | ps_codec->i4_strd, ps_codec->i4_strd, |
1438 | 181k | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); |
1439 | 181k | } |
1440 | 25.5k | else |
1441 | 25.5k | { |
1442 | 25.5k | ihevcd_hbd_fmt_conv_420sp_to_420sp((UWORD16 *)pu1_y_src, (UWORD16 *)pu1_uv_src, |
1443 | 25.5k | (UWORD16 *)pu1_y_dst_tmp, (UWORD16 *)pu1_uv_dst_tmp, |
1444 | 25.5k | ps_codec->i4_disp_wd, num_rows, |
1445 | 25.5k | ps_codec->i4_strd, ps_codec->i4_strd, |
1446 | 25.5k | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); |
1447 | 25.5k | } |
1448 | 207k | } |
1449 | 316 | else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_MONOCHROME) |
1450 | 0 | { |
1451 | 0 | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1452 | 0 | { |
1453 | 0 | ihevcd_fmt_conv_400_to_420sp(pu1_y_src, |
1454 | 0 | pu1_y_dst_tmp, pu1_uv_dst_tmp, |
1455 | 0 | ps_codec->i4_disp_wd, num_rows, |
1456 | 0 | ps_codec->i4_strd, |
1457 | 0 | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); |
1458 | 0 | } |
1459 | 0 | else |
1460 | 0 | { |
1461 | 0 | ihevcd_hbd_fmt_conv_400_to_420sp((UWORD16 *)pu1_y_src, |
1462 | 0 | (UWORD16 *)pu1_y_dst_tmp, |
1463 | 0 | (UWORD16 *)pu1_uv_dst_tmp, |
1464 | 0 | ps_codec->i4_disp_wd, num_rows, |
1465 | 0 | ps_codec->i4_strd, |
1466 | 0 | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd, |
1467 | 0 | ps_sps->i1_bit_depth_luma_minus8 + 8); |
1468 | 0 | } |
1469 | 0 | } |
1470 | 207k | } |
1471 | 445k | else if(IV_GRAY == ps_codec->e_chroma_fmt) |
1472 | 204k | { |
1473 | 204k | ihevcd_fmt_conv_luma_copy(pu1_y_src, |
1474 | 204k | pu1_y_dst_tmp, |
1475 | 204k | ps_codec->i4_disp_wd * ps_codec->i4_pixel_size_y, |
1476 | 204k | num_rows, |
1477 | 204k | ps_codec->i4_strd * ps_codec->i4_pixel_size_y, |
1478 | 204k | ps_codec->i4_disp_strd * ps_codec->i4_pixel_size_y); |
1479 | 204k | } |
1480 | 241k | else if(IV_YUV_444P == ps_codec->e_chroma_fmt) |
1481 | 0 | { |
1482 | 0 | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444) |
1483 | 0 | { |
1484 | 0 | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1485 | 0 | { |
1486 | 0 | ps_codec->s_func_selector.ihevcd_fmt_conv_444sp_to_444p_fptr( |
1487 | 0 | pu1_y_src, pu1_uv_src, |
1488 | 0 | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1489 | 0 | ps_codec->i4_disp_wd, num_rows, |
1490 | 0 | ps_codec->i4_strd, src_chroma_row_stride, |
1491 | 0 | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); |
1492 | 0 | } |
1493 | 0 | else |
1494 | 0 | { |
1495 | 0 | ihevcd_fmt_conv_hbd_444sp_to_444p((UWORD16 *)pu1_y_src, (UWORD16 *)pu1_uv_src, |
1496 | 0 | (UWORD16 *)pu1_y_dst_tmp, (UWORD16 *)pu1_u_dst_tmp, |
1497 | 0 | (UWORD16 *)pu1_v_dst_tmp, ps_codec->i4_disp_wd, num_rows, |
1498 | 0 | ps_codec->i4_strd, src_chroma_row_stride, |
1499 | 0 | ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); |
1500 | 0 | } |
1501 | 0 | } |
1502 | 0 | } |
1503 | 241k | else if(IV_YUV_422P == ps_codec->e_chroma_fmt) |
1504 | 19.3k | { |
1505 | 19.3k | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422) |
1506 | 19.3k | { |
1507 | 19.3k | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1508 | 13.6k | { |
1509 | 13.6k | ihevcd_fmt_conv_422sp_to_422p(pu1_y_src, pu1_uv_src, |
1510 | 13.6k | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1511 | 13.6k | ps_codec->i4_disp_wd, num_rows, |
1512 | 13.6k | ps_codec->i4_strd, ps_codec->i4_strd, |
1513 | 13.6k | ps_codec->i4_disp_strd, |
1514 | 13.6k | ((ps_codec->i4_disp_strd + 1) / 2)); |
1515 | 13.6k | } |
1516 | 5.72k | else |
1517 | 5.72k | { |
1518 | 5.72k | ihevcd_hbd_fmt_conv_422sp_to_422p((UWORD16 *)pu1_y_src, (UWORD16 *)pu1_uv_src, |
1519 | 5.72k | (UWORD16 *)pu1_y_dst_tmp, (UWORD16 *)pu1_u_dst_tmp, |
1520 | 5.72k | (UWORD16 *)pu1_v_dst_tmp, ps_codec->i4_disp_wd, num_rows, |
1521 | 5.72k | ps_codec->i4_strd, ps_codec->i4_strd, |
1522 | 5.72k | ps_codec->i4_disp_strd, ((ps_codec->i4_disp_strd + 1) / 2), |
1523 | 5.72k | is_u_first, disable_luma_copy); |
1524 | 5.72k | } |
1525 | 19.3k | } |
1526 | 19.3k | } |
1527 | 221k | else if(IV_YUV_420P == ps_codec->e_chroma_fmt) |
1528 | 211k | { |
1529 | 211k | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_MONOCHROME) |
1530 | 2.92k | { |
1531 | 2.92k | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1532 | 2.05k | { |
1533 | 2.05k | ihevcd_fmt_conv_400_to_420p(pu1_y_src, |
1534 | 2.05k | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1535 | 2.05k | ps_codec->i4_disp_wd, num_rows, |
1536 | 2.05k | ps_codec->i4_strd, |
1537 | 2.05k | ps_codec->i4_disp_strd, |
1538 | 2.05k | ((ps_codec->i4_disp_strd + 1) / 2)); |
1539 | 2.05k | } |
1540 | 874 | else |
1541 | 874 | { |
1542 | 874 | ihevcd_hbd_fmt_conv_400_to_420p((UWORD16 *)pu1_y_src, |
1543 | 874 | (UWORD16 *)pu1_y_dst_tmp, |
1544 | 874 | (UWORD16 *)pu1_u_dst_tmp, |
1545 | 874 | (UWORD16 *)pu1_v_dst_tmp, |
1546 | 874 | ps_codec->i4_disp_wd, num_rows, |
1547 | 874 | ps_codec->i4_strd, |
1548 | 874 | ps_codec->i4_disp_strd, |
1549 | 874 | ((ps_codec->i4_disp_strd + 1) / 2), |
1550 | 874 | ps_sps->i1_bit_depth_luma_minus8 + 8); |
1551 | 874 | } |
1552 | 2.92k | } |
1553 | 208k | else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420) |
1554 | 127k | { |
1555 | 127k | ihevcd_fmt_conv_420sp_to_420p_ft *fmt_conv_fptr; |
1556 | 127k | if(ps_codec->i4_disp_wd >= MIN_FMT_CONV_SIMD_WIDTH) |
1557 | 117k | { |
1558 | 117k | fmt_conv_fptr = ps_codec->s_func_selector.ihevcd_fmt_conv_420sp_to_420p_fptr; |
1559 | 117k | } |
1560 | 9.54k | else |
1561 | 9.54k | { |
1562 | 9.54k | fmt_conv_fptr = ihevcd_fmt_conv_420sp_to_420p; |
1563 | 9.54k | } |
1564 | | |
1565 | 127k | if(0 == disable_luma_copy) |
1566 | 127k | { |
1567 | | // copy luma |
1568 | 127k | WORD32 i; |
1569 | 127k | WORD32 num_cols = ps_codec->i4_disp_wd * ps_codec->i4_pixel_size_y; |
1570 | | |
1571 | 8.98M | for(i = 0; i < num_rows; i++) |
1572 | 8.86M | { |
1573 | 8.86M | memcpy(pu1_y_dst_tmp, pu1_y_src, num_cols); |
1574 | 8.86M | pu1_y_dst_tmp += ps_codec->i4_disp_strd * ps_codec->i4_pixel_size_y; |
1575 | 8.86M | pu1_y_src += ps_codec->i4_strd * ps_codec->i4_pixel_size_y; |
1576 | 8.86M | } |
1577 | | |
1578 | 127k | disable_luma_copy = 1; |
1579 | 127k | } |
1580 | | |
1581 | 127k | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1582 | 111k | { |
1583 | 111k | fmt_conv_fptr(pu1_y_src, pu1_uv_src, |
1584 | 111k | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1585 | 111k | ps_codec->i4_disp_wd, |
1586 | 111k | num_rows, |
1587 | 111k | ps_codec->i4_strd, |
1588 | 111k | ps_codec->i4_strd, |
1589 | 111k | ps_codec->i4_disp_strd, |
1590 | 111k | (ps_codec->i4_disp_strd / 2), |
1591 | 111k | is_u_first, |
1592 | 111k | disable_luma_copy); |
1593 | 111k | } |
1594 | 15.5k | else |
1595 | 15.5k | { |
1596 | 15.5k | ps_codec->s_func_selector.ihevcd_hbd_fmt_conv_420sp_to_420p_fptr( |
1597 | 15.5k | (UWORD16 *)pu1_y_src, (UWORD16 *)pu1_uv_src, |
1598 | 15.5k | (UWORD16 *)pu1_y_dst_tmp, (UWORD16 *)pu1_u_dst_tmp, |
1599 | 15.5k | (UWORD16 *)pu1_v_dst_tmp, |
1600 | 15.5k | ps_codec->i4_disp_wd, |
1601 | 15.5k | num_rows, |
1602 | 15.5k | ps_codec->i4_strd, |
1603 | 15.5k | ps_codec->i4_strd, |
1604 | 15.5k | ps_codec->i4_disp_strd, |
1605 | 15.5k | (ps_codec->i4_disp_strd / 2), |
1606 | 15.5k | is_u_first, |
1607 | 15.5k | disable_luma_copy); |
1608 | 15.5k | } |
1609 | 127k | } |
1610 | 81.2k | else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444) |
1611 | 0 | { |
1612 | 0 | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1613 | 0 | { |
1614 | 0 | ihevcd_fmt_conv_444sp_to_420p(pu1_y_src, pu1_uv_src, |
1615 | 0 | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1616 | 0 | ps_codec->i4_disp_wd, num_rows, |
1617 | 0 | ps_codec->i4_strd, src_chroma_row_stride, |
1618 | 0 | ps_codec->i4_disp_strd, |
1619 | 0 | ((ps_codec->i4_disp_strd + 1) / 2)); |
1620 | 0 | } |
1621 | 0 | else |
1622 | 0 | { |
1623 | 0 | ihevcd_hbd_fmt_conv_444sp_to_420p((UWORD16 *)pu1_y_src, |
1624 | 0 | (UWORD16 *)pu1_uv_src, |
1625 | 0 | (UWORD16 *)pu1_y_dst_tmp, |
1626 | 0 | (UWORD16 *)pu1_u_dst_tmp, |
1627 | 0 | (UWORD16 *)pu1_v_dst_tmp, |
1628 | 0 | ps_codec->i4_disp_wd, num_rows, |
1629 | 0 | ps_codec->i4_strd, src_chroma_row_stride, |
1630 | 0 | ps_codec->i4_disp_strd, |
1631 | 0 | ((ps_codec->i4_disp_strd + 1) / 2), |
1632 | 0 | is_u_first, disable_luma_copy); |
1633 | 0 | } |
1634 | 0 | } |
1635 | 81.2k | else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422) |
1636 | 81.0k | { |
1637 | 81.0k | if(PIXEL_SIZE_1BYTE == ps_codec->i4_pixel_size_y) |
1638 | 16.6k | { |
1639 | 16.6k | ihevcd_fmt_conv_422sp_to_420p(pu1_y_src, pu1_uv_src, |
1640 | 16.6k | pu1_y_dst_tmp, pu1_u_dst_tmp, pu1_v_dst_tmp, |
1641 | 16.6k | ps_codec->i4_disp_wd, num_rows, |
1642 | 16.6k | ps_codec->i4_strd, src_chroma_row_stride, |
1643 | 16.6k | ps_codec->i4_disp_strd, |
1644 | 16.6k | ((ps_codec->i4_disp_strd + 1) / 2)); |
1645 | 16.6k | } |
1646 | 64.4k | else |
1647 | 64.4k | { |
1648 | 64.4k | ihevcd_hbd_fmt_conv_422sp_to_420p((UWORD16 *)pu1_y_src, |
1649 | 64.4k | (UWORD16 *)pu1_uv_src, |
1650 | 64.4k | (UWORD16 *)pu1_y_dst_tmp, |
1651 | 64.4k | (UWORD16 *)pu1_u_dst_tmp, |
1652 | 64.4k | (UWORD16 *)pu1_v_dst_tmp, |
1653 | 64.4k | ps_codec->i4_disp_wd, num_rows, |
1654 | 64.4k | ps_codec->i4_strd, src_chroma_row_stride, |
1655 | 64.4k | ps_codec->i4_disp_strd, |
1656 | 64.4k | ((ps_codec->i4_disp_strd + 1) / 2), |
1657 | 64.4k | is_u_first, disable_luma_copy); |
1658 | 64.4k | } |
1659 | 81.0k | } |
1660 | 211k | } |
1661 | 653k | } |
1662 | 653k | return (ret); |
1663 | 655k | } |
1664 | | |