/src/libavc/encoder/ih264e_api.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2015 The Android Open Source Project |
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 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | |
21 | | /** |
22 | | ******************************************************************************* |
23 | | * @file |
24 | | * ih264e_api.c |
25 | | * |
26 | | * @brief |
27 | | * Contains api function definitions for H264 encoder |
28 | | * |
29 | | * @author |
30 | | * ittiam |
31 | | * |
32 | | * @par List of Functions: |
33 | | * - api_check_struct_sanity |
34 | | * - ih264e_codec_update_config |
35 | | * - ih264e_set_default_params |
36 | | * - ih264e_init |
37 | | * - ih264e_get_num_rec |
38 | | * - ih264e_fill_num_mem_rec |
39 | | * - ih264e_init_mem_rec |
40 | | * - ih264e_retrieve_memrec |
41 | | * - ih264e_set_flush_mode |
42 | | * - ih264e_get_buf_info |
43 | | * - ih264e_set_dimensions |
44 | | * - ih264e_set_frame_rate |
45 | | * - ih264e_set_bit_rate |
46 | | * - ih264e_set_frame_type |
47 | | * - ih264e_set_qp |
48 | | * - ih264e_set_enc_mode |
49 | | * - ih264e_set_vbv_params |
50 | | * - ih264_set_air_params |
51 | | * - ih264_set_me_params |
52 | | * - ih264_set_ipe_params |
53 | | * - ih264_set_gop_params |
54 | | * - ih264_set_profile_params |
55 | | * - ih264_set_deblock_params |
56 | | * - ih264e_set_num_cores |
57 | | * - ih264e_reset |
58 | | * - ih264e_ctl |
59 | | * - ih264e_api_function |
60 | | * |
61 | | * @remarks |
62 | | * none |
63 | | * |
64 | | ******************************************************************************* |
65 | | */ |
66 | | |
67 | | /*****************************************************************************/ |
68 | | /* File Includes */ |
69 | | /*****************************************************************************/ |
70 | | |
71 | | /* System Include Files */ |
72 | | #include <stdio.h> |
73 | | #include <stddef.h> |
74 | | #include <stdlib.h> |
75 | | #include <string.h> |
76 | | #include <assert.h> |
77 | | |
78 | | /* User Include Files */ |
79 | | #include "ih264e_config.h" |
80 | | #include "ih264_typedefs.h" |
81 | | #include "iv2.h" |
82 | | #include "ive2.h" |
83 | | #include "ithread.h" |
84 | | |
85 | | #include "ih264_debug.h" |
86 | | #include "ih264_macros.h" |
87 | | #include "ih264_error.h" |
88 | | #include "ih264_defs.h" |
89 | | #include "ih264_mem_fns.h" |
90 | | #include "ih264_padding.h" |
91 | | #include "ih264_structs.h" |
92 | | #include "ih264_size_defs.h" |
93 | | #include "ih264_trans_quant_itrans_iquant.h" |
94 | | #include "ih264_inter_pred_filters.h" |
95 | | #include "ih264_intra_pred_filters.h" |
96 | | #include "ih264_deblk_edge_filters.h" |
97 | | #include "ih264_common_tables.h" |
98 | | #include "ih264_cavlc_tables.h" |
99 | | #include "ih264_cabac_tables.h" |
100 | | #include "ih264_buf_mgr.h" |
101 | | #include "ih264_list.h" |
102 | | #include "ih264_dpb_mgr.h" |
103 | | #include "ih264_platform_macros.h" |
104 | | |
105 | | #include "ime_defs.h" |
106 | | #include "ime_distortion_metrics.h" |
107 | | #include "ime_structs.h" |
108 | | |
109 | | #include "irc_mem_req_and_acq.h" |
110 | | #include "irc_cntrl_param.h" |
111 | | #include "irc_frame_info_collector.h" |
112 | | #include "irc_rate_control_api.h" |
113 | | |
114 | | #include "ih264e.h" |
115 | | #include "ih264e_error.h" |
116 | | #include "ih264e_version.h" |
117 | | #include "ih264e_defs.h" |
118 | | #include "ih264e_globals.h" |
119 | | #include "ih264e_time_stamp.h" |
120 | | #include "ih264e_modify_frm_rate.h" |
121 | | #include "ih264e_rate_control.h" |
122 | | #include "ih264e_rc_mem_interface.h" |
123 | | #include "ih264e_bitstream.h" |
124 | | #include "ih264e_cabac_structs.h" |
125 | | #include "ih264e_structs.h" |
126 | | #include "ih264e_utils.h" |
127 | | #include "ih264e_core_coding.h" |
128 | | #include "ih264e_cavlc.h" |
129 | | #include "ih264e_master.h" |
130 | | #include "ih264e_fmt_conv.h" |
131 | | #include "ih264e_platform_macros.h" |
132 | | |
133 | | |
134 | | /*****************************************************************************/ |
135 | | /* Function Definitions */ |
136 | | /*****************************************************************************/ |
137 | | |
138 | | /** |
139 | | ******************************************************************************* |
140 | | * |
141 | | * @brief |
142 | | * Used to test arguments for corresponding API call |
143 | | * |
144 | | * @par Description: |
145 | | * For each command the arguments are validated |
146 | | * |
147 | | * @param[in] ps_handle |
148 | | * Codec handle at API level |
149 | | * |
150 | | * @param[in] pv_api_ip |
151 | | * Pointer to input structure |
152 | | * |
153 | | * @param[out] pv_api_op |
154 | | * Pointer to output structure |
155 | | * |
156 | | * @returns error status |
157 | | * |
158 | | * @remarks none |
159 | | * |
160 | | ******************************************************************************* |
161 | | */ |
162 | | static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, |
163 | | void *pv_api_ip, |
164 | | void *pv_api_op) |
165 | 207k | { |
166 | | /* api call */ |
167 | 207k | WORD32 command = IV_CMD_NA; |
168 | | |
169 | | /* input structure expected by the api call */ |
170 | 207k | UWORD32 *pu4_api_ip = pv_api_ip; |
171 | | |
172 | | /* output structure expected by the api call */ |
173 | 207k | UWORD32 *pu4_api_op = pv_api_op; |
174 | | |
175 | | /* temp var */ |
176 | 207k | WORD32 i, j; |
177 | | |
178 | 207k | if (NULL == pv_api_op || NULL == pv_api_ip) |
179 | 0 | { |
180 | 0 | return (IV_FAIL); |
181 | 0 | } |
182 | | |
183 | | /* get command */ |
184 | 207k | command = pu4_api_ip[1]; |
185 | | |
186 | | /* set error code */ |
187 | 207k | pu4_api_op[1] = 0; |
188 | | |
189 | | /* error checks on handle */ |
190 | 207k | switch (command) |
191 | 207k | { |
192 | 4.89k | case IV_CMD_GET_NUM_MEM_REC: |
193 | 14.6k | case IV_CMD_FILL_NUM_MEM_REC: |
194 | 14.6k | break; |
195 | | |
196 | 4.88k | case IV_CMD_INIT: |
197 | 4.88k | if (ps_handle == NULL) |
198 | 0 | { |
199 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
200 | 0 | *(pu4_api_op + 1) |= IVE_ERR_HANDLE_NULL; |
201 | 0 | return IV_FAIL; |
202 | 0 | } |
203 | | |
204 | 4.88k | if (ps_handle->u4_size != sizeof(iv_obj_t)) |
205 | 0 | { |
206 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
207 | 0 | *(pu4_api_op + 1) |= IVE_ERR_HANDLE_STRUCT_SIZE_INCORRECT; |
208 | 0 | return IV_FAIL; |
209 | 0 | } |
210 | 4.88k | break; |
211 | | |
212 | 4.88k | case IVE_CMD_QUEUE_INPUT: |
213 | 0 | case IVE_CMD_QUEUE_OUTPUT: |
214 | 0 | case IVE_CMD_DEQUEUE_OUTPUT: |
215 | 0 | case IVE_CMD_GET_RECON: |
216 | 4.87k | case IV_CMD_RETRIEVE_MEMREC: |
217 | 115k | case IVE_CMD_VIDEO_CTL: |
218 | 187k | case IVE_CMD_VIDEO_ENCODE: |
219 | | |
220 | 187k | if (ps_handle == NULL) |
221 | 0 | { |
222 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
223 | 0 | *(pu4_api_op + 1) |= IVE_ERR_HANDLE_NULL; |
224 | 0 | return IV_FAIL; |
225 | 0 | } |
226 | | |
227 | 187k | if (ps_handle->u4_size != sizeof(iv_obj_t)) |
228 | 0 | { |
229 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
230 | 0 | *(pu4_api_op + 1) |= IVE_ERR_HANDLE_STRUCT_SIZE_INCORRECT; |
231 | 0 | return IV_FAIL; |
232 | 0 | } |
233 | | |
234 | 187k | if (ps_handle->pv_fxns != ih264e_api_function) |
235 | 0 | { |
236 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
237 | 0 | *(pu4_api_op + 1) |= IVE_ERR_API_FUNCTION_PTR_NULL; |
238 | 0 | return IV_FAIL; |
239 | 0 | } |
240 | | |
241 | 187k | if (ps_handle->pv_codec_handle == NULL) |
242 | 0 | { |
243 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
244 | 0 | *(pu4_api_op + 1) |= IVE_ERR_INVALID_CODEC_HANDLE; |
245 | 0 | return IV_FAIL; |
246 | 0 | } |
247 | 187k | break; |
248 | | |
249 | 187k | default: |
250 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
251 | 0 | *(pu4_api_op + 1) |= IVE_ERR_INVALID_API_CMD; |
252 | 0 | return IV_FAIL; |
253 | 207k | } |
254 | | |
255 | | /* error checks on input output structures */ |
256 | 207k | switch (command) |
257 | 207k | { |
258 | 4.89k | case IV_CMD_GET_NUM_MEM_REC: |
259 | 4.89k | { |
260 | 4.89k | ih264e_num_mem_rec_ip_t *ps_ip = pv_api_ip; |
261 | 4.89k | ih264e_num_mem_rec_op_t *ps_op = pv_api_op; |
262 | | |
263 | 4.89k | ps_op->s_ive_op.u4_error_code = 0; |
264 | | |
265 | 4.89k | if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_num_mem_rec_ip_t)) |
266 | 0 | { |
267 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
268 | 0 | ps_op->s_ive_op.u4_error_code |= |
269 | 0 | IVE_ERR_IP_GET_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
270 | 0 | return (IV_FAIL); |
271 | 0 | } |
272 | | |
273 | 4.89k | if (ps_op->s_ive_op.u4_size != sizeof(ih264e_num_mem_rec_op_t)) |
274 | 0 | { |
275 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
276 | 0 | ps_op->s_ive_op.u4_error_code |= |
277 | 0 | IVE_ERR_OP_GET_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
278 | 0 | return (IV_FAIL); |
279 | 0 | } |
280 | 4.89k | break; |
281 | 4.89k | } |
282 | | |
283 | 9.77k | case IV_CMD_FILL_NUM_MEM_REC: |
284 | 9.77k | { |
285 | 9.77k | ih264e_fill_mem_rec_ip_t *ps_ip = pv_api_ip; |
286 | 9.77k | ih264e_fill_mem_rec_op_t *ps_op = pv_api_op; |
287 | | |
288 | 9.77k | iv_mem_rec_t *ps_mem_rec = NULL; |
289 | | |
290 | 9.77k | WORD32 max_wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd); |
291 | 9.77k | WORD32 max_ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht); |
292 | | |
293 | 9.77k | ps_op->s_ive_op.u4_error_code = 0; |
294 | | |
295 | 9.77k | if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_fill_mem_rec_ip_t)) |
296 | 0 | { |
297 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
298 | 0 | ps_op->s_ive_op.u4_error_code |= |
299 | 0 | IVE_ERR_IP_FILL_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
300 | 0 | return (IV_FAIL); |
301 | 0 | } |
302 | | |
303 | 9.77k | if (ps_op->s_ive_op.u4_size != sizeof(ih264e_fill_mem_rec_op_t)) |
304 | 0 | { |
305 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
306 | 0 | ps_op->s_ive_op.u4_error_code |= |
307 | 0 | IVE_ERR_OP_FILL_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
308 | 0 | return (IV_FAIL); |
309 | 0 | } |
310 | | |
311 | 9.77k | if (max_wd < MIN_WD || max_wd > MAX_WD) |
312 | 4 | { |
313 | 4 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
314 | 4 | ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED; |
315 | 4 | return (IV_FAIL); |
316 | 4 | } |
317 | | |
318 | 9.76k | if (max_ht < MIN_HT || max_ht > MAX_HT) |
319 | 5 | { |
320 | 5 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
321 | 5 | ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED; |
322 | 5 | return (IV_FAIL); |
323 | 5 | } |
324 | | |
325 | | /* verify number of mem rec ptr */ |
326 | 9.76k | if (NULL == ps_ip->s_ive_ip.ps_mem_rec) |
327 | 0 | { |
328 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
329 | 0 | ps_op->s_ive_op.u4_error_code |= |
330 | 0 | IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL; |
331 | 0 | return (IV_FAIL); |
332 | 0 | } |
333 | | |
334 | | /* verify number of mem records */ |
335 | 9.76k | if (ps_ip->s_ive_ip.u4_num_mem_rec != MEM_REC_CNT) |
336 | 0 | { |
337 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
338 | 0 | ps_op->s_ive_op.u4_error_code |= |
339 | 0 | IVE_ERR_NUM_MEM_REC_NOT_SUFFICIENT; |
340 | 0 | return IV_FAIL; |
341 | 0 | } |
342 | | |
343 | | /* check mem records sizes are correct */ |
344 | 9.76k | ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec; |
345 | 507k | for (i = 0; i < MEM_REC_CNT; i++) |
346 | 497k | { |
347 | 497k | if (ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t)) |
348 | 0 | { |
349 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
350 | 0 | ps_op->s_ive_op.u4_error_code |= |
351 | 0 | IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT; |
352 | 0 | return IV_FAIL; |
353 | 0 | } |
354 | 497k | } |
355 | 9.76k | break; |
356 | 9.76k | } |
357 | | |
358 | 9.76k | case IV_CMD_INIT: |
359 | 4.88k | { |
360 | 4.88k | ih264e_init_ip_t *ps_ip = pv_api_ip; |
361 | 4.88k | ih264e_init_op_t *ps_op = pv_api_op; |
362 | | |
363 | 4.88k | iv_mem_rec_t *ps_mem_rec = NULL; |
364 | | |
365 | 4.88k | WORD32 max_wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd); |
366 | 4.88k | WORD32 max_ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht); |
367 | | |
368 | 4.88k | ps_op->s_ive_op.u4_error_code = 0; |
369 | | |
370 | 4.88k | if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_init_ip_t)) |
371 | 0 | { |
372 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
373 | 0 | ps_op->s_ive_op.u4_error_code |= |
374 | 0 | IVE_ERR_IP_INIT_API_STRUCT_SIZE_INCORRECT; |
375 | 0 | return (IV_FAIL); |
376 | 0 | } |
377 | | |
378 | 4.88k | if (ps_op->s_ive_op.u4_size != sizeof(ih264e_init_op_t)) |
379 | 0 | { |
380 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
381 | 0 | ps_op->s_ive_op.u4_error_code |= |
382 | 0 | IVE_ERR_OP_INIT_API_STRUCT_SIZE_INCORRECT; |
383 | 0 | return (IV_FAIL); |
384 | 0 | } |
385 | | |
386 | 4.88k | if (max_wd < MIN_WD || max_wd > MAX_WD) |
387 | 0 | { |
388 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
389 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED; |
390 | 0 | return (IV_FAIL); |
391 | 0 | } |
392 | | |
393 | 4.88k | if (max_ht < MIN_HT || max_ht > MAX_HT) |
394 | 0 | { |
395 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
396 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED; |
397 | 0 | return (IV_FAIL); |
398 | 0 | } |
399 | | |
400 | 4.88k | if (ps_ip->s_ive_ip.u4_max_ref_cnt > MAX_REF_PIC_CNT || |
401 | 4.88k | ps_ip->s_ive_ip.u4_max_ref_cnt < MIN_REF_PIC_CNT) |
402 | 0 | { |
403 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
404 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REF_UNSUPPORTED; |
405 | 0 | return (IV_FAIL); |
406 | 0 | } |
407 | | |
408 | 4.88k | if (ps_ip->s_ive_ip.u4_max_reorder_cnt != 0) |
409 | 0 | { |
410 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
411 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REORDER_UNSUPPORTED; |
412 | 0 | return (IV_FAIL); |
413 | 0 | } |
414 | | |
415 | 4.88k | if ((ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_10) |
416 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_1B) |
417 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_11) |
418 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_12) |
419 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_13) |
420 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_20) |
421 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_21) |
422 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_22) |
423 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_30) |
424 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_31) |
425 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_32) |
426 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_40) |
427 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_41) |
428 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_42) |
429 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_50) |
430 | 4.88k | && (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_51)) |
431 | 0 | { |
432 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
433 | 0 | ps_op->s_ive_op.u4_error_code |= |
434 | 0 | IH264E_CODEC_LEVEL_NOT_SUPPORTED; |
435 | 0 | return (IV_FAIL); |
436 | 0 | } |
437 | | |
438 | 4.88k | if ((ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420P) |
439 | 4.88k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_422ILE) |
440 | 4.88k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_UV) |
441 | 4.88k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_VU)) |
442 | 0 | { |
443 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
444 | 0 | ps_op->s_ive_op.u4_error_code |= |
445 | 0 | IH264E_INPUT_CHROMA_FORMAT_NOT_SUPPORTED; |
446 | 0 | return (IV_FAIL); |
447 | 0 | } |
448 | | |
449 | 4.88k | if ((ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420P) |
450 | 4.88k | && (ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420SP_UV) |
451 | 4.88k | && (ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420SP_VU)) |
452 | 0 | { |
453 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
454 | 0 | ps_op->s_ive_op.u4_error_code |= |
455 | 0 | IH264E_RECON_CHROMA_FORMAT_NOT_SUPPORTED; |
456 | 0 | return (IV_FAIL); |
457 | 0 | } |
458 | | |
459 | 4.88k | if ((ps_ip->s_ive_ip.e_rc_mode != IVE_RC_NONE) |
460 | 4.88k | && (ps_ip->s_ive_ip.e_rc_mode != IVE_RC_STORAGE) |
461 | 4.88k | && (ps_ip->s_ive_ip.e_rc_mode != IVE_RC_CBR_NON_LOW_DELAY)) |
462 | 11 | { |
463 | 11 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
464 | 11 | ps_op->s_ive_op.u4_error_code |= |
465 | 11 | IH264E_RATE_CONTROL_MODE_NOT_SUPPORTED; |
466 | 11 | return (IV_FAIL); |
467 | 11 | } |
468 | | |
469 | 4.87k | if (ps_ip->s_ive_ip.u4_max_framerate > DEFAULT_MAX_FRAMERATE) |
470 | 0 | { |
471 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
472 | 0 | ps_op->s_ive_op.u4_error_code |= |
473 | 0 | IH264E_FRAME_RATE_NOT_SUPPORTED; |
474 | 0 | return (IV_FAIL); |
475 | 0 | } |
476 | | |
477 | 4.87k | if (ps_ip->s_ive_ip.u4_max_bitrate > DEFAULT_MAX_BITRATE) |
478 | 0 | { |
479 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
480 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_BITRATE_NOT_SUPPORTED; |
481 | 0 | return (IV_FAIL); |
482 | 0 | } |
483 | | |
484 | 4.87k | if (ps_ip->s_ive_ip.u4_num_bframes > MAX_NUM_BFRAMES) |
485 | 0 | { |
486 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
487 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_BFRAMES_NOT_SUPPORTED; |
488 | 0 | return (IV_FAIL); |
489 | 0 | } |
490 | | |
491 | 4.87k | if (ps_ip->s_ive_ip.u4_num_bframes |
492 | 4.87k | && (ps_ip->s_ive_ip.u4_max_ref_cnt < 2)) |
493 | 0 | { |
494 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
495 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_BFRAMES_NOT_SUPPORTED; |
496 | 0 | return (IV_FAIL); |
497 | 0 | } |
498 | | |
499 | 4.87k | if (ps_ip->s_ive_ip.e_content_type != IV_PROGRESSIVE) |
500 | 0 | { |
501 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
502 | 0 | ps_op->s_ive_op.u4_error_code |= |
503 | 0 | IH264E_CONTENT_TYPE_NOT_SUPPORTED; |
504 | 0 | return (IV_FAIL); |
505 | 0 | } |
506 | | |
507 | 4.87k | if (ps_ip->s_ive_ip.u4_max_srch_rng_x > DEFAULT_MAX_SRCH_RANGE_X) |
508 | 0 | { |
509 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
510 | 0 | ps_op->s_ive_op.u4_error_code |= |
511 | 0 | IH264E_HORIZONTAL_SEARCH_RANGE_NOT_SUPPORTED; |
512 | 0 | return (IV_FAIL); |
513 | 0 | } |
514 | | |
515 | 4.87k | if (ps_ip->s_ive_ip.u4_max_srch_rng_y > DEFAULT_MAX_SRCH_RANGE_Y) |
516 | 0 | { |
517 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
518 | 0 | ps_op->s_ive_op.u4_error_code |= |
519 | 0 | IH264E_VERTICAL_SEARCH_RANGE_NOT_SUPPORTED; |
520 | 0 | return (IV_FAIL); |
521 | 0 | } |
522 | | |
523 | 4.87k | if ((ps_ip->s_ive_ip.e_slice_mode != IVE_SLICE_MODE_NONE) |
524 | 4.87k | && (ps_ip->s_ive_ip.e_slice_mode != IVE_SLICE_MODE_BLOCKS)) |
525 | 0 | { |
526 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
527 | 0 | ps_op->s_ive_op.u4_error_code |= |
528 | 0 | IH264E_SLICE_TYPE_INPUT_INVALID; |
529 | 0 | return (IV_FAIL); |
530 | 0 | } |
531 | | |
532 | 4.87k | if (ps_ip->s_ive_ip.e_slice_mode == IVE_SLICE_MODE_BLOCKS) |
533 | 0 | { |
534 | 0 | if (ps_ip->s_ive_ip.u4_slice_param == 0 |
535 | 0 | || ps_ip->s_ive_ip.u4_slice_param > ((UWORD32)max_ht >> 4)) |
536 | 0 | { |
537 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
538 | 0 | ps_op->s_ive_op.u4_error_code |= |
539 | 0 | IH264E_SLICE_PARAM_INPUT_INVALID; |
540 | 0 | return (IV_FAIL); |
541 | 0 | } |
542 | 0 | } |
543 | | |
544 | 4.87k | if (NULL == ps_ip->s_ive_ip.ps_mem_rec) |
545 | 0 | { |
546 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
547 | 0 | ps_op->s_ive_op.u4_error_code |= |
548 | 0 | IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL; |
549 | 0 | return (IV_FAIL); |
550 | 0 | } |
551 | | |
552 | | /* verify number of mem records */ |
553 | 4.87k | if (ps_ip->s_ive_ip.u4_num_mem_rec != MEM_REC_CNT) |
554 | 0 | { |
555 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
556 | 0 | ps_op->s_ive_op.u4_error_code |= |
557 | 0 | IVE_ERR_NUM_MEM_REC_NOT_SUFFICIENT; |
558 | 0 | return (IV_FAIL); |
559 | 0 | } |
560 | | |
561 | 4.87k | ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec; |
562 | | |
563 | | /* check memrecords sizes are correct */ |
564 | 253k | for (i = 0; i <((WORD32)ps_ip->s_ive_ip.u4_num_mem_rec); i++) |
565 | 248k | { |
566 | 248k | if (ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t)) |
567 | 0 | { |
568 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
569 | 0 | ps_op->s_ive_op.u4_error_code |= |
570 | 0 | IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT; |
571 | 0 | return IV_FAIL; |
572 | 0 | } |
573 | | |
574 | | /* check memrecords pointers are not NULL */ |
575 | 248k | if (ps_mem_rec[i].pv_base == NULL) |
576 | 0 | { |
577 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
578 | 0 | ps_op->s_ive_op.u4_error_code |= |
579 | 0 | IVE_ERR_MEM_REC_BASE_POINTER_NULL; |
580 | 0 | return IV_FAIL; |
581 | 0 | } |
582 | 248k | } |
583 | | |
584 | | /* verify memtabs for overlapping regions */ |
585 | 4.87k | { |
586 | 4.87k | void *start[MEM_REC_CNT]; |
587 | 4.87k | void *end[MEM_REC_CNT]; |
588 | | |
589 | 4.87k | start[0] = (ps_mem_rec[0].pv_base); |
590 | 4.87k | end[0] = ((UWORD8 *) ps_mem_rec[0].pv_base) |
591 | 4.87k | + ps_mem_rec[0].u4_mem_size - 1; |
592 | | |
593 | 248k | for (i = 1; i < MEM_REC_CNT; i++) |
594 | 243k | { |
595 | | /* This array is populated to check memtab overlap */ |
596 | 243k | start[i] = (ps_mem_rec[i].pv_base); |
597 | 243k | end[i] = ((UWORD8 *) ps_mem_rec[i].pv_base) |
598 | 243k | + ps_mem_rec[i].u4_mem_size - 1; |
599 | | |
600 | 6.46M | for (j = 0; j < i; j++) |
601 | 6.21M | { |
602 | 6.21M | if ((start[i] >= start[j]) && (start[i] <= end[j])) |
603 | 0 | { |
604 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
605 | 0 | << IVE_UNSUPPORTEDPARAM; |
606 | 0 | ps_op->s_ive_op.u4_error_code |= |
607 | 0 | IVE_ERR_MEM_REC_OVERLAP_ERR; |
608 | 0 | return IV_FAIL; |
609 | 0 | } |
610 | | |
611 | 6.21M | if ((end[i] >= start[j]) && (end[i] <= end[j])) |
612 | 0 | { |
613 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
614 | 0 | << IVE_UNSUPPORTEDPARAM; |
615 | 0 | ps_op->s_ive_op.u4_error_code |= |
616 | 0 | IVE_ERR_MEM_REC_OVERLAP_ERR; |
617 | 0 | return IV_FAIL; |
618 | 0 | } |
619 | | |
620 | 6.21M | if ((start[i] < start[j]) && (end[i] > end[j])) |
621 | 0 | { |
622 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
623 | 0 | << IVE_UNSUPPORTEDPARAM; |
624 | 0 | ps_op->s_ive_op.u4_error_code |= |
625 | 0 | IVE_ERR_MEM_REC_OVERLAP_ERR; |
626 | 0 | return IV_FAIL; |
627 | 0 | } |
628 | 6.21M | } |
629 | 243k | } |
630 | 4.87k | } |
631 | | |
632 | | /* re-validate mem records with init config */ |
633 | 4.87k | { |
634 | | /* mem records */ |
635 | 4.87k | iv_mem_rec_t s_mem_rec_ittiam_api[MEM_REC_CNT]; |
636 | | |
637 | | /* api interface structs */ |
638 | 4.87k | ih264e_fill_mem_rec_ip_t s_ip; |
639 | 4.87k | ih264e_fill_mem_rec_op_t s_op; |
640 | | |
641 | | /* error status */ |
642 | 4.87k | IV_STATUS_T e_status; |
643 | | |
644 | | /* temp var */ |
645 | 4.87k | WORD32 i; |
646 | | |
647 | 4.87k | s_ip.s_ive_ip.u4_size = sizeof(ih264e_fill_mem_rec_ip_t); |
648 | 4.87k | s_op.s_ive_op.u4_size = sizeof(ih264e_fill_mem_rec_op_t); |
649 | | |
650 | 4.87k | s_ip.s_ive_ip.e_cmd = IV_CMD_FILL_NUM_MEM_REC; |
651 | 4.87k | s_ip.s_ive_ip.ps_mem_rec = s_mem_rec_ittiam_api; |
652 | 4.87k | s_ip.s_ive_ip.u4_max_wd = max_wd; |
653 | 4.87k | s_ip.s_ive_ip.u4_max_ht = max_ht; |
654 | 4.87k | s_ip.s_ive_ip.u4_num_mem_rec = ps_ip->s_ive_ip.u4_num_mem_rec; |
655 | 4.87k | s_ip.s_ive_ip.u4_max_level = ps_ip->s_ive_ip.u4_max_level; |
656 | 4.87k | s_ip.s_ive_ip.u4_max_ref_cnt = ps_ip->s_ive_ip.u4_max_ref_cnt; |
657 | 4.87k | s_ip.s_ive_ip.u4_max_reorder_cnt = |
658 | 4.87k | ps_ip->s_ive_ip.u4_max_reorder_cnt; |
659 | 4.87k | s_ip.s_ive_ip.e_color_format = ps_ip->s_ive_ip.e_inp_color_fmt; |
660 | 4.87k | s_ip.s_ive_ip.u4_max_srch_rng_x = |
661 | 4.87k | ps_ip->s_ive_ip.u4_max_srch_rng_x; |
662 | 4.87k | s_ip.s_ive_ip.u4_max_srch_rng_y = |
663 | 4.87k | ps_ip->s_ive_ip.u4_max_srch_rng_y; |
664 | 4.87k | s_ip.s_ive_ip.u4_keep_threads_active = ps_ip->s_ive_ip.u4_keep_threads_active; |
665 | | |
666 | 253k | for (i = 0; i < MEM_REC_CNT; i++) |
667 | 248k | { |
668 | 248k | s_mem_rec_ittiam_api[i].u4_size = sizeof(iv_mem_rec_t); |
669 | 248k | } |
670 | | |
671 | | /* fill mem records */ |
672 | 4.87k | e_status = ih264e_api_function(NULL, (void *) &s_ip, |
673 | 4.87k | (void *) &s_op); |
674 | | |
675 | 4.87k | if (IV_FAIL == e_status) |
676 | 0 | { |
677 | 0 | ps_op->s_ive_op.u4_error_code = s_op.s_ive_op.u4_error_code; |
678 | 0 | return (IV_FAIL); |
679 | 0 | } |
680 | | |
681 | | /* verify mem records */ |
682 | 253k | for (i = 0; i < MEM_REC_CNT; i++) |
683 | 248k | { |
684 | 248k | if (ps_mem_rec[i].u4_mem_size |
685 | 248k | < s_mem_rec_ittiam_api[i].u4_mem_size) |
686 | 0 | { |
687 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
688 | 0 | << IVE_UNSUPPORTEDPARAM; |
689 | 0 | ps_op->s_ive_op.u4_error_code |= |
690 | 0 | IVE_ERR_MEM_REC_INSUFFICIENT_SIZE; |
691 | |
|
692 | 0 | return IV_FAIL; |
693 | 0 | } |
694 | | |
695 | 248k | if (ps_mem_rec[i].u4_mem_alignment |
696 | 248k | != s_mem_rec_ittiam_api[i].u4_mem_alignment) |
697 | 0 | { |
698 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
699 | 0 | << IVE_UNSUPPORTEDPARAM; |
700 | 0 | ps_op->s_ive_op.u4_error_code |= |
701 | 0 | IVE_ERR_MEM_REC_ALIGNMENT_ERR; |
702 | |
|
703 | 0 | return IV_FAIL; |
704 | 0 | } |
705 | | |
706 | 248k | if (ps_mem_rec[i].e_mem_type |
707 | 248k | != s_mem_rec_ittiam_api[i].e_mem_type) |
708 | 0 | { |
709 | 0 | UWORD32 check = IV_SUCCESS; |
710 | 0 | UWORD32 diff = s_mem_rec_ittiam_api[i].e_mem_type |
711 | 0 | - ps_mem_rec[i].e_mem_type; |
712 | |
|
713 | 0 | if ((ps_mem_rec[i].e_mem_type |
714 | 0 | <= IV_EXTERNAL_CACHEABLE_SCRATCH_MEM) |
715 | 0 | && (s_mem_rec_ittiam_api[i].e_mem_type |
716 | 0 | >= IV_INTERNAL_NONCACHEABLE_PERSISTENT_MEM)) |
717 | 0 | { |
718 | 0 | check = IV_FAIL; |
719 | 0 | } |
720 | |
|
721 | 0 | if (3 != (s_mem_rec_ittiam_api[i].e_mem_type % 4)) |
722 | 0 | { |
723 | | /* It is not IV_EXTERNAL_NONCACHEABLE_PERSISTENT_MEM or |
724 | | * IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM */ |
725 | |
|
726 | 0 | if ((diff < 1) || (diff > 3)) |
727 | 0 | { |
728 | | /* Difference between 1 and 3 is okay for all cases other than the |
729 | | * two filtered with the MOD condition above */ |
730 | 0 | check = IV_FAIL; |
731 | 0 | } |
732 | 0 | } |
733 | 0 | else |
734 | 0 | { |
735 | 0 | if (diff == 1) |
736 | 0 | { |
737 | | /* This particular case is when codec asked for External Persistent, |
738 | | * but got Internal Scratch */ |
739 | 0 | check = IV_FAIL; |
740 | 0 | } |
741 | 0 | if ((diff != 2) && (diff != 3)) |
742 | 0 | { |
743 | 0 | check = IV_FAIL; |
744 | 0 | } |
745 | 0 | } |
746 | |
|
747 | 0 | if (check == IV_FAIL) |
748 | 0 | { |
749 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
750 | 0 | << IVE_UNSUPPORTEDPARAM; |
751 | 0 | ps_op->s_ive_op.u4_error_code |= |
752 | 0 | IVE_ERR_MEM_REC_INCORRECT_TYPE; |
753 | |
|
754 | 0 | return IV_FAIL; |
755 | 0 | } |
756 | 0 | } |
757 | 248k | } |
758 | 4.87k | } |
759 | 4.87k | break; |
760 | 4.87k | } |
761 | | |
762 | 4.87k | case IVE_CMD_QUEUE_INPUT: |
763 | 0 | case IVE_CMD_QUEUE_OUTPUT: |
764 | 0 | case IVE_CMD_DEQUEUE_OUTPUT: |
765 | 0 | case IVE_CMD_GET_RECON: |
766 | 0 | break; |
767 | | |
768 | 4.87k | case IV_CMD_RETRIEVE_MEMREC: |
769 | 4.87k | { |
770 | 4.87k | ih264e_retrieve_mem_rec_ip_t *ps_ip = pv_api_ip; |
771 | 4.87k | ih264e_retrieve_mem_rec_op_t *ps_op = pv_api_op; |
772 | | |
773 | 4.87k | iv_mem_rec_t *ps_mem_rec = NULL; |
774 | | |
775 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
776 | | |
777 | 4.87k | if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_retrieve_mem_rec_ip_t)) |
778 | 0 | { |
779 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
780 | 0 | ps_op->s_ive_op.u4_error_code |= |
781 | 0 | IVE_ERR_IP_RETRIEVE_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
782 | 0 | return (IV_FAIL); |
783 | 0 | } |
784 | | |
785 | 4.87k | if (ps_op->s_ive_op.u4_size != sizeof(ih264e_retrieve_mem_rec_op_t)) |
786 | 0 | { |
787 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
788 | 0 | ps_op->s_ive_op.u4_error_code |= |
789 | 0 | IVE_ERR_OP_RETRIEVE_MEM_REC_API_STRUCT_SIZE_INCORRECT; |
790 | 0 | return (IV_FAIL); |
791 | 0 | } |
792 | | |
793 | 4.87k | if (NULL == ps_ip->s_ive_ip.ps_mem_rec) |
794 | 0 | { |
795 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
796 | 0 | ps_op->s_ive_op.u4_error_code |= |
797 | 0 | IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL; |
798 | 0 | return (IV_FAIL); |
799 | 0 | } |
800 | | |
801 | 4.87k | ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec; |
802 | | |
803 | | /* check memrecords sizes are correct */ |
804 | 253k | for (i = 0; i < MEM_REC_CNT; i++) |
805 | 248k | { |
806 | 248k | if (ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t)) |
807 | 0 | { |
808 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
809 | 0 | ps_op->s_ive_op.u4_error_code |= |
810 | 0 | IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT; |
811 | 0 | return IV_FAIL; |
812 | 0 | } |
813 | 248k | } |
814 | 4.87k | break; |
815 | 4.87k | } |
816 | | |
817 | 72.3k | case IVE_CMD_VIDEO_ENCODE: |
818 | 72.3k | { |
819 | 72.3k | ih264e_video_encode_ip_t *ps_ip = pv_api_ip; |
820 | 72.3k | ih264e_video_encode_op_t *ps_op = pv_api_op; |
821 | | |
822 | 72.3k | if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_video_encode_ip_t)) |
823 | 0 | { |
824 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
825 | 0 | ps_op->s_ive_op.u4_error_code |= |
826 | 0 | IVE_ERR_IP_ENCODE_API_STRUCT_SIZE_INCORRECT; |
827 | 0 | return (IV_FAIL); |
828 | 0 | } |
829 | | |
830 | 72.3k | if (ps_op->s_ive_op.u4_size != sizeof(ih264e_video_encode_op_t)) |
831 | 0 | { |
832 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
833 | 0 | ps_op->s_ive_op.u4_error_code |= |
834 | 0 | IVE_ERR_OP_ENCODE_API_STRUCT_SIZE_INCORRECT; |
835 | 0 | return (IV_FAIL); |
836 | 0 | } |
837 | | |
838 | 72.3k | break; |
839 | 72.3k | } |
840 | | |
841 | 110k | case IVE_CMD_VIDEO_CTL: |
842 | 110k | { |
843 | | /* ptr to input structure */ |
844 | 110k | WORD32 *pu4_ptr_cmd = pv_api_ip; |
845 | | |
846 | | /* sub command */ |
847 | 110k | WORD32 sub_command = pu4_ptr_cmd[2]; |
848 | | |
849 | 110k | switch (sub_command) |
850 | 110k | { |
851 | 4.87k | case IVE_CMD_CTL_SETDEFAULT: |
852 | 4.87k | { |
853 | 4.87k | ih264e_ctl_setdefault_ip_t *ps_ip = pv_api_ip; |
854 | 4.87k | ih264e_ctl_setdefault_op_t *ps_op = pv_api_op; |
855 | | |
856 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
857 | 4.87k | != sizeof(ih264e_ctl_setdefault_ip_t)) |
858 | 0 | { |
859 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
860 | 0 | << IVE_UNSUPPORTEDPARAM; |
861 | 0 | ps_op->s_ive_op.u4_error_code |= |
862 | 0 | IVE_ERR_IP_CTL_SETDEF_API_STRUCT_SIZE_INCORRECT; |
863 | 0 | return IV_FAIL; |
864 | 0 | } |
865 | | |
866 | 4.87k | if (ps_op->s_ive_op.u4_size |
867 | 4.87k | != sizeof(ih264e_ctl_setdefault_op_t)) |
868 | 0 | { |
869 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
870 | 0 | << IVE_UNSUPPORTEDPARAM; |
871 | 0 | ps_op->s_ive_op.u4_error_code |= |
872 | 0 | IVE_ERR_OP_CTL_SETDEF_API_STRUCT_SIZE_INCORRECT; |
873 | 0 | return IV_FAIL; |
874 | 0 | } |
875 | 4.87k | break; |
876 | 4.87k | } |
877 | | |
878 | 4.87k | case IVE_CMD_CTL_GETBUFINFO: |
879 | 4.87k | { |
880 | 4.87k | codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle); |
881 | | |
882 | 4.87k | ih264e_ctl_getbufinfo_ip_t *ps_ip = pv_api_ip; |
883 | 4.87k | ih264e_ctl_getbufinfo_op_t *ps_op = pv_api_op; |
884 | | |
885 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
886 | 4.87k | != sizeof(ih264e_ctl_getbufinfo_ip_t)) |
887 | 0 | { |
888 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
889 | 0 | << IVE_UNSUPPORTEDPARAM; |
890 | 0 | ps_op->s_ive_op.u4_error_code |= |
891 | 0 | IVE_ERR_IP_CTL_GETBUFINFO_API_STRUCT_SIZE_INCORRECT; |
892 | 0 | return IV_FAIL; |
893 | 0 | } |
894 | | |
895 | 4.87k | if (ps_op->s_ive_op.u4_size |
896 | 4.87k | != sizeof(ih264e_ctl_getbufinfo_op_t)) |
897 | 0 | { |
898 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
899 | 0 | << IVE_UNSUPPORTEDPARAM; |
900 | 0 | ps_op->s_ive_op.u4_error_code |= |
901 | 0 | IVE_ERR_OP_CTL_GETBUFINFO_API_STRUCT_SIZE_INCORRECT; |
902 | 0 | return IV_FAIL; |
903 | 0 | } |
904 | | |
905 | 4.87k | if (ps_ip->s_ive_ip.u4_max_wd < MIN_WD) |
906 | 47 | { |
907 | 47 | ps_op->s_ive_op.u4_error_code |= 1 |
908 | 47 | << IVE_UNSUPPORTEDPARAM; |
909 | 47 | ps_op->s_ive_op.u4_error_code |= |
910 | 47 | IH264E_WIDTH_NOT_SUPPORTED; |
911 | 47 | return (IV_FAIL); |
912 | 47 | } |
913 | | |
914 | 4.82k | if (ps_ip->s_ive_ip.u4_max_wd > ps_codec->s_cfg.u4_max_wd) |
915 | 0 | { |
916 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
917 | 0 | << IVE_UNSUPPORTEDPARAM; |
918 | 0 | ps_op->s_ive_op.u4_error_code |= |
919 | 0 | IH264E_WIDTH_NOT_SUPPORTED; |
920 | 0 | return (IV_FAIL); |
921 | 0 | } |
922 | | |
923 | 4.82k | if (ps_ip->s_ive_ip.u4_max_ht < MIN_HT) |
924 | 12 | { |
925 | 12 | ps_op->s_ive_op.u4_error_code |= 1 |
926 | 12 | << IVE_UNSUPPORTEDPARAM; |
927 | 12 | ps_op->s_ive_op.u4_error_code |= |
928 | 12 | IH264E_HEIGHT_NOT_SUPPORTED; |
929 | 12 | return (IV_FAIL); |
930 | 12 | } |
931 | | |
932 | 4.81k | if (ps_ip->s_ive_ip.u4_max_ht > ps_codec->s_cfg.u4_max_ht) |
933 | 0 | { |
934 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
935 | 0 | << IVE_UNSUPPORTEDPARAM; |
936 | 0 | ps_op->s_ive_op.u4_error_code |= |
937 | 0 | IH264E_HEIGHT_NOT_SUPPORTED; |
938 | 0 | return (IV_FAIL); |
939 | 0 | } |
940 | | |
941 | 4.81k | if ((ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420P) |
942 | 4.81k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_422ILE) |
943 | 4.81k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_UV) |
944 | 4.81k | && (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_VU)) |
945 | 0 | { |
946 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
947 | 0 | << IVE_UNSUPPORTEDPARAM; |
948 | 0 | ps_op->s_ive_op.u4_error_code |= |
949 | 0 | IH264E_INPUT_CHROMA_FORMAT_NOT_SUPPORTED; |
950 | 0 | return (IV_FAIL); |
951 | 0 | } |
952 | 4.81k | break; |
953 | 4.81k | } |
954 | | |
955 | 4.87k | case IVE_CMD_CTL_GETVERSION: |
956 | 4.87k | { |
957 | 4.87k | ih264e_ctl_getversioninfo_ip_t *ps_ip = pv_api_ip; |
958 | 4.87k | ih264e_ctl_getversioninfo_op_t *ps_op = pv_api_op; |
959 | | |
960 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
961 | 4.87k | != sizeof(ih264e_ctl_getversioninfo_ip_t)) |
962 | 0 | { |
963 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
964 | 0 | << IVE_UNSUPPORTEDPARAM; |
965 | 0 | ps_op->s_ive_op.u4_error_code |= |
966 | 0 | IVE_ERR_IP_CTL_GETVERSION_API_STRUCT_SIZE_INCORRECT; |
967 | 0 | return IV_FAIL; |
968 | 0 | } |
969 | | |
970 | 4.87k | if (ps_op->s_ive_op.u4_size |
971 | 4.87k | != sizeof(ih264e_ctl_getversioninfo_op_t)) |
972 | 0 | { |
973 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
974 | 0 | << IVE_UNSUPPORTEDPARAM; |
975 | 0 | ps_op->s_ive_op.u4_error_code |= |
976 | 0 | IVE_ERR_OP_CTL_GETVERSION_API_STRUCT_SIZE_INCORRECT; |
977 | 0 | return IV_FAIL; |
978 | 0 | } |
979 | | |
980 | 4.87k | if (ps_ip->s_ive_ip.pu1_version == NULL) |
981 | 0 | { |
982 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
983 | 0 | << IVE_UNSUPPORTEDPARAM; |
984 | 0 | ps_op->s_ive_op.u4_error_code |= |
985 | 0 | IVE_ERR_CTL_GET_VERSION_BUFFER_IS_NULL; |
986 | 0 | return IV_FAIL; |
987 | 0 | } |
988 | | |
989 | 4.87k | break; |
990 | 4.87k | } |
991 | | |
992 | 4.87k | case IVE_CMD_CTL_FLUSH: |
993 | 0 | { |
994 | 0 | ih264e_ctl_flush_ip_t *ps_ip = pv_api_ip; |
995 | 0 | ih264e_ctl_flush_op_t *ps_op = pv_api_op; |
996 | |
|
997 | 0 | if (ps_ip->s_ive_ip.u4_size |
998 | 0 | != sizeof(ih264e_ctl_flush_ip_t)) |
999 | 0 | { |
1000 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1001 | 0 | << IVE_UNSUPPORTEDPARAM; |
1002 | 0 | ps_op->s_ive_op.u4_error_code |= |
1003 | 0 | IVE_ERR_IP_CTL_FLUSH_API_STRUCT_SIZE_INCORRECT; |
1004 | 0 | return IV_FAIL; |
1005 | 0 | } |
1006 | | |
1007 | 0 | if (ps_op->s_ive_op.u4_size |
1008 | 0 | != sizeof(ih264e_ctl_flush_op_t)) |
1009 | 0 | { |
1010 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1011 | 0 | << IVE_UNSUPPORTEDPARAM; |
1012 | 0 | ps_op->s_ive_op.u4_error_code |= |
1013 | 0 | IVE_ERR_OP_CTL_FLUSH_API_STRUCT_SIZE_INCORRECT; |
1014 | 0 | return IV_FAIL; |
1015 | 0 | } |
1016 | | |
1017 | 0 | break; |
1018 | 0 | } |
1019 | | |
1020 | 0 | case IVE_CMD_CTL_RESET: |
1021 | 0 | { |
1022 | 0 | ih264e_ctl_reset_ip_t *ps_ip = pv_api_ip; |
1023 | 0 | ih264e_ctl_reset_op_t *ps_op = pv_api_op; |
1024 | |
|
1025 | 0 | if (ps_ip->s_ive_ip.u4_size |
1026 | 0 | != sizeof(ih264e_ctl_reset_ip_t)) |
1027 | 0 | { |
1028 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1029 | 0 | << IVE_UNSUPPORTEDPARAM; |
1030 | 0 | ps_op->s_ive_op.u4_error_code |= |
1031 | 0 | IVE_ERR_IP_CTL_RESET_API_STRUCT_SIZE_INCORRECT; |
1032 | 0 | return IV_FAIL; |
1033 | 0 | } |
1034 | | |
1035 | 0 | if (ps_op->s_ive_op.u4_size |
1036 | 0 | != sizeof(ih264e_ctl_reset_op_t)) |
1037 | 0 | { |
1038 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1039 | 0 | << IVE_UNSUPPORTEDPARAM; |
1040 | 0 | ps_op->s_ive_op.u4_error_code |= |
1041 | 0 | IVE_ERR_OP_CTL_RESET_API_STRUCT_SIZE_INCORRECT; |
1042 | 0 | return IV_FAIL; |
1043 | 0 | } |
1044 | | |
1045 | 0 | break; |
1046 | 0 | } |
1047 | | |
1048 | 4.87k | case IVE_CMD_CTL_SET_NUM_CORES: |
1049 | 4.87k | { |
1050 | 4.87k | ih264e_ctl_set_num_cores_ip_t *ps_ip = pv_api_ip; |
1051 | 4.87k | ih264e_ctl_set_num_cores_op_t *ps_op = pv_api_op; |
1052 | | |
1053 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1054 | 4.87k | != sizeof(ih264e_ctl_set_num_cores_ip_t)) |
1055 | 0 | { |
1056 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1057 | 0 | << IVE_UNSUPPORTEDPARAM; |
1058 | 0 | ps_op->s_ive_op.u4_error_code |= |
1059 | 0 | IVE_ERR_IP_CTL_SETCORES_API_STRUCT_SIZE_INCORRECT; |
1060 | 0 | return IV_FAIL; |
1061 | 0 | } |
1062 | | |
1063 | 4.87k | if (ps_op->s_ive_op.u4_size |
1064 | 4.87k | != sizeof(ih264e_ctl_set_num_cores_op_t)) |
1065 | 0 | { |
1066 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1067 | 0 | << IVE_UNSUPPORTEDPARAM; |
1068 | 0 | ps_op->s_ive_op.u4_error_code |= |
1069 | 0 | IVE_ERR_OP_CTL_SETCORES_API_STRUCT_SIZE_INCORRECT; |
1070 | 0 | return IV_FAIL; |
1071 | 0 | } |
1072 | | |
1073 | 4.87k | if ((ps_ip->s_ive_ip.u4_num_cores < 1) |
1074 | 4.87k | || (ps_ip->s_ive_ip.u4_num_cores > MAX_NUM_CORES)) |
1075 | 0 | { |
1076 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1077 | 0 | << IVE_UNSUPPORTEDPARAM; |
1078 | 0 | ps_op->s_ive_op.u4_error_code |= |
1079 | 0 | IH264E_INVALID_NUM_CORES; |
1080 | 0 | return IV_FAIL; |
1081 | 0 | } |
1082 | | |
1083 | 4.87k | break; |
1084 | 4.87k | } |
1085 | | |
1086 | 4.87k | case IVE_CMD_CTL_SET_DIMENSIONS: |
1087 | 4.87k | { |
1088 | 4.87k | codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle); |
1089 | | |
1090 | 4.87k | ih264e_ctl_set_dimensions_ip_t *ps_ip = pv_api_ip; |
1091 | 4.87k | ih264e_ctl_set_dimensions_op_t *ps_op = pv_api_op; |
1092 | | |
1093 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1094 | 4.87k | != sizeof(ih264e_ctl_set_dimensions_ip_t)) |
1095 | 0 | { |
1096 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1097 | 0 | << IVE_UNSUPPORTEDPARAM; |
1098 | 0 | ps_op->s_ive_op.u4_error_code |= |
1099 | 0 | IVE_ERR_IP_CTL_SETDIM_API_STRUCT_SIZE_INCORRECT; |
1100 | 0 | return IV_FAIL; |
1101 | 0 | } |
1102 | | |
1103 | 4.87k | if (ps_op->s_ive_op.u4_size |
1104 | 4.87k | != sizeof(ih264e_ctl_set_dimensions_op_t)) |
1105 | 0 | { |
1106 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1107 | 0 | << IVE_UNSUPPORTEDPARAM; |
1108 | 0 | ps_op->s_ive_op.u4_error_code |= |
1109 | 0 | IVE_ERR_OP_CTL_SETDIM_API_STRUCT_SIZE_INCORRECT; |
1110 | 0 | return IV_FAIL; |
1111 | 0 | } |
1112 | | |
1113 | 4.87k | if (ps_ip->s_ive_ip.u4_wd < MIN_WD) |
1114 | 47 | { |
1115 | 47 | ps_op->s_ive_op.u4_error_code |= 1 |
1116 | 47 | << IVE_UNSUPPORTEDPARAM; |
1117 | 47 | ps_op->s_ive_op.u4_error_code |= |
1118 | 47 | IH264E_WIDTH_NOT_SUPPORTED; |
1119 | 47 | return (IV_FAIL); |
1120 | 47 | } |
1121 | | |
1122 | 4.82k | if (ps_ip->s_ive_ip.u4_wd > ps_codec->s_cfg.u4_max_wd) |
1123 | 0 | { |
1124 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1125 | 0 | << IVE_UNSUPPORTEDPARAM; |
1126 | 0 | ps_op->s_ive_op.u4_error_code |= |
1127 | 0 | IH264E_WIDTH_NOT_SUPPORTED; |
1128 | 0 | return (IV_FAIL); |
1129 | 0 | } |
1130 | | |
1131 | 4.82k | if (ps_ip->s_ive_ip.u4_ht < MIN_HT) |
1132 | 12 | { |
1133 | 12 | ps_op->s_ive_op.u4_error_code |= 1 |
1134 | 12 | << IVE_UNSUPPORTEDPARAM; |
1135 | 12 | ps_op->s_ive_op.u4_error_code |= |
1136 | 12 | IH264E_HEIGHT_NOT_SUPPORTED; |
1137 | 12 | return (IV_FAIL); |
1138 | 12 | } |
1139 | | |
1140 | 4.81k | if (ps_ip->s_ive_ip.u4_ht > ps_codec->s_cfg.u4_max_ht) |
1141 | 0 | { |
1142 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1143 | 0 | << IVE_UNSUPPORTEDPARAM; |
1144 | 0 | ps_op->s_ive_op.u4_error_code |= |
1145 | 0 | IH264E_HEIGHT_NOT_SUPPORTED; |
1146 | 0 | return (IV_FAIL); |
1147 | 0 | } |
1148 | | |
1149 | 4.81k | if(ps_ip->s_ive_ip.u4_wd & 1) |
1150 | 52 | { |
1151 | 52 | ps_op->s_ive_op.u4_error_code |= 1 |
1152 | 52 | << IVE_UNSUPPORTEDPARAM; |
1153 | 52 | ps_op->s_ive_op.u4_error_code |= |
1154 | 52 | IH264E_WIDTH_NOT_SUPPORTED; |
1155 | 52 | return (IV_FAIL); |
1156 | 52 | } |
1157 | | |
1158 | 4.76k | if(ps_ip->s_ive_ip.u4_ht & 1) |
1159 | 33 | { |
1160 | 33 | ps_op->s_ive_op.u4_error_code |= 1 |
1161 | 33 | << IVE_UNSUPPORTEDPARAM; |
1162 | 33 | ps_op->s_ive_op.u4_error_code |= |
1163 | 33 | IH264E_HEIGHT_NOT_SUPPORTED; |
1164 | 33 | return (IV_FAIL); |
1165 | 33 | } |
1166 | | |
1167 | 4.73k | break; |
1168 | 4.76k | } |
1169 | | |
1170 | 5.87k | case IVE_CMD_CTL_SET_FRAMERATE: |
1171 | 5.87k | { |
1172 | 5.87k | ih264e_ctl_set_frame_rate_ip_t *ps_ip = pv_api_ip; |
1173 | 5.87k | ih264e_ctl_set_frame_rate_op_t *ps_op = pv_api_op; |
1174 | | |
1175 | 5.87k | if (ps_ip->s_ive_ip.u4_size |
1176 | 5.87k | != sizeof(ih264e_ctl_set_frame_rate_ip_t)) |
1177 | 0 | { |
1178 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1179 | 0 | << IVE_UNSUPPORTEDPARAM; |
1180 | 0 | ps_op->s_ive_op.u4_error_code |= |
1181 | 0 | IVE_ERR_IP_CTL_SETFRAMERATE_API_STRUCT_SIZE_INCORRECT; |
1182 | 0 | return IV_FAIL; |
1183 | 0 | } |
1184 | | |
1185 | 5.87k | if (ps_op->s_ive_op.u4_size |
1186 | 5.87k | != sizeof(ih264e_ctl_set_frame_rate_op_t)) |
1187 | 0 | { |
1188 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1189 | 0 | << IVE_UNSUPPORTEDPARAM; |
1190 | 0 | ps_op->s_ive_op.u4_error_code |= |
1191 | 0 | IVE_ERR_OP_CTL_SETFRAMERATE_API_STRUCT_SIZE_INCORRECT; |
1192 | 0 | return IV_FAIL; |
1193 | 0 | } |
1194 | | |
1195 | 5.87k | if (((ps_ip->s_ive_ip.u4_src_frame_rate * 1000) > DEFAULT_MAX_FRAMERATE) |
1196 | 5.87k | || ((ps_ip->s_ive_ip.u4_tgt_frame_rate * 1000) > DEFAULT_MAX_FRAMERATE)) |
1197 | 2.02k | { |
1198 | 2.02k | ps_op->s_ive_op.u4_error_code |= 1 |
1199 | 2.02k | << IVE_UNSUPPORTEDPARAM; |
1200 | 2.02k | ps_op->s_ive_op.u4_error_code |= |
1201 | 2.02k | IH264E_FRAME_RATE_NOT_SUPPORTED; |
1202 | 2.02k | return (IV_FAIL); |
1203 | 2.02k | } |
1204 | | |
1205 | 3.85k | if ((ps_ip->s_ive_ip.u4_src_frame_rate == 0) |
1206 | 3.85k | || (ps_ip->s_ive_ip.u4_tgt_frame_rate == 0)) |
1207 | 1.14k | { |
1208 | 1.14k | ps_op->s_ive_op.u4_error_code |= 1 |
1209 | 1.14k | << IVE_UNSUPPORTEDPARAM; |
1210 | 1.14k | ps_op->s_ive_op.u4_error_code |= |
1211 | 1.14k | IH264E_FRAME_RATE_NOT_SUPPORTED; |
1212 | 1.14k | return (IV_FAIL); |
1213 | 1.14k | } |
1214 | | |
1215 | 2.70k | if (ps_ip->s_ive_ip.u4_tgt_frame_rate |
1216 | 2.70k | > ps_ip->s_ive_ip.u4_src_frame_rate) |
1217 | 0 | { |
1218 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1219 | 0 | << IVE_UNSUPPORTEDPARAM; |
1220 | 0 | ps_op->s_ive_op.u4_error_code |= |
1221 | 0 | IH264E_TGT_FRAME_RATE_EXCEEDS_SRC_FRAME_RATE; |
1222 | 0 | return (IV_FAIL); |
1223 | 0 | } |
1224 | | |
1225 | 2.70k | break; |
1226 | 2.70k | } |
1227 | | |
1228 | 5.90k | case IVE_CMD_CTL_SET_BITRATE: |
1229 | 5.90k | { |
1230 | 5.90k | ih264e_ctl_set_bitrate_ip_t *ps_ip = pv_api_ip; |
1231 | 5.90k | ih264e_ctl_set_bitrate_op_t *ps_op = pv_api_op; |
1232 | | |
1233 | 5.90k | if (ps_ip->s_ive_ip.u4_size |
1234 | 5.90k | != sizeof(ih264e_ctl_set_bitrate_ip_t)) |
1235 | 0 | { |
1236 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1237 | 0 | << IVE_UNSUPPORTEDPARAM; |
1238 | 0 | ps_op->s_ive_op.u4_error_code |= |
1239 | 0 | IVE_ERR_IP_CTL_SETBITRATE_API_STRUCT_SIZE_INCORRECT; |
1240 | 0 | return IV_FAIL; |
1241 | 0 | } |
1242 | | |
1243 | 5.90k | if (ps_op->s_ive_op.u4_size |
1244 | 5.90k | != sizeof(ih264e_ctl_set_bitrate_op_t)) |
1245 | 0 | { |
1246 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1247 | 0 | << IVE_UNSUPPORTEDPARAM; |
1248 | 0 | ps_op->s_ive_op.u4_error_code |= |
1249 | 0 | IVE_ERR_OP_CTL_SETBITRATE_API_STRUCT_SIZE_INCORRECT; |
1250 | 0 | return IV_FAIL; |
1251 | 0 | } |
1252 | | |
1253 | 5.90k | if ((ps_ip->s_ive_ip.u4_target_bitrate > DEFAULT_MAX_BITRATE) |
1254 | 5.90k | || (ps_ip->s_ive_ip.u4_target_bitrate == 0)) |
1255 | 463 | { |
1256 | 463 | ps_op->s_ive_op.u4_error_code |= 1 |
1257 | 463 | << IVE_UNSUPPORTEDPARAM; |
1258 | 463 | ps_op->s_ive_op.u4_error_code |= |
1259 | 463 | IH264E_BITRATE_NOT_SUPPORTED; |
1260 | 463 | return (IV_FAIL); |
1261 | 463 | } |
1262 | | |
1263 | 5.44k | break; |
1264 | 5.90k | } |
1265 | | |
1266 | 5.44k | case IVE_CMD_CTL_SET_FRAMETYPE: |
1267 | 1.00k | { |
1268 | 1.00k | ih264e_ctl_set_frame_type_ip_t *ps_ip = pv_api_ip; |
1269 | 1.00k | ih264e_ctl_set_frame_type_op_t *ps_op = pv_api_op; |
1270 | | |
1271 | 1.00k | if (ps_ip->s_ive_ip.u4_size |
1272 | 1.00k | != sizeof(ih264e_ctl_set_frame_type_ip_t)) |
1273 | 0 | { |
1274 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1275 | 0 | << IVE_UNSUPPORTEDPARAM; |
1276 | 0 | ps_op->s_ive_op.u4_error_code |= |
1277 | 0 | IVE_ERR_IP_CTL_SETFRAMETYPE_API_STRUCT_SIZE_INCORRECT; |
1278 | 0 | return IV_FAIL; |
1279 | 0 | } |
1280 | | |
1281 | 1.00k | if (ps_op->s_ive_op.u4_size |
1282 | 1.00k | != sizeof(ih264e_ctl_set_frame_type_op_t)) |
1283 | 0 | { |
1284 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1285 | 0 | << IVE_UNSUPPORTEDPARAM; |
1286 | 0 | ps_op->s_ive_op.u4_error_code |= |
1287 | 0 | IVE_ERR_OP_CTL_SETFRAMETYPE_API_STRUCT_SIZE_INCORRECT; |
1288 | 0 | return IV_FAIL; |
1289 | 0 | } |
1290 | | |
1291 | 1.00k | if ((ps_ip->s_ive_ip.e_frame_type != IV_NA_FRAME) |
1292 | 1.00k | && (ps_ip->s_ive_ip.e_frame_type != IV_I_FRAME) |
1293 | 1.00k | && (ps_ip->s_ive_ip.e_frame_type != IV_P_FRAME) |
1294 | 1.00k | && (ps_ip->s_ive_ip.e_frame_type != IV_IDR_FRAME)) |
1295 | 0 | { |
1296 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1297 | 0 | << IVE_UNSUPPORTEDPARAM; |
1298 | 0 | ps_op->s_ive_op.u4_error_code |= |
1299 | 0 | IH264E_INVALID_FORCE_FRAME_INPUT; |
1300 | 0 | return IV_FAIL; |
1301 | 0 | } |
1302 | 1.00k | break; |
1303 | 1.00k | } |
1304 | | |
1305 | 4.87k | case IVE_CMD_CTL_SET_ME_PARAMS: |
1306 | 4.87k | { |
1307 | 4.87k | codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle); |
1308 | | |
1309 | 4.87k | ih264e_ctl_set_me_params_ip_t *ps_ip = pv_api_ip; |
1310 | 4.87k | ih264e_ctl_set_me_params_op_t *ps_op = pv_api_op; |
1311 | | |
1312 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1313 | 4.87k | != sizeof(ih264e_ctl_set_me_params_ip_t)) |
1314 | 0 | { |
1315 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1316 | 0 | << IVE_UNSUPPORTEDPARAM; |
1317 | 0 | ps_op->s_ive_op.u4_error_code |= |
1318 | 0 | IVE_ERR_IP_CTL_SETMEPARAMS_API_STRUCT_SIZE_INCORRECT; |
1319 | 0 | return IV_FAIL; |
1320 | 0 | } |
1321 | | |
1322 | 4.87k | if (ps_op->s_ive_op.u4_size |
1323 | 4.87k | != sizeof(ih264e_ctl_set_me_params_op_t)) |
1324 | 0 | { |
1325 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1326 | 0 | << IVE_UNSUPPORTEDPARAM; |
1327 | 0 | ps_op->s_ive_op.u4_error_code |= |
1328 | 0 | IVE_ERR_OP_CTL_SETMEPARAMS_API_STRUCT_SIZE_INCORRECT; |
1329 | 0 | return IV_FAIL; |
1330 | 0 | } |
1331 | | |
1332 | 4.87k | if (ps_ip->s_ive_ip.u4_me_speed_preset != DMND_SRCH) |
1333 | 3.52k | { |
1334 | 3.52k | ps_op->s_ive_op.u4_error_code |= 1 |
1335 | 3.52k | << IVE_UNSUPPORTEDPARAM; |
1336 | 3.52k | ps_op->s_ive_op.u4_error_code |= |
1337 | 3.52k | IH264E_INVALID_ME_SPEED_PRESET; |
1338 | 3.52k | return IV_FAIL; |
1339 | 3.52k | } |
1340 | | |
1341 | 1.35k | if ((ps_ip->s_ive_ip.u4_enable_hpel != 0) |
1342 | 1.35k | && (ps_ip->s_ive_ip.u4_enable_hpel != 1)) |
1343 | 0 | { |
1344 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1345 | 0 | << IVE_UNSUPPORTEDPARAM; |
1346 | 0 | ps_op->s_ive_op.u4_error_code |= |
1347 | 0 | IH264E_INVALID_HALFPEL_OPTION; |
1348 | 0 | return IV_FAIL; |
1349 | 0 | } |
1350 | | |
1351 | 1.35k | if ((ps_ip->s_ive_ip.u4_enable_qpel != 0) |
1352 | 1.35k | && (ps_ip->s_ive_ip.u4_enable_qpel != 1)) |
1353 | 0 | { |
1354 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1355 | 0 | << IVE_UNSUPPORTEDPARAM; |
1356 | 0 | ps_op->s_ive_op.u4_error_code |= |
1357 | 0 | IH264E_INVALID_QPEL_OPTION; |
1358 | 0 | return IV_FAIL; |
1359 | 0 | } |
1360 | | |
1361 | 1.35k | if ((ps_ip->s_ive_ip.u4_enable_fast_sad != 0) |
1362 | 1.35k | && (ps_ip->s_ive_ip.u4_enable_fast_sad != 1)) |
1363 | 0 | { |
1364 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1365 | 0 | << IVE_UNSUPPORTEDPARAM; |
1366 | 0 | ps_op->s_ive_op.u4_error_code |= |
1367 | 0 | IH264E_INVALID_FAST_SAD_OPTION; |
1368 | 0 | return IV_FAIL; |
1369 | 0 | } |
1370 | | |
1371 | 1.35k | if (ps_ip->s_ive_ip.u4_enable_alt_ref > 255) |
1372 | 0 | { |
1373 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1374 | 0 | << IVE_UNSUPPORTEDPARAM; |
1375 | 0 | ps_op->s_ive_op.u4_error_code |= |
1376 | 0 | IH264E_INVALID_ALT_REF_OPTION; |
1377 | 0 | return IV_FAIL; |
1378 | 0 | } |
1379 | | |
1380 | 1.35k | if (ps_ip->s_ive_ip.u4_srch_rng_x |
1381 | 1.35k | > ps_codec->s_cfg.u4_max_srch_rng_x) |
1382 | 0 | { |
1383 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1384 | 0 | << IVE_UNSUPPORTEDPARAM; |
1385 | 0 | ps_op->s_ive_op.u4_error_code |= |
1386 | 0 | IH264E_HORIZONTAL_SEARCH_RANGE_NOT_SUPPORTED; |
1387 | 0 | return (IV_FAIL); |
1388 | 0 | } |
1389 | | |
1390 | 1.35k | if (ps_ip->s_ive_ip.u4_srch_rng_y |
1391 | 1.35k | > ps_codec->s_cfg.u4_max_srch_rng_y) |
1392 | 0 | { |
1393 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1394 | 0 | << IVE_UNSUPPORTEDPARAM; |
1395 | 0 | ps_op->s_ive_op.u4_error_code |= |
1396 | 0 | IH264E_VERTICAL_SEARCH_RANGE_NOT_SUPPORTED; |
1397 | 0 | return (IV_FAIL); |
1398 | 0 | } |
1399 | | |
1400 | 1.35k | break; |
1401 | 1.35k | } |
1402 | | |
1403 | 4.87k | case IVE_CMD_CTL_SET_IPE_PARAMS: |
1404 | 4.87k | { |
1405 | 4.87k | ih264e_ctl_set_ipe_params_ip_t *ps_ip = pv_api_ip; |
1406 | 4.87k | ih264e_ctl_set_ipe_params_op_t *ps_op = pv_api_op; |
1407 | | |
1408 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1409 | 4.87k | != sizeof(ih264e_ctl_set_ipe_params_ip_t)) |
1410 | 0 | { |
1411 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1412 | 0 | << IVE_UNSUPPORTEDPARAM; |
1413 | 0 | ps_op->s_ive_op.u4_error_code |= |
1414 | 0 | IVE_ERR_IP_CTL_SETIPEPARAMS_API_STRUCT_SIZE_INCORRECT; |
1415 | 0 | return IV_FAIL; |
1416 | 0 | } |
1417 | | |
1418 | 4.87k | if (ps_op->s_ive_op.u4_size |
1419 | 4.87k | != sizeof(ih264e_ctl_set_ipe_params_op_t)) |
1420 | 0 | { |
1421 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1422 | 0 | << IVE_UNSUPPORTEDPARAM; |
1423 | 0 | ps_op->s_ive_op.u4_error_code |= |
1424 | 0 | IVE_ERR_OP_CTL_SETIPEPARAMS_API_STRUCT_SIZE_INCORRECT; |
1425 | 0 | return IV_FAIL; |
1426 | 0 | } |
1427 | | |
1428 | 4.87k | if ((ps_ip->s_ive_ip.u4_enable_intra_4x4 != 0) |
1429 | 4.87k | && (ps_ip->s_ive_ip.u4_enable_intra_4x4 != 1)) |
1430 | 0 | { |
1431 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1432 | 0 | << IVE_UNSUPPORTEDPARAM; |
1433 | 0 | ps_op->s_ive_op.u4_error_code |= |
1434 | 0 | IH264E_INVALID_INTRA4x4_OPTION; |
1435 | 0 | return IV_FAIL; |
1436 | 0 | } |
1437 | | |
1438 | 4.87k | if ((ps_ip->s_ive_ip.u4_constrained_intra_pred != 0) |
1439 | 4.87k | && (ps_ip->s_ive_ip.u4_constrained_intra_pred != 1)) |
1440 | 0 | { |
1441 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1442 | 0 | << IVE_UNSUPPORTEDPARAM; |
1443 | 0 | ps_op->s_ive_op.u4_error_code |= |
1444 | 0 | IH264E_INVALID_CONSTRAINED_INTRA_PREDICTION_MODE; |
1445 | 0 | return IV_FAIL; |
1446 | 0 | } |
1447 | | |
1448 | 4.87k | if ((ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_CONFIG) |
1449 | 4.87k | && (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_SLOWEST) |
1450 | 4.87k | && (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_NORMAL) |
1451 | 4.87k | && (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_FAST) |
1452 | 4.87k | && (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_HIGH_SPEED) |
1453 | 4.87k | && (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_FASTEST)) |
1454 | 0 | { |
1455 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1456 | 0 | << IVE_UNSUPPORTEDPARAM; |
1457 | 0 | ps_op->s_ive_op.u4_error_code |= |
1458 | 0 | IH264E_INVALID_ENC_SPEED_PRESET; |
1459 | 0 | return IV_FAIL; |
1460 | 0 | } |
1461 | | |
1462 | 4.87k | break; |
1463 | 4.87k | } |
1464 | | |
1465 | 4.87k | case IVE_CMD_CTL_SET_GOP_PARAMS: |
1466 | 4.87k | { |
1467 | 4.87k | ih264e_ctl_set_gop_params_ip_t *ps_ip = pv_api_ip; |
1468 | 4.87k | ih264e_ctl_set_gop_params_op_t *ps_op = pv_api_op; |
1469 | | |
1470 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1471 | 4.87k | != sizeof(ih264e_ctl_set_gop_params_ip_t)) |
1472 | 0 | { |
1473 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1474 | 0 | << IVE_UNSUPPORTEDPARAM; |
1475 | 0 | ps_op->s_ive_op.u4_error_code |= |
1476 | 0 | IVE_ERR_IP_CTL_SETGOPPARAMS_API_STRUCT_SIZE_INCORRECT; |
1477 | 0 | return IV_FAIL; |
1478 | 0 | } |
1479 | | |
1480 | 4.87k | if (ps_op->s_ive_op.u4_size |
1481 | 4.87k | != sizeof(ih264e_ctl_set_gop_params_op_t)) |
1482 | 0 | { |
1483 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1484 | 0 | << IVE_UNSUPPORTEDPARAM; |
1485 | 0 | ps_op->s_ive_op.u4_error_code |= |
1486 | 0 | IVE_ERR_OP_CTL_SETGOPPARAMS_API_STRUCT_SIZE_INCORRECT; |
1487 | 0 | return IV_FAIL; |
1488 | 0 | } |
1489 | | |
1490 | 4.87k | if ((ps_ip->s_ive_ip.u4_i_frm_interval < DEFAULT_MIN_INTRA_FRAME_RATE) |
1491 | 4.87k | || (ps_ip->s_ive_ip.u4_i_frm_interval > DEFAULT_MAX_INTRA_FRAME_RATE)) |
1492 | 0 | { |
1493 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1494 | 0 | << IVE_UNSUPPORTEDPARAM; |
1495 | 0 | ps_op->s_ive_op.u4_error_code |= |
1496 | 0 | IH264E_INVALID_INTRA_FRAME_INTERVAL; |
1497 | 0 | return IV_FAIL; |
1498 | 0 | } |
1499 | | |
1500 | 4.87k | if ((ps_ip->s_ive_ip.u4_idr_frm_interval < DEFAULT_MIN_INTRA_FRAME_RATE) |
1501 | 4.87k | || (ps_ip->s_ive_ip.u4_idr_frm_interval > DEFAULT_MAX_INTRA_FRAME_RATE)) |
1502 | 0 | { |
1503 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1504 | 0 | << IVE_UNSUPPORTEDPARAM; |
1505 | 0 | ps_op->s_ive_op.u4_error_code |= |
1506 | 0 | IH264E_INVALID_IDR_FRAME_INTERVAL; |
1507 | 0 | return IV_FAIL; |
1508 | 0 | } |
1509 | | |
1510 | 4.87k | if((ps_ip->s_ive_ip.u4_idr_frm_interval > ps_ip->s_ive_ip.u4_i_frm_interval) && |
1511 | 4.87k | (ps_ip->s_ive_ip.u4_idr_frm_interval % ps_ip->s_ive_ip.u4_i_frm_interval != 0)) |
1512 | 956 | { |
1513 | 956 | ps_op->s_ive_op.u4_error_code |= 1 |
1514 | 956 | << IVE_UNSUPPORTEDPARAM; |
1515 | 956 | ps_op->s_ive_op.u4_error_code |= |
1516 | 956 | IH264E_INVALID_INTRA_FRAME_INTERVAL; |
1517 | 956 | return IV_FAIL; |
1518 | 956 | } |
1519 | | |
1520 | 3.92k | break; |
1521 | 4.87k | } |
1522 | | |
1523 | 4.87k | case IVE_CMD_CTL_SET_DEBLOCK_PARAMS: |
1524 | 4.87k | { |
1525 | 4.87k | ih264e_ctl_set_deblock_params_ip_t *ps_ip = pv_api_ip; |
1526 | 4.87k | ih264e_ctl_set_deblock_params_op_t *ps_op = pv_api_op; |
1527 | | |
1528 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1529 | 4.87k | != sizeof(ih264e_ctl_set_deblock_params_ip_t)) |
1530 | 0 | { |
1531 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1532 | 0 | << IVE_UNSUPPORTEDPARAM; |
1533 | 0 | ps_op->s_ive_op.u4_error_code |= |
1534 | 0 | IVE_ERR_IP_CTL_SETDEBLKPARAMS_API_STRUCT_SIZE_INCORRECT; |
1535 | 0 | return IV_FAIL; |
1536 | 0 | } |
1537 | | |
1538 | 4.87k | if (ps_op->s_ive_op.u4_size |
1539 | 4.87k | != sizeof(ih264e_ctl_set_deblock_params_op_t)) |
1540 | 0 | { |
1541 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1542 | 0 | << IVE_UNSUPPORTEDPARAM; |
1543 | 0 | ps_op->s_ive_op.u4_error_code |= |
1544 | 0 | IVE_ERR_OP_CTL_SETDEBLKPARAMS_API_STRUCT_SIZE_INCORRECT; |
1545 | 0 | return IV_FAIL; |
1546 | 0 | } |
1547 | | |
1548 | 4.87k | if ((ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_0) |
1549 | 4.87k | && (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_2) |
1550 | 4.87k | && (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_3) |
1551 | 4.87k | && (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_4)) |
1552 | 847 | { |
1553 | 847 | ps_op->s_ive_op.u4_error_code |= 1 |
1554 | 847 | << IVE_UNSUPPORTEDPARAM; |
1555 | 847 | ps_op->s_ive_op.u4_error_code |= |
1556 | 847 | IH264E_INVALID_DEBLOCKING_TYPE_INPUT; |
1557 | 847 | return IV_FAIL; |
1558 | 847 | } |
1559 | | |
1560 | 4.02k | break; |
1561 | 4.87k | } |
1562 | | |
1563 | 4.87k | case IVE_CMD_CTL_SET_QP: |
1564 | 4.87k | { |
1565 | 4.87k | ih264e_ctl_set_qp_ip_t *ps_ip = pv_api_ip; |
1566 | 4.87k | ih264e_ctl_set_qp_op_t *ps_op = pv_api_op; |
1567 | | |
1568 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
1569 | 4.87k | != sizeof(ih264e_ctl_set_qp_ip_t)) |
1570 | 0 | { |
1571 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1572 | 0 | << IVE_UNSUPPORTEDPARAM; |
1573 | 0 | ps_op->s_ive_op.u4_error_code |= |
1574 | 0 | IVE_ERR_IP_CTL_SETQPPARAMS_API_STRUCT_SIZE_INCORRECT; |
1575 | 0 | return IV_FAIL; |
1576 | 0 | } |
1577 | | |
1578 | 4.87k | if (ps_op->s_ive_op.u4_size |
1579 | 4.87k | != sizeof(ih264e_ctl_set_qp_op_t)) |
1580 | 0 | { |
1581 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1582 | 0 | << IVE_UNSUPPORTEDPARAM; |
1583 | 0 | ps_op->s_ive_op.u4_error_code |= |
1584 | 0 | IVE_ERR_OP_CTL_SETQPPARAMS_API_STRUCT_SIZE_INCORRECT; |
1585 | 0 | return IV_FAIL; |
1586 | 0 | } |
1587 | | |
1588 | 4.87k | if ((ps_ip->s_ive_ip.u4_i_qp_max > MAX_H264_QP) |
1589 | 4.87k | || (ps_ip->s_ive_ip.u4_p_qp_max > MAX_H264_QP) |
1590 | 4.87k | || (ps_ip->s_ive_ip.u4_b_qp_max > MAX_H264_QP)) |
1591 | 0 | { |
1592 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1593 | 0 | << IVE_UNSUPPORTEDPARAM; |
1594 | 0 | ps_op->s_ive_op.u4_error_code |= |
1595 | 0 | IH264E_INVALID_MAX_FRAME_QP; |
1596 | 0 | return IV_FAIL; |
1597 | 0 | } |
1598 | | |
1599 | | /* We donot support QP < 4 */ |
1600 | 4.87k | if ((ps_ip->s_ive_ip.u4_i_qp_min < 4) |
1601 | 4.87k | || (ps_ip->s_ive_ip.u4_p_qp_min < 4) |
1602 | 4.87k | || (ps_ip->s_ive_ip.u4_b_qp_min < 4) |
1603 | 4.87k | || (ps_ip->s_ive_ip.u4_i_qp_min > ps_ip->s_ive_ip.u4_i_qp_max) |
1604 | 4.87k | || (ps_ip->s_ive_ip.u4_p_qp_min > ps_ip->s_ive_ip.u4_p_qp_max) |
1605 | 4.87k | || (ps_ip->s_ive_ip.u4_b_qp_min > ps_ip->s_ive_ip.u4_b_qp_max)) |
1606 | 0 | { |
1607 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1608 | 0 | << IVE_UNSUPPORTEDPARAM; |
1609 | 0 | ps_op->s_ive_op.u4_error_code |= |
1610 | 0 | IH264E_INVALID_MIN_FRAME_QP; |
1611 | 0 | return IV_FAIL; |
1612 | 0 | } |
1613 | | |
1614 | 4.87k | if ((ps_ip->s_ive_ip.u4_i_qp > ps_ip->s_ive_ip.u4_i_qp_max) |
1615 | 4.87k | || (ps_ip->s_ive_ip.u4_p_qp > ps_ip->s_ive_ip.u4_p_qp_max) |
1616 | 4.87k | || (ps_ip->s_ive_ip.u4_b_qp > ps_ip->s_ive_ip.u4_b_qp_max) |
1617 | 4.87k | || (ps_ip->s_ive_ip.u4_i_qp < ps_ip->s_ive_ip.u4_i_qp_min) |
1618 | 4.87k | || (ps_ip->s_ive_ip.u4_p_qp < ps_ip->s_ive_ip.u4_p_qp_min) |
1619 | 4.87k | || (ps_ip->s_ive_ip.u4_b_qp < ps_ip->s_ive_ip.u4_b_qp_min)) |
1620 | 0 | { |
1621 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
1622 | 0 | << IVE_UNSUPPORTEDPARAM; |
1623 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_INVALID_INIT_QP; |
1624 | 0 | return IV_FAIL; |
1625 | 0 | } |
1626 | | |
1627 | 4.87k | break; |
1628 | 4.87k | } |
1629 | | |
1630 | 4.87k | case IVE_CMD_CTL_SET_VUI_PARAMS: |
1631 | 4.87k | { |
1632 | 4.87k | ih264e_vui_ip_t *ps_ip = pv_api_ip; |
1633 | 4.87k | ih264e_vui_op_t *ps_op = pv_api_op; |
1634 | | |
1635 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_vui_ip_t)) |
1636 | 0 | { |
1637 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1638 | 0 | ps_op->u4_error_code |= |
1639 | 0 | IVE_ERR_IP_CTL_SET_VUI_STRUCT_SIZE_INCORRECT; |
1640 | 0 | return IV_FAIL; |
1641 | 0 | } |
1642 | | |
1643 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_vui_op_t)) |
1644 | 0 | { |
1645 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1646 | 0 | ps_op->u4_error_code |= |
1647 | 0 | IVE_ERR_OP_CTL_SET_VUI_STRUCT_SIZE_INCORRECT; |
1648 | 0 | return IV_FAIL; |
1649 | 0 | } |
1650 | | |
1651 | 4.87k | break; |
1652 | 4.87k | } |
1653 | | |
1654 | 4.87k | case IVE_CMD_CTL_SET_SEI_MDCV_PARAMS: |
1655 | 4.87k | { |
1656 | 4.87k | ih264e_ctl_set_sei_mdcv_params_ip_t *ps_ip = pv_api_ip; |
1657 | 4.87k | ih264e_ctl_set_sei_mdcv_params_op_t *ps_op = pv_api_op; |
1658 | | |
1659 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_mdcv_params_ip_t)) |
1660 | 0 | { |
1661 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1662 | 0 | ps_op->u4_error_code |= |
1663 | 0 | IVE_ERR_IP_CTL_SET_SEI_MDCV_STRUCT_SIZE_INCORRECT; |
1664 | 0 | return IV_FAIL; |
1665 | 0 | } |
1666 | | |
1667 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_mdcv_params_op_t)) |
1668 | 0 | { |
1669 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1670 | 0 | ps_op->u4_error_code |= |
1671 | 0 | IVE_ERR_OP_CTL_SET_SEI_MDCV_STRUCT_SIZE_INCORRECT; |
1672 | 0 | return IV_FAIL; |
1673 | 0 | } |
1674 | | |
1675 | 4.87k | if((ps_ip->u1_sei_mdcv_params_present_flag != 0) |
1676 | 4.87k | && (ps_ip->u1_sei_mdcv_params_present_flag) != 1) |
1677 | 0 | { |
1678 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1679 | 0 | ps_op->u4_error_code |= |
1680 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1681 | 0 | return IV_FAIL; |
1682 | 0 | } |
1683 | | |
1684 | 4.87k | if(1 == ps_ip->u1_sei_mdcv_params_present_flag) |
1685 | 2.05k | { |
1686 | | /* Check values for u2_display_primaries_x and u2_display_primaries_y */ |
1687 | 8.23k | for(i = 0; i < 3; i++) |
1688 | 6.17k | { |
1689 | 6.17k | if((ps_ip->au2_display_primaries_x[i] > |
1690 | 6.17k | DISPLAY_PRIMARIES_X_UPPER_LIMIT) || |
1691 | 6.17k | (ps_ip->au2_display_primaries_x[i] < |
1692 | 6.17k | DISPLAY_PRIMARIES_X_LOWER_LIMIT) || |
1693 | 6.17k | ((ps_ip->au2_display_primaries_x[i] % |
1694 | 6.17k | DISPLAY_PRIMARIES_X_DIVISION_FACTOR) != 0)) |
1695 | 0 | { |
1696 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1697 | 0 | ps_op->u4_error_code |= |
1698 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1699 | 0 | return IV_FAIL; |
1700 | 0 | } |
1701 | | |
1702 | 6.17k | if((ps_ip->au2_display_primaries_y[i] > |
1703 | 6.17k | DISPLAY_PRIMARIES_Y_UPPER_LIMIT) || |
1704 | 6.17k | (ps_ip->au2_display_primaries_y[i] < |
1705 | 6.17k | DISPLAY_PRIMARIES_Y_LOWER_LIMIT) || |
1706 | 6.17k | ((ps_ip->au2_display_primaries_y[i] % |
1707 | 6.17k | DISPLAY_PRIMARIES_Y_DIVISION_FACTOR) != 0)) |
1708 | 0 | { |
1709 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1710 | 0 | ps_op->u4_error_code |= |
1711 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1712 | 0 | return IV_FAIL; |
1713 | 0 | } |
1714 | 6.17k | } |
1715 | | |
1716 | 2.05k | if((ps_ip->u2_white_point_x > WHITE_POINT_X_UPPER_LIMIT) || |
1717 | 2.05k | (ps_ip->u2_white_point_x < WHITE_POINT_X_LOWER_LIMIT) || |
1718 | 2.05k | ((ps_ip->u2_white_point_x % WHITE_POINT_X_DIVISION_FACTOR) != 0)) |
1719 | 0 | { |
1720 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1721 | 0 | ps_op->u4_error_code |= |
1722 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1723 | 0 | return IV_FAIL; |
1724 | 0 | } |
1725 | | |
1726 | 2.05k | if((ps_ip->u2_white_point_y > WHITE_POINT_Y_UPPER_LIMIT) || |
1727 | 2.05k | (ps_ip->u2_white_point_y < WHITE_POINT_Y_LOWER_LIMIT) || |
1728 | 2.05k | ((ps_ip->u2_white_point_y % WHITE_POINT_Y_DIVISION_FACTOR) != 0)) |
1729 | 0 | { |
1730 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1731 | 0 | ps_op->u4_error_code |= |
1732 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1733 | 0 | return IV_FAIL; |
1734 | 0 | } |
1735 | | |
1736 | 2.05k | if((ps_ip->u4_max_display_mastering_luminance > |
1737 | 2.05k | MAX_DISPLAY_MASTERING_LUMINANCE_UPPER_LIMIT) || |
1738 | 2.05k | (ps_ip->u4_max_display_mastering_luminance < |
1739 | 2.05k | MAX_DISPLAY_MASTERING_LUMINANCE_LOWER_LIMIT) || |
1740 | 2.05k | ((ps_ip->u4_max_display_mastering_luminance % |
1741 | 2.05k | MAX_DISPLAY_MASTERING_LUMINANCE_DIVISION_FACTOR) != 0)) |
1742 | 0 | { |
1743 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1744 | 0 | ps_op->u4_error_code |= |
1745 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1746 | 0 | return IV_FAIL; |
1747 | 0 | } |
1748 | | |
1749 | 2.05k | if((ps_ip->u4_min_display_mastering_luminance > |
1750 | 2.05k | MIN_DISPLAY_MASTERING_LUMINANCE_UPPER_LIMIT ) || |
1751 | 2.05k | (ps_ip->u4_min_display_mastering_luminance < |
1752 | 2.05k | MIN_DISPLAY_MASTERING_LUMINANCE_LOWER_LIMIT)) |
1753 | 0 | { |
1754 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1755 | 0 | ps_op->u4_error_code |= |
1756 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1757 | 0 | return IV_FAIL; |
1758 | 0 | } |
1759 | | |
1760 | 2.05k | if(ps_ip->u4_max_display_mastering_luminance <= |
1761 | 2.05k | ps_ip->u4_min_display_mastering_luminance) |
1762 | 0 | { |
1763 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1764 | 0 | ps_op->u4_error_code |= |
1765 | 0 | IH264E_INVALID_SEI_MDCV_PARAMS; |
1766 | 0 | return IV_FAIL; |
1767 | 0 | } |
1768 | 2.05k | } |
1769 | 4.87k | break; |
1770 | 4.87k | } |
1771 | | |
1772 | 4.87k | case IVE_CMD_CTL_SET_SEI_CLL_PARAMS: |
1773 | 4.87k | { |
1774 | 4.87k | ih264e_ctl_set_sei_cll_params_ip_t *ps_ip = pv_api_ip; |
1775 | 4.87k | ih264e_ctl_set_sei_cll_params_op_t *ps_op = pv_api_op; |
1776 | | |
1777 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_cll_params_ip_t)) |
1778 | 0 | { |
1779 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1780 | 0 | ps_op->u4_error_code |= |
1781 | 0 | IVE_ERR_IP_CTL_SET_SEI_CLL_STRUCT_SIZE_INCORRECT; |
1782 | 0 | return IV_FAIL; |
1783 | 0 | } |
1784 | | |
1785 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_cll_params_op_t)) |
1786 | 0 | { |
1787 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1788 | 0 | ps_op->u4_error_code |= |
1789 | 0 | IVE_ERR_OP_CTL_SET_SEI_CLL_STRUCT_SIZE_INCORRECT; |
1790 | 0 | return IV_FAIL; |
1791 | 0 | } |
1792 | | |
1793 | 4.87k | if((ps_ip->u1_sei_cll_params_present_flag != 0) |
1794 | 4.87k | && (ps_ip->u1_sei_cll_params_present_flag != 1)) |
1795 | 0 | { |
1796 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1797 | 0 | ps_op->u4_error_code |= |
1798 | 0 | IH264E_INVALID_SEI_CLL_PARAMS; |
1799 | 0 | return IV_FAIL; |
1800 | 0 | } |
1801 | 4.87k | break; |
1802 | 4.87k | } |
1803 | | |
1804 | 4.87k | case IVE_CMD_CTL_SET_SEI_AVE_PARAMS: |
1805 | 4.87k | { |
1806 | 4.87k | ih264e_ctl_set_sei_ave_params_ip_t *ps_ip = pv_api_ip; |
1807 | 4.87k | ih264e_ctl_set_sei_ave_params_op_t *ps_op = pv_api_op; |
1808 | | |
1809 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_ave_params_ip_t)) |
1810 | 0 | { |
1811 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1812 | 0 | ps_op->u4_error_code |= |
1813 | 0 | IVE_ERR_IP_CTL_SET_SEI_AVE_STRUCT_SIZE_INCORRECT; |
1814 | 0 | return IV_FAIL; |
1815 | 0 | } |
1816 | | |
1817 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_ave_params_op_t)) |
1818 | 0 | { |
1819 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1820 | 0 | ps_op->u4_error_code |= |
1821 | 0 | IVE_ERR_OP_CTL_SET_SEI_AVE_STRUCT_SIZE_INCORRECT; |
1822 | 0 | return IV_FAIL; |
1823 | 0 | } |
1824 | | |
1825 | 4.87k | if((ps_ip->u1_sei_ave_params_present_flag != 0) |
1826 | 4.87k | && (ps_ip->u1_sei_ave_params_present_flag != 1)) |
1827 | 0 | { |
1828 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1829 | 0 | ps_op->u4_error_code |= |
1830 | 0 | IH264E_INVALID_SEI_AVE_PARAMS; |
1831 | 0 | return IV_FAIL; |
1832 | 0 | } |
1833 | | |
1834 | 4.87k | if(1 == ps_ip->u1_sei_ave_params_present_flag) |
1835 | 1.82k | { |
1836 | 1.82k | if((0 == ps_ip->u4_ambient_illuminance)) |
1837 | 0 | { |
1838 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1839 | 0 | ps_op->u4_error_code |= |
1840 | 0 | IH264E_INVALID_SEI_AVE_PARAMS; |
1841 | 0 | return IV_FAIL; |
1842 | 0 | } |
1843 | | |
1844 | 1.82k | if(ps_ip->u2_ambient_light_x > AMBIENT_LIGHT_X_UPPER_LIMIT) |
1845 | 0 | { |
1846 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1847 | 0 | ps_op->u4_error_code |= |
1848 | 0 | IH264E_INVALID_SEI_AVE_PARAMS; |
1849 | 0 | return IV_FAIL; |
1850 | 0 | } |
1851 | | |
1852 | 1.82k | if(ps_ip->u2_ambient_light_y > AMBIENT_LIGHT_Y_UPPER_LIMIT) |
1853 | 0 | { |
1854 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1855 | 0 | ps_op->u4_error_code |= |
1856 | 0 | IH264E_INVALID_SEI_AVE_PARAMS; |
1857 | 0 | return IV_FAIL; |
1858 | 0 | } |
1859 | 1.82k | } |
1860 | 4.87k | break; |
1861 | 4.87k | } |
1862 | | |
1863 | 4.87k | case IVE_CMD_CTL_SET_SEI_CCV_PARAMS: |
1864 | 4.87k | { |
1865 | 4.87k | ih264e_ctl_set_sei_ccv_params_ip_t *ps_ip = pv_api_ip; |
1866 | 4.87k | ih264e_ctl_set_sei_ccv_params_op_t *ps_op = pv_api_op; |
1867 | | |
1868 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_ccv_params_ip_t)) |
1869 | 0 | { |
1870 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1871 | 0 | ps_op->u4_error_code |= |
1872 | 0 | IVE_ERR_IP_CTL_SET_SEI_CCV_STRUCT_SIZE_INCORRECT; |
1873 | 0 | return IV_FAIL; |
1874 | 0 | } |
1875 | | |
1876 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_ccv_params_op_t)) |
1877 | 0 | { |
1878 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1879 | 0 | ps_op->u4_error_code |= |
1880 | 0 | IVE_ERR_OP_CTL_SET_SEI_CCV_STRUCT_SIZE_INCORRECT; |
1881 | 0 | return IV_FAIL; |
1882 | 0 | } |
1883 | | |
1884 | 4.87k | if((ps_ip->u1_sei_ccv_params_present_flag != 0) |
1885 | 4.87k | && (ps_ip->u1_sei_ccv_params_present_flag != 1)) |
1886 | 0 | { |
1887 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1888 | 0 | ps_op->u4_error_code |= |
1889 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1890 | 0 | return IV_FAIL; |
1891 | 0 | } |
1892 | | |
1893 | | |
1894 | 4.87k | if(1 == ps_ip->u1_sei_ccv_params_present_flag) |
1895 | 1.61k | { |
1896 | 1.61k | if((ps_ip->u1_ccv_cancel_flag != 0) |
1897 | 1.61k | && (ps_ip->u1_ccv_cancel_flag != 1)) |
1898 | 0 | { |
1899 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1900 | 0 | ps_op->u4_error_code |= |
1901 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1902 | 0 | return IV_FAIL; |
1903 | 0 | } |
1904 | | |
1905 | 1.61k | if(0 == ps_ip->u1_ccv_cancel_flag) |
1906 | 1.61k | { |
1907 | 1.61k | if((ps_ip->u1_ccv_persistence_flag != 0) |
1908 | 1.61k | && (ps_ip->u1_ccv_persistence_flag != 1)) |
1909 | 0 | { |
1910 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1911 | 0 | ps_op->u4_error_code |= |
1912 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1913 | 0 | return IV_FAIL; |
1914 | 0 | } |
1915 | 1.61k | if((ps_ip->u1_ccv_primaries_present_flag != 0) |
1916 | 1.61k | && (ps_ip->u1_ccv_primaries_present_flag != 1)) |
1917 | 0 | { |
1918 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1919 | 0 | ps_op->u4_error_code |= |
1920 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1921 | 0 | return IV_FAIL; |
1922 | 0 | } |
1923 | 1.61k | if((ps_ip->u1_ccv_min_luminance_value_present_flag != 0) |
1924 | 1.61k | && (ps_ip->u1_ccv_min_luminance_value_present_flag != 1)) |
1925 | 0 | { |
1926 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1927 | 0 | ps_op->u4_error_code |= |
1928 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1929 | 0 | return IV_FAIL; |
1930 | 0 | } |
1931 | 1.61k | if((ps_ip->u1_ccv_max_luminance_value_present_flag != 0) |
1932 | 1.61k | && (ps_ip->u1_ccv_max_luminance_value_present_flag != 1)) |
1933 | 0 | { |
1934 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1935 | 0 | ps_op->u4_error_code |= |
1936 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1937 | 0 | return IV_FAIL; |
1938 | 0 | } |
1939 | 1.61k | if((ps_ip->u1_ccv_avg_luminance_value_present_flag != 0) |
1940 | 1.61k | && (ps_ip->u1_ccv_avg_luminance_value_present_flag != 1)) |
1941 | 0 | { |
1942 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1943 | 0 | ps_op->u4_error_code |= |
1944 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1945 | 0 | return IV_FAIL; |
1946 | 0 | } |
1947 | 1.61k | if((ps_ip->u1_ccv_primaries_present_flag == 0) |
1948 | 1.61k | && (ps_ip->u1_ccv_min_luminance_value_present_flag == 0) |
1949 | 1.61k | && (ps_ip->u1_ccv_max_luminance_value_present_flag == 0) |
1950 | 1.61k | && (ps_ip->u1_ccv_avg_luminance_value_present_flag == 0)) |
1951 | 0 | { |
1952 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1953 | 0 | ps_op->u4_error_code |= |
1954 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1955 | 0 | return IV_FAIL; |
1956 | 0 | } |
1957 | | |
1958 | 1.61k | if((ps_ip->u1_ccv_reserved_zero_2bits != 0)) |
1959 | 0 | { |
1960 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1961 | 0 | ps_op->u4_error_code |= |
1962 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1963 | 0 | return IV_FAIL; |
1964 | 0 | } |
1965 | | |
1966 | 1.61k | if(1 == ps_ip->u1_ccv_primaries_present_flag) |
1967 | 1.61k | { |
1968 | 6.47k | for(i = 0; i < 3; i++) |
1969 | 4.85k | { |
1970 | 4.85k | if((ps_ip->ai4_ccv_primaries_x[i] > |
1971 | 4.85k | CCV_PRIMARIES_X_UPPER_LIMIT) || |
1972 | 4.85k | (ps_ip->ai4_ccv_primaries_x[i] < |
1973 | 4.85k | CCV_PRIMARIES_X_LOWER_LIMIT)) |
1974 | 0 | { |
1975 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1976 | 0 | ps_op->u4_error_code |= |
1977 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1978 | 0 | return IV_FAIL; |
1979 | 0 | } |
1980 | | |
1981 | 4.85k | if((ps_ip->ai4_ccv_primaries_y[i] > |
1982 | 4.85k | CCV_PRIMARIES_Y_UPPER_LIMIT) || |
1983 | 4.85k | (ps_ip->ai4_ccv_primaries_y[i] < |
1984 | 4.85k | CCV_PRIMARIES_Y_LOWER_LIMIT)) |
1985 | 0 | { |
1986 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
1987 | 0 | ps_op->u4_error_code |= |
1988 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
1989 | 0 | return IV_FAIL; |
1990 | 0 | } |
1991 | 4.85k | } |
1992 | 1.61k | } |
1993 | | |
1994 | 1.61k | if((1 == ps_ip->u1_ccv_min_luminance_value_present_flag) && |
1995 | 1.61k | (1 == ps_ip->u1_ccv_avg_luminance_value_present_flag)) |
1996 | 1.61k | { |
1997 | 1.61k | if((ps_ip->u4_ccv_avg_luminance_value < |
1998 | 1.61k | ps_ip->u4_ccv_min_luminance_value)) |
1999 | 0 | { |
2000 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2001 | 0 | ps_op->u4_error_code |= |
2002 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
2003 | 0 | return IV_FAIL; |
2004 | 0 | } |
2005 | 1.61k | } |
2006 | | |
2007 | 1.61k | if((1 == ps_ip->u1_ccv_min_luminance_value_present_flag) && |
2008 | 1.61k | (1 == ps_ip->u1_ccv_max_luminance_value_present_flag)) |
2009 | 1.61k | { |
2010 | 1.61k | if((ps_ip->u4_ccv_max_luminance_value < |
2011 | 1.61k | ps_ip->u4_ccv_min_luminance_value)) |
2012 | 0 | { |
2013 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2014 | 0 | ps_op->u4_error_code |= |
2015 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
2016 | 0 | return IV_FAIL; |
2017 | 0 | } |
2018 | 1.61k | } |
2019 | 1.61k | if((1 == ps_ip->u1_ccv_avg_luminance_value_present_flag) && |
2020 | 1.61k | (1 == ps_ip->u1_ccv_max_luminance_value_present_flag)) |
2021 | 1.61k | { |
2022 | 1.61k | if((ps_ip->u4_ccv_max_luminance_value < |
2023 | 1.61k | ps_ip->u4_ccv_avg_luminance_value)) |
2024 | 0 | { |
2025 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2026 | 0 | ps_op->u4_error_code |= |
2027 | 0 | IH264E_INVALID_SEI_CCV_PARAMS; |
2028 | 0 | return IV_FAIL; |
2029 | 0 | } |
2030 | 1.61k | } |
2031 | 1.61k | } |
2032 | 1.61k | } |
2033 | 4.87k | break; |
2034 | 4.87k | } |
2035 | | |
2036 | 4.87k | case IVE_CMD_CTL_SET_SEI_SII_PARAMS: |
2037 | 4.87k | { |
2038 | 4.87k | ih264e_ctl_set_sei_sii_params_ip_t *ps_ip = pv_api_ip; |
2039 | 4.87k | ih264e_ctl_set_sei_sii_params_op_t *ps_op = pv_api_op; |
2040 | | |
2041 | 4.87k | if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_sii_params_ip_t)) |
2042 | 0 | { |
2043 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2044 | 0 | ps_op->u4_error_code |= IVE_ERR_IP_CTL_SET_SEI_SII_STRUCT_SIZE_INCORRECT; |
2045 | 0 | return IV_FAIL; |
2046 | 0 | } |
2047 | | |
2048 | 4.87k | if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_sii_params_op_t)) |
2049 | 0 | { |
2050 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2051 | 0 | ps_op->u4_error_code |= IVE_ERR_OP_CTL_SET_SEI_SII_STRUCT_SIZE_INCORRECT; |
2052 | 0 | return IV_FAIL; |
2053 | 0 | } |
2054 | | |
2055 | | /* The below error check is based on H264 spec docs SII syntax */ |
2056 | 4.87k | if(0 != ps_ip->u4_sii_sub_layer_idx) |
2057 | 0 | { |
2058 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2059 | 0 | ps_op->u4_error_code |= IH264E_INVALID_SEI_SII_PARAMS; |
2060 | 0 | return IV_FAIL; |
2061 | 0 | } |
2062 | | |
2063 | 4.87k | if(ps_ip->u1_sii_max_sub_layers_minus1 > 7) |
2064 | 0 | { |
2065 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2066 | 0 | ps_op->u4_error_code |= IH264E_INVALID_SEI_SII_PARAMS; |
2067 | 0 | return IV_FAIL; |
2068 | 0 | } |
2069 | | |
2070 | 4.87k | if((ps_ip->u4_sii_sub_layer_idx > 0) && |
2071 | 4.87k | (ps_ip->u1_fixed_shutter_interval_within_cvs_flag == 1)) |
2072 | 0 | { |
2073 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2074 | 0 | ps_op->u4_error_code |= IH264E_SEI_SII_FAILED_TO_MATCH_SPEC_COND; |
2075 | 0 | return IV_FAIL; |
2076 | 0 | } |
2077 | | |
2078 | 4.87k | if((ps_ip->u4_sii_sub_layer_idx > ps_ip->u1_sii_max_sub_layers_minus1) && |
2079 | 4.87k | (ps_ip->u1_fixed_shutter_interval_within_cvs_flag == 0)) |
2080 | 0 | { |
2081 | 0 | ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM; |
2082 | 0 | ps_op->u4_error_code |= IH264E_SEI_SII_FAILED_TO_MATCH_SPEC_COND; |
2083 | 0 | return IV_FAIL; |
2084 | 0 | } |
2085 | | |
2086 | 4.87k | break; |
2087 | 4.87k | } |
2088 | | |
2089 | 4.87k | case IVE_CMD_CTL_SET_ENC_MODE: |
2090 | 4.87k | { |
2091 | 4.87k | ih264e_ctl_set_enc_mode_ip_t *ps_ip = pv_api_ip; |
2092 | 4.87k | ih264e_ctl_set_enc_mode_op_t *ps_op = pv_api_op; |
2093 | | |
2094 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
2095 | 4.87k | != sizeof(ih264e_ctl_set_enc_mode_ip_t)) |
2096 | 0 | { |
2097 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2098 | 0 | << IVE_UNSUPPORTEDPARAM; |
2099 | 0 | ps_op->s_ive_op.u4_error_code |= |
2100 | 0 | IVE_ERR_IP_CTL_SETENCMODE_API_STRUCT_SIZE_INCORRECT; |
2101 | 0 | return IV_FAIL; |
2102 | 0 | } |
2103 | | |
2104 | 4.87k | if (ps_op->s_ive_op.u4_size |
2105 | 4.87k | != sizeof(ih264e_ctl_set_enc_mode_op_t)) |
2106 | 0 | { |
2107 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2108 | 0 | << IVE_UNSUPPORTEDPARAM; |
2109 | 0 | ps_op->s_ive_op.u4_error_code |= |
2110 | 0 | IVE_ERR_OP_CTL_SETENCMODE_API_STRUCT_SIZE_INCORRECT; |
2111 | 0 | return IV_FAIL; |
2112 | 0 | } |
2113 | | |
2114 | 4.87k | if ((ps_ip->s_ive_ip.e_enc_mode != IVE_ENC_MODE_HEADER) |
2115 | 4.87k | && (ps_ip->s_ive_ip.e_enc_mode != IVE_ENC_MODE_PICTURE)) |
2116 | 0 | { |
2117 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2118 | 0 | << IVE_UNSUPPORTEDPARAM; |
2119 | 0 | ps_op->s_ive_op.u4_error_code |= |
2120 | 0 | IH264E_INVALID_ENC_OPERATION_MODE; |
2121 | 0 | return IV_FAIL; |
2122 | 0 | } |
2123 | | |
2124 | 4.87k | break; |
2125 | 4.87k | } |
2126 | | |
2127 | 4.87k | case IVE_CMD_CTL_SET_VBV_PARAMS: |
2128 | 4.87k | { |
2129 | 4.87k | ih264e_ctl_set_vbv_params_ip_t *ps_ip = pv_api_ip; |
2130 | 4.87k | ih264e_ctl_set_vbv_params_op_t *ps_op = pv_api_op; |
2131 | | |
2132 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
2133 | 4.87k | != sizeof(ih264e_ctl_set_vbv_params_ip_t)) |
2134 | 0 | { |
2135 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2136 | 0 | << IVE_UNSUPPORTEDPARAM; |
2137 | 0 | ps_op->s_ive_op.u4_error_code |= |
2138 | 0 | IVE_ERR_IP_CTL_SETVBVPARAMS_API_STRUCT_SIZE_INCORRECT; |
2139 | 0 | return IV_FAIL; |
2140 | 0 | } |
2141 | | |
2142 | 4.87k | if (ps_op->s_ive_op.u4_size |
2143 | 4.87k | != sizeof(ih264e_ctl_set_vbv_params_op_t)) |
2144 | 0 | { |
2145 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2146 | 0 | << IVE_UNSUPPORTEDPARAM; |
2147 | 0 | ps_op->s_ive_op.u4_error_code |= |
2148 | 0 | IVE_ERR_OP_CTL_SETVBVPARAMS_API_STRUCT_SIZE_INCORRECT; |
2149 | 0 | return IV_FAIL; |
2150 | 0 | } |
2151 | | |
2152 | 4.87k | if ((ps_ip->s_ive_ip.u4_vbv_buffer_delay < DEFAULT_MIN_BUFFER_DELAY) |
2153 | 4.87k | || (ps_ip->s_ive_ip.u4_vbv_buffer_delay > DEFAULT_MAX_BUFFER_DELAY)) |
2154 | 0 | { |
2155 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2156 | 0 | << IVE_UNSUPPORTEDPARAM; |
2157 | 0 | ps_op->s_ive_op.u4_error_code |= |
2158 | 0 | IH264E_INVALID_BUFFER_DELAY; |
2159 | 0 | return IV_FAIL; |
2160 | 0 | } |
2161 | | |
2162 | 4.87k | break; |
2163 | 4.87k | } |
2164 | | |
2165 | 4.87k | case IVE_CMD_CTL_SET_AIR_PARAMS: |
2166 | 4.87k | { |
2167 | 4.87k | ih264e_ctl_set_air_params_ip_t *ps_ip = pv_api_ip; |
2168 | 4.87k | ih264e_ctl_set_air_params_op_t *ps_op = pv_api_op; |
2169 | | |
2170 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
2171 | 4.87k | != sizeof(ih264e_ctl_set_air_params_ip_t)) |
2172 | 0 | { |
2173 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2174 | 0 | << IVE_UNSUPPORTEDPARAM; |
2175 | 0 | ps_op->s_ive_op.u4_error_code |= |
2176 | 0 | IVE_ERR_IP_CTL_SETAIRPARAMS_API_STRUCT_SIZE_INCORRECT; |
2177 | 0 | return IV_FAIL; |
2178 | 0 | } |
2179 | | |
2180 | 4.87k | if (ps_op->s_ive_op.u4_size |
2181 | 4.87k | != sizeof(ih264e_ctl_set_air_params_op_t)) |
2182 | 0 | { |
2183 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2184 | 0 | << IVE_UNSUPPORTEDPARAM; |
2185 | 0 | ps_op->s_ive_op.u4_error_code |= |
2186 | 0 | IVE_ERR_OP_CTL_SETAIRPARAMS_API_STRUCT_SIZE_INCORRECT; |
2187 | 0 | return IV_FAIL; |
2188 | 0 | } |
2189 | | |
2190 | 4.87k | if ((ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_NONE) |
2191 | 4.87k | && (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_CYCLIC) |
2192 | 4.87k | && (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_RANDOM)) |
2193 | 0 | { |
2194 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2195 | 0 | << IVE_UNSUPPORTEDPARAM; |
2196 | 0 | ps_op->s_ive_op.u4_error_code |= |
2197 | 0 | IH264E_INVALID_AIR_MODE; |
2198 | 0 | return IV_FAIL; |
2199 | 0 | } |
2200 | | |
2201 | 4.87k | if (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_NONE && |
2202 | 4.87k | ps_ip->s_ive_ip.u4_air_refresh_period == 0) |
2203 | 0 | { |
2204 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2205 | 0 | << IVE_UNSUPPORTEDPARAM; |
2206 | 0 | ps_op->s_ive_op.u4_error_code |= |
2207 | 0 | IH264E_INVALID_AIR_REFRESH_PERIOD; |
2208 | 0 | return IV_FAIL; |
2209 | 0 | } |
2210 | | |
2211 | 4.87k | break; |
2212 | 4.87k | } |
2213 | | |
2214 | 4.87k | case IVE_CMD_CTL_SET_PROFILE_PARAMS: |
2215 | 4.87k | { |
2216 | 4.87k | ih264e_ctl_set_profile_params_ip_t *ps_ip = pv_api_ip; |
2217 | 4.87k | ih264e_ctl_set_profile_params_op_t *ps_op = pv_api_op; |
2218 | | |
2219 | 4.87k | if (ps_ip->s_ive_ip.u4_size |
2220 | 4.87k | != sizeof(ih264e_ctl_set_profile_params_ip_t)) |
2221 | 0 | { |
2222 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2223 | 0 | << IVE_UNSUPPORTEDPARAM; |
2224 | 0 | ps_op->s_ive_op.u4_error_code |= |
2225 | 0 | IVE_ERR_IP_CTL_SETPROFILE_API_STRUCT_SIZE_INCORRECT; |
2226 | 0 | return IV_FAIL; |
2227 | 0 | } |
2228 | | |
2229 | 4.87k | if (ps_op->s_ive_op.u4_size |
2230 | 4.87k | != sizeof(ih264e_ctl_set_profile_params_op_t)) |
2231 | 0 | { |
2232 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2233 | 0 | << IVE_UNSUPPORTEDPARAM; |
2234 | 0 | ps_op->s_ive_op.u4_error_code |= |
2235 | 0 | IVE_ERR_OP_CTL_SETPROFILE_API_STRUCT_SIZE_INCORRECT; |
2236 | 0 | return IV_FAIL; |
2237 | 0 | } |
2238 | | |
2239 | 4.87k | if (ps_ip->s_ive_ip.e_profile != IV_PROFILE_BASE && |
2240 | 4.87k | ps_ip->s_ive_ip.e_profile != IV_PROFILE_MAIN) |
2241 | 0 | { |
2242 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2243 | 0 | << IVE_UNSUPPORTEDPARAM; |
2244 | 0 | ps_op->s_ive_op.u4_error_code |= |
2245 | 0 | IH264E_PROFILE_NOT_SUPPORTED; |
2246 | 0 | return IV_FAIL; |
2247 | 0 | } |
2248 | | |
2249 | 4.87k | if (ps_ip->s_ive_ip.u4_entropy_coding_mode > 1) |
2250 | 0 | { |
2251 | 0 | ps_op->s_ive_op.u4_error_code |= 1 |
2252 | 0 | << IVE_UNSUPPORTEDPARAM; |
2253 | 0 | ps_op->s_ive_op.u4_error_code |= |
2254 | 0 | IH264E_INVALID_ENTROPY_CODING_MODE; |
2255 | 0 | return IV_FAIL; |
2256 | 0 | } |
2257 | | |
2258 | 4.87k | break; |
2259 | 4.87k | } |
2260 | | |
2261 | 4.87k | default: |
2262 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
2263 | 0 | *(pu4_api_op + 1) |= IVE_ERR_INVALID_API_SUB_CMD; |
2264 | 0 | return IV_FAIL; |
2265 | 110k | } |
2266 | | |
2267 | 101k | break; |
2268 | 110k | } |
2269 | | |
2270 | 101k | default: |
2271 | 0 | *(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM; |
2272 | 0 | *(pu4_api_op + 1) |= IVE_ERR_INVALID_API_CMD; |
2273 | 0 | return IV_FAIL; |
2274 | 207k | } |
2275 | | |
2276 | 197k | return IV_SUCCESS; |
2277 | 207k | } |
2278 | | |
2279 | | /** |
2280 | | ******************************************************************************* |
2281 | | * |
2282 | | * @brief update encoder configuration parameters |
2283 | | * |
2284 | | * @par Description: |
2285 | | * updates encoder configuration parameters from the given config set. |
2286 | | * Initialize/reinitialize codec parameters according to new configurations. |
2287 | | * |
2288 | | * @param[in] ps_codec |
2289 | | * Pointer to codec context |
2290 | | * |
2291 | | * @param[in] ps_cfg |
2292 | | * Pointer to config param set |
2293 | | * |
2294 | | * @remarks none |
2295 | | * |
2296 | | ******************************************************************************* |
2297 | | */ |
2298 | | IH264E_ERROR_T ih264e_codec_update_config(codec_t *ps_codec, |
2299 | | cfg_params_t *ps_cfg) |
2300 | 91.4k | { |
2301 | | /* config params */ |
2302 | 91.4k | cfg_params_t *ps_curr_cfg = &ps_codec->s_cfg; |
2303 | | |
2304 | | /* error status */ |
2305 | 91.4k | IH264E_ERROR_T err = IH264E_SUCCESS; |
2306 | | |
2307 | | /* temp var */ |
2308 | 91.4k | UWORD32 u4_init_rc = 0; |
2309 | | |
2310 | | /***********************/ |
2311 | | /* UPDATE CODEC CONFIG */ |
2312 | | /***********************/ |
2313 | 91.4k | if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_DIMENSIONS) |
2314 | 4.73k | { |
2315 | 4.73k | UWORD32 wd_aln = ALIGN16(ps_cfg->u4_wd); |
2316 | 4.73k | UWORD32 ht_aln = ALIGN16(ps_cfg->u4_ht); |
2317 | | |
2318 | 4.73k | if (ps_curr_cfg->u4_wd != wd_aln || ps_curr_cfg->u4_ht != ht_aln |
2319 | 4.73k | || ps_curr_cfg->u4_disp_wd != ps_cfg->u4_disp_wd |
2320 | 4.73k | || ps_curr_cfg->u4_disp_ht != ps_cfg->u4_disp_ht) |
2321 | 3.44k | { |
2322 | 3.44k | ps_curr_cfg->u4_wd = wd_aln; |
2323 | 3.44k | ps_curr_cfg->u4_ht = ht_aln; |
2324 | | |
2325 | 3.44k | ps_curr_cfg->u4_disp_wd = ps_cfg->u4_disp_wd; |
2326 | 3.44k | ps_curr_cfg->u4_disp_ht = ps_cfg->u4_disp_ht; |
2327 | | |
2328 | 3.44k | ps_curr_cfg->i4_wd_mbs = ps_curr_cfg->u4_wd >> 4; |
2329 | 3.44k | ps_curr_cfg->i4_ht_mbs = ps_curr_cfg->u4_ht >> 4; |
2330 | | |
2331 | 3.44k | ps_codec->i4_rec_strd = ALIGN16(ps_cfg->u4_wd) + PAD_WD; |
2332 | | |
2333 | | /* If number of MBs in a frame changes the air map also changes. |
2334 | | * Hence recompute air map also reset air pic cnt */ |
2335 | 3.44k | if (ps_codec->s_cfg.e_air_mode != IVE_AIR_MODE_NONE) |
2336 | 0 | { |
2337 | | /* re-init the air map */ |
2338 | 0 | ih264e_init_air_map(ps_codec); |
2339 | | |
2340 | | /* reset air counter */ |
2341 | 0 | ps_codec->i4_air_pic_cnt = -1; |
2342 | 0 | } |
2343 | | |
2344 | | /* initialize mv bank buffer manager */ |
2345 | 3.44k | err = ih264e_mv_buf_mgr_add_bufs(ps_codec); |
2346 | 3.44k | if (err != IH264E_SUCCESS) |
2347 | 0 | return err; |
2348 | | |
2349 | | /* initialize ref bank buffer manager */ |
2350 | 3.44k | err = ih264e_pic_buf_mgr_add_bufs(ps_codec); |
2351 | 3.44k | if (err != IH264E_SUCCESS) |
2352 | 0 | return err; |
2353 | | |
2354 | | /* since dimension changed, start new sequence by forcing IDR */ |
2355 | 3.44k | ps_codec->force_curr_frame_type = IV_IDR_FRAME; |
2356 | | |
2357 | | /* in case dimension changes, we need to reinitialize RC as the |
2358 | | * old model shall not fit further */ |
2359 | 3.44k | u4_init_rc = 1; |
2360 | | |
2361 | | /* when the dimension changes, the header needs to be regenerated */ |
2362 | 3.44k | ps_codec->i4_gen_header = 1; |
2363 | 3.44k | } |
2364 | 4.73k | } |
2365 | 86.6k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_FRAMERATE) |
2366 | 2.69k | { |
2367 | | /* temp var */ |
2368 | 2.69k | UWORD32 u4_src_ticks, u4_tgt_ticks; |
2369 | | |
2370 | 2.69k | u4_src_ticks = ih264e_frame_time_get_src_ticks( |
2371 | 2.69k | ps_codec->s_rate_control.pps_frame_time); |
2372 | | |
2373 | 2.69k | u4_tgt_ticks = ih264e_frame_time_get_tgt_ticks( |
2374 | 2.69k | ps_codec->s_rate_control.pps_frame_time); |
2375 | | |
2376 | | /* Change frame rate */ |
2377 | 2.69k | if (ps_codec->s_cfg.u4_src_frame_rate |
2378 | 2.69k | != ps_cfg->u4_src_frame_rate * 1000) |
2379 | 2.68k | { |
2380 | 2.68k | ps_codec->s_cfg.u4_src_frame_rate = ps_cfg->u4_src_frame_rate |
2381 | 2.68k | * 1000; |
2382 | | |
2383 | 2.68k | ih264e_frame_time_update_src_frame_rate( |
2384 | 2.68k | ps_codec->s_rate_control.pps_frame_time, |
2385 | 2.68k | ps_codec->s_cfg.u4_src_frame_rate); |
2386 | | |
2387 | 2.68k | ih264_time_stamp_update_frame_rate( |
2388 | 2.68k | ps_codec->s_rate_control.pps_time_stamp, |
2389 | 2.68k | ps_codec->s_cfg.u4_src_frame_rate); |
2390 | | |
2391 | 2.68k | irc_change_frame_rate(ps_codec->s_rate_control.pps_rate_control_api, |
2392 | 2.68k | ps_codec->s_cfg.u4_src_frame_rate, |
2393 | 2.68k | u4_src_ticks, u4_tgt_ticks); |
2394 | 2.68k | } |
2395 | | |
2396 | 2.69k | if (ps_codec->s_cfg.u4_tgt_frame_rate |
2397 | 2.69k | != ps_cfg->u4_tgt_frame_rate * 1000) |
2398 | 2.68k | { |
2399 | 2.68k | ps_codec->s_cfg.u4_tgt_frame_rate = ps_cfg->u4_tgt_frame_rate |
2400 | 2.68k | * 1000; |
2401 | | |
2402 | 2.68k | ih264e_frame_time_update_tgt_frame_rate( |
2403 | 2.68k | ps_codec->s_rate_control.pps_frame_time, |
2404 | 2.68k | ps_codec->s_cfg.u4_tgt_frame_rate); |
2405 | | |
2406 | 2.68k | irc_change_frame_rate(ps_codec->s_rate_control.pps_rate_control_api, |
2407 | 2.68k | ps_codec->s_cfg.u4_src_frame_rate, |
2408 | 2.68k | u4_src_ticks, u4_tgt_ticks); |
2409 | | |
2410 | 2.68k | irc_change_frm_rate_for_bit_alloc( |
2411 | 2.68k | ps_codec->s_rate_control.pps_rate_control_api, |
2412 | 2.68k | ps_codec->s_cfg.u4_tgt_frame_rate); |
2413 | 2.68k | } |
2414 | | |
2415 | 2.69k | } |
2416 | 83.9k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_BITRATE) |
2417 | 5.42k | { |
2418 | 5.42k | if (ps_curr_cfg->u4_target_bitrate != ps_cfg->u4_target_bitrate) |
2419 | 5.42k | { |
2420 | 5.42k | if (IVE_RC_NONE != ps_curr_cfg->e_rc_mode) |
2421 | 3.32k | irc_change_avg_bit_rate( |
2422 | 3.32k | ps_codec->s_rate_control.pps_rate_control_api, |
2423 | 3.32k | ps_cfg->u4_target_bitrate); |
2424 | | |
2425 | 5.42k | ps_curr_cfg->u4_target_bitrate = ps_cfg->u4_target_bitrate; |
2426 | 5.42k | } |
2427 | 5.42k | } |
2428 | 78.5k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_FRAMETYPE) |
2429 | 998 | { |
2430 | 998 | switch (ps_cfg->e_frame_type) |
2431 | 998 | { |
2432 | 0 | case IV_I_FRAME: |
2433 | 0 | ps_codec->force_curr_frame_type = IV_I_FRAME; |
2434 | 0 | break; |
2435 | | |
2436 | 998 | case IV_IDR_FRAME: |
2437 | 998 | ps_codec->force_curr_frame_type = IV_IDR_FRAME; |
2438 | 998 | break; |
2439 | | |
2440 | 0 | case IV_P_FRAME: |
2441 | 0 | default: |
2442 | 0 | break; |
2443 | 998 | } |
2444 | 998 | } |
2445 | 77.5k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_ME_PARAMS) |
2446 | 1.35k | { |
2447 | 1.35k | if (ps_curr_cfg->u4_enc_speed_preset == IVE_CONFIG) |
2448 | 463 | { |
2449 | 463 | ps_codec->s_cfg.u4_enable_hpel = ps_cfg->u4_enable_hpel; |
2450 | 463 | ps_codec->s_cfg.u4_enable_fast_sad = ps_cfg->u4_enable_fast_sad; |
2451 | 463 | ps_codec->s_cfg.u4_me_speed_preset = ps_cfg->u4_me_speed_preset; |
2452 | 463 | ps_codec->s_cfg.u4_enable_qpel = ps_cfg->u4_enable_qpel; |
2453 | 463 | } |
2454 | 893 | else if (ps_curr_cfg->u4_enc_speed_preset == IVE_FASTEST) |
2455 | 85 | { |
2456 | 85 | ps_codec->s_cfg.u4_enable_fast_sad = ps_cfg->u4_enable_fast_sad; |
2457 | 85 | } |
2458 | 1.35k | ps_codec->s_cfg.u4_srch_rng_x = ps_cfg->u4_srch_rng_x; |
2459 | 1.35k | ps_codec->s_cfg.u4_srch_rng_y = ps_cfg->u4_srch_rng_y; |
2460 | | |
2461 | 1.35k | if (ps_codec->s_cfg.u4_enable_alt_ref != ps_cfg->u4_enable_alt_ref) |
2462 | 0 | { |
2463 | 0 | ps_codec->s_cfg.u4_enable_alt_ref = ps_cfg->u4_enable_alt_ref; |
2464 | 0 | ps_codec->u4_is_curr_frm_ref = 1; |
2465 | 0 | } |
2466 | 1.35k | } |
2467 | 76.2k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_IPE_PARAMS) |
2468 | 4.87k | { |
2469 | 4.87k | ps_curr_cfg->u4_enc_speed_preset = ps_cfg->u4_enc_speed_preset; |
2470 | | |
2471 | 4.87k | ps_curr_cfg->u4_constrained_intra_pred = ps_cfg->u4_constrained_intra_pred; |
2472 | | |
2473 | 4.87k | if (ps_curr_cfg->u4_enc_speed_preset != IVE_CONFIG) |
2474 | 3.29k | { |
2475 | 3.29k | ih264e_speed_preset_side_effects(ps_codec); |
2476 | 3.29k | } |
2477 | 1.58k | else |
2478 | 1.58k | { |
2479 | 1.58k | ps_curr_cfg->u4_enable_intra_4x4 = ps_cfg->u4_enable_intra_4x4; |
2480 | 1.58k | } |
2481 | 4.87k | } |
2482 | 71.3k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_GOP_PARAMS) |
2483 | 3.92k | { |
2484 | 3.92k | if (ps_curr_cfg->u4_i_frm_interval != ps_cfg->u4_i_frm_interval) |
2485 | 3.90k | { |
2486 | 3.90k | ps_curr_cfg->u4_i_frm_interval = ps_cfg->u4_i_frm_interval; |
2487 | | |
2488 | | /* reset air counter */ |
2489 | 3.90k | ps_codec->i4_air_pic_cnt = -1; |
2490 | | |
2491 | | /* re-init air map */ |
2492 | 3.90k | ih264e_init_air_map(ps_codec); |
2493 | | |
2494 | | /* Effect intra frame interval change */ |
2495 | 3.90k | irc_change_intra_frm_int_call( |
2496 | 3.90k | ps_codec->s_rate_control.pps_rate_control_api, |
2497 | 3.90k | ps_curr_cfg->u4_i_frm_interval); |
2498 | 3.90k | } |
2499 | | |
2500 | 3.92k | ps_curr_cfg->u4_idr_frm_interval = ps_cfg->u4_idr_frm_interval; |
2501 | | |
2502 | 3.92k | } |
2503 | 67.4k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_DEBLOCK_PARAMS) |
2504 | 4.02k | { |
2505 | 4.02k | if (ps_curr_cfg->u4_enc_speed_preset == IVE_CONFIG) |
2506 | 1.26k | { |
2507 | 1.26k | ps_curr_cfg->u4_disable_deblock_level = |
2508 | 1.26k | ps_cfg->u4_disable_deblock_level; |
2509 | 1.26k | } |
2510 | 4.02k | } |
2511 | 63.3k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_QP) |
2512 | 4.87k | { |
2513 | 4.87k | UWORD8 au1_init_qp[MAX_PIC_TYPE]; |
2514 | 4.87k | UWORD8 au1_min_max_qp[2 * MAX_PIC_TYPE]; |
2515 | | |
2516 | 4.87k | ps_codec->s_cfg.u4_i_qp_max = ps_cfg->u4_i_qp_max; |
2517 | 4.87k | ps_codec->s_cfg.u4_i_qp_min = ps_cfg->u4_i_qp_min; |
2518 | 4.87k | ps_codec->s_cfg.u4_i_qp = ps_cfg->u4_i_qp; |
2519 | | |
2520 | 4.87k | ps_codec->s_cfg.u4_p_qp_max = ps_cfg->u4_p_qp_max; |
2521 | 4.87k | ps_codec->s_cfg.u4_p_qp_min = ps_cfg->u4_p_qp_min; |
2522 | 4.87k | ps_codec->s_cfg.u4_p_qp = ps_cfg->u4_p_qp; |
2523 | | |
2524 | 4.87k | ps_codec->s_cfg.u4_b_qp_max = ps_cfg->u4_b_qp_max; |
2525 | 4.87k | ps_codec->s_cfg.u4_b_qp_min = ps_cfg->u4_b_qp_min; |
2526 | 4.87k | ps_codec->s_cfg.u4_b_qp = ps_cfg->u4_b_qp; |
2527 | | |
2528 | | /* update rc lib with modified qp */ |
2529 | 4.87k | au1_init_qp[0] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp]; |
2530 | 4.87k | au1_init_qp[1] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp]; |
2531 | 4.87k | au1_init_qp[2] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp]; |
2532 | | |
2533 | 4.87k | irc_change_init_qp(ps_codec->s_rate_control.pps_rate_control_api, |
2534 | 4.87k | au1_init_qp); |
2535 | | |
2536 | 4.87k | au1_min_max_qp[2 * I_PIC] = |
2537 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_min]; |
2538 | 4.87k | au1_min_max_qp[2 * I_PIC + 1] = |
2539 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_max]; |
2540 | | |
2541 | 4.87k | au1_min_max_qp[2 * P_PIC] = |
2542 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_min]; |
2543 | 4.87k | au1_min_max_qp[2 * P_PIC + 1] = |
2544 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_max]; |
2545 | | |
2546 | 4.87k | au1_min_max_qp[2 * B_PIC] = |
2547 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_min]; |
2548 | 4.87k | au1_min_max_qp[2 * B_PIC + 1] = |
2549 | 4.87k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_max]; |
2550 | | |
2551 | 4.87k | irc_change_min_max_qp(ps_codec->s_rate_control.pps_rate_control_api, |
2552 | 4.87k | au1_min_max_qp); |
2553 | 4.87k | } |
2554 | 58.5k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_ENC_MODE) |
2555 | 4.87k | { |
2556 | 4.87k | ps_codec->s_cfg.e_enc_mode = ps_cfg->e_enc_mode; |
2557 | | |
2558 | 4.87k | if (ps_codec->s_cfg.e_enc_mode == IVE_ENC_MODE_HEADER) |
2559 | 4.87k | { |
2560 | 4.87k | ps_codec->i4_header_mode = 1; |
2561 | 4.87k | ps_codec->s_cfg.e_enc_mode = IVE_ENC_MODE_PICTURE; |
2562 | 4.87k | } |
2563 | 0 | else |
2564 | 0 | { |
2565 | 0 | ps_codec->i4_header_mode = 0; |
2566 | 0 | } |
2567 | 4.87k | } |
2568 | 53.6k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_VBV_PARAMS |
2569 | 53.6k | && IVE_RC_NONE != ps_codec->s_cfg.e_rc_mode) |
2570 | 2.79k | { |
2571 | 2.79k | ps_codec->s_cfg.u4_vbv_buf_size = ps_cfg->u4_vbv_buf_size; |
2572 | 2.79k | ps_codec->s_cfg.u4_vbv_buffer_delay = ps_cfg->u4_vbv_buffer_delay; |
2573 | | |
2574 | | // irc_change_buffer_delay(ps_codec->s_rate_control.pps_rate_control_api, ps_codec->s_cfg.u4_vbv_buffer_delay); |
2575 | | |
2576 | | // TODO: remove this when the support for changing buffer dynamically |
2577 | | // is yet to be added. |
2578 | 2.79k | u4_init_rc = 1; |
2579 | 2.79k | } |
2580 | 50.8k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_AIR_PARAMS) |
2581 | 4.87k | { |
2582 | 4.87k | if (ps_curr_cfg->e_air_mode != ps_cfg->e_air_mode |
2583 | 4.87k | || ps_curr_cfg->u4_air_refresh_period |
2584 | 2.71k | != ps_cfg->u4_air_refresh_period) |
2585 | 4.86k | { |
2586 | 4.86k | ps_curr_cfg->e_air_mode = ps_cfg->e_air_mode; |
2587 | 4.86k | ps_curr_cfg->u4_air_refresh_period = ps_cfg->u4_air_refresh_period; |
2588 | | |
2589 | 4.86k | ih264e_init_air_map(ps_codec); |
2590 | | |
2591 | | /* reset air counter */ |
2592 | 4.86k | ps_codec->i4_air_pic_cnt = -1; |
2593 | 4.86k | } |
2594 | 4.87k | } |
2595 | 45.9k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_PROFILE_PARAMS) |
2596 | 4.87k | { |
2597 | 4.87k | ps_codec->s_cfg.e_profile = ps_cfg->e_profile; |
2598 | 4.87k | ps_codec->s_cfg.u4_entropy_coding_mode = ps_cfg->u4_entropy_coding_mode; |
2599 | 4.87k | } |
2600 | 41.0k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_NUM_CORES) |
2601 | 4.87k | { |
2602 | 4.87k | ps_codec->s_cfg.u4_num_cores = ps_cfg->u4_num_cores; |
2603 | 4.87k | } |
2604 | 36.2k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_VUI_PARAMS) |
2605 | 4.87k | { |
2606 | 4.87k | ps_codec->s_cfg.s_vui = ps_cfg->s_vui; |
2607 | 4.87k | } |
2608 | | |
2609 | 31.3k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_SEI_MDCV_PARAMS) |
2610 | 4.87k | { |
2611 | 4.87k | ps_codec->s_cfg.s_sei.u1_sei_mdcv_params_present_flag = |
2612 | 4.87k | ps_cfg->s_sei.u1_sei_mdcv_params_present_flag; |
2613 | 4.87k | ps_codec->s_cfg.s_sei.s_sei_mdcv_params = ps_cfg->s_sei.s_sei_mdcv_params; |
2614 | 4.87k | } |
2615 | 26.4k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_SEI_CLL_PARAMS) |
2616 | 4.87k | { |
2617 | 4.87k | ps_codec->s_cfg.s_sei.u1_sei_cll_params_present_flag = |
2618 | 4.87k | ps_cfg->s_sei.u1_sei_cll_params_present_flag; |
2619 | 4.87k | ps_codec->s_cfg.s_sei.s_sei_cll_params = ps_cfg->s_sei.s_sei_cll_params; |
2620 | 4.87k | } |
2621 | 21.5k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_SEI_AVE_PARAMS) |
2622 | 4.87k | { |
2623 | 4.87k | ps_codec->s_cfg.s_sei.u1_sei_ave_params_present_flag = |
2624 | 4.87k | ps_cfg->s_sei.u1_sei_ave_params_present_flag; |
2625 | 4.87k | ps_codec->s_cfg.s_sei.s_sei_ave_params = ps_cfg->s_sei.s_sei_ave_params; |
2626 | 4.87k | } |
2627 | 16.7k | else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_SEI_CCV_PARAMS) |
2628 | 4.87k | { |
2629 | 4.87k | ps_codec->s_cfg.s_sei.u1_sei_ccv_params_present_flag = |
2630 | 4.87k | ps_cfg->s_sei.u1_sei_ccv_params_present_flag; |
2631 | 4.87k | ps_codec->s_cfg.s_sei.s_sei_ccv_params = ps_cfg->s_sei.s_sei_ccv_params; |
2632 | 4.87k | } |
2633 | 11.8k | else if(ps_cfg->e_cmd == IVE_CMD_CTL_SET_SEI_SII_PARAMS) |
2634 | 4.87k | { |
2635 | 4.87k | ps_codec->s_cfg.s_sei.u1_sei_sii_params_present_flag = |
2636 | 4.87k | ps_cfg->s_sei.u1_sei_sii_params_present_flag; |
2637 | 4.87k | ps_codec->s_cfg.s_sei.s_sei_sii_params = ps_cfg->s_sei.s_sei_sii_params; |
2638 | 4.87k | } |
2639 | | |
2640 | | /* reset RC model */ |
2641 | 91.4k | if (u4_init_rc) |
2642 | 6.24k | { |
2643 | | /* init qp */ |
2644 | 6.24k | UWORD8 au1_init_qp[MAX_PIC_TYPE]; |
2645 | | |
2646 | | /* min max qp */ |
2647 | 6.24k | UWORD8 au1_min_max_qp[2 * MAX_PIC_TYPE]; |
2648 | | |
2649 | | /* init i,p,b qp */ |
2650 | 6.24k | au1_init_qp[0] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp]; |
2651 | 6.24k | au1_init_qp[1] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp]; |
2652 | 6.24k | au1_init_qp[2] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp]; |
2653 | | |
2654 | | /* init min max qp */ |
2655 | 6.24k | au1_min_max_qp[2 * I_PIC] = |
2656 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_min]; |
2657 | 6.24k | au1_min_max_qp[2 * I_PIC + 1] = |
2658 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_max]; |
2659 | | |
2660 | 6.24k | au1_min_max_qp[2 * P_PIC] = |
2661 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_min]; |
2662 | 6.24k | au1_min_max_qp[2 * P_PIC + 1] = |
2663 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_max]; |
2664 | | |
2665 | 6.24k | au1_min_max_qp[2 * B_PIC] = |
2666 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_min]; |
2667 | 6.24k | au1_min_max_qp[2 * B_PIC + 1] = |
2668 | 6.24k | gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_max]; |
2669 | | |
2670 | | /* get rc mode */ |
2671 | 6.24k | switch (ps_codec->s_cfg.e_rc_mode) |
2672 | 6.24k | { |
2673 | 2.62k | case IVE_RC_STORAGE: |
2674 | 2.62k | ps_codec->s_rate_control.e_rc_type = VBR_STORAGE; |
2675 | 2.62k | break; |
2676 | | |
2677 | 1.97k | case IVE_RC_CBR_NON_LOW_DELAY: |
2678 | 1.97k | ps_codec->s_rate_control.e_rc_type = CBR_NLDRC; |
2679 | 1.97k | break; |
2680 | | |
2681 | 0 | case IVE_RC_CBR_LOW_DELAY: |
2682 | 0 | ps_codec->s_rate_control.e_rc_type = CBR_LDRC; |
2683 | 0 | break; |
2684 | | |
2685 | 1.65k | case IVE_RC_NONE: |
2686 | 1.65k | ps_codec->s_rate_control.e_rc_type = CONST_QP; |
2687 | 1.65k | break; |
2688 | | |
2689 | 0 | default: |
2690 | 0 | break; |
2691 | 6.24k | } |
2692 | | |
2693 | | /* init rate control */ |
2694 | 6.24k | ih264e_rc_init(ps_codec->s_rate_control.pps_rate_control_api, |
2695 | 6.24k | ps_codec->s_rate_control.pps_frame_time, |
2696 | 6.24k | ps_codec->s_rate_control.pps_time_stamp, |
2697 | 6.24k | ps_codec->s_rate_control.pps_pd_frm_rate, |
2698 | 6.24k | ps_codec->s_cfg.u4_max_framerate, |
2699 | 6.24k | ps_codec->s_cfg.u4_src_frame_rate, |
2700 | 6.24k | ps_codec->s_cfg.u4_tgt_frame_rate, |
2701 | 6.24k | ps_codec->s_rate_control.e_rc_type, |
2702 | 6.24k | ps_codec->s_cfg.u4_target_bitrate, |
2703 | 6.24k | ps_codec->s_cfg.u4_max_bitrate, |
2704 | 6.24k | ps_codec->s_cfg.u4_vbv_buffer_delay, |
2705 | 6.24k | ps_codec->s_cfg.u4_i_frm_interval, |
2706 | 6.24k | ps_codec->s_cfg.u4_num_bframes + 1, au1_init_qp, |
2707 | 6.24k | ps_codec->s_cfg.u4_num_bframes + 2, au1_min_max_qp, |
2708 | 6.24k | ps_codec->s_cfg.u4_max_level); |
2709 | 6.24k | } |
2710 | | |
2711 | 91.4k | return err; |
2712 | 91.4k | } |
2713 | | |
2714 | | /** |
2715 | | ******************************************************************************* |
2716 | | * |
2717 | | * @brief |
2718 | | * Sets default encoder config parameters |
2719 | | * |
2720 | | * @par Description: |
2721 | | * Sets default dynamic parameters. Will be called in ih264e_init() to ensure |
2722 | | * that even if set_params is not called, codec continues to work |
2723 | | * |
2724 | | * @param[in] ps_cfg |
2725 | | * Pointer to encoder config params |
2726 | | * |
2727 | | * @returns error status |
2728 | | * |
2729 | | * @remarks none |
2730 | | * |
2731 | | ******************************************************************************* |
2732 | | */ |
2733 | | static WORD32 ih264e_set_default_params(cfg_params_t *ps_cfg) |
2734 | 9.75k | { |
2735 | 9.75k | WORD32 ret = IV_SUCCESS; |
2736 | | |
2737 | 9.75k | ps_cfg->u4_max_wd = MAX_WD; |
2738 | 9.75k | ps_cfg->u4_max_ht = MAX_HT; |
2739 | 9.75k | ps_cfg->u4_max_ref_cnt = MAX_REF_CNT; |
2740 | 9.75k | ps_cfg->u4_max_reorder_cnt = MAX_REF_CNT; |
2741 | 9.75k | ps_cfg->u4_max_level = DEFAULT_MAX_LEVEL; |
2742 | 9.75k | ps_cfg->e_inp_color_fmt = IV_YUV_420SP_UV; |
2743 | 9.75k | ps_cfg->u4_enable_recon = DEFAULT_RECON_ENABLE; |
2744 | 9.75k | ps_cfg->u4_enable_quality_metrics = DEFAULT_QUALITY_METRICS_ENABLE; |
2745 | 9.75k | ps_cfg->e_recon_color_fmt = IV_YUV_420P; |
2746 | 9.75k | ps_cfg->u4_enc_speed_preset = IVE_FASTEST; |
2747 | 9.75k | ps_cfg->e_rc_mode = DEFAULT_RC; |
2748 | 9.75k | ps_cfg->u4_max_framerate = DEFAULT_MAX_FRAMERATE; |
2749 | 9.75k | ps_cfg->u4_max_bitrate = DEFAULT_MAX_BITRATE; |
2750 | 9.75k | ps_cfg->u4_num_bframes = DEFAULT_MAX_NUM_BFRAMES; |
2751 | 9.75k | ps_cfg->e_content_type = IV_PROGRESSIVE; |
2752 | 9.75k | ps_cfg->u4_max_srch_rng_x = DEFAULT_MAX_SRCH_RANGE_X; |
2753 | 9.75k | ps_cfg->u4_max_srch_rng_y = DEFAULT_MAX_SRCH_RANGE_Y; |
2754 | 9.75k | ps_cfg->e_slice_mode = IVE_SLICE_MODE_NONE; |
2755 | 9.75k | ps_cfg->u4_slice_param = DEFAULT_SLICE_PARAM; |
2756 | 9.75k | ps_cfg->e_arch = ih264e_default_arch(); |
2757 | 9.75k | ps_cfg->e_soc = SOC_GENERIC; |
2758 | 9.75k | ps_cfg->u4_disp_wd = MAX_WD; |
2759 | 9.75k | ps_cfg->u4_disp_ht = MAX_HT; |
2760 | 9.75k | ps_cfg->u4_wd = MAX_WD; |
2761 | 9.75k | ps_cfg->u4_ht = MAX_HT; |
2762 | 9.75k | ps_cfg->u4_src_frame_rate = DEFAULT_SRC_FRAME_RATE; |
2763 | 9.75k | ps_cfg->u4_tgt_frame_rate = DEFAULT_TGT_FRAME_RATE; |
2764 | 9.75k | ps_cfg->u4_target_bitrate = DEFAULT_BITRATE; |
2765 | 9.75k | ps_cfg->e_frame_type = IV_NA_FRAME; |
2766 | 9.75k | ps_cfg->e_enc_mode = IVE_ENC_MODE_DEFAULT; |
2767 | 9.75k | ps_cfg->u4_i_qp = DEFAULT_I_QP; |
2768 | 9.75k | ps_cfg->u4_p_qp = DEFAULT_P_QP; |
2769 | 9.75k | ps_cfg->u4_b_qp = DEFAULT_B_QP; |
2770 | 9.75k | ps_cfg->u4_i_qp_min = DEFAULT_QP_MIN; |
2771 | 9.75k | ps_cfg->u4_i_qp_max = DEFAULT_QP_MAX; |
2772 | 9.75k | ps_cfg->u4_p_qp_min = DEFAULT_QP_MIN; |
2773 | 9.75k | ps_cfg->u4_p_qp_max = DEFAULT_QP_MAX; |
2774 | 9.75k | ps_cfg->u4_b_qp_min = DEFAULT_QP_MIN; |
2775 | 9.75k | ps_cfg->u4_b_qp_max = DEFAULT_QP_MAX; |
2776 | 9.75k | ps_cfg->e_air_mode = DEFAULT_AIR_MODE; |
2777 | 9.75k | ps_cfg->u4_air_refresh_period = DEFAULT_AIR_REFRESH_PERIOD; |
2778 | 9.75k | ps_cfg->u4_vbv_buffer_delay = DEFAULT_VBV_DELAY; |
2779 | 9.75k | ps_cfg->u4_vbv_buf_size = DEFAULT_VBV_SIZE; |
2780 | 9.75k | ps_cfg->u4_num_cores = DEFAULT_NUM_CORES; |
2781 | 9.75k | ps_cfg->u4_me_speed_preset = DEFAULT_ME_SPEED_PRESET; |
2782 | 9.75k | ps_cfg->u4_enable_hpel = DEFAULT_HPEL; |
2783 | 9.75k | ps_cfg->u4_enable_qpel = DEFAULT_QPEL; |
2784 | 9.75k | ps_cfg->u4_enable_intra_4x4 = DEFAULT_I4; |
2785 | 9.75k | ps_cfg->u4_enable_intra_8x8 = DEFAULT_I8; |
2786 | 9.75k | ps_cfg->u4_enable_intra_16x16 = DEFAULT_I16; |
2787 | 9.75k | ps_cfg->u4_enable_fast_sad = DEFAULT_ENABLE_FAST_SAD; |
2788 | 9.75k | ps_cfg->u4_enable_satqd = DEFAULT_ENABLE_SATQD; |
2789 | 9.75k | ps_cfg->i4_min_sad = |
2790 | 9.75k | (ps_cfg->u4_enable_satqd == DEFAULT_ENABLE_SATQD) ? |
2791 | 9.75k | DEFAULT_MIN_SAD_ENABLE : |
2792 | 9.75k | DEFAULT_MIN_SAD_DISABLE; |
2793 | 9.75k | ps_cfg->u4_srch_rng_x = DEFAULT_SRCH_RNG_X; |
2794 | 9.75k | ps_cfg->u4_srch_rng_y = DEFAULT_SRCH_RNG_Y; |
2795 | 9.75k | ps_cfg->u4_i_frm_interval = DEFAULT_I_INTERVAL; |
2796 | 9.75k | ps_cfg->u4_idr_frm_interval = DEFAULT_IDR_INTERVAL; |
2797 | 9.75k | ps_cfg->u4_disable_deblock_level = DEFAULT_DISABLE_DEBLK_LEVEL; |
2798 | 9.75k | ps_cfg->e_profile = DEFAULT_PROFILE; |
2799 | 9.75k | ps_cfg->u4_timestamp_low = 0; |
2800 | 9.75k | ps_cfg->u4_timestamp_high = 0; |
2801 | 9.75k | ps_cfg->u4_is_valid = 1; |
2802 | 9.75k | ps_cfg->e_cmd = IVE_CMD_CT_NA; |
2803 | 9.75k | ps_cfg->i4_wd_mbs = ps_cfg->u4_max_wd >> 4; |
2804 | 9.75k | ps_cfg->i4_ht_mbs = ps_cfg->u4_max_ht >> 4; |
2805 | 9.75k | ps_cfg->u4_entropy_coding_mode = DEFAULT_ENTROPY_CODING_MODE; |
2806 | 9.75k | ps_cfg->u4_weighted_prediction = 0; |
2807 | 9.75k | ps_cfg->u4_constrained_intra_pred = DEFAULT_CONSTRAINED_INTRAPRED; |
2808 | 9.75k | ps_cfg->u4_pic_info_type = 0; |
2809 | 9.75k | ps_cfg->u4_mb_info_type = 0; |
2810 | 9.75k | ps_cfg->s_vui.u1_video_signal_type_present_flag = 0; |
2811 | 9.75k | ps_cfg->s_vui.u1_colour_description_present_flag = 0; |
2812 | | |
2813 | 9.75k | return ret; |
2814 | 9.75k | } |
2815 | | |
2816 | | /** |
2817 | | ******************************************************************************* |
2818 | | * |
2819 | | * @brief |
2820 | | * Initialize encoder context. This will be called by init_mem_rec and during |
2821 | | * codec reset |
2822 | | * |
2823 | | * @par Description: |
2824 | | * Initializes the context |
2825 | | * |
2826 | | * @param[in] ps_codec |
2827 | | * Codec context pointer |
2828 | | * |
2829 | | * @returns error status |
2830 | | * |
2831 | | * @remarks none |
2832 | | * |
2833 | | ******************************************************************************* |
2834 | | */ |
2835 | | static WORD32 ih264e_init(codec_t *ps_codec) |
2836 | 4.87k | { |
2837 | | /* enc config param set */ |
2838 | 4.87k | cfg_params_t *ps_cfg = &(ps_codec->s_cfg); |
2839 | | |
2840 | | /* temp var */ |
2841 | 4.87k | WORD32 i; |
2842 | | |
2843 | | /* coded pic count */ |
2844 | 4.87k | ps_codec->i4_poc = 0; |
2845 | | |
2846 | | /* Number of API calls to encode are made */ |
2847 | 4.87k | ps_codec->i4_encode_api_call_cnt = -1; |
2848 | | |
2849 | | /* Indicates no header has been generated yet */ |
2850 | 4.87k | ps_codec->u4_header_generated = 0; |
2851 | | |
2852 | | /* Number of pictures encoded */ |
2853 | 4.87k | ps_codec->i4_pic_cnt = -1; |
2854 | | |
2855 | | /* Number of threads created */ |
2856 | 4.87k | ps_codec->i4_proc_thread_cnt = 0; |
2857 | | |
2858 | | /* ctl mutex init */ |
2859 | 4.87k | ithread_mutex_init(ps_codec->pv_ctl_mutex); |
2860 | | |
2861 | 4.87k | if (ps_codec->s_cfg.u4_keep_threads_active) |
2862 | 4.87k | { |
2863 | | /* thread pool mutex init */ |
2864 | 4.87k | ithread_mutex_init(ps_codec->s_thread_pool.pv_thread_pool_mutex); |
2865 | | |
2866 | | /* thread pool conditional init */ |
2867 | 4.87k | ithread_cond_init(ps_codec->s_thread_pool.pv_thread_pool_cond); |
2868 | 4.87k | } |
2869 | | |
2870 | | /* Set encoder chroma format */ |
2871 | 4.87k | ps_codec->e_codec_color_format = |
2872 | 4.87k | (ps_cfg->e_inp_color_fmt == IV_YUV_420SP_VU) ? |
2873 | 3.68k | IV_YUV_420SP_VU : IV_YUV_420SP_UV; |
2874 | | |
2875 | | /* Number of continuous frames where deblocking was disabled */ |
2876 | 4.87k | ps_codec->i4_disable_deblk_pic_cnt = 0; |
2877 | | |
2878 | | /* frame num */ |
2879 | 4.87k | ps_codec->i4_frame_num = 0; |
2880 | | |
2881 | | /* set the current frame type to I frame, since we are going to start encoding*/ |
2882 | 4.87k | ps_codec->force_curr_frame_type = IV_NA_FRAME; |
2883 | | |
2884 | | /* idr_pic_id */ |
2885 | 4.87k | ps_codec->i4_idr_pic_id = -1; |
2886 | | |
2887 | | /* Flush mode */ |
2888 | 4.87k | ps_codec->i4_flush_mode = 0; |
2889 | | |
2890 | | /* Encode header mode */ |
2891 | 4.87k | ps_codec->i4_header_mode = 0; |
2892 | | |
2893 | | /* Encode generate header */ |
2894 | 4.87k | ps_codec->i4_gen_header = 0; |
2895 | | |
2896 | | /* To signal successful completion of init */ |
2897 | 4.87k | ps_codec->i4_init_done = 1; |
2898 | | |
2899 | | /* To signal that at least one picture was decoded */ |
2900 | 4.87k | ps_codec->i4_first_pic_done = 0; |
2901 | | |
2902 | | /* Reset Codec */ |
2903 | 4.87k | ps_codec->i4_reset_flag = 0; |
2904 | | |
2905 | | /* Current error code */ |
2906 | 4.87k | ps_codec->i4_error_code = IH264E_SUCCESS; |
2907 | | |
2908 | | /* threshold residue */ |
2909 | 4.87k | ps_codec->u4_thres_resi = 1; |
2910 | | |
2911 | | /* inter gating enable */ |
2912 | 4.87k | ps_codec->u4_inter_gate = 0; |
2913 | | |
2914 | | /* entropy mutex init */ |
2915 | 4.87k | ithread_mutex_init(ps_codec->pv_entropy_mutex); |
2916 | | |
2917 | | /* sps id */ |
2918 | 4.87k | ps_codec->i4_sps_id = 0; |
2919 | | |
2920 | | /* sps id */ |
2921 | 4.87k | ps_codec->i4_pps_id = 0; |
2922 | | |
2923 | | /* Process thread created status */ |
2924 | 4.87k | memset(ps_codec->ai4_process_thread_created, 0, |
2925 | 4.87k | sizeof(ps_codec->ai4_process_thread_created)); |
2926 | | |
2927 | 4.87k | memset(&ps_codec->s_global_quality_stats, 0, sizeof(ps_codec->s_global_quality_stats)); |
2928 | | |
2929 | | /* Number of MBs processed together */ |
2930 | 4.87k | ps_codec->i4_proc_nmb = 8; |
2931 | | |
2932 | | /* Previous POC msb */ |
2933 | 4.87k | ps_codec->i4_prev_poc_msb = 0; |
2934 | | |
2935 | | /* Previous POC lsb */ |
2936 | 4.87k | ps_codec->i4_prev_poc_lsb = -1; |
2937 | | |
2938 | | /* max Previous POC lsb */ |
2939 | 4.87k | ps_codec->i4_max_prev_poc_lsb = -1; |
2940 | | |
2941 | | /* sps, pps status */ |
2942 | 4.87k | { |
2943 | 4.87k | sps_t *ps_sps = ps_codec->ps_sps_base; |
2944 | 4.87k | pps_t *ps_pps = ps_codec->ps_pps_base; |
2945 | | |
2946 | 165k | for (i = 0; i < MAX_SPS_CNT; i++) |
2947 | 160k | { |
2948 | 160k | ps_sps->i1_sps_valid = 0; |
2949 | 160k | ps_sps++; |
2950 | 160k | } |
2951 | | |
2952 | 1.25M | for (i = 0; i < MAX_PPS_CNT; i++) |
2953 | 1.25M | { |
2954 | 1.25M | ps_pps->i1_pps_valid = 0; |
2955 | 1.25M | ps_pps++; |
2956 | 1.25M | } |
2957 | 4.87k | } |
2958 | | |
2959 | 4.87k | { |
2960 | 4.87k | WORD32 max_mb_rows = ps_cfg->i4_ht_mbs; |
2961 | | |
2962 | 4.87k | WORD32 num_jobs = max_mb_rows * MAX_CTXT_SETS; |
2963 | 4.87k | WORD32 clz; |
2964 | | |
2965 | | /* Use next power of two number of entries*/ |
2966 | 4.87k | clz = CLZ(num_jobs); |
2967 | 4.87k | num_jobs = 1 << (32 - clz); |
2968 | | |
2969 | | /* init process jobq */ |
2970 | 4.87k | ps_codec->pv_proc_jobq = ih264_list_init( |
2971 | 4.87k | ps_codec->pv_proc_jobq_buf, |
2972 | 4.87k | ps_codec->i4_proc_jobq_buf_size, num_jobs, |
2973 | 4.87k | sizeof(job_t), 10); |
2974 | 4.87k | RETURN_IF((ps_codec->pv_proc_jobq == NULL), IV_FAIL); |
2975 | 4.87k | ih264_list_reset(ps_codec->pv_proc_jobq); |
2976 | | |
2977 | | /* init entropy jobq */ |
2978 | 4.87k | ps_codec->pv_entropy_jobq = ih264_list_init( |
2979 | 4.87k | ps_codec->pv_entropy_jobq_buf, |
2980 | 4.87k | ps_codec->i4_entropy_jobq_buf_size, num_jobs, |
2981 | 4.87k | sizeof(job_t), 10); |
2982 | 4.87k | RETURN_IF((ps_codec->pv_entropy_jobq == NULL), IV_FAIL); |
2983 | 4.87k | ih264_list_reset(ps_codec->pv_entropy_jobq); |
2984 | 4.87k | } |
2985 | | |
2986 | | /* Update the jobq context to all the threads */ |
2987 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
2988 | 39.0k | { |
2989 | 39.0k | ps_codec->as_process[i].pv_proc_jobq = ps_codec->pv_proc_jobq; |
2990 | 39.0k | ps_codec->as_process[i].pv_entropy_jobq = ps_codec->pv_entropy_jobq; |
2991 | | |
2992 | | /* i4_id always stays between 0 and MAX_PROCESS_THREADS */ |
2993 | 39.0k | ps_codec->as_process[i].i4_id = |
2994 | 39.0k | (i >= MAX_PROCESS_THREADS) ? |
2995 | 39.0k | (i - MAX_PROCESS_THREADS) : i; |
2996 | 39.0k | ps_codec->as_process[i].ps_codec = ps_codec; |
2997 | | |
2998 | 39.0k | ps_codec->as_process[i].s_entropy.pv_proc_jobq = ps_codec->pv_proc_jobq; |
2999 | 39.0k | ps_codec->as_process[i].s_entropy.pv_entropy_jobq = |
3000 | 39.0k | ps_codec->pv_entropy_jobq; |
3001 | 39.0k | ps_codec->as_process[i].s_entropy.i4_abs_pic_order_cnt = -1; |
3002 | 39.0k | } |
3003 | | |
3004 | | /* Initialize MV Bank buffer manager */ |
3005 | 4.87k | ps_codec->pv_mv_buf_mgr = ih264_buf_mgr_init(ps_codec->pv_mv_buf_mgr_base); |
3006 | | |
3007 | | /* Initialize Picture buffer manager for reference buffers*/ |
3008 | 4.87k | ps_codec->pv_ref_buf_mgr = ih264_buf_mgr_init( |
3009 | 4.87k | ps_codec->pv_ref_buf_mgr_base); |
3010 | | |
3011 | | /* Initialize Picture buffer manager for input buffers*/ |
3012 | 4.87k | ps_codec->pv_inp_buf_mgr = ih264_buf_mgr_init( |
3013 | 4.87k | ps_codec->pv_inp_buf_mgr_base); |
3014 | | |
3015 | | /* Initialize buffer manager for output buffers*/ |
3016 | 4.87k | ps_codec->pv_out_buf_mgr = ih264_buf_mgr_init( |
3017 | 4.87k | ps_codec->pv_out_buf_mgr_base); |
3018 | | |
3019 | | /* buffer cnt in buffer manager */ |
3020 | 4.87k | ps_codec->i4_inp_buf_cnt = 0; |
3021 | 4.87k | ps_codec->i4_out_buf_cnt = 0; |
3022 | 4.87k | ps_codec->i4_ref_buf_cnt = 0; |
3023 | | |
3024 | 4.87k | ps_codec->ps_pic_buf = (pic_buf_t *) ps_codec->pv_pic_buf_base; |
3025 | 4.87k | memset(ps_codec->ps_pic_buf, 0, BUF_MGR_MAX_CNT * sizeof(pic_buf_t)); |
3026 | | |
3027 | | /* Initialize dpb manager */ |
3028 | 4.87k | ih264_dpb_mgr_init((dpb_mgr_t*) ps_codec->pv_dpb_mgr); |
3029 | | |
3030 | 4.87k | memset(ps_codec->as_ref_set, 0, |
3031 | 4.87k | sizeof(ref_set_t) * (MAX_DPB_SIZE + MAX_CTXT_SETS)); |
3032 | 87.7k | for (i = 0; i < (MAX_DPB_SIZE + MAX_CTXT_SETS); i++) |
3033 | 82.8k | { |
3034 | 82.8k | ps_codec->as_ref_set[i].i4_pic_cnt = -1; |
3035 | 82.8k | } |
3036 | | |
3037 | | /* fn ptr init */ |
3038 | 4.87k | ih264e_init_function_ptr(ps_codec); |
3039 | | |
3040 | | /* reset status flags */ |
3041 | 9.75k | for (i = 0; i < MAX_CTXT_SETS; i++) |
3042 | 4.87k | { |
3043 | 4.87k | ps_codec->au4_entropy_thread_active[i] = 0; |
3044 | 4.87k | ps_codec->ai4_pic_cnt[i] = -1; |
3045 | | |
3046 | 4.87k | ps_codec->s_rate_control.pre_encode_skip[i] = 0; |
3047 | 4.87k | ps_codec->s_rate_control.post_encode_skip[i] = 0; |
3048 | 4.87k | } |
3049 | | |
3050 | 4.87k | ps_codec->s_rate_control.num_intra_in_prev_frame = 0; |
3051 | 4.87k | ps_codec->s_rate_control.i4_avg_activity = 0; |
3052 | | |
3053 | 4.87k | return IV_SUCCESS; |
3054 | 4.87k | } |
3055 | | |
3056 | | /** |
3057 | | ******************************************************************************* |
3058 | | * |
3059 | | * @brief |
3060 | | * Gets number of memory records required by the codec |
3061 | | * |
3062 | | * @par Description: |
3063 | | * Gets codec memory requirements |
3064 | | * |
3065 | | * @param[in] pv_api_ip |
3066 | | * Pointer to input argument structure |
3067 | | * |
3068 | | * @param[out] pv_api_op |
3069 | | * Pointer to output argument structure |
3070 | | * |
3071 | | * @returns status |
3072 | | * |
3073 | | * @remarks |
3074 | | * |
3075 | | ******************************************************************************* |
3076 | | */ |
3077 | | static WORD32 ih264e_get_num_rec(void *pv_api_ip, void *pv_api_op) |
3078 | 4.89k | { |
3079 | | /* api call I/O structures */ |
3080 | 4.89k | ih264e_num_mem_rec_op_t *ps_op = pv_api_op; |
3081 | | |
3082 | 4.89k | UNUSED(pv_api_ip); |
3083 | | |
3084 | 4.89k | ps_op->s_ive_op.u4_num_mem_rec = MEM_REC_CNT; |
3085 | | |
3086 | 4.89k | return IV_SUCCESS; |
3087 | 4.89k | } |
3088 | | |
3089 | | /** |
3090 | | ******************************************************************************* |
3091 | | * |
3092 | | * @brief |
3093 | | * Fills memory records of the codec |
3094 | | * |
3095 | | * @par Description: |
3096 | | * Fills codec memory requirements |
3097 | | * |
3098 | | * @param[in] pv_api_ip |
3099 | | * Pointer to input argument structure |
3100 | | * |
3101 | | * @param[out] pv_api_op |
3102 | | * Pointer to output argument structure |
3103 | | * |
3104 | | * @returns error status |
3105 | | * |
3106 | | * @remarks none |
3107 | | * |
3108 | | ******************************************************************************* |
3109 | | */ |
3110 | | static WORD32 ih264e_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op) |
3111 | 9.76k | { |
3112 | | /* api call I/O structures */ |
3113 | 9.76k | ih264e_fill_mem_rec_ip_t *ps_ip = pv_api_ip; |
3114 | 9.76k | ih264e_fill_mem_rec_op_t *ps_op = pv_api_op; |
3115 | | |
3116 | | /* profile / level info */ |
3117 | 9.76k | WORD32 level; |
3118 | 9.76k | WORD32 num_reorder_frames; |
3119 | 9.76k | WORD32 num_ref_frames; |
3120 | | |
3121 | | /* mem records */ |
3122 | 9.76k | WORD32 no_of_mem_rec; |
3123 | 9.76k | iv_mem_rec_t *ps_mem_rec_base, *ps_mem_rec; |
3124 | | |
3125 | | /* frame dimensions */ |
3126 | 9.76k | WORD32 max_wd_luma, max_ht_luma; |
3127 | 9.76k | WORD32 max_mb_rows, max_mb_cols, max_mb_cnt; |
3128 | | |
3129 | | /* temp var */ |
3130 | 9.76k | WORD32 i; |
3131 | | |
3132 | | /* error status */ |
3133 | 9.76k | IV_STATUS_T status = IV_SUCCESS; |
3134 | | |
3135 | 9.76k | num_reorder_frames = ps_ip->s_ive_ip.u4_max_reorder_cnt; |
3136 | 9.76k | num_ref_frames = ps_ip->s_ive_ip.u4_max_ref_cnt; |
3137 | | |
3138 | | /* mem records */ |
3139 | 9.76k | ps_mem_rec_base = ps_ip->s_ive_ip.ps_mem_rec; |
3140 | 9.76k | no_of_mem_rec = ps_ip->s_ive_ip.u4_num_mem_rec; |
3141 | | |
3142 | | /* frame dimensions */ |
3143 | 9.76k | max_ht_luma = ps_ip->s_ive_ip.u4_max_ht; |
3144 | 9.76k | max_wd_luma = ps_ip->s_ive_ip.u4_max_wd; |
3145 | 9.76k | max_ht_luma = ALIGN16(max_ht_luma); |
3146 | 9.76k | max_wd_luma = ALIGN16(max_wd_luma); |
3147 | 9.76k | max_mb_rows = max_ht_luma / MB_SIZE; |
3148 | 9.76k | max_mb_cols = max_wd_luma / MB_SIZE; |
3149 | 9.76k | max_mb_cnt = max_mb_rows * max_mb_cols; |
3150 | | |
3151 | | /* profile / level info */ |
3152 | 9.76k | level = ih264e_get_min_level(max_wd_luma, max_ht_luma); |
3153 | | |
3154 | | /* validate params */ |
3155 | 9.76k | if ((level < MIN_LEVEL) || (level > MAX_LEVEL)) |
3156 | 0 | { |
3157 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_CODEC_LEVEL_NOT_SUPPORTED; |
3158 | 0 | level = MAX_LEVEL; |
3159 | 0 | } |
3160 | | |
3161 | 9.76k | if (num_ref_frames > MAX_REF_CNT) |
3162 | 0 | { |
3163 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REF_UNSUPPORTED; |
3164 | 0 | num_ref_frames = MAX_REF_CNT; |
3165 | 0 | } |
3166 | | |
3167 | 9.76k | if (num_reorder_frames > MAX_REF_CNT) |
3168 | 0 | { |
3169 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REORDER_UNSUPPORTED; |
3170 | 0 | num_reorder_frames = MAX_REF_CNT; |
3171 | 0 | } |
3172 | | |
3173 | | /* Set all memory records as persistent and alignment as 128 by default */ |
3174 | 9.76k | ps_mem_rec = ps_mem_rec_base; |
3175 | 507k | for (i = 0; i < no_of_mem_rec; i++) |
3176 | 497k | { |
3177 | 497k | ps_mem_rec->u4_mem_alignment = 128; |
3178 | 497k | ps_mem_rec->e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM; |
3179 | 497k | ps_mem_rec++; |
3180 | 497k | } |
3181 | | |
3182 | | /************************************************************************ |
3183 | | * Request memory for h264 encoder handle * |
3184 | | ***********************************************************************/ |
3185 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_IV_OBJ]; |
3186 | 9.76k | { |
3187 | 9.76k | ps_mem_rec->u4_mem_size = sizeof(iv_obj_t); |
3188 | 9.76k | } |
3189 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_IV_OBJ, ps_mem_rec->u4_mem_size); |
3190 | | |
3191 | | /************************************************************************ |
3192 | | * Request memory for h264 encoder context * |
3193 | | ***********************************************************************/ |
3194 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CODEC]; |
3195 | 9.76k | { |
3196 | 9.76k | ps_mem_rec->u4_mem_size = sizeof(codec_t); |
3197 | 9.76k | } |
3198 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_CODEC, ps_mem_rec->u4_mem_size); |
3199 | | |
3200 | | /************************************************************************ |
3201 | | * Request memory for CABAC context * |
3202 | | ***********************************************************************/ |
3203 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CABAC]; |
3204 | 9.76k | { |
3205 | 9.76k | ps_mem_rec->u4_mem_size = sizeof(cabac_ctxt_t); |
3206 | 9.76k | } |
3207 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_CABAC, ps_mem_rec->u4_mem_size); |
3208 | | |
3209 | | /************************************************************************ |
3210 | | * Request memory for CABAC MB info * |
3211 | | ***********************************************************************/ |
3212 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CABAC_MB_INFO]; |
3213 | 9.76k | { |
3214 | 9.76k | ps_mem_rec->u4_mem_size = ((max_mb_cols + 1) + 1) |
3215 | 9.76k | * sizeof(mb_info_ctxt_t); |
3216 | 9.76k | } |
3217 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_CABAC_MB_INFO, ps_mem_rec->u4_mem_size); |
3218 | | |
3219 | | |
3220 | | /************************************************************************ |
3221 | | * Request memory for entropy context * |
3222 | | * In multi core encoding, each row is assumed to be launched on a * |
3223 | | * thread. The rows below can only start after its neighbors are coded * |
3224 | | * The status of an mb coded/uncoded is signaled via entropy map. * |
3225 | | * 1. One word32 to store skip run cnt * |
3226 | | * 2. mb entropy map (mb status entropy coded/uncoded). The size* |
3227 | | * of the entropy map is max mb cols. Further allocate one * |
3228 | | * more additional row to evade checking for row -1. * |
3229 | | * 3. size of bit stream buffer to store bit stream ctxt. * |
3230 | | * 4. Entropy coding is dependent on nnz coefficient count for * |
3231 | | * the neighbor blocks. It is sufficient to maintain one row * |
3232 | | * worth of nnz as entropy for lower row waits on entropy map* |
3233 | | ************************************************************************/ |
3234 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY]; |
3235 | 9.76k | { |
3236 | | /* total size of the mem record */ |
3237 | 9.76k | WORD32 total_size = 0; |
3238 | | |
3239 | | /* size of skip mb run */ |
3240 | 9.76k | total_size += sizeof(WORD32); |
3241 | 9.76k | total_size = ALIGN8(total_size); |
3242 | | |
3243 | | /* size in bytes to store entropy status of an entire frame */ |
3244 | 9.76k | total_size += (max_mb_cols * max_mb_rows); |
3245 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
3246 | 9.76k | total_size += max_mb_cols; |
3247 | 9.76k | total_size = ALIGN128(total_size); |
3248 | | |
3249 | | /* size of bit stream buffer */ |
3250 | 9.76k | total_size += sizeof(bitstrm_t); |
3251 | 9.76k | total_size = ALIGN128(total_size); |
3252 | | |
3253 | | /* top nnz luma */ |
3254 | 9.76k | total_size += (max_mb_cols * 4 * sizeof(UWORD8)); |
3255 | 9.76k | total_size = ALIGN128(total_size); |
3256 | | |
3257 | | /* top nnz cbcr */ |
3258 | 9.76k | total_size += (max_mb_cols * 4 * sizeof(UWORD8)); |
3259 | 9.76k | total_size = ALIGN128(total_size); |
3260 | | |
3261 | | /* total size per each proc ctxt */ |
3262 | 9.76k | total_size *= MAX_CTXT_SETS; |
3263 | | |
3264 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3265 | 9.76k | } |
3266 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_ENTROPY, ps_mem_rec->u4_mem_size); |
3267 | | |
3268 | | /************************************************************************ |
3269 | | * The residue coefficients that needs to be entropy coded are packed * |
3270 | | * at a buffer space by the proc threads. The entropy thread shall * |
3271 | | * read from the buffer space, unpack them and encode the same. The * |
3272 | | * buffer space required to pack a row of mbs are as follows. * |
3273 | | * Assuming transform_8x8_flag is disabled, * |
3274 | | * In the worst case, 1 mb contains 1 dc 4x4 luma sub block, followed * |
3275 | | * by 16 ac 4x4 luma sub blocks, 2 dc chroma 2x2 sub blocks, followed * |
3276 | | * by 8 ac 4x4 chroma sub blocks. * |
3277 | | * For the sake of simplicity we assume that all sub blocks are of * |
3278 | | * type 4x4. The packing of each 4x4 is depicted by the structure * |
3279 | | * tu_sblk_coeff_data_t * |
3280 | | ************************************************************************/ |
3281 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_COEFF_DATA]; |
3282 | 9.76k | { |
3283 | | /* temp var */ |
3284 | 9.76k | WORD32 size = 0; |
3285 | | |
3286 | | /* size of coeff data of 1 mb */ |
3287 | 9.76k | size += sizeof(tu_sblk_coeff_data_t) * MAX_4x4_SUBBLKS; |
3288 | | |
3289 | | /* size of coeff data of 1 row of mb's */ |
3290 | 9.76k | size *= max_mb_cols; |
3291 | | |
3292 | | /* align to avoid any false sharing across threads */ |
3293 | 9.76k | size = ALIGN64(size); |
3294 | | |
3295 | | /* size for one full frame */ |
3296 | 9.76k | size *= max_mb_rows; |
3297 | | |
3298 | | /* size of each proc buffer set (ping, pong) */ |
3299 | 9.76k | size *= MAX_CTXT_SETS; |
3300 | | |
3301 | 9.76k | ps_mem_rec->u4_mem_size = size; |
3302 | 9.76k | } |
3303 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MB_COEFF_DATA, ps_mem_rec->u4_mem_size); |
3304 | | |
3305 | | /************************************************************************ |
3306 | | * while encoding an mb, the mb header data is signaled to the entropy* |
3307 | | * thread by writing to a buffer space. the size of header data per mb * |
3308 | | * is assumed to be 40 bytes * |
3309 | | * TODO: revisit this inference * |
3310 | | ************************************************************************/ |
3311 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_HEADER_DATA]; |
3312 | 9.76k | { |
3313 | | /* temp var */ |
3314 | 9.76k | WORD32 size; |
3315 | | |
3316 | | /* size per MB */ |
3317 | 9.76k | size = 40; |
3318 | | |
3319 | | /* size for 1 row of mbs */ |
3320 | 9.76k | size = size * max_mb_cols; |
3321 | | |
3322 | | /* align to avoid any false sharing across threads */ |
3323 | 9.76k | size = ALIGN64(size); |
3324 | | |
3325 | | /* size for one full frame */ |
3326 | 9.76k | size *= max_mb_rows; |
3327 | | |
3328 | | /* size of each proc buffer set (ping, pong) */ |
3329 | 9.76k | size *= MAX_CTXT_SETS; |
3330 | | |
3331 | 9.76k | ps_mem_rec->u4_mem_size = size; |
3332 | 9.76k | } |
3333 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MB_HEADER_DATA, ps_mem_rec->u4_mem_size); |
3334 | | |
3335 | | /************************************************************************ |
3336 | | * Size for holding mv_buf_t for each MV Bank. * |
3337 | | * Note this allocation is done for BUF_MGR_MAX_CNT instead of * |
3338 | | * MAX_DPB_SIZE or max_dpb_size for following reasons * |
3339 | | * max_dpb_size will be based on max_wd and max_ht * |
3340 | | * For higher max_wd and max_ht this number will be smaller than * |
3341 | | * MAX_DPB_SIZE But during actual initialization number of buffers * |
3342 | | * allocated can be more. * |
3343 | | * * |
3344 | | * One extra MV Bank is needed to hold current pics MV bank. * |
3345 | | * Since this is only a structure allocation and not actual buffer * |
3346 | | * allocation, it is allocated for BUF_MGR_MAX_CNT entries * |
3347 | | ************************************************************************/ |
3348 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MVBANK]; |
3349 | 9.76k | { |
3350 | | /* max luma samples */ |
3351 | 9.76k | WORD32 max_luma_samples = 0; |
3352 | | |
3353 | | /* determine max luma samples */ |
3354 | 165k | for (i = 0; i < 16; i++) |
3355 | 156k | if (level ==(WORD32)gas_ih264_lvl_tbl[i].u4_level_idc) |
3356 | 9.76k | max_luma_samples = gas_ih264_lvl_tbl[i].u4_max_fs |
3357 | 9.76k | << (BLK_SIZE + BLK_SIZE); |
3358 | | |
3359 | 9.76k | ps_mem_rec->u4_mem_size = ih264_buf_mgr_size(); |
3360 | | |
3361 | | /************************************************************************ |
3362 | | * Allocate for pu_map, enc_pu_t and pic_pu_idx for each MV bank * |
3363 | | * Note: Number of luma samples is not max_wd * max_ht here, instead it * |
3364 | | * is set to maximum number of luma samples allowed at the given level. * |
3365 | | * This is done to ensure that any stream with width and height lesser * |
3366 | | * than max_wd and max_ht is supported. Number of buffers required can * |
3367 | | * be greater for lower width and heights at a given level and this * |
3368 | | * increased number of buffers might require more memory than what * |
3369 | | * max_wd and max_ht buffer would have required Also note one extra * |
3370 | | * buffer is allocated to store current pictures MV bank. * |
3371 | | ***********************************************************************/ |
3372 | | |
3373 | 9.76k | ps_mem_rec->u4_mem_size += BUF_MGR_MAX_CNT * sizeof(mv_buf_t); |
3374 | | |
3375 | 9.76k | ps_mem_rec->u4_mem_size += (num_ref_frames + num_reorder_frames |
3376 | 9.76k | + MAX_CTXT_SETS) |
3377 | 9.76k | * ih264e_get_pic_mv_bank_size(max_luma_samples); |
3378 | 9.76k | } |
3379 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MVBANK, ps_mem_rec->u4_mem_size); |
3380 | | |
3381 | | /************************************************************************ |
3382 | | * While encoding inter slices, to compute the cost of encoding an mb * |
3383 | | * with the mv's at hand, we employ the expression cost = sad + lambda * |
3384 | | * x mv_bits. Here mv_bits is the total number of bits taken to represe* |
3385 | | * nt the mv in the stream. The mv bits for all the possible mv are * |
3386 | | * stored in the look up table. The mem record for this look up table * |
3387 | | * is given below. * |
3388 | | ************************************************************************/ |
3389 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MVBITS]; |
3390 | 9.76k | { |
3391 | | /* max srch range x */ |
3392 | 9.76k | UWORD32 u4_srch_range_x = ps_ip->s_ive_ip.u4_max_srch_rng_x; |
3393 | | |
3394 | | /* max srch range y */ |
3395 | 9.76k | UWORD32 u4_srch_range_y = ps_ip->s_ive_ip.u4_max_srch_rng_y; |
3396 | | |
3397 | | /* max srch range */ |
3398 | 9.76k | UWORD32 u4_max_srch_range = MAX(u4_srch_range_x, u4_srch_range_y); |
3399 | | |
3400 | | /* due to subpel */ |
3401 | 9.76k | u4_max_srch_range <<= 2; |
3402 | | |
3403 | | /* due to mv on either direction */ |
3404 | 9.76k | u4_max_srch_range = (u4_max_srch_range << 1); |
3405 | | |
3406 | | /* due to pred mv + zero */ |
3407 | 9.76k | u4_max_srch_range = (u4_max_srch_range << 1) + 1; |
3408 | | |
3409 | 9.76k | u4_max_srch_range = ALIGN128(u4_max_srch_range); |
3410 | | |
3411 | 9.76k | ps_mem_rec->u4_mem_size = u4_max_srch_range; |
3412 | 9.76k | } |
3413 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MVBITS, ps_mem_rec->u4_mem_size); |
3414 | | |
3415 | | /************************************************************************ |
3416 | | * Frame level Intra Cost Map. During intra/inter analysis preserve the* |
3417 | | * intra mb cost for future complexity estimation. * |
3418 | | * NOTE: The cost map is a overlay on the previous frame. In case if an* |
3419 | | * mb is not intra analyzed, the cost here represents its collocated mb* |
3420 | | * intra cost. This traversal can go till the latest I frame at worse * |
3421 | | ************************************************************************/ |
3422 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_INTRA_COST]; |
3423 | 9.76k | { |
3424 | | /* total size of the mem record */ |
3425 | 9.76k | WORD32 total_size = 0; |
3426 | | |
3427 | | /* size in bytes to mb core coding status of an entire frame */ |
3428 | 9.76k | total_size = max_mb_cnt * sizeof(WORD32); |
3429 | | |
3430 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3431 | 9.76k | } |
3432 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_INTRA_COST, ps_mem_rec->u4_mem_size); |
3433 | | |
3434 | | /************************************************************************ |
3435 | | * Request memory for SPS * |
3436 | | ***********************************************************************/ |
3437 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SPS]; |
3438 | 9.76k | { |
3439 | 9.76k | ps_mem_rec->u4_mem_size = MAX_SPS_CNT * sizeof(sps_t); |
3440 | 9.76k | } |
3441 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_SPS, ps_mem_rec->u4_mem_size); |
3442 | | |
3443 | | /************************************************************************ |
3444 | | * Request memory for PPS * |
3445 | | ***********************************************************************/ |
3446 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PPS]; |
3447 | 9.76k | { |
3448 | 9.76k | ps_mem_rec->u4_mem_size = MAX_PPS_CNT * sizeof(pps_t); |
3449 | 9.76k | } |
3450 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_PPS, ps_mem_rec->u4_mem_size); |
3451 | | |
3452 | | /************************************************************************ |
3453 | | * Request memory for Slice Header * |
3454 | | ***********************************************************************/ |
3455 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SLICE_HDR]; |
3456 | 9.76k | { |
3457 | 9.76k | ps_mem_rec->u4_mem_size = MAX_CTXT_SETS * MAX_SLICE_HDR_CNT |
3458 | 9.76k | * sizeof(slice_header_t); |
3459 | 9.76k | } |
3460 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_SLICE_HDR, ps_mem_rec->u4_mem_size); |
3461 | | |
3462 | | /************************************************************************ |
3463 | | * Request memory for Adaptive Intra Refresh * |
3464 | | ***********************************************************************/ |
3465 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_AIR_MAP]; |
3466 | 9.76k | { |
3467 | | /* total size of the mem record */ |
3468 | 9.76k | WORD32 total_size = 0; |
3469 | | |
3470 | | /* intra coded map */ |
3471 | 9.76k | total_size += max_mb_cnt; |
3472 | 9.76k | total_size *= MAX_CTXT_SETS; |
3473 | | |
3474 | | /* mb refresh map */ |
3475 | 9.76k | total_size += sizeof(UWORD16) * max_mb_cnt; |
3476 | | |
3477 | | /* alignment */ |
3478 | 9.76k | total_size = ALIGN128(total_size); |
3479 | | |
3480 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3481 | 9.76k | } |
3482 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_AIR_MAP, ps_mem_rec->u4_mem_size); |
3483 | | |
3484 | | /************************************************************************ |
3485 | | * In multi slice encoding, this memory record helps tracking the start* |
3486 | | * of slice with reference to mb. * |
3487 | | * MEM RECORD for holding * |
3488 | | * 1. mb slice map * |
3489 | | ************************************************************************/ |
3490 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SLICE_MAP]; |
3491 | 9.76k | { |
3492 | | /* total size of the mem record */ |
3493 | 9.76k | WORD32 total_size = 0; |
3494 | | |
3495 | | /* size in bytes to slice index of all mbs of a frame */ |
3496 | 9.76k | total_size = ALIGN64(max_mb_cnt); |
3497 | | |
3498 | | /* ih264e_update_proc_ctxt can overread by 1 at the end */ |
3499 | 9.76k | total_size += 1; |
3500 | | |
3501 | | /* total size per each proc ctxt */ |
3502 | 9.76k | total_size *= MAX_CTXT_SETS; |
3503 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3504 | 9.76k | } |
3505 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_SLICE_MAP, ps_mem_rec->u4_mem_size); |
3506 | | |
3507 | | /************************************************************************ |
3508 | | * Request memory to hold thread handles and synchronization variables * |
3509 | | ************************************************************************/ |
3510 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; |
3511 | 9.76k | { |
3512 | 9.76k | WORD32 thread_pool_size = 0; |
3513 | 9.76k | WORD32 handle_size = ithread_get_handle_size(); |
3514 | | |
3515 | 9.76k | if (ps_ip->s_ive_ip.u4_keep_threads_active) |
3516 | 9.76k | { |
3517 | 9.76k | thread_pool_size += ithread_get_mutex_lock_size(); |
3518 | 9.76k | thread_pool_size += ithread_get_cond_size(); |
3519 | 9.76k | } |
3520 | | |
3521 | 9.76k | ps_mem_rec->u4_mem_size = thread_pool_size + (MAX_PROCESS_THREADS * handle_size); |
3522 | 9.76k | } |
3523 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_THREAD_HANDLE, ps_mem_rec->u4_mem_size); |
3524 | | |
3525 | | /************************************************************************ |
3526 | | * Request memory to hold mutex for control calls * |
3527 | | ************************************************************************/ |
3528 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CTL_MUTEX]; |
3529 | 9.76k | { |
3530 | 9.76k | ps_mem_rec->u4_mem_size = ithread_get_mutex_lock_size(); |
3531 | 9.76k | } |
3532 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_CTL_MUTEX, ps_mem_rec->u4_mem_size); |
3533 | | |
3534 | | /************************************************************************ |
3535 | | * Request memory to hold mutex for entropy calls * |
3536 | | ************************************************************************/ |
3537 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY_MUTEX]; |
3538 | 9.76k | { |
3539 | 9.76k | ps_mem_rec->u4_mem_size = ithread_get_mutex_lock_size(); |
3540 | 9.76k | } |
3541 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_ENTROPY_MUTEX, ps_mem_rec->u4_mem_size); |
3542 | | |
3543 | | /************************************************************************ |
3544 | | * Request memory to hold process jobs * |
3545 | | ***********************************************************************/ |
3546 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_JOBQ]; |
3547 | 9.76k | { |
3548 | | /* One process job per row of MBs */ |
3549 | | /* Allocate for two pictures, so that wrap around can be handled easily */ |
3550 | 9.76k | WORD32 num_jobs = max_mb_rows * MAX_CTXT_SETS; |
3551 | | |
3552 | 9.76k | WORD32 job_queue_size = ih264_list_size(num_jobs, sizeof(job_t)); |
3553 | | |
3554 | 9.76k | ps_mem_rec->u4_mem_size = job_queue_size; |
3555 | 9.76k | } |
3556 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_PROC_JOBQ, ps_mem_rec->u4_mem_size); |
3557 | | |
3558 | | /************************************************************************ |
3559 | | * Request memory to hold entropy jobs * |
3560 | | ***********************************************************************/ |
3561 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY_JOBQ]; |
3562 | 9.76k | { |
3563 | | /* One process job per row of MBs */ |
3564 | | /* Allocate for two pictures, so that wrap around can be handled easily */ |
3565 | 9.76k | WORD32 num_jobs = max_mb_rows * MAX_CTXT_SETS; |
3566 | | |
3567 | 9.76k | WORD32 job_queue_size = ih264_list_size(num_jobs, sizeof(job_t)); |
3568 | | |
3569 | 9.76k | ps_mem_rec->u4_mem_size = job_queue_size; |
3570 | 9.76k | } |
3571 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_ENTROPY_JOBQ, ps_mem_rec->u4_mem_size); |
3572 | | |
3573 | | /************************************************************************ |
3574 | | * In multi core encoding, each row is assumed to be launched on a * |
3575 | | * thread. The rows below can only start after its neighbors are coded * |
3576 | | * The status of an mb coded/uncoded is signaled via proc map. * |
3577 | | * MEM RECORD for holding * |
3578 | | * 1. mb proc map (mb status core coded/uncoded) * |
3579 | | ************************************************************************/ |
3580 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_MAP]; |
3581 | 9.76k | { |
3582 | | /* total size of the mem record */ |
3583 | 9.76k | WORD32 total_size = 0; |
3584 | | |
3585 | | /* size in bytes to mb core coding status of an entire frame */ |
3586 | 9.76k | total_size = max_mb_cnt; |
3587 | | |
3588 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
3589 | 9.76k | total_size += max_mb_cols; |
3590 | | |
3591 | | /* total size per each proc ctxt */ |
3592 | 9.76k | total_size *= MAX_CTXT_SETS; |
3593 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3594 | 9.76k | } |
3595 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_PROC_MAP, ps_mem_rec->u4_mem_size); |
3596 | | |
3597 | | /************************************************************************ |
3598 | | * mem record for holding a particular MB is deblocked or not * |
3599 | | * 1. mb deblk map (mb status deblocked/not deblocked) * |
3600 | | ************************************************************************/ |
3601 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_DBLK_MAP]; |
3602 | 9.76k | { |
3603 | | /* total size of the mem record */ |
3604 | 9.76k | WORD32 total_size = 0; |
3605 | | |
3606 | | /* size in bytes to mb core coding status of an entire frame */ |
3607 | 9.76k | total_size = max_mb_cnt; |
3608 | | |
3609 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
3610 | 9.76k | total_size += max_mb_cols; |
3611 | | |
3612 | 9.76k | total_size = ALIGN64(total_size); |
3613 | | |
3614 | | /* total size per each proc ctxt */ |
3615 | 9.76k | total_size *= MAX_CTXT_SETS; |
3616 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3617 | 9.76k | } |
3618 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_DBLK_MAP, ps_mem_rec->u4_mem_size); |
3619 | | |
3620 | | /************************************************************************ |
3621 | | * mem record for holding a particular MB's me is done or not * |
3622 | | * 1. mb me map * |
3623 | | ************************************************************************/ |
3624 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ME_MAP]; |
3625 | 9.76k | { |
3626 | | /* total size of the mem record */ |
3627 | 9.76k | WORD32 total_size = 0; |
3628 | | |
3629 | | /* size in bytes to mb core coding status of an entire frame */ |
3630 | 9.76k | total_size = max_mb_cnt; |
3631 | | |
3632 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
3633 | 9.76k | total_size += max_mb_cols; |
3634 | | |
3635 | | /* total size per each proc ctxt */ |
3636 | 9.76k | total_size *= MAX_CTXT_SETS; |
3637 | | |
3638 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3639 | 9.76k | } |
3640 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_ME_MAP, ps_mem_rec->u4_mem_size); |
3641 | | |
3642 | | /************************************************************************ |
3643 | | * size for holding dpb manager context * |
3644 | | ************************************************************************/ |
3645 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_DPB_MGR]; |
3646 | 9.76k | { |
3647 | 9.76k | ps_mem_rec->u4_mem_size = sizeof(dpb_mgr_t); |
3648 | 9.76k | } |
3649 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_DPB_MGR, ps_mem_rec->u4_mem_size); |
3650 | | |
3651 | | /************************************************************************ |
3652 | | * luma or chroma core coding involves mb estimation, error computation* |
3653 | | * between the estimated singnal and the actual signal, transform the * |
3654 | | * error, quantize the error, then inverse transform and inverse quant * |
3655 | | * ize the residue and add the result back to estimated signal. * |
3656 | | * To perform all these, a set of temporary buffers are needed. * |
3657 | | * MEM RECORD for holding scratch buffers * |
3658 | | * 1. prediction buffer used during mb mode analysis * |
3659 | | * 2 temp. reference buffer when intra 4x4 with rdopt on is * |
3660 | | * enabled * |
3661 | | * - when intra 4x4 is enabled, rdopt is on, to store the * |
3662 | | * reconstructed values and use them later this temp. buffer * |
3663 | | * is used. * |
3664 | | * 3. prediction buffer used during intra mode analysis * |
3665 | | * 4. prediction buffer used during intra 16x16 plane mode * |
3666 | | * analysis |
3667 | | * 5. prediction buffer used during intra chroma mode analysis * |
3668 | | * 6. prediction buffer used during intra chroma 16x16 plane * |
3669 | | * mode analysis |
3670 | | * 7. forward transform output buffer * |
3671 | | * - to store the error between estimated and the actual inp * |
3672 | | * ut and to store the fwd transformed quantized output * |
3673 | | * 8. forward transform output buffer * |
3674 | | * - when intra 4x4 is enabled, rdopt is on, to store the * |
3675 | | * fwd transform values and use them later this temp. buffer * |
3676 | | * is used. * |
3677 | | * 9. temporary buffer for inverse transform * |
3678 | | * - temporary buffer used in inverse transform and inverse * |
3679 | | * quantization * |
3680 | | * A. Buffers for holding half_x , half_y and half_xy planes * |
3681 | | ************************************************************************/ |
3682 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_SCRATCH]; |
3683 | 9.76k | { |
3684 | 9.76k | WORD32 total_size = 0; |
3685 | 9.76k | WORD32 i4_tmp_size; |
3686 | | |
3687 | | /* size to hold prediction buffer */ |
3688 | 9.76k | total_size += sizeof(UWORD8) * 16 * 16; |
3689 | 9.76k | total_size = ALIGN64(total_size); |
3690 | | |
3691 | | /* size to hold recon for intra 4x4 buffer */ |
3692 | 9.76k | total_size += sizeof(UWORD8) * 16 * 16; |
3693 | 9.76k | total_size = ALIGN64(total_size); |
3694 | | |
3695 | | /* prediction buffer intra 16x16 */ |
3696 | 9.76k | total_size += sizeof(UWORD8) * 16 * 16; |
3697 | 9.76k | total_size = ALIGN64(total_size); |
3698 | | |
3699 | | /* prediction buffer intra 16x16 plane*/ |
3700 | 9.76k | total_size += sizeof(UWORD8) * 16 * 16; |
3701 | 9.76k | total_size = ALIGN64(total_size); |
3702 | | |
3703 | | /* prediction buffer intra chroma*/ |
3704 | 9.76k | total_size += sizeof(UWORD8) * 16 * 8; |
3705 | 9.76k | total_size = ALIGN64(total_size); |
3706 | | |
3707 | | /* prediction buffer intra chroma plane*/ |
3708 | 9.76k | total_size += sizeof(UWORD8) * 16 * 8; |
3709 | 9.76k | total_size = ALIGN64(total_size); |
3710 | | |
3711 | | /* size to hold fwd transform output */ |
3712 | 9.76k | total_size += sizeof(WORD16) * SIZE_TRANS_BUFF; |
3713 | 9.76k | total_size = ALIGN64(total_size); |
3714 | | |
3715 | | /* size to hold fwd transform output */ |
3716 | 9.76k | total_size += sizeof(WORD16) * SIZE_TRANS_BUFF; |
3717 | 9.76k | total_size = ALIGN64(total_size); |
3718 | | |
3719 | | /* size to hold temporary data during inverse transform */ |
3720 | 9.76k | total_size += sizeof(WORD32) * SIZE_TMP_BUFF_ITRANS; |
3721 | 9.76k | total_size = ALIGN64(total_size); |
3722 | | |
3723 | | /* Buffers for holding half_x , half_y and half_xy planes */ |
3724 | 9.76k | i4_tmp_size = sizeof(UWORD8) * (HP_BUFF_WD * HP_BUFF_HT); |
3725 | 9.76k | total_size += (ALIGN64(i4_tmp_size) * SUBPEL_BUFF_CNT); |
3726 | | |
3727 | | /* Allocate for each process thread */ |
3728 | 9.76k | total_size *= MAX_PROCESS_CTXT; |
3729 | | |
3730 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3731 | 9.76k | } |
3732 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_PROC_SCRATCH, ps_mem_rec->u4_mem_size); |
3733 | | |
3734 | | /************************************************************************ |
3735 | | * When transform_8x8_flag is disabled, the size of a sub block is * |
3736 | | * 4x4 and when the transform_8x8_flag is enabled the size of the sub * |
3737 | | * block is 8x8. The threshold matrix and the forward scaling list * |
3738 | | * is of the size of the sub block. * |
3739 | | * MEM RECORD for holding * |
3740 | | * 1. quantization parameters for plane y, cb, cr * |
3741 | | * - threshold matrix for quantization * |
3742 | | * - forward weight matrix * |
3743 | | * - satqd threshold matrix * |
3744 | | ************************************************************************/ |
3745 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_QUANT_PARAM]; |
3746 | 9.76k | { |
3747 | | /* total size of the mem record */ |
3748 | 9.76k | WORD32 total_size = 0; |
3749 | | |
3750 | | /* quantization parameter list for planes y,cb and cr */ |
3751 | 9.76k | total_size += ALIGN64(sizeof(quant_params_t)) * 3; |
3752 | | |
3753 | | /* size of threshold matrix for quantization |
3754 | | * (assuming the transform_8x8_flag is disabled). |
3755 | | * for all 3 planes */ |
3756 | 9.76k | total_size += ALIGN64(sizeof(WORD16) * 4 * 4) * 3; |
3757 | | |
3758 | | /* size of forward weight matrix for quantization |
3759 | | * (assuming the transform_8x8_flag is disabled). |
3760 | | * for all 3 planes */ |
3761 | 9.76k | total_size += ALIGN64(sizeof(WORD16) * 4 * 4) * 3; |
3762 | | |
3763 | | /* Size for SATDQ threshold matrix for palnes y, cb and cr */ |
3764 | 9.76k | total_size += ALIGN64(sizeof(UWORD16) * 9) * 3; |
3765 | | |
3766 | | /* total size per each proc thread */ |
3767 | 9.76k | total_size *= MAX_PROCESS_CTXT; |
3768 | | |
3769 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3770 | 9.76k | } |
3771 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_QUANT_PARAM, ps_mem_rec->u4_mem_size); |
3772 | | |
3773 | | /************************************************************************ |
3774 | | * While computing blocking strength for the current mb, the csbp, mb * |
3775 | | * type for the neighboring mbs are necessary. memtab for storing top * |
3776 | | * row mbtype and csbp is evaluated here. * |
3777 | | * * |
3778 | | * when encoding intra 4x4 or intra 8x8 the submb types are estimated * |
3779 | | * and sent. The estimation is dependent on neighbor mbs. For this * |
3780 | | * store the top row sub mb types for intra mbs * |
3781 | | * * |
3782 | | * During motion vector prediction, the curr mb mv is predicted from * |
3783 | | * neigbors left, top, top right and sometimes top left depending on * |
3784 | | * the availability. The top and top right content is accessed from * |
3785 | | * the memtab specified below. * |
3786 | | ************************************************************************/ |
3787 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_TOP_ROW_SYN_INFO]; |
3788 | 9.76k | { |
3789 | | /* total size of the mem record */ |
3790 | 9.76k | WORD32 total_size = 0; |
3791 | | |
3792 | | /* size in bytes to store 1 row of mb_info_t */ |
3793 | | /* one additional mb, to avoid checking end of row condition */ |
3794 | 9.76k | total_size += (max_mb_cols + 1) * sizeof(mb_info_t); |
3795 | | |
3796 | | /* size in bytes to store 1 row of intra macroblock sub modes */ |
3797 | 9.76k | total_size += max_mb_cols * sizeof(UWORD8) * 16; |
3798 | | |
3799 | | /* size in bytes to store 1 row + 1 of enc_pu_t */ |
3800 | | /* one additional mb, to avoid checking end of row condition */ |
3801 | 9.76k | total_size += (max_mb_cols + 1) * sizeof(enc_pu_t); |
3802 | | |
3803 | | /* total size per proc ctxt */ |
3804 | 9.76k | total_size = ALIGN128(total_size); |
3805 | | |
3806 | | /* total size per each proc ctxt */ |
3807 | 9.76k | total_size *= MAX_CTXT_SETS; |
3808 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3809 | 9.76k | } |
3810 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_TOP_ROW_SYN_INFO, ps_mem_rec->u4_mem_size); |
3811 | | |
3812 | | /************************************************************************ |
3813 | | * When transform_8x8_flag is disabled, the mb is partitioned into * |
3814 | | * 4 sub blocks. This corresponds to 1 vertical left edge and 1 * |
3815 | | * vertical inner edge, 1 horizontal top edge and 1 horizontal * |
3816 | | * inner edge per mb. Further, When transform_8x8_flag is enabled, * |
3817 | | * the mb is partitioned in to 16 sub blocks. This corresponds to * |
3818 | | * 1 vertical left edge and 3 vertical inner edges, 1 horizontal top * |
3819 | | * edge and 3 horizontal inner edges per mb. * |
3820 | | * MEM RECORD for holding * |
3821 | | * 1. vertical edge blocking strength * |
3822 | | * 2. horizontal edge blocking strength * |
3823 | | * 3. mb qp * |
3824 | | * all are frame level * |
3825 | | ************************************************************************/ |
3826 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_BS_QP]; |
3827 | 9.76k | { |
3828 | | /* total size of the mem record */ |
3829 | 9.76k | WORD32 total_size = 0; |
3830 | | |
3831 | | /* size in bytes to store vertical edge bs, horizontal edge bs and qp of every mb*/ |
3832 | 9.76k | WORD32 vert_bs_size, horz_bs_size, qp_size; |
3833 | | |
3834 | | /* vertical edge bs = total number of vertical edges * number of bytes per each edge */ |
3835 | | /* total num of v edges = total mb * 4 (assuming transform_8x8_flag = 0), |
3836 | | * each edge is formed by 4 pairs of subblks, requiring 4 bytes to storing bs */ |
3837 | 9.76k | vert_bs_size = ALIGN64(max_mb_cnt * 4 * 4); |
3838 | | |
3839 | | /* horizontal edge bs = total number of horizontal edges * number of bytes per each edge */ |
3840 | | /* total num of h edges = total mb * 4 (assuming transform_8x8_flag = 0), |
3841 | | * each edge is formed by 4 pairs of subblks, requiring 4 bytes to storing bs */ |
3842 | 9.76k | horz_bs_size = ALIGN64(max_mb_cnt * 4 * 4); |
3843 | | |
3844 | | /* qp of each mb requires 1 byte */ |
3845 | 9.76k | qp_size = ALIGN64(max_mb_cnt); |
3846 | | |
3847 | | /* total size */ |
3848 | 9.76k | total_size = vert_bs_size + horz_bs_size + qp_size; |
3849 | | |
3850 | | /* total size per each proc ctxt */ |
3851 | 9.76k | total_size *= MAX_CTXT_SETS; |
3852 | | |
3853 | 9.76k | ps_mem_rec->u4_mem_size = total_size; |
3854 | 9.76k | } |
3855 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_BS_QP, ps_mem_rec->u4_mem_size); |
3856 | | |
3857 | | /************************************************************************ |
3858 | | * size for holding dpb manager context * |
3859 | | ************************************************************************/ |
3860 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_INP_PIC]; |
3861 | 9.76k | { |
3862 | 9.76k | ps_mem_rec->u4_mem_size = ih264_buf_mgr_size(); |
3863 | 9.76k | } |
3864 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_INP_PIC, ps_mem_rec->u4_mem_size); |
3865 | | |
3866 | | /************************************************************************ |
3867 | | * size for holding dpb manager context * |
3868 | | ************************************************************************/ |
3869 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_OUT]; |
3870 | 9.76k | { |
3871 | 9.76k | ps_mem_rec->u4_mem_size = ih264_buf_mgr_size(); |
3872 | 9.76k | } |
3873 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_OUT, ps_mem_rec->u4_mem_size); |
3874 | | |
3875 | | /************************************************************************ |
3876 | | * Size for color space conversion * |
3877 | | ************************************************************************/ |
3878 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CSC]; |
3879 | 9.76k | { |
3880 | | /* We need a total a memory for a single frame of 420 sp, ie |
3881 | | * (wd * ht) for luma and (wd * ht / 2) for chroma*/ |
3882 | 9.76k | ps_mem_rec->u4_mem_size = MAX_CTXT_SETS |
3883 | 9.76k | * ((3 * max_ht_luma * max_wd_luma) >> 1); |
3884 | | /* Allocate an extra row, since inverse transform functions for |
3885 | | * chroma access(only read, not used) few extra bytes due to |
3886 | | * interleaved input |
3887 | | */ |
3888 | 9.76k | ps_mem_rec->u4_mem_size += max_wd_luma; |
3889 | 9.76k | } |
3890 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_CSC, ps_mem_rec->u4_mem_size); |
3891 | | |
3892 | | /************************************************************************ |
3893 | | * Size for holding pic_buf_t for each reference picture * |
3894 | | * Note this allocation is done for BUF_MGR_MAX_CNT instead of * |
3895 | | * MAX_DPB_SIZE or max_dpb_size for following reasons * |
3896 | | * max_dpb_size will be based on max_wd and max_ht * |
3897 | | * For higher max_wd and max_ht this number will be smaller than * |
3898 | | * MAX_DPB_SIZE But during actual initialization number of buffers * |
3899 | | * allocated can be more. * |
3900 | | * * |
3901 | | * Also to handle display depth application can allocate more than * |
3902 | | * what codec asks for in case of non-shared mode * |
3903 | | * Since this is only a structure allocation and not actual buffer * |
3904 | | * allocation, it is allocated for BUF_MGR_MAX_CNT entries * |
3905 | | ************************************************************************/ |
3906 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_REF_PIC]; |
3907 | 9.76k | { |
3908 | 9.76k | ps_mem_rec->u4_mem_size = ih264_buf_mgr_size(); |
3909 | 9.76k | ps_mem_rec->u4_mem_size += BUF_MGR_MAX_CNT * sizeof(pic_buf_t); |
3910 | | |
3911 | | /************************************************************************ |
3912 | | * Note: Number of luma samples is not max_wd * max_ht here, instead it * |
3913 | | * is set to maximum number of luma samples allowed at the given level. * |
3914 | | * This is done to ensure that any stream with width and height lesser * |
3915 | | * than max_wd and max_ht is supported. Number of buffers required can * |
3916 | | * be greater for lower width and heights at a given level and this * |
3917 | | * increased number of buffers might require more memory than what * |
3918 | | * max_wd and max_ht buffer would have required. Number of buffers is * |
3919 | | * doubled in order to return one frame at a time instead of sending * |
3920 | | * multiple outputs during dpb full case. Also note one extra buffer is * |
3921 | | * allocted to store current picture. * |
3922 | | * * |
3923 | | * Half-pel planes for each reference buffer are allocated along with * |
3924 | | * the reference buffer. So each reference buffer is 4 times the * |
3925 | | * required size. This way buffer management for the half-pel planes is * |
3926 | | * easier and while using the half-pel planes in MC, an offset can be * |
3927 | | * used from a single pointer * |
3928 | | ***********************************************************************/ |
3929 | 9.76k | ps_mem_rec->u4_mem_size += HPEL_PLANES_CNT |
3930 | 9.76k | * ih264e_get_total_pic_buf_size( |
3931 | 9.76k | max_wd_luma * max_ht_luma, level, |
3932 | 9.76k | PAD_WD, PAD_HT, num_ref_frames, |
3933 | 9.76k | num_reorder_frames); |
3934 | 9.76k | } |
3935 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_REF_PIC, ps_mem_rec->u4_mem_size); |
3936 | | |
3937 | | /************************************************************************ |
3938 | | * Request memory to hold mem recs to be returned during retrieve call * |
3939 | | ************************************************************************/ |
3940 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_BACKUP]; |
3941 | 9.76k | { |
3942 | 9.76k | ps_mem_rec->u4_mem_size = MEM_REC_CNT * sizeof(iv_mem_rec_t); |
3943 | 9.76k | } |
3944 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_BACKUP, ps_mem_rec->u4_mem_size); |
3945 | | |
3946 | | /************************************************************************ |
3947 | | * size for memory required by NMB info structs and buffer for storing * |
3948 | | * half pel plane * |
3949 | | ************************************************************************/ |
3950 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_INFO_NMB]; |
3951 | 9.76k | { |
3952 | 9.76k | ps_mem_rec->u4_mem_size = MAX_PROCESS_CTXT * max_mb_cols * |
3953 | 9.76k | (sizeof(mb_info_nmb_t) + MB_SIZE * MB_SIZE |
3954 | 9.76k | * sizeof(UWORD8)); |
3955 | 9.76k | } |
3956 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MB_INFO_NMB, ps_mem_rec->u4_mem_size); |
3957 | | |
3958 | | /************************************************************************ |
3959 | | * RC mem records * |
3960 | | ************************************************************************/ |
3961 | 9.76k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_RC]; |
3962 | 9.76k | { |
3963 | 9.76k | ih264e_get_rate_control_mem_tab(NULL, ps_mem_rec, FILL_MEMTAB); |
3964 | 9.76k | } |
3965 | 9.76k | DEBUG("\nMemory record Id %d = %d \n", MEM_REC_RC, ps_mem_rec->u4_mem_size); |
3966 | | |
3967 | | /* Each memtab size is aligned to next multiple of 128 bytes */ |
3968 | | /* This is to ensure all the memtabs start at different cache lines */ |
3969 | 9.76k | ps_mem_rec = ps_mem_rec_base; |
3970 | 507k | for (i = 0; i < MEM_REC_CNT; i++) |
3971 | 497k | { |
3972 | 497k | ps_mem_rec->u4_mem_size = ALIGN128(ps_mem_rec->u4_mem_size); |
3973 | 497k | ps_mem_rec++; |
3974 | 497k | } |
3975 | | |
3976 | 9.76k | ps_op->s_ive_op.u4_num_mem_rec = MEM_REC_CNT; |
3977 | | |
3978 | 9.76k | DEBUG("Num mem recs in fill call : %d\n", ps_op->s_ive_op.u4_num_mem_rec); |
3979 | | |
3980 | 9.76k | return (status); |
3981 | 9.76k | } |
3982 | | |
3983 | | /** |
3984 | | ******************************************************************************* |
3985 | | * |
3986 | | * @brief |
3987 | | * Initializes from mem records passed to the codec |
3988 | | * |
3989 | | * @par Description: |
3990 | | * Initializes pointers based on mem records passed |
3991 | | * |
3992 | | * @param[in] ps_codec_obj |
3993 | | * Pointer to codec object at API level |
3994 | | * |
3995 | | * @param[in] pv_api_ip |
3996 | | * Pointer to input argument structure |
3997 | | * |
3998 | | * @param[out] pv_api_op |
3999 | | * Pointer to output argument structure |
4000 | | * |
4001 | | * @returns error status |
4002 | | * |
4003 | | * @remarks none |
4004 | | * |
4005 | | ******************************************************************************* |
4006 | | */ |
4007 | | static WORD32 ih264e_init_mem_rec(iv_obj_t *ps_codec_obj, |
4008 | | void *pv_api_ip, |
4009 | | void *pv_api_op) |
4010 | 4.87k | { |
4011 | | /* api call I/O structures */ |
4012 | 4.87k | ih264e_init_ip_t *ps_ip = pv_api_ip; |
4013 | 4.87k | ih264e_init_op_t *ps_op = pv_api_op; |
4014 | | |
4015 | | /* mem records */ |
4016 | 4.87k | iv_mem_rec_t *ps_mem_rec_base, *ps_mem_rec; |
4017 | | |
4018 | | /* codec variables */ |
4019 | 4.87k | codec_t * ps_codec; |
4020 | 4.87k | cabac_ctxt_t *ps_cabac; |
4021 | 4.87k | mb_info_ctxt_t *ps_mb_map_ctxt_inc; |
4022 | | |
4023 | 4.87k | cfg_params_t *ps_cfg; |
4024 | | |
4025 | | /* frame dimensions */ |
4026 | 4.87k | WORD32 max_wd_luma, max_ht_luma; |
4027 | 4.87k | WORD32 max_mb_rows, max_mb_cols, max_mb_cnt; |
4028 | | |
4029 | | /* temp var */ |
4030 | 4.87k | WORD32 i, j; |
4031 | 4.87k | WORD32 status = IV_SUCCESS; |
4032 | | |
4033 | | /* frame dimensions */ |
4034 | 4.87k | max_ht_luma = ALIGN16(ps_ip->s_ive_ip.u4_max_ht); |
4035 | 4.87k | max_wd_luma = ALIGN16(ps_ip->s_ive_ip.u4_max_wd); |
4036 | 4.87k | max_mb_rows = max_ht_luma / MB_SIZE; |
4037 | 4.87k | max_mb_cols = max_wd_luma / MB_SIZE; |
4038 | 4.87k | max_mb_cnt = max_mb_rows * max_mb_cols; |
4039 | | |
4040 | | /* mem records */ |
4041 | 4.87k | ps_mem_rec_base = ps_ip->s_ive_ip.ps_mem_rec; |
4042 | | /* memset all allocated memory, except the first one. First buffer (i.e. i == MEM_REC_IV_OBJ) |
4043 | | is initialized by application before calling this init function */ |
4044 | 248k | for (i = MEM_REC_CODEC; i < MEM_REC_CNT; i++) |
4045 | 243k | { |
4046 | 243k | ps_mem_rec = &ps_mem_rec_base[i]; |
4047 | 243k | memset(ps_mem_rec->pv_base, 0, ps_mem_rec->u4_mem_size); |
4048 | 243k | } |
4049 | | |
4050 | | /* Init mem records */ |
4051 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CODEC]; |
4052 | 4.87k | { |
4053 | 4.87k | ps_codec_obj->pv_codec_handle = ps_mem_rec->pv_base; |
4054 | 4.87k | ps_codec = (codec_t *) (ps_codec_obj->pv_codec_handle); |
4055 | 4.87k | } |
4056 | | /* Init mem records_cabac ctxt */ |
4057 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CABAC]; |
4058 | 4.87k | { |
4059 | 4.87k | ps_cabac = (cabac_ctxt_t *)(ps_mem_rec->pv_base); |
4060 | 4.87k | } |
4061 | | |
4062 | | /* Init mem records mb info array for CABAC */ |
4063 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CABAC_MB_INFO]; |
4064 | 4.87k | { |
4065 | 4.87k | ps_mb_map_ctxt_inc = (mb_info_ctxt_t *)(ps_mem_rec->pv_base); |
4066 | 4.87k | } |
4067 | | |
4068 | | /* Note this memset can not be done in init() call, since init will called |
4069 | | during reset as well. And calling this during reset will mean all pointers |
4070 | | need to reinitialized */ |
4071 | 4.87k | memset(ps_codec, 0, sizeof(codec_t)); |
4072 | 4.87k | memset(ps_cabac, 0, sizeof(cabac_ctxt_t)); |
4073 | | |
4074 | | /* Set default Config Params */ |
4075 | 4.87k | ps_cfg = &ps_codec->s_cfg; |
4076 | 4.87k | ih264e_set_default_params(ps_cfg); |
4077 | | |
4078 | | /* Update config params as per input */ |
4079 | 4.87k | ps_cfg->u4_max_wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd); |
4080 | 4.87k | ps_cfg->u4_max_ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht); |
4081 | | |
4082 | | /* Initialize dimensions to max dimensions during init */ |
4083 | 4.87k | ps_cfg->u4_wd = ps_cfg->u4_disp_wd = ps_cfg->u4_max_wd; |
4084 | 4.87k | ps_cfg->u4_ht = ps_cfg->u4_disp_ht = ps_cfg->u4_max_ht; |
4085 | | |
4086 | 4.87k | ps_cfg->i4_wd_mbs = ps_cfg->u4_max_wd >> 4; |
4087 | 4.87k | ps_cfg->i4_ht_mbs = ps_cfg->u4_max_ht >> 4; |
4088 | 4.87k | ps_cfg->u4_max_ref_cnt = ps_ip->s_ive_ip.u4_max_ref_cnt; |
4089 | 4.87k | ps_cfg->u4_max_reorder_cnt = ps_ip->s_ive_ip.u4_max_reorder_cnt; |
4090 | 4.87k | ps_cfg->u4_max_level = ps_ip->s_ive_ip.u4_max_level; |
4091 | 4.87k | ps_cfg->e_inp_color_fmt = ps_ip->s_ive_ip.e_inp_color_fmt; |
4092 | 4.87k | ps_cfg->e_recon_color_fmt = ps_ip->s_ive_ip.e_recon_color_fmt; |
4093 | 4.87k | ps_cfg->u4_max_framerate = ps_ip->s_ive_ip.u4_max_framerate; |
4094 | 4.87k | ps_cfg->u4_max_bitrate = ps_ip->s_ive_ip.u4_max_bitrate; |
4095 | 4.87k | ps_cfg->u4_num_bframes = ps_ip->s_ive_ip.u4_num_bframes; |
4096 | 4.87k | ps_cfg->e_content_type = ps_ip->s_ive_ip.e_content_type; |
4097 | 4.87k | ps_cfg->u4_max_srch_rng_x = ps_ip->s_ive_ip.u4_max_srch_rng_x; |
4098 | 4.87k | ps_cfg->u4_max_srch_rng_y = ps_ip->s_ive_ip.u4_max_srch_rng_y; |
4099 | 4.87k | ps_cfg->e_slice_mode = ps_ip->s_ive_ip.e_slice_mode; |
4100 | 4.87k | ps_cfg->u4_slice_param = ps_ip->s_ive_ip.u4_slice_param; |
4101 | 4.87k | ps_cfg->e_arch = ps_ip->s_ive_ip.e_arch; |
4102 | 4.87k | ps_cfg->e_soc = ps_ip->s_ive_ip.e_soc; |
4103 | 4.87k | ps_cfg->u4_enable_recon = ps_ip->s_ive_ip.u4_enable_recon; |
4104 | 4.87k | ps_cfg->e_rc_mode = ps_ip->s_ive_ip.e_rc_mode; |
4105 | 4.87k | ps_cfg->u4_keep_threads_active = ps_ip->s_ive_ip.u4_keep_threads_active; |
4106 | | |
4107 | | /* Validate params */ |
4108 | 4.87k | if ((ps_ip->s_ive_ip.u4_max_level < MIN_LEVEL) |
4109 | 4.87k | || (ps_ip->s_ive_ip.u4_max_level > MAX_LEVEL)) |
4110 | 0 | { |
4111 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_CODEC_LEVEL_NOT_SUPPORTED; |
4112 | 0 | ps_cfg->u4_max_level = DEFAULT_MAX_LEVEL; |
4113 | 0 | } |
4114 | | |
4115 | 4.87k | if (ps_ip->s_ive_ip.u4_max_ref_cnt > MAX_REF_CNT) |
4116 | 0 | { |
4117 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REF_UNSUPPORTED; |
4118 | 0 | ps_cfg->u4_max_ref_cnt = MAX_REF_CNT; |
4119 | 0 | } |
4120 | | |
4121 | 4.87k | if (ps_ip->s_ive_ip.u4_max_reorder_cnt > MAX_REF_CNT) |
4122 | 0 | { |
4123 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REORDER_UNSUPPORTED; |
4124 | 0 | ps_cfg->u4_max_reorder_cnt = MAX_REF_CNT; |
4125 | 0 | } |
4126 | | |
4127 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_BACKUP]; |
4128 | 4.87k | { |
4129 | 4.87k | ps_codec->ps_mem_rec_backup = (iv_mem_rec_t *) ps_mem_rec->pv_base; |
4130 | | |
4131 | 4.87k | memcpy(ps_codec->ps_mem_rec_backup, ps_mem_rec_base, |
4132 | 4.87k | MEM_REC_CNT * sizeof(iv_mem_rec_t)); |
4133 | 4.87k | } |
4134 | | |
4135 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY]; |
4136 | 4.87k | { |
4137 | | /* temp var */ |
4138 | 4.87k | WORD32 size = 0, offset; |
4139 | | |
4140 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4141 | 39.0k | { |
4142 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4143 | 39.0k | { |
4144 | | /* base ptr */ |
4145 | 39.0k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4146 | | |
4147 | | /* reset size */ |
4148 | 39.0k | size = 0; |
4149 | | |
4150 | | /* skip mb run */ |
4151 | 39.0k | ps_codec->as_process[i].s_entropy.pi4_mb_skip_run = |
4152 | 39.0k | (void *) (pu1_buf + size); |
4153 | 39.0k | size += sizeof(WORD32); |
4154 | 39.0k | size = ALIGN8(size); |
4155 | | |
4156 | | /* entropy map */ |
4157 | 39.0k | ps_codec->as_process[i].s_entropy.pu1_entropy_map = |
4158 | 39.0k | (void *) (pu1_buf + size + max_mb_cols); |
4159 | | /* size in bytes to store entropy status of an entire frame */ |
4160 | 39.0k | size += (max_mb_cols * max_mb_rows); |
4161 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
4162 | 39.0k | size += max_mb_cols; |
4163 | 39.0k | size = ALIGN128(size); |
4164 | | |
4165 | | /* bit stream ptr */ |
4166 | 39.0k | ps_codec->as_process[i].s_entropy.ps_bitstrm = (void *) (pu1_buf |
4167 | 39.0k | + size); |
4168 | 39.0k | size += sizeof(bitstrm_t); |
4169 | 39.0k | size = ALIGN128(size); |
4170 | | |
4171 | | /* nnz luma */ |
4172 | 39.0k | ps_codec->as_process[i].s_entropy.pu1_top_nnz_luma = |
4173 | 39.0k | (void *) (pu1_buf + size); |
4174 | 39.0k | size += (max_mb_cols * 4 * sizeof(UWORD8)); |
4175 | 39.0k | size = ALIGN128(size); |
4176 | | |
4177 | | /* nnz chroma */ |
4178 | 39.0k | ps_codec->as_process[i].s_entropy.pu1_top_nnz_cbcr = |
4179 | 39.0k | (void *) (pu1_buf + size); |
4180 | 39.0k | size += (max_mb_cols * 4 * sizeof(UWORD8)); |
4181 | 39.0k | size = ALIGN128(size); |
4182 | 39.0k | offset = size; |
4183 | | /* cabac Context */ |
4184 | 39.0k | ps_codec->as_process[i].s_entropy.ps_cabac = ps_cabac; |
4185 | 39.0k | } |
4186 | 0 | else |
4187 | 0 | { |
4188 | | /* base ptr */ |
4189 | 0 | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4190 | | |
4191 | | /* reset size */ |
4192 | 0 | size = offset; |
4193 | | |
4194 | | /* skip mb run */ |
4195 | 0 | ps_codec->as_process[i].s_entropy.pi4_mb_skip_run = |
4196 | 0 | (void *) (pu1_buf + size); |
4197 | 0 | size += sizeof(WORD32); |
4198 | 0 | size = ALIGN8(size); |
4199 | | |
4200 | | /* entropy map */ |
4201 | 0 | ps_codec->as_process[i].s_entropy.pu1_entropy_map = |
4202 | 0 | (void *) (pu1_buf + size + max_mb_cols); |
4203 | | /* size in bytes to store entropy status of an entire frame */ |
4204 | 0 | size += (max_mb_cols * max_mb_rows); |
4205 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
4206 | 0 | size += max_mb_cols; |
4207 | 0 | size = ALIGN128(size); |
4208 | | |
4209 | | /* bit stream ptr */ |
4210 | 0 | ps_codec->as_process[i].s_entropy.ps_bitstrm = (void *) (pu1_buf |
4211 | 0 | + size); |
4212 | 0 | size += sizeof(bitstrm_t); |
4213 | 0 | size = ALIGN128(size); |
4214 | | |
4215 | | /* nnz luma */ |
4216 | 0 | ps_codec->as_process[i].s_entropy.pu1_top_nnz_luma = |
4217 | 0 | (void *) (pu1_buf + size); |
4218 | 0 | size += (max_mb_cols * 4 * sizeof(UWORD8)); |
4219 | 0 | size = ALIGN128(size); |
4220 | | |
4221 | | /* nnz chroma */ |
4222 | 0 | ps_codec->as_process[i].s_entropy.pu1_top_nnz_cbcr = |
4223 | 0 | (void *) (pu1_buf + size); |
4224 | 0 | size += (max_mb_cols * 4 * sizeof(UWORD8)); |
4225 | 0 | size = ALIGN128(size); |
4226 | | /* cabac Context */ |
4227 | 0 | ps_codec->as_process[i].s_entropy.ps_cabac = ps_cabac; |
4228 | 0 | } |
4229 | 39.0k | } |
4230 | 4.87k | ps_codec->as_process[0].s_entropy.ps_cabac->ps_mb_map_ctxt_inc_base = |
4231 | 4.87k | ps_mb_map_ctxt_inc; |
4232 | 4.87k | } |
4233 | | |
4234 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_COEFF_DATA]; |
4235 | 4.87k | { |
4236 | | /* temp var */ |
4237 | 4.87k | WORD32 size = 0, size_of_row; |
4238 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4239 | | |
4240 | | /* size of coeff data of 1 mb */ |
4241 | 4.87k | size += sizeof(tu_sblk_coeff_data_t) * MAX_4x4_SUBBLKS; |
4242 | | |
4243 | | /* size of coeff data of 1 row of mb's */ |
4244 | 4.87k | size *= max_mb_cols; |
4245 | | |
4246 | | /* align to avoid false sharing */ |
4247 | 4.87k | size = ALIGN64(size); |
4248 | 4.87k | size_of_row = size; |
4249 | | |
4250 | | /* size for one full frame */ |
4251 | 4.87k | size *= max_mb_rows; |
4252 | | |
4253 | 4.87k | ps_codec->u4_size_coeff_data = size_of_row; |
4254 | | |
4255 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4256 | 39.0k | { |
4257 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4258 | 39.0k | { |
4259 | 39.0k | ps_codec->as_process[i].pv_pic_mb_coeff_data = pu1_buf; |
4260 | 39.0k | ps_codec->as_process[i].s_entropy.pv_pic_mb_coeff_data = |
4261 | 39.0k | pu1_buf; |
4262 | 39.0k | } |
4263 | 0 | else |
4264 | 0 | { |
4265 | 0 | ps_codec->as_process[i].pv_pic_mb_coeff_data = pu1_buf + size; |
4266 | 0 | ps_codec->as_process[i].s_entropy.pv_pic_mb_coeff_data = pu1_buf |
4267 | 0 | + size; |
4268 | 0 | } |
4269 | 39.0k | } |
4270 | 4.87k | } |
4271 | | |
4272 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_HEADER_DATA]; |
4273 | 4.87k | { |
4274 | | /* temp var */ |
4275 | 4.87k | WORD32 size, size_of_row; |
4276 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4277 | | |
4278 | | /* size of header data of 1 mb */ |
4279 | 4.87k | size = sizeof(mb_hdr_t); |
4280 | | |
4281 | | /* size for 1 row of mbs */ |
4282 | 4.87k | size = size * max_mb_cols; |
4283 | | |
4284 | | /* align to avoid any false sharing across threads */ |
4285 | 4.87k | size = ALIGN64(size); |
4286 | 4.87k | size_of_row = size; |
4287 | | |
4288 | | /* size for one full frame */ |
4289 | 4.87k | size *= max_mb_rows; |
4290 | | |
4291 | 4.87k | ps_codec->u4_size_header_data = size_of_row; |
4292 | | |
4293 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4294 | 39.0k | { |
4295 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4296 | 39.0k | { |
4297 | 39.0k | ps_codec->as_process[i].pv_pic_mb_header_data = pu1_buf; |
4298 | 39.0k | ps_codec->as_process[i].s_entropy.pv_pic_mb_header_data = |
4299 | 39.0k | pu1_buf; |
4300 | 39.0k | } |
4301 | 0 | else |
4302 | 0 | { |
4303 | 0 | ps_codec->as_process[i].pv_pic_mb_header_data = pu1_buf + size; |
4304 | 0 | ps_codec->as_process[i].s_entropy.pv_pic_mb_header_data = |
4305 | 0 | pu1_buf + size; |
4306 | 0 | } |
4307 | 39.0k | } |
4308 | 4.87k | } |
4309 | | |
4310 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MVBANK]; |
4311 | 4.87k | { |
4312 | | /* size of buf mgr struct */ |
4313 | 4.87k | WORD32 size = ih264_buf_mgr_size(); |
4314 | | |
4315 | | /* temp var */ |
4316 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4317 | | |
4318 | | /* mv buffer mgr */ |
4319 | 4.87k | ps_codec->pv_mv_buf_mgr_base = pu1_buf; |
4320 | | |
4321 | | /* mv bank */ |
4322 | 4.87k | ps_codec->pv_mv_bank_buf_base = pu1_buf + size; |
4323 | 4.87k | ps_codec->i4_total_mv_bank_size = ps_mem_rec->u4_mem_size - size; |
4324 | 4.87k | } |
4325 | | |
4326 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MVBITS]; |
4327 | 4.87k | { |
4328 | | /* max srch range x */ |
4329 | 4.87k | UWORD32 u4_srch_range_x = ps_ip->s_ive_ip.u4_max_srch_rng_x; |
4330 | | |
4331 | | /* max srch range y */ |
4332 | 4.87k | UWORD32 u4_srch_range_y = ps_ip->s_ive_ip.u4_max_srch_rng_y; |
4333 | | |
4334 | | /* max srch range */ |
4335 | 4.87k | UWORD32 u4_max_srch_range = MAX(u4_srch_range_x, u4_srch_range_y); |
4336 | | |
4337 | | /* temp var */ |
4338 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4339 | | |
4340 | | /* due to subpel */ |
4341 | 4.87k | u4_max_srch_range <<= 2; |
4342 | | |
4343 | | // /* due to mv on either direction */ |
4344 | | // u4_max_srch_range = (u4_max_srch_range << 1); |
4345 | | |
4346 | | /* due to pred mv + zero */ |
4347 | 4.87k | u4_max_srch_range = (u4_max_srch_range << 1) + 1; |
4348 | | |
4349 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4350 | 39.0k | { |
4351 | | /* me ctxt */ |
4352 | 39.0k | me_ctxt_t *ps_mem_ctxt = &(ps_codec->as_process[i].s_me_ctxt); |
4353 | | |
4354 | | /* init at zero mv */ |
4355 | 39.0k | ps_mem_ctxt->pu1_mv_bits = pu1_buf + u4_max_srch_range; |
4356 | 39.0k | } |
4357 | 4.87k | } |
4358 | | |
4359 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_INTRA_COST]; |
4360 | 4.87k | { |
4361 | 4.87k | ps_codec->pi4_mb_intra_cost = ps_mem_rec->pv_base; |
4362 | 4.87k | } |
4363 | | |
4364 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SPS]; |
4365 | 4.87k | { |
4366 | 4.87k | ps_codec->ps_sps_base = (sps_t *) ps_mem_rec->pv_base; |
4367 | 4.87k | } |
4368 | | |
4369 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PPS]; |
4370 | 4.87k | { |
4371 | 4.87k | ps_codec->ps_pps_base = (pps_t *) ps_mem_rec->pv_base; |
4372 | 4.87k | } |
4373 | | |
4374 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SLICE_HDR]; |
4375 | 4.87k | { |
4376 | 4.87k | ps_codec->ps_slice_hdr_base = ps_mem_rec->pv_base; |
4377 | | |
4378 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4379 | 39.0k | { |
4380 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4381 | 39.0k | { |
4382 | 39.0k | ps_codec->as_process[i].ps_slice_hdr_base = ps_mem_rec->pv_base; |
4383 | 39.0k | } |
4384 | 0 | else |
4385 | 0 | { |
4386 | | /* temp var */ |
4387 | 0 | WORD32 size = MAX_SLICE_HDR_CNT * sizeof(slice_header_t); |
4388 | 0 | void *pv_buf = (UWORD8 *) ps_mem_rec->pv_base + size; |
4389 | |
|
4390 | 0 | ps_codec->as_process[i].ps_slice_hdr_base = pv_buf; |
4391 | 0 | } |
4392 | 39.0k | } |
4393 | 4.87k | } |
4394 | | |
4395 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_AIR_MAP]; |
4396 | 4.87k | { |
4397 | | /* temp var */ |
4398 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4399 | | |
4400 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4401 | 39.0k | { |
4402 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4403 | 39.0k | { |
4404 | 39.0k | ps_codec->as_process[i].pu1_is_intra_coded = pu1_buf; |
4405 | 39.0k | } |
4406 | 0 | else |
4407 | 0 | { |
4408 | 0 | ps_codec->as_process[i].pu1_is_intra_coded = pu1_buf |
4409 | 0 | + max_mb_cnt; |
4410 | 0 | } |
4411 | 39.0k | } |
4412 | | |
4413 | 4.87k | ps_codec->pu2_intr_rfrsh_map = (UWORD16 *) (pu1_buf + max_mb_cnt * MAX_CTXT_SETS); |
4414 | 4.87k | } |
4415 | | |
4416 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_SLICE_MAP]; |
4417 | 4.87k | { |
4418 | | /* pointer to storage space */ |
4419 | 4.87k | UWORD8 *pu1_buf_ping, *pu1_buf_pong; |
4420 | | |
4421 | | /* init pointer */ |
4422 | 4.87k | pu1_buf_ping = ps_mem_rec->pv_base; |
4423 | 4.87k | pu1_buf_pong = pu1_buf_ping + ALIGN64(max_mb_cnt); |
4424 | | |
4425 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4426 | 39.0k | { |
4427 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4428 | 39.0k | { |
4429 | 39.0k | ps_codec->as_process[i].pu1_slice_idx = pu1_buf_ping; |
4430 | 39.0k | } |
4431 | 0 | else |
4432 | 0 | { |
4433 | 0 | ps_codec->as_process[i].pu1_slice_idx = pu1_buf_pong; |
4434 | 0 | } |
4435 | 39.0k | } |
4436 | 4.87k | } |
4437 | | |
4438 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_THREAD_HANDLE]; |
4439 | 4.87k | { |
4440 | 4.87k | UWORD8 *pu1_buf = (UWORD8 *)ps_mem_rec->pv_base; |
4441 | 4.87k | WORD32 handle_size = ithread_get_handle_size(); |
4442 | | |
4443 | 4.87k | if (ps_ip->s_ive_ip.u4_keep_threads_active) |
4444 | 4.87k | { |
4445 | 4.87k | ps_codec->s_thread_pool.pv_thread_pool_mutex = (void *)pu1_buf; |
4446 | 4.87k | pu1_buf += ithread_get_mutex_lock_size(); |
4447 | | |
4448 | 4.87k | ps_codec->s_thread_pool.pv_thread_pool_cond = (void *)pu1_buf; |
4449 | 4.87k | pu1_buf += ithread_get_cond_size(); |
4450 | 4.87k | } |
4451 | | |
4452 | 43.8k | for (i = 0; i < MAX_PROCESS_THREADS; i++) |
4453 | 39.0k | { |
4454 | 39.0k | ps_codec->apv_proc_thread_handle[i] = (void *)(pu1_buf + (i * handle_size)); |
4455 | 39.0k | } |
4456 | 4.87k | } |
4457 | | |
4458 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CTL_MUTEX]; |
4459 | 4.87k | { |
4460 | 4.87k | ps_codec->pv_ctl_mutex = ps_mem_rec->pv_base; |
4461 | 4.87k | } |
4462 | | |
4463 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY_MUTEX]; |
4464 | 4.87k | { |
4465 | 4.87k | ps_codec->pv_entropy_mutex = ps_mem_rec->pv_base; |
4466 | 4.87k | } |
4467 | | |
4468 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_JOBQ]; |
4469 | 4.87k | { |
4470 | 4.87k | ps_codec->pv_proc_jobq_buf = ps_mem_rec->pv_base; |
4471 | 4.87k | ps_codec->i4_proc_jobq_buf_size = ps_mem_rec->u4_mem_size; |
4472 | 4.87k | } |
4473 | | |
4474 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ENTROPY_JOBQ]; |
4475 | 4.87k | { |
4476 | 4.87k | ps_codec->pv_entropy_jobq_buf = ps_mem_rec->pv_base; |
4477 | 4.87k | ps_codec->i4_entropy_jobq_buf_size = ps_mem_rec->u4_mem_size; |
4478 | 4.87k | } |
4479 | | |
4480 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_MAP]; |
4481 | 4.87k | { |
4482 | | /* pointer to storage space */ |
4483 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4484 | | |
4485 | | /* total size of the mem record */ |
4486 | 4.87k | WORD32 total_size = 0; |
4487 | | |
4488 | | /* size in bytes to mb core coding status of an entire frame */ |
4489 | 4.87k | total_size = max_mb_cnt; |
4490 | | |
4491 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
4492 | 4.87k | total_size += max_mb_cols; |
4493 | | |
4494 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4495 | 39.0k | { |
4496 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4497 | 39.0k | { |
4498 | 39.0k | ps_codec->as_process[i].pu1_proc_map = pu1_buf + max_mb_cols; |
4499 | 39.0k | } |
4500 | 0 | else |
4501 | 0 | { |
4502 | 0 | ps_codec->as_process[i].pu1_proc_map = pu1_buf + total_size |
4503 | 0 | + max_mb_cols; |
4504 | 0 | } |
4505 | 39.0k | } |
4506 | 4.87k | } |
4507 | | |
4508 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_DBLK_MAP]; |
4509 | 4.87k | { |
4510 | | /* pointer to storage space */ |
4511 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4512 | | |
4513 | | /* total size of the mem record */ |
4514 | 4.87k | WORD32 total_size = 0; |
4515 | | |
4516 | | /* size in bytes to mb core coding status of an entire frame */ |
4517 | 4.87k | total_size = max_mb_cnt; |
4518 | | |
4519 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
4520 | 4.87k | total_size += max_mb_cols; |
4521 | | |
4522 | | /*Align the memory offsets*/ |
4523 | 4.87k | total_size = ALIGN64(total_size); |
4524 | | |
4525 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4526 | 39.0k | { |
4527 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4528 | 39.0k | { |
4529 | 39.0k | ps_codec->as_process[i].pu1_deblk_map = pu1_buf + max_mb_cols; |
4530 | | |
4531 | 39.0k | } |
4532 | 0 | else |
4533 | 0 | { |
4534 | 0 | ps_codec->as_process[i].pu1_deblk_map = pu1_buf + total_size |
4535 | 0 | + max_mb_cols; |
4536 | |
|
4537 | 0 | } |
4538 | 39.0k | } |
4539 | 4.87k | } |
4540 | | |
4541 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_ME_MAP]; |
4542 | 4.87k | { |
4543 | | /* pointer to storage space */ |
4544 | 4.87k | UWORD8 *pu1_buf = (UWORD8 *) ps_mem_rec->pv_base; |
4545 | | |
4546 | | /* total size of the mem record */ |
4547 | 4.87k | WORD32 total_size = 0; |
4548 | | |
4549 | | /* size in bytes to mb core coding status of an entire frame */ |
4550 | 4.87k | total_size = max_mb_cnt; |
4551 | | |
4552 | | /* add an additional 1 row of bytes to evade the special case of row 0 */ |
4553 | 4.87k | total_size += max_mb_cols; |
4554 | | |
4555 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4556 | 39.0k | { |
4557 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4558 | 39.0k | { |
4559 | 39.0k | ps_codec->as_process[i].pu1_me_map = pu1_buf + max_mb_cols; |
4560 | 39.0k | } |
4561 | 0 | else |
4562 | 0 | { |
4563 | 0 | ps_codec->as_process[i].pu1_me_map = pu1_buf + total_size |
4564 | 0 | + max_mb_cols; |
4565 | 0 | } |
4566 | 39.0k | } |
4567 | 4.87k | } |
4568 | | |
4569 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_DPB_MGR]; |
4570 | 4.87k | { |
4571 | 4.87k | ps_codec->pv_dpb_mgr = ps_mem_rec->pv_base; |
4572 | 4.87k | } |
4573 | | |
4574 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_PROC_SCRATCH]; |
4575 | 4.87k | { |
4576 | | /* pointer to storage space */ |
4577 | 4.87k | UWORD8 *pu1_buf = (UWORD8 *) ps_mem_rec->pv_base; |
4578 | | |
4579 | | /* size of pred buffer, fwd transform output, temp buffer for inv tra */ |
4580 | 4.87k | WORD32 size_pred_luma, size_pred_chroma, size_fwd, size_inv, size_hp; |
4581 | | |
4582 | | /* temp var */ |
4583 | 4.87k | WORD32 size = 0; |
4584 | | |
4585 | | /* size to hold intra/inter prediction buffer */ |
4586 | 4.87k | size_pred_luma = sizeof(UWORD8) * 16 * 16; |
4587 | 4.87k | size_pred_chroma = sizeof(UWORD8) * 8 * 16; |
4588 | | |
4589 | | /* size to hold fwd transform output */ |
4590 | 4.87k | size_fwd = sizeof(WORD16) * SIZE_TRANS_BUFF; |
4591 | | |
4592 | | /* size to hold temporary data during inverse transform */ |
4593 | 4.87k | size_inv = sizeof(WORD32) * SIZE_TMP_BUFF_ITRANS; |
4594 | | |
4595 | | /* size to hold half pel plane buffers */ |
4596 | 4.87k | size_hp = sizeof(UWORD8) * (HP_BUFF_WD * HP_BUFF_HT); |
4597 | | |
4598 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4599 | 39.0k | { |
4600 | | /* prediction buffer */ |
4601 | 39.0k | ps_codec->as_process[i].pu1_pred_mb = (void *) (pu1_buf + size); |
4602 | 39.0k | ps_codec->as_process[i].i4_pred_strd = 16; |
4603 | 39.0k | size += size_pred_luma; |
4604 | 39.0k | size = ALIGN64(size); |
4605 | | |
4606 | | /* prediction buffer */ |
4607 | 39.0k | ps_codec->as_process[i].pu1_ref_mb_intra_4x4 = (void *) (pu1_buf |
4608 | 39.0k | + size); |
4609 | 39.0k | size += size_pred_luma; |
4610 | 39.0k | size = ALIGN64(size); |
4611 | | |
4612 | | /* prediction buffer intra 16x16 */ |
4613 | 39.0k | ps_codec->as_process[i].pu1_pred_mb_intra_16x16 = (void *) (pu1_buf |
4614 | 39.0k | + size); |
4615 | 39.0k | size += size_pred_luma; |
4616 | 39.0k | size = ALIGN64(size); |
4617 | | |
4618 | | /* prediction buffer intra 16x16 plane*/ |
4619 | 39.0k | ps_codec->as_process[i].pu1_pred_mb_intra_16x16_plane = |
4620 | 39.0k | (void *) (pu1_buf + size); |
4621 | 39.0k | size += size_pred_luma; |
4622 | 39.0k | size = ALIGN64(size); |
4623 | | |
4624 | | /* prediction buffer intra chroma*/ |
4625 | 39.0k | ps_codec->as_process[i].pu1_pred_mb_intra_chroma = (void *) (pu1_buf |
4626 | 39.0k | + size); |
4627 | 39.0k | size += size_pred_chroma; |
4628 | 39.0k | size = ALIGN64(size); |
4629 | | |
4630 | | /* prediction buffer intra chroma plane*/ |
4631 | 39.0k | ps_codec->as_process[i].pu1_pred_mb_intra_chroma_plane = |
4632 | 39.0k | (void *) (pu1_buf + size); |
4633 | 39.0k | size += size_pred_chroma; |
4634 | 39.0k | size = ALIGN64(size); |
4635 | | |
4636 | | /* Fwd transform output */ |
4637 | 39.0k | ps_codec->as_process[i].pi2_res_buf = (void *) (pu1_buf + size); |
4638 | 39.0k | ps_codec->as_process[i].i4_res_strd = 16; |
4639 | 39.0k | size += size_fwd; |
4640 | 39.0k | size = ALIGN64(size); |
4641 | | |
4642 | | /* Fwd transform output */ |
4643 | 39.0k | ps_codec->as_process[i].pi2_res_buf_intra_4x4 = (void *) (pu1_buf |
4644 | 39.0k | + size); |
4645 | 39.0k | size += size_fwd; |
4646 | 39.0k | size = ALIGN64(size); |
4647 | | |
4648 | | /* scratch buffer used during inverse transform */ |
4649 | 39.0k | ps_codec->as_process[i].pv_scratch_buff = (void *) (pu1_buf + size); |
4650 | 39.0k | size += size_inv; |
4651 | 39.0k | size = ALIGN64(size); |
4652 | | |
4653 | 195k | for (j = 0; j < SUBPEL_BUFF_CNT; j++) |
4654 | 156k | { |
4655 | 156k | ps_codec->as_process[i].apu1_subpel_buffs[j] = (pu1_buf + size); |
4656 | 156k | size += ALIGN64(size_hp); |
4657 | 156k | } |
4658 | 39.0k | } |
4659 | 4.87k | } |
4660 | | |
4661 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_QUANT_PARAM]; |
4662 | 4.87k | { |
4663 | | /* pointer to storage space */ |
4664 | 4.87k | UWORD8 *pu1_buf = (UWORD8 *) ps_mem_rec->pv_base; |
4665 | | |
4666 | | /* size of qp, threshold matrix, fwd scaling list for one plane */ |
4667 | 4.87k | WORD32 size_quant_param, size_thres_mat, size_fwd_weight_mat, |
4668 | 4.87k | size_satqd_weight_mat; |
4669 | | |
4670 | | /* temp var */ |
4671 | 4.87k | WORD32 total_size = 0; |
4672 | | |
4673 | | /* size of quantization parameter list of 1 plane */ |
4674 | 4.87k | size_quant_param = ALIGN64(sizeof(quant_params_t)); |
4675 | | |
4676 | | /* size of threshold matrix for quantization |
4677 | | * (assuming the transform_8x8_flag is disabled). |
4678 | | * for 1 plane */ |
4679 | 4.87k | size_thres_mat = ALIGN64(sizeof(WORD16) * 4 * 4); |
4680 | | |
4681 | | /* size of forward weight matrix for quantization |
4682 | | * (assuming the transform_8x8_flag is disabled). |
4683 | | * for 1 plane */ |
4684 | 4.87k | size_fwd_weight_mat = ALIGN64(sizeof(WORD16) * 4 * 4); |
4685 | | |
4686 | | /* size of SATQD matrix*/ |
4687 | 4.87k | size_satqd_weight_mat = ALIGN64(sizeof(UWORD16) * 9); |
4688 | | |
4689 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4690 | 39.0k | { |
4691 | 39.0k | quant_params_t **ps_qp_params = ps_codec->as_process[i].ps_qp_params; |
4692 | | |
4693 | | /* quantization param structure */ |
4694 | 39.0k | ps_qp_params[0] = (quant_params_t *) (pu1_buf + total_size); |
4695 | 39.0k | total_size = total_size + size_quant_param; |
4696 | 39.0k | ps_qp_params[1] = (quant_params_t *) (pu1_buf + total_size); |
4697 | 39.0k | total_size = total_size + size_quant_param; |
4698 | 39.0k | ps_qp_params[2] = (quant_params_t *) (pu1_buf + total_size); |
4699 | 39.0k | total_size = total_size + size_quant_param; |
4700 | | |
4701 | | /* threshold matrix for quantization */ |
4702 | 39.0k | ps_qp_params[0]->pu2_thres_mat = (void *) (pu1_buf + total_size); |
4703 | 39.0k | total_size = total_size + size_thres_mat; |
4704 | 39.0k | ps_qp_params[1]->pu2_thres_mat = (void *) (pu1_buf + total_size); |
4705 | 39.0k | total_size = total_size + size_thres_mat; |
4706 | 39.0k | ps_qp_params[2]->pu2_thres_mat = (void *) (pu1_buf + total_size); |
4707 | 39.0k | total_size = total_size + size_thres_mat; |
4708 | | |
4709 | | /* fwd weight matrix */ |
4710 | 39.0k | ps_qp_params[0]->pu2_weigh_mat = (void *) (pu1_buf + total_size); |
4711 | 39.0k | total_size = total_size + size_fwd_weight_mat; |
4712 | 39.0k | ps_qp_params[1]->pu2_weigh_mat = (void *) (pu1_buf + total_size); |
4713 | 39.0k | total_size = total_size + size_fwd_weight_mat; |
4714 | 39.0k | ps_qp_params[2]->pu2_weigh_mat = (void *) (pu1_buf + total_size); |
4715 | 39.0k | total_size = total_size + size_fwd_weight_mat; |
4716 | | |
4717 | | /* threshold matrix for SATQD */ |
4718 | 39.0k | ps_qp_params[0]->pu2_sad_thrsh = (void *) (pu1_buf + total_size); |
4719 | 39.0k | total_size = total_size + size_satqd_weight_mat; |
4720 | 39.0k | ps_qp_params[1]->pu2_sad_thrsh = (void *) (pu1_buf + total_size); |
4721 | 39.0k | total_size = total_size + size_satqd_weight_mat; |
4722 | 39.0k | ps_qp_params[2]->pu2_sad_thrsh = (void *) (pu1_buf + total_size); |
4723 | 39.0k | total_size = total_size + size_satqd_weight_mat; |
4724 | | |
4725 | 39.0k | total_size = ALIGN128(total_size); |
4726 | 39.0k | } |
4727 | 4.87k | } |
4728 | | |
4729 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_TOP_ROW_SYN_INFO]; |
4730 | 4.87k | { |
4731 | | /* total size of the mem record */ |
4732 | 4.87k | WORD32 total_size = 0, size_csbp, size_intra_modes, size_mv; |
4733 | | |
4734 | | /* pointer to buffer */ |
4735 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4736 | | |
4737 | | /* size in bytes to store 1 row of mb_info_t */ |
4738 | | /* one additional mb, to avoid checking end of row condition */ |
4739 | 4.87k | size_csbp = (max_mb_cols + 1) * sizeof(mb_info_t); |
4740 | | |
4741 | | /* size in bytes to store 1 row of intra macroblock sub modes */ |
4742 | 4.87k | size_intra_modes = max_mb_cols * sizeof(UWORD8) * 16; |
4743 | | |
4744 | | /* size in bytes to store 1 row + 1 of enc_pu_t */ |
4745 | | /* one additional mb, to avoid checking end of row condition */ |
4746 | 4.87k | size_mv = (max_mb_cols + 1) * sizeof(enc_pu_t); |
4747 | | |
4748 | | /* total size per proc ctxt */ |
4749 | 4.87k | total_size = size_csbp + size_intra_modes + size_mv; |
4750 | | |
4751 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4752 | 39.0k | { |
4753 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4754 | 39.0k | { |
4755 | 39.0k | ps_codec->as_process[i].ps_top_row_mb_syntax_ele_base = |
4756 | 39.0k | (mb_info_t *) pu1_buf; |
4757 | 39.0k | ps_codec->as_process[i].pu1_top_mb_intra_modes_base = pu1_buf |
4758 | 39.0k | + size_csbp; |
4759 | 39.0k | ps_codec->as_process[i].ps_top_row_pu_base = |
4760 | 39.0k | (enc_pu_t *) (pu1_buf + size_csbp |
4761 | 39.0k | + size_intra_modes); |
4762 | 39.0k | } |
4763 | 0 | else |
4764 | 0 | { |
4765 | 0 | ps_codec->as_process[i].ps_top_row_mb_syntax_ele_base = |
4766 | 0 | (mb_info_t *) (pu1_buf + total_size); |
4767 | 0 | ps_codec->as_process[i].pu1_top_mb_intra_modes_base = pu1_buf |
4768 | 0 | + total_size + size_csbp; |
4769 | 0 | ps_codec->as_process[i].ps_top_row_pu_base = |
4770 | 0 | (enc_pu_t *) (pu1_buf + total_size + size_csbp |
4771 | 0 | + size_intra_modes); |
4772 | 0 | } |
4773 | 39.0k | } |
4774 | 4.87k | } |
4775 | | |
4776 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_BS_QP]; |
4777 | 4.87k | { |
4778 | 4.87k | UWORD8 *pu1_buf_ping, *pu1_buf_pong; |
4779 | | |
4780 | | /* total size of the mem record */ |
4781 | 4.87k | WORD32 total_size = 0; |
4782 | | |
4783 | | /* size in bytes to store vertical edge bs, horizontal edge bs and qp of every mb*/ |
4784 | 4.87k | WORD32 vert_bs_size, horz_bs_size, qp_size; |
4785 | | |
4786 | | /* vertical edge bs = total number of vertical edges * number of bytes per each edge */ |
4787 | | /* total num of v edges = total mb * 4 (assuming transform_8x8_flag = 0), |
4788 | | * each edge is formed by 4 pairs of subblks, requiring 4 bytes to storing bs */ |
4789 | 4.87k | vert_bs_size = ALIGN64(max_mb_cnt * 4 * 4); |
4790 | | |
4791 | | /* horizontal edge bs = total number of horizontal edges * number of bytes per each edge */ |
4792 | | /* total num of h edges = total mb * 4 (assuming transform_8x8_flag = 0), |
4793 | | * each edge is formed by 4 pairs of subblks, requiring 4 bytes to storing bs */ |
4794 | 4.87k | horz_bs_size = ALIGN64(max_mb_cnt * 4 * 4); |
4795 | | |
4796 | | /* qp of each mb requires 1 byte */ |
4797 | 4.87k | qp_size = ALIGN64(max_mb_cnt); |
4798 | | |
4799 | | /* total size */ |
4800 | 4.87k | total_size = vert_bs_size + horz_bs_size + qp_size; |
4801 | | |
4802 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4803 | 39.0k | { |
4804 | 39.0k | if (i < MAX_PROCESS_CTXT / MAX_CTXT_SETS) |
4805 | 39.0k | { |
4806 | 39.0k | pu1_buf_ping = (UWORD8 *) ps_mem_rec->pv_base; |
4807 | | |
4808 | | /* vertical edge bs storage space */ |
4809 | 39.0k | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_vert_bs = |
4810 | 39.0k | (UWORD32 *) pu1_buf_ping; |
4811 | 39.0k | pu1_buf_ping += vert_bs_size; |
4812 | | |
4813 | | /* horizontal edge bs storage space */ |
4814 | 39.0k | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_horz_bs = |
4815 | 39.0k | (UWORD32 *) pu1_buf_ping; |
4816 | 39.0k | pu1_buf_ping += horz_bs_size; |
4817 | | |
4818 | | /* qp */ |
4819 | 39.0k | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp = |
4820 | 39.0k | (UWORD8 *) pu1_buf_ping; |
4821 | 39.0k | pu1_buf_ping += qp_size; |
4822 | 39.0k | } |
4823 | 0 | else |
4824 | 0 | { |
4825 | 0 | pu1_buf_pong = (UWORD8 *) ps_mem_rec->pv_base; |
4826 | 0 | pu1_buf_pong += total_size; |
4827 | | |
4828 | | /* vertical edge bs storage space */ |
4829 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_vert_bs = |
4830 | 0 | (UWORD32 *) pu1_buf_pong; |
4831 | 0 | pu1_buf_pong += vert_bs_size; |
4832 | | |
4833 | | /* horizontal edge bs storage space */ |
4834 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu4_pic_horz_bs = |
4835 | 0 | (UWORD32 *) pu1_buf_pong; |
4836 | 0 | pu1_buf_pong += horz_bs_size; |
4837 | | |
4838 | | /* qp */ |
4839 | 0 | ps_codec->as_process[i].s_deblk_ctxt.s_bs_ctxt.pu1_pic_qp = |
4840 | 0 | (UWORD8 *) pu1_buf_pong; |
4841 | 0 | pu1_buf_pong += qp_size; |
4842 | 0 | } |
4843 | 39.0k | } |
4844 | 4.87k | } |
4845 | | |
4846 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_INP_PIC]; |
4847 | 4.87k | { |
4848 | 4.87k | ps_codec->pv_inp_buf_mgr_base = ps_mem_rec->pv_base; |
4849 | 4.87k | } |
4850 | | |
4851 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_OUT]; |
4852 | 4.87k | { |
4853 | 4.87k | ps_codec->pv_out_buf_mgr_base = ps_mem_rec->pv_base; |
4854 | 4.87k | } |
4855 | | |
4856 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_CSC]; |
4857 | 4.87k | { |
4858 | 4.87k | ps_codec->pu1_y_csc_buf_base = ps_mem_rec->pv_base; |
4859 | 4.87k | ps_codec->pu1_uv_csc_buf_base = (UWORD8 *) ps_mem_rec->pv_base |
4860 | 4.87k | + (max_ht_luma * max_wd_luma); |
4861 | 4.87k | } |
4862 | | |
4863 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_REF_PIC]; |
4864 | 4.87k | { |
4865 | | /* size of buf mgr struct */ |
4866 | 4.87k | WORD32 size = ih264_buf_mgr_size(); |
4867 | | |
4868 | | /* temp var */ |
4869 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4870 | | |
4871 | | /* pic buffer mgr */ |
4872 | 4.87k | ps_codec->pv_ref_buf_mgr_base = pu1_buf; |
4873 | | |
4874 | | /* picture bank */ |
4875 | 4.87k | ps_codec->pv_pic_buf_base = pu1_buf + size; |
4876 | 4.87k | ps_codec->i4_total_pic_buf_size = ps_mem_rec->u4_mem_size - size; |
4877 | 4.87k | } |
4878 | | |
4879 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_INFO_NMB]; |
4880 | 4.87k | { |
4881 | | /* temp var */ |
4882 | 4.87k | UWORD8 *pu1_buf = ps_mem_rec->pv_base; |
4883 | | |
4884 | | /* size of nmb ctxt */ |
4885 | 4.87k | WORD32 size = max_mb_cols * sizeof(mb_info_nmb_t); |
4886 | | |
4887 | 4.87k | WORD32 nmb_cntr, subpel_buf_size; |
4888 | | |
4889 | | /* init nmb info structure pointer in all proc ctxts */ |
4890 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4891 | 39.0k | { |
4892 | 39.0k | ps_codec->as_process[i].ps_nmb_info = (mb_info_nmb_t *) (pu1_buf); |
4893 | | |
4894 | 39.0k | pu1_buf += size; |
4895 | 39.0k | } |
4896 | | |
4897 | 4.87k | subpel_buf_size = MB_SIZE * MB_SIZE * sizeof(UWORD8); |
4898 | | |
4899 | | /* adjusting pointers for nmb halfpel buffer */ |
4900 | 43.8k | for (i = 0; i < MAX_PROCESS_CTXT; i++) |
4901 | 39.0k | { |
4902 | 39.0k | mb_info_nmb_t* ps_mb_info_nmb = |
4903 | 39.0k | &ps_codec->as_process[i].ps_nmb_info[0]; |
4904 | | |
4905 | 977k | for (nmb_cntr = 0; nmb_cntr < max_mb_cols; nmb_cntr++) |
4906 | 938k | { |
4907 | 938k | ps_mb_info_nmb[nmb_cntr].pu1_best_sub_pel_buf = pu1_buf; |
4908 | | |
4909 | 938k | pu1_buf = pu1_buf + subpel_buf_size; |
4910 | | |
4911 | 938k | ps_mb_info_nmb[nmb_cntr].u4_bst_spel_buf_strd = MB_SIZE; |
4912 | 938k | } |
4913 | 39.0k | } |
4914 | 4.87k | } |
4915 | | |
4916 | 4.87k | ps_mem_rec = &ps_mem_rec_base[MEM_REC_RC]; |
4917 | 4.87k | { |
4918 | 4.87k | ih264e_get_rate_control_mem_tab(&ps_codec->s_rate_control, ps_mem_rec, |
4919 | 4.87k | USE_BASE); |
4920 | 4.87k | } |
4921 | | |
4922 | | /* init codec ctxt */ |
4923 | 4.87k | status = ih264e_init(ps_codec); |
4924 | | |
4925 | 4.87k | return status; |
4926 | 4.87k | } |
4927 | | |
4928 | | /** |
4929 | | ******************************************************************************* |
4930 | | * |
4931 | | * @brief |
4932 | | * Retrieves mem records passed to the codec |
4933 | | * |
4934 | | * @par Description: |
4935 | | * Retrieves mem recs passed during init |
4936 | | * |
4937 | | * @param[in] ps_codec_obj |
4938 | | * Pointer to codec object at API level |
4939 | | * |
4940 | | * @param[in] pv_api_ip |
4941 | | * Pointer to input argument structure |
4942 | | * |
4943 | | * @param[out] pv_api_op |
4944 | | * Pointer to output argument structure |
4945 | | * |
4946 | | * @returns error status |
4947 | | * |
4948 | | * @remarks none |
4949 | | * |
4950 | | ******************************************************************************* |
4951 | | */ |
4952 | | static WORD32 ih264e_retrieve_memrec(iv_obj_t *ps_codec_obj, |
4953 | | void *pv_api_ip, |
4954 | | void *pv_api_op) |
4955 | 4.87k | { |
4956 | | /* codec ctxt */ |
4957 | 4.87k | codec_t *ps_codec = (codec_t *) ps_codec_obj->pv_codec_handle; |
4958 | | |
4959 | | /* ctrl call I/O structures */ |
4960 | 4.87k | ih264e_retrieve_mem_rec_ip_t *ps_ip = pv_api_ip; |
4961 | 4.87k | ih264e_retrieve_mem_rec_op_t *ps_op = pv_api_op; |
4962 | | |
4963 | 4.87k | if (ps_codec->i4_init_done != 1) |
4964 | 0 | { |
4965 | 0 | ps_op->s_ive_op.u4_error_code |= 1 << IVE_FATALERROR; |
4966 | 0 | ps_op->s_ive_op.u4_error_code |= IH264E_INIT_NOT_DONE; |
4967 | 0 | return IV_FAIL; |
4968 | 0 | } |
4969 | | |
4970 | 4.87k | if (ps_codec->s_cfg.u4_keep_threads_active) |
4971 | 4.87k | { |
4972 | 4.87k | ih264e_thread_pool_shutdown(ps_codec); |
4973 | 4.87k | ithread_cond_destroy(ps_codec->s_thread_pool.pv_thread_pool_cond); |
4974 | 4.87k | ithread_mutex_destroy(ps_codec->s_thread_pool.pv_thread_pool_mutex); |
4975 | 4.87k | } |
4976 | 0 | else |
4977 | 0 | { |
4978 | | /* join threads upon at end of sequence */ |
4979 | 0 | ih264e_join_threads(ps_codec); |
4980 | 0 | } |
4981 | | |
4982 | | /* collect list of memory records used by the encoder library */ |
4983 | 4.87k | memcpy(ps_ip->s_ive_ip.ps_mem_rec, ps_codec->ps_mem_rec_backup, |
4984 | 4.87k | MEM_REC_CNT * (sizeof(iv_mem_rec_t))); |
4985 | 4.87k | ps_op->s_ive_op.u4_num_mem_rec_filled = MEM_REC_CNT; |
4986 | | |
4987 | | /* clean up mutex memory */ |
4988 | 4.87k | ih264_list_free(ps_codec->pv_entropy_jobq); |
4989 | 4.87k | ih264_list_free(ps_codec->pv_proc_jobq); |
4990 | 4.87k | ithread_mutex_destroy(ps_codec->pv_ctl_mutex); |
4991 | 4.87k | ithread_mutex_destroy(ps_codec->pv_entropy_mutex); |
4992 | | |
4993 | 4.87k | ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_mv_buf_mgr); |
4994 | 4.87k | ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_ref_buf_mgr); |
4995 | 4.87k | ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_inp_buf_mgr); |
4996 | 4.87k | ih264_buf_mgr_free((buf_mgr_t *)ps_codec->pv_out_buf_mgr); |
4997 | | |
4998 | 4.87k | return IV_SUCCESS; |
4999 | 4.87k | } |
5000 | | |
5001 | | /** |
5002 | | ******************************************************************************* |
5003 | | * |
5004 | | * @brief |
5005 | | * Sets the encoder in flush mode. |
5006 | | * |
5007 | | * @par Description: |
5008 | | * Sets the encoder in flush mode |
5009 | | * |
5010 | | * @param[in] ps_codec_obj |
5011 | | * Pointer to codec object at API level |
5012 | | * |
5013 | | * @param[in] pv_api_ip |
5014 | | * Pointer to input argument structure |
5015 | | * |
5016 | | * @param[out] pv_api_op |
5017 | | * Pointer to output argument structure |
5018 | | * |
5019 | | * @returns error status |
5020 | | * |
5021 | | * @remarks This call has no real effect on encoder |
5022 | | * |
5023 | | ******************************************************************************* |
5024 | | */ |
5025 | | static WORD32 ih264e_set_flush_mode(iv_obj_t *ps_codec_obj, |
5026 | | void *pv_api_ip, |
5027 | | void *pv_api_op) |
5028 | 0 | { |
5029 | | /* codec ctxt */ |
5030 | 0 | codec_t *ps_codec = (codec_t *) ps_codec_obj->pv_codec_handle; |
5031 | | |
5032 | | /* ctrl call I/O structures */ |
5033 | 0 | ih264e_ctl_flush_op_t *ps_ctl_op = pv_api_op; |
5034 | |
|
5035 | 0 | UNUSED(pv_api_ip); |
5036 | |
|
5037 | 0 | ps_ctl_op->s_ive_op.u4_error_code = 0; |
5038 | | |
5039 | | /* signal flush frame control call */ |
5040 | 0 | ps_codec->i4_flush_mode = 1; |
5041 | |
|
5042 | 0 | return IV_SUCCESS; |
5043 | 0 | } |
5044 | | |
5045 | | /** |
5046 | | ******************************************************************************* |
5047 | | * |
5048 | | * @brief |
5049 | | * Gets encoder buffer requirements |
5050 | | * |
5051 | | * @par Description: |
5052 | | * Gets the encoder buffer requirements. Basing on max width and max height |
5053 | | * configuration settings, this routine, computes the sizes of necessary input, |
5054 | | * output buffers returns this info to callee. |
5055 | | * |
5056 | | * @param[in] ps_codec_obj |
5057 | | * Pointer to codec object at API level |
5058 | | * |
5059 | | * @param[in] pv_api_ip |
5060 | | * Pointer to input argument structure |
5061 | | * |
5062 | | * @param[out] pv_api_op |
5063 | | * Pointer to output argument structure |
5064 | | * |
5065 | | * @returns error status |
5066 | | * |
5067 | | * @remarks none |
5068 | | * |
5069 | | ******************************************************************************* |
5070 | | */ |
5071 | | static WORD32 ih264e_get_buf_info(iv_obj_t *ps_codec_obj, |
5072 | | void *pv_api_ip, |
5073 | | void *pv_api_op) |
5074 | 4.81k | { |
5075 | | /* ctrl call I/O structures */ |
5076 | 4.81k | ih264e_ctl_getbufinfo_ip_t *ps_ip = pv_api_ip; |
5077 | 4.81k | ih264e_ctl_getbufinfo_op_t *ps_op = pv_api_op; |
5078 | | |
5079 | | /* temp var */ |
5080 | 4.81k | WORD32 wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd); |
5081 | 4.81k | WORD32 ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht); |
5082 | 4.81k | WORD32 i; |
5083 | | |
5084 | 4.81k | UNUSED(ps_codec_obj); |
5085 | | |
5086 | 4.81k | ps_op->s_ive_op.u4_error_code = 0; |
5087 | | |
5088 | | /* Number of components in input buffers required for codec & |
5089 | | * Minimum sizes of each component in input buffer required */ |
5090 | 4.81k | if (ps_ip->s_ive_ip.e_inp_color_fmt == IV_YUV_420P) |
5091 | 2.04k | { |
5092 | 2.04k | ps_op->s_ive_op.u4_inp_comp_cnt = MIN_RAW_BUFS_420_COMP; |
5093 | | |
5094 | 2.04k | ps_op->s_ive_op.au4_min_in_buf_size[0] = wd * ht; |
5095 | 2.04k | ps_op->s_ive_op.au4_min_in_buf_size[1] = (wd >> 1) * (ht >> 1); |
5096 | 2.04k | ps_op->s_ive_op.au4_min_in_buf_size[2] = (wd >> 1) * (ht >> 1); |
5097 | 2.04k | } |
5098 | 2.76k | else if (ps_ip->s_ive_ip.e_inp_color_fmt == IV_YUV_422ILE) |
5099 | 660 | { |
5100 | 660 | ps_op->s_ive_op.u4_inp_comp_cnt = MIN_RAW_BUFS_422ILE_COMP; |
5101 | | |
5102 | 660 | ps_op->s_ive_op.au4_min_in_buf_size[0] = wd * ht * 2; |
5103 | 660 | ps_op->s_ive_op.au4_min_in_buf_size[1] = |
5104 | 660 | ps_op->s_ive_op.au4_min_in_buf_size[2] = 0; |
5105 | 660 | } |
5106 | 2.10k | else if (ps_ip->s_ive_ip.e_inp_color_fmt == IV_RGB_565) |
5107 | 0 | { |
5108 | 0 | ps_op->s_ive_op.u4_inp_comp_cnt = MIN_RAW_BUFS_RGB565_COMP; |
5109 | |
|
5110 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[0] = wd * ht * 2; |
5111 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[1] = |
5112 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[2] = 0; |
5113 | 0 | } |
5114 | 2.10k | else if (ps_ip->s_ive_ip.e_inp_color_fmt == IV_RGBA_8888) |
5115 | 0 | { |
5116 | 0 | ps_op->s_ive_op.u4_inp_comp_cnt = MIN_RAW_BUFS_RGBA8888_COMP; |
5117 | |
|
5118 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[0] = wd * ht * 4; |
5119 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[1] = |
5120 | 0 | ps_op->s_ive_op.au4_min_in_buf_size[2] = 0; |
5121 | 0 | } |
5122 | 2.10k | else if ((ps_ip->s_ive_ip.e_inp_color_fmt == IV_YUV_420SP_UV) |
5123 | 2.10k | || (ps_ip->s_ive_ip.e_inp_color_fmt == IV_YUV_420SP_VU)) |
5124 | 2.10k | { |
5125 | 2.10k | ps_op->s_ive_op.u4_inp_comp_cnt = MIN_RAW_BUFS_420SP_COMP; |
5126 | | |
5127 | 2.10k | ps_op->s_ive_op.au4_min_in_buf_size[0] = wd * ht; |
5128 | 2.10k | ps_op->s_ive_op.au4_min_in_buf_size[1] = wd * (ht >> 1); |
5129 | 2.10k | ps_op->s_ive_op.au4_min_in_buf_size[2] = 0; |
5130 | 2.10k | } |
5131 | | |
5132 | | /* Number of components in output buffers required for codec & |
5133 | | * Minimum sizes of each component in output buffer required */ |
5134 | 4.81k | ps_op->s_ive_op.u4_out_comp_cnt = MIN_BITS_BUFS_COMP; |
5135 | | |
5136 | 9.63k | for (i = 0; i < (WORD32) ps_op->s_ive_op.u4_out_comp_cnt; i++) |
5137 | 4.81k | { |
5138 | 4.81k | ps_op->s_ive_op.au4_min_out_buf_size[i] = MAX(((wd * ht * 3) >> 1), MIN_STREAM_SIZE); |
5139 | 4.81k | } |
5140 | | |
5141 | 4.81k | ps_op->s_ive_op.u4_min_inp_bufs = MIN_INP_BUFS; |
5142 | 4.81k | ps_op->s_ive_op.u4_min_out_bufs = MIN_OUT_BUFS; |
5143 | | |
5144 | 4.81k | return IV_SUCCESS; |
5145 | 4.81k | } |
5146 | | |
5147 | | /** |
5148 | | ******************************************************************************* |
5149 | | * |
5150 | | * @brief |
5151 | | * Sets the picture dimensions |
5152 | | * |
5153 | | * @par Description: |
5154 | | * Sets width, height, display width, display height and strides |
5155 | | * |
5156 | | * @param[in] pv_api_ip |
5157 | | * Pointer to input argument structure |
5158 | | * |
5159 | | * @param[out] pv_api_op |
5160 | | * Pointer to output argument structure |
5161 | | * |
5162 | | * @param[out] ps_cfg |
5163 | | * Pointer to config structure to be updated |
5164 | | * |
5165 | | * @returns error status |
5166 | | * |
5167 | | * @remarks none |
5168 | | * |
5169 | | ******************************************************************************* |
5170 | | */ |
5171 | | static IV_STATUS_T ih264e_set_dimensions(void *pv_api_ip, |
5172 | | void *pv_api_op, |
5173 | | cfg_params_t *ps_cfg) |
5174 | 4.73k | { |
5175 | | /* ctrl call I/O structures */ |
5176 | 4.73k | ih264e_ctl_set_dimensions_ip_t *ps_ip = pv_api_ip; |
5177 | 4.73k | ih264e_ctl_set_dimensions_op_t *ps_op = pv_api_op; |
5178 | | |
5179 | 4.73k | ps_op->s_ive_op.u4_error_code = 0; |
5180 | | |
5181 | 4.73k | ps_cfg->u4_wd = ALIGN16(ps_ip->s_ive_ip.u4_wd); |
5182 | 4.73k | ps_cfg->u4_ht = ALIGN16(ps_ip->s_ive_ip.u4_ht); |
5183 | 4.73k | ps_cfg->i4_wd_mbs = ps_cfg->u4_wd >> 4; |
5184 | 4.73k | ps_cfg->i4_ht_mbs = ps_cfg->u4_ht >> 4; |
5185 | 4.73k | ps_cfg->u4_disp_wd = ps_ip->s_ive_ip.u4_wd; |
5186 | 4.73k | ps_cfg->u4_disp_ht = ps_ip->s_ive_ip.u4_ht; |
5187 | | |
5188 | 4.73k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5189 | 4.73k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5190 | | |
5191 | 4.73k | return IV_SUCCESS; |
5192 | 4.73k | } |
5193 | | |
5194 | | /** |
5195 | | ******************************************************************************* |
5196 | | * |
5197 | | * @brief |
5198 | | * Sets source and target frame rates |
5199 | | * |
5200 | | * @par Description: |
5201 | | * Sets source and target frame rates |
5202 | | * |
5203 | | * @param[in] pv_api_ip |
5204 | | * Pointer to input argument structure |
5205 | | * |
5206 | | * @param[out] pv_api_op |
5207 | | * Pointer to output argument structure |
5208 | | * |
5209 | | * @param[out] ps_cfg |
5210 | | * Pointer to config structure to be updated |
5211 | | * |
5212 | | * @returns error status |
5213 | | * |
5214 | | * @remarks none |
5215 | | * |
5216 | | ******************************************************************************* |
5217 | | */ |
5218 | | static IV_STATUS_T ih264e_set_frame_rate(void *pv_api_ip, |
5219 | | void *pv_api_op, |
5220 | | cfg_params_t *ps_cfg) |
5221 | 2.70k | { |
5222 | | /* ctrl call I/O structures */ |
5223 | 2.70k | ih264e_ctl_set_frame_rate_ip_t *ps_ip = pv_api_ip; |
5224 | 2.70k | ih264e_ctl_set_frame_rate_op_t *ps_op = pv_api_op; |
5225 | | |
5226 | 2.70k | ps_op->s_ive_op.u4_error_code = 0; |
5227 | | |
5228 | 2.70k | ps_cfg->u4_src_frame_rate = ps_ip->s_ive_ip.u4_src_frame_rate; |
5229 | 2.70k | ps_cfg->u4_tgt_frame_rate = ps_ip->s_ive_ip.u4_tgt_frame_rate; |
5230 | | |
5231 | 2.70k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5232 | 2.70k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5233 | | |
5234 | 2.70k | return IV_SUCCESS; |
5235 | 2.70k | } |
5236 | | |
5237 | | /** |
5238 | | ******************************************************************************* |
5239 | | * |
5240 | | * @brief |
5241 | | * Sets target bit rate |
5242 | | * |
5243 | | * @par Description: |
5244 | | * Sets target bit rate |
5245 | | * |
5246 | | * @param[in] pv_api_ip |
5247 | | * Pointer to input argument structure |
5248 | | * |
5249 | | * @param[out] pv_api_op |
5250 | | * Pointer to output argument structure |
5251 | | * |
5252 | | * @param[out] ps_cfg |
5253 | | * Pointer to config structure to be updated |
5254 | | * |
5255 | | * @returns error status |
5256 | | * |
5257 | | * @remarks none |
5258 | | * |
5259 | | ******************************************************************************* |
5260 | | */ |
5261 | | static IV_STATUS_T ih264e_set_bit_rate(void *pv_api_ip, |
5262 | | void *pv_api_op, |
5263 | | cfg_params_t *ps_cfg) |
5264 | 5.44k | { |
5265 | | /* ctrl call I/O structures */ |
5266 | 5.44k | ih264e_ctl_set_bitrate_ip_t *ps_ip = pv_api_ip; |
5267 | 5.44k | ih264e_ctl_set_bitrate_op_t *ps_op = pv_api_op; |
5268 | | |
5269 | 5.44k | ps_op->s_ive_op.u4_error_code = 0; |
5270 | | |
5271 | 5.44k | ps_cfg->u4_target_bitrate = ps_ip->s_ive_ip.u4_target_bitrate; |
5272 | | |
5273 | 5.44k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5274 | 5.44k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5275 | | |
5276 | 5.44k | return IV_SUCCESS; |
5277 | 5.44k | } |
5278 | | |
5279 | | /** |
5280 | | ******************************************************************************* |
5281 | | * |
5282 | | * @brief |
5283 | | * Sets frame type |
5284 | | * |
5285 | | * @par Description: |
5286 | | * Sets frame type |
5287 | | * |
5288 | | * @param[in] pv_api_ip |
5289 | | * Pointer to input argument structure |
5290 | | * |
5291 | | * @param[out] pv_api_op |
5292 | | * Pointer to output argument structure |
5293 | | * |
5294 | | * @param[out] ps_cfg |
5295 | | * Pointer to config structure to be updated |
5296 | | * |
5297 | | * @returns error status |
5298 | | * |
5299 | | * @remarks not a sticky tag |
5300 | | * |
5301 | | ******************************************************************************* |
5302 | | */ |
5303 | | static IV_STATUS_T ih264e_set_frame_type(void *pv_api_ip, |
5304 | | void *pv_api_op, |
5305 | | cfg_params_t *ps_cfg) |
5306 | 1.00k | { |
5307 | | /* ctrl call I/O structures */ |
5308 | 1.00k | ih264e_ctl_set_frame_type_ip_t *ps_ip = pv_api_ip; |
5309 | 1.00k | ih264e_ctl_set_frame_type_op_t *ps_op = pv_api_op; |
5310 | | |
5311 | 1.00k | ps_op->s_ive_op.u4_error_code = 0; |
5312 | | |
5313 | 1.00k | ps_cfg->e_frame_type = ps_ip->s_ive_ip.e_frame_type; |
5314 | | |
5315 | 1.00k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5316 | 1.00k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5317 | | |
5318 | 1.00k | return IV_SUCCESS; |
5319 | 1.00k | } |
5320 | | |
5321 | | /** |
5322 | | ******************************************************************************* |
5323 | | * |
5324 | | * @brief |
5325 | | * Sets quantization params |
5326 | | * |
5327 | | * @par Description: |
5328 | | * Sets the max, min and default qp for I frame, P frame and B frame |
5329 | | * |
5330 | | * @param[in] pv_api_ip |
5331 | | * Pointer to input argument structure |
5332 | | * |
5333 | | * @param[out] pv_api_op |
5334 | | * Pointer to output argument structure |
5335 | | * |
5336 | | * @param[out] ps_cfg |
5337 | | * Pointer to config structure to be updated |
5338 | | * |
5339 | | * @returns error status |
5340 | | * |
5341 | | * @remarks none |
5342 | | * |
5343 | | ******************************************************************************* |
5344 | | */ |
5345 | | static IV_STATUS_T ih264e_set_qp(void *pv_api_ip, |
5346 | | void *pv_api_op, |
5347 | | cfg_params_t *ps_cfg) |
5348 | 4.87k | { |
5349 | | /* ctrl call I/O structures */ |
5350 | 4.87k | ih264e_ctl_set_qp_ip_t *ps_set_qp_ip = pv_api_ip; |
5351 | 4.87k | ih264e_ctl_set_qp_op_t *ps_set_qp_op = pv_api_op; |
5352 | | |
5353 | 4.87k | ps_set_qp_op->s_ive_op.u4_error_code = 0; |
5354 | | |
5355 | 4.87k | ps_cfg->u4_i_qp_max = ps_set_qp_ip->s_ive_ip.u4_i_qp_max; |
5356 | 4.87k | ps_cfg->u4_i_qp_min = ps_set_qp_ip->s_ive_ip.u4_i_qp_min; |
5357 | 4.87k | ps_cfg->u4_i_qp = ps_set_qp_ip->s_ive_ip.u4_i_qp; |
5358 | 4.87k | ps_cfg->u4_p_qp_max = ps_set_qp_ip->s_ive_ip.u4_p_qp_max; |
5359 | 4.87k | ps_cfg->u4_p_qp_min = ps_set_qp_ip->s_ive_ip.u4_p_qp_min; |
5360 | 4.87k | ps_cfg->u4_p_qp = ps_set_qp_ip->s_ive_ip.u4_p_qp; |
5361 | 4.87k | ps_cfg->u4_b_qp_max = ps_set_qp_ip->s_ive_ip.u4_b_qp_max; |
5362 | 4.87k | ps_cfg->u4_b_qp_min = ps_set_qp_ip->s_ive_ip.u4_b_qp_min; |
5363 | 4.87k | ps_cfg->u4_b_qp = ps_set_qp_ip->s_ive_ip.u4_b_qp; |
5364 | | |
5365 | 4.87k | ps_cfg->u4_timestamp_high = ps_set_qp_ip->s_ive_ip.u4_timestamp_high; |
5366 | 4.87k | ps_cfg->u4_timestamp_low = ps_set_qp_ip->s_ive_ip.u4_timestamp_low; |
5367 | | |
5368 | 4.87k | return IV_SUCCESS; |
5369 | 4.87k | } |
5370 | | |
5371 | | /** |
5372 | | ******************************************************************************* |
5373 | | * |
5374 | | * @brief |
5375 | | * Sets encoding mode |
5376 | | * |
5377 | | * @par Description: |
5378 | | * Sets encoding mode |
5379 | | * |
5380 | | * @param[in] pv_api_ip |
5381 | | * Pointer to input argument structure |
5382 | | * |
5383 | | * @param[out] pv_api_op |
5384 | | * Pointer to output argument structure |
5385 | | * |
5386 | | * @param[out] ps_cfg |
5387 | | * Pointer to config structure to be updated |
5388 | | * |
5389 | | * @returns error status |
5390 | | * |
5391 | | * @remarks none |
5392 | | * |
5393 | | ******************************************************************************* |
5394 | | */ |
5395 | | static IV_STATUS_T ih264e_set_enc_mode(void *pv_api_ip, |
5396 | | void *pv_api_op, |
5397 | | cfg_params_t *ps_cfg) |
5398 | 4.87k | { |
5399 | | /* ctrl call I/O structures */ |
5400 | 4.87k | ih264e_ctl_set_enc_mode_ip_t *ps_ip = pv_api_ip; |
5401 | 4.87k | ih264e_ctl_set_enc_mode_op_t *ps_op = pv_api_op; |
5402 | | |
5403 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
5404 | | |
5405 | 4.87k | ps_cfg->e_enc_mode = ps_ip->s_ive_ip.e_enc_mode; |
5406 | | |
5407 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5408 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5409 | | |
5410 | 4.87k | return IV_SUCCESS; |
5411 | 4.87k | } |
5412 | | |
5413 | | /** |
5414 | | ******************************************************************************* |
5415 | | * |
5416 | | * @brief |
5417 | | * Sets vbv parameters |
5418 | | * |
5419 | | * @par Description: |
5420 | | * Sets vbv parameters |
5421 | | * |
5422 | | * @param[in] pv_api_ip |
5423 | | * Pointer to input argument structure |
5424 | | * |
5425 | | * @param[out] pv_api_op |
5426 | | * Pointer to output argument structure |
5427 | | * |
5428 | | * @param[out] ps_cfg |
5429 | | * Pointer to config structure to be updated |
5430 | | * |
5431 | | * @returns error status |
5432 | | * |
5433 | | * @remarks none |
5434 | | * |
5435 | | ******************************************************************************* |
5436 | | */ |
5437 | | static IV_STATUS_T ih264e_set_vbv_params(void *pv_api_ip, |
5438 | | void *pv_api_op, |
5439 | | cfg_params_t *ps_cfg) |
5440 | 4.87k | { |
5441 | | /* ctrl call I/O structures */ |
5442 | 4.87k | ih264e_ctl_set_vbv_params_ip_t *ps_ip = pv_api_ip; |
5443 | 4.87k | ih264e_ctl_set_vbv_params_op_t *ps_op = pv_api_op; |
5444 | | |
5445 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
5446 | | |
5447 | 4.87k | ps_cfg->u4_vbv_buf_size = ps_ip->s_ive_ip.u4_vbv_buf_size; |
5448 | 4.87k | ps_cfg->u4_vbv_buffer_delay = ps_ip->s_ive_ip.u4_vbv_buffer_delay; |
5449 | | |
5450 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5451 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5452 | | |
5453 | 4.87k | return IV_SUCCESS; |
5454 | 4.87k | } |
5455 | | |
5456 | | /** |
5457 | | ******************************************************************************* |
5458 | | * |
5459 | | * @brief |
5460 | | * Sets AIR parameters |
5461 | | * |
5462 | | * @par Description: |
5463 | | * Sets AIR parameters |
5464 | | * |
5465 | | * @param[in] pv_api_ip |
5466 | | * Pointer to input argument structure |
5467 | | * |
5468 | | * @param[out] pv_api_op |
5469 | | * Pointer to output argument structure |
5470 | | * |
5471 | | * @param[out] ps_cfg |
5472 | | * Pointer to config structure to be updated |
5473 | | * |
5474 | | * @returns error status |
5475 | | * |
5476 | | * @remarks none |
5477 | | * |
5478 | | ******************************************************************************* |
5479 | | */ |
5480 | | static IV_STATUS_T ih264_set_air_params(void *pv_api_ip, |
5481 | | void *pv_api_op, |
5482 | | cfg_params_t *ps_cfg) |
5483 | 4.87k | { |
5484 | | /* ctrl call I/O structures */ |
5485 | 4.87k | ih264e_ctl_set_air_params_ip_t *ps_ip = pv_api_ip; |
5486 | 4.87k | ih264e_ctl_set_air_params_op_t *ps_op = pv_api_op; |
5487 | | |
5488 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
5489 | | |
5490 | 4.87k | ps_cfg->e_air_mode = ps_ip->s_ive_ip.e_air_mode; |
5491 | 4.87k | ps_cfg->u4_air_refresh_period = ps_ip->s_ive_ip.u4_air_refresh_period; |
5492 | | |
5493 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5494 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5495 | | |
5496 | 4.87k | return IV_SUCCESS; |
5497 | 4.87k | } |
5498 | | |
5499 | | /** |
5500 | | ******************************************************************************* |
5501 | | * |
5502 | | * @brief |
5503 | | * Sets motion estimation parameters |
5504 | | * |
5505 | | * @par Description: |
5506 | | * Sets motion estimation parameters |
5507 | | * |
5508 | | * @param[in] pv_api_ip |
5509 | | * Pointer to input argument structure |
5510 | | * |
5511 | | * @param[out] pv_api_op |
5512 | | * Pointer to output argument structure |
5513 | | * |
5514 | | * @param[out] ps_cfg |
5515 | | * Pointer to config structure to be updated |
5516 | | * |
5517 | | * @returns error status |
5518 | | * |
5519 | | * @remarks none |
5520 | | * |
5521 | | ******************************************************************************* |
5522 | | */ |
5523 | | static IV_STATUS_T ih264_set_me_params(void *pv_api_ip, |
5524 | | void *pv_api_op, |
5525 | | cfg_params_t *ps_cfg) |
5526 | 1.35k | { |
5527 | | /* ctrl call I/O structures */ |
5528 | 1.35k | ih264e_ctl_set_me_params_ip_t *ps_ip = pv_api_ip; |
5529 | 1.35k | ih264e_ctl_set_me_params_op_t *ps_op = pv_api_op; |
5530 | | |
5531 | 1.35k | ps_op->s_ive_op.u4_error_code = 0; |
5532 | | |
5533 | 1.35k | ps_cfg->u4_enable_hpel = ps_ip->s_ive_ip.u4_enable_hpel; |
5534 | 1.35k | ps_cfg->u4_enable_qpel = ps_ip->s_ive_ip.u4_enable_qpel; |
5535 | 1.35k | ps_cfg->u4_enable_fast_sad = ps_ip->s_ive_ip.u4_enable_fast_sad; |
5536 | 1.35k | ps_cfg->u4_enable_alt_ref = ps_ip->s_ive_ip.u4_enable_alt_ref; |
5537 | 1.35k | ps_cfg->u4_srch_rng_x = ps_ip->s_ive_ip.u4_srch_rng_x; |
5538 | 1.35k | ps_cfg->u4_srch_rng_y = ps_ip->s_ive_ip.u4_srch_rng_y; |
5539 | 1.35k | ps_cfg->u4_me_speed_preset = ps_ip->s_ive_ip.u4_me_speed_preset; |
5540 | | |
5541 | 1.35k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5542 | 1.35k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5543 | | |
5544 | 1.35k | return IV_SUCCESS; |
5545 | 1.35k | } |
5546 | | |
5547 | | /** |
5548 | | ******************************************************************************* |
5549 | | * |
5550 | | * @brief |
5551 | | * Sets Intra/Inter Prediction estimation parameters |
5552 | | * |
5553 | | * @par Description: |
5554 | | * Sets Intra/Inter Prediction estimation parameters |
5555 | | * |
5556 | | * @param[in] pv_api_ip |
5557 | | * Pointer to input argument structure |
5558 | | * |
5559 | | * @param[out] pv_api_op |
5560 | | * Pointer to output argument structure |
5561 | | * |
5562 | | * @param[out] ps_cfg |
5563 | | * Pointer to config structure to be updated |
5564 | | * |
5565 | | * @returns error status |
5566 | | * |
5567 | | * @remarks none |
5568 | | * |
5569 | | ******************************************************************************* |
5570 | | */ |
5571 | | static IV_STATUS_T ih264_set_ipe_params(void *pv_api_ip, |
5572 | | void *pv_api_op, |
5573 | | cfg_params_t *ps_cfg) |
5574 | 4.87k | { |
5575 | | /* ctrl call I/O structures */ |
5576 | 4.87k | ih264e_ctl_set_ipe_params_ip_t *ps_ip = pv_api_ip; |
5577 | 4.87k | ih264e_ctl_set_ipe_params_op_t *ps_op = pv_api_op; |
5578 | | |
5579 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
5580 | | |
5581 | 4.87k | ps_cfg->u4_enable_intra_4x4 = ps_ip->s_ive_ip.u4_enable_intra_4x4; |
5582 | 4.87k | ps_cfg->u4_enc_speed_preset = ps_ip->s_ive_ip.u4_enc_speed_preset; |
5583 | 4.87k | ps_cfg->u4_constrained_intra_pred = ps_ip->s_ive_ip.u4_constrained_intra_pred; |
5584 | | |
5585 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5586 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5587 | | |
5588 | 4.87k | return IV_SUCCESS; |
5589 | 4.87k | } |
5590 | | |
5591 | | /** |
5592 | | ******************************************************************************* |
5593 | | * |
5594 | | * @brief |
5595 | | * Sets GOP parameters |
5596 | | * |
5597 | | * @par Description: |
5598 | | * Sets GOP parameters |
5599 | | * |
5600 | | * @param[in] pv_api_ip |
5601 | | * Pointer to input argument structure |
5602 | | * |
5603 | | * @param[out] pv_api_op |
5604 | | * Pointer to output argument structure |
5605 | | * |
5606 | | * @param[out] ps_cfg |
5607 | | * Pointer to config structure to be updated |
5608 | | * |
5609 | | * @returns error status |
5610 | | * |
5611 | | * @remarks none |
5612 | | * |
5613 | | ******************************************************************************* |
5614 | | */ |
5615 | | static IV_STATUS_T ih264_set_gop_params(void *pv_api_ip, |
5616 | | void *pv_api_op, |
5617 | | cfg_params_t *ps_cfg) |
5618 | 3.92k | { |
5619 | | /* ctrl call I/O structures */ |
5620 | 3.92k | ih264e_ctl_set_gop_params_ip_t *ps_ip = pv_api_ip; |
5621 | 3.92k | ih264e_ctl_set_gop_params_op_t *ps_op = pv_api_op; |
5622 | | |
5623 | 3.92k | ps_op->s_ive_op.u4_error_code = 0; |
5624 | | |
5625 | 3.92k | ps_cfg->u4_i_frm_interval = ps_ip->s_ive_ip.u4_i_frm_interval; |
5626 | 3.92k | ps_cfg->u4_idr_frm_interval = ps_ip->s_ive_ip.u4_idr_frm_interval; |
5627 | 3.92k | if (ps_cfg->u4_idr_frm_interval < ps_cfg->u4_i_frm_interval) |
5628 | 1.57k | ps_cfg->u4_i_frm_interval = ps_cfg->u4_idr_frm_interval; |
5629 | | |
5630 | 3.92k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5631 | 3.92k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5632 | | |
5633 | 3.92k | return IV_SUCCESS; |
5634 | 3.92k | } |
5635 | | |
5636 | | /** |
5637 | | ******************************************************************************* |
5638 | | * |
5639 | | * @brief |
5640 | | * Sets profile parameters |
5641 | | * |
5642 | | * @par Description: |
5643 | | * Sets profile parameters |
5644 | | * |
5645 | | * @param[in] pv_api_ip |
5646 | | * Pointer to input argument structure |
5647 | | * |
5648 | | * @param[out] pv_api_op |
5649 | | * Pointer to output argument structure |
5650 | | * |
5651 | | * @param[out] ps_cfg |
5652 | | * Pointer to config structure to be updated |
5653 | | * |
5654 | | * @returns error status |
5655 | | * |
5656 | | * @remarks none |
5657 | | * |
5658 | | ******************************************************************************* |
5659 | | */ |
5660 | | static IV_STATUS_T ih264_set_profile_params(void *pv_api_ip, |
5661 | | void *pv_api_op, |
5662 | | cfg_params_t *ps_cfg) |
5663 | 4.87k | { |
5664 | | /* ctrl call I/O structures */ |
5665 | 4.87k | ih264e_ctl_set_profile_params_ip_t *ps_ip = pv_api_ip; |
5666 | 4.87k | ih264e_ctl_set_profile_params_op_t *ps_op = pv_api_op; |
5667 | | |
5668 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
5669 | | |
5670 | 4.87k | ps_cfg->e_profile = ps_ip->s_ive_ip.e_profile; |
5671 | 4.87k | ps_cfg->u4_entropy_coding_mode = ps_ip->s_ive_ip.u4_entropy_coding_mode; |
5672 | | |
5673 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5674 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5675 | | |
5676 | 4.87k | return IV_SUCCESS; |
5677 | 4.87k | } |
5678 | | |
5679 | | /** |
5680 | | ******************************************************************************* |
5681 | | * |
5682 | | * @brief |
5683 | | * Sets disable deblock level |
5684 | | * |
5685 | | * @par Description: |
5686 | | * Sets disable deblock level. Level 0 means no disabling and level 4 means |
5687 | | * disable completely. 1, 2, 3 are intermediate levels that control amount |
5688 | | * of deblocking done. |
5689 | | * |
5690 | | * @param[in] ps_codec_obj |
5691 | | * Pointer to codec object at API level |
5692 | | * |
5693 | | * @param[in] pv_api_ip |
5694 | | * Pointer to input argument structure |
5695 | | * |
5696 | | * @param[out] pv_api_op |
5697 | | * Pointer to output argument structure |
5698 | | * |
5699 | | * @returns error status |
5700 | | * |
5701 | | * @remarks none |
5702 | | * |
5703 | | ******************************************************************************* |
5704 | | */ |
5705 | | static WORD32 ih264_set_deblock_params(void *pv_api_ip, |
5706 | | void *pv_api_op, |
5707 | | cfg_params_t *ps_cfg) |
5708 | 4.02k | { |
5709 | | /* ctrl call I/O structures */ |
5710 | 4.02k | ih264e_ctl_set_deblock_params_ip_t *ps_ip = pv_api_ip; |
5711 | 4.02k | ih264e_ctl_set_deblock_params_op_t *ps_op = pv_api_op; |
5712 | | |
5713 | 4.02k | ps_op->s_ive_op.u4_error_code = 0; |
5714 | | |
5715 | 4.02k | ps_cfg->u4_disable_deblock_level = ps_ip->s_ive_ip.u4_disable_deblock_level; |
5716 | | |
5717 | 4.02k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
5718 | 4.02k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
5719 | | |
5720 | 4.02k | return IV_SUCCESS; |
5721 | 4.02k | } |
5722 | | /** |
5723 | | ******************************************************************************* |
5724 | | * |
5725 | | * @brief |
5726 | | * Sets vui params |
5727 | | * |
5728 | | * @par Description: |
5729 | | * Video usability information |
5730 | | * |
5731 | | * @param[in] pv_api_ip |
5732 | | * Pointer to input argument structure |
5733 | | * |
5734 | | * @param[out] pv_api_op |
5735 | | * Pointer to output argument structure |
5736 | | * |
5737 | | * @param[out] ps_cfg |
5738 | | * Pointer to config structure to be updated |
5739 | | * |
5740 | | * @returns error status |
5741 | | * |
5742 | | * @remarks none |
5743 | | * |
5744 | | ******************************************************************************* |
5745 | | */ |
5746 | | static WORD32 ih264e_set_vui_params(void *pv_api_ip, |
5747 | | void *pv_api_op, |
5748 | | cfg_params_t *ps_cfg) |
5749 | 4.87k | { |
5750 | | /* ctrl call I/O structures */ |
5751 | 4.87k | ih264e_vui_ip_t *ps_ip = pv_api_ip; |
5752 | 4.87k | ih264e_vui_op_t *ps_op = pv_api_op; |
5753 | 4.87k | vui_t *ps_vui = &ps_cfg->s_vui; |
5754 | | |
5755 | 4.87k | ps_op->u4_error_code = 0; |
5756 | | |
5757 | 4.87k | ps_vui->u1_aspect_ratio_info_present_flag = ps_ip->u1_aspect_ratio_info_present_flag; |
5758 | 4.87k | ps_vui->u1_aspect_ratio_idc = ps_ip->u1_aspect_ratio_idc; |
5759 | 4.87k | ps_vui->u2_sar_width = ps_ip->u2_sar_width; |
5760 | 4.87k | ps_vui->u2_sar_height = ps_ip->u2_sar_height; |
5761 | 4.87k | ps_vui->u1_overscan_info_present_flag = ps_ip->u1_overscan_info_present_flag; |
5762 | 4.87k | ps_vui->u1_overscan_appropriate_flag = ps_ip->u1_overscan_appropriate_flag; |
5763 | 4.87k | ps_vui->u1_video_signal_type_present_flag = ps_ip->u1_video_signal_type_present_flag; |
5764 | 4.87k | ps_vui->u1_video_format = ps_ip->u1_video_format; |
5765 | 4.87k | ps_vui->u1_video_full_range_flag = ps_ip->u1_video_full_range_flag; |
5766 | 4.87k | ps_vui->u1_colour_description_present_flag = ps_ip->u1_colour_description_present_flag; |
5767 | 4.87k | ps_vui->u1_colour_primaries = ps_ip->u1_colour_primaries; |
5768 | 4.87k | ps_vui->u1_transfer_characteristics = ps_ip->u1_transfer_characteristics; |
5769 | 4.87k | ps_vui->u1_matrix_coefficients = ps_ip->u1_matrix_coefficients; |
5770 | 4.87k | ps_vui->u1_chroma_loc_info_present_flag = ps_ip->u1_chroma_loc_info_present_flag; |
5771 | 4.87k | ps_vui->u1_chroma_sample_loc_type_top_field = ps_ip->u1_chroma_sample_loc_type_top_field; |
5772 | 4.87k | ps_vui->u1_chroma_sample_loc_type_bottom_field = ps_ip->u1_chroma_sample_loc_type_bottom_field; |
5773 | 4.87k | ps_vui->u1_vui_timing_info_present_flag = ps_ip->u1_vui_timing_info_present_flag; |
5774 | 4.87k | ps_vui->u4_vui_num_units_in_tick = ps_ip->u4_vui_num_units_in_tick; |
5775 | 4.87k | ps_vui->u4_vui_time_scale = ps_ip->u4_vui_time_scale; |
5776 | 4.87k | ps_vui->u1_fixed_frame_rate_flag = ps_ip->u1_fixed_frame_rate_flag; |
5777 | 4.87k | ps_vui->u1_nal_hrd_parameters_present_flag = ps_ip->u1_nal_hrd_parameters_present_flag; |
5778 | 4.87k | ps_vui->u1_vcl_hrd_parameters_present_flag = ps_ip->u1_vcl_hrd_parameters_present_flag; |
5779 | 4.87k | ps_vui->u1_low_delay_hrd_flag = ps_ip->u1_low_delay_hrd_flag; |
5780 | 4.87k | ps_vui->u1_pic_struct_present_flag = ps_ip->u1_pic_struct_present_flag; |
5781 | 4.87k | ps_vui->u1_bitstream_restriction_flag = ps_ip->u1_bitstream_restriction_flag; |
5782 | 4.87k | ps_vui->u1_motion_vectors_over_pic_boundaries_flag = ps_ip->u1_motion_vectors_over_pic_boundaries_flag; |
5783 | 4.87k | ps_vui->u1_max_bytes_per_pic_denom = ps_ip->u1_max_bytes_per_pic_denom; |
5784 | 4.87k | ps_vui->u1_max_bits_per_mb_denom = ps_ip->u1_max_bits_per_mb_denom; |
5785 | 4.87k | ps_vui->u1_log2_max_mv_length_horizontal = ps_ip->u1_log2_max_mv_length_horizontal; |
5786 | 4.87k | ps_vui->u1_log2_max_mv_length_vertical = ps_ip->u1_log2_max_mv_length_vertical; |
5787 | 4.87k | ps_vui->u1_num_reorder_frames = ps_ip->u1_num_reorder_frames; |
5788 | 4.87k | ps_vui->u1_max_dec_frame_buffering = ps_ip->u1_max_dec_frame_buffering; |
5789 | | |
5790 | 4.87k | ps_cfg->u4_timestamp_high = -1; |
5791 | 4.87k | ps_cfg->u4_timestamp_low = -1; |
5792 | | |
5793 | 4.87k | return IV_SUCCESS; |
5794 | 4.87k | } |
5795 | | |
5796 | | /** |
5797 | | ******************************************************************************* |
5798 | | * |
5799 | | * @brief |
5800 | | * Sets Mastering display color volume sei params |
5801 | | * |
5802 | | * @par Description: |
5803 | | * Supplemental enhancement information |
5804 | | * |
5805 | | * @param[in] pv_api_ip |
5806 | | * Pointer to input argument structure |
5807 | | * |
5808 | | * @param[out] pv_api_op |
5809 | | * Pointer to output argument structure |
5810 | | * |
5811 | | * @param[out] ps_cfg |
5812 | | * Pointer to config structure to be updated |
5813 | | * |
5814 | | * @return error status |
5815 | | * |
5816 | | * @remarks none |
5817 | | * |
5818 | | ******************************************************************************* |
5819 | | */ |
5820 | | static WORD32 ih264e_set_sei_mdcv_params(void *pv_api_ip, |
5821 | | void *pv_api_op, |
5822 | | cfg_params_t *ps_cfg) |
5823 | 4.87k | { |
5824 | 4.87k | WORD32 i4_count; |
5825 | | /* ctrl call I/O structures */ |
5826 | 4.87k | ih264e_ctl_set_sei_mdcv_params_ip_t *ps_ip = pv_api_ip; |
5827 | 4.87k | ih264e_ctl_set_sei_mdcv_params_op_t *ps_op = pv_api_op; |
5828 | 4.87k | sei_params_t *ps_sei = &ps_cfg->s_sei; |
5829 | | |
5830 | 4.87k | ps_op->u4_error_code = 0; |
5831 | | |
5832 | 4.87k | ps_sei->u1_sei_mdcv_params_present_flag = ps_ip->u1_sei_mdcv_params_present_flag; |
5833 | 19.5k | for(i4_count = 0; i4_count < NUM_SEI_MDCV_PRIMARIES; i4_count++) |
5834 | 14.6k | { |
5835 | 14.6k | ps_sei->s_sei_mdcv_params.au2_display_primaries_x[i4_count] = |
5836 | 14.6k | ps_ip->au2_display_primaries_x[i4_count]; |
5837 | 14.6k | ps_sei->s_sei_mdcv_params.au2_display_primaries_y[i4_count] = |
5838 | 14.6k | ps_ip->au2_display_primaries_y[i4_count]; |
5839 | 14.6k | } |
5840 | | |
5841 | 4.87k | ps_sei->s_sei_mdcv_params.u2_white_point_x = ps_ip->u2_white_point_x; |
5842 | 4.87k | ps_sei->s_sei_mdcv_params.u2_white_point_y = ps_ip->u2_white_point_y; |
5843 | 4.87k | ps_sei->s_sei_mdcv_params.u4_max_display_mastering_luminance = |
5844 | 4.87k | ps_ip->u4_max_display_mastering_luminance; |
5845 | 4.87k | ps_sei->s_sei_mdcv_params.u4_min_display_mastering_luminance = |
5846 | 4.87k | ps_ip->u4_min_display_mastering_luminance; |
5847 | | |
5848 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->u4_timestamp_high; |
5849 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->u4_timestamp_low; |
5850 | | |
5851 | 4.87k | return IV_SUCCESS; |
5852 | 4.87k | } |
5853 | | |
5854 | | /** |
5855 | | ******************************************************************************* |
5856 | | * |
5857 | | * @brief |
5858 | | * Sets content light level sei params |
5859 | | * |
5860 | | * @par Description: |
5861 | | * Supplemental enhancement information |
5862 | | * |
5863 | | * @param[in] pv_api_ip |
5864 | | * Pointer to input argument structure |
5865 | | * |
5866 | | * @param[out] pv_api_op |
5867 | | * Pointer to output argument structure |
5868 | | * |
5869 | | * @param[out] ps_cfg |
5870 | | * Pointer to config structure to be updated |
5871 | | * |
5872 | | * @return error status |
5873 | | * |
5874 | | * @remarks none |
5875 | | * |
5876 | | ******************************************************************************* |
5877 | | */ |
5878 | | static WORD32 ih264e_set_sei_cll_params(void *pv_api_ip, |
5879 | | void *pv_api_op, |
5880 | | cfg_params_t *ps_cfg) |
5881 | 4.87k | { |
5882 | | /* ctrl call I/O structures */ |
5883 | 4.87k | ih264e_ctl_set_sei_cll_params_ip_t *ps_ip = pv_api_ip; |
5884 | 4.87k | ih264e_ctl_set_sei_cll_params_op_t *ps_op = pv_api_op; |
5885 | 4.87k | sei_params_t *ps_sei = &ps_cfg->s_sei; |
5886 | | |
5887 | 4.87k | ps_op->u4_error_code = 0; |
5888 | | |
5889 | 4.87k | ps_sei->u1_sei_cll_params_present_flag = ps_ip->u1_sei_cll_params_present_flag; |
5890 | | |
5891 | 4.87k | ps_sei->s_sei_cll_params.u2_max_content_light_level = ps_ip->u2_max_content_light_level; |
5892 | 4.87k | ps_sei->s_sei_cll_params.u2_max_pic_average_light_level = |
5893 | 4.87k | ps_ip->u2_max_pic_average_light_level; |
5894 | | |
5895 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->u4_timestamp_high; |
5896 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->u4_timestamp_low; |
5897 | | |
5898 | 4.87k | return IV_SUCCESS; |
5899 | 4.87k | } |
5900 | | |
5901 | | /** |
5902 | | ******************************************************************************* |
5903 | | * |
5904 | | * @brief |
5905 | | * Sets ambient viewing environment sei params |
5906 | | * |
5907 | | * @par Description: |
5908 | | * Supplemental enhancement information |
5909 | | * |
5910 | | * @param[in] pv_api_ip |
5911 | | * Pointer to input argument structure |
5912 | | * |
5913 | | * @param[out] pv_api_op |
5914 | | * Pointer to output argument structure |
5915 | | * |
5916 | | * @param[out] ps_cfg |
5917 | | * Pointer to config structure to be updated |
5918 | | * |
5919 | | * @return error status |
5920 | | * |
5921 | | * @remarks none |
5922 | | * |
5923 | | ******************************************************************************* |
5924 | | */ |
5925 | | static WORD32 ih264e_set_sei_ave_params(void *pv_api_ip, |
5926 | | void *pv_api_op, |
5927 | | cfg_params_t *ps_cfg) |
5928 | 4.87k | { |
5929 | | /* ctrl call I/O structures */ |
5930 | 4.87k | ih264e_ctl_set_sei_ave_params_ip_t *ps_ip = pv_api_ip; |
5931 | 4.87k | ih264e_ctl_set_sei_ave_params_op_t *ps_op = pv_api_op; |
5932 | 4.87k | sei_params_t *ps_sei = &ps_cfg->s_sei; |
5933 | | |
5934 | 4.87k | ps_op->u4_error_code = 0; |
5935 | | |
5936 | 4.87k | ps_sei->u1_sei_ave_params_present_flag = ps_ip->u1_sei_ave_params_present_flag; |
5937 | | |
5938 | 4.87k | ps_sei->s_sei_ave_params.u4_ambient_illuminance = ps_ip->u4_ambient_illuminance; |
5939 | 4.87k | ps_sei->s_sei_ave_params.u2_ambient_light_x = ps_ip->u2_ambient_light_x; |
5940 | 4.87k | ps_sei->s_sei_ave_params.u2_ambient_light_y = ps_ip->u2_ambient_light_y; |
5941 | | |
5942 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->u4_timestamp_high; |
5943 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->u4_timestamp_low; |
5944 | | |
5945 | 4.87k | return IV_SUCCESS; |
5946 | 4.87k | } |
5947 | | |
5948 | | /** |
5949 | | ******************************************************************************* |
5950 | | * |
5951 | | * @brief |
5952 | | * Sets content color volume sei params |
5953 | | * |
5954 | | * @par Description: |
5955 | | * Supplemental enhancement information |
5956 | | * |
5957 | | * @param[in] pv_api_ip |
5958 | | * Pointer to input argument structure |
5959 | | * |
5960 | | * @param[out] pv_api_op |
5961 | | * Pointer to output argument structure |
5962 | | * |
5963 | | * @param[out] ps_cfg |
5964 | | * Pointer to config structure to be updated |
5965 | | * |
5966 | | * @return error status |
5967 | | * |
5968 | | * @remarks none |
5969 | | * |
5970 | | ******************************************************************************* |
5971 | | */ |
5972 | | static WORD32 ih264e_set_sei_ccv_params(void *pv_api_ip, |
5973 | | void *pv_api_op, |
5974 | | cfg_params_t *ps_cfg) |
5975 | 4.87k | { |
5976 | 4.87k | WORD32 i4_count; |
5977 | | /* ctrl call I/O structures */ |
5978 | 4.87k | ih264e_ctl_set_sei_ccv_params_ip_t *ps_ip = pv_api_ip; |
5979 | 4.87k | ih264e_ctl_set_sei_ccv_params_op_t *ps_op = pv_api_op; |
5980 | 4.87k | sei_params_t *ps_sei = &ps_cfg->s_sei; |
5981 | | |
5982 | 4.87k | ps_op->u4_error_code = 0; |
5983 | | |
5984 | 4.87k | ps_sei->u1_sei_ccv_params_present_flag = ps_ip->u1_sei_ccv_params_present_flag; |
5985 | | |
5986 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_cancel_flag = ps_ip->u1_ccv_cancel_flag; |
5987 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_persistence_flag = ps_ip->u1_ccv_persistence_flag; |
5988 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_primaries_present_flag = |
5989 | 4.87k | ps_ip->u1_ccv_primaries_present_flag; |
5990 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_min_luminance_value_present_flag = |
5991 | 4.87k | ps_ip->u1_ccv_min_luminance_value_present_flag; |
5992 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_max_luminance_value_present_flag = |
5993 | 4.87k | ps_ip->u1_ccv_max_luminance_value_present_flag; |
5994 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_avg_luminance_value_present_flag = |
5995 | 4.87k | ps_ip->u1_ccv_avg_luminance_value_present_flag; |
5996 | 4.87k | ps_sei->s_sei_ccv_params.u1_ccv_reserved_zero_2bits = |
5997 | 4.87k | ps_ip->u1_ccv_reserved_zero_2bits; |
5998 | | |
5999 | 19.5k | for(i4_count = 0; i4_count < NUM_SEI_CCV_PRIMARIES; i4_count++) |
6000 | 14.6k | { |
6001 | 14.6k | ps_sei->s_sei_ccv_params.ai4_ccv_primaries_x[i4_count] = |
6002 | 14.6k | ps_ip->ai4_ccv_primaries_x[i4_count]; |
6003 | 14.6k | ps_sei->s_sei_ccv_params.ai4_ccv_primaries_y[i4_count] = |
6004 | 14.6k | ps_ip->ai4_ccv_primaries_y[i4_count]; |
6005 | 14.6k | } |
6006 | | |
6007 | 4.87k | ps_sei->s_sei_ccv_params.u4_ccv_min_luminance_value = ps_ip->u4_ccv_min_luminance_value; |
6008 | 4.87k | ps_sei->s_sei_ccv_params.u4_ccv_max_luminance_value = ps_ip->u4_ccv_max_luminance_value; |
6009 | 4.87k | ps_sei->s_sei_ccv_params.u4_ccv_avg_luminance_value = ps_ip->u4_ccv_avg_luminance_value; |
6010 | | |
6011 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->u4_timestamp_high; |
6012 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->u4_timestamp_low; |
6013 | | |
6014 | 4.87k | return IV_SUCCESS; |
6015 | 4.87k | } |
6016 | | |
6017 | | /** |
6018 | | ******************************************************************************* |
6019 | | * |
6020 | | * @brief |
6021 | | * Sets shutter interval info sei params |
6022 | | * |
6023 | | * @par Description: |
6024 | | * Supplemental enhancement information |
6025 | | * |
6026 | | * @param[in] pv_api_ip |
6027 | | * Pointer to input argument structure |
6028 | | * |
6029 | | * @param[out] pv_api_op |
6030 | | * Pointer to output argument structure |
6031 | | * |
6032 | | * @param[out] ps_cfg |
6033 | | * Pointer to config structure to be updated |
6034 | | * |
6035 | | * @return error status |
6036 | | * |
6037 | | * @remarks none |
6038 | | * |
6039 | | ******************************************************************************* |
6040 | | */ |
6041 | | static WORD32 ih264e_set_sei_sii_params(void *pv_api_ip, void *pv_api_op, cfg_params_t *ps_cfg) |
6042 | 4.87k | { |
6043 | | /* ctrl call I/O structures */ |
6044 | 4.87k | ih264e_ctl_set_sei_sii_params_ip_t *ps_ip = pv_api_ip; |
6045 | 4.87k | ih264e_ctl_set_sei_sii_params_op_t *ps_op = pv_api_op; |
6046 | 4.87k | sei_params_t *ps_sei = &ps_cfg->s_sei; |
6047 | | |
6048 | 4.87k | ps_op->u4_error_code = 0; |
6049 | 4.87k | ps_sei->u1_sei_sii_params_present_flag = ps_ip->u1_shutter_interval_info_present_flag; |
6050 | 4.87k | ps_sei->s_sei_sii_params.u4_sii_sub_layer_idx = ps_ip->u4_sii_sub_layer_idx; |
6051 | | |
6052 | 4.87k | if(0 == ps_sei->s_sei_sii_params.u4_sii_sub_layer_idx) |
6053 | 4.87k | { |
6054 | 4.87k | ps_sei->s_sei_sii_params.u1_shutter_interval_info_present_flag = |
6055 | 4.87k | ps_ip->u1_shutter_interval_info_present_flag; |
6056 | | |
6057 | 4.87k | if(1 == ps_sei->s_sei_sii_params.u1_shutter_interval_info_present_flag) |
6058 | 1.86k | { |
6059 | 1.86k | ps_sei->s_sei_sii_params.u4_sii_time_scale = ps_ip->u4_sii_time_scale; |
6060 | 1.86k | ps_sei->s_sei_sii_params.u1_fixed_shutter_interval_within_cvs_flag = |
6061 | 1.86k | ps_ip->u1_fixed_shutter_interval_within_cvs_flag; |
6062 | | |
6063 | 1.86k | if(1 == ps_sei->s_sei_sii_params.u1_fixed_shutter_interval_within_cvs_flag) |
6064 | 0 | { |
6065 | 0 | ps_sei->s_sei_sii_params.u4_sii_num_units_in_shutter_interval = |
6066 | 0 | ps_ip->u4_sii_num_units_in_shutter_interval; |
6067 | 0 | } |
6068 | 1.86k | else |
6069 | 1.86k | { |
6070 | 1.86k | int i; |
6071 | 1.86k | ps_sei->s_sei_sii_params.u1_sii_max_sub_layers_minus1 = |
6072 | 1.86k | ps_ip->u1_sii_max_sub_layers_minus1; |
6073 | | |
6074 | 16.7k | for(i = 0; i <= ps_ip->u1_sii_max_sub_layers_minus1; i++) |
6075 | 14.9k | { |
6076 | 14.9k | ps_sei->s_sei_sii_params.au4_sub_layer_num_units_in_shutter_interval[i] = |
6077 | 14.9k | ps_ip->au4_sub_layer_num_units_in_shutter_interval[i]; |
6078 | 14.9k | } |
6079 | 1.86k | } |
6080 | 1.86k | } |
6081 | 4.87k | } |
6082 | | |
6083 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->u4_timestamp_high; |
6084 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->u4_timestamp_low; |
6085 | | |
6086 | 4.87k | return IV_SUCCESS; |
6087 | 4.87k | } |
6088 | | |
6089 | | /** |
6090 | | ******************************************************************************* |
6091 | | * |
6092 | | * @brief |
6093 | | * Sets number of cores |
6094 | | * |
6095 | | * @par Description: |
6096 | | * Sets number of cores |
6097 | | * |
6098 | | * @param[in] ps_codec_obj |
6099 | | * Pointer to codec object at API level |
6100 | | * |
6101 | | * @param[in] pv_api_ip |
6102 | | * Pointer to input argument structure |
6103 | | * |
6104 | | * @param[out] pv_api_op |
6105 | | * Pointer to output argument structure |
6106 | | * |
6107 | | * @returns error status |
6108 | | * |
6109 | | * @remarks The number of encoder threads is limited to MAX_PROCESS_THREADS |
6110 | | * |
6111 | | ******************************************************************************* |
6112 | | */ |
6113 | | static WORD32 ih264e_set_num_cores(void *pv_api_ip, |
6114 | | void *pv_api_op, |
6115 | | cfg_params_t *ps_cfg) |
6116 | 4.87k | { |
6117 | | /* ctrl call I/O structures */ |
6118 | 4.87k | ih264e_ctl_set_num_cores_ip_t *ps_ip = pv_api_ip; |
6119 | 4.87k | ih264e_ctl_set_num_cores_op_t *ps_op = pv_api_op; |
6120 | | |
6121 | 4.87k | ps_op->s_ive_op.u4_error_code = 0; |
6122 | | |
6123 | 4.87k | ps_cfg->u4_num_cores = MIN(ps_ip->s_ive_ip.u4_num_cores, MAX_PROCESS_THREADS); |
6124 | | |
6125 | 4.87k | ps_cfg->u4_timestamp_high = ps_ip->s_ive_ip.u4_timestamp_high; |
6126 | 4.87k | ps_cfg->u4_timestamp_low = ps_ip->s_ive_ip.u4_timestamp_low; |
6127 | | |
6128 | 4.87k | return IV_SUCCESS; |
6129 | 4.87k | } |
6130 | | |
6131 | | /** |
6132 | | ******************************************************************************* |
6133 | | * |
6134 | | * @brief |
6135 | | * Resets encoder state |
6136 | | * |
6137 | | * @par Description: |
6138 | | * Resets encoder state by calling ih264e_init() |
6139 | | * |
6140 | | * @param[in] ps_codec_obj |
6141 | | * Pointer to codec object at API level |
6142 | | * |
6143 | | * @param[in] pv_api_ip |
6144 | | * Pointer to input argument structure |
6145 | | * |
6146 | | * @param[out] pv_api_op |
6147 | | * Pointer to output argument structure |
6148 | | * |
6149 | | * @returns error status |
6150 | | * |
6151 | | * @remarks none |
6152 | | * |
6153 | | ******************************************************************************* |
6154 | | */ |
6155 | | static WORD32 ih264e_reset(iv_obj_t *ps_codec_obj, |
6156 | | void *pv_api_ip, |
6157 | | void *pv_api_op) |
6158 | 0 | { |
6159 | | /* codec ctxt */ |
6160 | 0 | codec_t * ps_codec = (codec_t *) (ps_codec_obj->pv_codec_handle); |
6161 | | |
6162 | | /* ctrl call I/O structures */ |
6163 | 0 | ih264e_ctl_reset_op_t *ps_op = pv_api_op; |
6164 | |
|
6165 | 0 | UNUSED(pv_api_ip); |
6166 | |
|
6167 | 0 | ps_op->s_ive_op.u4_error_code = 0; |
6168 | |
|
6169 | 0 | if (ps_codec != NULL) |
6170 | 0 | { |
6171 | 0 | if (ps_codec->s_cfg.u4_keep_threads_active) |
6172 | 0 | { |
6173 | | /* Shutdown active threads before reinitialization */ |
6174 | 0 | ih264e_thread_pool_shutdown(ps_codec); |
6175 | 0 | } |
6176 | 0 | ih264e_init(ps_codec); |
6177 | 0 | } |
6178 | 0 | else |
6179 | 0 | { |
6180 | 0 | ps_op->s_ive_op.u4_error_code = IH264E_INIT_NOT_DONE; |
6181 | 0 | } |
6182 | |
|
6183 | 0 | return IV_SUCCESS; |
6184 | 0 | } |
6185 | | |
6186 | | /** |
6187 | | ******************************************************************************* |
6188 | | * |
6189 | | * @brief |
6190 | | * Codec control call |
6191 | | * |
6192 | | * @par Description: |
6193 | | * Codec control call which in turn calls appropriate calls based on sub-command |
6194 | | * |
6195 | | * @param[in] ps_codec_obj |
6196 | | * Pointer to codec object at API level |
6197 | | * |
6198 | | * @param[in] pv_api_ip |
6199 | | * Pointer to input argument structure |
6200 | | * |
6201 | | * @param[out] pv_api_op |
6202 | | * Pointer to output argument structure |
6203 | | * |
6204 | | * @returns error status |
6205 | | * |
6206 | | * @remarks none |
6207 | | * |
6208 | | ******************************************************************************* |
6209 | | */ |
6210 | | static WORD32 ih264e_ctl(iv_obj_t *ps_codec_obj, |
6211 | | void *pv_api_ip, |
6212 | | void *pv_api_op) |
6213 | 101k | { |
6214 | | /* codec ctxt */ |
6215 | 101k | codec_t *ps_codec = (codec_t *) ps_codec_obj->pv_codec_handle; |
6216 | | |
6217 | | /* ctrl call I/O structures */ |
6218 | 101k | ih264e_ctl_setdefault_ip_t *ps_ctl_ip = pv_api_ip; |
6219 | 101k | ih264e_ctl_setdefault_op_t *ps_ctl_op = pv_api_op; |
6220 | | |
6221 | | /* ctrl call sub cmd */ |
6222 | 101k | IVE_CONTROL_API_COMMAND_TYPE_T sub_cmd = ps_ctl_ip->s_ive_ip.e_sub_cmd; |
6223 | | |
6224 | | /* error status */ |
6225 | 101k | IV_STATUS_T ret = IV_SUCCESS; |
6226 | | |
6227 | | /* temp var */ |
6228 | 101k | WORD32 i; |
6229 | 101k | cfg_params_t *ps_cfg = NULL; |
6230 | | |
6231 | | /* control call is for configuring encoding params, this is not to be called |
6232 | | * before a successful init call */ |
6233 | 101k | if (ps_codec->i4_init_done != 1) |
6234 | 0 | { |
6235 | 0 | ps_ctl_op->s_ive_op.u4_error_code |= 1 << IVE_FATALERROR; |
6236 | 0 | ps_ctl_op->s_ive_op.u4_error_code |= IH264E_INIT_NOT_DONE; |
6237 | 0 | return IV_FAIL; |
6238 | 0 | } |
6239 | | |
6240 | | /* make it thread safe */ |
6241 | 101k | ithread_mutex_lock(ps_codec->pv_ctl_mutex); |
6242 | | |
6243 | | /* find a free config param set to hold current parameters */ |
6244 | 873k | for (i = 0; i < MAX_ACTIVE_CONFIG_PARAMS; i++) |
6245 | 873k | { |
6246 | 873k | if (0 == ps_codec->as_cfg[i].u4_is_valid) |
6247 | 101k | { |
6248 | 101k | ps_cfg = &ps_codec->as_cfg[i]; |
6249 | 101k | break; |
6250 | 101k | } |
6251 | 873k | } |
6252 | | |
6253 | | /* If all are invalid, then start overwriting from the head config params */ |
6254 | 101k | if (NULL == ps_cfg) |
6255 | 0 | { |
6256 | 0 | ps_cfg = &ps_codec->as_cfg[0]; |
6257 | 0 | } |
6258 | | |
6259 | 101k | ps_cfg->u4_is_valid = 1; |
6260 | | |
6261 | 101k | ps_cfg->e_cmd = sub_cmd; |
6262 | | |
6263 | 101k | switch (sub_cmd) |
6264 | 101k | { |
6265 | 4.73k | case IVE_CMD_CTL_SET_DIMENSIONS: |
6266 | 4.73k | ret = ih264e_set_dimensions(pv_api_ip, pv_api_op, ps_cfg); |
6267 | 4.73k | break; |
6268 | | |
6269 | 2.70k | case IVE_CMD_CTL_SET_FRAMERATE: |
6270 | 2.70k | ret = ih264e_set_frame_rate(pv_api_ip, pv_api_op, ps_cfg); |
6271 | 2.70k | break; |
6272 | | |
6273 | 5.44k | case IVE_CMD_CTL_SET_BITRATE: |
6274 | 5.44k | ret = ih264e_set_bit_rate(pv_api_ip, pv_api_op, ps_cfg); |
6275 | 5.44k | break; |
6276 | | |
6277 | 1.00k | case IVE_CMD_CTL_SET_FRAMETYPE: |
6278 | 1.00k | ret = ih264e_set_frame_type(pv_api_ip, pv_api_op, ps_cfg); |
6279 | 1.00k | break; |
6280 | | |
6281 | 4.87k | case IVE_CMD_CTL_SET_QP: |
6282 | 4.87k | ret = ih264e_set_qp(pv_api_ip, pv_api_op, ps_cfg); |
6283 | 4.87k | break; |
6284 | | |
6285 | 4.87k | case IVE_CMD_CTL_SET_ENC_MODE: |
6286 | 4.87k | ret = ih264e_set_enc_mode(pv_api_ip, pv_api_op, ps_cfg); |
6287 | 4.87k | break; |
6288 | | |
6289 | 4.87k | case IVE_CMD_CTL_SET_VBV_PARAMS: |
6290 | 4.87k | ret = ih264e_set_vbv_params(pv_api_ip, pv_api_op, ps_cfg); |
6291 | 4.87k | break; |
6292 | | |
6293 | 4.87k | case IVE_CMD_CTL_SET_AIR_PARAMS: |
6294 | 4.87k | ret = ih264_set_air_params(pv_api_ip, pv_api_op, ps_cfg); |
6295 | 4.87k | break; |
6296 | | |
6297 | 1.35k | case IVE_CMD_CTL_SET_ME_PARAMS: |
6298 | 1.35k | ret = ih264_set_me_params(pv_api_ip, pv_api_op, ps_cfg); |
6299 | 1.35k | break; |
6300 | | |
6301 | 4.87k | case IVE_CMD_CTL_SET_IPE_PARAMS: |
6302 | 4.87k | ret = ih264_set_ipe_params(pv_api_ip, pv_api_op, ps_cfg); |
6303 | 4.87k | break; |
6304 | | |
6305 | 3.92k | case IVE_CMD_CTL_SET_GOP_PARAMS: |
6306 | 3.92k | ret = ih264_set_gop_params(pv_api_ip, pv_api_op, ps_cfg); |
6307 | 3.92k | break; |
6308 | | |
6309 | 4.87k | case IVE_CMD_CTL_SET_PROFILE_PARAMS: |
6310 | 4.87k | ret = ih264_set_profile_params(pv_api_ip, pv_api_op, ps_cfg); |
6311 | 4.87k | break; |
6312 | | |
6313 | 4.02k | case IVE_CMD_CTL_SET_DEBLOCK_PARAMS: |
6314 | 4.02k | ret = ih264_set_deblock_params(pv_api_ip, pv_api_op, ps_cfg); |
6315 | 4.02k | break; |
6316 | | |
6317 | 4.87k | case IVE_CMD_CTL_SET_VUI_PARAMS: |
6318 | 4.87k | ret = ih264e_set_vui_params(pv_api_ip, pv_api_op, ps_cfg); |
6319 | 4.87k | break; |
6320 | | |
6321 | 4.87k | case IVE_CMD_CTL_SET_SEI_MDCV_PARAMS: |
6322 | 4.87k | ret = ih264e_set_sei_mdcv_params(pv_api_ip, pv_api_op, ps_cfg); |
6323 | 4.87k | break; |
6324 | | |
6325 | 4.87k | case IVE_CMD_CTL_SET_SEI_CLL_PARAMS: |
6326 | 4.87k | ret = ih264e_set_sei_cll_params(pv_api_ip, pv_api_op, ps_cfg); |
6327 | 4.87k | break; |
6328 | | |
6329 | 4.87k | case IVE_CMD_CTL_SET_SEI_AVE_PARAMS: |
6330 | 4.87k | ret = ih264e_set_sei_ave_params(pv_api_ip, pv_api_op, ps_cfg); |
6331 | 4.87k | break; |
6332 | | |
6333 | 4.87k | case IVE_CMD_CTL_SET_SEI_CCV_PARAMS: |
6334 | 4.87k | ret = ih264e_set_sei_ccv_params(pv_api_ip, pv_api_op, ps_cfg); |
6335 | 4.87k | break; |
6336 | | |
6337 | 4.87k | case IVE_CMD_CTL_SET_SEI_SII_PARAMS: |
6338 | 4.87k | ret = ih264e_set_sei_sii_params(pv_api_ip, pv_api_op, ps_cfg); |
6339 | 4.87k | break; |
6340 | | |
6341 | 0 | case IVE_CMD_CTL_RESET: |
6342 | | |
6343 | | /* invalidate config param struct as it is being served right away */ |
6344 | 0 | ps_codec->as_cfg[i].u4_is_valid = 0; |
6345 | |
|
6346 | 0 | ret = ih264e_reset(ps_codec_obj, pv_api_ip, pv_api_op); |
6347 | 0 | break; |
6348 | | |
6349 | 4.87k | case IVE_CMD_CTL_SETDEFAULT: |
6350 | 4.87k | { |
6351 | | /* ctrl call I/O structures */ |
6352 | 4.87k | ih264e_ctl_setdefault_op_t *ps_op = pv_api_op; |
6353 | | |
6354 | | /* invalidate config param struct as it is being served right away */ |
6355 | 4.87k | ps_codec->as_cfg[i].u4_is_valid = 0; |
6356 | | |
6357 | | /* error status */ |
6358 | 4.87k | ret = ih264e_set_default_params(ps_cfg); |
6359 | | |
6360 | 4.87k | ps_op->s_ive_op.u4_error_code = ret; |
6361 | | |
6362 | 4.87k | break; |
6363 | 0 | } |
6364 | | |
6365 | 0 | case IVE_CMD_CTL_FLUSH: |
6366 | | |
6367 | | /* invalidate config param struct as it is being served right away */ |
6368 | 0 | ps_codec->as_cfg[i].u4_is_valid = 0; |
6369 | |
|
6370 | 0 | ret = ih264e_set_flush_mode(ps_codec_obj, pv_api_ip, pv_api_op); |
6371 | 0 | break; |
6372 | | |
6373 | 4.81k | case IVE_CMD_CTL_GETBUFINFO: |
6374 | | |
6375 | | /* invalidate config param struct as it is being served right away */ |
6376 | 4.81k | ps_codec->as_cfg[i].u4_is_valid = 0; |
6377 | | |
6378 | 4.81k | ret = ih264e_get_buf_info(ps_codec_obj, pv_api_ip, pv_api_op); |
6379 | 4.81k | break; |
6380 | | |
6381 | 4.87k | case IVE_CMD_CTL_GETVERSION: |
6382 | 4.87k | { |
6383 | | /* ctrl call I/O structures */ |
6384 | 4.87k | ih264e_ctl_getversioninfo_ip_t *ps_ip = pv_api_ip; |
6385 | 4.87k | ih264e_ctl_getversioninfo_op_t *ps_op = pv_api_op; |
6386 | | |
6387 | | /* invalidate config param struct as it is being served right away */ |
6388 | 4.87k | ps_codec->as_cfg[i].u4_is_valid = 0; |
6389 | | |
6390 | | /* error status */ |
6391 | 4.87k | ps_op->s_ive_op.u4_error_code = IV_SUCCESS; |
6392 | | |
6393 | 4.87k | if (ps_ip->s_ive_ip.u4_version_bufsize <= 0) |
6394 | 0 | { |
6395 | 0 | ps_op->s_ive_op.u4_error_code = |
6396 | 0 | IH264E_CXA_VERS_BUF_INSUFFICIENT; |
6397 | 0 | ret = IV_FAIL; |
6398 | 0 | } |
6399 | 4.87k | else |
6400 | 4.87k | { |
6401 | 4.87k | ret = ih264e_get_version((CHAR *) ps_ip->s_ive_ip.pu1_version, |
6402 | 4.87k | ps_ip->s_ive_ip.u4_version_bufsize); |
6403 | | |
6404 | 4.87k | if (ret != IV_SUCCESS) |
6405 | 0 | { |
6406 | 0 | ps_op->s_ive_op.u4_error_code = |
6407 | 0 | IH264E_CXA_VERS_BUF_INSUFFICIENT; |
6408 | 0 | ret = IV_FAIL; |
6409 | 0 | } |
6410 | 4.87k | } |
6411 | 4.87k | break; |
6412 | 0 | } |
6413 | | |
6414 | 4.87k | case IVE_CMD_CTL_SET_NUM_CORES: |
6415 | 4.87k | ret = ih264e_set_num_cores(pv_api_ip, pv_api_op, ps_cfg); |
6416 | 4.87k | break; |
6417 | | |
6418 | 0 | default: |
6419 | | /* invalidate config param struct as it is being served right away */ |
6420 | 0 | ps_codec->as_cfg[i].u4_is_valid = 0; |
6421 | |
|
6422 | 0 | DEBUG("Warning !! unrecognized control api command \n"); |
6423 | 0 | break; |
6424 | 101k | } |
6425 | | |
6426 | 101k | ithread_mutex_unlock(ps_codec->pv_ctl_mutex); |
6427 | | |
6428 | 101k | return ret; |
6429 | 101k | } |
6430 | | |
6431 | | /** |
6432 | | ******************************************************************************* |
6433 | | * |
6434 | | * @brief |
6435 | | * Codec entry point function. All the function calls to the codec are done |
6436 | | * using this function with different values specified in command |
6437 | | * |
6438 | | * @par Description: |
6439 | | * Arguments are tested for validity and then based on the command |
6440 | | * appropriate function is called |
6441 | | * |
6442 | | * @param[in] ps_handle |
6443 | | * API level handle for codec |
6444 | | * |
6445 | | * @param[in] pv_api_ip |
6446 | | * Input argument structure |
6447 | | * |
6448 | | * @param[out] pv_api_op |
6449 | | * Output argument structure |
6450 | | * |
6451 | | * @returns error_status |
6452 | | * |
6453 | | * @remarks |
6454 | | * |
6455 | | ******************************************************************************* |
6456 | | */ |
6457 | | IV_STATUS_T ih264e_api_function(iv_obj_t *ps_handle, |
6458 | | void *pv_api_ip, |
6459 | | void *pv_api_op) |
6460 | 207k | { |
6461 | | /* api command */ |
6462 | 207k | WORD32 command = IV_CMD_NA; |
6463 | | |
6464 | | /* error status */ |
6465 | 207k | IV_STATUS_T e_status; |
6466 | 207k | WORD32 ret; |
6467 | | |
6468 | | /* tmp var */ |
6469 | 207k | WORD32 *pu4_ptr_cmd = (WORD32 *) pv_api_ip; |
6470 | | |
6471 | | /* validate input / output structures */ |
6472 | 207k | e_status = api_check_struct_sanity(ps_handle, pv_api_ip, pv_api_op); |
6473 | | |
6474 | 207k | if (e_status != IV_SUCCESS) |
6475 | 9.18k | { |
6476 | 9.18k | DEBUG("error code = %d\n", *((UWORD32 *)pv_api_op + 1)); |
6477 | 9.18k | return IV_FAIL; |
6478 | 9.18k | } |
6479 | | |
6480 | 197k | pu4_ptr_cmd++; |
6481 | | |
6482 | 197k | command = *pu4_ptr_cmd; |
6483 | | |
6484 | 197k | switch (command) |
6485 | 197k | { |
6486 | 4.89k | case IV_CMD_GET_NUM_MEM_REC: |
6487 | 4.89k | ret = ih264e_get_num_rec(pv_api_ip, pv_api_op); |
6488 | 4.89k | break; |
6489 | | |
6490 | 9.76k | case IV_CMD_FILL_NUM_MEM_REC: |
6491 | 9.76k | ret = ih264e_fill_num_mem_rec(pv_api_ip, pv_api_op); |
6492 | 9.76k | break; |
6493 | | |
6494 | 4.87k | case IV_CMD_INIT: |
6495 | 4.87k | ret = ih264e_init_mem_rec(ps_handle, pv_api_ip, pv_api_op); |
6496 | 4.87k | break; |
6497 | | |
6498 | 4.87k | case IV_CMD_RETRIEVE_MEMREC: |
6499 | 4.87k | ret = ih264e_retrieve_memrec(ps_handle, pv_api_ip, pv_api_op); |
6500 | 4.87k | break; |
6501 | | |
6502 | 101k | case IVE_CMD_VIDEO_CTL: |
6503 | 101k | ret = ih264e_ctl(ps_handle, pv_api_ip, pv_api_op); |
6504 | 101k | break; |
6505 | | |
6506 | 72.3k | case IVE_CMD_VIDEO_ENCODE: |
6507 | 72.3k | ret = ih264e_encode(ps_handle, pv_api_ip, pv_api_op); |
6508 | 72.3k | break; |
6509 | | |
6510 | 0 | default: |
6511 | 0 | ret = IV_FAIL; |
6512 | 0 | break; |
6513 | 197k | } |
6514 | | |
6515 | 197k | return (IV_STATUS_T) ret; |
6516 | 197k | } |