1 /******************************************************************************
2 *
3 * Copyright (C) 2018 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 ihevce_error_checks.c
24 *
25 * \brief
26 * This file contains all the functions which checks the validity of the
27 * parameters passed to the encoder.
28 *
29 * \date
30 * 18/09/2012
31 *
32 * \author
33 * Ittiam
34 *
35 * List of Functions
36 * ihevce_get_level_index()
37 * ihevce_hle_validate_static_params()
38 * ihevce_validate_tile_config_params()
39 *
40 ******************************************************************************
41 */
42
43 /*****************************************************************************/
44 /* File Includes */
45 /*****************************************************************************/
46 /* System include files */
47 #include <stdio.h>
48 #include <string.h>
49 #include <stdlib.h>
50 #include <assert.h>
51 #include <stdarg.h>
52 #include <math.h>
53
54 /* User include files */
55 #include "ihevc_typedefs.h"
56 #include "itt_video_api.h"
57 #include "ihevce_api.h"
58
59 #include "rc_cntrl_param.h"
60 #include "rc_frame_info_collector.h"
61 #include "rc_look_ahead_params.h"
62
63 #include "ihevc_defs.h"
64 #include "ihevc_macros.h"
65 #include "ihevc_debug.h"
66 #include "ihevc_structs.h"
67 #include "ihevc_platform_macros.h"
68 #include "ihevc_deblk.h"
69 #include "ihevc_itrans_recon.h"
70 #include "ihevc_chroma_itrans_recon.h"
71 #include "ihevc_chroma_intra_pred.h"
72 #include "ihevc_intra_pred.h"
73 #include "ihevc_inter_pred.h"
74 #include "ihevc_mem_fns.h"
75 #include "ihevc_padding.h"
76 #include "ihevc_weighted_pred.h"
77 #include "ihevc_sao.h"
78 #include "ihevc_resi_trans.h"
79 #include "ihevc_quant_iquant_ssd.h"
80 #include "ihevc_cabac_tables.h"
81 #include "ihevc_trans_tables.h"
82 #include "ihevc_trans_macros.h"
83
84 #include "ihevce_defs.h"
85 #include "ihevce_lap_enc_structs.h"
86 #include "ihevce_hle_interface.h"
87 #include "ihevce_multi_thrd_structs.h"
88 #include "ihevce_multi_thrd_funcs.h"
89 #include "ihevce_me_common_defs.h"
90 #include "ihevce_had_satd.h"
91 #include "ihevce_error_codes.h"
92 #include "ihevce_error_checks.h"
93 #include "ihevce_bitstream.h"
94 #include "ihevce_cabac.h"
95 #include "ihevce_rdoq_macros.h"
96 #include "ihevce_function_selector.h"
97 #include "ihevce_enc_structs.h"
98 #include "ihevce_global_tables.h"
99 #include "ihevce_trace.h"
100
101 /*****************************************************************************/
102 /* Function Definitions */
103 /*****************************************************************************/
104
105 /*!
106 ******************************************************************************
107 * \if Function name : ihevce_validate_tile_config_params \endif
108 *
109 * \brief
110 * This function validates the static parameters related to tiles
111 *
112 * \param[in] Encoder static config prms pointer
113 *
114 * \return
115 * None
116 *
117 * \author
118 * Ittiam
119 *
120 *****************************************************************************
121 */
ihevce_validate_tile_config_params(ihevce_static_cfg_params_t * ps_static_cfg_prms)122 WORD32 ihevce_validate_tile_config_params(ihevce_static_cfg_params_t *ps_static_cfg_prms)
123 {
124 WORD32 error_code = IHEVCE_SUCCESS;
125 ihevce_sys_api_t *ps_sys_api = &ps_static_cfg_prms->s_sys_api;
126 void *pv_cb_handle = ps_sys_api->pv_cb_handle;
127
128 /* As of now tiles are not supported */
129 if(ps_static_cfg_prms->s_app_tile_params.i4_tiles_enabled_flag != 0)
130 {
131 error_code = IHEVCE_BAD_TILE_CONFIGURATION;
132 ps_sys_api->ihevce_printf(
133 pv_cb_handle, "IHEVCE ERROR: i4_tiles_enabled_flag should be set to 0 \n");
134 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
135 }
136
137 return error_code;
138 }
139
140 /*!
141 ******************************************************************************
142 * \if Function name : ihevce_hle_validate_static_params \endif
143 *
144 * \brief
145 * This function validates the static parameters before creating the encoder
146 * instance.
147 *
148 * \param[in] Encoder context pointer
149 *
150 * \return
151 * Error code
152 *
153 * \author
154 * Ittiam
155 *
156 *****************************************************************************
157 */
ihevce_hle_validate_static_params(ihevce_static_cfg_params_t * ps_static_cfg_prms)158 WORD32 ihevce_hle_validate_static_params(ihevce_static_cfg_params_t *ps_static_cfg_prms)
159 {
160 WORD32 error_code;
161 WORD32 i4_resolution_id;
162 WORD32 ai4_num_bitrate_instances[IHEVCE_MAX_NUM_RESOLUTIONS] = { 1 };
163 WORD32 i4_num_resolutions;
164 ihevce_sys_api_t *ps_sys_api = &ps_static_cfg_prms->s_sys_api;
165 void *pv_cb_handle = ps_sys_api->pv_cb_handle;
166
167 /* derive local variables */
168 i4_num_resolutions = ps_static_cfg_prms->s_tgt_lyr_prms.i4_num_res_layers;
169 for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
170 {
171 ai4_num_bitrate_instances[i4_resolution_id] =
172 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
173 .i4_num_bitrate_instances;
174 }
175 // clang-format off
176 if(0 != ps_static_cfg_prms->i4_log_dump_level)
177 {
178 /* Print all the config params */
179 if((0 == ps_static_cfg_prms->i4_res_id) && (0 == ps_static_cfg_prms->i4_br_id))
180 {
181 WORD32 i4_resolution_id_loop, i4_i;
182 WORD32 i4_num_res_layers = ps_static_cfg_prms->s_tgt_lyr_prms.i4_num_res_layers;
183
184 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "**********************************************\n");
185 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "*********** STATIC PARAMS CONFIG *************\n");
186 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "**********************************************\n");
187
188 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : ps_static_cfg_prms->s_src_prms \n");
189 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_width %d \n", ps_static_cfg_prms->s_src_prms.i4_width);
190 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_height %d \n", ps_static_cfg_prms->s_src_prms.i4_height);
191 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_frm_rate_num %d \n", ps_static_cfg_prms->s_src_prms.i4_frm_rate_num);
192 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_frm_rate_denom %d \n", ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom);
193 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_field_pic %d \n", ps_static_cfg_prms->s_src_prms.i4_field_pic);
194 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_chr_format %d \n", ps_static_cfg_prms->s_src_prms.i4_chr_format);
195 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_input_bit_depth %d \n", ps_static_cfg_prms->s_src_prms.i4_input_bit_depth);
196 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_topfield_first %d \n\n", ps_static_cfg_prms->s_src_prms.i4_topfield_first);
197
198 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : ps_static_cfg_prms->s_tgt_lyr_prms \n");
199 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_num_res_layers %d \n", i4_num_res_layers);
200 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_multi_res_layer_reuse %d \n", ps_static_cfg_prms->s_tgt_lyr_prms.i4_multi_res_layer_reuse);
201 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_mbr_quality_setting %d \n", ps_static_cfg_prms->s_tgt_lyr_prms.i4_mbr_quality_setting);
202
203 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : For Each resolution,");
204 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : i4_target_width ");
205 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
206 {
207 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_width);
208 }
209
210 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : i4_target_width ");
211 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
212 {
213 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_height);
214 }
215
216 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : i4_frm_rate_scale_factor ");
217 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
218 {
219 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop,
220 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_frm_rate_scale_factor);
221 }
222
223 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : i4_codec_level ");
224 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
225 {
226 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_codec_level);
227 }
228
229 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : i4_num_bitrate_instances ");
230 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
231 {
232 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d", i4_resolution_id_loop,
233 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_num_bitrate_instances);
234 }
235
236 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
237 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
238 {
239 WORD32 i4_num_bitrate_instances, i4_br_loop;
240 i4_num_bitrate_instances = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_num_bitrate_instances;
241 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_tgt_bitrate res_id %d ", i4_resolution_id_loop);
242 for(i4_br_loop = 0; i4_br_loop < i4_num_bitrate_instances; i4_br_loop++)
243 {
244 PRINTF(
245 ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "br_id %d %d ", i4_br_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].ai4_tgt_bitrate[i4_br_loop]);
246 }
247 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
248 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_peak_bitrate res_id %d ", i4_resolution_id_loop);
249 for(i4_br_loop = 0; i4_br_loop < i4_num_bitrate_instances; i4_br_loop++)
250 {
251 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "br_id %d %d ", i4_br_loop,
252 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].ai4_peak_bitrate[i4_br_loop]);
253 }
254 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
255 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : vbv_buffer_size res_id %d ", i4_resolution_id_loop);
256 for(i4_br_loop = 0; i4_br_loop < i4_num_bitrate_instances; i4_br_loop++)
257 {
258 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "br_id %d %d ", i4_br_loop,
259 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].ai4_max_vbv_buffer_size[i4_br_loop]);
260 }
261 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
262 }
263
264 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
265 {
266 WORD32 i4_num_bitrate_instances, i4_br_loop;
267
268 i4_num_bitrate_instances = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_num_bitrate_instances;
269 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_frame_qp res_id %d ", i4_resolution_id_loop);
270 for(i4_br_loop = 0; i4_br_loop < i4_num_bitrate_instances; i4_br_loop++)
271 {
272 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "br_id %d %d ", i4_br_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].ai4_frame_qp[i4_br_loop]);
273 }
274 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
275 }
276
277 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_internal_bit_depth %d \n", ps_static_cfg_prms->s_tgt_lyr_prms.i4_internal_bit_depth);
278 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_enable_temporal_scalability %d \n", ps_static_cfg_prms->s_tgt_lyr_prms.i4_enable_temporal_scalability);
279
280 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_quality_preset ");
281 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
282 {
283 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d", i4_resolution_id_loop, ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id_loop].i4_quality_preset);
284 }
285 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
286
287 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_coding_tools_prms \n");
288 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_idr_period %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period);
289 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_min_idr_period %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_min_closed_gop_period);
290 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_cra_period %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period);
291 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_i_cra_period %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period);
292 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_temporal_layers %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers);
293 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_reference_frames %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_max_reference_frames);
294 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_deblocking_type %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type);
295 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_use_default_sc_mtx %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_use_default_sc_mtx);
296 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_enable_entropy_sync %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_enable_entropy_sync);
297 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_cropping_mode %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_cropping_mode);
298 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_vqet %d \n", ps_static_cfg_prms->s_coding_tools_prms.i4_vqet);
299
300 switch(ps_static_cfg_prms->e_arch_type)
301 {
302 case ARCH_NA:
303 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : archType %d \n", 0);
304 break;
305 #ifdef ARM
306 case ARCH_ARM_NONEON:
307 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : archType %d \n", 4);
308 break;
309 #endif
310 default:
311 break;
312 }
313
314 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_config_prms \n");
315 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_num_frms_to_encode %d \n", ps_static_cfg_prms->s_config_prms.i4_num_frms_to_encode);
316 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_log2_cu_size %d \n", ps_static_cfg_prms->s_config_prms.i4_max_log2_cu_size);
317 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_log2_cu_size %d \n", ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size);
318 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_log2_cu_size %d \n", ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size);
319 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_log2_cu_size %d \n", ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size);
320 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_tr_tree_depth_I %d \n", ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_I);
321 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_tr_tree_depth_nI %d \n", ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_nI);
322 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_search_range_horz %d \n", ps_static_cfg_prms->s_config_prms.i4_max_search_range_horz);
323 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_search_range_vert %d \n", ps_static_cfg_prms->s_config_prms.i4_max_search_range_vert);
324
325 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_multi_thrd_prms \n");
326 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_num_cores %d \n", ps_static_cfg_prms->s_multi_thrd_prms.i4_max_num_cores);
327 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_use_thrd_affinity %d \n", ps_static_cfg_prms->s_multi_thrd_prms.i4_use_thrd_affinity);
328
329 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : rate control params \n");
330 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_rate_control_mode %d \n", ps_static_cfg_prms->s_config_prms.i4_rate_control_mode);
331 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_cu_level_rc %d \n", ps_static_cfg_prms->s_config_prms.i4_cu_level_rc);
332 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_pass %d \n", ps_static_cfg_prms->s_pass_prms.i4_pass);
333 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_vbr_max_peak_rate_dur %d \n", ps_static_cfg_prms->s_config_prms.i4_vbr_max_peak_rate_dur);
334 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_init_vbv_fullness %d \n", ps_static_cfg_prms->s_config_prms.i4_init_vbv_fullness);
335 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_stuffing_enable %d \n", ps_static_cfg_prms->s_config_prms.i4_stuffing_enable);
336 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_max_frame_qp %d \n", ps_static_cfg_prms->s_config_prms.i4_max_frame_qp);
337 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_min_frame_qp %d \n", ps_static_cfg_prms->s_config_prms.i4_min_frame_qp);
338
339 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\n");
340
341 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_lap_prms\n");
342 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_rc_look_ahead_pics %d \n", ps_static_cfg_prms->s_lap_prms.i4_rc_look_ahead_pics);
343 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_enable_wts_ofsts %d \n", ps_static_cfg_prms->s_lap_prms.i4_enable_wts_ofsts);
344
345 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_out_strm_prms\n");
346 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_codec_type %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_codec_type);
347 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_codec_profile %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_codec_profile);
348 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_codec_tier %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier);
349 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_aud_enable_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_aud_enable_flags);
350 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_interop_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_interop_flags);
351 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sps_at_cdr_enable %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sps_at_cdr_enable);
352 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_vui_enable %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable);
353 #ifndef DISABLE_SEI
354 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_enable_flag %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_enable_flag);
355 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_payload_enable_flag %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_payload_enable_flag);
356 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_buffer_period_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_buffer_period_flags);
357 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_pic_timing_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_pic_timing_flags);
358 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_cll_enable %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_cll_enable);
359 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_sei_avg_cll %d \n", ps_static_cfg_prms->s_out_strm_prms.u2_sei_avg_cll);
360 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_sei_max_cll %d \n", ps_static_cfg_prms->s_out_strm_prms.u2_sei_max_cll);
361 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_recovery_point_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_recovery_point_flags);
362 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_mastering_disp_colour_vol_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags);
363 for(i4_i = 0; i4_i < 3; i4_i++)
364 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_display_primaries_x[i4_i] %d \n", ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_x[i4_i]);
365 for(i4_i = 0; i4_i < 3; i4_i++)
366 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_display_primaries_y[i4_i] %d \n", ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_y[i4_i]);
367 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_white_point_x %d \n", ps_static_cfg_prms->s_out_strm_prms.u2_white_point_x);
368 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u2_white_point_y %d \n", ps_static_cfg_prms->s_out_strm_prms.u2_white_point_y);
369 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u4_max_display_mastering_luminance %d \n", ps_static_cfg_prms->s_out_strm_prms.u4_max_display_mastering_luminance);
370 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u4_min_display_mastering_luminance %d \n", ps_static_cfg_prms->s_out_strm_prms.u4_min_display_mastering_luminance);
371 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_sei_hash_flags %d \n", ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag);
372 #endif
373
374 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_app_tile_params\n");
375 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_tiles_enabled_flag %d \n", ps_static_cfg_prms->s_app_tile_params.i4_tiles_enabled_flag);
376 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_uniform_spacing_flag %d \n", ps_static_cfg_prms->s_app_tile_params.i4_uniform_spacing_flag);
377 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_num_tile_cols %d \n", ps_static_cfg_prms->s_app_tile_params.i4_num_tile_cols);
378 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_num_tile_rows %d \n", ps_static_cfg_prms->s_app_tile_params.i4_num_tile_rows);
379
380 for(i4_i = 0; i4_i < ps_static_cfg_prms->s_app_tile_params.i4_num_tile_cols; i4_i++)
381 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_column_width[i4_i] %d \n", ps_static_cfg_prms->s_app_tile_params.ai4_column_width[i4_i]);
382
383 for(i4_i = 0; i4_i < ps_static_cfg_prms->s_app_tile_params.i4_num_tile_rows; i4_i++)
384 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_row_height[i4_i] %d \n", ps_static_cfg_prms->s_app_tile_params.ai4_row_height[i4_i]);
385
386 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_slice_params\n");
387 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_slice_segment_mode %d \n", ps_static_cfg_prms->s_slice_params.i4_slice_segment_mode);
388 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_slice_segment_argument %d \n", ps_static_cfg_prms->s_slice_params.i4_slice_segment_argument);
389
390 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms->s_vui_sei_prms\n");
391 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_aspect_ratio_info_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_aspect_ratio_info_present_flag);
392
393 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_aspect_ratio_idc ");
394 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
395 {
396 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_vui_sei_prms.au1_aspect_ratio_idc[i4_resolution_id_loop]);
397 }
398
399 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : au2_sar_width ");
400 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
401 {
402 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_vui_sei_prms.au2_sar_width[i4_resolution_id_loop]);
403 }
404 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : au2_sar_width ");
405 for(i4_resolution_id_loop = 0; i4_resolution_id_loop < i4_num_res_layers; i4_resolution_id_loop++)
406 {
407 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "res_id %d %d ", i4_resolution_id_loop, ps_static_cfg_prms->s_vui_sei_prms.au2_sar_height[i4_resolution_id_loop]);
408 }
409 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : u1_overscan_info_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_info_present_flag);
410 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_overscan_appropriate_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_appropriate_flag);
411 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_video_signal_type_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_video_signal_type_present_flag);
412 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_video_format %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_video_format);
413 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_video_full_range_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_video_full_range_flag);
414 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_colour_description_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_colour_description_present_flag);
415 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_colour_primaries %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_colour_primaries);
416 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_transfer_characteristics %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_transfer_characteristics);
417 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_matrix_coefficients %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_matrix_coefficients);
418 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_chroma_loc_info_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_loc_info_present_flag);
419 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_chroma_sample_loc_type_top_field %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_top_field);
420 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_chroma_sample_loc_type_bottom_field %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_bottom_field);
421 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_timing_info_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_timing_info_present_flag);
422 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_vui_hrd_parameters_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_vui_hrd_parameters_present_flag);
423 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : u1_nal_hrd_parameters_present_flag %d \n", ps_static_cfg_prms->s_vui_sei_prms.u1_nal_hrd_parameters_present_flag);
424 }
425
426 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "\nIHEVCE : ps_static_cfg_prms \n");
427 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_enable_logo %d \n", ps_static_cfg_prms->i4_enable_logo);
428 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_log_dump_level %d \n", ps_static_cfg_prms->i4_log_dump_level);
429 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "IHEVCE : i4_save_recon %d \n", ps_static_cfg_prms->i4_save_recon);
430
431 PRINTF(ps_sys_api->pv_cb_handle, i4_res_id, i4_br_id, "**********************************************\n");
432 }
433 // clang-format on
434
435 if(ps_static_cfg_prms->s_multi_thrd_prms.i4_num_proc_groups > MAX_NUMBER_PROC_GRPS)
436 {
437 error_code = IHEVCE_UNSUPPORTED_PROC_CONFIG;
438 ps_sys_api->ihevce_printf(
439 pv_cb_handle, "IHEVCE ERROR: Number of Processor Groups not supported \n");
440 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
441 }
442
443 /* Error check for system-api callback functions */
444 if(NULL == ps_sys_api->ihevce_printf)
445 {
446 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
447 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
448 }
449 if(NULL == ps_sys_api->s_file_io_api.ihevce_fopen)
450 {
451 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
452 ps_sys_api->ihevce_printf(
453 pv_cb_handle, "IHEVCE ERROR: ihevce_fopen callback function not initiallized\n");
454 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
455 }
456 if(NULL == ps_sys_api->s_file_io_api.ihevce_fclose)
457 {
458 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
459 ps_sys_api->ihevce_printf(
460 pv_cb_handle, "IHEVCE ERROR: ihevce_fclose callback function not initiallized\n");
461 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
462 }
463 if(NULL == ps_sys_api->s_file_io_api.ihevce_fflush)
464 {
465 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
466 ps_sys_api->ihevce_printf(
467 pv_cb_handle, "IHEVCE ERROR: ihevce_fflush callback function not initiallized\n");
468 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
469 }
470 if(NULL == ps_sys_api->s_file_io_api.ihevce_fseek)
471 {
472 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
473 ps_sys_api->ihevce_printf(
474 pv_cb_handle, "IHEVCE ERROR: ihevce_fseek callback function not initiallized\n");
475 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
476 }
477 if(NULL == ps_sys_api->s_file_io_api.ihevce_fread)
478 {
479 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
480 ps_sys_api->ihevce_printf(
481 pv_cb_handle, "IHEVCE ERROR: ihevce_fread callback function not initiallized\n");
482 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
483 }
484 if(NULL == ps_sys_api->s_file_io_api.ihevce_fscanf)
485 {
486 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
487 ps_sys_api->ihevce_printf(
488 pv_cb_handle, "IHEVCE ERROR: ihevce_fscanf callback function not initiallized\n");
489 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
490 }
491 if(NULL == ps_sys_api->ihevce_sscanf)
492 {
493 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
494 ps_sys_api->ihevce_printf(
495 pv_cb_handle, "IHEVCE ERROR: ihevce_sscanf callback function not initiallized\n");
496 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
497 }
498 if(NULL == ps_sys_api->s_file_io_api.ihevce_fprintf)
499 {
500 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
501 ps_sys_api->ihevce_printf(
502 pv_cb_handle, "IHEVCE ERROR: ihevce_fprintf callback function not initiallized\n");
503 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
504 }
505 if(NULL == ps_sys_api->s_file_io_api.ihevce_fwrite)
506 {
507 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
508 ps_sys_api->ihevce_printf(
509 pv_cb_handle, "IHEVCE ERROR: ihevce_fwrite callback function not initiallized\n");
510 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
511 }
512 if(NULL == ps_sys_api->ihevce_sprintf)
513 {
514 error_code = IHEVCE_SYSTEM_APIS_NOT_INITIALLIZED;
515 ps_sys_api->ihevce_printf(
516 pv_cb_handle, "IHEVCE ERROR: ihevce_sprintf callback function not initiallized\n");
517 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
518 }
519
520 /* Error check for static source parameters */
521 if((ps_static_cfg_prms->s_src_prms.i4_orig_width > HEVCE_MAX_WIDTH) ||
522 (ps_static_cfg_prms->s_src_prms.i4_orig_width < 2))
523 {
524 error_code = IHEVCE_WIDTH_NOT_SUPPORTED;
525 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_src_width out of range \n");
526 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
527 }
528
529 if((ps_static_cfg_prms->s_src_prms.i4_orig_height > HEVCE_MAX_HEIGHT) ||
530 (ps_static_cfg_prms->s_src_prms.i4_orig_height < 2))
531 {
532 error_code = IHEVCE_HEIGHT_NOT_SUPPORTED;
533 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_src_height out of range \n");
534 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
535 }
536 /*check for odd resolution*/
537 if(0 != (ps_static_cfg_prms->s_src_prms.i4_width & 1))
538 {
539 error_code = IHEVCE_WIDTH_NOT_SUPPORTED;
540 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_src_width not supported \n");
541 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
542 }
543 if(0 != (ps_static_cfg_prms->s_src_prms.i4_height & 1))
544 {
545 error_code = IHEVCE_HEIGHT_NOT_SUPPORTED;
546 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_src_height not supported \n");
547 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
548 }
549
550 if((ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom != 1000) &&
551 (ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom != 1001))
552 {
553 error_code = IHEVCE_FRAME_RATE_NOT_SUPPORTED;
554 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: frame rate denom not supported \n");
555 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
556 }
557
558 if((((ps_static_cfg_prms->s_src_prms.i4_frm_rate_num * 1.0) /
559 ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom) > MAX_FRAME_RATE) ||
560 (((ps_static_cfg_prms->s_src_prms.i4_frm_rate_num * 1.0) /
561 ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom) < MIN_FRAME_RATE))
562 {
563 error_code = IHEVCE_FRAME_RATE_NOT_SUPPORTED;
564 ps_sys_api->ihevce_printf(
565 pv_cb_handle,
566 "IHEVCE ERROR: Frame rate (%d / %d) is out of range [%.1f - %.1f]\n",
567 ps_static_cfg_prms->s_src_prms.i4_frm_rate_num,
568 ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom,
569 MIN_FRAME_RATE, MAX_FRAME_RATE);
570 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
571 }
572
573 if(ps_static_cfg_prms->s_src_prms.i4_field_pic != 0)
574 {
575 error_code = IHEVCE_CONTENT_TYPE_NOT_SUPPORTED;
576 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Field encoding not supported \n");
577 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
578 }
579
580 if(ps_static_cfg_prms->s_src_prms.inp_chr_format != IV_YUV_420SP_UV &&
581 ps_static_cfg_prms->s_src_prms.inp_chr_format != IV_YUV_420P)
582 {
583 error_code = IHEVCE_CHROMA_FORMAT_NOT_SUPPORTED;
584 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_input_chroma_format Invalid \n");
585 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
586 }
587
588 if(ps_static_cfg_prms->s_src_prms.i4_chr_format != IV_YUV_420SP_UV)
589 {
590 error_code = IHEVCE_CHROMA_FORMAT_NOT_SUPPORTED;
591 ps_sys_api->ihevce_printf(
592 pv_cb_handle, "IHEVCE ERROR: i4_internal_chroma_format Invalid \n");
593 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
594 }
595
596 /* Check error for interoperability flags */
597 if(ps_static_cfg_prms->s_out_strm_prms.i4_interop_flags != 0)
598 {
599 error_code = IHEVCE_INTEROPERABILITY_FLAG_SUPPORTED;
600 ps_sys_api->ihevce_printf(
601 pv_cb_handle, "IHEVCE ERROR: i4_interop_flags out of range, to be set to 0\n");
602 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
603 }
604
605 /* Error check for static output stream parameters */
606 if(ps_static_cfg_prms->s_out_strm_prms.i4_codec_type != 0)
607 {
608 error_code = IHEVCE_CODEC_NOT_SUPPORTED;
609 ps_sys_api->ihevce_printf(
610 pv_cb_handle, "IHEVCE ERROR: i4_codec_type should be set to 0 \n");
611 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
612 }
613
614 if(ps_static_cfg_prms->s_out_strm_prms.i4_codec_profile != 1)
615 {
616 error_code = IHEVCE_CODEC_PROFILE_NOT_SUPPORTED;
617 ps_sys_api->ihevce_printf(
618 pv_cb_handle, "IHEVCE ERROR: i4_codec_profile should be set to 1 \n");
619 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
620 }
621
622 if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_internal_bit_depth != 8)
623 {
624 error_code = IHEVCE_OUTPUT_BIT_DEPTH_OUT_OF_RANGE;
625 ps_sys_api->ihevce_printf(
626 pv_cb_handle,
627 "IHEVCE ERROR: (output_bit_depth = %d) not supported \n",
628 ps_static_cfg_prms->s_tgt_lyr_prms.i4_internal_bit_depth);
629 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
630 }
631
632 if(ps_static_cfg_prms->s_src_prms.i4_input_bit_depth != 8)
633 {
634 error_code = IHEVCE_INPUT_BIT_DEPTH_OUT_OF_RANGE;
635 ps_sys_api->ihevce_printf(
636 pv_cb_handle, "IHEVCE ERROR: i4_input_bit_depth value not supported \n");
637 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
638 }
639
640 if((ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable > 1) ||
641 (ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable < 0))
642 {
643 error_code = IHEVCE_VUI_ENABLE_OUT_OF_RANGE;
644 ps_sys_api->ihevce_printf(
645 pv_cb_handle, "IHEVCE ERROR: i4_vui_enable should be set to 1 or 0 \n");
646 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
647 }
648
649 #ifndef DISABLE_SEI
650 if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_enable_flag > 1) ||
651 (ps_static_cfg_prms->s_out_strm_prms.i4_sei_enable_flag < 0))
652 {
653 error_code = IHEVCE_SEI_ENABLE_OUT_OF_RANGE;
654 ps_sys_api->ihevce_printf(
655 pv_cb_handle, "IHEVCE ERROR: i4_sei_enable_flags should be set to 1 or 0 \n");
656 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
657 }
658
659 if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_payload_enable_flag > 1) ||
660 (ps_static_cfg_prms->s_out_strm_prms.i4_sei_payload_enable_flag < 0))
661 {
662 error_code = IHEVCE_SEI_PAYLOAD_ENABLE_OUT_OF_RANGE;
663 ps_sys_api->ihevce_printf(
664 pv_cb_handle, "IHEVCE ERROR: i4_sei_payload_enable_flag should be set to 1 or 0 \n");
665 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
666 }
667 #endif
668 if((ps_static_cfg_prms->s_multi_thrd_prms.i4_max_num_cores > MAX_NUM_CORES) ||
669 (ps_static_cfg_prms->s_multi_thrd_prms.i4_max_num_cores < 1))
670 {
671 error_code = IHEVCE_INVALID_CORE_CONFIG;
672 ps_sys_api->ihevce_printf(
673 pv_cb_handle, "IHEVCE ERROR: Invalid Number of Cores configured\n");
674 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
675 }
676
677 if((ps_static_cfg_prms->e_arch_type != ARCH_NA) &&
678 (ps_static_cfg_prms->e_arch_type != ARCH_ARM_NONEON))
679 {
680 error_code = IHEVCE_ARCHITECTURE_TYPE_UNSUPPORTED;
681 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: unsupported archType \n");
682 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
683 }
684
685 if(ps_static_cfg_prms->s_coding_tools_prms.i4_vqet != 0)
686 {
687 error_code = IHEVCE_VISUAL_QUALITY_ENHANCEMENTS_TOGGLER_VALUE_UNSUPPORTED;
688 ps_sys_api->ihevce_printf(
689 pv_cb_handle,
690 "IHEVCE ERROR: visual_quality_enhancements_toggler should be set to 0 \n");
691 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
692 }
693
694 if(ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers < 0 ||
695 ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers > 3)
696 {
697 error_code = IHEVCE_TEMPORAL_LAYERS_NOT_SUPPORTED;
698 ps_sys_api->ihevce_printf(
699 pv_cb_handle, "IHEVCE ERROR: i4_max_temporal_layers out of range \n");
700 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
701 }
702
703 if((ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period < 0) ||
704 (ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period < 0) ||
705 (ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period < 0))
706 {
707 error_code = IHEVCE_INVALID_GOP_PERIOD;
708 ps_sys_api->ihevce_printf(
709 pv_cb_handle,
710 "IHEVCE ERROR: gop period is not valid for the configured temporal layers\n");
711 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
712 }
713
714 {
715 WORD32 i4_max_idr_period, i4_min_idr_period, i4_max_cra_period, i4_max_i_period;
716 WORD32 i4_max_i_distance;
717 WORD32 i4_min_i_distance = 0, i4_non_zero_idr_period = 0x7FFFFFFF,
718 i4_non_zero_cra_period = 0x7FFFFFFF, i4_non_zero_i_period = 0x7FFFFFFF;
719 i4_max_idr_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period;
720 i4_min_idr_period = ps_static_cfg_prms->s_coding_tools_prms.i4_min_closed_gop_period;
721 i4_max_cra_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period;
722 i4_max_i_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period;
723 i4_max_i_distance = MAX(MAX(i4_max_idr_period, i4_max_cra_period), i4_max_i_period);
724 WORD32 num_b_frms =
725 (1 << ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers) - 1;
726 if (i4_max_i_distance <= num_b_frms)
727 ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers = 0;
728 WORD32 sub_gop_size = (1 << ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers)
729 << ps_static_cfg_prms->s_src_prms.i4_field_pic;
730
731 if(sub_gop_size > 1)
732 {
733 switch(sub_gop_size)
734 {
735 case 2:
736 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
737 ALIGN2(i4_max_idr_period);
738
739 if(i4_max_idr_period > 1)
740 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
741 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
742
743 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
744 ALIGN2(i4_max_cra_period);
745 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
746 ALIGN2(i4_max_i_period);
747 break;
748 case 4:
749 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
750 ALIGN4(i4_max_idr_period);
751
752 if(i4_max_idr_period > 1)
753 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
754 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
755
756 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
757 ALIGN4(i4_max_cra_period);
758 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
759 ALIGN4(i4_max_i_period);
760 break;
761 case 8:
762 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
763 ALIGN8(i4_max_idr_period);
764
765 if(i4_max_idr_period > 1)
766 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
767 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
768
769 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
770 ALIGN8(i4_max_cra_period);
771 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
772 ALIGN8(i4_max_i_period);
773 break;
774 }
775 }
776
777 if(0 != i4_max_idr_period)
778 {
779 i4_non_zero_idr_period = i4_max_idr_period;
780 }
781 if(0 != i4_max_cra_period)
782 {
783 i4_non_zero_cra_period = i4_max_cra_period;
784 }
785 if(0 != i4_max_i_period)
786 {
787 i4_non_zero_i_period = i4_max_i_period;
788 }
789 i4_min_i_distance =
790 MIN(MIN(i4_non_zero_idr_period, i4_non_zero_cra_period), i4_non_zero_i_period);
791 if(i4_min_i_distance < sub_gop_size && i4_min_i_distance)
792 {
793 error_code = IHEVCE_INVALID_GOP_PERIOD;
794 ps_sys_api->ihevce_printf(
795 pv_cb_handle,
796 "IHEVCE ERROR: gop period is not valid for the configured temporal layers\n");
797 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
798 }
799
800 if((i4_min_idr_period > i4_max_idr_period) || (i4_min_idr_period < 0))
801 {
802 error_code = IHEVCE_INVALID_GOP_PERIOD;
803 ps_sys_api->ihevce_printf(
804 pv_cb_handle,
805 "IHEVCE ERROR: gop period is not valid => min closed gop > max closed gop\n");
806 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
807 }
808 if(ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers && i4_max_i_distance == 1)
809 {
810 error_code = IHEVCE_TEMPORAL_LAYERS_NOT_SUPPORTED;
811 ps_sys_api->ihevce_printf(
812 pv_cb_handle, "IHEVCE ERROR: Invalid max temporal layer for I only encoding\n");
813 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
814 }
815 if((i4_max_idr_period < i4_max_cra_period || i4_max_idr_period < i4_max_i_period) &&
816 i4_max_idr_period)
817 {
818 error_code = IHEVCE_INVALID_GOP_PERIOD;
819 ps_sys_api->ihevce_printf(
820 pv_cb_handle,
821 "IHEVCE ERROR: MAX IDR period can't be less than Max CRA or I period\n");
822 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
823 }
824 if((i4_max_cra_period < i4_max_i_period) && i4_max_cra_period)
825 {
826 error_code = IHEVCE_INVALID_GOP_PERIOD;
827 ps_sys_api->ihevce_printf(
828 pv_cb_handle, "IHEVCE ERROR: MAX CRA period can't be less than Max I period\n");
829 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
830 }
831 }
832 if(0 != ps_static_cfg_prms->s_tgt_lyr_prms.i4_enable_temporal_scalability)
833 {
834 error_code = IHEVCE_INVALID_TEMPORAL_SCALABILITY;
835 ps_sys_api->ihevce_printf(
836 pv_cb_handle, "IHEVCE ERROR: Temporal scalability is not supported \n");
837 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
838 }
839
840 if(ps_static_cfg_prms->s_coding_tools_prms.i4_max_reference_frames != -1)
841 {
842 error_code = IHEVCE_REF_FRAMES_NOT_SUPPORTED;
843 ps_sys_api->ihevce_printf(
844 pv_cb_handle, "IHEVCE ERROR: only supported value for i4_max_reference_frames is -1\n");
845 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
846 }
847
848 if(ps_static_cfg_prms->s_coding_tools_prms.i4_weighted_pred_enable != 0 &&
849 ps_static_cfg_prms->s_coding_tools_prms.i4_weighted_pred_enable != 1)
850 {
851 error_code = IHEVCE_INVALID_WEIGHTED_PREDICTION_INPUT;
852 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_weighted_pred_enable invalid \n");
853 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
854 }
855
856 if(ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 0 &&
857 ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 1 &&
858 ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 2)
859 {
860 error_code = IHEVCE_INVALID_DEBLOCKING_TYPE_INPUT;
861 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_deblocking_type invalid\n");
862 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
863 }
864
865 if(ps_static_cfg_prms->s_coding_tools_prms.i4_use_default_sc_mtx != 0 &&
866 ps_static_cfg_prms->s_coding_tools_prms.i4_use_default_sc_mtx != 1)
867 {
868 error_code = IHEVCE_INVALID_DEFAULT_SC_MATRIX_ENABLE_INPUT;
869 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_use_default_sc_mtx invalid \n");
870 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
871 }
872
873 if(ps_static_cfg_prms->s_coding_tools_prms.i4_cropping_mode != 0 &&
874 ps_static_cfg_prms->s_coding_tools_prms.i4_cropping_mode != 1)
875 {
876 error_code = IHEVCE_INVALID_CROPPING_MODE;
877 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_cropping_mode invalid \n");
878 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
879 }
880
881 /* Error checks for Static Config Parameters */
882 if(ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size != 3)
883 {
884 error_code = IHEVCE_MIN_CU_SIZE_INPUT_NOT_SUPPORTED;
885 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_min_log2_cu_size invalid \n");
886 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
887 }
888
889 if(ps_static_cfg_prms->s_config_prms.i4_min_log2_tu_size != 2)
890 {
891 error_code = IHEVCE_MIN_TU_SIZE_INPUT_NOT_SUPPORTED;
892 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_min_log2_tu_size invalid \n");
893 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
894 }
895
896 if(ps_static_cfg_prms->s_config_prms.i4_max_log2_cu_size < 4 ||
897 ps_static_cfg_prms->s_config_prms.i4_max_log2_cu_size > 6)
898 {
899 error_code = IHEVCE_MAX_CU_SIZE_INPUT_NOT_SUPPORTED;
900 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_max_log2_cu_size invalid \n");
901 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
902 }
903
904 if(ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size < 2 ||
905 ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size > 5)
906 {
907 error_code = IHEVCE_MAX_TU_SIZE_INPUT_NOT_SUPPORTED;
908 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_max_log2_tu_size invalid \n");
909 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
910 }
911
912 if(ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size == 4 &&
913 ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size == 5)
914 {
915 /* Because tu size should always be lesser than the cu size */
916 error_code = IHEVCE_INVALID_MAX_TU_SIZE;
917 ps_sys_api->ihevce_printf(
918 pv_cb_handle,
919 "IHEVCE ERROR: Invalid combination of i4_min_log2_cu_size and i4_max_log2_tu_size\n");
920 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
921 }
922
923 if(ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_I < 1 ||
924 ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_I > 3)
925 {
926 error_code = IHEVCE_INVALID_TR_TREE_DEPTH_FOR_I_FRAME;
927 ps_sys_api->ihevce_printf(
928 pv_cb_handle, "IHEVCE ERROR: i4_max_tr_tree_depth_I out of range\n");
929 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
930 }
931
932 if(ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_nI < 1 ||
933 ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_nI > 4)
934 {
935 error_code = IHEVCE_INVALID_TR_TREE_DEPTH;
936 ps_sys_api->ihevce_printf(
937 pv_cb_handle, "IHEVCE ERROR: i4_max_tr_tree_depth_nI out of range\n");
938 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
939 }
940
941 if(ps_static_cfg_prms->s_config_prms.i4_max_search_range_horz < 64 ||
942 ps_static_cfg_prms->s_config_prms.i4_max_search_range_horz > 512)
943 {
944 error_code = IHEVCE_UNSUPPORTED_HORIZONTAL_SEARCH_RANGE;
945 ps_sys_api->ihevce_printf(
946 pv_cb_handle, "IHEVCE ERROR: i4_max_search_range_horz out of range\n");
947 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
948 }
949
950 if(ps_static_cfg_prms->s_config_prms.i4_max_search_range_vert < 32 ||
951 ps_static_cfg_prms->s_config_prms.i4_max_search_range_vert > 256)
952 {
953 error_code = IHEVCE_UNSUPPORTED_VERTICAL_SEARCH_RANGE;
954 ps_sys_api->ihevce_printf(
955 pv_cb_handle, "IHEVCE ERROR: i4_max_search_range_vert out of range\n");
956 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
957 }
958
959 if(ps_static_cfg_prms->s_lap_prms.i4_rc_look_ahead_pics > NUM_LAP2_LOOK_AHEAD ||
960 ps_static_cfg_prms->s_lap_prms.i4_rc_look_ahead_pics < 0)
961 {
962 error_code = IHEVCE_UNSUPPORTED_LOOK_AHEAD;
963 ps_sys_api->ihevce_printf(
964 pv_cb_handle,
965 "IHEVCE ERROR: rc look ahead pc must be in range of 0 to NUM_LAP2_LOOK_AHEAD\n");
966 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
967 }
968
969 /* Num res instances should be less than equal to IHEVCE_MAX_NUM_RESOLUTIONS */
970 if((i4_num_resolutions < 1) || (i4_num_resolutions > IHEVCE_MAX_NUM_RESOLUTIONS))
971 {
972 error_code = IHEVCE_NUM_MAX_RESOLUTIONS_NOT_SUPPORTED;
973 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid i4_num_resolutions \n");
974 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
975 }
976
977 if((ps_static_cfg_prms->i4_res_id < 0) || (ps_static_cfg_prms->i4_res_id >= i4_num_resolutions))
978 {
979 error_code = IHEVCE_NUM_MAX_RESOLUTIONS_NOT_SUPPORTED;
980 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid i4_num_resolutions \n");
981 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
982 }
983
984 if((ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out < 0) ||
985 (ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out > 1))
986 {
987 error_code = IHEVCE_INVALID_MRES_SINGLE_OUT;
988 ps_sys_api->ihevce_printf(
989 pv_cb_handle, "IHEVCE ERROR: invalid i4_mres_single_out value \n");
990 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
991 }
992
993 if((ps_static_cfg_prms->i4_save_recon) &&
994 (1 == ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out))
995 {
996 ps_sys_api->ihevce_printf(
997 pv_cb_handle,
998 "IHEVCE WARNING: i4_save_recon not supported for mres single out case \n");
999 ps_static_cfg_prms->i4_save_recon = 0;
1000 }
1001
1002 if((1 == i4_num_resolutions) && (1 == ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out))
1003 {
1004 ps_sys_api->ihevce_printf(
1005 pv_cb_handle,
1006 "IHEVCE WARNING: i4_mres_single_out value changed to 0 for single resolution case \n");
1007 ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out = 0;
1008 }
1009
1010 if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_mbr_quality_setting < 0 ||
1011 ps_static_cfg_prms->s_tgt_lyr_prms.i4_mbr_quality_setting > 3)
1012 {
1013 error_code = IHEVCE_INVALID_MBR_QUALITY_SETTING;
1014 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid mbr quality setting\n");
1015 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1016 }
1017
1018 if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_multi_res_layer_reuse != 0)
1019 {
1020 error_code = IHEVCE_MULTI_RES_LAYER_REUSE_NOT_SUPPORTED;
1021 ps_sys_api->ihevce_printf(
1022 pv_cb_handle,
1023 "IHEVCE ERROR: reuse of info across resolution is not currently supported \n");
1024 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1025 }
1026
1027 for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1028 {
1029 WORD32 codec_level_index, quality_preset, height, width, frm_rate_scale_factor;
1030 WORD32 br_ctr;
1031 UWORD32 u4_luma_sample_rate;
1032 WORD32 max_dpb_size;
1033 WORD32 i4_field_pic = ps_static_cfg_prms->s_src_prms.i4_field_pic;
1034
1035 codec_level_index = ihevce_get_level_index(
1036 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level);
1037 quality_preset =
1038 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_quality_preset;
1039 height = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_height;
1040 width = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_width;
1041 frm_rate_scale_factor = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1042 .i4_frm_rate_scale_factor;
1043 /* Check error for max picture size(luma) for the given level */
1044 if((width * height) > g_as_level_data[codec_level_index].i4_max_luma_picture_size)
1045 {
1046 error_code = IHEVCE_PIC_SIZE_NOT_SUPPORTED;
1047 ps_sys_api->ihevce_printf(
1048 pv_cb_handle,
1049 "IHEVCE ERROR: (i4_tgt_width * i4_tgt_height) out of range for resolution number "
1050 "'%d' codec level %d "
1051 "\n",
1052 i4_resolution_id,
1053 codec_level_index);
1054 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1055 }
1056
1057 if((width * height) <= (g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 2))
1058 {
1059 max_dpb_size = 16;
1060 }
1061 else if((width * height) <= (g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 1))
1062 {
1063 max_dpb_size = 12;
1064 }
1065 else if(
1066 (width * height) <=
1067 (3 * g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 2))
1068 {
1069 max_dpb_size = 8;
1070 }
1071 else
1072 {
1073 max_dpb_size = 6;
1074 }
1075
1076 /* DPB check */
1077 if((((DEFAULT_MAX_REFERENCE_PICS - i4_field_pic) /*max reference*/ + 2) << i4_field_pic) >
1078 max_dpb_size)
1079 {
1080 error_code = IHEVCE_CODEC_LEVEL_NOT_SUPPORTED;
1081 ps_sys_api->ihevce_printf(
1082 pv_cb_handle, "IHEVCE ERROR: i4_codec_level should be set correct \n");
1083 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1084 }
1085
1086 if((quality_preset > IHEVCE_QUALITY_P7) || (quality_preset < 0) || (quality_preset == 1))
1087 {
1088 error_code = IHEVCE_INVALID_QUALITY_PRESET_INPUT;
1089 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_quality_preset invalid \n");
1090 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1091 }
1092
1093 /* Error checks for target width and height */
1094 if((height > HEVCE_MAX_HEIGHT) || (height < HEVCE_MIN_HEIGHT) ||
1095 (height != ps_static_cfg_prms->s_src_prms.i4_height))
1096 {
1097 error_code = IHEVCE_TGT_HEIGHT_NOT_SUPPORTED;
1098 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Target height not supported\n");
1099 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1100 }
1101
1102 if((width > HEVCE_MAX_WIDTH) || (width < HEVCE_MIN_WIDTH) ||
1103 (width != ps_static_cfg_prms->s_src_prms.i4_width))
1104 {
1105 error_code = IHEVCE_TGT_WIDTH_NOT_SUPPORTED;
1106 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Target width not supported\n");
1107 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1108 }
1109
1110 /* Error checks for the codec level */
1111 if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level >
1112 LEVEL6)
1113 {
1114 error_code = IHEVCE_CODEC_LEVEL_NOT_SUPPORTED;
1115 ps_sys_api->ihevce_printf(
1116 pv_cb_handle,
1117 "IHEVCE ERROR: i4_codec_level should be set to a max value of 153 \n");
1118 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1119 }
1120
1121 if(frm_rate_scale_factor != 1)
1122 {
1123 error_code = IHEVCE_TGT_FRAME_RATE_SCALING_NOT_SUPPORTED;
1124 ps_sys_api->ihevce_printf(
1125 pv_cb_handle, "IHEVCE ERROR: Target frame rate scaler should be 1 \n");
1126 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1127 }
1128
1129 u4_luma_sample_rate = (UWORD32)(width * height);
1130 u4_luma_sample_rate *= (UWORD32)(
1131 ps_static_cfg_prms->s_src_prms.i4_frm_rate_num /
1132 (ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom * frm_rate_scale_factor));
1133 /* Check error for max samples rate (frame rate * luma picture size) for the given level */
1134 if(u4_luma_sample_rate > g_as_level_data[codec_level_index].u4_max_luma_sample_rate)
1135 {
1136 error_code = IHEVCE_LUMA_SAMPLE_RATE_NOT_SUPPORTED;
1137 ps_sys_api->ihevce_printf(
1138 pv_cb_handle,
1139 "IHEVCE ERROR: input sample rate (i4_src_width * i4_src_height * i4_frm_rate_num / "
1140 "i4_frm_rate_denom ) "
1141 "exceeds u4_max_luma_sample_rate\n");
1142 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1143 }
1144
1145 /* Num instances should be less than equal to IHEVCE_MAX_NUM_BITRATES */
1146 if((ai4_num_bitrate_instances[i4_resolution_id] < 1) ||
1147 (ai4_num_bitrate_instances[i4_resolution_id] > IHEVCE_MAX_NUM_BITRATES))
1148 {
1149 error_code = IHEVCE_INVALID_NUM_BR_INSTANCES;
1150 ps_sys_api->ihevce_printf(
1151 pv_cb_handle, "IHEVCE ERROR: invalid i4_num_bitrate_instances \n");
1152 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1153 }
1154
1155 /* check for codec tier */
1156 if((ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier > HIGH_TIER) ||
1157 (ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier < MAIN_TIER))
1158 {
1159 error_code = IHEVC_CODEC_TIER_NOT_SUPPORTED;
1160 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Codec tier out of range\n");
1161 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1162 }
1163
1164 if((ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level <
1165 120) &&
1166 (ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier == HIGH_TIER))
1167 {
1168 error_code = IHEVC_CODEC_TIER_NOT_SUPPORTED;
1169 ps_sys_api->ihevce_printf(
1170 pv_cb_handle, "IHEVCE ERROR: Codec tier = HIGH TIER Not supported below Level 4\n");
1171 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1172 }
1173
1174 /* Check error for max bitrate for the given level */
1175 for(br_ctr = 0; br_ctr < ai4_num_bitrate_instances[i4_resolution_id]; br_ctr++)
1176 {
1177 WORD32 frame_qp = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1178 .ai4_frame_qp[br_ctr];
1179 WORD32 tgt_bitrate = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1180 .ai4_tgt_bitrate[br_ctr];
1181 WORD32 i4_max_bit_rate =
1182 g_as_level_data[codec_level_index]
1183 .i4_max_bit_rate[ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier];
1184 WORD32 peak_bitrate;
1185
1186 if(frame_qp > MAX_HEVC_QP || frame_qp < MIN_HEVC_QP)
1187 {
1188 error_code = IHEVCE_UNSUPPORTED_FRAME_QP;
1189 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_frame_qp out of range\n");
1190 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1191 }
1192
1193 if(tgt_bitrate > i4_max_bit_rate * CBP_VCL_FACTOR || tgt_bitrate < MIN_BITRATE)
1194 {
1195 error_code = IHEVCE_BITRATE_NOT_SUPPORTED;
1196 ps_sys_api->ihevce_printf(
1197 pv_cb_handle,
1198 "IHEVCE ERROR: i4_tgt_bitrate %d out of range for resolution %dX%d "
1199 "bitrate should be within [%d .. %d]\n",
1200 tgt_bitrate,
1201 width, height,
1202 MIN_BITRATE, i4_max_bit_rate * CBP_VCL_FACTOR);
1203 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1204 }
1205
1206 peak_bitrate = tgt_bitrate << 1;
1207 peak_bitrate = MIN(peak_bitrate, i4_max_bit_rate * 1000);
1208 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1209 .ai4_peak_bitrate[br_ctr] = peak_bitrate;
1210 ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1211 .ai4_max_vbv_buffer_size[br_ctr] = peak_bitrate;
1212 }
1213 }
1214
1215 if((ps_static_cfg_prms->i4_br_id < 0) ||
1216 (ps_static_cfg_prms->i4_br_id >= ai4_num_bitrate_instances[ps_static_cfg_prms->i4_res_id]))
1217 {
1218 error_code = IHEVCE_INVALID_NUM_BR_INSTANCES;
1219 ps_sys_api->ihevce_printf(
1220 pv_cb_handle, "IHEVCE ERROR: invalid i4_num_bitrate_instances \n");
1221 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1222 }
1223
1224 /* Check error for rate control mode for the given level */
1225 if(ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 2 &&
1226 ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 3 &&
1227 ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 5)
1228 {
1229 error_code = IHEVCE_RATE_CONTROL_MDOE_NOT_SUPPORTED;
1230 ps_sys_api->ihevce_printf(
1231 pv_cb_handle, "IHEVCE ERROR: i4_rate_control_mode out of range\n");
1232 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1233 }
1234
1235 /* Check error for pass number */
1236 if(ps_static_cfg_prms->s_pass_prms.i4_pass != 0)
1237 {
1238 error_code = IHEVCE_RATE_CONTROL_PASS_INVALID;
1239 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_pass out of range\n");
1240 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1241 }
1242
1243 /* Check error for cu level qp modultion for the given level */
1244 if(ps_static_cfg_prms->s_config_prms.i4_cu_level_rc != 0 &&
1245 ps_static_cfg_prms->s_config_prms.i4_cu_level_rc != 1)
1246 {
1247 error_code = IHEVCE_RATE_CONTROL_MDOE_NOT_SUPPORTED;
1248 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_cu_level_rc out of range\n");
1249 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1250 }
1251
1252 /* size error checks for the api structures */
1253 if(ps_static_cfg_prms->i4_size != sizeof(ihevce_static_cfg_params_t))
1254 {
1255 error_code = IHEVCE_INVALID_SIZE;
1256 ps_sys_api->ihevce_printf(
1257 pv_cb_handle,
1258 "IHEVCE ERROR: Size element of ihevce_static_cfg_params_t is not matching with actual "
1259 "size");
1260 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1261 }
1262 if(ps_static_cfg_prms->s_src_prms.i4_size != sizeof(ihevce_src_params_t))
1263 {
1264 error_code = IHEVCE_INVALID_SIZE;
1265 ps_sys_api->ihevce_printf(
1266 pv_cb_handle,
1267 "IHEVCE ERROR: Size element of ihevce_src_params_t is not matching with actual size");
1268 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1269 }
1270 if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_size != sizeof(ihevce_tgt_layer_params_t))
1271 {
1272 error_code = IHEVCE_INVALID_SIZE;
1273 ps_sys_api->ihevce_printf(
1274 pv_cb_handle,
1275 "IHEVCE ERROR: Size element of ihevce_tgt_layer_params_t is not matching with actual "
1276 "size");
1277 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1278 }
1279 if(ps_static_cfg_prms->s_out_strm_prms.i4_size != sizeof(ihevce_out_strm_params_t))
1280 {
1281 error_code = IHEVCE_INVALID_SIZE;
1282 ps_sys_api->ihevce_printf(
1283 pv_cb_handle,
1284 "IHEVCE ERROR: Size element of ihevce_out_strm_params_t is not matching with actual "
1285 "size");
1286 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1287 }
1288 if(ps_static_cfg_prms->s_coding_tools_prms.i4_size != sizeof(ihevce_coding_params_t))
1289 {
1290 error_code = IHEVCE_INVALID_SIZE;
1291 ps_sys_api->ihevce_printf(
1292 pv_cb_handle,
1293 "IHEVCE ERROR: Size element of ihevce_coding_params_t is not matching with actual "
1294 "size");
1295 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1296 }
1297 if(ps_static_cfg_prms->s_config_prms.i4_size != sizeof(ihevce_config_prms_t))
1298 {
1299 error_code = IHEVCE_INVALID_SIZE;
1300 ps_sys_api->ihevce_printf(
1301 pv_cb_handle,
1302 "IHEVCE ERROR: Size element of ihevce_config_prms_t is not matching with actual size");
1303 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1304 }
1305 if(ps_static_cfg_prms->s_multi_thrd_prms.i4_size != sizeof(ihevce_static_multi_thread_params_t))
1306 {
1307 error_code = IHEVCE_INVALID_SIZE;
1308 ps_sys_api->ihevce_printf(
1309 pv_cb_handle,
1310 "IHEVCE ERROR: Size element of ihevce_static_multi_thread_params_t is not matching "
1311 "with actual size");
1312 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1313 }
1314 for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1315 {
1316 if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_size !=
1317 sizeof(ihevce_tgt_params_t))
1318 {
1319 error_code = IHEVCE_INVALID_SIZE;
1320 ps_sys_api->ihevce_printf(
1321 pv_cb_handle,
1322 "IHEVCE ERROR: Size element of ihevce_tgt_params_t is not matching with actual "
1323 "size");
1324 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1325 }
1326 }
1327
1328 if(ps_static_cfg_prms->s_lap_prms.i4_size != sizeof(ihevce_lap_params_t))
1329 {
1330 error_code = IHEVCE_INVALID_SIZE;
1331 ps_sys_api->ihevce_printf(
1332 pv_cb_handle,
1333 "IHEVCE ERROR: Size element of ihevce_lap_params_t is not matching with actual size");
1334 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1335 }
1336
1337 for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1338 {
1339 if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_size !=
1340 sizeof(ihevce_tgt_params_t))
1341 {
1342 error_code = IHEVCE_INVALID_SIZE;
1343 ps_sys_api->ihevce_printf(
1344 pv_cb_handle,
1345 "IHEVCE ERROR: Size element of ihevce_tgt_params_t is not matching with actual "
1346 "size");
1347 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1348 }
1349 }
1350
1351 #ifndef DISABLE_SEI
1352 /* Check SEI related error checks */
1353 if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_enable_flag)
1354 {
1355 WORD32 i;
1356 /* Check values for i4_sei_hash_flags */
1357 if(!((ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 2) ||
1358 (ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 3) ||
1359 (ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 0)))
1360 {
1361 error_code = IHEVCE_SEI_HASH_VALUE_NOT_SUPPORTED;
1362 ps_sys_api->ihevce_printf(
1363 pv_cb_handle, "IHEVCE ERROR: i4_sei_hash_flags out of range\n");
1364 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1365 }
1366
1367 /* Content Light Level Info error check */
1368 if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_cll_enable > 1) ||
1369 (ps_static_cfg_prms->s_out_strm_prms.i4_sei_cll_enable < 0))
1370 {
1371 error_code = IHEVCE_SEI_CLL_ENABLE_OUT_OF_RANGE;
1372 ps_sys_api->ihevce_printf(
1373 pv_cb_handle, "IHEVCE ERROR: i4_sei_cll_enable out of range\n");
1374 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1375 }
1376
1377 if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_buffer_period_flags ||
1378 ps_static_cfg_prms->s_out_strm_prms.i4_sei_pic_timing_flags) &&
1379 (!ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable))
1380 {
1381 error_code = IHEVCE_SEI_ENABLED_VUI_DISABLED;
1382 ps_sys_api->ihevce_printf(
1383 pv_cb_handle,
1384 "IHEVCE ERROR: Both SEI and VUI ought to be enabled when either "
1385 "'i4_sei_buffer_period_flags' or "
1386 "'i4_sei_pic_timing_flags' are enabled\n");
1387 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1388 }
1389
1390 if((1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_buffer_period_flags) &&
1391 (3 == ps_static_cfg_prms->s_config_prms.i4_rate_control_mode))
1392 {
1393 error_code = IHEVCE_SEI_MESSAGES_DEPENDENCY;
1394 ps_sys_api->ihevce_printf(
1395 pv_cb_handle,
1396 "IHEVCE ERROR: i4_sei_buffer_period_flags should be disabled for CQP mode of Rate "
1397 "control \n");
1398 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1399 }
1400
1401 /* Check values for i4_sei_mastering_disp_colour_vol_flags */
1402 if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags != 0) &&
1403 (ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags != 1))
1404 {
1405 error_code = IHEVCE_MASTERING_DISP_COL_VOL_OUT_OF_RANGE;
1406 ps_sys_api->ihevce_printf(
1407 pv_cb_handle,
1408 "IHEVCE ERROR: i4_sei_mastering_disp_colour_vol_flags out of range\n");
1409 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1410 }
1411
1412 if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags)
1413 {
1414 /* Check values for u2_display_primaries_x and u2_display_primaries_y */
1415 for(i = 0; i < 3; i++)
1416 {
1417 if((ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_x[i] > 50000))
1418 {
1419 error_code = IHEVCE_DISPLAY_PRIMARY_X_OUT_OF_RANGE;
1420 ps_sys_api->ihevce_printf(
1421 pv_cb_handle, "IHEVCE ERROR: au2_display_primaries_x out of range\n");
1422 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1423 }
1424
1425 if((ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_y[i] > 50000))
1426 {
1427 error_code = IHEVCE_DISPLAY_PRIMARY_Y_OUT_OF_RANGE;
1428 ps_sys_api->ihevce_printf(
1429 pv_cb_handle, "IHEVCE ERROR: au2_display_primaries_y out of range\n");
1430 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1431 }
1432 }
1433
1434 if((ps_static_cfg_prms->s_out_strm_prms.u2_white_point_x > 50000))
1435 {
1436 error_code = IHEVCE_WHITE_POINT_X_OUT_OF_RANGE;
1437 ps_sys_api->ihevce_printf(
1438 pv_cb_handle, "IHEVCE ERROR: u2_white_point_x out of range\n");
1439 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1440 }
1441
1442 if((ps_static_cfg_prms->s_out_strm_prms.u2_white_point_y > 50000))
1443 {
1444 error_code = IHEVCE_WHITE_POINT_Y_OUT_OF_RANGE;
1445 ps_sys_api->ihevce_printf(
1446 pv_cb_handle, "IHEVCE ERROR: u2_white_point_y out of range\n");
1447 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1448 }
1449
1450 if(ps_static_cfg_prms->s_out_strm_prms.u4_max_display_mastering_luminance <=
1451 ps_static_cfg_prms->s_out_strm_prms.u4_min_display_mastering_luminance)
1452 {
1453 error_code = IHEVCE_MAX_DISP_MATERING_LUM_OUT_OF_RANGE;
1454 ps_sys_api->ihevce_printf(
1455 pv_cb_handle,
1456 "IHEVCE ERROR: u4_max_display_mastering_luminance should be greater then "
1457 "u4_min_display_mastering_luminance \n");
1458 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1459 }
1460 }
1461 }
1462 #endif
1463
1464 if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable)
1465 {
1466 /* validate static vui parameters */
1467 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_aspect_ratio_info_present_flag & 0xFE) > 0))
1468 {
1469 error_code = IHEVC_INVALID_ASPECT_RATIO_PARAMS;
1470 ps_sys_api->ihevce_printf(
1471 pv_cb_handle, "IHEVCE ERROR: invalid aspect ratio parameters\n");
1472 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1473 }
1474
1475 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_info_present_flag & 0xFE) > 0) ||
1476 ((ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_appropriate_flag & 0xFE) > 0))
1477 {
1478 error_code = IHEVC_INVALID_OVERSCAN_PARAMS;
1479 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid overscan parameters\n");
1480 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1481 }
1482
1483 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_video_signal_type_present_flag & 0xFE) > 0) ||
1484 (ps_static_cfg_prms->s_vui_sei_prms.u1_video_format > 5) ||
1485 ((ps_static_cfg_prms->s_vui_sei_prms.u1_video_full_range_flag & 0xFE) > 0))
1486 {
1487 error_code = IHEVC_INVALID_VIDEO_PARAMS;
1488 ps_sys_api->ihevce_printf(
1489 pv_cb_handle, "IHEVCE ERROR: invalid video signal type parameters\n");
1490 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1491 }
1492
1493 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_colour_description_present_flag & 0xFE) > 0))
1494 {
1495 error_code = IHEVC_INVALID_COLOUR_PARAMS;
1496 ps_sys_api->ihevce_printf(
1497 pv_cb_handle, "IHEVCE ERROR: invalid colour description parameters\n");
1498 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1499 }
1500
1501 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_loc_info_present_flag & 0xFE) > 0) ||
1502 (ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_top_field > 5) ||
1503 (ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_bottom_field > 5))
1504 {
1505 error_code = IHEVC_INVALID_CHROMA_PARAMS;
1506 ps_sys_api->ihevce_printf(
1507 pv_cb_handle, "IHEVCE ERROR: invalid chroma info parameters\n");
1508 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1509 }
1510
1511 if((ps_static_cfg_prms->s_vui_sei_prms.u1_timing_info_present_flag & 0xFE) > 0)
1512 {
1513 error_code = IHEVC_INVALID_TIMING_INFO_PARAM;
1514 ps_sys_api->ihevce_printf(
1515 pv_cb_handle, "IHEVCE ERROR: invalid timing info present flag\n");
1516 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1517 }
1518
1519 if(((ps_static_cfg_prms->s_vui_sei_prms.u1_vui_hrd_parameters_present_flag & 0xFE) > 0) ||
1520 ((ps_static_cfg_prms->s_vui_sei_prms.u1_nal_hrd_parameters_present_flag & 0xFE) > 0))
1521 {
1522 error_code = IHEVC_INVALID_HRD_PRESENT_PARAMS;
1523 ps_sys_api->ihevce_printf(
1524 pv_cb_handle, "IHEVCE ERROR: invalid vui or vcl hrd parameters present flag\n");
1525 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1526 }
1527 }
1528
1529 error_code = ihevce_validate_tile_config_params(ps_static_cfg_prms);
1530 if(IHEVCE_SUCCESS != error_code)
1531 {
1532 return error_code;
1533 }
1534
1535 if(ps_static_cfg_prms->s_slice_params.i4_slice_segment_mode != 0)
1536 {
1537 error_code = IHEVCE_BAD_SLICE_PARAMS;
1538 ps_sys_api->ihevce_printf(
1539 pv_cb_handle, "IHEVCE ERROR: i4_slice_segment_mode should be 0 \n");
1540 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1541 }
1542
1543 return IHEVCE_SUCCESS;
1544 }
1545
1546 /*!
1547 ******************************************************************************
1548 * \if Function name : ihevce_get_level_index \endif
1549 *
1550 * \brief
1551 * This function returns the index of level based on codec_level value
1552 * Please see the LEVEL_T enum def
1553 *
1554 * \param[in] Codec Level
1555 *
1556 * \return
1557 * Index of Codec level
1558 *
1559 * \author
1560 * Ittiam
1561 *
1562 *****************************************************************************
1563 */
ihevce_get_level_index(WORD32 i4_codec_level)1564 WORD32 ihevce_get_level_index(WORD32 i4_codec_level)
1565 {
1566 switch(i4_codec_level)
1567 {
1568 case LEVEL1:
1569 return 0;
1570 case LEVEL2:
1571 return 1;
1572 case LEVEL2_1:
1573 return 2;
1574 case LEVEL3:
1575 return 3;
1576 case LEVEL3_1:
1577 return 4;
1578 case LEVEL4:
1579 return 5;
1580 case LEVEL4_1:
1581 return 6;
1582 case LEVEL5:
1583 return 7;
1584 case LEVEL5_1:
1585 return 8;
1586 case LEVEL5_2:
1587 return 9;
1588 case LEVEL6:
1589 return 10;
1590 case LEVEL6_1:
1591 return 11;
1592 case LEVEL6_2:
1593 return 12;
1594 default:
1595 return 0;
1596 }
1597 }
1598