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