/src/libhevc/decoder/ihevcd_api.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_api.c |
22 | | * |
23 | | * @brief |
24 | | * Contains api functions definitions for HEVC decoder |
25 | | * |
26 | | * @author |
27 | | * Harish |
28 | | * |
29 | | * @par List of Functions: |
30 | | * - api_check_struct_sanity() |
31 | | * - ihevcd_get_version() |
32 | | * - ihevcd_set_default_params() |
33 | | * - ihevcd_init() |
34 | | * - ihevcd_get_num_rec() |
35 | | * - ihevcd_allocate_static_bufs() |
36 | | * - ihevcd_create() |
37 | | * - ihevcd_retrieve_memrec() |
38 | | * - ihevcd_set_display_frame() |
39 | | * - ihevcd_set_flush_mode() |
40 | | * - ihevcd_get_status() |
41 | | * - ihevcd_get_buf_info() |
42 | | * - ihevcd_set_params() |
43 | | * - ihevcd_reset() |
44 | | * - ihevcd_rel_display_frame() |
45 | | * - ihevcd_disable_deblk() |
46 | | * - ihevcd_get_frame_dimensions() |
47 | | * - ihevcd_set_num_cores() |
48 | | * - ihevcd_ctl() |
49 | | * - ihevcd_cxa_api_function() |
50 | | * |
51 | | * @remarks |
52 | | * None |
53 | | * |
54 | | ******************************************************************************* |
55 | | */ |
56 | | /*****************************************************************************/ |
57 | | /* File Includes */ |
58 | | /*****************************************************************************/ |
59 | | #include <stdio.h> |
60 | | #include <stddef.h> |
61 | | #include <stdlib.h> |
62 | | #include <string.h> |
63 | | |
64 | | #include "ihevc_typedefs.h" |
65 | | #include "iv.h" |
66 | | #include "ivd.h" |
67 | | #include "ihevcd_cxa.h" |
68 | | #include "ithread.h" |
69 | | |
70 | | #include "ihevc_defs.h" |
71 | | #include "ihevc_debug.h" |
72 | | |
73 | | #include "ihevc_structs.h" |
74 | | #include "ihevc_macros.h" |
75 | | #include "ihevc_platform_macros.h" |
76 | | |
77 | | #include "ihevc_buf_mgr.h" |
78 | | #include "ihevc_dpb_mgr.h" |
79 | | #include "ihevc_disp_mgr.h" |
80 | | #include "ihevc_common_tables.h" |
81 | | #include "ihevc_cabac_tables.h" |
82 | | #include "ihevc_error.h" |
83 | | |
84 | | #include "ihevcd_defs.h" |
85 | | #include "ihevcd_trace.h" |
86 | | |
87 | | #include "ihevcd_function_selector.h" |
88 | | #include "ihevcd_structs.h" |
89 | | #include "ihevcd_error.h" |
90 | | #include "ihevcd_utils.h" |
91 | | #include "ihevcd_decode.h" |
92 | | #include "ihevcd_job_queue.h" |
93 | | #include "ihevcd_statistics.h" |
94 | | |
95 | | |
96 | 0 | #define ALIGNED_FREE(ps_codec, y) \ |
97 | 0 | if(y) {ps_codec->pf_aligned_free(ps_codec->pv_mem_ctxt, ((void *)y)); (y) = NULL;} |
98 | | |
99 | | /*****************************************************************************/ |
100 | | /* Function Prototypes */ |
101 | | /*****************************************************************************/ |
102 | | IV_API_CALL_STATUS_T ihevcd_get_version(CHAR *pc_version_string, |
103 | | UWORD32 u4_version_buffer_size); |
104 | | WORD32 ihevcd_free_dynamic_bufs(codec_t *ps_codec); |
105 | | |
106 | | |
107 | | /** |
108 | | ******************************************************************************* |
109 | | * |
110 | | * @brief |
111 | | * Used to test arguments for corresponding API call |
112 | | * |
113 | | * @par Description: |
114 | | * For each command the arguments are validated |
115 | | * |
116 | | * @param[in] ps_handle |
117 | | * Codec handle at API level |
118 | | * |
119 | | * @param[in] pv_api_ip |
120 | | * Pointer to input structure |
121 | | * |
122 | | * @param[out] pv_api_op |
123 | | * Pointer to output structure |
124 | | * |
125 | | * @returns Status of error checking |
126 | | * |
127 | | * @remarks |
128 | | * |
129 | | * |
130 | | ******************************************************************************* |
131 | | */ |
132 | | |
133 | | static IV_API_CALL_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, |
134 | | void *pv_api_ip, |
135 | | void *pv_api_op) |
136 | 0 | { |
137 | 0 | IVD_API_COMMAND_TYPE_T e_cmd; |
138 | 0 | UWORD32 *pu4_api_ip; |
139 | 0 | UWORD32 *pu4_api_op; |
140 | 0 | WORD32 i; |
141 | |
|
142 | 0 | if(NULL == pv_api_op) |
143 | 0 | return (IV_FAIL); |
144 | | |
145 | 0 | if(NULL == pv_api_ip) |
146 | 0 | return (IV_FAIL); |
147 | | |
148 | 0 | pu4_api_ip = (UWORD32 *)pv_api_ip; |
149 | 0 | pu4_api_op = (UWORD32 *)pv_api_op; |
150 | 0 | e_cmd = (IVD_API_COMMAND_TYPE_T)*(pu4_api_ip + 1); |
151 | |
|
152 | 0 | *(pu4_api_op + 1) = 0; |
153 | | /* error checks on handle */ |
154 | 0 | switch((WORD32)e_cmd) |
155 | 0 | { |
156 | 0 | case IVD_CMD_CREATE: |
157 | 0 | break; |
158 | | |
159 | 0 | case IVD_CMD_REL_DISPLAY_FRAME: |
160 | 0 | case IVD_CMD_SET_DISPLAY_FRAME: |
161 | 0 | case IVD_CMD_GET_DISPLAY_FRAME: |
162 | 0 | case IVD_CMD_VIDEO_DECODE: |
163 | 0 | case IVD_CMD_DELETE: |
164 | 0 | case IVD_CMD_VIDEO_CTL: |
165 | 0 | if(ps_handle == NULL) |
166 | 0 | { |
167 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
168 | 0 | *(pu4_api_op + 1) |= IVD_HANDLE_NULL; |
169 | 0 | return IV_FAIL; |
170 | 0 | } |
171 | | |
172 | 0 | if(ps_handle->u4_size != sizeof(iv_obj_t)) |
173 | 0 | { |
174 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
175 | 0 | *(pu4_api_op + 1) |= IVD_HANDLE_STRUCT_SIZE_INCORRECT; |
176 | 0 | return IV_FAIL; |
177 | 0 | } |
178 | | |
179 | | |
180 | 0 | if(ps_handle->pv_codec_handle == NULL) |
181 | 0 | { |
182 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
183 | 0 | *(pu4_api_op + 1) |= IVD_INVALID_HANDLE_NULL; |
184 | 0 | return IV_FAIL; |
185 | 0 | } |
186 | 0 | break; |
187 | 0 | default: |
188 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
189 | 0 | *(pu4_api_op + 1) |= IVD_INVALID_API_CMD; |
190 | 0 | return IV_FAIL; |
191 | 0 | } |
192 | | |
193 | 0 | switch((WORD32)e_cmd) |
194 | 0 | { |
195 | 0 | case IVD_CMD_CREATE: |
196 | 0 | { |
197 | 0 | ihevcd_cxa_create_ip_t *ps_ip = (ihevcd_cxa_create_ip_t *)pv_api_ip; |
198 | 0 | ihevcd_cxa_create_op_t *ps_op = (ihevcd_cxa_create_op_t *)pv_api_op; |
199 | | |
200 | |
|
201 | 0 | ps_op->s_ivd_create_op_t.u4_error_code = 0; |
202 | |
|
203 | 0 | if((ps_ip->s_ivd_create_ip_t.u4_size > sizeof(ihevcd_cxa_create_ip_t)) |
204 | 0 | || (ps_ip->s_ivd_create_ip_t.u4_size |
205 | 0 | < sizeof(ivd_create_ip_t))) |
206 | 0 | { |
207 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= 1 |
208 | 0 | << IVD_UNSUPPORTEDPARAM; |
209 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= |
210 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
211 | |
|
212 | 0 | return (IV_FAIL); |
213 | 0 | } |
214 | | |
215 | 0 | if((ps_op->s_ivd_create_op_t.u4_size != sizeof(ihevcd_cxa_create_op_t)) |
216 | 0 | && (ps_op->s_ivd_create_op_t.u4_size |
217 | 0 | != sizeof(ivd_create_op_t))) |
218 | 0 | { |
219 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= 1 |
220 | 0 | << IVD_UNSUPPORTEDPARAM; |
221 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= |
222 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
223 | |
|
224 | 0 | return (IV_FAIL); |
225 | 0 | } |
226 | | |
227 | | |
228 | 0 | if((ps_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420P) |
229 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format |
230 | 0 | != IV_YUV_420SP_UV) |
231 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format |
232 | 0 | != IV_YUV_420SP_VU) |
233 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format |
234 | 0 | != IV_GRAY) |
235 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format |
236 | 0 | != IV_YUV_444P) |
237 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format |
238 | 0 | != IV_YUV_422P)) |
239 | 0 | { |
240 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= 1 |
241 | 0 | << IVD_UNSUPPORTEDPARAM; |
242 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= |
243 | 0 | IVD_INIT_DEC_COL_FMT_NOT_SUPPORTED; |
244 | |
|
245 | 0 | return (IV_FAIL); |
246 | 0 | } |
247 | | |
248 | | /* Shared display mode is supported only for 420SP and 420P formats */ |
249 | 0 | if((ps_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420P) |
250 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420SP_UV) |
251 | 0 | && (ps_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420SP_VU) |
252 | 0 | && ps_ip->s_ivd_create_ip_t.u4_share_disp_buf == 1) |
253 | 0 | { |
254 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= 1 |
255 | 0 | << IVD_UNSUPPORTEDPARAM; |
256 | 0 | ps_op->s_ivd_create_op_t.u4_error_code |= |
257 | 0 | IVD_INIT_DEC_FAILED; |
258 | 0 | return (IV_FAIL); |
259 | 0 | } |
260 | |
|
261 | 0 | } |
262 | 0 | break; |
263 | | |
264 | 0 | case IVD_CMD_GET_DISPLAY_FRAME: |
265 | 0 | { |
266 | 0 | ihevcd_cxa_get_display_frame_ip_t *ps_ip = |
267 | 0 | (ihevcd_cxa_get_display_frame_ip_t *)pv_api_ip; |
268 | 0 | ihevcd_cxa_get_display_frame_op_t *ps_op = |
269 | 0 | (ihevcd_cxa_get_display_frame_op_t *)pv_api_op; |
270 | |
|
271 | 0 | ps_op->s_ivd_get_display_frame_op_t.u4_error_code = 0; |
272 | |
|
273 | 0 | if((ps_ip->s_ivd_get_display_frame_ip_t.u4_size |
274 | 0 | != sizeof(ihevcd_cxa_get_display_frame_ip_t)) |
275 | 0 | && (ps_ip->s_ivd_get_display_frame_ip_t.u4_size |
276 | 0 | != sizeof(ivd_get_display_frame_ip_t))) |
277 | 0 | { |
278 | 0 | ps_op->s_ivd_get_display_frame_op_t.u4_error_code |= 1 |
279 | 0 | << IVD_UNSUPPORTEDPARAM; |
280 | 0 | ps_op->s_ivd_get_display_frame_op_t.u4_error_code |= |
281 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
282 | 0 | return (IV_FAIL); |
283 | 0 | } |
284 | | |
285 | 0 | if((ps_op->s_ivd_get_display_frame_op_t.u4_size |
286 | 0 | != sizeof(ihevcd_cxa_get_display_frame_op_t)) |
287 | 0 | && (ps_op->s_ivd_get_display_frame_op_t.u4_size |
288 | 0 | != sizeof(ivd_get_display_frame_op_t))) |
289 | 0 | { |
290 | 0 | ps_op->s_ivd_get_display_frame_op_t.u4_error_code |= 1 |
291 | 0 | << IVD_UNSUPPORTEDPARAM; |
292 | 0 | ps_op->s_ivd_get_display_frame_op_t.u4_error_code |= |
293 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
294 | 0 | return (IV_FAIL); |
295 | 0 | } |
296 | |
|
297 | 0 | } |
298 | 0 | break; |
299 | | |
300 | 0 | case IVD_CMD_REL_DISPLAY_FRAME: |
301 | 0 | { |
302 | 0 | ihevcd_cxa_rel_display_frame_ip_t *ps_ip = |
303 | 0 | (ihevcd_cxa_rel_display_frame_ip_t *)pv_api_ip; |
304 | 0 | ihevcd_cxa_rel_display_frame_op_t *ps_op = |
305 | 0 | (ihevcd_cxa_rel_display_frame_op_t *)pv_api_op; |
306 | |
|
307 | 0 | ps_op->s_ivd_rel_display_frame_op_t.u4_error_code = 0; |
308 | |
|
309 | 0 | if((ps_ip->s_ivd_rel_display_frame_ip_t.u4_size |
310 | 0 | != sizeof(ihevcd_cxa_rel_display_frame_ip_t)) |
311 | 0 | && (ps_ip->s_ivd_rel_display_frame_ip_t.u4_size |
312 | 0 | != sizeof(ivd_rel_display_frame_ip_t))) |
313 | 0 | { |
314 | 0 | ps_op->s_ivd_rel_display_frame_op_t.u4_error_code |= 1 |
315 | 0 | << IVD_UNSUPPORTEDPARAM; |
316 | 0 | ps_op->s_ivd_rel_display_frame_op_t.u4_error_code |= |
317 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
318 | 0 | return (IV_FAIL); |
319 | 0 | } |
320 | | |
321 | 0 | if((ps_op->s_ivd_rel_display_frame_op_t.u4_size |
322 | 0 | != sizeof(ihevcd_cxa_rel_display_frame_op_t)) |
323 | 0 | && (ps_op->s_ivd_rel_display_frame_op_t.u4_size |
324 | 0 | != sizeof(ivd_rel_display_frame_op_t))) |
325 | 0 | { |
326 | 0 | ps_op->s_ivd_rel_display_frame_op_t.u4_error_code |= 1 |
327 | 0 | << IVD_UNSUPPORTEDPARAM; |
328 | 0 | ps_op->s_ivd_rel_display_frame_op_t.u4_error_code |= |
329 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
330 | 0 | return (IV_FAIL); |
331 | 0 | } |
332 | |
|
333 | 0 | } |
334 | 0 | break; |
335 | | |
336 | 0 | case IVD_CMD_SET_DISPLAY_FRAME: |
337 | 0 | { |
338 | 0 | ihevcd_cxa_set_display_frame_ip_t *ps_ip = |
339 | 0 | (ihevcd_cxa_set_display_frame_ip_t *)pv_api_ip; |
340 | 0 | ihevcd_cxa_set_display_frame_op_t *ps_op = |
341 | 0 | (ihevcd_cxa_set_display_frame_op_t *)pv_api_op; |
342 | 0 | UWORD32 j; |
343 | |
|
344 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code = 0; |
345 | |
|
346 | 0 | if((ps_ip->s_ivd_set_display_frame_ip_t.u4_size |
347 | 0 | != sizeof(ihevcd_cxa_set_display_frame_ip_t)) |
348 | 0 | && (ps_ip->s_ivd_set_display_frame_ip_t.u4_size |
349 | 0 | != sizeof(ivd_set_display_frame_ip_t))) |
350 | 0 | { |
351 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
352 | 0 | << IVD_UNSUPPORTEDPARAM; |
353 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
354 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
355 | 0 | return (IV_FAIL); |
356 | 0 | } |
357 | | |
358 | 0 | if((ps_op->s_ivd_set_display_frame_op_t.u4_size |
359 | 0 | != sizeof(ihevcd_cxa_set_display_frame_op_t)) |
360 | 0 | && (ps_op->s_ivd_set_display_frame_op_t.u4_size |
361 | 0 | != sizeof(ivd_set_display_frame_op_t))) |
362 | 0 | { |
363 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
364 | 0 | << IVD_UNSUPPORTEDPARAM; |
365 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
366 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
367 | 0 | return (IV_FAIL); |
368 | 0 | } |
369 | | |
370 | 0 | if(ps_ip->s_ivd_set_display_frame_ip_t.num_disp_bufs == 0) |
371 | 0 | { |
372 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
373 | 0 | << IVD_UNSUPPORTEDPARAM; |
374 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
375 | 0 | IVD_DISP_FRM_ZERO_OP_BUFS; |
376 | 0 | return IV_FAIL; |
377 | 0 | } |
378 | | |
379 | 0 | for(j = 0; j < ps_ip->s_ivd_set_display_frame_ip_t.num_disp_bufs; |
380 | 0 | j++) |
381 | 0 | { |
382 | 0 | if(ps_ip->s_ivd_set_display_frame_ip_t.s_disp_buffer[j].u4_num_bufs |
383 | 0 | == 0) |
384 | 0 | { |
385 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
386 | 0 | << IVD_UNSUPPORTEDPARAM; |
387 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
388 | 0 | IVD_DISP_FRM_ZERO_OP_BUFS; |
389 | 0 | return IV_FAIL; |
390 | 0 | } |
391 | | |
392 | 0 | for(i = 0; |
393 | 0 | i |
394 | 0 | < (WORD32)ps_ip->s_ivd_set_display_frame_ip_t.s_disp_buffer[j].u4_num_bufs; |
395 | 0 | i++) |
396 | 0 | { |
397 | 0 | if(ps_ip->s_ivd_set_display_frame_ip_t.s_disp_buffer[j].pu1_bufs[i] |
398 | 0 | == NULL) |
399 | 0 | { |
400 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
401 | 0 | << IVD_UNSUPPORTEDPARAM; |
402 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
403 | 0 | IVD_DISP_FRM_OP_BUF_NULL; |
404 | 0 | return IV_FAIL; |
405 | 0 | } |
406 | | |
407 | 0 | if(ps_ip->s_ivd_set_display_frame_ip_t.s_disp_buffer[j].u4_min_out_buf_size[i] |
408 | 0 | == 0) |
409 | 0 | { |
410 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= 1 |
411 | 0 | << IVD_UNSUPPORTEDPARAM; |
412 | 0 | ps_op->s_ivd_set_display_frame_op_t.u4_error_code |= |
413 | 0 | IVD_DISP_FRM_ZERO_OP_BUF_SIZE; |
414 | 0 | return IV_FAIL; |
415 | 0 | } |
416 | 0 | } |
417 | 0 | } |
418 | 0 | } |
419 | 0 | break; |
420 | | |
421 | 0 | case IVD_CMD_VIDEO_DECODE: |
422 | 0 | { |
423 | 0 | ihevcd_cxa_video_decode_ip_t *ps_ip = |
424 | 0 | (ihevcd_cxa_video_decode_ip_t *)pv_api_ip; |
425 | 0 | ihevcd_cxa_video_decode_op_t *ps_op = |
426 | 0 | (ihevcd_cxa_video_decode_op_t *)pv_api_op; |
427 | |
|
428 | 0 | DEBUG("The input bytes is: %d", |
429 | 0 | ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes); |
430 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code = 0; |
431 | |
|
432 | 0 | if(ps_ip->s_ivd_video_decode_ip_t.u4_size |
433 | 0 | != sizeof(ihevcd_cxa_video_decode_ip_t) |
434 | 0 | && ps_ip->s_ivd_video_decode_ip_t.u4_size |
435 | 0 | != sizeof(ivd_video_decode_ip_t)) |
436 | 0 | { |
437 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= 1 |
438 | 0 | << IVD_UNSUPPORTEDPARAM; |
439 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= |
440 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
441 | 0 | return (IV_FAIL); |
442 | 0 | } |
443 | | |
444 | 0 | if(ps_op->s_ivd_video_decode_op_t.u4_size |
445 | 0 | != sizeof(ihevcd_cxa_video_decode_op_t) |
446 | 0 | && ps_op->s_ivd_video_decode_op_t.u4_size |
447 | 0 | != sizeof(ivd_video_decode_op_t)) |
448 | 0 | { |
449 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= 1 |
450 | 0 | << IVD_UNSUPPORTEDPARAM; |
451 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= |
452 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
453 | 0 | return (IV_FAIL); |
454 | 0 | } |
455 | | |
456 | 0 | if(((codec_t *)(ps_handle->pv_codec_handle))->u1_enable_cu_info |
457 | 0 | && !ps_ip->pu1_8x8_blk_qp_map && !ps_ip->pu1_8x8_blk_type_map) |
458 | 0 | { |
459 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= 1 |
460 | 0 | << IVD_UNSUPPORTEDPARAM; |
461 | 0 | ps_op->s_ivd_video_decode_op_t.u4_error_code |= |
462 | 0 | IHEVCD_FRAME_INFO_OP_BUF_NULL; |
463 | 0 | return (IV_FAIL); |
464 | 0 | } |
465 | |
|
466 | 0 | } |
467 | 0 | break; |
468 | | |
469 | 0 | case IVD_CMD_DELETE: |
470 | 0 | { |
471 | 0 | ihevcd_cxa_delete_ip_t *ps_ip = |
472 | 0 | (ihevcd_cxa_delete_ip_t *)pv_api_ip; |
473 | 0 | ihevcd_cxa_delete_op_t *ps_op = |
474 | 0 | (ihevcd_cxa_delete_op_t *)pv_api_op; |
475 | |
|
476 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code = 0; |
477 | |
|
478 | 0 | if(ps_ip->s_ivd_delete_ip_t.u4_size |
479 | 0 | != sizeof(ihevcd_cxa_delete_ip_t)) |
480 | 0 | { |
481 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code |= 1 |
482 | 0 | << IVD_UNSUPPORTEDPARAM; |
483 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code |= |
484 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
485 | 0 | return (IV_FAIL); |
486 | 0 | } |
487 | | |
488 | 0 | if(ps_op->s_ivd_delete_op_t.u4_size |
489 | 0 | != sizeof(ihevcd_cxa_delete_op_t)) |
490 | 0 | { |
491 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code |= 1 |
492 | 0 | << IVD_UNSUPPORTEDPARAM; |
493 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code |= |
494 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
495 | 0 | return (IV_FAIL); |
496 | 0 | } |
497 | |
|
498 | 0 | } |
499 | 0 | break; |
500 | | |
501 | 0 | case IVD_CMD_VIDEO_CTL: |
502 | 0 | { |
503 | 0 | UWORD32 *pu4_ptr_cmd; |
504 | 0 | UWORD32 sub_command; |
505 | |
|
506 | 0 | pu4_ptr_cmd = (UWORD32 *)pv_api_ip; |
507 | 0 | pu4_ptr_cmd += 2; |
508 | 0 | sub_command = *pu4_ptr_cmd; |
509 | |
|
510 | 0 | switch(sub_command) |
511 | 0 | { |
512 | 0 | case IVD_CMD_CTL_SETPARAMS: |
513 | 0 | { |
514 | 0 | ihevcd_cxa_ctl_set_config_ip_t *ps_ip; |
515 | 0 | ihevcd_cxa_ctl_set_config_op_t *ps_op; |
516 | 0 | ps_ip = (ihevcd_cxa_ctl_set_config_ip_t *)pv_api_ip; |
517 | 0 | ps_op = (ihevcd_cxa_ctl_set_config_op_t *)pv_api_op; |
518 | |
|
519 | 0 | if(ps_ip->s_ivd_ctl_set_config_ip_t.u4_size |
520 | 0 | != sizeof(ihevcd_cxa_ctl_set_config_ip_t) && |
521 | 0 | ps_ip->s_ivd_ctl_set_config_ip_t.u4_size |
522 | 0 | != sizeof(ivd_ctl_set_config_ip_t)) |
523 | 0 | { |
524 | 0 | ps_op->s_ivd_ctl_set_config_op_t.u4_error_code |= 1 |
525 | 0 | << IVD_UNSUPPORTEDPARAM; |
526 | 0 | ps_op->s_ivd_ctl_set_config_op_t.u4_error_code |= |
527 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
528 | 0 | return IV_FAIL; |
529 | 0 | } |
530 | 0 | } |
531 | | //no break; is needed here |
532 | 0 | case IVD_CMD_CTL_SETDEFAULT: |
533 | 0 | { |
534 | 0 | ihevcd_cxa_ctl_set_config_op_t *ps_op; |
535 | 0 | ps_op = (ihevcd_cxa_ctl_set_config_op_t *)pv_api_op; |
536 | 0 | if(ps_op->s_ivd_ctl_set_config_op_t.u4_size |
537 | 0 | != sizeof(ihevcd_cxa_ctl_set_config_op_t)) |
538 | 0 | { |
539 | 0 | ps_op->s_ivd_ctl_set_config_op_t.u4_error_code |= 1 |
540 | 0 | << IVD_UNSUPPORTEDPARAM; |
541 | 0 | ps_op->s_ivd_ctl_set_config_op_t.u4_error_code |= |
542 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
543 | 0 | return IV_FAIL; |
544 | 0 | } |
545 | 0 | } |
546 | 0 | break; |
547 | | |
548 | 0 | case IVD_CMD_CTL_GETPARAMS: |
549 | 0 | { |
550 | 0 | ihevcd_cxa_ctl_getstatus_ip_t *ps_ip; |
551 | 0 | ihevcd_cxa_ctl_getstatus_op_t *ps_op; |
552 | |
|
553 | 0 | ps_ip = (ihevcd_cxa_ctl_getstatus_ip_t *)pv_api_ip; |
554 | 0 | ps_op = (ihevcd_cxa_ctl_getstatus_op_t *)pv_api_op; |
555 | 0 | if(ps_ip->s_ivd_ctl_getstatus_ip_t.u4_size |
556 | 0 | != sizeof(ihevcd_cxa_ctl_getstatus_ip_t)) |
557 | 0 | { |
558 | 0 | ps_op->s_ivd_ctl_getstatus_op_t.u4_error_code |= 1 |
559 | 0 | << IVD_UNSUPPORTEDPARAM; |
560 | 0 | ps_op->s_ivd_ctl_getstatus_op_t.u4_error_code |= |
561 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
562 | 0 | return IV_FAIL; |
563 | 0 | } |
564 | 0 | if((ps_op->s_ivd_ctl_getstatus_op_t.u4_size |
565 | 0 | != sizeof(ihevcd_cxa_ctl_getstatus_op_t)) && |
566 | 0 | (ps_op->s_ivd_ctl_getstatus_op_t.u4_size |
567 | 0 | != sizeof(ivd_ctl_getstatus_op_t))) |
568 | 0 | { |
569 | 0 | ps_op->s_ivd_ctl_getstatus_op_t.u4_error_code |= 1 |
570 | 0 | << IVD_UNSUPPORTEDPARAM; |
571 | 0 | ps_op->s_ivd_ctl_getstatus_op_t.u4_error_code |= |
572 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
573 | 0 | return IV_FAIL; |
574 | 0 | } |
575 | 0 | } |
576 | 0 | break; |
577 | | |
578 | 0 | case IVD_CMD_CTL_GETBUFINFO: |
579 | 0 | { |
580 | 0 | ihevcd_cxa_ctl_getbufinfo_ip_t *ps_ip; |
581 | 0 | ihevcd_cxa_ctl_getbufinfo_op_t *ps_op; |
582 | 0 | ps_ip = (ihevcd_cxa_ctl_getbufinfo_ip_t *)pv_api_ip; |
583 | 0 | ps_op = (ihevcd_cxa_ctl_getbufinfo_op_t *)pv_api_op; |
584 | |
|
585 | 0 | if(ps_ip->s_ivd_ctl_getbufinfo_ip_t.u4_size |
586 | 0 | != sizeof(ihevcd_cxa_ctl_getbufinfo_ip_t)) |
587 | 0 | { |
588 | 0 | ps_op->s_ivd_ctl_getbufinfo_op_t.u4_error_code |= 1 |
589 | 0 | << IVD_UNSUPPORTEDPARAM; |
590 | 0 | ps_op->s_ivd_ctl_getbufinfo_op_t.u4_error_code |= |
591 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
592 | 0 | return IV_FAIL; |
593 | 0 | } |
594 | 0 | if(ps_op->s_ivd_ctl_getbufinfo_op_t.u4_size |
595 | 0 | != sizeof(ihevcd_cxa_ctl_getbufinfo_op_t)) |
596 | 0 | { |
597 | 0 | ps_op->s_ivd_ctl_getbufinfo_op_t.u4_error_code |= 1 |
598 | 0 | << IVD_UNSUPPORTEDPARAM; |
599 | 0 | ps_op->s_ivd_ctl_getbufinfo_op_t.u4_error_code |= |
600 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
601 | 0 | return IV_FAIL; |
602 | 0 | } |
603 | 0 | } |
604 | 0 | break; |
605 | | |
606 | 0 | case IVD_CMD_CTL_GETVERSION: |
607 | 0 | { |
608 | 0 | ihevcd_cxa_ctl_getversioninfo_ip_t *ps_ip; |
609 | 0 | ihevcd_cxa_ctl_getversioninfo_op_t *ps_op; |
610 | 0 | ps_ip = (ihevcd_cxa_ctl_getversioninfo_ip_t *)pv_api_ip; |
611 | 0 | ps_op = (ihevcd_cxa_ctl_getversioninfo_op_t *)pv_api_op; |
612 | 0 | if(ps_ip->s_ivd_ctl_getversioninfo_ip_t.u4_size |
613 | 0 | != sizeof(ihevcd_cxa_ctl_getversioninfo_ip_t)) |
614 | 0 | { |
615 | 0 | ps_op->s_ivd_ctl_getversioninfo_op_t.u4_error_code |= 1 |
616 | 0 | << IVD_UNSUPPORTEDPARAM; |
617 | 0 | ps_op->s_ivd_ctl_getversioninfo_op_t.u4_error_code |= |
618 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
619 | 0 | return IV_FAIL; |
620 | 0 | } |
621 | 0 | if(ps_op->s_ivd_ctl_getversioninfo_op_t.u4_size |
622 | 0 | != sizeof(ihevcd_cxa_ctl_getversioninfo_op_t)) |
623 | 0 | { |
624 | 0 | ps_op->s_ivd_ctl_getversioninfo_op_t.u4_error_code |= 1 |
625 | 0 | << IVD_UNSUPPORTEDPARAM; |
626 | 0 | ps_op->s_ivd_ctl_getversioninfo_op_t.u4_error_code |= |
627 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
628 | 0 | return IV_FAIL; |
629 | 0 | } |
630 | 0 | } |
631 | 0 | break; |
632 | | |
633 | 0 | case IVD_CMD_CTL_FLUSH: |
634 | 0 | { |
635 | 0 | ihevcd_cxa_ctl_flush_ip_t *ps_ip; |
636 | 0 | ihevcd_cxa_ctl_flush_op_t *ps_op; |
637 | 0 | ps_ip = (ihevcd_cxa_ctl_flush_ip_t *)pv_api_ip; |
638 | 0 | ps_op = (ihevcd_cxa_ctl_flush_op_t *)pv_api_op; |
639 | 0 | if(ps_ip->s_ivd_ctl_flush_ip_t.u4_size |
640 | 0 | != sizeof(ihevcd_cxa_ctl_flush_ip_t)) |
641 | 0 | { |
642 | 0 | ps_op->s_ivd_ctl_flush_op_t.u4_error_code |= 1 |
643 | 0 | << IVD_UNSUPPORTEDPARAM; |
644 | 0 | ps_op->s_ivd_ctl_flush_op_t.u4_error_code |= |
645 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
646 | 0 | return IV_FAIL; |
647 | 0 | } |
648 | 0 | if(ps_op->s_ivd_ctl_flush_op_t.u4_size |
649 | 0 | != sizeof(ihevcd_cxa_ctl_flush_op_t)) |
650 | 0 | { |
651 | 0 | ps_op->s_ivd_ctl_flush_op_t.u4_error_code |= 1 |
652 | 0 | << IVD_UNSUPPORTEDPARAM; |
653 | 0 | ps_op->s_ivd_ctl_flush_op_t.u4_error_code |= |
654 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
655 | 0 | return IV_FAIL; |
656 | 0 | } |
657 | 0 | } |
658 | 0 | break; |
659 | | |
660 | 0 | case IVD_CMD_CTL_RESET: |
661 | 0 | { |
662 | 0 | ihevcd_cxa_ctl_reset_ip_t *ps_ip; |
663 | 0 | ihevcd_cxa_ctl_reset_op_t *ps_op; |
664 | 0 | ps_ip = (ihevcd_cxa_ctl_reset_ip_t *)pv_api_ip; |
665 | 0 | ps_op = (ihevcd_cxa_ctl_reset_op_t *)pv_api_op; |
666 | 0 | if(ps_ip->s_ivd_ctl_reset_ip_t.u4_size |
667 | 0 | != sizeof(ihevcd_cxa_ctl_reset_ip_t)) |
668 | 0 | { |
669 | 0 | ps_op->s_ivd_ctl_reset_op_t.u4_error_code |= 1 |
670 | 0 | << IVD_UNSUPPORTEDPARAM; |
671 | 0 | ps_op->s_ivd_ctl_reset_op_t.u4_error_code |= |
672 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
673 | 0 | return IV_FAIL; |
674 | 0 | } |
675 | 0 | if(ps_op->s_ivd_ctl_reset_op_t.u4_size |
676 | 0 | != sizeof(ihevcd_cxa_ctl_reset_op_t)) |
677 | 0 | { |
678 | 0 | ps_op->s_ivd_ctl_reset_op_t.u4_error_code |= 1 |
679 | 0 | << IVD_UNSUPPORTEDPARAM; |
680 | 0 | ps_op->s_ivd_ctl_reset_op_t.u4_error_code |= |
681 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
682 | 0 | return IV_FAIL; |
683 | 0 | } |
684 | 0 | } |
685 | 0 | break; |
686 | 0 | case IHEVCD_CXA_CMD_CTL_DEGRADE: |
687 | 0 | { |
688 | 0 | ihevcd_cxa_ctl_degrade_ip_t *ps_ip; |
689 | 0 | ihevcd_cxa_ctl_degrade_op_t *ps_op; |
690 | |
|
691 | 0 | ps_ip = (ihevcd_cxa_ctl_degrade_ip_t *)pv_api_ip; |
692 | 0 | ps_op = (ihevcd_cxa_ctl_degrade_op_t *)pv_api_op; |
693 | |
|
694 | 0 | if(ps_ip->u4_size |
695 | 0 | != sizeof(ihevcd_cxa_ctl_degrade_ip_t)) |
696 | 0 | { |
697 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
698 | 0 | ps_op->u4_error_code |= |
699 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
700 | 0 | return IV_FAIL; |
701 | 0 | } |
702 | | |
703 | 0 | if(ps_op->u4_size |
704 | 0 | != sizeof(ihevcd_cxa_ctl_degrade_op_t)) |
705 | 0 | { |
706 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
707 | 0 | ps_op->u4_error_code |= |
708 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
709 | 0 | return IV_FAIL; |
710 | 0 | } |
711 | | |
712 | 0 | if((ps_ip->i4_degrade_pics < 0) || |
713 | 0 | (ps_ip->i4_degrade_pics > 4) || |
714 | 0 | (ps_ip->i4_nondegrade_interval < 0) || |
715 | 0 | (ps_ip->i4_degrade_type < 0) || |
716 | 0 | (ps_ip->i4_degrade_type > 15)) |
717 | 0 | { |
718 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
719 | 0 | return IV_FAIL; |
720 | 0 | } |
721 | | |
722 | 0 | break; |
723 | 0 | } |
724 | | |
725 | 0 | case IHEVCD_CXA_CMD_CTL_GET_BUFFER_DIMENSIONS: |
726 | 0 | { |
727 | 0 | ihevcd_cxa_ctl_get_frame_dimensions_ip_t *ps_ip; |
728 | 0 | ihevcd_cxa_ctl_get_frame_dimensions_op_t *ps_op; |
729 | |
|
730 | 0 | ps_ip = |
731 | 0 | (ihevcd_cxa_ctl_get_frame_dimensions_ip_t *)pv_api_ip; |
732 | 0 | ps_op = |
733 | 0 | (ihevcd_cxa_ctl_get_frame_dimensions_op_t *)pv_api_op; |
734 | |
|
735 | 0 | if(ps_ip->u4_size |
736 | 0 | != sizeof(ihevcd_cxa_ctl_get_frame_dimensions_ip_t)) |
737 | 0 | { |
738 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
739 | 0 | ps_op->u4_error_code |= |
740 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
741 | 0 | return IV_FAIL; |
742 | 0 | } |
743 | | |
744 | 0 | if(ps_op->u4_size |
745 | 0 | != sizeof(ihevcd_cxa_ctl_get_frame_dimensions_op_t)) |
746 | 0 | { |
747 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
748 | 0 | ps_op->u4_error_code |= |
749 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
750 | 0 | return IV_FAIL; |
751 | 0 | } |
752 | | |
753 | 0 | break; |
754 | 0 | } |
755 | | |
756 | 0 | case IHEVCD_CXA_CMD_CTL_GET_VUI_PARAMS: |
757 | 0 | { |
758 | 0 | ihevcd_cxa_ctl_get_vui_params_ip_t *ps_ip; |
759 | 0 | ihevcd_cxa_ctl_get_vui_params_op_t *ps_op; |
760 | |
|
761 | 0 | ps_ip = |
762 | 0 | (ihevcd_cxa_ctl_get_vui_params_ip_t *)pv_api_ip; |
763 | 0 | ps_op = |
764 | 0 | (ihevcd_cxa_ctl_get_vui_params_op_t *)pv_api_op; |
765 | |
|
766 | 0 | if(ps_ip->u4_size |
767 | 0 | != sizeof(ihevcd_cxa_ctl_get_vui_params_ip_t)) |
768 | 0 | { |
769 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
770 | 0 | ps_op->u4_error_code |= |
771 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
772 | 0 | return IV_FAIL; |
773 | 0 | } |
774 | | |
775 | 0 | if(ps_op->u4_size |
776 | 0 | != sizeof(ihevcd_cxa_ctl_get_vui_params_op_t)) |
777 | 0 | { |
778 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
779 | 0 | ps_op->u4_error_code |= |
780 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
781 | 0 | return IV_FAIL; |
782 | 0 | } |
783 | | |
784 | 0 | break; |
785 | 0 | } |
786 | 0 | #ifndef DISABLE_SEI |
787 | 0 | case IHEVCD_CXA_CMD_CTL_GET_SEI_MASTERING_PARAMS: |
788 | 0 | { |
789 | 0 | ihevcd_cxa_ctl_get_sei_mastering_params_ip_t *ps_ip; |
790 | 0 | ihevcd_cxa_ctl_get_sei_mastering_params_op_t *ps_op; |
791 | |
|
792 | 0 | ps_ip = (ihevcd_cxa_ctl_get_sei_mastering_params_ip_t *)pv_api_ip; |
793 | 0 | ps_op = (ihevcd_cxa_ctl_get_sei_mastering_params_op_t *)pv_api_op; |
794 | |
|
795 | 0 | if(ps_ip->u4_size |
796 | 0 | != sizeof(ihevcd_cxa_ctl_get_sei_mastering_params_ip_t)) |
797 | 0 | { |
798 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
799 | 0 | ps_op->u4_error_code |= |
800 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
801 | 0 | return IV_FAIL; |
802 | 0 | } |
803 | | |
804 | 0 | if(ps_op->u4_size |
805 | 0 | != sizeof(ihevcd_cxa_ctl_get_sei_mastering_params_op_t)) |
806 | 0 | { |
807 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
808 | 0 | ps_op->u4_error_code |= |
809 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
810 | 0 | return IV_FAIL; |
811 | 0 | } |
812 | | |
813 | 0 | break; |
814 | 0 | } |
815 | 0 | #endif |
816 | 0 | case IHEVCD_CXA_CMD_CTL_SET_NUM_CORES: |
817 | 0 | { |
818 | 0 | ihevcd_cxa_ctl_set_num_cores_ip_t *ps_ip; |
819 | 0 | ihevcd_cxa_ctl_set_num_cores_op_t *ps_op; |
820 | |
|
821 | 0 | ps_ip = (ihevcd_cxa_ctl_set_num_cores_ip_t *)pv_api_ip; |
822 | 0 | ps_op = (ihevcd_cxa_ctl_set_num_cores_op_t *)pv_api_op; |
823 | |
|
824 | 0 | if(ps_ip->u4_size |
825 | 0 | != sizeof(ihevcd_cxa_ctl_set_num_cores_ip_t)) |
826 | 0 | { |
827 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
828 | 0 | ps_op->u4_error_code |= |
829 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
830 | 0 | return IV_FAIL; |
831 | 0 | } |
832 | | |
833 | 0 | if(ps_op->u4_size |
834 | 0 | != sizeof(ihevcd_cxa_ctl_set_num_cores_op_t)) |
835 | 0 | { |
836 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
837 | 0 | ps_op->u4_error_code |= |
838 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
839 | 0 | return IV_FAIL; |
840 | 0 | } |
841 | | |
842 | 0 | if((ps_ip->u4_num_cores < 1) || (ps_ip->u4_num_cores > MAX_NUM_CORES)) |
843 | 0 | { |
844 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
845 | 0 | return IV_FAIL; |
846 | 0 | } |
847 | 0 | break; |
848 | 0 | } |
849 | 0 | case IHEVCD_CXA_CMD_CTL_SET_PROCESSOR: |
850 | 0 | { |
851 | 0 | ihevcd_cxa_ctl_set_processor_ip_t *ps_ip; |
852 | 0 | ihevcd_cxa_ctl_set_processor_op_t *ps_op; |
853 | |
|
854 | 0 | ps_ip = (ihevcd_cxa_ctl_set_processor_ip_t *)pv_api_ip; |
855 | 0 | ps_op = (ihevcd_cxa_ctl_set_processor_op_t *)pv_api_op; |
856 | |
|
857 | 0 | if(ps_ip->u4_size |
858 | 0 | != sizeof(ihevcd_cxa_ctl_set_processor_ip_t)) |
859 | 0 | { |
860 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
861 | 0 | ps_op->u4_error_code |= |
862 | 0 | IVD_IP_API_STRUCT_SIZE_INCORRECT; |
863 | 0 | return IV_FAIL; |
864 | 0 | } |
865 | | |
866 | 0 | if(ps_op->u4_size |
867 | 0 | != sizeof(ihevcd_cxa_ctl_set_processor_op_t)) |
868 | 0 | { |
869 | 0 | ps_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; |
870 | 0 | ps_op->u4_error_code |= |
871 | 0 | IVD_OP_API_STRUCT_SIZE_INCORRECT; |
872 | 0 | return IV_FAIL; |
873 | 0 | } |
874 | | |
875 | 0 | break; |
876 | 0 | } |
877 | 0 | default: |
878 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
879 | 0 | *(pu4_api_op + 1) |= IVD_UNSUPPORTED_API_CMD; |
880 | 0 | return IV_FAIL; |
881 | 0 | } |
882 | 0 | } |
883 | 0 | break; |
884 | 0 | default: |
885 | 0 | *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; |
886 | 0 | *(pu4_api_op + 1) |= IVD_UNSUPPORTED_API_CMD; |
887 | 0 | return IV_FAIL; |
888 | 0 | } |
889 | | |
890 | 0 | return IV_SUCCESS; |
891 | 0 | } |
892 | | |
893 | | |
894 | | /** |
895 | | ******************************************************************************* |
896 | | * |
897 | | * @brief |
898 | | * Sets default dynamic parameters |
899 | | * |
900 | | * @par Description: |
901 | | * Sets default dynamic parameters. Will be called in ihevcd_init() to ensure |
902 | | * that even if set_params is not called, codec continues to work |
903 | | * |
904 | | * @param[in] ps_codec_obj |
905 | | * Pointer to codec object at API level |
906 | | * |
907 | | * @param[in] pv_api_ip |
908 | | * Pointer to input argument structure |
909 | | * |
910 | | * @param[out] pv_api_op |
911 | | * Pointer to output argument structure |
912 | | * |
913 | | * @returns Status |
914 | | * |
915 | | * @remarks |
916 | | * |
917 | | * |
918 | | ******************************************************************************* |
919 | | */ |
920 | | WORD32 ihevcd_set_default_params(codec_t *ps_codec) |
921 | 0 | { |
922 | |
|
923 | 0 | WORD32 ret = IV_SUCCESS; |
924 | |
|
925 | 0 | ps_codec->e_pic_skip_mode = IVD_SKIP_NONE; |
926 | 0 | ps_codec->i4_strd = 0; |
927 | 0 | ps_codec->i4_disp_strd = 0; |
928 | 0 | ps_codec->i4_header_mode = 0; |
929 | 0 | ps_codec->e_pic_out_order = IVD_DISPLAY_FRAME_OUT; |
930 | 0 | return ret; |
931 | 0 | } |
932 | | |
933 | | void ihevcd_update_function_ptr(codec_t *ps_codec) |
934 | 0 | { |
935 | | |
936 | | /* Init inter pred function array */ |
937 | 0 | ps_codec->apf_inter_pred[0] = NULL; |
938 | 0 | ps_codec->apf_inter_pred[1] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_copy_fptr; |
939 | 0 | ps_codec->apf_inter_pred[2] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_vert_fptr; |
940 | 0 | ps_codec->apf_inter_pred[3] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_horz_fptr; |
941 | 0 | ps_codec->apf_inter_pred[4] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_horz_w16out_fptr; |
942 | 0 | ps_codec->apf_inter_pred[5] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_copy_w16out_fptr; |
943 | 0 | ps_codec->apf_inter_pred[6] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_vert_w16out_fptr; |
944 | 0 | ps_codec->apf_inter_pred[7] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_horz_w16out_fptr; |
945 | 0 | ps_codec->apf_inter_pred[8] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_horz_w16out_fptr; |
946 | 0 | ps_codec->apf_inter_pred[9] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_vert_w16inp_fptr; |
947 | 0 | ps_codec->apf_inter_pred[10] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_luma_vert_w16inp_w16out_fptr; |
948 | 0 | ps_codec->apf_inter_pred[11] = NULL; |
949 | 0 | ps_codec->apf_inter_pred[12] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_copy_fptr; |
950 | 0 | ps_codec->apf_inter_pred[13] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_vert_fptr; |
951 | 0 | ps_codec->apf_inter_pred[14] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_horz_fptr; |
952 | 0 | ps_codec->apf_inter_pred[15] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_horz_w16out_fptr; |
953 | 0 | ps_codec->apf_inter_pred[16] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_copy_w16out_fptr; |
954 | 0 | ps_codec->apf_inter_pred[17] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_vert_w16out_fptr; |
955 | 0 | ps_codec->apf_inter_pred[18] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_horz_w16out_fptr; |
956 | 0 | ps_codec->apf_inter_pred[19] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_horz_w16out_fptr; |
957 | 0 | ps_codec->apf_inter_pred[20] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_vert_w16inp_fptr; |
958 | 0 | ps_codec->apf_inter_pred[21] = (pf_inter_pred)ps_codec->s_func_selector.ihevc_inter_pred_chroma_vert_w16inp_w16out_fptr; |
959 | | |
960 | | /* Init intra pred function array */ |
961 | 0 | ps_codec->apf_intra_pred_luma[0] = (pf_intra_pred)NULL; |
962 | 0 | ps_codec->apf_intra_pred_luma[1] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_planar_fptr; |
963 | 0 | ps_codec->apf_intra_pred_luma[2] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_dc_fptr; |
964 | 0 | ps_codec->apf_intra_pred_luma[3] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode2_fptr; |
965 | 0 | ps_codec->apf_intra_pred_luma[4] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode_3_to_9_fptr; |
966 | 0 | ps_codec->apf_intra_pred_luma[5] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_horz_fptr; |
967 | 0 | ps_codec->apf_intra_pred_luma[6] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode_11_to_17_fptr; |
968 | 0 | ps_codec->apf_intra_pred_luma[7] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode_18_34_fptr; |
969 | 0 | ps_codec->apf_intra_pred_luma[8] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode_19_to_25_fptr; |
970 | 0 | ps_codec->apf_intra_pred_luma[9] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_ver_fptr; |
971 | 0 | ps_codec->apf_intra_pred_luma[10] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_luma_mode_27_to_33_fptr; |
972 | |
|
973 | 0 | ps_codec->apf_intra_pred_chroma[0] = (pf_intra_pred)NULL; |
974 | 0 | ps_codec->apf_intra_pred_chroma[1] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_planar_fptr; |
975 | 0 | ps_codec->apf_intra_pred_chroma[2] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_dc_fptr; |
976 | 0 | ps_codec->apf_intra_pred_chroma[3] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode2_fptr; |
977 | 0 | ps_codec->apf_intra_pred_chroma[4] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode_3_to_9_fptr; |
978 | 0 | ps_codec->apf_intra_pred_chroma[5] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_horz_fptr; |
979 | 0 | ps_codec->apf_intra_pred_chroma[6] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode_11_to_17_fptr; |
980 | 0 | ps_codec->apf_intra_pred_chroma[7] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode_18_34_fptr; |
981 | 0 | ps_codec->apf_intra_pred_chroma[8] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode_19_to_25_fptr; |
982 | 0 | ps_codec->apf_intra_pred_chroma[9] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_ver_fptr; |
983 | 0 | ps_codec->apf_intra_pred_chroma[10] = (pf_intra_pred)ps_codec->s_func_selector.ihevc_intra_pred_chroma_mode_27_to_33_fptr; |
984 | | |
985 | | /* Init itrans res function array */ |
986 | 0 | ps_codec->apf_itrans_res[0] = (pf_itrans_res)ps_codec->s_func_selector.ihevc_itrans_res_4x4_ttype1_fptr; |
987 | 0 | ps_codec->apf_itrans_res[1] = (pf_itrans_res)ps_codec->s_func_selector.ihevc_itrans_res_4x4_fptr; |
988 | 0 | ps_codec->apf_itrans_res[2] = (pf_itrans_res)ps_codec->s_func_selector.ihevc_itrans_res_8x8_fptr; |
989 | 0 | ps_codec->apf_itrans_res[3] = (pf_itrans_res)ps_codec->s_func_selector.ihevc_itrans_res_16x16_fptr; |
990 | 0 | ps_codec->apf_itrans_res[4] = (pf_itrans_res)ps_codec->s_func_selector.ihevc_itrans_res_32x32_fptr; |
991 | | |
992 | | /* Init itrans_recon function array */ |
993 | 0 | ps_codec->apf_itrans_recon[0] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_itrans_recon_4x4_ttype1_fptr; |
994 | 0 | ps_codec->apf_itrans_recon[1] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_itrans_recon_4x4_fptr; |
995 | 0 | ps_codec->apf_itrans_recon[2] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_itrans_recon_8x8_fptr; |
996 | 0 | ps_codec->apf_itrans_recon[3] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_itrans_recon_16x16_fptr; |
997 | 0 | ps_codec->apf_itrans_recon[4] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_itrans_recon_32x32_fptr; |
998 | 0 | ps_codec->apf_itrans_recon[5] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_chroma_itrans_recon_4x4_fptr; |
999 | 0 | ps_codec->apf_itrans_recon[6] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_chroma_itrans_recon_8x8_fptr; |
1000 | 0 | ps_codec->apf_itrans_recon[7] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_chroma_itrans_recon_16x16_fptr; |
1001 | 0 | ps_codec->apf_itrans_recon[8] = (pf_itrans_recon)ps_codec->s_func_selector.ihevc_chroma_itrans_recon_32x32_fptr; |
1002 | | |
1003 | | /* Init recon function array */ |
1004 | 0 | ps_codec->apf_recon[0] = (pf_recon)ps_codec->s_func_selector.ihevc_recon_4x4_ttype1_fptr; |
1005 | 0 | ps_codec->apf_recon[1] = (pf_recon)ps_codec->s_func_selector.ihevc_recon_4x4_fptr; |
1006 | 0 | ps_codec->apf_recon[2] = (pf_recon)ps_codec->s_func_selector.ihevc_recon_8x8_fptr; |
1007 | 0 | ps_codec->apf_recon[3] = (pf_recon)ps_codec->s_func_selector.ihevc_recon_16x16_fptr; |
1008 | 0 | ps_codec->apf_recon[4] = (pf_recon)ps_codec->s_func_selector.ihevc_recon_32x32_fptr; |
1009 | 0 | ps_codec->apf_recon[5] = (pf_recon)ps_codec->s_func_selector.ihevc_chroma_recon_4x4_fptr; |
1010 | 0 | ps_codec->apf_recon[6] = (pf_recon)ps_codec->s_func_selector.ihevc_chroma_recon_8x8_fptr; |
1011 | 0 | ps_codec->apf_recon[7] = (pf_recon)ps_codec->s_func_selector.ihevc_chroma_recon_16x16_fptr; |
1012 | 0 | ps_codec->apf_recon[8] = (pf_recon)ps_codec->s_func_selector.ihevc_chroma_recon_32x32_fptr; |
1013 | | |
1014 | | /* Init itrans_recon_dc function array */ |
1015 | 0 | ps_codec->apf_itrans_recon_dc[0] = (pf_itrans_recon_dc)ps_codec->s_func_selector.ihevcd_itrans_recon_dc_luma_fptr; |
1016 | 0 | ps_codec->apf_itrans_recon_dc[1] = (pf_itrans_recon_dc)ps_codec->s_func_selector.ihevcd_itrans_recon_dc_chroma_fptr; |
1017 | |
|
1018 | 0 | ps_codec->apf_itrans_res_dc = (pf_itrans_res_dc)ps_codec->s_func_selector.ihevc_itrans_res_dc_fptr; |
1019 | | |
1020 | | /* Init sao function array */ |
1021 | 0 | ps_codec->apf_sao_luma[0] = (pf_sao_luma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class0_fptr; |
1022 | 0 | ps_codec->apf_sao_luma[1] = (pf_sao_luma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class1_fptr; |
1023 | 0 | ps_codec->apf_sao_luma[2] = (pf_sao_luma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class2_fptr; |
1024 | 0 | ps_codec->apf_sao_luma[3] = (pf_sao_luma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class3_fptr; |
1025 | |
|
1026 | 0 | ps_codec->apf_sao_chroma[0] = (pf_sao_chroma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class0_chroma_fptr; |
1027 | 0 | ps_codec->apf_sao_chroma[1] = (pf_sao_chroma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class1_chroma_fptr; |
1028 | 0 | ps_codec->apf_sao_chroma[2] = (pf_sao_chroma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class2_chroma_fptr; |
1029 | 0 | ps_codec->apf_sao_chroma[3] = (pf_sao_chroma)ps_codec->s_func_selector.ihevc_sao_edge_offset_class3_chroma_fptr; |
1030 | 0 | } |
1031 | | /** |
1032 | | ******************************************************************************* |
1033 | | * |
1034 | | * @brief |
1035 | | * Initialize the context. This will be called by create and during |
1036 | | * reset |
1037 | | * |
1038 | | * @par Description: |
1039 | | * Initializes the context |
1040 | | * |
1041 | | * @param[in] ps_codec |
1042 | | * Codec context pointer |
1043 | | * |
1044 | | * @returns Status |
1045 | | * |
1046 | | * @remarks |
1047 | | * |
1048 | | * |
1049 | | ******************************************************************************* |
1050 | | */ |
1051 | | WORD32 ihevcd_init(codec_t *ps_codec) |
1052 | 0 | { |
1053 | 0 | WORD32 status = IV_SUCCESS; |
1054 | 0 | WORD32 i; |
1055 | | |
1056 | | /* Free any dynamic buffers that are allocated */ |
1057 | 0 | ihevcd_free_dynamic_bufs(ps_codec); |
1058 | |
|
1059 | 0 | ps_codec->u4_allocate_dynamic_done = 0; |
1060 | 0 | ps_codec->i4_num_disp_bufs = 1; |
1061 | 0 | ps_codec->i4_flush_mode = 0; |
1062 | |
|
1063 | 0 | ps_codec->i4_ht = ps_codec->i4_disp_ht = 0; |
1064 | 0 | ps_codec->i4_wd = ps_codec->i4_disp_wd = 0; |
1065 | 0 | ps_codec->i4_strd = 0; |
1066 | 0 | ps_codec->i4_disp_strd = 0; |
1067 | 0 | ps_codec->i4_num_cores = 1; |
1068 | |
|
1069 | 0 | ps_codec->u4_pic_cnt = 0; |
1070 | 0 | ps_codec->u4_disp_cnt = 0; |
1071 | |
|
1072 | 0 | ps_codec->i4_header_mode = 0; |
1073 | 0 | ps_codec->i4_header_in_slice_mode = 0; |
1074 | 0 | ps_codec->i4_sps_done = 0; |
1075 | 0 | ps_codec->i4_pps_done = 0; |
1076 | 0 | ps_codec->i4_init_done = 1; |
1077 | 0 | ps_codec->i4_first_pic_done = 0; |
1078 | 0 | ps_codec->s_parse.i4_first_pic_init = 0; |
1079 | 0 | ps_codec->i4_error_code = 0; |
1080 | 0 | ps_codec->i4_reset_flag = 0; |
1081 | 0 | ps_codec->i4_cra_as_first_pic = 1; |
1082 | 0 | ps_codec->i4_rasl_output_flag = 0; |
1083 | |
|
1084 | 0 | ps_codec->i4_prev_poc_msb = 0; |
1085 | 0 | ps_codec->i4_prev_poc_lsb = -1; |
1086 | 0 | ps_codec->i4_max_prev_poc_lsb = -1; |
1087 | 0 | ps_codec->s_parse.i4_abs_pic_order_cnt = -1; |
1088 | | |
1089 | | /* Set ref chroma format by default to 420SP UV interleaved */ |
1090 | 0 | ps_codec->e_ref_chroma_fmt = IV_YUV_420SP_UV; |
1091 | | |
1092 | | /* If the codec is in shared mode and required format is 420 SP VU interleaved then change |
1093 | | * reference buffers chroma format |
1094 | | */ |
1095 | 0 | if(IV_YUV_420SP_VU == ps_codec->e_chroma_fmt) |
1096 | 0 | { |
1097 | 0 | ps_codec->e_ref_chroma_fmt = IV_YUV_420SP_VU; |
1098 | 0 | } |
1099 | | |
1100 | | |
1101 | |
|
1102 | 0 | ps_codec->i4_disable_deblk_pic = 0; |
1103 | |
|
1104 | 0 | ps_codec->i4_degrade_pic_cnt = 0; |
1105 | 0 | ps_codec->i4_degrade_pics = 0; |
1106 | 0 | ps_codec->i4_degrade_type = 0; |
1107 | 0 | ps_codec->i4_disable_sao_pic = 0; |
1108 | 0 | ps_codec->i4_fullpel_inter_pred = 0; |
1109 | 0 | ps_codec->u4_enable_fmt_conv_ahead = 0; |
1110 | 0 | ps_codec->i4_share_disp_buf_cnt = 0; |
1111 | |
|
1112 | 0 | { |
1113 | 0 | sps_t *ps_sps = ps_codec->ps_sps_base; |
1114 | 0 | pps_t *ps_pps = ps_codec->ps_pps_base; |
1115 | |
|
1116 | 0 | for(i = 0; i < MAX_SPS_CNT; i++) |
1117 | 0 | { |
1118 | 0 | ps_sps->i1_sps_valid = 0; |
1119 | 0 | ps_sps++; |
1120 | 0 | } |
1121 | |
|
1122 | 0 | for(i = 0; i < MAX_PPS_CNT; i++) |
1123 | 0 | { |
1124 | 0 | ps_pps->i1_pps_valid = 0; |
1125 | 0 | ps_pps++; |
1126 | 0 | } |
1127 | 0 | } |
1128 | |
|
1129 | 0 | ihevcd_set_default_params(ps_codec); |
1130 | | /* Initialize MV Bank buffer manager */ |
1131 | 0 | ihevc_buf_mgr_init((buf_mgr_t *)ps_codec->pv_mv_buf_mgr); |
1132 | | |
1133 | | /* Initialize Picture buffer manager */ |
1134 | 0 | ihevc_buf_mgr_init((buf_mgr_t *)ps_codec->pv_pic_buf_mgr); |
1135 | |
|
1136 | 0 | ps_codec->ps_pic_buf = (pic_buf_t *)ps_codec->pv_pic_buf_base; |
1137 | |
|
1138 | 0 | memset(ps_codec->ps_pic_buf, 0, BUF_MGR_MAX_CNT * sizeof(pic_buf_t)); |
1139 | | |
1140 | | |
1141 | | |
1142 | | /* Initialize display buffer manager */ |
1143 | 0 | ihevc_disp_mgr_init((disp_mgr_t *)ps_codec->pv_disp_buf_mgr); |
1144 | | |
1145 | | /* Initialize dpb manager */ |
1146 | 0 | ihevc_dpb_mgr_init((dpb_mgr_t *)ps_codec->pv_dpb_mgr); |
1147 | |
|
1148 | 0 | ps_codec->e_processor_soc = SOC_GENERIC; |
1149 | | /* The following can be over-ridden using soc parameter as a hack */ |
1150 | 0 | ps_codec->u4_nctb = 0x7FFFFFFF; |
1151 | 0 | ihevcd_init_arch(ps_codec); |
1152 | |
|
1153 | 0 | ihevcd_init_function_ptr(ps_codec); |
1154 | |
|
1155 | 0 | ihevcd_update_function_ptr(ps_codec); |
1156 | |
|
1157 | 0 | return status; |
1158 | 0 | } |
1159 | | |
1160 | | /** |
1161 | | ******************************************************************************* |
1162 | | * |
1163 | | * @brief |
1164 | | * Allocate static memory for the codec |
1165 | | * |
1166 | | * @par Description: |
1167 | | * Allocates static memory for the codec |
1168 | | * |
1169 | | * @param[in] pv_api_ip |
1170 | | * Pointer to input argument structure |
1171 | | * |
1172 | | * @param[out] pv_api_op |
1173 | | * Pointer to output argument structure |
1174 | | * |
1175 | | * @returns Status |
1176 | | * |
1177 | | * @remarks |
1178 | | * |
1179 | | * |
1180 | | ******************************************************************************* |
1181 | | */ |
1182 | | WORD32 ihevcd_allocate_static_bufs(iv_obj_t **pps_codec_obj, |
1183 | | ihevcd_cxa_create_ip_t *ps_create_ip, |
1184 | | ihevcd_cxa_create_op_t *ps_create_op) |
1185 | 0 | { |
1186 | 0 | WORD32 size; |
1187 | 0 | void *pv_buf; |
1188 | 0 | UWORD8 *pu1_buf; |
1189 | 0 | WORD32 i; |
1190 | 0 | codec_t *ps_codec; |
1191 | 0 | IV_API_CALL_STATUS_T status = IV_SUCCESS; |
1192 | 0 | void *(*pf_aligned_alloc)(void *pv_mem_ctxt, WORD32 alignment, WORD32 size); |
1193 | 0 | void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf); |
1194 | 0 | void *pv_mem_ctxt; |
1195 | | |
1196 | | /* Request memory for HEVCD object */ |
1197 | 0 | ps_create_op->s_ivd_create_op_t.pv_handle = NULL; |
1198 | |
|
1199 | 0 | pf_aligned_alloc = ps_create_ip->s_ivd_create_ip_t.pf_aligned_alloc; |
1200 | 0 | pf_aligned_free = ps_create_ip->s_ivd_create_ip_t.pf_aligned_free; |
1201 | 0 | pv_mem_ctxt = ps_create_ip->s_ivd_create_ip_t.pv_mem_ctxt; |
1202 | | |
1203 | |
|
1204 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, sizeof(iv_obj_t)); |
1205 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1206 | 0 | memset(pv_buf, 0, sizeof(iv_obj_t)); |
1207 | 0 | *pps_codec_obj = (iv_obj_t *)pv_buf; |
1208 | 0 | ps_create_op->s_ivd_create_op_t.pv_handle = *pps_codec_obj; |
1209 | | |
1210 | |
|
1211 | 0 | (*pps_codec_obj)->pv_codec_handle = NULL; |
1212 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, sizeof(codec_t)); |
1213 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1214 | 0 | (*pps_codec_obj)->pv_codec_handle = (codec_t *)pv_buf; |
1215 | 0 | ps_codec = (codec_t *)pv_buf; |
1216 | |
|
1217 | 0 | memset(ps_codec, 0, sizeof(codec_t)); |
1218 | |
|
1219 | 0 | #ifndef LOGO_EN |
1220 | 0 | ps_codec->i4_share_disp_buf = ps_create_ip->s_ivd_create_ip_t.u4_share_disp_buf; |
1221 | | #else |
1222 | | ps_codec->i4_share_disp_buf = 0; |
1223 | | #endif |
1224 | | |
1225 | | /* Shared display mode is supported only for 420SP and 420P formats */ |
1226 | 0 | if((ps_create_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420P) && |
1227 | 0 | (ps_create_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420SP_UV) && |
1228 | 0 | (ps_create_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420SP_VU)) |
1229 | 0 | { |
1230 | 0 | ps_codec->i4_share_disp_buf = 0; |
1231 | 0 | } |
1232 | |
|
1233 | 0 | if (ps_create_ip->s_ivd_create_ip_t.u4_size == sizeof(ihevcd_cxa_create_ip_t)) |
1234 | 0 | { |
1235 | 0 | ps_codec->u1_enable_cu_info = ps_create_ip->u4_enable_frame_info; |
1236 | 0 | } |
1237 | |
|
1238 | 0 | ps_codec->e_chroma_fmt = ps_create_ip->s_ivd_create_ip_t.e_output_format; |
1239 | |
|
1240 | 0 | ps_codec->pf_aligned_alloc = pf_aligned_alloc; |
1241 | 0 | ps_codec->pf_aligned_free = pf_aligned_free; |
1242 | 0 | ps_codec->pv_mem_ctxt = pv_mem_ctxt; |
1243 | 0 | ps_codec->i4_threads_active = ps_create_ip->u4_keep_threads_active; |
1244 | | |
1245 | | /* Request memory to hold thread handles for each processing thread */ |
1246 | 0 | size = MAX_PROCESS_THREADS * ithread_get_handle_size(); |
1247 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1248 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1249 | 0 | memset(pv_buf, 0, size); |
1250 | |
|
1251 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1252 | 0 | { |
1253 | 0 | WORD32 handle_size = ithread_get_handle_size(); |
1254 | 0 | ps_codec->apv_process_thread_handle[i] = |
1255 | 0 | (UWORD8 *)pv_buf + (i * handle_size); |
1256 | 0 | } |
1257 | |
|
1258 | 0 | if(ps_codec->i4_threads_active) |
1259 | 0 | { |
1260 | | /* Request memory to hold mutex (start/done) for each processing thread */ |
1261 | 0 | size = 2 * MAX_PROCESS_THREADS * ithread_get_mutex_lock_size(); |
1262 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1263 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1264 | 0 | memset(pv_buf, 0, size); |
1265 | |
|
1266 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1267 | 0 | { |
1268 | 0 | WORD32 ret; |
1269 | 0 | WORD32 mutex_size = ithread_get_mutex_lock_size(); |
1270 | 0 | ps_codec->apv_proc_start_mutex[i] = |
1271 | 0 | (UWORD8 *)pv_buf + (2 * i * mutex_size); |
1272 | 0 | ps_codec->apv_proc_done_mutex[i] = |
1273 | 0 | (UWORD8 *)pv_buf + ((2 * i + 1) * mutex_size); |
1274 | |
|
1275 | 0 | ret = ithread_mutex_init(ps_codec->apv_proc_start_mutex[i]); |
1276 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1277 | |
|
1278 | 0 | ret = ithread_mutex_init(ps_codec->apv_proc_done_mutex[i]); |
1279 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1280 | 0 | } |
1281 | | |
1282 | 0 | size = 2 * MAX_PROCESS_THREADS * ithread_get_cond_struct_size(); |
1283 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1284 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1285 | 0 | memset(pv_buf, 0, size); |
1286 | |
|
1287 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1288 | 0 | { |
1289 | 0 | WORD32 ret; |
1290 | 0 | WORD32 cond_size = ithread_get_cond_struct_size(); |
1291 | 0 | ps_codec->apv_proc_start_condition[i] = |
1292 | 0 | (UWORD8 *)pv_buf + (2 * i * cond_size); |
1293 | 0 | ps_codec->apv_proc_done_condition[i] = |
1294 | 0 | (UWORD8 *)pv_buf + ((2 * i + 1) * cond_size); |
1295 | |
|
1296 | 0 | ret = ithread_cond_init(ps_codec->apv_proc_start_condition[i]); |
1297 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1298 | |
|
1299 | 0 | ret = ithread_cond_init(ps_codec->apv_proc_done_condition[i]); |
1300 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1301 | 0 | } |
1302 | 0 | } |
1303 | | |
1304 | | /* Request memory for static bitstream buffer which holds bitstream after emulation prevention */ |
1305 | 0 | size = MIN_BITSBUF_SIZE; |
1306 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size + 16); //Alloc extra for parse optimization |
1307 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1308 | 0 | memset(pv_buf, 0, size + 16); |
1309 | 0 | ps_codec->pu1_bitsbuf_static = pv_buf; |
1310 | 0 | ps_codec->u4_bitsbuf_size_static = size; |
1311 | | |
1312 | | /* size for holding display manager context */ |
1313 | 0 | size = sizeof(buf_mgr_t); |
1314 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1315 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1316 | 0 | memset(pv_buf, 0, size); |
1317 | 0 | ps_codec->pv_disp_buf_mgr = pv_buf; |
1318 | | |
1319 | | /* size for holding dpb manager context */ |
1320 | 0 | size = sizeof(dpb_mgr_t); |
1321 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1322 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1323 | 0 | memset(pv_buf, 0, size); |
1324 | 0 | ps_codec->pv_dpb_mgr = pv_buf; |
1325 | | |
1326 | | /* size for holding buffer manager context */ |
1327 | 0 | size = sizeof(buf_mgr_t); |
1328 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1329 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1330 | 0 | memset(pv_buf, 0, size); |
1331 | 0 | ps_codec->pv_pic_buf_mgr = pv_buf; |
1332 | | |
1333 | | /* size for holding mv buffer manager context */ |
1334 | 0 | size = sizeof(buf_mgr_t); |
1335 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1336 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1337 | 0 | memset(pv_buf, 0, size); |
1338 | 0 | ps_codec->pv_mv_buf_mgr = pv_buf; |
1339 | |
|
1340 | 0 | size = MAX_VPS_CNT * sizeof(vps_t); |
1341 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1342 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1343 | 0 | memset(pv_buf, 0, size); |
1344 | 0 | ps_codec->ps_vps_base = pv_buf; |
1345 | 0 | ps_codec->s_parse.ps_vps_base = ps_codec->ps_vps_base; |
1346 | |
|
1347 | 0 | size = MAX_SPS_CNT * sizeof(sps_t); |
1348 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1349 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1350 | 0 | memset(pv_buf, 0, size); |
1351 | 0 | ps_codec->ps_sps_base = pv_buf; |
1352 | 0 | ps_codec->s_parse.ps_sps_base = ps_codec->ps_sps_base; |
1353 | |
|
1354 | 0 | size = MAX_PPS_CNT * sizeof(pps_t); |
1355 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1356 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1357 | 0 | memset(pv_buf, 0, size); |
1358 | 0 | ps_codec->ps_pps_base = pv_buf; |
1359 | 0 | ps_codec->s_parse.ps_pps_base = ps_codec->ps_pps_base; |
1360 | |
|
1361 | 0 | size = MAX_SLICE_HDR_CNT * sizeof(slice_header_t); |
1362 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1363 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1364 | 0 | memset(pv_buf, 0, size); |
1365 | 0 | ps_codec->ps_slice_hdr_base = (slice_header_t *)pv_buf; |
1366 | 0 | ps_codec->s_parse.ps_slice_hdr_base = ps_codec->ps_slice_hdr_base; |
1367 | | |
1368 | |
|
1369 | 0 | SCALING_MAT_SIZE(size) |
1370 | 0 | size = (MAX_SPS_CNT + MAX_PPS_CNT) * size * sizeof(WORD16); |
1371 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1372 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1373 | 0 | memset(pv_buf, 0, size); |
1374 | 0 | ps_codec->pi2_scaling_mat = (WORD16 *)pv_buf; |
1375 | | |
1376 | | |
1377 | | /* Size for holding pic_buf_t for each reference picture |
1378 | | * Since this is only a structure allocation and not actual buffer allocation, |
1379 | | * it is allocated for BUF_MGR_MAX_CNT entries |
1380 | | */ |
1381 | 0 | size = BUF_MGR_MAX_CNT * sizeof(pic_buf_t); |
1382 | 0 | pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1383 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1384 | 0 | memset(pv_buf, 0, size); |
1385 | 0 | ps_codec->pv_pic_buf_base = (UWORD8 *)pv_buf; |
1386 | | |
1387 | | /* TO hold scratch buffers needed for each SAO context */ |
1388 | 0 | size = 4 * MAX_CTB_SIZE * MAX_CTB_SIZE + 8 * MAX_CTB_SIZE * MAX_CTB_SIZE; |
1389 | |
|
1390 | 0 | size *= MAX_PROCESS_THREADS; |
1391 | |
|
1392 | 0 | pu1_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1393 | 0 | RETURN_IF((NULL == pu1_buf), IV_FAIL); |
1394 | 0 | memset(pu1_buf, 0, size); |
1395 | |
|
1396 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1397 | 0 | { |
1398 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_tmp_buf_luma = (UWORD8 *)pu1_buf; |
1399 | 0 | pu1_buf += 4 * MAX_CTB_SIZE * MAX_CTB_SIZE * sizeof(UWORD8); |
1400 | |
|
1401 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_tmp_buf_chroma = (UWORD8 *)pu1_buf; |
1402 | 0 | pu1_buf += 8 * MAX_CTB_SIZE * MAX_CTB_SIZE * sizeof(UWORD8); |
1403 | 0 | } |
1404 | | |
1405 | | /* Allocate intra pred modes buffer */ |
1406 | | /* 8 bits per 4x4 */ |
1407 | | /* 16 bytes each for top and left 64 pixels and 16 bytes for default mode */ |
1408 | 0 | size = 3 * 16 * sizeof(UWORD8); |
1409 | 0 | pu1_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1410 | 0 | RETURN_IF((NULL == pu1_buf), IV_FAIL); |
1411 | 0 | memset(pu1_buf, 0, size); |
1412 | 0 | ps_codec->s_parse.pu1_luma_intra_pred_mode_left = pu1_buf; |
1413 | 0 | ps_codec->s_parse.pu1_luma_intra_pred_mode_top = pu1_buf + 16; |
1414 | |
|
1415 | 0 | { |
1416 | 0 | WORD32 inter_pred_tmp_buf_size, ntaps_luma; |
1417 | 0 | #ifdef ENABLE_MAIN_REXT_PROFILE |
1418 | 0 | WORD32 res_buf_size; |
1419 | 0 | #endif |
1420 | 0 | WORD32 pic_pu_idx_map_size; |
1421 | | |
1422 | | /* Max inter pred size */ |
1423 | 0 | ntaps_luma = 8; |
1424 | | // For yuv 4:4:4 chroma the inter pred buffer size for one CTB will be double of luma |
1425 | 0 | inter_pred_tmp_buf_size = sizeof(WORD16) * (MAX_CTB_SIZE + ntaps_luma) * MAX_CTB_SIZE * 2; |
1426 | |
|
1427 | 0 | inter_pred_tmp_buf_size = ALIGN64(inter_pred_tmp_buf_size); |
1428 | |
|
1429 | 0 | #ifdef ENABLE_MAIN_REXT_PROFILE |
1430 | 0 | res_buf_size = sizeof(WORD16) * (MAX_TU_SIZE * MAX_TU_SIZE); |
1431 | 0 | res_buf_size = ALIGN64(res_buf_size); |
1432 | 0 | #endif |
1433 | | |
1434 | | /* To hold pu_index w.r.t. frame level pu_t array for a CTB */ |
1435 | 0 | pic_pu_idx_map_size = sizeof(WORD32) * (18 * 18); |
1436 | 0 | pic_pu_idx_map_size = ALIGN64(pic_pu_idx_map_size); |
1437 | |
|
1438 | 0 | size = inter_pred_tmp_buf_size * 2; |
1439 | 0 | #ifdef ENABLE_MAIN_REXT_PROFILE |
1440 | 0 | size += (res_buf_size * 4); |
1441 | 0 | #endif |
1442 | 0 | size += pic_pu_idx_map_size; |
1443 | 0 | size *= MAX_PROCESS_THREADS; |
1444 | |
|
1445 | 0 | pu1_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1446 | 0 | RETURN_IF((NULL == pu1_buf), IV_FAIL); |
1447 | 0 | memset(pu1_buf, 0, size); |
1448 | |
|
1449 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1450 | 0 | { |
1451 | 0 | ps_codec->as_process[i].pi2_inter_pred_tmp_buf1 = (WORD16 *)pu1_buf; |
1452 | 0 | pu1_buf += inter_pred_tmp_buf_size; |
1453 | |
|
1454 | 0 | ps_codec->as_process[i].pi2_inter_pred_tmp_buf2 = (WORD16 *)pu1_buf; |
1455 | 0 | pu1_buf += inter_pred_tmp_buf_size; |
1456 | |
|
1457 | 0 | #ifdef ENABLE_MAIN_REXT_PROFILE |
1458 | 0 | ps_codec->as_process[i].pi2_res_luma_buf = (WORD16 *)pu1_buf; |
1459 | 0 | pu1_buf += res_buf_size; |
1460 | |
|
1461 | 0 | ps_codec->as_process[i].pi2_res_chroma_buf = (WORD16 *)pu1_buf; |
1462 | 0 | pu1_buf += res_buf_size; |
1463 | |
|
1464 | 0 | ps_codec->as_process[i].pi2_invscan_out_subtu = (WORD16 *)pu1_buf; |
1465 | 0 | pu1_buf += (res_buf_size * 2); |
1466 | 0 | #endif |
1467 | | |
1468 | | /* Inverse transform intermediate and inverse scan output buffers reuse inter pred scratch buffers */ |
1469 | 0 | ps_codec->as_process[i].pi2_itrans_intrmd_buf = |
1470 | 0 | ps_codec->as_process[i].pi2_inter_pred_tmp_buf2; |
1471 | 0 | ps_codec->as_process[i].pi2_invscan_out = |
1472 | 0 | ps_codec->as_process[i].pi2_inter_pred_tmp_buf1; |
1473 | |
|
1474 | 0 | ps_codec->as_process[i].pu4_pic_pu_idx_map = (UWORD32 *)pu1_buf; |
1475 | 0 | ps_codec->as_process[i].s_bs_ctxt.pu4_pic_pu_idx_map = |
1476 | 0 | (UWORD32 *)pu1_buf; |
1477 | 0 | pu1_buf += pic_pu_idx_map_size; |
1478 | | |
1479 | | // ps_codec->as_process[i].pi2_inter_pred_tmp_buf3 = (WORD16 *)pu1_buf; |
1480 | | // pu1_buf += inter_pred_tmp_buf_size; |
1481 | |
|
1482 | 0 | ps_codec->as_process[i].i4_inter_pred_tmp_buf_strd = MAX_CTB_SIZE; |
1483 | |
|
1484 | 0 | } |
1485 | 0 | } |
1486 | | /* Initialize pointers in PPS structures */ |
1487 | 0 | { |
1488 | 0 | sps_t *ps_sps = ps_codec->ps_sps_base; |
1489 | 0 | pps_t *ps_pps = ps_codec->ps_pps_base; |
1490 | 0 | WORD16 *pi2_scaling_mat = ps_codec->pi2_scaling_mat; |
1491 | 0 | WORD32 scaling_mat_size; |
1492 | |
|
1493 | 0 | SCALING_MAT_SIZE(scaling_mat_size); |
1494 | |
|
1495 | 0 | for(i = 0; i < MAX_SPS_CNT; i++) |
1496 | 0 | { |
1497 | 0 | ps_sps->pi2_scaling_mat = pi2_scaling_mat; |
1498 | 0 | pi2_scaling_mat += scaling_mat_size; |
1499 | 0 | ps_sps++; |
1500 | 0 | } |
1501 | |
|
1502 | 0 | for(i = 0; i < MAX_PPS_CNT; i++) |
1503 | 0 | { |
1504 | 0 | ps_pps->pi2_scaling_mat = pi2_scaling_mat; |
1505 | 0 | pi2_scaling_mat += scaling_mat_size; |
1506 | 0 | ps_pps++; |
1507 | 0 | } |
1508 | 0 | } |
1509 | |
|
1510 | 0 | return (status); |
1511 | 0 | } |
1512 | | |
1513 | | WORD32 ihevcd_join_threads(codec_t *ps_codec) |
1514 | 0 | { |
1515 | 0 | if(ps_codec->i4_threads_active) |
1516 | 0 | { |
1517 | 0 | int i; |
1518 | | /* Wait for threads */ |
1519 | 0 | ps_codec->i4_break_threads = 1; |
1520 | |
|
1521 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1522 | 0 | { |
1523 | 0 | WORD32 ret; |
1524 | 0 | if(ps_codec->ai4_process_thread_created[i]) |
1525 | 0 | { |
1526 | 0 | ret = ithread_mutex_lock(ps_codec->apv_proc_start_mutex[i]); |
1527 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1528 | |
|
1529 | 0 | ps_codec->ai4_process_start[i] = 1; |
1530 | 0 | ret = ithread_cond_signal(ps_codec->apv_proc_start_condition[i]); |
1531 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1532 | |
|
1533 | 0 | ret = ithread_mutex_unlock(ps_codec->apv_proc_start_mutex[i]); |
1534 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1535 | |
|
1536 | 0 | ithread_join(ps_codec->apv_process_thread_handle[i], NULL); |
1537 | |
|
1538 | 0 | ps_codec->ai4_process_thread_created[i] = 0; |
1539 | 0 | } |
1540 | 0 | } |
1541 | 0 | } |
1542 | 0 | return IV_SUCCESS; |
1543 | 0 | } |
1544 | | /** |
1545 | | ******************************************************************************* |
1546 | | * |
1547 | | * @brief |
1548 | | * Free static memory for the codec |
1549 | | * |
1550 | | * @par Description: |
1551 | | * Free static memory for the codec |
1552 | | * |
1553 | | * @param[in] ps_codec |
1554 | | * Pointer to codec context |
1555 | | * |
1556 | | * @returns Status |
1557 | | * |
1558 | | * @remarks |
1559 | | * |
1560 | | * |
1561 | | ******************************************************************************* |
1562 | | */ |
1563 | | WORD32 ihevcd_free_static_bufs(iv_obj_t *ps_codec_obj) |
1564 | 0 | { |
1565 | 0 | codec_t *ps_codec; |
1566 | |
|
1567 | 0 | void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf); |
1568 | 0 | void *pv_mem_ctxt; |
1569 | |
|
1570 | 0 | ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
1571 | 0 | pf_aligned_free = ps_codec->pf_aligned_free; |
1572 | 0 | pv_mem_ctxt = ps_codec->pv_mem_ctxt; |
1573 | |
|
1574 | 0 | if(ps_codec->i4_threads_active) |
1575 | 0 | { |
1576 | | /* Wait for threads */ |
1577 | 0 | ihevcd_join_threads(ps_codec); |
1578 | |
|
1579 | 0 | for(int i = 0; i < MAX_PROCESS_THREADS; i++) |
1580 | 0 | { |
1581 | 0 | WORD32 ret; |
1582 | 0 | ret = ithread_cond_destroy(ps_codec->apv_proc_start_condition[i]); |
1583 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1584 | |
|
1585 | 0 | ret = ithread_cond_destroy(ps_codec->apv_proc_done_condition[i]); |
1586 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1587 | |
|
1588 | 0 | ret = ithread_mutex_destroy(ps_codec->apv_proc_start_mutex[i]); |
1589 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1590 | |
|
1591 | 0 | ret = ithread_mutex_destroy(ps_codec->apv_proc_done_mutex[i]); |
1592 | 0 | RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); |
1593 | 0 | } |
1594 | 0 | ALIGNED_FREE(ps_codec, ps_codec->apv_proc_start_mutex[0]); |
1595 | 0 | ALIGNED_FREE(ps_codec, ps_codec->apv_proc_start_condition[0]); |
1596 | 0 | } |
1597 | | |
1598 | 0 | ALIGNED_FREE(ps_codec, ps_codec->apv_process_thread_handle[0]); |
1599 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_bitsbuf_static); |
1600 | |
|
1601 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_disp_buf_mgr); |
1602 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_dpb_mgr); |
1603 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_pic_buf_mgr); |
1604 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_mv_buf_mgr); |
1605 | 0 | ALIGNED_FREE(ps_codec, ps_codec->ps_vps_base); |
1606 | 0 | ALIGNED_FREE(ps_codec, ps_codec->ps_sps_base); |
1607 | 0 | ALIGNED_FREE(ps_codec, ps_codec->ps_pps_base); |
1608 | 0 | ALIGNED_FREE(ps_codec, ps_codec->ps_slice_hdr_base); |
1609 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pi2_scaling_mat); |
1610 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_pic_buf_base); |
1611 | 0 | ALIGNED_FREE(ps_codec, ps_codec->s_parse.pu1_luma_intra_pred_mode_left); |
1612 | 0 | ALIGNED_FREE(ps_codec, ps_codec->as_process[0].s_sao_ctxt.pu1_tmp_buf_luma); |
1613 | 0 | ALIGNED_FREE(ps_codec, ps_codec->as_process[0].pi2_inter_pred_tmp_buf1); |
1614 | 0 | ALIGNED_FREE(ps_codec, ps_codec_obj->pv_codec_handle); |
1615 | |
|
1616 | 0 | if(ps_codec_obj) |
1617 | 0 | { |
1618 | 0 | pf_aligned_free(pv_mem_ctxt, ps_codec_obj); |
1619 | 0 | } |
1620 | |
|
1621 | 0 | return IV_SUCCESS; |
1622 | |
|
1623 | 0 | } |
1624 | | |
1625 | | |
1626 | | /** |
1627 | | ******************************************************************************* |
1628 | | * |
1629 | | * @brief |
1630 | | * Allocate dynamic memory for the codec |
1631 | | * |
1632 | | * @par Description: |
1633 | | * Allocates dynamic memory for the codec |
1634 | | * |
1635 | | * @param[in] ps_codec |
1636 | | * Pointer to codec context |
1637 | | * |
1638 | | * @returns Status |
1639 | | * |
1640 | | * @remarks |
1641 | | * |
1642 | | * |
1643 | | ******************************************************************************* |
1644 | | */ |
1645 | | WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec) |
1646 | 0 | { |
1647 | 0 | WORD32 max_tile_cols, max_tile_rows; |
1648 | 0 | WORD32 max_ctb_rows, max_ctb_cols; |
1649 | 0 | WORD32 max_num_cu_cols; |
1650 | 0 | WORD32 max_num_cu_rows; |
1651 | 0 | WORD32 max_num_4x4_cols; |
1652 | 0 | WORD32 max_ctb_cnt; |
1653 | 0 | WORD32 wd; |
1654 | 0 | WORD32 ht; |
1655 | 0 | WORD32 i; |
1656 | 0 | WORD32 max_dpb_size; |
1657 | 0 | void *pv_mem_ctxt = ps_codec->pv_mem_ctxt; |
1658 | 0 | void *pv_buf; |
1659 | 0 | UWORD8 *pu1_buf; |
1660 | 0 | WORD32 size; |
1661 | | |
1662 | | /* Free any dynamic buffers that are allocated earlier. As ps_codec is memset to zero */ |
1663 | | /* at the beginning, it is safe to call this even if no memory was allocated earlier */ |
1664 | 0 | ihevcd_free_dynamic_bufs(ps_codec); |
1665 | |
|
1666 | 0 | wd = ALIGN64(ps_codec->i4_wd); |
1667 | 0 | ht = ALIGN64(ps_codec->i4_ht); |
1668 | |
|
1669 | 0 | max_tile_cols = (wd + MIN_TILE_WD - 1) / MIN_TILE_WD; |
1670 | 0 | max_tile_rows = (ht + MIN_TILE_HT - 1) / MIN_TILE_HT; |
1671 | 0 | max_ctb_rows = ht / MIN_CTB_SIZE; |
1672 | 0 | max_ctb_cols = wd / MIN_CTB_SIZE; |
1673 | 0 | max_ctb_cnt = max_ctb_rows * max_ctb_cols; |
1674 | 0 | max_num_cu_cols = wd / MIN_CU_SIZE; |
1675 | 0 | max_num_cu_rows = ht / MIN_CU_SIZE; |
1676 | 0 | max_num_4x4_cols = wd / 4; |
1677 | | |
1678 | | /* Allocate tile structures */ |
1679 | 0 | size = max_tile_cols * max_tile_rows; |
1680 | 0 | size *= sizeof(tile_t); |
1681 | 0 | size *= MAX_PPS_CNT; |
1682 | |
|
1683 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1684 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1685 | 0 | memset(pv_buf, 0, size); |
1686 | 0 | ps_codec->ps_tile = (tile_t *)pv_buf; |
1687 | | |
1688 | | |
1689 | | /* Allocate memory to hold entry point offsets */ |
1690 | | /* One entry point per tile */ |
1691 | 0 | size = max_tile_cols * max_tile_rows; |
1692 | | |
1693 | | /* One entry point per row of CTBs */ |
1694 | | /*********************************************************************/ |
1695 | | /* Only tiles or entropy sync is enabled at a time in main */ |
1696 | | /* profile, but since memory required does not increase too much, */ |
1697 | | /* this allocation is done to handle both cases */ |
1698 | | /*********************************************************************/ |
1699 | 0 | size += max_ctb_rows; |
1700 | 0 | size *= sizeof(WORD32); |
1701 | |
|
1702 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1703 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1704 | 0 | memset(pv_buf, 0, size); |
1705 | 0 | ps_codec->pi4_entry_ofst = (WORD32 *)pv_buf; |
1706 | | |
1707 | | /* Allocate parse skip flag buffer */ |
1708 | | /* 1 bit per 8x8 */ |
1709 | 0 | size = max_num_cu_cols / 8; |
1710 | 0 | size = ALIGN4(size); |
1711 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1712 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1713 | 0 | memset(pv_buf, 0, size); |
1714 | 0 | ps_codec->s_parse.pu4_skip_cu_top = (UWORD32 *)pv_buf; |
1715 | | |
1716 | | /* Allocate parse coding tree depth buffer */ |
1717 | | /* 2 bits per 8x8 */ |
1718 | 0 | size = max_num_cu_cols / 4; |
1719 | 0 | size = ALIGN4(size); |
1720 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1721 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1722 | 0 | memset(pv_buf, 0, size); |
1723 | 0 | ps_codec->s_parse.pu4_ct_depth_top = (UWORD32 *)pv_buf; |
1724 | | |
1725 | | /* Allocate intra flag buffer */ |
1726 | | /* 1 bit per 8x8 */ |
1727 | 0 | size = max_num_cu_cols * max_num_cu_rows / 8; |
1728 | 0 | size = ALIGN4(size); |
1729 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1730 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1731 | 0 | memset(pv_buf, 0, size); |
1732 | 0 | ps_codec->pu1_pic_intra_flag = (UWORD8 *)pv_buf; |
1733 | 0 | ps_codec->s_parse.pu1_pic_intra_flag = ps_codec->pu1_pic_intra_flag; |
1734 | | |
1735 | | /* Allocate transquant bypass flag buffer */ |
1736 | | /* 1 bit per 8x8 */ |
1737 | | /* Extra row and column are allocated for easy processing of top and left blocks while loop filtering */ |
1738 | 0 | size = ((max_num_cu_cols + 8) * (max_num_cu_rows + 8)) / 8; |
1739 | 0 | size = ALIGN4(size); |
1740 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1741 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1742 | 0 | memset(pv_buf, 1, size); |
1743 | 0 | { |
1744 | 0 | WORD32 loop_filter_strd = (wd + 63) >> 6; |
1745 | 0 | ps_codec->pu1_pic_no_loop_filter_flag_base = pv_buf; |
1746 | | /* The offset is added for easy processing of top and left blocks while loop filtering */ |
1747 | 0 | ps_codec->pu1_pic_no_loop_filter_flag = (UWORD8 *)pv_buf + loop_filter_strd + 1; |
1748 | 0 | ps_codec->s_parse.pu1_pic_no_loop_filter_flag = ps_codec->pu1_pic_no_loop_filter_flag; |
1749 | 0 | ps_codec->s_parse.s_deblk_ctxt.pu1_pic_no_loop_filter_flag = ps_codec->pu1_pic_no_loop_filter_flag; |
1750 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_pic_no_loop_filter_flag = ps_codec->pu1_pic_no_loop_filter_flag; |
1751 | 0 | } |
1752 | | |
1753 | | /* Initialize pointers in PPS structures */ |
1754 | 0 | { |
1755 | 0 | pps_t *ps_pps = ps_codec->ps_pps_base; |
1756 | 0 | tile_t *ps_tile = ps_codec->ps_tile; |
1757 | |
|
1758 | 0 | for(i = 0; i < MAX_PPS_CNT; i++) |
1759 | 0 | { |
1760 | 0 | ps_pps->ps_tile = ps_tile; |
1761 | 0 | ps_tile += (max_tile_cols * max_tile_rows); |
1762 | 0 | ps_pps++; |
1763 | 0 | } |
1764 | |
|
1765 | 0 | } |
1766 | | |
1767 | | /* Allocate memory for job queue */ |
1768 | | |
1769 | | /* One job per row of CTBs */ |
1770 | 0 | size = max_ctb_rows; |
1771 | | |
1772 | | /* One each tile a row of CTBs, num_jobs has to incremented */ |
1773 | 0 | size *= max_tile_cols; |
1774 | | |
1775 | | /* One format convert/frame copy job per row of CTBs for non-shared mode*/ |
1776 | 0 | size += max_ctb_rows; |
1777 | |
|
1778 | 0 | size *= sizeof(proc_job_t); |
1779 | |
|
1780 | 0 | size += ihevcd_jobq_ctxt_size(); |
1781 | 0 | size = ALIGN4(size); |
1782 | |
|
1783 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1784 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1785 | 0 | memset(pv_buf, 0, size); |
1786 | 0 | ps_codec->pv_proc_jobq_buf = pv_buf; |
1787 | 0 | ps_codec->i4_proc_jobq_buf_size = size; |
1788 | |
|
1789 | 0 | size = max_ctb_cnt; |
1790 | 0 | size = ALIGN4(size); |
1791 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1792 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1793 | 0 | memset(pv_buf, 0, size); |
1794 | 0 | ps_codec->pu1_parse_map = (UWORD8 *)pv_buf; |
1795 | |
|
1796 | 0 | size = max_ctb_cnt; |
1797 | 0 | size = ALIGN4(size); |
1798 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1799 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1800 | 0 | memset(pv_buf, 0, size); |
1801 | 0 | ps_codec->pu1_proc_map = (UWORD8 *)pv_buf; |
1802 | | |
1803 | | /** Holds top and left neighbor's pu idx into picture level pu array */ |
1804 | | /* Only one top row is enough but left has to be replicated for each process context */ |
1805 | 0 | size = (max_num_4x4_cols /* left */ + MAX_PROCESS_THREADS * (MAX_CTB_SIZE / 4)/* top */ + 1/* top right */) * sizeof(WORD32); |
1806 | 0 | size = ALIGN4(size); |
1807 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1808 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
1809 | 0 | memset(pv_buf, 0, size); |
1810 | |
|
1811 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1812 | 0 | { |
1813 | 0 | UWORD32 *pu4_buf = (UWORD32 *)pv_buf; |
1814 | 0 | ps_codec->as_process[i].pu4_pic_pu_idx_left = pu4_buf + i * (MAX_CTB_SIZE / 4); |
1815 | 0 | memset(ps_codec->as_process[i].pu4_pic_pu_idx_left, 0, sizeof(UWORD32) * MAX_CTB_SIZE / 4); |
1816 | 0 | ps_codec->as_process[i].pu4_pic_pu_idx_top = pu4_buf + MAX_PROCESS_THREADS * (MAX_CTB_SIZE / 4); |
1817 | 0 | } |
1818 | 0 | memset(ps_codec->as_process[0].pu4_pic_pu_idx_top, 0, sizeof(UWORD32) * (wd / 4 + 1)); |
1819 | |
|
1820 | 0 | { |
1821 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
1822 | 0 | WORD32 chroma_pixel_strd = 2; |
1823 | 0 | WORD32 h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2; |
1824 | 0 | WORD32 v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1; |
1825 | | |
1826 | | /* To hold SAO left buffer for luma */ |
1827 | 0 | size = sizeof(UWORD8) * (MAX(ht, wd)); |
1828 | | |
1829 | | /* To hold SAO left buffer for chroma */ |
1830 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1831 | 0 | { |
1832 | 0 | size += sizeof(UWORD8) * (MAX(ht, wd)) * (chroma_pixel_strd / v_samp_factor); |
1833 | 0 | } |
1834 | | |
1835 | | /* To hold SAO top buffer for luma */ |
1836 | 0 | size += sizeof(UWORD8) * wd; |
1837 | | |
1838 | | /* To hold SAO top buffer for chroma */ |
1839 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1840 | 0 | { |
1841 | 0 | size += sizeof(UWORD8) * wd * (chroma_pixel_strd / h_samp_factor); |
1842 | 0 | } |
1843 | | |
1844 | | /* To hold SAO top left luma pixel value for last output ctb in a row*/ |
1845 | 0 | size += sizeof(UWORD8) * max_ctb_rows; |
1846 | | |
1847 | | /* To hold SAO top left chroma pixel value last output ctb in a row*/ |
1848 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1849 | 0 | { |
1850 | 0 | size += sizeof(UWORD8) * max_ctb_rows * 2; |
1851 | 0 | } |
1852 | | |
1853 | | /* To hold SAO top left pixel luma for current ctb - column array*/ |
1854 | 0 | size += sizeof(UWORD8) * max_ctb_rows; |
1855 | | |
1856 | | /* To hold SAO top left pixel chroma for current ctb-column array*/ |
1857 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1858 | 0 | { |
1859 | 0 | size += sizeof(UWORD8) * max_ctb_rows * 2; |
1860 | 0 | } |
1861 | | |
1862 | | /* To hold SAO top right pixel luma pixel value last output ctb in a row*/ |
1863 | 0 | size += sizeof(UWORD8) * max_ctb_cols; |
1864 | | |
1865 | | /* To hold SAO top right pixel chroma pixel value last output ctb in a row*/ |
1866 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1867 | 0 | { |
1868 | 0 | size += sizeof(UWORD8) * max_ctb_cols * 2; |
1869 | 0 | } |
1870 | | |
1871 | | /*To hold SAO botton bottom left pixels for luma*/ |
1872 | 0 | size += sizeof(UWORD8) * max_ctb_rows; |
1873 | | |
1874 | | /*To hold SAO botton bottom left pixels for chroma*/ |
1875 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1876 | 0 | { |
1877 | 0 | size += sizeof(UWORD8) * max_ctb_rows * 2; |
1878 | 0 | } |
1879 | |
|
1880 | 0 | size = ALIGN64(size); |
1881 | |
|
1882 | 0 | pu1_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
1883 | 0 | RETURN_IF((NULL == pu1_buf), IV_FAIL); |
1884 | 0 | memset(pu1_buf, 0, size); |
1885 | |
|
1886 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1887 | 0 | { |
1888 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_left_luma = (UWORD8 *)pu1_buf; |
1889 | 0 | } |
1890 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_left_luma = (UWORD8 *)pu1_buf; |
1891 | 0 | pu1_buf += MAX(ht, wd); |
1892 | |
|
1893 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1894 | 0 | { |
1895 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1896 | 0 | { |
1897 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_left_chroma = (UWORD8 *)pu1_buf; |
1898 | 0 | } |
1899 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_left_chroma = (UWORD8 *)pu1_buf; |
1900 | 0 | pu1_buf += MAX(ht, wd) * (chroma_pixel_strd / v_samp_factor); |
1901 | 0 | } |
1902 | |
|
1903 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1904 | 0 | { |
1905 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_luma = (UWORD8 *)pu1_buf; |
1906 | 0 | } |
1907 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_luma = (UWORD8 *)pu1_buf; |
1908 | 0 | pu1_buf += wd; |
1909 | |
|
1910 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1911 | 0 | { |
1912 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1913 | 0 | { |
1914 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_chroma = (UWORD8 *)pu1_buf; |
1915 | 0 | } |
1916 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_chroma = (UWORD8 *)pu1_buf; |
1917 | 0 | pu1_buf += wd * (chroma_pixel_strd / h_samp_factor); |
1918 | 0 | } |
1919 | |
|
1920 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1921 | 0 | { |
1922 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_luma_top_left_ctb = (UWORD8 *)pu1_buf; |
1923 | 0 | } |
1924 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_luma_top_left_ctb = (UWORD8 *)pu1_buf; |
1925 | 0 | pu1_buf += ht / MIN_CTB_SIZE; |
1926 | |
|
1927 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1928 | 0 | { |
1929 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1930 | 0 | { |
1931 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_chroma_top_left_ctb = (UWORD8 *)pu1_buf; |
1932 | 0 | } |
1933 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_chroma_top_left_ctb = (UWORD8 *)pu1_buf; |
1934 | 0 | pu1_buf += (ht / MIN_CTB_SIZE) * 2; |
1935 | 0 | } |
1936 | |
|
1937 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1938 | 0 | { |
1939 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_luma_curr_ctb = (UWORD8 *)pu1_buf; |
1940 | 0 | } |
1941 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_luma_curr_ctb = (UWORD8 *)pu1_buf; |
1942 | 0 | pu1_buf += ht / MIN_CTB_SIZE; |
1943 | |
|
1944 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1945 | 0 | { |
1946 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1947 | 0 | { |
1948 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_chroma_curr_ctb = (UWORD8 *)pu1_buf; |
1949 | 0 | } |
1950 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_chroma_curr_ctb = (UWORD8 *)pu1_buf; |
1951 | 0 | pu1_buf += (ht / MIN_CTB_SIZE) * 2; |
1952 | 0 | } |
1953 | |
|
1954 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1955 | 0 | { |
1956 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_luma_top_right = (UWORD8 *)pu1_buf; |
1957 | 0 | } |
1958 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_luma_top_right = (UWORD8 *)pu1_buf; |
1959 | 0 | pu1_buf += wd / MIN_CTB_SIZE; |
1960 | |
|
1961 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1962 | 0 | { |
1963 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1964 | 0 | { |
1965 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_chroma_top_right = (UWORD8 *)pu1_buf; |
1966 | 0 | } |
1967 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_chroma_top_right = (UWORD8 *)pu1_buf; |
1968 | 0 | pu1_buf += (wd / MIN_CTB_SIZE) * 2; |
1969 | 0 | } |
1970 | | |
1971 | | /*Per CTB, Store 1 value for luma , 2 values for chroma*/ |
1972 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1973 | 0 | { |
1974 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_luma_bot_left = (UWORD8 *)pu1_buf; |
1975 | 0 | } |
1976 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_luma_bot_left = (UWORD8 *)pu1_buf; |
1977 | 0 | pu1_buf += (ht / MIN_CTB_SIZE); |
1978 | |
|
1979 | 0 | if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME) |
1980 | 0 | { |
1981 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
1982 | 0 | { |
1983 | 0 | ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_left_chroma_bot_left = (UWORD8 *)pu1_buf; |
1984 | 0 | } |
1985 | 0 | ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_left_chroma_bot_left = (UWORD8 *)pu1_buf; |
1986 | 0 | pu1_buf += (ht / MIN_CTB_SIZE) * 2; |
1987 | 0 | } |
1988 | 0 | } |
1989 | | |
1990 | | |
1991 | 0 | { |
1992 | 0 | UWORD8 *pu1_buf = (UWORD8 *)pv_buf; |
1993 | 0 | WORD32 vert_bs_size, horz_bs_size; |
1994 | 0 | WORD32 qp_const_flag_size; |
1995 | 0 | WORD32 qp_size; |
1996 | 0 | WORD32 num_8x8; |
1997 | | |
1998 | | /* Max Number of vertical edges */ |
1999 | 0 | vert_bs_size = wd / 8 + 2 * MAX_CTB_SIZE / 8; |
2000 | | |
2001 | | /* Max Number of horizontal edges - extra MAX_CTB_SIZE / 8 to handle the last 4 rows separately(shifted CTB processing) */ |
2002 | 0 | vert_bs_size *= (ht + MAX_CTB_SIZE) / MIN_TU_SIZE; |
2003 | | |
2004 | | /* Number of bytes */ |
2005 | 0 | vert_bs_size /= 8; |
2006 | | |
2007 | | /* Two bits per edge */ |
2008 | 0 | vert_bs_size *= 2; |
2009 | | |
2010 | | /* Max Number of horizontal edges */ |
2011 | 0 | horz_bs_size = ht / 8 + MAX_CTB_SIZE / 8; |
2012 | | |
2013 | | /* Max Number of vertical edges - extra MAX_CTB_SIZE / 8 to handle the last 4 columns separately(shifted CTB processing) */ |
2014 | 0 | horz_bs_size *= (wd + MAX_CTB_SIZE) / MIN_TU_SIZE; |
2015 | | |
2016 | | /* Number of bytes */ |
2017 | 0 | horz_bs_size /= 8; |
2018 | | |
2019 | | /* Two bits per edge */ |
2020 | 0 | horz_bs_size *= 2; |
2021 | | |
2022 | | /* Max CTBs in a row */ |
2023 | 0 | qp_const_flag_size = wd / MIN_CTB_SIZE + 1 /* The last ctb row deblk is done in last ctb + 1 row.*/; |
2024 | | |
2025 | | /* Max CTBs in a column */ |
2026 | 0 | qp_const_flag_size *= ht / MIN_CTB_SIZE; |
2027 | | |
2028 | | /* Number of bytes */ |
2029 | 0 | qp_const_flag_size /= 8; |
2030 | | |
2031 | | /* QP changes at CU level - So store at 8x8 level */ |
2032 | 0 | num_8x8 = (wd * ht) / (MIN_CU_SIZE * MIN_CU_SIZE); |
2033 | 0 | qp_size = num_8x8; |
2034 | | |
2035 | | /* To hold vertical boundary strength */ |
2036 | 0 | size += vert_bs_size; |
2037 | | |
2038 | | /* To hold horizontal boundary strength */ |
2039 | 0 | size += horz_bs_size; |
2040 | | |
2041 | | /* To hold QP */ |
2042 | 0 | size += qp_size; |
2043 | | |
2044 | | /* To hold QP const in CTB flags */ |
2045 | 0 | size += qp_const_flag_size; |
2046 | |
|
2047 | 0 | pu1_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2048 | 0 | RETURN_IF((NULL == pu1_buf), IV_FAIL); |
2049 | |
|
2050 | 0 | memset(pu1_buf, 0, size); |
2051 | |
|
2052 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
2053 | 0 | { |
2054 | 0 | ps_codec->as_process[i].s_bs_ctxt.pu4_pic_vert_bs = (UWORD32 *)pu1_buf; |
2055 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_vert_bs = (UWORD32 *)pu1_buf; |
2056 | 0 | ps_codec->s_parse.s_deblk_ctxt.s_bs_ctxt.pu4_pic_vert_bs = (UWORD32 *)pu1_buf; |
2057 | 0 | pu1_buf += vert_bs_size; |
2058 | |
|
2059 | 0 | ps_codec->as_process[i].s_bs_ctxt.pu4_pic_horz_bs = (UWORD32 *)pu1_buf; |
2060 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_horz_bs = (UWORD32 *)pu1_buf; |
2061 | 0 | ps_codec->s_parse.s_deblk_ctxt.s_bs_ctxt.pu4_pic_horz_bs = (UWORD32 *)pu1_buf; |
2062 | 0 | pu1_buf += horz_bs_size; |
2063 | |
|
2064 | 0 | ps_codec->as_process[i].s_bs_ctxt.pu1_pic_qp = (UWORD8 *)pu1_buf; |
2065 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp = (UWORD8 *)pu1_buf; |
2066 | 0 | ps_codec->s_parse.s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp = (UWORD8 *)pu1_buf; |
2067 | 0 | pu1_buf += qp_size; |
2068 | |
|
2069 | 0 | ps_codec->as_process[i].s_bs_ctxt.pu1_pic_qp_const_in_ctb = (UWORD8 *)pu1_buf; |
2070 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp_const_in_ctb = (UWORD8 *)pu1_buf; |
2071 | 0 | ps_codec->s_parse.s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp_const_in_ctb = (UWORD8 *)pu1_buf; |
2072 | 0 | pu1_buf += qp_const_flag_size; |
2073 | |
|
2074 | 0 | pu1_buf -= (vert_bs_size + horz_bs_size + qp_size + qp_const_flag_size); |
2075 | 0 | } |
2076 | 0 | ps_codec->s_parse.s_bs_ctxt.pu4_pic_vert_bs = (UWORD32 *)pu1_buf; |
2077 | 0 | pu1_buf += vert_bs_size; |
2078 | |
|
2079 | 0 | ps_codec->s_parse.s_bs_ctxt.pu4_pic_horz_bs = (UWORD32 *)pu1_buf; |
2080 | 0 | pu1_buf += horz_bs_size; |
2081 | |
|
2082 | 0 | ps_codec->s_parse.s_bs_ctxt.pu1_pic_qp = (UWORD8 *)pu1_buf; |
2083 | 0 | pu1_buf += qp_size; |
2084 | |
|
2085 | 0 | ps_codec->s_parse.s_bs_ctxt.pu1_pic_qp_const_in_ctb = (UWORD8 *)pu1_buf; |
2086 | 0 | pu1_buf += qp_const_flag_size; |
2087 | |
|
2088 | 0 | } |
2089 | | |
2090 | | /* Max CTBs in a row */ |
2091 | 0 | size = wd / MIN_CTB_SIZE; |
2092 | | /* Max CTBs in a column */ |
2093 | 0 | size *= (ht / MIN_CTB_SIZE + 2) /* Top row and bottom row extra. This ensures accessing left,top in first row |
2094 | 0 | and right in last row will not result in invalid access*/; |
2095 | |
|
2096 | 0 | size *= sizeof(UWORD16); |
2097 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2098 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2099 | 0 | memset(pv_buf, 0, size); |
2100 | |
|
2101 | 0 | ps_codec->pu1_tile_idx_base = pv_buf; |
2102 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
2103 | 0 | { |
2104 | 0 | ps_codec->as_process[i].pu1_tile_idx = (UWORD16 *)pv_buf + wd / MIN_CTB_SIZE /* Offset 1 row */; |
2105 | 0 | } |
2106 | | |
2107 | | /* 4 bytes per color component per CTB */ |
2108 | 0 | size = 3 * 4; |
2109 | | |
2110 | | /* MAX number of CTBs in a row */ |
2111 | 0 | size *= wd / MIN_CTB_SIZE; |
2112 | | |
2113 | | /* MAX number of CTBs in a column */ |
2114 | 0 | size *= ht / MIN_CTB_SIZE; |
2115 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2116 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2117 | 0 | memset(pv_buf, 0, size); |
2118 | |
|
2119 | 0 | ps_codec->s_parse.ps_pic_sao = (sao_t *)pv_buf; |
2120 | 0 | ps_codec->s_parse.s_sao_ctxt.ps_pic_sao = (sao_t *)pv_buf; |
2121 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
2122 | 0 | { |
2123 | 0 | ps_codec->as_process[i].s_sao_ctxt.ps_pic_sao = ps_codec->s_parse.ps_pic_sao; |
2124 | 0 | } |
2125 | | |
2126 | | /* Only if (frame size * compression factor) is greater than MIN_BITSBUF_SIZE, |
2127 | | then allocate dynamic bistream buffer */ |
2128 | 0 | ps_codec->pu1_bitsbuf_dynamic = NULL; |
2129 | 0 | { |
2130 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
2131 | |
|
2132 | 0 | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444) |
2133 | 0 | { |
2134 | 0 | size = wd * ht * 3; |
2135 | 0 | } |
2136 | 0 | else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422) |
2137 | 0 | { |
2138 | 0 | size = wd * ht * 2; |
2139 | 0 | } |
2140 | 0 | else |
2141 | 0 | { |
2142 | 0 | size = wd * ht; |
2143 | 0 | } |
2144 | |
|
2145 | 0 | if(size > MIN_BITSBUF_SIZE) |
2146 | 0 | { |
2147 | | //Alloc extra for parse optimization |
2148 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size + 16); |
2149 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2150 | |
|
2151 | 0 | memset(pv_buf, 0, size + 16); |
2152 | 0 | ps_codec->pu1_bitsbuf_dynamic = pv_buf; |
2153 | 0 | ps_codec->u4_bitsbuf_size_dynamic = size; |
2154 | 0 | } |
2155 | 0 | } |
2156 | | |
2157 | 0 | size = ihevcd_get_tu_data_size(ps_codec, wd * ht); |
2158 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2159 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2160 | 0 | memset(pv_buf, 0, size); |
2161 | 0 | ps_codec->pv_tu_data = pv_buf; |
2162 | | |
2163 | | /* CU info map to store qp and CU type at 8x8 level */ |
2164 | 0 | if(ps_codec->u1_enable_cu_info) |
2165 | 0 | { |
2166 | 0 | size = ((wd * ht) / (MIN_CU_SIZE * MIN_CU_SIZE)) * BUF_MGR_MAX_CNT; |
2167 | |
|
2168 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2169 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2170 | 0 | memset(pv_buf, 0, size); |
2171 | 0 | ps_codec->pu1_qp_map_base = pv_buf; |
2172 | |
|
2173 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2174 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2175 | 0 | memset(pv_buf, 0, size); |
2176 | 0 | ps_codec->pu1_cu_type_map_base = pv_buf; |
2177 | 0 | } |
2178 | | |
2179 | 0 | { |
2180 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
2181 | | |
2182 | | |
2183 | | /* Allocate for pu_map, pu_t and pic_pu_idx for each MV bank */ |
2184 | | /* Note: Number of luma samples is not max_wd * max_ht here, instead it is |
2185 | | * set to maximum number of luma samples allowed at the given level. |
2186 | | * This is done to ensure that any stream with width and height lesser |
2187 | | * than max_wd and max_ht is supported. Number of buffers required can be greater |
2188 | | * for lower width and heights at a given level and this increased number of buffers |
2189 | | * might require more memory than what max_wd and max_ht buffer would have required |
2190 | | * Also note one extra buffer is allocted to store current pictures MV bank |
2191 | | * In case of asynchronous parsing and processing, number of buffers should increase here |
2192 | | * based on when parsing and processing threads are synchronized |
2193 | | */ |
2194 | 0 | max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1]; |
2195 | | /* Size for holding mv_buf_t for each MV Bank |
2196 | | * One extra MV Bank is needed to hold current pics MV bank. |
2197 | | */ |
2198 | 0 | size = (max_dpb_size + 1) * sizeof(mv_buf_t); |
2199 | |
|
2200 | 0 | size += (max_dpb_size + 1) * |
2201 | 0 | ihevcd_get_pic_mv_bank_size(wd * ht); |
2202 | |
|
2203 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2204 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2205 | 0 | memset(pv_buf, 0, size); |
2206 | |
|
2207 | 0 | ps_codec->pv_mv_bank_buf_base = pv_buf; |
2208 | 0 | ps_codec->i4_total_mv_bank_size = size; |
2209 | |
|
2210 | 0 | } |
2211 | | |
2212 | | /* In case of non-shared mode allocate for reference picture buffers */ |
2213 | | /* In case of shared and 420p output, allocate for chroma samples */ |
2214 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
2215 | 0 | { |
2216 | | /* Number of buffers is doubled in order to return one frame at a time instead of sending |
2217 | | * multiple outputs during dpb full case. |
2218 | | * Also note one extra buffer is allocted to store current picture |
2219 | | * In case of asynchronous parsing and processing, number of buffers should increase here |
2220 | | * based on when parsing and processing threads are synchronized |
2221 | | */ |
2222 | 0 | size = ihevcd_get_total_pic_buf_size(ps_codec, wd, ht); |
2223 | 0 | pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2224 | 0 | RETURN_IF((NULL == pv_buf), IV_FAIL); |
2225 | 0 | memset(pv_buf, 0, size); |
2226 | |
|
2227 | 0 | ps_codec->i4_total_pic_buf_size = size; |
2228 | 0 | ps_codec->pu1_ref_pic_buf_base = (UWORD8 *)pv_buf; |
2229 | 0 | } |
2230 | | |
2231 | 0 | ps_codec->pv_proc_jobq = ihevcd_jobq_init(ps_codec->pv_proc_jobq_buf, ps_codec->i4_proc_jobq_buf_size); |
2232 | 0 | RETURN_IF((ps_codec->pv_proc_jobq == NULL), IV_FAIL); |
2233 | | |
2234 | | /* Update the jobq context to all the threads */ |
2235 | 0 | ps_codec->s_parse.pv_proc_jobq = ps_codec->pv_proc_jobq; |
2236 | 0 | for(i = 0; i < MAX_PROCESS_THREADS; i++) |
2237 | 0 | { |
2238 | 0 | ps_codec->as_process[i].pv_proc_jobq = ps_codec->pv_proc_jobq; |
2239 | 0 | ps_codec->as_process[i].i4_id = i; |
2240 | 0 | ps_codec->as_process[i].ps_codec = ps_codec; |
2241 | | |
2242 | | /* Set the following to zero assuming it is a single core solution |
2243 | | * When threads are launched these will be set appropriately |
2244 | | */ |
2245 | 0 | ps_codec->as_process[i].i4_check_parse_status = 0; |
2246 | 0 | ps_codec->as_process[i].i4_check_proc_status = 0; |
2247 | 0 | } |
2248 | |
|
2249 | 0 | ps_codec->u4_allocate_dynamic_done = 1; |
2250 | |
|
2251 | 0 | return IV_SUCCESS; |
2252 | 0 | } |
2253 | | |
2254 | | /** |
2255 | | ******************************************************************************* |
2256 | | * |
2257 | | * @brief |
2258 | | * Free dynamic memory for the codec |
2259 | | * |
2260 | | * @par Description: |
2261 | | * Free dynamic memory for the codec |
2262 | | * |
2263 | | * @param[in] ps_codec |
2264 | | * Pointer to codec context |
2265 | | * |
2266 | | * @returns Status |
2267 | | * |
2268 | | * @remarks |
2269 | | * |
2270 | | * |
2271 | | ******************************************************************************* |
2272 | | */ |
2273 | | WORD32 ihevcd_free_dynamic_bufs(codec_t *ps_codec) |
2274 | 0 | { |
2275 | |
|
2276 | 0 | if(ps_codec->pv_proc_jobq) |
2277 | 0 | { |
2278 | 0 | ihevcd_jobq_deinit(ps_codec->pv_proc_jobq); |
2279 | 0 | ps_codec->pv_proc_jobq = NULL; |
2280 | 0 | } |
2281 | |
|
2282 | 0 | ALIGNED_FREE(ps_codec, ps_codec->ps_tile); |
2283 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pi4_entry_ofst); |
2284 | 0 | ALIGNED_FREE(ps_codec, ps_codec->s_parse.pu4_skip_cu_top); |
2285 | 0 | ALIGNED_FREE(ps_codec, ps_codec->s_parse.pu4_ct_depth_top); |
2286 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_pic_intra_flag); |
2287 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_pic_no_loop_filter_flag_base); |
2288 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_proc_jobq_buf); |
2289 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_parse_map); |
2290 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_proc_map); |
2291 | 0 | ALIGNED_FREE(ps_codec, ps_codec->as_process[0].pu4_pic_pu_idx_left); |
2292 | 0 | ALIGNED_FREE(ps_codec, ps_codec->as_process[0].s_sao_ctxt.pu1_sao_src_left_luma); |
2293 | 0 | ALIGNED_FREE(ps_codec, ps_codec->as_process[0].s_bs_ctxt.pu4_pic_vert_bs); |
2294 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_tile_idx_base); |
2295 | 0 | ALIGNED_FREE(ps_codec, ps_codec->s_parse.ps_pic_sao); |
2296 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_bitsbuf_dynamic); |
2297 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_tu_data); |
2298 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pv_mv_bank_buf_base); |
2299 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_ref_pic_buf_base); |
2300 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_cur_chroma_ref_buf); |
2301 | 0 | if(ps_codec->u1_enable_cu_info) |
2302 | 0 | { |
2303 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_qp_map_base); |
2304 | 0 | ALIGNED_FREE(ps_codec, ps_codec->pu1_cu_type_map_base); |
2305 | 0 | } |
2306 | |
|
2307 | 0 | ps_codec->u4_allocate_dynamic_done = 0; |
2308 | 0 | return IV_SUCCESS; |
2309 | 0 | } |
2310 | | |
2311 | | |
2312 | | /** |
2313 | | ******************************************************************************* |
2314 | | * |
2315 | | * @brief |
2316 | | * Initializes from mem records passed to the codec |
2317 | | * |
2318 | | * @par Description: |
2319 | | * Initializes pointers based on mem records passed |
2320 | | * |
2321 | | * @param[in] ps_codec_obj |
2322 | | * Pointer to codec object at API level |
2323 | | * |
2324 | | * @param[in] pv_api_ip |
2325 | | * Pointer to input argument structure |
2326 | | * |
2327 | | * @param[out] pv_api_op |
2328 | | * Pointer to output argument structure |
2329 | | * |
2330 | | * @returns Status |
2331 | | * |
2332 | | * @remarks |
2333 | | * |
2334 | | * |
2335 | | ******************************************************************************* |
2336 | | */ |
2337 | | WORD32 ihevcd_create(iv_obj_t *ps_codec_obj, |
2338 | | void *pv_api_ip, |
2339 | | void *pv_api_op) |
2340 | 0 | { |
2341 | 0 | ihevcd_cxa_create_ip_t *ps_create_ip; |
2342 | 0 | ihevcd_cxa_create_op_t *ps_create_op; |
2343 | |
|
2344 | 0 | WORD32 ret; |
2345 | 0 | codec_t *ps_codec; |
2346 | 0 | ps_create_ip = (ihevcd_cxa_create_ip_t *)pv_api_ip; |
2347 | 0 | ps_create_op = (ihevcd_cxa_create_op_t *)pv_api_op; |
2348 | |
|
2349 | 0 | ps_create_op->s_ivd_create_op_t.u4_error_code = 0; |
2350 | 0 | ps_codec_obj = NULL; |
2351 | 0 | ret = ihevcd_allocate_static_bufs(&ps_codec_obj, pv_api_ip, pv_api_op); |
2352 | | |
2353 | | /* If allocation of some buffer fails, then free buffers allocated till then */ |
2354 | 0 | if(IV_FAIL == ret) |
2355 | 0 | { |
2356 | 0 | if(NULL != ps_codec_obj) |
2357 | 0 | { |
2358 | 0 | if(ps_codec_obj->pv_codec_handle) |
2359 | 0 | { |
2360 | 0 | ihevcd_free_static_bufs(ps_codec_obj); |
2361 | 0 | } |
2362 | 0 | else |
2363 | 0 | { |
2364 | 0 | void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf); |
2365 | 0 | void *pv_mem_ctxt; |
2366 | |
|
2367 | 0 | pf_aligned_free = ps_create_ip->s_ivd_create_ip_t.pf_aligned_free; |
2368 | 0 | pv_mem_ctxt = ps_create_ip->s_ivd_create_ip_t.pv_mem_ctxt; |
2369 | 0 | pf_aligned_free(pv_mem_ctxt, ps_codec_obj); |
2370 | 0 | } |
2371 | 0 | } |
2372 | 0 | ps_create_op->s_ivd_create_op_t.u4_error_code = IVD_MEM_ALLOC_FAILED; |
2373 | 0 | ps_create_op->s_ivd_create_op_t.u4_error_code |= 1 << IVD_FATALERROR; |
2374 | |
|
2375 | 0 | return IV_FAIL; |
2376 | 0 | } |
2377 | 0 | ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
2378 | 0 | if (ps_create_ip->u4_enable_yuv_formats == 0) { |
2379 | 0 | ps_create_ip->u4_enable_yuv_formats = 1 << CHROMA_FMT_IDC_YUV420; |
2380 | 0 | } |
2381 | 0 | ps_codec->u4_enable_yuv_formats = ps_create_ip->u4_enable_yuv_formats; |
2382 | 0 | ret = ihevcd_init(ps_codec); |
2383 | |
|
2384 | 0 | TRACE_INIT(NULL); |
2385 | 0 | STATS_INIT(); |
2386 | |
|
2387 | 0 | return ret; |
2388 | 0 | } |
2389 | | /** |
2390 | | ******************************************************************************* |
2391 | | * |
2392 | | * @brief |
2393 | | * Delete codec |
2394 | | * |
2395 | | * @par Description: |
2396 | | * Delete codec |
2397 | | * |
2398 | | * @param[in] ps_codec_obj |
2399 | | * Pointer to codec object at API level |
2400 | | * |
2401 | | * @param[in] pv_api_ip |
2402 | | * Pointer to input argument structure |
2403 | | * |
2404 | | * @param[out] pv_api_op |
2405 | | * Pointer to output argument structure |
2406 | | * |
2407 | | * @returns Status |
2408 | | * |
2409 | | * @remarks |
2410 | | * |
2411 | | * |
2412 | | ******************************************************************************* |
2413 | | */ |
2414 | | WORD32 ihevcd_delete(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) |
2415 | 0 | { |
2416 | 0 | codec_t *ps_dec; |
2417 | 0 | ihevcd_cxa_delete_ip_t *ps_ip = (ihevcd_cxa_delete_ip_t *)pv_api_ip; |
2418 | 0 | ihevcd_cxa_delete_op_t *ps_op = (ihevcd_cxa_delete_op_t *)pv_api_op; |
2419 | |
|
2420 | 0 | ps_dec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2421 | 0 | UNUSED(ps_ip); |
2422 | 0 | ps_op->s_ivd_delete_op_t.u4_error_code = 0; |
2423 | 0 | ihevcd_free_dynamic_bufs(ps_dec); |
2424 | 0 | ihevcd_free_static_bufs(ps_codec_obj); |
2425 | 0 | return IV_SUCCESS; |
2426 | 0 | } |
2427 | | |
2428 | | |
2429 | | /** |
2430 | | ******************************************************************************* |
2431 | | * |
2432 | | * @brief |
2433 | | * Passes display buffer from application to codec |
2434 | | * |
2435 | | * @par Description: |
2436 | | * Adds display buffer to the codec |
2437 | | * |
2438 | | * @param[in] ps_codec_obj |
2439 | | * Pointer to codec object at API level |
2440 | | * |
2441 | | * @param[in] pv_api_ip |
2442 | | * Pointer to input argument structure |
2443 | | * |
2444 | | * @param[out] pv_api_op |
2445 | | * Pointer to output argument structure |
2446 | | * |
2447 | | * @returns Status |
2448 | | * |
2449 | | * @remarks |
2450 | | * |
2451 | | * |
2452 | | ******************************************************************************* |
2453 | | */ |
2454 | | WORD32 ihevcd_set_display_frame(iv_obj_t *ps_codec_obj, |
2455 | | void *pv_api_ip, |
2456 | | void *pv_api_op) |
2457 | 0 | { |
2458 | 0 | WORD32 ret = IV_SUCCESS; |
2459 | |
|
2460 | 0 | ivd_set_display_frame_ip_t *ps_dec_disp_ip; |
2461 | 0 | ivd_set_display_frame_op_t *ps_dec_disp_op; |
2462 | |
|
2463 | 0 | WORD32 i; |
2464 | |
|
2465 | 0 | codec_t *ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2466 | |
|
2467 | 0 | ps_dec_disp_ip = (ivd_set_display_frame_ip_t *)pv_api_ip; |
2468 | 0 | ps_dec_disp_op = (ivd_set_display_frame_op_t *)pv_api_op; |
2469 | |
|
2470 | 0 | ps_codec->i4_num_disp_bufs = 0; |
2471 | 0 | if(ps_codec->i4_share_disp_buf) |
2472 | 0 | { |
2473 | 0 | UWORD32 num_bufs = ps_dec_disp_ip->num_disp_bufs; |
2474 | 0 | pic_buf_t *ps_pic_buf; |
2475 | 0 | UWORD8 *pu1_buf; |
2476 | 0 | WORD32 buf_ret; |
2477 | |
|
2478 | 0 | UWORD8 *pu1_chroma_buf = NULL; |
2479 | 0 | num_bufs = MIN(num_bufs, BUF_MGR_MAX_CNT); |
2480 | 0 | ps_codec->i4_num_disp_bufs = num_bufs; |
2481 | |
|
2482 | 0 | ps_pic_buf = (pic_buf_t *)ps_codec->ps_pic_buf; |
2483 | | |
2484 | | /* If color format is 420P, then allocate chroma buffers to hold semiplanar |
2485 | | * chroma data */ |
2486 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2487 | 0 | { |
2488 | 0 | WORD32 num_samples = ps_dec_disp_ip->s_disp_buffer[0].u4_min_out_buf_size[1] << 1; |
2489 | 0 | WORD32 size = num_samples * num_bufs; |
2490 | 0 | void *pv_mem_ctxt = ps_codec->pv_mem_ctxt; |
2491 | |
|
2492 | 0 | pu1_chroma_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); |
2493 | 0 | RETURN_IF((NULL == pu1_chroma_buf), IV_FAIL); |
2494 | 0 | memset(pu1_chroma_buf, 0, size); |
2495 | |
|
2496 | 0 | ps_codec->pu1_cur_chroma_ref_buf = pu1_chroma_buf; |
2497 | 0 | } |
2498 | 0 | for(i = 0; i < (WORD32)num_bufs; i++) |
2499 | 0 | { |
2500 | | /* Stride is not available in some cases here. |
2501 | | So store base pointers to buffer manager now, |
2502 | | and update these pointers once header is decoded */ |
2503 | 0 | pu1_buf = ps_dec_disp_ip->s_disp_buffer[i].pu1_bufs[0]; |
2504 | 0 | ps_pic_buf->pu1_luma = pu1_buf; |
2505 | |
|
2506 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2507 | 0 | { |
2508 | 0 | pu1_buf = pu1_chroma_buf; |
2509 | 0 | pu1_chroma_buf += ps_dec_disp_ip->s_disp_buffer[0].u4_min_out_buf_size[1] << 1; |
2510 | 0 | } |
2511 | 0 | else |
2512 | 0 | { |
2513 | | /* For YUV 420SP case use display buffer itself as chroma ref buffer */ |
2514 | 0 | pu1_buf = ps_dec_disp_ip->s_disp_buffer[i].pu1_bufs[1]; |
2515 | 0 | } |
2516 | |
|
2517 | 0 | ps_pic_buf->pu1_chroma = pu1_buf; |
2518 | |
|
2519 | 0 | buf_ret = ihevc_buf_mgr_add((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, ps_pic_buf, i); |
2520 | |
|
2521 | 0 | if(0 != buf_ret) |
2522 | 0 | { |
2523 | 0 | ps_codec->i4_error_code = IHEVCD_BUF_MGR_ERROR; |
2524 | 0 | return IHEVCD_BUF_MGR_ERROR; |
2525 | 0 | } |
2526 | | |
2527 | | /* Mark pic buf as needed for display */ |
2528 | | /* This ensures that till the buffer is explicitly passed to the codec, |
2529 | | * application owns the buffer. Decoder is allowed to use a buffer only |
2530 | | * when application sends it through fill this buffer call in OMX |
2531 | | */ |
2532 | 0 | ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, i, BUF_MGR_DISP); |
2533 | |
|
2534 | 0 | ps_pic_buf++; |
2535 | | |
2536 | | /* Store display buffers in codec context. Needed for 420p output */ |
2537 | 0 | memcpy(&ps_codec->s_disp_buffer[ps_codec->i4_share_disp_buf_cnt], |
2538 | 0 | &ps_dec_disp_ip->s_disp_buffer[i], |
2539 | 0 | sizeof(ps_dec_disp_ip->s_disp_buffer[i])); |
2540 | |
|
2541 | 0 | ps_codec->i4_share_disp_buf_cnt++; |
2542 | |
|
2543 | 0 | } |
2544 | 0 | } |
2545 | | |
2546 | 0 | ps_dec_disp_op->u4_error_code = 0; |
2547 | 0 | return ret; |
2548 | |
|
2549 | 0 | } |
2550 | | |
2551 | | /** |
2552 | | ******************************************************************************* |
2553 | | * |
2554 | | * @brief |
2555 | | * Sets the decoder in flush mode. Decoder will come out of flush only |
2556 | | * after returning all the buffers or at reset |
2557 | | * |
2558 | | * @par Description: |
2559 | | * Sets the decoder in flush mode |
2560 | | * |
2561 | | * @param[in] ps_codec_obj |
2562 | | * Pointer to codec object at API level |
2563 | | * |
2564 | | * @param[in] pv_api_ip |
2565 | | * Pointer to input argument structure |
2566 | | * |
2567 | | * @param[out] pv_api_op |
2568 | | * Pointer to output argument structure |
2569 | | * |
2570 | | * @returns Status |
2571 | | * |
2572 | | * @remarks |
2573 | | * |
2574 | | * |
2575 | | ******************************************************************************* |
2576 | | */ |
2577 | | WORD32 ihevcd_set_flush_mode(iv_obj_t *ps_codec_obj, |
2578 | | void *pv_api_ip, |
2579 | | void *pv_api_op) |
2580 | 0 | { |
2581 | |
|
2582 | 0 | codec_t *ps_codec; |
2583 | 0 | ivd_ctl_flush_op_t *ps_ctl_op = (ivd_ctl_flush_op_t *)pv_api_op; |
2584 | 0 | UNUSED(pv_api_ip); |
2585 | 0 | ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2586 | 0 | ihevcd_join_threads(ps_codec); |
2587 | | |
2588 | | /* Signal flush frame control call */ |
2589 | 0 | ps_codec->i4_flush_mode = 1; |
2590 | |
|
2591 | 0 | ps_ctl_op->u4_error_code = 0; |
2592 | | |
2593 | | /* Set pic count to zero, so that decoder starts buffering again */ |
2594 | | /* once it comes out of flush mode */ |
2595 | 0 | ps_codec->u4_pic_cnt = 0; |
2596 | 0 | ps_codec->u4_disp_cnt = 0; |
2597 | | |
2598 | | /* If the first slice NAL fed to decoder after flush is a CRA NAL, then */ |
2599 | | /* it may have associated RASL nals that need to be skipped */ |
2600 | 0 | ps_codec->i4_cra_as_first_pic = 1; |
2601 | 0 | return IV_SUCCESS; |
2602 | | |
2603 | |
|
2604 | 0 | } |
2605 | | |
2606 | | /** |
2607 | | ******************************************************************************* |
2608 | | * |
2609 | | * @brief |
2610 | | * Gets decoder status and buffer requirements |
2611 | | * |
2612 | | * @par Description: |
2613 | | * Gets the decoder status |
2614 | | * |
2615 | | * @param[in] ps_codec_obj |
2616 | | * Pointer to codec object at API level |
2617 | | * |
2618 | | * @param[in] pv_api_ip |
2619 | | * Pointer to input argument structure |
2620 | | * |
2621 | | * @param[out] pv_api_op |
2622 | | * Pointer to output argument structure |
2623 | | * |
2624 | | * @returns Status |
2625 | | * |
2626 | | * @remarks |
2627 | | * |
2628 | | * |
2629 | | ******************************************************************************* |
2630 | | */ |
2631 | | |
2632 | | WORD32 ihevcd_get_status(iv_obj_t *ps_codec_obj, |
2633 | | void *pv_api_ip, |
2634 | | void *pv_api_op) |
2635 | 0 | { |
2636 | |
|
2637 | 0 | WORD32 i; |
2638 | 0 | codec_t *ps_codec; |
2639 | 0 | WORD32 wd, ht; |
2640 | 0 | WORD32 aligned_wd, aligned_ht; |
2641 | 0 | ivd_ctl_getstatus_op_t *ps_ctl_op = (ivd_ctl_getstatus_op_t *)pv_api_op; |
2642 | |
|
2643 | 0 | UNUSED(pv_api_ip); |
2644 | |
|
2645 | 0 | ps_ctl_op->u4_error_code = 0; |
2646 | |
|
2647 | 0 | ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2648 | |
|
2649 | 0 | ps_ctl_op->u4_min_num_in_bufs = MIN_IN_BUFS; |
2650 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2651 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420; |
2652 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_444P) |
2653 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_444; |
2654 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_422P) |
2655 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_422; |
2656 | 0 | else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV) |
2657 | 0 | || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU)) |
2658 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420SP; |
2659 | 0 | else if(ps_codec->e_chroma_fmt == IV_GRAY) |
2660 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_GRAY; |
2661 | |
|
2662 | 0 | ps_ctl_op->u4_num_disp_bufs = 1; |
2663 | |
|
2664 | 0 | for(i = 0; i < (WORD32)ps_ctl_op->u4_min_num_in_bufs; i++) |
2665 | 0 | { |
2666 | 0 | wd = ALIGN64(ps_codec->i4_wd); |
2667 | 0 | ht = ALIGN64(ps_codec->i4_ht); |
2668 | 0 | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht), MIN_BITSBUF_SIZE); |
2669 | 0 | } |
2670 | |
|
2671 | 0 | wd = ps_codec->i4_wd; |
2672 | 0 | ht = ps_codec->i4_ht; |
2673 | |
|
2674 | 0 | if(ps_codec->i4_sps_done) |
2675 | 0 | { |
2676 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
2677 | 0 | { |
2678 | 0 | wd = ps_codec->i4_disp_wd; |
2679 | 0 | ht = ps_codec->i4_disp_ht; |
2680 | |
|
2681 | 0 | } |
2682 | 0 | else |
2683 | 0 | { |
2684 | 0 | wd = ps_codec->i4_disp_strd; |
2685 | 0 | ht = ps_codec->i4_ht + PAD_HT; |
2686 | 0 | } |
2687 | 0 | } |
2688 | |
|
2689 | 0 | if(ps_codec->i4_disp_strd > wd) |
2690 | 0 | wd = ps_codec->i4_disp_strd; |
2691 | |
|
2692 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
2693 | 0 | ps_ctl_op->u4_num_disp_bufs = 1; |
2694 | 0 | else |
2695 | 0 | { |
2696 | 0 | if(ps_codec->i4_sps_done) |
2697 | 0 | { |
2698 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
2699 | 0 | WORD32 reorder_pic_cnt, ref_pic_cnt; |
2700 | 0 | reorder_pic_cnt = 0; |
2701 | 0 | if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT) |
2702 | 0 | reorder_pic_cnt = ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1]; |
2703 | 0 | ref_pic_cnt = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1]; |
2704 | |
|
2705 | 0 | ps_ctl_op->u4_num_disp_bufs = reorder_pic_cnt; |
2706 | |
|
2707 | 0 | ps_ctl_op->u4_num_disp_bufs += ref_pic_cnt + 1; |
2708 | 0 | } |
2709 | 0 | else |
2710 | 0 | { |
2711 | 0 | ps_ctl_op->u4_num_disp_bufs = MAX_REF_CNT; |
2712 | 0 | } |
2713 | |
|
2714 | 0 | ps_ctl_op->u4_num_disp_bufs = MIN( |
2715 | 0 | ps_ctl_op->u4_num_disp_bufs, 32); |
2716 | 0 | } |
2717 | | |
2718 | | /*!*/ |
2719 | 0 | aligned_wd = ALIGN2(wd); |
2720 | 0 | aligned_ht = ALIGN2(ht); |
2721 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2722 | 0 | { |
2723 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2724 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * aligned_ht) >> 2; |
2725 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (aligned_wd * aligned_ht) >> 2; |
2726 | 0 | } |
2727 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_444P) |
2728 | 0 | { |
2729 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2730 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (wd * ht); |
2731 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (wd * ht); |
2732 | 0 | } |
2733 | 0 | else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV) |
2734 | 0 | || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU)) |
2735 | 0 | { |
2736 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2737 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * aligned_ht) >> 1; |
2738 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = 0; |
2739 | 0 | } |
2740 | 0 | else if(ps_codec->e_chroma_fmt == IV_GRAY) |
2741 | 0 | { |
2742 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2743 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = 0; |
2744 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = 0; |
2745 | 0 | } |
2746 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_422P) |
2747 | 0 | { |
2748 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2749 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * ht) >> 1; |
2750 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (aligned_wd * ht) >> 1; |
2751 | 0 | } |
2752 | 0 | ps_ctl_op->u4_pic_ht = ht; |
2753 | 0 | ps_ctl_op->u4_pic_wd = wd; |
2754 | 0 | ps_ctl_op->u4_frame_rate = 30000; |
2755 | 0 | ps_ctl_op->u4_bit_rate = 1000000; |
2756 | 0 | ps_ctl_op->e_content_type = IV_PROGRESSIVE; |
2757 | 0 | ps_ctl_op->e_output_chroma_format = ps_codec->e_chroma_fmt; |
2758 | 0 | ps_codec->i4_num_disp_bufs = ps_ctl_op->u4_num_disp_bufs; |
2759 | |
|
2760 | 0 | if(ps_ctl_op->u4_size == sizeof(ihevcd_cxa_ctl_getstatus_op_t)) |
2761 | 0 | { |
2762 | 0 | ihevcd_cxa_ctl_getstatus_op_t *ps_ext_ctl_op = (ihevcd_cxa_ctl_getstatus_op_t *)ps_ctl_op; |
2763 | 0 | ps_ext_ctl_op->u4_coded_pic_wd = ps_codec->i4_wd; |
2764 | 0 | ps_ext_ctl_op->u4_coded_pic_wd = ps_codec->i4_ht; |
2765 | 0 | } |
2766 | 0 | return IV_SUCCESS; |
2767 | 0 | } |
2768 | | /** |
2769 | | ******************************************************************************* |
2770 | | * |
2771 | | * @brief |
2772 | | * Gets decoder buffer requirements |
2773 | | * |
2774 | | * @par Description: |
2775 | | * Gets the decoder buffer requirements. If called before header decoder, |
2776 | | * buffer requirements are based on max_wd and max_ht else actual width and |
2777 | | * height will be used |
2778 | | * |
2779 | | * @param[in] ps_codec_obj |
2780 | | * Pointer to codec object at API level |
2781 | | * |
2782 | | * @param[in] pv_api_ip |
2783 | | * Pointer to input argument structure |
2784 | | * |
2785 | | * @param[out] pv_api_op |
2786 | | * Pointer to output argument structure |
2787 | | * |
2788 | | * @returns Status |
2789 | | * |
2790 | | * @remarks |
2791 | | * |
2792 | | * |
2793 | | ******************************************************************************* |
2794 | | */ |
2795 | | WORD32 ihevcd_get_buf_info(iv_obj_t *ps_codec_obj, |
2796 | | void *pv_api_ip, |
2797 | | void *pv_api_op) |
2798 | 0 | { |
2799 | |
|
2800 | 0 | codec_t *ps_codec; |
2801 | 0 | UWORD32 i = 0; |
2802 | 0 | WORD32 wd, ht; |
2803 | 0 | WORD32 aligned_wd, aligned_ht; |
2804 | 0 | ivd_ctl_getbufinfo_op_t *ps_ctl_op = |
2805 | 0 | (ivd_ctl_getbufinfo_op_t *)pv_api_op; |
2806 | |
|
2807 | 0 | UNUSED(pv_api_ip); |
2808 | 0 | ps_ctl_op->u4_error_code = 0; |
2809 | |
|
2810 | 0 | ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2811 | |
|
2812 | 0 | ps_ctl_op->u4_min_num_in_bufs = MIN_IN_BUFS; |
2813 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2814 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420; |
2815 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_444P) |
2816 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_444; |
2817 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_422P) |
2818 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_422; |
2819 | 0 | else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV) |
2820 | 0 | || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU)) |
2821 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420SP; |
2822 | 0 | else if(ps_codec->e_chroma_fmt == IV_GRAY) |
2823 | 0 | ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_GRAY; |
2824 | |
|
2825 | 0 | ps_ctl_op->u4_num_disp_bufs = 1; |
2826 | |
|
2827 | 0 | for(i = 0; i < ps_ctl_op->u4_min_num_in_bufs; i++) |
2828 | 0 | { |
2829 | 0 | wd = ALIGN64(ps_codec->i4_wd); |
2830 | 0 | ht = ALIGN64(ps_codec->i4_ht); |
2831 | |
|
2832 | 0 | if(ps_codec->i4_sps_done) |
2833 | 0 | { |
2834 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
2835 | |
|
2836 | 0 | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444) |
2837 | 0 | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht * 3), MIN_BITSBUF_SIZE); |
2838 | 0 | if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422) |
2839 | 0 | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht * 2), MIN_BITSBUF_SIZE); |
2840 | 0 | else |
2841 | 0 | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht), MIN_BITSBUF_SIZE); |
2842 | 0 | } |
2843 | 0 | else |
2844 | 0 | { |
2845 | 0 | #ifdef ENABLE_MAIN_REXT_PROFILE |
2846 | 0 | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht * 3), MIN_BITSBUF_SIZE); |
2847 | | #else |
2848 | | ps_ctl_op->u4_min_in_buf_size[i] = MAX((wd * ht), MIN_BITSBUF_SIZE); |
2849 | | #endif |
2850 | 0 | } |
2851 | 0 | } |
2852 | |
|
2853 | 0 | wd = 0; |
2854 | 0 | ht = 0; |
2855 | |
|
2856 | 0 | if(ps_codec->i4_sps_done) |
2857 | 0 | { |
2858 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
2859 | 0 | { |
2860 | 0 | wd = ps_codec->i4_disp_wd; |
2861 | 0 | ht = ps_codec->i4_disp_ht; |
2862 | |
|
2863 | 0 | } |
2864 | 0 | else |
2865 | 0 | { |
2866 | 0 | wd = ps_codec->i4_disp_strd; |
2867 | 0 | ht = ps_codec->i4_ht + PAD_HT; |
2868 | 0 | } |
2869 | 0 | } |
2870 | 0 | else |
2871 | 0 | { |
2872 | 0 | if(1 == ps_codec->i4_share_disp_buf) |
2873 | 0 | { |
2874 | 0 | wd = ALIGN32(wd + PAD_WD); |
2875 | 0 | ht += PAD_HT; |
2876 | 0 | } |
2877 | 0 | } |
2878 | |
|
2879 | 0 | if(ps_codec->i4_disp_strd > wd) |
2880 | 0 | wd = ps_codec->i4_disp_strd; |
2881 | |
|
2882 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
2883 | 0 | ps_ctl_op->u4_num_disp_bufs = 1; |
2884 | 0 | else |
2885 | 0 | { |
2886 | 0 | if(ps_codec->i4_sps_done) |
2887 | 0 | { |
2888 | 0 | sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id); |
2889 | 0 | WORD32 reorder_pic_cnt, ref_pic_cnt; |
2890 | 0 | reorder_pic_cnt = 0; |
2891 | 0 | if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT) |
2892 | 0 | reorder_pic_cnt = ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1]; |
2893 | 0 | ref_pic_cnt = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1]; |
2894 | |
|
2895 | 0 | ps_ctl_op->u4_num_disp_bufs = reorder_pic_cnt; |
2896 | |
|
2897 | 0 | ps_ctl_op->u4_num_disp_bufs += ref_pic_cnt + 1; |
2898 | 0 | } |
2899 | 0 | else |
2900 | 0 | { |
2901 | 0 | ps_ctl_op->u4_num_disp_bufs = MAX_REF_CNT; |
2902 | 0 | } |
2903 | |
|
2904 | 0 | ps_ctl_op->u4_num_disp_bufs = MIN( |
2905 | 0 | ps_ctl_op->u4_num_disp_bufs, 32); |
2906 | |
|
2907 | 0 | } |
2908 | | |
2909 | | /*!*/ |
2910 | 0 | aligned_wd = ALIGN2(wd); |
2911 | 0 | aligned_ht = ALIGN2(ht); |
2912 | 0 | if(ps_codec->e_chroma_fmt == IV_YUV_420P) |
2913 | 0 | { |
2914 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2915 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * aligned_ht) >> 2; |
2916 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (aligned_wd * aligned_ht) >> 2; |
2917 | 0 | } |
2918 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_444P) |
2919 | 0 | { |
2920 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2921 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (wd * ht); |
2922 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (wd * ht); |
2923 | 0 | } |
2924 | 0 | else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV) |
2925 | 0 | || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU)) |
2926 | 0 | { |
2927 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2928 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * aligned_ht) >> 1; |
2929 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = 0; |
2930 | 0 | } |
2931 | 0 | else if(ps_codec->e_chroma_fmt == IV_GRAY) |
2932 | 0 | { |
2933 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2934 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = 0; |
2935 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = 0; |
2936 | 0 | } |
2937 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_422P) |
2938 | 0 | { |
2939 | 0 | ps_ctl_op->u4_min_out_buf_size[0] = (wd * ht); |
2940 | 0 | ps_ctl_op->u4_min_out_buf_size[1] = (aligned_wd * ht) >> 1; |
2941 | 0 | ps_ctl_op->u4_min_out_buf_size[2] = (aligned_wd * ht) >> 1; |
2942 | 0 | } |
2943 | 0 | ps_codec->i4_num_disp_bufs = ps_ctl_op->u4_num_disp_bufs; |
2944 | |
|
2945 | 0 | return IV_SUCCESS; |
2946 | 0 | } |
2947 | | |
2948 | | |
2949 | | /** |
2950 | | ******************************************************************************* |
2951 | | * |
2952 | | * @brief |
2953 | | * Sets dynamic parameters |
2954 | | * |
2955 | | * @par Description: |
2956 | | * Sets dynamic parameters. Note Frame skip, decode header mode are dynamic |
2957 | | * Dynamic change in stride is not supported |
2958 | | * |
2959 | | * @param[in] ps_codec_obj |
2960 | | * Pointer to codec object at API level |
2961 | | * |
2962 | | * @param[in] pv_api_ip |
2963 | | * Pointer to input argument structure |
2964 | | * |
2965 | | * @param[out] pv_api_op |
2966 | | * Pointer to output argument structure |
2967 | | * |
2968 | | * @returns Status |
2969 | | * |
2970 | | * @remarks |
2971 | | * |
2972 | | * |
2973 | | ******************************************************************************* |
2974 | | */ |
2975 | | WORD32 ihevcd_set_params(iv_obj_t *ps_codec_obj, |
2976 | | void *pv_api_ip, |
2977 | | void *pv_api_op) |
2978 | 0 | { |
2979 | |
|
2980 | 0 | codec_t *ps_codec; |
2981 | 0 | WORD32 ret = IV_SUCCESS; |
2982 | 0 | WORD32 strd; |
2983 | 0 | ivd_ctl_set_config_ip_t *s_ctl_dynparams_ip = |
2984 | 0 | (ivd_ctl_set_config_ip_t *)pv_api_ip; |
2985 | 0 | ivd_ctl_set_config_op_t *s_ctl_dynparams_op = |
2986 | 0 | (ivd_ctl_set_config_op_t *)pv_api_op; |
2987 | |
|
2988 | 0 | ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
2989 | |
|
2990 | 0 | s_ctl_dynparams_op->u4_error_code = 0; |
2991 | |
|
2992 | 0 | ps_codec->e_pic_skip_mode = s_ctl_dynparams_ip->e_frm_skip_mode; |
2993 | |
|
2994 | 0 | if(s_ctl_dynparams_ip->e_frm_skip_mode != IVD_SKIP_NONE) |
2995 | 0 | { |
2996 | |
|
2997 | 0 | if((s_ctl_dynparams_ip->e_frm_skip_mode != IVD_SKIP_P) && |
2998 | 0 | (s_ctl_dynparams_ip->e_frm_skip_mode != IVD_SKIP_B) && |
2999 | 0 | (s_ctl_dynparams_ip->e_frm_skip_mode != IVD_SKIP_PB)) |
3000 | 0 | { |
3001 | 0 | s_ctl_dynparams_op->u4_error_code = (1 << IVD_UNSUPPORTEDPARAM); |
3002 | 0 | ret = IV_FAIL; |
3003 | 0 | } |
3004 | 0 | } |
3005 | |
|
3006 | 0 | strd = ps_codec->i4_disp_strd; |
3007 | 0 | if(1 == ps_codec->i4_share_disp_buf) |
3008 | 0 | { |
3009 | 0 | strd = ps_codec->i4_strd; |
3010 | 0 | } |
3011 | | |
3012 | |
|
3013 | 0 | { |
3014 | 0 | if((WORD32)s_ctl_dynparams_ip->u4_disp_wd >= ps_codec->i4_disp_wd) |
3015 | 0 | { |
3016 | 0 | strd = s_ctl_dynparams_ip->u4_disp_wd; |
3017 | 0 | } |
3018 | 0 | else if(0 == ps_codec->i4_sps_done) |
3019 | 0 | { |
3020 | 0 | strd = s_ctl_dynparams_ip->u4_disp_wd; |
3021 | 0 | } |
3022 | 0 | else if(s_ctl_dynparams_ip->u4_disp_wd == 0) |
3023 | 0 | { |
3024 | 0 | strd = ps_codec->i4_disp_strd; |
3025 | 0 | } |
3026 | 0 | else |
3027 | 0 | { |
3028 | 0 | strd = 0; |
3029 | 0 | s_ctl_dynparams_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); |
3030 | 0 | s_ctl_dynparams_op->u4_error_code |= IHEVCD_INVALID_DISP_STRD; |
3031 | 0 | ret = IV_FAIL; |
3032 | 0 | } |
3033 | 0 | } |
3034 | | |
3035 | | // output stride needs to be even for all formats other than 400 and 444 |
3036 | 0 | if(ps_codec->e_chroma_fmt != IV_GRAY && ps_codec->e_chroma_fmt != IV_YUV_444P) |
3037 | 0 | { |
3038 | 0 | if(strd & 1) |
3039 | 0 | { |
3040 | 0 | s_ctl_dynparams_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); |
3041 | 0 | s_ctl_dynparams_op->u4_error_code |= IHEVCD_INVALID_DISP_STRD; |
3042 | 0 | ret = IV_FAIL; |
3043 | 0 | } |
3044 | 0 | } |
3045 | |
|
3046 | 0 | ps_codec->i4_disp_strd = strd; |
3047 | 0 | if(1 == ps_codec->i4_share_disp_buf) |
3048 | 0 | { |
3049 | 0 | ps_codec->i4_strd = strd; |
3050 | 0 | } |
3051 | |
|
3052 | 0 | if(s_ctl_dynparams_ip->e_vid_dec_mode == IVD_DECODE_FRAME) |
3053 | 0 | ps_codec->i4_header_mode = 0; |
3054 | 0 | else if(s_ctl_dynparams_ip->e_vid_dec_mode == IVD_DECODE_HEADER) |
3055 | 0 | ps_codec->i4_header_mode = 1; |
3056 | 0 | else |
3057 | 0 | { |
3058 | |
|
3059 | 0 | s_ctl_dynparams_op->u4_error_code = (1 << IVD_UNSUPPORTEDPARAM); |
3060 | 0 | ps_codec->i4_header_mode = 1; |
3061 | 0 | ret = IV_FAIL; |
3062 | 0 | } |
3063 | |
|
3064 | 0 | ps_codec->e_frm_out_mode = IVD_DISPLAY_FRAME_OUT; |
3065 | |
|
3066 | 0 | if((s_ctl_dynparams_ip->e_frm_out_mode != IVD_DECODE_FRAME_OUT) && |
3067 | 0 | (s_ctl_dynparams_ip->e_frm_out_mode != IVD_DISPLAY_FRAME_OUT)) |
3068 | 0 | { |
3069 | 0 | s_ctl_dynparams_op->u4_error_code = (1 << IVD_UNSUPPORTEDPARAM); |
3070 | 0 | ret = IV_FAIL; |
3071 | 0 | } |
3072 | 0 | ps_codec->e_frm_out_mode = s_ctl_dynparams_ip->e_frm_out_mode; |
3073 | |
|
3074 | 0 | return ret; |
3075 | |
|
3076 | 0 | } |
3077 | | /** |
3078 | | ******************************************************************************* |
3079 | | * |
3080 | | * @brief |
3081 | | * Resets the decoder state |
3082 | | * |
3083 | | * @par Description: |
3084 | | * Resets the decoder state by calling ihevcd_init() |
3085 | | * |
3086 | | * @param[in] ps_codec_obj |
3087 | | * Pointer to codec object at API level |
3088 | | * |
3089 | | * @param[in] pv_api_ip |
3090 | | * Pointer to input argument structure |
3091 | | * |
3092 | | * @param[out] pv_api_op |
3093 | | * Pointer to output argument structure |
3094 | | * |
3095 | | * @returns Status |
3096 | | * |
3097 | | * @remarks |
3098 | | * |
3099 | | * |
3100 | | ******************************************************************************* |
3101 | | */ |
3102 | | WORD32 ihevcd_reset(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) |
3103 | 0 | { |
3104 | 0 | codec_t *ps_codec; |
3105 | 0 | ivd_ctl_reset_op_t *s_ctl_reset_op = (ivd_ctl_reset_op_t *)pv_api_op; |
3106 | 0 | UNUSED(pv_api_ip); |
3107 | 0 | ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); |
3108 | |
|
3109 | 0 | if(ps_codec != NULL) |
3110 | 0 | { |
3111 | 0 | DEBUG("\nReset called \n"); |
3112 | 0 | ihevcd_join_threads(ps_codec); |
3113 | |
|
3114 | 0 | ihevcd_init(ps_codec); |
3115 | 0 | } |
3116 | 0 | else |
3117 | 0 | { |
3118 | 0 | DEBUG("\nReset called without Initializing the decoder\n"); |
3119 | 0 | s_ctl_reset_op->u4_error_code = IHEVCD_INIT_NOT_DONE; |
3120 | 0 | } |
3121 | |
|
3122 | 0 | return IV_SUCCESS; |
3123 | 0 | } |
3124 | | |
3125 | | /** |
3126 | | ******************************************************************************* |
3127 | | * |
3128 | | * @brief |
3129 | | * Releases display buffer from application to codec to signal to the codec |
3130 | | * that it can write to this buffer if required. Till release is called, |
3131 | | * codec can not write to this buffer |
3132 | | * |
3133 | | * @par Description: |
3134 | | * Marks the buffer as display done |
3135 | | * |
3136 | | * @param[in] ps_codec_obj |
3137 | | * Pointer to codec object at API level |
3138 | | * |
3139 | | * @param[in] pv_api_ip |
3140 | | * Pointer to input argument structure |
3141 | | * |
3142 | | * @param[out] pv_api_op |
3143 | | * Pointer to output argument structure |
3144 | | * |
3145 | | * @returns Status |
3146 | | * |
3147 | | * @remarks |
3148 | | * |
3149 | | * |
3150 | | ******************************************************************************* |
3151 | | */ |
3152 | | |
3153 | | WORD32 ihevcd_rel_display_frame(iv_obj_t *ps_codec_obj, |
3154 | | void *pv_api_ip, |
3155 | | void *pv_api_op) |
3156 | 0 | { |
3157 | |
|
3158 | 0 | ivd_rel_display_frame_ip_t *ps_dec_rel_disp_ip; |
3159 | 0 | ivd_rel_display_frame_op_t *ps_dec_rel_disp_op; |
3160 | |
|
3161 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3162 | |
|
3163 | 0 | ps_dec_rel_disp_ip = (ivd_rel_display_frame_ip_t *)pv_api_ip; |
3164 | 0 | ps_dec_rel_disp_op = (ivd_rel_display_frame_op_t *)pv_api_op; |
3165 | |
|
3166 | 0 | UNUSED(ps_dec_rel_disp_op); |
3167 | |
|
3168 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
3169 | 0 | { |
3170 | 0 | return IV_SUCCESS; |
3171 | 0 | } |
3172 | | |
3173 | 0 | ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, ps_dec_rel_disp_ip->u4_disp_buf_id, BUF_MGR_DISP); |
3174 | |
|
3175 | 0 | return IV_SUCCESS; |
3176 | 0 | } |
3177 | | /** |
3178 | | ******************************************************************************* |
3179 | | * |
3180 | | * @brief |
3181 | | * Sets degrade params |
3182 | | * |
3183 | | * @par Description: |
3184 | | * Sets degrade params. |
3185 | | * Refer to ihevcd_cxa_ctl_degrade_ip_t definition for details |
3186 | | * |
3187 | | * @param[in] ps_codec_obj |
3188 | | * Pointer to codec object at API level |
3189 | | * |
3190 | | * @param[in] pv_api_ip |
3191 | | * Pointer to input argument structure |
3192 | | * |
3193 | | * @param[out] pv_api_op |
3194 | | * Pointer to output argument structure |
3195 | | * |
3196 | | * @returns Status |
3197 | | * |
3198 | | * @remarks |
3199 | | * |
3200 | | * |
3201 | | ******************************************************************************* |
3202 | | */ |
3203 | | |
3204 | | WORD32 ihevcd_set_degrade(iv_obj_t *ps_codec_obj, |
3205 | | void *pv_api_ip, |
3206 | | void *pv_api_op) |
3207 | 0 | { |
3208 | 0 | ihevcd_cxa_ctl_degrade_ip_t *ps_ip; |
3209 | 0 | ihevcd_cxa_ctl_degrade_op_t *ps_op; |
3210 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3211 | |
|
3212 | 0 | ps_ip = (ihevcd_cxa_ctl_degrade_ip_t *)pv_api_ip; |
3213 | 0 | ps_op = (ihevcd_cxa_ctl_degrade_op_t *)pv_api_op; |
3214 | |
|
3215 | 0 | ps_codec->i4_degrade_type = ps_ip->i4_degrade_type; |
3216 | 0 | ps_codec->i4_nondegrade_interval = ps_ip->i4_nondegrade_interval; |
3217 | 0 | ps_codec->i4_degrade_pics = ps_ip->i4_degrade_pics; |
3218 | |
|
3219 | 0 | ps_op->u4_error_code = 0; |
3220 | 0 | ps_codec->i4_degrade_pic_cnt = 0; |
3221 | |
|
3222 | 0 | return IV_SUCCESS; |
3223 | 0 | } |
3224 | | |
3225 | | |
3226 | | /** |
3227 | | ******************************************************************************* |
3228 | | * |
3229 | | * @brief |
3230 | | * Gets frame dimensions/offsets |
3231 | | * |
3232 | | * @par Description: |
3233 | | * Gets frame buffer chararacteristics such a x & y offsets display and |
3234 | | * buffer dimensions |
3235 | | * |
3236 | | * @param[in] ps_codec_obj |
3237 | | * Pointer to codec object at API level |
3238 | | * |
3239 | | * @param[in] pv_api_ip |
3240 | | * Pointer to input argument structure |
3241 | | * |
3242 | | * @param[out] pv_api_op |
3243 | | * Pointer to output argument structure |
3244 | | * |
3245 | | * @returns Status |
3246 | | * |
3247 | | * @remarks |
3248 | | * |
3249 | | * |
3250 | | ******************************************************************************* |
3251 | | */ |
3252 | | |
3253 | | WORD32 ihevcd_get_frame_dimensions(iv_obj_t *ps_codec_obj, |
3254 | | void *pv_api_ip, |
3255 | | void *pv_api_op) |
3256 | 0 | { |
3257 | 0 | ihevcd_cxa_ctl_get_frame_dimensions_ip_t *ps_ip; |
3258 | 0 | ihevcd_cxa_ctl_get_frame_dimensions_op_t *ps_op; |
3259 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3260 | 0 | WORD32 disp_wd, disp_ht, buffer_wd, buffer_ht, x_offset, y_offset; |
3261 | 0 | ps_ip = (ihevcd_cxa_ctl_get_frame_dimensions_ip_t *)pv_api_ip; |
3262 | 0 | ps_op = (ihevcd_cxa_ctl_get_frame_dimensions_op_t *)pv_api_op; |
3263 | 0 | UNUSED(ps_ip); |
3264 | 0 | if(ps_codec->i4_sps_done) |
3265 | 0 | { |
3266 | 0 | disp_wd = ps_codec->i4_disp_wd; |
3267 | 0 | disp_ht = ps_codec->i4_disp_ht; |
3268 | |
|
3269 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
3270 | 0 | { |
3271 | 0 | buffer_wd = disp_wd; |
3272 | 0 | buffer_ht = disp_ht; |
3273 | 0 | } |
3274 | 0 | else |
3275 | 0 | { |
3276 | 0 | buffer_wd = ps_codec->i4_strd; |
3277 | 0 | buffer_ht = ps_codec->i4_ht + PAD_HT; |
3278 | 0 | } |
3279 | 0 | } |
3280 | 0 | else |
3281 | 0 | { |
3282 | |
|
3283 | 0 | disp_wd = 0; |
3284 | 0 | disp_ht = 0; |
3285 | |
|
3286 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
3287 | 0 | { |
3288 | 0 | buffer_wd = disp_wd; |
3289 | 0 | buffer_ht = disp_ht; |
3290 | 0 | } |
3291 | 0 | else |
3292 | 0 | { |
3293 | 0 | buffer_wd = ALIGN16(disp_wd) + PAD_WD; |
3294 | 0 | buffer_ht = ALIGN16(disp_ht) + PAD_HT; |
3295 | |
|
3296 | 0 | } |
3297 | 0 | } |
3298 | 0 | if(ps_codec->i4_strd > buffer_wd) |
3299 | 0 | buffer_wd = ps_codec->i4_strd; |
3300 | |
|
3301 | 0 | if(0 == ps_codec->i4_share_disp_buf) |
3302 | 0 | { |
3303 | 0 | x_offset = 0; |
3304 | 0 | y_offset = 0; |
3305 | 0 | } |
3306 | 0 | else |
3307 | 0 | { |
3308 | 0 | y_offset = PAD_TOP; |
3309 | 0 | x_offset = PAD_LEFT; |
3310 | 0 | } |
3311 | |
|
3312 | 0 | ps_op->u4_disp_wd[0] = disp_wd; |
3313 | 0 | ps_op->u4_disp_ht[0] = disp_ht; |
3314 | 0 | ps_op->u4_buffer_wd[0] = buffer_wd; |
3315 | 0 | ps_op->u4_buffer_ht[0] = buffer_ht; |
3316 | 0 | ps_op->u4_x_offset[0] = x_offset; |
3317 | 0 | ps_op->u4_y_offset[0] = y_offset; |
3318 | |
|
3319 | 0 | ps_op->u4_disp_wd[1] = ps_op->u4_disp_wd[2] = ((ps_op->u4_disp_wd[0] + 1) >> 1); |
3320 | 0 | ps_op->u4_disp_ht[1] = ps_op->u4_disp_ht[2] = ((ps_op->u4_disp_ht[0] + 1) >> 1); |
3321 | 0 | ps_op->u4_buffer_wd[1] = ps_op->u4_buffer_wd[2] = ((ps_op->u4_buffer_wd[0] + 1) >> 1); |
3322 | 0 | ps_op->u4_buffer_ht[1] = ps_op->u4_buffer_ht[2] = ((ps_op->u4_buffer_ht[0] + 1) >> 1); |
3323 | 0 | ps_op->u4_x_offset[1] = ps_op->u4_x_offset[2] = (ps_op->u4_x_offset[0] >> 1); |
3324 | 0 | ps_op->u4_y_offset[1] = ps_op->u4_y_offset[2] = (ps_op->u4_y_offset[0] >> 1); |
3325 | |
|
3326 | 0 | if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV) |
3327 | 0 | || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU)) |
3328 | 0 | { |
3329 | 0 | ps_op->u4_disp_wd[2] = 0; |
3330 | 0 | ps_op->u4_disp_ht[2] = 0; |
3331 | 0 | ps_op->u4_buffer_wd[2] = 0; |
3332 | 0 | ps_op->u4_buffer_ht[2] = 0; |
3333 | 0 | ps_op->u4_x_offset[2] = 0; |
3334 | 0 | ps_op->u4_y_offset[2] = 0; |
3335 | |
|
3336 | 0 | ps_op->u4_disp_wd[1] <<= 1; |
3337 | 0 | ps_op->u4_buffer_wd[1] <<= 1; |
3338 | 0 | ps_op->u4_x_offset[1] <<= 1; |
3339 | 0 | } |
3340 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_444P) |
3341 | 0 | { |
3342 | 0 | ps_op->u4_disp_wd[1] = ps_op->u4_disp_wd[2] = ps_op->u4_disp_wd[0]; |
3343 | 0 | ps_op->u4_disp_ht[1] = ps_op->u4_disp_ht[2] = ps_op->u4_disp_ht[0]; |
3344 | 0 | ps_op->u4_buffer_wd[1] = ps_op->u4_buffer_wd[2] = ps_op->u4_buffer_wd[0]; |
3345 | 0 | ps_op->u4_buffer_ht[1] = ps_op->u4_buffer_ht[2] = ps_op->u4_buffer_ht[0]; |
3346 | 0 | ps_op->u4_x_offset[1] = ps_op->u4_x_offset[2] = ps_op->u4_x_offset[0]; |
3347 | 0 | ps_op->u4_y_offset[1] = ps_op->u4_y_offset[2] = ps_op->u4_y_offset[0]; |
3348 | 0 | } |
3349 | 0 | else if(ps_codec->e_chroma_fmt == IV_YUV_422P) |
3350 | 0 | { |
3351 | 0 | ps_op->u4_disp_ht[1] = ps_op->u4_disp_ht[2] = ps_op->u4_disp_ht[0]; |
3352 | 0 | ps_op->u4_buffer_ht[1] = ps_op->u4_buffer_ht[2] = ps_op->u4_buffer_ht[0]; |
3353 | 0 | ps_op->u4_y_offset[1] = ps_op->u4_y_offset[2] = ps_op->u4_y_offset[0]; |
3354 | 0 | } |
3355 | 0 | else if(ps_codec->e_chroma_fmt == IV_GRAY) |
3356 | 0 | { |
3357 | 0 | ps_op->u4_disp_wd[1] = ps_op->u4_disp_wd[2] = 0; |
3358 | 0 | ps_op->u4_disp_ht[1] = ps_op->u4_disp_ht[2] = 0; |
3359 | 0 | ps_op->u4_buffer_wd[1] = ps_op->u4_buffer_wd[2] = 0; |
3360 | 0 | ps_op->u4_buffer_ht[1] = ps_op->u4_buffer_ht[2] = 0; |
3361 | 0 | ps_op->u4_x_offset[1] = ps_op->u4_x_offset[2] = 0; |
3362 | 0 | ps_op->u4_y_offset[1] = ps_op->u4_y_offset[2] = 0; |
3363 | 0 | } |
3364 | |
|
3365 | 0 | return IV_SUCCESS; |
3366 | |
|
3367 | 0 | } |
3368 | | |
3369 | | |
3370 | | /** |
3371 | | ******************************************************************************* |
3372 | | * |
3373 | | * @brief |
3374 | | * Gets vui parameters |
3375 | | * |
3376 | | * @par Description: |
3377 | | * Gets VUI parameters |
3378 | | * |
3379 | | * @param[in] ps_codec_obj |
3380 | | * Pointer to codec object at API level |
3381 | | * |
3382 | | * @param[in] pv_api_ip |
3383 | | * Pointer to input argument structure |
3384 | | * |
3385 | | * @param[out] pv_api_op |
3386 | | * Pointer to output argument structure |
3387 | | * |
3388 | | * @returns Status |
3389 | | * |
3390 | | * @remarks |
3391 | | * |
3392 | | * |
3393 | | ******************************************************************************* |
3394 | | */ |
3395 | | WORD32 ihevcd_get_vui_params(iv_obj_t *ps_codec_obj, |
3396 | | void *pv_api_ip, |
3397 | | void *pv_api_op) |
3398 | 0 | { |
3399 | 0 | ihevcd_cxa_ctl_get_vui_params_ip_t *ps_ip; |
3400 | 0 | ihevcd_cxa_ctl_get_vui_params_op_t *ps_op; |
3401 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3402 | 0 | sps_t *ps_sps; |
3403 | 0 | vui_t *ps_vui; |
3404 | 0 | WORD32 i; |
3405 | |
|
3406 | 0 | ps_ip = (ihevcd_cxa_ctl_get_vui_params_ip_t *)pv_api_ip; |
3407 | 0 | ps_op = (ihevcd_cxa_ctl_get_vui_params_op_t *)pv_api_op; |
3408 | |
|
3409 | 0 | if(0 == ps_codec->i4_sps_done) |
3410 | 0 | { |
3411 | 0 | ps_op->u4_error_code = IHEVCD_VUI_PARAMS_NOT_FOUND; |
3412 | 0 | return IV_FAIL; |
3413 | 0 | } |
3414 | | |
3415 | 0 | ps_sps = ps_codec->s_parse.ps_sps; |
3416 | 0 | if(0 == ps_sps->i1_sps_valid || 0 == ps_sps->i1_vui_parameters_present_flag) |
3417 | 0 | { |
3418 | 0 | WORD32 sps_idx = 0; |
3419 | 0 | ps_sps = ps_codec->ps_sps_base; |
3420 | |
|
3421 | 0 | while((0 == ps_sps->i1_sps_valid) || (0 == ps_sps->i1_vui_parameters_present_flag)) |
3422 | 0 | { |
3423 | 0 | sps_idx++; |
3424 | 0 | ps_sps++; |
3425 | |
|
3426 | 0 | if(sps_idx == MAX_SPS_CNT - 1) |
3427 | 0 | { |
3428 | 0 | ps_op->u4_error_code = IHEVCD_VUI_PARAMS_NOT_FOUND; |
3429 | 0 | return IV_FAIL; |
3430 | 0 | } |
3431 | 0 | } |
3432 | 0 | } |
3433 | | |
3434 | 0 | ps_vui = &ps_sps->s_vui_parameters; |
3435 | 0 | UNUSED(ps_ip); |
3436 | |
|
3437 | 0 | ps_op->u1_aspect_ratio_info_present_flag = ps_vui->u1_aspect_ratio_info_present_flag; |
3438 | 0 | ps_op->u1_aspect_ratio_idc = ps_vui->u1_aspect_ratio_idc; |
3439 | 0 | ps_op->u2_sar_width = ps_vui->u2_sar_width; |
3440 | 0 | ps_op->u2_sar_height = ps_vui->u2_sar_height; |
3441 | 0 | ps_op->u1_overscan_info_present_flag = ps_vui->u1_overscan_info_present_flag; |
3442 | 0 | ps_op->u1_overscan_appropriate_flag = ps_vui->u1_overscan_appropriate_flag; |
3443 | 0 | ps_op->u1_video_signal_type_present_flag = ps_vui->u1_video_signal_type_present_flag; |
3444 | 0 | ps_op->u1_video_format = ps_vui->u1_video_format; |
3445 | 0 | ps_op->u1_video_full_range_flag = ps_vui->u1_video_full_range_flag; |
3446 | 0 | ps_op->u1_colour_description_present_flag = ps_vui->u1_colour_description_present_flag; |
3447 | 0 | ps_op->u1_colour_primaries = ps_vui->u1_colour_primaries; |
3448 | 0 | ps_op->u1_transfer_characteristics = ps_vui->u1_transfer_characteristics; |
3449 | 0 | ps_op->u1_matrix_coefficients = ps_vui->u1_matrix_coefficients; |
3450 | 0 | ps_op->u1_chroma_loc_info_present_flag = ps_vui->u1_chroma_loc_info_present_flag; |
3451 | 0 | ps_op->u1_chroma_sample_loc_type_top_field = ps_vui->u1_chroma_sample_loc_type_top_field; |
3452 | 0 | ps_op->u1_chroma_sample_loc_type_bottom_field = ps_vui->u1_chroma_sample_loc_type_bottom_field; |
3453 | 0 | ps_op->u1_neutral_chroma_indication_flag = ps_vui->u1_neutral_chroma_indication_flag; |
3454 | 0 | ps_op->u1_field_seq_flag = ps_vui->u1_field_seq_flag; |
3455 | 0 | ps_op->u1_frame_field_info_present_flag = ps_vui->u1_frame_field_info_present_flag; |
3456 | 0 | ps_op->u1_default_display_window_flag = ps_vui->u1_default_display_window_flag; |
3457 | 0 | ps_op->u4_def_disp_win_left_offset = ps_vui->u4_def_disp_win_left_offset; |
3458 | 0 | ps_op->u4_def_disp_win_right_offset = ps_vui->u4_def_disp_win_right_offset; |
3459 | 0 | ps_op->u4_def_disp_win_top_offset = ps_vui->u4_def_disp_win_top_offset; |
3460 | 0 | ps_op->u4_def_disp_win_bottom_offset = ps_vui->u4_def_disp_win_bottom_offset; |
3461 | 0 | ps_op->u1_vui_hrd_parameters_present_flag = ps_vui->u1_vui_hrd_parameters_present_flag; |
3462 | 0 | ps_op->u1_vui_timing_info_present_flag = ps_vui->u1_vui_timing_info_present_flag; |
3463 | 0 | ps_op->u4_vui_num_units_in_tick = ps_vui->u4_vui_num_units_in_tick; |
3464 | 0 | ps_op->u4_vui_time_scale = ps_vui->u4_vui_time_scale; |
3465 | 0 | ps_op->u1_poc_proportional_to_timing_flag = ps_vui->u1_poc_proportional_to_timing_flag; |
3466 | 0 | ps_op->u4_num_ticks_poc_diff_one_minus1 = ps_vui->u4_num_ticks_poc_diff_one_minus1; |
3467 | 0 | ps_op->u1_bitstream_restriction_flag = ps_vui->u1_bitstream_restriction_flag; |
3468 | 0 | ps_op->u1_tiles_fixed_structure_flag = ps_vui->u1_tiles_fixed_structure_flag; |
3469 | 0 | ps_op->u1_motion_vectors_over_pic_boundaries_flag = ps_vui->u1_motion_vectors_over_pic_boundaries_flag; |
3470 | 0 | ps_op->u1_restricted_ref_pic_lists_flag = ps_vui->u1_restricted_ref_pic_lists_flag; |
3471 | 0 | ps_op->u4_min_spatial_segmentation_idc = ps_vui->u4_min_spatial_segmentation_idc; |
3472 | 0 | ps_op->u1_max_bytes_per_pic_denom = ps_vui->u1_max_bytes_per_pic_denom; |
3473 | 0 | ps_op->u1_max_bits_per_mincu_denom = ps_vui->u1_max_bits_per_mincu_denom; |
3474 | 0 | ps_op->u1_log2_max_mv_length_horizontal = ps_vui->u1_log2_max_mv_length_horizontal; |
3475 | 0 | ps_op->u1_log2_max_mv_length_vertical = ps_vui->u1_log2_max_mv_length_vertical; |
3476 | | |
3477 | | |
3478 | | /* HRD parameters */ |
3479 | 0 | ps_op->u1_timing_info_present_flag = ps_vui->s_vui_hrd_parameters.u1_timing_info_present_flag; |
3480 | 0 | ps_op->u4_num_units_in_tick = ps_vui->s_vui_hrd_parameters.u4_num_units_in_tick; |
3481 | 0 | ps_op->u4_time_scale = ps_vui->s_vui_hrd_parameters.u4_time_scale; |
3482 | 0 | ps_op->u1_nal_hrd_parameters_present_flag = ps_vui->s_vui_hrd_parameters.u1_nal_hrd_parameters_present_flag; |
3483 | 0 | ps_op->u1_vcl_hrd_parameters_present_flag = ps_vui->s_vui_hrd_parameters.u1_vcl_hrd_parameters_present_flag; |
3484 | 0 | ps_op->u1_cpbdpb_delays_present_flag = ps_vui->s_vui_hrd_parameters.u1_cpbdpb_delays_present_flag; |
3485 | 0 | ps_op->u1_sub_pic_cpb_params_present_flag = ps_vui->s_vui_hrd_parameters.u1_sub_pic_cpb_params_present_flag; |
3486 | 0 | ps_op->u1_tick_divisor_minus2 = ps_vui->s_vui_hrd_parameters.u1_tick_divisor_minus2; |
3487 | 0 | ps_op->u1_du_cpb_removal_delay_increment_length_minus1 = ps_vui->s_vui_hrd_parameters.u1_du_cpb_removal_delay_increment_length_minus1; |
3488 | 0 | ps_op->u1_sub_pic_cpb_params_in_pic_timing_sei_flag = ps_vui->s_vui_hrd_parameters.u1_sub_pic_cpb_params_in_pic_timing_sei_flag; |
3489 | 0 | ps_op->u1_dpb_output_delay_du_length_minus1 = ps_vui->s_vui_hrd_parameters.u1_dpb_output_delay_du_length_minus1; |
3490 | 0 | ps_op->u4_bit_rate_scale = ps_vui->s_vui_hrd_parameters.u4_bit_rate_scale; |
3491 | 0 | ps_op->u4_cpb_size_scale = ps_vui->s_vui_hrd_parameters.u4_cpb_size_scale; |
3492 | 0 | ps_op->u4_cpb_size_du_scale = ps_vui->s_vui_hrd_parameters.u4_cpb_size_du_scale; |
3493 | 0 | ps_op->u1_initial_cpb_removal_delay_length_minus1 = ps_vui->s_vui_hrd_parameters.u1_initial_cpb_removal_delay_length_minus1; |
3494 | 0 | ps_op->u1_au_cpb_removal_delay_length_minus1 = ps_vui->s_vui_hrd_parameters.u1_au_cpb_removal_delay_length_minus1; |
3495 | 0 | ps_op->u1_dpb_output_delay_length_minus1 = ps_vui->s_vui_hrd_parameters.u1_dpb_output_delay_length_minus1; |
3496 | |
|
3497 | 0 | for(i = 0; i < 6; i++) |
3498 | 0 | { |
3499 | 0 | ps_op->au1_fixed_pic_rate_general_flag[i] = ps_vui->s_vui_hrd_parameters.au1_fixed_pic_rate_general_flag[i]; |
3500 | 0 | ps_op->au1_fixed_pic_rate_within_cvs_flag[i] = ps_vui->s_vui_hrd_parameters.au1_fixed_pic_rate_within_cvs_flag[i]; |
3501 | 0 | ps_op->au2_elemental_duration_in_tc_minus1[i] = ps_vui->s_vui_hrd_parameters.au2_elemental_duration_in_tc_minus1[i]; |
3502 | 0 | ps_op->au1_low_delay_hrd_flag[i] = ps_vui->s_vui_hrd_parameters.au1_low_delay_hrd_flag[i]; |
3503 | 0 | ps_op->au1_cpb_cnt_minus1[i] = ps_vui->s_vui_hrd_parameters.au1_cpb_cnt_minus1[i]; |
3504 | 0 | } |
3505 | | |
3506 | |
|
3507 | 0 | return IV_SUCCESS; |
3508 | 0 | } |
3509 | | |
3510 | | #ifndef DISABLE_SEI |
3511 | | /** |
3512 | | ******************************************************************************* |
3513 | | * |
3514 | | * @brief |
3515 | | * Gets SEI mastering display color volume parameters |
3516 | | * |
3517 | | * @par Description: |
3518 | | * Gets SEI mastering display color volume parameters |
3519 | | * |
3520 | | * @param[in] ps_codec_obj |
3521 | | * Pointer to codec object at API level |
3522 | | * |
3523 | | * @param[in] pv_api_ip |
3524 | | * Pointer to input argument structure |
3525 | | * |
3526 | | * @param[out] pv_api_op |
3527 | | * Pointer to output argument structure |
3528 | | * |
3529 | | * @returns Status |
3530 | | * |
3531 | | * @remarks |
3532 | | * |
3533 | | * |
3534 | | ******************************************************************************* |
3535 | | */ |
3536 | | WORD32 ihevcd_get_sei_mastering_params(iv_obj_t *ps_codec_obj, |
3537 | | void *pv_api_ip, |
3538 | | void *pv_api_op) |
3539 | 0 | { |
3540 | 0 | ihevcd_cxa_ctl_get_sei_mastering_params_ip_t *ps_ip; |
3541 | 0 | ihevcd_cxa_ctl_get_sei_mastering_params_op_t *ps_op; |
3542 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3543 | 0 | sei_params_t *ps_sei; |
3544 | 0 | mastering_dis_col_vol_sei_params_t *ps_mastering_dis_col_vol; |
3545 | 0 | WORD32 i; |
3546 | |
|
3547 | 0 | ps_ip = (ihevcd_cxa_ctl_get_sei_mastering_params_ip_t *)pv_api_ip; |
3548 | 0 | ps_op = (ihevcd_cxa_ctl_get_sei_mastering_params_op_t *)pv_api_op; |
3549 | 0 | UNUSED(ps_ip); |
3550 | 0 | if(NULL == ps_codec->ps_disp_buf) |
3551 | 0 | { |
3552 | 0 | ps_op->u4_error_code = IHEVCD_SEI_MASTERING_PARAMS_NOT_FOUND; |
3553 | 0 | return IV_FAIL; |
3554 | 0 | } |
3555 | 0 | ps_sei = &ps_codec->ps_disp_buf->s_sei_params; |
3556 | 0 | if((0 == ps_sei->i4_sei_mastering_disp_colour_vol_params_present_flags) |
3557 | 0 | || (0 == ps_sei->i1_sei_parameters_present_flag)) |
3558 | 0 | { |
3559 | 0 | ps_op->u4_error_code = IHEVCD_SEI_MASTERING_PARAMS_NOT_FOUND; |
3560 | 0 | return IV_FAIL; |
3561 | 0 | } |
3562 | | |
3563 | 0 | ps_mastering_dis_col_vol = &ps_sei->s_mastering_dis_col_vol_sei_params; |
3564 | |
|
3565 | 0 | for(i = 0; i < 3; i++) |
3566 | 0 | { |
3567 | 0 | ps_op->au2_display_primaries_x[i] = |
3568 | 0 | ps_mastering_dis_col_vol->au2_display_primaries_x[i]; |
3569 | |
|
3570 | 0 | ps_op->au2_display_primaries_y[i] = |
3571 | 0 | ps_mastering_dis_col_vol->au2_display_primaries_y[i]; |
3572 | 0 | } |
3573 | |
|
3574 | 0 | ps_op->u2_white_point_x = ps_mastering_dis_col_vol->u2_white_point_x; |
3575 | |
|
3576 | 0 | ps_op->u2_white_point_y = ps_mastering_dis_col_vol->u2_white_point_y; |
3577 | |
|
3578 | 0 | ps_op->u4_max_display_mastering_luminance = |
3579 | 0 | ps_mastering_dis_col_vol->u4_max_display_mastering_luminance; |
3580 | |
|
3581 | 0 | ps_op->u4_min_display_mastering_luminance = |
3582 | 0 | ps_mastering_dis_col_vol->u4_min_display_mastering_luminance; |
3583 | |
|
3584 | 0 | return IV_SUCCESS; |
3585 | 0 | } |
3586 | | #endif |
3587 | | |
3588 | | /** |
3589 | | ******************************************************************************* |
3590 | | * |
3591 | | * @brief |
3592 | | * Sets Processor type |
3593 | | * |
3594 | | * @par Description: |
3595 | | * Sets Processor type |
3596 | | * |
3597 | | * @param[in] ps_codec_obj |
3598 | | * Pointer to codec object at API level |
3599 | | * |
3600 | | * @param[in] pv_api_ip |
3601 | | * Pointer to input argument structure |
3602 | | * |
3603 | | * @param[out] pv_api_op |
3604 | | * Pointer to output argument structure |
3605 | | * |
3606 | | * @returns Status |
3607 | | * |
3608 | | * @remarks |
3609 | | * |
3610 | | * |
3611 | | ******************************************************************************* |
3612 | | */ |
3613 | | |
3614 | | WORD32 ihevcd_set_processor(iv_obj_t *ps_codec_obj, |
3615 | | void *pv_api_ip, |
3616 | | void *pv_api_op) |
3617 | 0 | { |
3618 | 0 | ihevcd_cxa_ctl_set_processor_ip_t *ps_ip; |
3619 | 0 | ihevcd_cxa_ctl_set_processor_op_t *ps_op; |
3620 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3621 | |
|
3622 | 0 | ps_ip = (ihevcd_cxa_ctl_set_processor_ip_t *)pv_api_ip; |
3623 | 0 | ps_op = (ihevcd_cxa_ctl_set_processor_op_t *)pv_api_op; |
3624 | |
|
3625 | 0 | ps_codec->e_processor_arch = (IV_ARCH_T)ps_ip->u4_arch; |
3626 | 0 | ps_codec->e_processor_soc = (IV_SOC_T)ps_ip->u4_soc; |
3627 | |
|
3628 | 0 | ihevcd_init_function_ptr(ps_codec); |
3629 | |
|
3630 | 0 | ihevcd_update_function_ptr(ps_codec); |
3631 | |
|
3632 | 0 | if(ps_codec->e_processor_soc && (ps_codec->e_processor_soc <= SOC_HISI_37X)) |
3633 | 0 | { |
3634 | | /* 8th bit indicates if format conversion is to be done ahead */ |
3635 | 0 | if(ps_codec->e_processor_soc & 0x80) |
3636 | 0 | ps_codec->u4_enable_fmt_conv_ahead = 1; |
3637 | | |
3638 | | /* Lower 7 bit indicate NCTB - if non-zero */ |
3639 | 0 | ps_codec->e_processor_soc &= 0x7F; |
3640 | |
|
3641 | 0 | if(ps_codec->e_processor_soc) |
3642 | 0 | ps_codec->u4_nctb = ps_codec->e_processor_soc; |
3643 | | |
3644 | |
|
3645 | 0 | } |
3646 | |
|
3647 | 0 | if((ps_codec->e_processor_soc == SOC_HISI_37X) && (ps_codec->i4_num_cores == 2)) |
3648 | 0 | { |
3649 | 0 | ps_codec->u4_nctb = 2; |
3650 | 0 | } |
3651 | | |
3652 | |
|
3653 | 0 | ps_op->u4_error_code = 0; |
3654 | 0 | return IV_SUCCESS; |
3655 | 0 | } |
3656 | | |
3657 | | /** |
3658 | | ******************************************************************************* |
3659 | | * |
3660 | | * @brief |
3661 | | * Sets Number of cores that can be used in the codec. Codec uses these many |
3662 | | * threads for decoding |
3663 | | * |
3664 | | * @par Description: |
3665 | | * Sets number of cores |
3666 | | * |
3667 | | * @param[in] ps_codec_obj |
3668 | | * Pointer to codec object at API level |
3669 | | * |
3670 | | * @param[in] pv_api_ip |
3671 | | * Pointer to input argument structure |
3672 | | * |
3673 | | * @param[out] pv_api_op |
3674 | | * Pointer to output argument structure |
3675 | | * |
3676 | | * @returns Status |
3677 | | * |
3678 | | * @remarks |
3679 | | * |
3680 | | * |
3681 | | ******************************************************************************* |
3682 | | */ |
3683 | | |
3684 | | WORD32 ihevcd_set_num_cores(iv_obj_t *ps_codec_obj, |
3685 | | void *pv_api_ip, |
3686 | | void *pv_api_op) |
3687 | 0 | { |
3688 | 0 | ihevcd_cxa_ctl_set_num_cores_ip_t *ps_ip; |
3689 | 0 | ihevcd_cxa_ctl_set_num_cores_op_t *ps_op; |
3690 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3691 | |
|
3692 | 0 | ps_ip = (ihevcd_cxa_ctl_set_num_cores_ip_t *)pv_api_ip; |
3693 | 0 | ps_op = (ihevcd_cxa_ctl_set_num_cores_op_t *)pv_api_op; |
3694 | |
|
3695 | 0 | ps_codec->i4_num_cores = ps_ip->u4_num_cores; |
3696 | 0 | ps_op->u4_error_code = 0; |
3697 | 0 | return IV_SUCCESS; |
3698 | 0 | } |
3699 | | /** |
3700 | | ******************************************************************************* |
3701 | | * |
3702 | | * @brief |
3703 | | * Codec control call |
3704 | | * |
3705 | | * @par Description: |
3706 | | * Codec control call which in turn calls appropriate calls based on |
3707 | | * subcommand |
3708 | | * |
3709 | | * @param[in] ps_codec_obj |
3710 | | * Pointer to codec object at API level |
3711 | | * |
3712 | | * @param[in] pv_api_ip |
3713 | | * Pointer to input argument structure |
3714 | | * |
3715 | | * @param[out] pv_api_op |
3716 | | * Pointer to output argument structure |
3717 | | * |
3718 | | * @returns Status |
3719 | | * |
3720 | | * @remarks |
3721 | | * |
3722 | | * |
3723 | | ******************************************************************************* |
3724 | | */ |
3725 | | |
3726 | | WORD32 ihevcd_ctl(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) |
3727 | 0 | { |
3728 | 0 | ivd_ctl_set_config_ip_t *ps_ctl_ip; |
3729 | 0 | ivd_ctl_set_config_op_t *ps_ctl_op; |
3730 | 0 | WORD32 ret = 0; |
3731 | 0 | WORD32 subcommand; |
3732 | 0 | codec_t *ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle; |
3733 | |
|
3734 | 0 | ps_ctl_ip = (ivd_ctl_set_config_ip_t *)pv_api_ip; |
3735 | 0 | ps_ctl_op = (ivd_ctl_set_config_op_t *)pv_api_op; |
3736 | |
|
3737 | 0 | if(ps_codec->i4_init_done != 1) |
3738 | 0 | { |
3739 | 0 | ps_ctl_op->u4_error_code |= 1 << IVD_FATALERROR; |
3740 | 0 | ps_ctl_op->u4_error_code |= IHEVCD_INIT_NOT_DONE; |
3741 | 0 | return IV_FAIL; |
3742 | 0 | } |
3743 | 0 | subcommand = ps_ctl_ip->e_sub_cmd; |
3744 | |
|
3745 | 0 | switch(subcommand) |
3746 | 0 | { |
3747 | 0 | case IVD_CMD_CTL_GETPARAMS: |
3748 | 0 | ret = ihevcd_get_status(ps_codec_obj, (void *)pv_api_ip, |
3749 | 0 | (void *)pv_api_op); |
3750 | 0 | break; |
3751 | 0 | case IVD_CMD_CTL_SETPARAMS: |
3752 | 0 | ret = ihevcd_set_params(ps_codec_obj, (void *)pv_api_ip, |
3753 | 0 | (void *)pv_api_op); |
3754 | 0 | break; |
3755 | 0 | case IVD_CMD_CTL_RESET: |
3756 | 0 | ret = ihevcd_reset(ps_codec_obj, (void *)pv_api_ip, |
3757 | 0 | (void *)pv_api_op); |
3758 | 0 | break; |
3759 | 0 | case IVD_CMD_CTL_SETDEFAULT: |
3760 | 0 | { |
3761 | 0 | ivd_ctl_set_config_op_t *s_ctl_dynparams_op = |
3762 | 0 | (ivd_ctl_set_config_op_t *)pv_api_op; |
3763 | |
|
3764 | 0 | ret = ihevcd_set_default_params(ps_codec); |
3765 | 0 | if(IV_SUCCESS == ret) |
3766 | 0 | s_ctl_dynparams_op->u4_error_code = 0; |
3767 | 0 | break; |
3768 | 0 | } |
3769 | 0 | case IVD_CMD_CTL_FLUSH: |
3770 | 0 | ret = ihevcd_set_flush_mode(ps_codec_obj, (void *)pv_api_ip, |
3771 | 0 | (void *)pv_api_op); |
3772 | 0 | break; |
3773 | 0 | case IVD_CMD_CTL_GETBUFINFO: |
3774 | 0 | ret = ihevcd_get_buf_info(ps_codec_obj, (void *)pv_api_ip, |
3775 | 0 | (void *)pv_api_op); |
3776 | 0 | break; |
3777 | 0 | case IVD_CMD_CTL_GETVERSION: |
3778 | 0 | { |
3779 | 0 | ivd_ctl_getversioninfo_ip_t *ps_ip; |
3780 | 0 | ivd_ctl_getversioninfo_op_t *ps_op; |
3781 | 0 | IV_API_CALL_STATUS_T ret; |
3782 | 0 | ps_ip = (ivd_ctl_getversioninfo_ip_t *)pv_api_ip; |
3783 | 0 | ps_op = (ivd_ctl_getversioninfo_op_t *)pv_api_op; |
3784 | |
|
3785 | 0 | ps_op->u4_error_code = IV_SUCCESS; |
3786 | |
|
3787 | 0 | if((WORD32)ps_ip->u4_version_buffer_size <= 0) |
3788 | 0 | { |
3789 | 0 | ps_op->u4_error_code = IHEVCD_CXA_VERS_BUF_INSUFFICIENT; |
3790 | 0 | ret = IV_FAIL; |
3791 | 0 | } |
3792 | 0 | else |
3793 | 0 | { |
3794 | 0 | ret = ihevcd_get_version((CHAR *)ps_ip->pv_version_buffer, |
3795 | 0 | ps_ip->u4_version_buffer_size); |
3796 | 0 | if(ret != IV_SUCCESS) |
3797 | 0 | { |
3798 | 0 | ps_op->u4_error_code = IHEVCD_CXA_VERS_BUF_INSUFFICIENT; |
3799 | 0 | ret = IV_FAIL; |
3800 | 0 | } |
3801 | 0 | } |
3802 | 0 | } |
3803 | 0 | break; |
3804 | 0 | case IHEVCD_CXA_CMD_CTL_DEGRADE: |
3805 | 0 | ret = ihevcd_set_degrade(ps_codec_obj, (void *)pv_api_ip, |
3806 | 0 | (void *)pv_api_op); |
3807 | 0 | break; |
3808 | 0 | case IHEVCD_CXA_CMD_CTL_SET_NUM_CORES: |
3809 | 0 | ret = ihevcd_set_num_cores(ps_codec_obj, (void *)pv_api_ip, |
3810 | 0 | (void *)pv_api_op); |
3811 | 0 | break; |
3812 | 0 | case IHEVCD_CXA_CMD_CTL_GET_BUFFER_DIMENSIONS: |
3813 | 0 | ret = ihevcd_get_frame_dimensions(ps_codec_obj, (void *)pv_api_ip, |
3814 | 0 | (void *)pv_api_op); |
3815 | 0 | break; |
3816 | 0 | case IHEVCD_CXA_CMD_CTL_GET_VUI_PARAMS: |
3817 | 0 | ret = ihevcd_get_vui_params(ps_codec_obj, (void *)pv_api_ip, |
3818 | 0 | (void *)pv_api_op); |
3819 | 0 | break; |
3820 | 0 | case IHEVCD_CXA_CMD_CTL_GET_SEI_MASTERING_PARAMS: |
3821 | 0 | #ifndef DISABLE_SEI |
3822 | 0 | ret = ihevcd_get_sei_mastering_params(ps_codec_obj, (void *)pv_api_ip, |
3823 | 0 | (void *)pv_api_op); |
3824 | | #else |
3825 | | { |
3826 | | ihevcd_cxa_ctl_get_sei_mastering_params_op_t *ps_op = |
3827 | | (ihevcd_cxa_ctl_get_sei_mastering_params_op_t *)pv_api_op; |
3828 | | ps_op->u4_error_code = IHEVCD_SEI_MASTERING_PARAMS_NOT_FOUND; |
3829 | | return IV_FAIL; |
3830 | | } |
3831 | | #endif |
3832 | 0 | break; |
3833 | 0 | case IHEVCD_CXA_CMD_CTL_SET_PROCESSOR: |
3834 | 0 | ret = ihevcd_set_processor(ps_codec_obj, (void *)pv_api_ip, |
3835 | 0 | (void *)pv_api_op); |
3836 | 0 | break; |
3837 | 0 | default: |
3838 | 0 | DEBUG("\nDo nothing\n"); |
3839 | 0 | break; |
3840 | 0 | } |
3841 | | |
3842 | 0 | return ret; |
3843 | 0 | } |
3844 | | |
3845 | | /** |
3846 | | ******************************************************************************* |
3847 | | * |
3848 | | * @brief |
3849 | | * Codecs entry point function. All the function calls to the codec are |
3850 | | * done using this function with different values specified in command |
3851 | | * |
3852 | | * @par Description: |
3853 | | * Arguments are tested for validity and then based on the command |
3854 | | * appropriate function is called |
3855 | | * |
3856 | | * @param[in] ps_handle |
3857 | | * API level handle for codec |
3858 | | * |
3859 | | * @param[in] pv_api_ip |
3860 | | * Input argument structure |
3861 | | * |
3862 | | * @param[out] pv_api_op |
3863 | | * Output argument structure |
3864 | | * |
3865 | | * @returns Status of the function corresponding to command |
3866 | | * |
3867 | | * @remarks |
3868 | | * |
3869 | | * |
3870 | | ******************************************************************************* |
3871 | | */ |
3872 | | IV_API_CALL_STATUS_T ihevcd_cxa_api_function(iv_obj_t *ps_handle, |
3873 | | void *pv_api_ip, |
3874 | | void *pv_api_op) |
3875 | 0 | { |
3876 | 0 | WORD32 command; |
3877 | 0 | UWORD32 *pu4_ptr_cmd; |
3878 | 0 | WORD32 ret = 0; |
3879 | 0 | IV_API_CALL_STATUS_T e_status; |
3880 | 0 | e_status = api_check_struct_sanity(ps_handle, pv_api_ip, pv_api_op); |
3881 | |
|
3882 | 0 | if(e_status != IV_SUCCESS) |
3883 | 0 | { |
3884 | 0 | DEBUG("error code = %d\n", *((UWORD32 *)pv_api_op + 1)); |
3885 | 0 | return IV_FAIL; |
3886 | 0 | } |
3887 | | |
3888 | 0 | pu4_ptr_cmd = (UWORD32 *)pv_api_ip; |
3889 | 0 | pu4_ptr_cmd++; |
3890 | |
|
3891 | 0 | command = *pu4_ptr_cmd; |
3892 | |
|
3893 | 0 | switch(command) |
3894 | 0 | { |
3895 | 0 | case IVD_CMD_CREATE: |
3896 | 0 | ret = ihevcd_create(ps_handle, (void *)pv_api_ip, (void *)pv_api_op); |
3897 | 0 | break; |
3898 | 0 | case IVD_CMD_DELETE: |
3899 | 0 | ret = ihevcd_delete(ps_handle, (void *)pv_api_ip, (void *)pv_api_op); |
3900 | 0 | break; |
3901 | | |
3902 | 0 | case IVD_CMD_VIDEO_DECODE: |
3903 | 0 | ret = ihevcd_decode(ps_handle, (void *)pv_api_ip, (void *)pv_api_op); |
3904 | 0 | break; |
3905 | | |
3906 | 0 | case IVD_CMD_GET_DISPLAY_FRAME: |
3907 | | //ret = ihevcd_get_display_frame(ps_handle,(void *)pv_api_ip,(void *)pv_api_op); |
3908 | 0 | break; |
3909 | | |
3910 | 0 | case IVD_CMD_SET_DISPLAY_FRAME: |
3911 | 0 | ret = ihevcd_set_display_frame(ps_handle, (void *)pv_api_ip, |
3912 | 0 | (void *)pv_api_op); |
3913 | |
|
3914 | 0 | break; |
3915 | | |
3916 | 0 | case IVD_CMD_REL_DISPLAY_FRAME: |
3917 | 0 | ret = ihevcd_rel_display_frame(ps_handle, (void *)pv_api_ip, |
3918 | 0 | (void *)pv_api_op); |
3919 | 0 | break; |
3920 | | |
3921 | 0 | case IVD_CMD_VIDEO_CTL: |
3922 | 0 | ret = ihevcd_ctl(ps_handle, (void *)pv_api_ip, (void *)pv_api_op); |
3923 | 0 | break; |
3924 | 0 | default: |
3925 | 0 | ret = IV_FAIL; |
3926 | 0 | break; |
3927 | 0 | } |
3928 | | |
3929 | 0 | return (IV_API_CALL_STATUS_T)ret; |
3930 | 0 | } |
3931 | | |