• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 sub_gop_size = (1 << ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers)
716                               << ps_static_cfg_prms->s_src_prms.i4_field_pic;
717         WORD32 i4_max_idr_period, i4_min_idr_period, i4_max_cra_period, i4_max_i_period;
718         WORD32 i4_max_i_distance;
719         WORD32 i4_min_i_distance = 0, i4_non_zero_idr_period = 0x7FFFFFFF,
720                i4_non_zero_cra_period = 0x7FFFFFFF, i4_non_zero_i_period = 0x7FFFFFFF;
721         i4_max_idr_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period;
722         i4_min_idr_period = ps_static_cfg_prms->s_coding_tools_prms.i4_min_closed_gop_period;
723         i4_max_cra_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period;
724         i4_max_i_period = ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period;
725         i4_max_i_distance = MAX(MAX(i4_max_idr_period, i4_max_cra_period), i4_max_i_period);
726 
727         if(sub_gop_size > 1)
728         {
729             switch(sub_gop_size)
730             {
731             case 2:
732                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
733                     ALIGN2(i4_max_idr_period);
734 
735                 if(i4_max_idr_period > 1)
736                     ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
737                         ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
738 
739                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
740                     ALIGN2(i4_max_cra_period);
741                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
742                     ALIGN2(i4_max_i_period);
743                 break;
744             case 4:
745                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
746                     ALIGN4(i4_max_idr_period);
747 
748                 if(i4_max_idr_period > 1)
749                     ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
750                         ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
751 
752                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
753                     ALIGN4(i4_max_cra_period);
754                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
755                     ALIGN4(i4_max_i_period);
756                 break;
757             case 8:
758                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
759                     ALIGN8(i4_max_idr_period);
760 
761                 if(i4_max_idr_period > 1)
762                     ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period =
763                         ps_static_cfg_prms->s_coding_tools_prms.i4_max_closed_gop_period + 1;
764 
765                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_cra_open_gop_period =
766                     ALIGN8(i4_max_cra_period);
767                 ps_static_cfg_prms->s_coding_tools_prms.i4_max_i_open_gop_period =
768                     ALIGN8(i4_max_i_period);
769                 break;
770             }
771         }
772 
773         if(0 != i4_max_idr_period)
774         {
775             i4_non_zero_idr_period = i4_max_idr_period;
776         }
777         if(0 != i4_max_cra_period)
778         {
779             i4_non_zero_cra_period = i4_max_cra_period;
780         }
781         if(0 != i4_max_i_period)
782         {
783             i4_non_zero_i_period = i4_max_i_period;
784         }
785         i4_min_i_distance =
786             MIN(MIN(i4_non_zero_idr_period, i4_non_zero_cra_period), i4_non_zero_i_period);
787         if(i4_min_i_distance < sub_gop_size && i4_min_i_distance)
788         {
789             error_code = IHEVCE_INVALID_GOP_PERIOD;
790             ps_sys_api->ihevce_printf(
791                 pv_cb_handle,
792                 "IHEVCE ERROR: gop period is not valid for the configured temporal layers\n");
793             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
794         }
795 
796         if((i4_min_idr_period > i4_max_idr_period) || (i4_min_idr_period < 0))
797         {
798             error_code = IHEVCE_INVALID_GOP_PERIOD;
799             ps_sys_api->ihevce_printf(
800                 pv_cb_handle,
801                 "IHEVCE ERROR: gop period is not valid => min closed gop > max closed gop\n");
802             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
803         }
804         if(ps_static_cfg_prms->s_coding_tools_prms.i4_max_temporal_layers && i4_max_i_distance == 1)
805         {
806             error_code = IHEVCE_TEMPORAL_LAYERS_NOT_SUPPORTED;
807             ps_sys_api->ihevce_printf(
808                 pv_cb_handle, "IHEVCE ERROR: Invalid max temporal layer for I only encoding\n");
809             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
810         }
811         if((i4_max_idr_period < i4_max_cra_period || i4_max_idr_period < i4_max_i_period) &&
812            i4_max_idr_period)
813         {
814             error_code = IHEVCE_INVALID_GOP_PERIOD;
815             ps_sys_api->ihevce_printf(
816                 pv_cb_handle,
817                 "IHEVCE ERROR: MAX IDR period can't be less than Max CRA or I period\n");
818             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
819         }
820         if((i4_max_cra_period < i4_max_i_period) && i4_max_cra_period)
821         {
822             error_code = IHEVCE_INVALID_GOP_PERIOD;
823             ps_sys_api->ihevce_printf(
824                 pv_cb_handle, "IHEVCE ERROR: MAX CRA period can't be less than Max I period\n");
825             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
826         }
827     }
828     if(0 != ps_static_cfg_prms->s_tgt_lyr_prms.i4_enable_temporal_scalability)
829     {
830         error_code = IHEVCE_INVALID_TEMPORAL_SCALABILITY;
831         ps_sys_api->ihevce_printf(
832             pv_cb_handle, "IHEVCE ERROR: Temporal scalability is not supported \n");
833         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
834     }
835 
836     if(ps_static_cfg_prms->s_coding_tools_prms.i4_max_reference_frames != -1)
837     {
838         error_code = IHEVCE_REF_FRAMES_NOT_SUPPORTED;
839         ps_sys_api->ihevce_printf(
840             pv_cb_handle, "IHEVCE ERROR: only supported value for i4_max_reference_frames is -1\n");
841         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
842     }
843 
844     if(ps_static_cfg_prms->s_coding_tools_prms.i4_weighted_pred_enable != 0 &&
845        ps_static_cfg_prms->s_coding_tools_prms.i4_weighted_pred_enable != 1)
846     {
847         error_code = IHEVCE_INVALID_WEIGHTED_PREDICTION_INPUT;
848         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_weighted_pred_enable invalid \n");
849         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
850     }
851 
852     if(ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 0 &&
853        ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 1 &&
854        ps_static_cfg_prms->s_coding_tools_prms.i4_deblocking_type != 2)
855     {
856         error_code = IHEVCE_INVALID_DEBLOCKING_TYPE_INPUT;
857         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_deblocking_type invalid\n");
858         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
859     }
860 
861     if(ps_static_cfg_prms->s_coding_tools_prms.i4_use_default_sc_mtx != 0 &&
862        ps_static_cfg_prms->s_coding_tools_prms.i4_use_default_sc_mtx != 1)
863     {
864         error_code = IHEVCE_INVALID_DEFAULT_SC_MATRIX_ENABLE_INPUT;
865         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_use_default_sc_mtx invalid \n");
866         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
867     }
868 
869     if(ps_static_cfg_prms->s_coding_tools_prms.i4_cropping_mode != 0 &&
870        ps_static_cfg_prms->s_coding_tools_prms.i4_cropping_mode != 1)
871     {
872         error_code = IHEVCE_INVALID_CROPPING_MODE;
873         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_cropping_mode invalid \n");
874         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
875     }
876 
877     /* Error checks for Static Config Parameters */
878     if(ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size != 3)
879     {
880         error_code = IHEVCE_MIN_CU_SIZE_INPUT_NOT_SUPPORTED;
881         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_min_log2_cu_size invalid \n");
882         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
883     }
884 
885     if(ps_static_cfg_prms->s_config_prms.i4_min_log2_tu_size != 2)
886     {
887         error_code = IHEVCE_MIN_TU_SIZE_INPUT_NOT_SUPPORTED;
888         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_min_log2_tu_size invalid \n");
889         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
890     }
891 
892     if(ps_static_cfg_prms->s_config_prms.i4_max_log2_cu_size < 4 ||
893        ps_static_cfg_prms->s_config_prms.i4_max_log2_cu_size > 6)
894     {
895         error_code = IHEVCE_MAX_CU_SIZE_INPUT_NOT_SUPPORTED;
896         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_max_log2_cu_size invalid \n");
897         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
898     }
899 
900     if(ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size < 2 ||
901        ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size > 5)
902     {
903         error_code = IHEVCE_MAX_TU_SIZE_INPUT_NOT_SUPPORTED;
904         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_max_log2_tu_size invalid \n");
905         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
906     }
907 
908     if(ps_static_cfg_prms->s_config_prms.i4_min_log2_cu_size == 4 &&
909        ps_static_cfg_prms->s_config_prms.i4_max_log2_tu_size == 5)
910     {
911         /* Because tu size should always be lesser than the cu size */
912         error_code = IHEVCE_INVALID_MAX_TU_SIZE;
913         ps_sys_api->ihevce_printf(
914             pv_cb_handle,
915             "IHEVCE ERROR: Invalid combination of i4_min_log2_cu_size and i4_max_log2_tu_size\n");
916         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
917     }
918 
919     if(ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_I < 1 ||
920        ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_I > 3)
921     {
922         error_code = IHEVCE_INVALID_TR_TREE_DEPTH_FOR_I_FRAME;
923         ps_sys_api->ihevce_printf(
924             pv_cb_handle, "IHEVCE ERROR: i4_max_tr_tree_depth_I out of range\n");
925         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
926     }
927 
928     if(ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_nI < 1 ||
929        ps_static_cfg_prms->s_config_prms.i4_max_tr_tree_depth_nI > 4)
930     {
931         error_code = IHEVCE_INVALID_TR_TREE_DEPTH;
932         ps_sys_api->ihevce_printf(
933             pv_cb_handle, "IHEVCE ERROR: i4_max_tr_tree_depth_nI out of range\n");
934         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
935     }
936 
937     if(ps_static_cfg_prms->s_config_prms.i4_max_search_range_horz < 64 ||
938        ps_static_cfg_prms->s_config_prms.i4_max_search_range_horz > 512)
939     {
940         error_code = IHEVCE_UNSUPPORTED_HORIZONTAL_SEARCH_RANGE;
941         ps_sys_api->ihevce_printf(
942             pv_cb_handle, "IHEVCE ERROR: i4_max_search_range_horz out of range\n");
943         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
944     }
945 
946     if(ps_static_cfg_prms->s_config_prms.i4_max_search_range_vert < 32 ||
947        ps_static_cfg_prms->s_config_prms.i4_max_search_range_vert > 256)
948     {
949         error_code = IHEVCE_UNSUPPORTED_VERTICAL_SEARCH_RANGE;
950         ps_sys_api->ihevce_printf(
951             pv_cb_handle, "IHEVCE ERROR: i4_max_search_range_vert out of range\n");
952         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
953     }
954 
955     if(ps_static_cfg_prms->s_lap_prms.i4_rc_look_ahead_pics > NUM_LAP2_LOOK_AHEAD ||
956        ps_static_cfg_prms->s_lap_prms.i4_rc_look_ahead_pics < 0)
957     {
958         error_code = IHEVCE_UNSUPPORTED_LOOK_AHEAD;
959         ps_sys_api->ihevce_printf(
960             pv_cb_handle,
961             "IHEVCE ERROR: rc look ahead pc must be in range of 0 to NUM_LAP2_LOOK_AHEAD\n");
962         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
963     }
964 
965     /* Num res instances should be less than equal to IHEVCE_MAX_NUM_RESOLUTIONS */
966     if((i4_num_resolutions < 1) || (i4_num_resolutions > IHEVCE_MAX_NUM_RESOLUTIONS))
967     {
968         error_code = IHEVCE_NUM_MAX_RESOLUTIONS_NOT_SUPPORTED;
969         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid i4_num_resolutions \n");
970         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
971     }
972 
973     if((ps_static_cfg_prms->i4_res_id < 0) || (ps_static_cfg_prms->i4_res_id >= i4_num_resolutions))
974     {
975         error_code = IHEVCE_NUM_MAX_RESOLUTIONS_NOT_SUPPORTED;
976         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid i4_num_resolutions \n");
977         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
978     }
979 
980     if((ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out < 0) ||
981        (ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out > 1))
982     {
983         error_code = IHEVCE_INVALID_MRES_SINGLE_OUT;
984         ps_sys_api->ihevce_printf(
985             pv_cb_handle, "IHEVCE ERROR: invalid i4_mres_single_out value \n");
986         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
987     }
988 
989     if((ps_static_cfg_prms->i4_save_recon) &&
990        (1 == ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out))
991     {
992         ps_sys_api->ihevce_printf(
993             pv_cb_handle,
994             "IHEVCE WARNING: i4_save_recon not supported for mres single out case \n");
995         ps_static_cfg_prms->i4_save_recon = 0;
996     }
997 
998     if((1 == i4_num_resolutions) && (1 == ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out))
999     {
1000         ps_sys_api->ihevce_printf(
1001             pv_cb_handle,
1002             "IHEVCE WARNING: i4_mres_single_out value changed to 0 for single resolution case \n");
1003         ps_static_cfg_prms->s_tgt_lyr_prms.i4_mres_single_out = 0;
1004     }
1005 
1006     if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_mbr_quality_setting < 0 ||
1007        ps_static_cfg_prms->s_tgt_lyr_prms.i4_mbr_quality_setting > 3)
1008     {
1009         error_code = IHEVCE_INVALID_MBR_QUALITY_SETTING;
1010         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid mbr quality setting\n");
1011         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1012     }
1013 
1014     if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_multi_res_layer_reuse != 0)
1015     {
1016         error_code = IHEVCE_MULTI_RES_LAYER_REUSE_NOT_SUPPORTED;
1017         ps_sys_api->ihevce_printf(
1018             pv_cb_handle,
1019             "IHEVCE ERROR: reuse of info across resolution is not currently supported \n");
1020         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1021     }
1022 
1023     for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1024     {
1025         WORD32 codec_level_index, quality_preset, height, width, frm_rate_scale_factor;
1026         WORD32 br_ctr;
1027         UWORD32 u4_luma_sample_rate;
1028         WORD32 max_dpb_size;
1029         WORD32 i4_field_pic = ps_static_cfg_prms->s_src_prms.i4_field_pic;
1030 
1031         codec_level_index = ihevce_get_level_index(
1032             ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level);
1033         quality_preset =
1034             ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_quality_preset;
1035         height = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_height;
1036         width = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_width;
1037         frm_rate_scale_factor = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1038                                     .i4_frm_rate_scale_factor;
1039         /* Check error for max picture size(luma) for the given level */
1040         if((width * height) > g_as_level_data[codec_level_index].i4_max_luma_picture_size)
1041         {
1042             error_code = IHEVCE_PIC_SIZE_NOT_SUPPORTED;
1043             ps_sys_api->ihevce_printf(
1044                 pv_cb_handle,
1045                 "IHEVCE ERROR: (i4_tgt_width * i4_tgt_height) out of range for resolution number "
1046                 "'%d' codec level %d "
1047                 "\n",
1048                 i4_resolution_id,
1049                 codec_level_index);
1050             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1051         }
1052 
1053         if((width * height) <= (g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 2))
1054         {
1055             max_dpb_size = 16;
1056         }
1057         else if((width * height) <= (g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 1))
1058         {
1059             max_dpb_size = 12;
1060         }
1061         else if(
1062             (width * height) <=
1063             (3 * g_as_level_data[codec_level_index].i4_max_luma_picture_size >> 2))
1064         {
1065             max_dpb_size = 8;
1066         }
1067         else
1068         {
1069             max_dpb_size = 6;
1070         }
1071 
1072         /* DPB check */
1073         if((((DEFAULT_MAX_REFERENCE_PICS - i4_field_pic) /*max reference*/ + 2) << i4_field_pic) >
1074            max_dpb_size)
1075         {
1076             error_code = IHEVCE_CODEC_LEVEL_NOT_SUPPORTED;
1077             ps_sys_api->ihevce_printf(
1078                 pv_cb_handle, "IHEVCE ERROR: i4_codec_level should be set correct \n");
1079             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1080         }
1081 
1082         if((quality_preset > IHEVCE_QUALITY_P7) || (quality_preset < 0) || (quality_preset == 1))
1083         {
1084             error_code = IHEVCE_INVALID_QUALITY_PRESET_INPUT;
1085             ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_quality_preset invalid \n");
1086             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1087         }
1088 
1089         /* Error checks for target width and height */
1090         if((height > HEVCE_MAX_HEIGHT) || (height < HEVCE_MIN_HEIGHT) ||
1091            (height != ps_static_cfg_prms->s_src_prms.i4_height))
1092         {
1093             error_code = IHEVCE_TGT_HEIGHT_NOT_SUPPORTED;
1094             ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Target height not supported\n");
1095             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1096         }
1097 
1098         if((width > HEVCE_MAX_WIDTH) || (width < HEVCE_MIN_WIDTH) ||
1099            (width != ps_static_cfg_prms->s_src_prms.i4_width))
1100         {
1101             error_code = IHEVCE_TGT_WIDTH_NOT_SUPPORTED;
1102             ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Target width not supported\n");
1103             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1104         }
1105 
1106         /* Error checks for the codec level */
1107         if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level >
1108            LEVEL6)
1109         {
1110             error_code = IHEVCE_CODEC_LEVEL_NOT_SUPPORTED;
1111             ps_sys_api->ihevce_printf(
1112                 pv_cb_handle,
1113                 "IHEVCE ERROR: i4_codec_level should be set to a max value of 153 \n");
1114             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1115         }
1116 
1117         if(frm_rate_scale_factor != 1)
1118         {
1119             error_code = IHEVCE_TGT_FRAME_RATE_SCALING_NOT_SUPPORTED;
1120             ps_sys_api->ihevce_printf(
1121                 pv_cb_handle, "IHEVCE ERROR:  Target frame rate scaler should be 1 \n");
1122             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1123         }
1124 
1125         u4_luma_sample_rate = (UWORD32)(width * height);
1126         u4_luma_sample_rate *= (UWORD32)(
1127             ps_static_cfg_prms->s_src_prms.i4_frm_rate_num /
1128             (ps_static_cfg_prms->s_src_prms.i4_frm_rate_denom * frm_rate_scale_factor));
1129         /* Check error for max samples rate (frame rate * luma picture size) for the given level */
1130         if(u4_luma_sample_rate > g_as_level_data[codec_level_index].u4_max_luma_sample_rate)
1131         {
1132             error_code = IHEVCE_LUMA_SAMPLE_RATE_NOT_SUPPORTED;
1133             ps_sys_api->ihevce_printf(
1134                 pv_cb_handle,
1135                 "IHEVCE ERROR: input sample rate (i4_src_width * i4_src_height * i4_frm_rate_num / "
1136                 "i4_frm_rate_denom ) "
1137                 "exceeds u4_max_luma_sample_rate\n");
1138             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1139         }
1140 
1141         /* Num instances should be less than equal to IHEVCE_MAX_NUM_BITRATES */
1142         if((ai4_num_bitrate_instances[i4_resolution_id] < 1) ||
1143            (ai4_num_bitrate_instances[i4_resolution_id] > IHEVCE_MAX_NUM_BITRATES))
1144         {
1145             error_code = IHEVCE_INVALID_NUM_BR_INSTANCES;
1146             ps_sys_api->ihevce_printf(
1147                 pv_cb_handle, "IHEVCE ERROR: invalid i4_num_bitrate_instances \n");
1148             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1149         }
1150 
1151         /* check for codec tier */
1152         if((ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier > HIGH_TIER) ||
1153            (ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier < MAIN_TIER))
1154         {
1155             error_code = IHEVC_CODEC_TIER_NOT_SUPPORTED;
1156             ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: Codec tier  out of range\n");
1157             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1158         }
1159 
1160         if((ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_codec_level <
1161             120) &&
1162            (ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier == HIGH_TIER))
1163         {
1164             error_code = IHEVC_CODEC_TIER_NOT_SUPPORTED;
1165             ps_sys_api->ihevce_printf(
1166                 pv_cb_handle, "IHEVCE ERROR: Codec tier = HIGH TIER Not supported below Level 4\n");
1167             return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1168         }
1169 
1170         /* Check error for max bitrate for the given level */
1171         for(br_ctr = 0; br_ctr < ai4_num_bitrate_instances[i4_resolution_id]; br_ctr++)
1172         {
1173             WORD32 frame_qp = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1174                                   .ai4_frame_qp[br_ctr];
1175             WORD32 tgt_bitrate = ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1176                                      .ai4_tgt_bitrate[br_ctr];
1177             WORD32 i4_max_bit_rate =
1178                 g_as_level_data[codec_level_index]
1179                     .i4_max_bit_rate[ps_static_cfg_prms->s_out_strm_prms.i4_codec_tier];
1180             WORD32 peak_bitrate;
1181 
1182             if(frame_qp > MAX_HEVC_QP || frame_qp < MIN_HEVC_QP)
1183             {
1184                 error_code = IHEVCE_UNSUPPORTED_FRAME_QP;
1185                 ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_frame_qp out of range\n");
1186                 return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1187             }
1188 
1189             if(tgt_bitrate > i4_max_bit_rate * CBP_VCL_FACTOR || tgt_bitrate < MIN_BITRATE)
1190             {
1191                 error_code = IHEVCE_BITRATE_NOT_SUPPORTED;
1192                 ps_sys_api->ihevce_printf(
1193                     pv_cb_handle,
1194                     "IHEVCE ERROR: i4_tgt_bitrate %d out of range for resolution %dX%d "
1195                     "bitrate should be within [%d .. %d]\n",
1196                     tgt_bitrate,
1197                     width, height,
1198                     MIN_BITRATE, i4_max_bit_rate * CBP_VCL_FACTOR);
1199                 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1200             }
1201 
1202             peak_bitrate = tgt_bitrate << 1;
1203             peak_bitrate = MIN(peak_bitrate, i4_max_bit_rate * 1000);
1204             ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1205                 .ai4_peak_bitrate[br_ctr] = peak_bitrate;
1206             ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id]
1207                 .ai4_max_vbv_buffer_size[br_ctr] = peak_bitrate;
1208         }
1209     }
1210 
1211     if((ps_static_cfg_prms->i4_br_id < 0) ||
1212        (ps_static_cfg_prms->i4_br_id >= ai4_num_bitrate_instances[ps_static_cfg_prms->i4_res_id]))
1213     {
1214         error_code = IHEVCE_INVALID_NUM_BR_INSTANCES;
1215         ps_sys_api->ihevce_printf(
1216             pv_cb_handle, "IHEVCE ERROR: invalid i4_num_bitrate_instances \n");
1217         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1218     }
1219 
1220     /* Check error for rate control mode for the given level */
1221     if(ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 2 &&
1222        ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 3 &&
1223        ps_static_cfg_prms->s_config_prms.i4_rate_control_mode != 5)
1224     {
1225         error_code = IHEVCE_RATE_CONTROL_MDOE_NOT_SUPPORTED;
1226         ps_sys_api->ihevce_printf(
1227             pv_cb_handle, "IHEVCE ERROR: i4_rate_control_mode out of range\n");
1228         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1229     }
1230 
1231     /* Check error for pass number */
1232     if(ps_static_cfg_prms->s_pass_prms.i4_pass != 0)
1233     {
1234         error_code = IHEVCE_RATE_CONTROL_PASS_INVALID;
1235         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_pass out of range\n");
1236         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1237     }
1238 
1239     /* Check error for cu level qp modultion for the given level */
1240     if(ps_static_cfg_prms->s_config_prms.i4_cu_level_rc != 0 &&
1241        ps_static_cfg_prms->s_config_prms.i4_cu_level_rc != 1)
1242     {
1243         error_code = IHEVCE_RATE_CONTROL_MDOE_NOT_SUPPORTED;
1244         ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: i4_cu_level_rc out of range\n");
1245         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1246     }
1247 
1248     /* size error checks for the api structures */
1249     if(ps_static_cfg_prms->i4_size != sizeof(ihevce_static_cfg_params_t))
1250     {
1251         error_code = IHEVCE_INVALID_SIZE;
1252         ps_sys_api->ihevce_printf(
1253             pv_cb_handle,
1254             "IHEVCE ERROR: Size element of ihevce_static_cfg_params_t is not matching with actual "
1255             "size");
1256         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1257     }
1258     if(ps_static_cfg_prms->s_src_prms.i4_size != sizeof(ihevce_src_params_t))
1259     {
1260         error_code = IHEVCE_INVALID_SIZE;
1261         ps_sys_api->ihevce_printf(
1262             pv_cb_handle,
1263             "IHEVCE ERROR: Size element of ihevce_src_params_t is not matching with actual size");
1264         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1265     }
1266     if(ps_static_cfg_prms->s_tgt_lyr_prms.i4_size != sizeof(ihevce_tgt_layer_params_t))
1267     {
1268         error_code = IHEVCE_INVALID_SIZE;
1269         ps_sys_api->ihevce_printf(
1270             pv_cb_handle,
1271             "IHEVCE ERROR: Size element of ihevce_tgt_layer_params_t is not matching with actual "
1272             "size");
1273         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1274     }
1275     if(ps_static_cfg_prms->s_out_strm_prms.i4_size != sizeof(ihevce_out_strm_params_t))
1276     {
1277         error_code = IHEVCE_INVALID_SIZE;
1278         ps_sys_api->ihevce_printf(
1279             pv_cb_handle,
1280             "IHEVCE ERROR: Size element of ihevce_out_strm_params_t is not matching with actual "
1281             "size");
1282         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1283     }
1284     if(ps_static_cfg_prms->s_coding_tools_prms.i4_size != sizeof(ihevce_coding_params_t))
1285     {
1286         error_code = IHEVCE_INVALID_SIZE;
1287         ps_sys_api->ihevce_printf(
1288             pv_cb_handle,
1289             "IHEVCE ERROR: Size element of ihevce_coding_params_t is not matching with actual "
1290             "size");
1291         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1292     }
1293     if(ps_static_cfg_prms->s_config_prms.i4_size != sizeof(ihevce_config_prms_t))
1294     {
1295         error_code = IHEVCE_INVALID_SIZE;
1296         ps_sys_api->ihevce_printf(
1297             pv_cb_handle,
1298             "IHEVCE ERROR: Size element of ihevce_config_prms_t is not matching with actual size");
1299         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1300     }
1301     if(ps_static_cfg_prms->s_multi_thrd_prms.i4_size != sizeof(ihevce_static_multi_thread_params_t))
1302     {
1303         error_code = IHEVCE_INVALID_SIZE;
1304         ps_sys_api->ihevce_printf(
1305             pv_cb_handle,
1306             "IHEVCE ERROR: Size element of ihevce_static_multi_thread_params_t is not matching "
1307             "with actual size");
1308         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1309     }
1310     for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1311     {
1312         if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_size !=
1313            sizeof(ihevce_tgt_params_t))
1314         {
1315             error_code = IHEVCE_INVALID_SIZE;
1316             ps_sys_api->ihevce_printf(
1317                 pv_cb_handle,
1318                 "IHEVCE ERROR: Size element of ihevce_tgt_params_t is not matching with actual "
1319                 "size");
1320             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1321         }
1322     }
1323 
1324     if(ps_static_cfg_prms->s_lap_prms.i4_size != sizeof(ihevce_lap_params_t))
1325     {
1326         error_code = IHEVCE_INVALID_SIZE;
1327         ps_sys_api->ihevce_printf(
1328             pv_cb_handle,
1329             "IHEVCE ERROR: Size element of ihevce_lap_params_t is not matching with actual size");
1330         return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1331     }
1332 
1333     for(i4_resolution_id = 0; i4_resolution_id < i4_num_resolutions; i4_resolution_id++)
1334     {
1335         if(ps_static_cfg_prms->s_tgt_lyr_prms.as_tgt_params[i4_resolution_id].i4_size !=
1336            sizeof(ihevce_tgt_params_t))
1337         {
1338             error_code = IHEVCE_INVALID_SIZE;
1339             ps_sys_api->ihevce_printf(
1340                 pv_cb_handle,
1341                 "IHEVCE ERROR: Size element of ihevce_tgt_params_t is not matching with actual "
1342                 "size");
1343             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1344         }
1345     }
1346 
1347 #ifndef DISABLE_SEI
1348     /* Check SEI related error checks */
1349     if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_enable_flag)
1350     {
1351         WORD32 i;
1352         /* Check values for i4_sei_hash_flags */
1353         if(!((ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 2) ||
1354              (ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 3) ||
1355              (ps_static_cfg_prms->s_out_strm_prms.i4_decoded_pic_hash_sei_flag == 0)))
1356         {
1357             error_code = IHEVCE_SEI_HASH_VALUE_NOT_SUPPORTED;
1358             ps_sys_api->ihevce_printf(
1359                 pv_cb_handle, "IHEVCE ERROR: i4_sei_hash_flags out of range\n");
1360             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1361         }
1362 
1363         /* Content Light Level Info error check */
1364         if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_cll_enable > 1) ||
1365            (ps_static_cfg_prms->s_out_strm_prms.i4_sei_cll_enable < 0))
1366         {
1367             error_code = IHEVCE_SEI_CLL_ENABLE_OUT_OF_RANGE;
1368             ps_sys_api->ihevce_printf(
1369                 pv_cb_handle, "IHEVCE ERROR: i4_sei_cll_enable out of range\n");
1370             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1371         }
1372 
1373         if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_buffer_period_flags ||
1374             ps_static_cfg_prms->s_out_strm_prms.i4_sei_pic_timing_flags) &&
1375            (!ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable))
1376         {
1377             error_code = IHEVCE_SEI_ENABLED_VUI_DISABLED;
1378             ps_sys_api->ihevce_printf(
1379                 pv_cb_handle,
1380                 "IHEVCE ERROR: Both SEI and VUI ought to be enabled when either "
1381                 "'i4_sei_buffer_period_flags' or "
1382                 "'i4_sei_pic_timing_flags' are enabled\n");
1383             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1384         }
1385 
1386         if((1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_buffer_period_flags) &&
1387            (3 == ps_static_cfg_prms->s_config_prms.i4_rate_control_mode))
1388         {
1389             error_code = IHEVCE_SEI_MESSAGES_DEPENDENCY;
1390             ps_sys_api->ihevce_printf(
1391                 pv_cb_handle,
1392                 "IHEVCE ERROR: i4_sei_buffer_period_flags should be disabled for CQP mode of Rate "
1393                 "control \n");
1394             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1395         }
1396 
1397         /* Check values for i4_sei_mastering_disp_colour_vol_flags */
1398         if((ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags != 0) &&
1399            (ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags != 1))
1400         {
1401             error_code = IHEVCE_MASTERING_DISP_COL_VOL_OUT_OF_RANGE;
1402             ps_sys_api->ihevce_printf(
1403                 pv_cb_handle,
1404                 "IHEVCE ERROR: i4_sei_mastering_disp_colour_vol_flags out of range\n");
1405             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1406         }
1407 
1408         if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_sei_mastering_disp_colour_vol_flags)
1409         {
1410             /* Check values for u2_display_primaries_x and u2_display_primaries_y */
1411             for(i = 0; i < 3; i++)
1412             {
1413                 if((ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_x[i] > 50000))
1414                 {
1415                     error_code = IHEVCE_DISPLAY_PRIMARY_X_OUT_OF_RANGE;
1416                     ps_sys_api->ihevce_printf(
1417                         pv_cb_handle, "IHEVCE ERROR: au2_display_primaries_x out of range\n");
1418                     return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1419                 }
1420 
1421                 if((ps_static_cfg_prms->s_out_strm_prms.au2_display_primaries_y[i] > 50000))
1422                 {
1423                     error_code = IHEVCE_DISPLAY_PRIMARY_Y_OUT_OF_RANGE;
1424                     ps_sys_api->ihevce_printf(
1425                         pv_cb_handle, "IHEVCE ERROR: au2_display_primaries_y out of range\n");
1426                     return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1427                 }
1428             }
1429 
1430             if((ps_static_cfg_prms->s_out_strm_prms.u2_white_point_x > 50000))
1431             {
1432                 error_code = IHEVCE_WHITE_POINT_X_OUT_OF_RANGE;
1433                 ps_sys_api->ihevce_printf(
1434                     pv_cb_handle, "IHEVCE ERROR: u2_white_point_x out of range\n");
1435                 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1436             }
1437 
1438             if((ps_static_cfg_prms->s_out_strm_prms.u2_white_point_y > 50000))
1439             {
1440                 error_code = IHEVCE_WHITE_POINT_Y_OUT_OF_RANGE;
1441                 ps_sys_api->ihevce_printf(
1442                     pv_cb_handle, "IHEVCE ERROR: u2_white_point_y out of range\n");
1443                 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1444             }
1445 
1446             if(ps_static_cfg_prms->s_out_strm_prms.u4_max_display_mastering_luminance <=
1447                ps_static_cfg_prms->s_out_strm_prms.u4_min_display_mastering_luminance)
1448             {
1449                 error_code = IHEVCE_MAX_DISP_MATERING_LUM_OUT_OF_RANGE;
1450                 ps_sys_api->ihevce_printf(
1451                     pv_cb_handle,
1452                     "IHEVCE ERROR: u4_max_display_mastering_luminance should be greater then "
1453                     "u4_min_display_mastering_luminance \n");
1454                 return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1455             }
1456         }
1457     }
1458 #endif
1459 
1460     if(1 == ps_static_cfg_prms->s_out_strm_prms.i4_vui_enable)
1461     {
1462         /* validate static vui parameters */
1463         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_aspect_ratio_info_present_flag & 0xFE) > 0))
1464         {
1465             error_code = IHEVC_INVALID_ASPECT_RATIO_PARAMS;
1466             ps_sys_api->ihevce_printf(
1467                 pv_cb_handle, "IHEVCE ERROR: invalid aspect ratio parameters\n");
1468             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1469         }
1470 
1471         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_info_present_flag & 0xFE) > 0) ||
1472            ((ps_static_cfg_prms->s_vui_sei_prms.u1_overscan_appropriate_flag & 0xFE) > 0))
1473         {
1474             error_code = IHEVC_INVALID_OVERSCAN_PARAMS;
1475             ps_sys_api->ihevce_printf(pv_cb_handle, "IHEVCE ERROR: invalid overscan parameters\n");
1476             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1477         }
1478 
1479         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_video_signal_type_present_flag & 0xFE) > 0) ||
1480            (ps_static_cfg_prms->s_vui_sei_prms.u1_video_format > 5) ||
1481            ((ps_static_cfg_prms->s_vui_sei_prms.u1_video_full_range_flag & 0xFE) > 0))
1482         {
1483             error_code = IHEVC_INVALID_VIDEO_PARAMS;
1484             ps_sys_api->ihevce_printf(
1485                 pv_cb_handle, "IHEVCE ERROR: invalid video signal type parameters\n");
1486             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1487         }
1488 
1489         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_colour_description_present_flag & 0xFE) > 0))
1490         {
1491             error_code = IHEVC_INVALID_COLOUR_PARAMS;
1492             ps_sys_api->ihevce_printf(
1493                 pv_cb_handle, "IHEVCE ERROR: invalid colour description parameters\n");
1494             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1495         }
1496 
1497         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_loc_info_present_flag & 0xFE) > 0) ||
1498            (ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_top_field > 5) ||
1499            (ps_static_cfg_prms->s_vui_sei_prms.u1_chroma_sample_loc_type_bottom_field > 5))
1500         {
1501             error_code = IHEVC_INVALID_CHROMA_PARAMS;
1502             ps_sys_api->ihevce_printf(
1503                 pv_cb_handle, "IHEVCE ERROR: invalid chroma info parameters\n");
1504             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1505         }
1506 
1507         if((ps_static_cfg_prms->s_vui_sei_prms.u1_timing_info_present_flag & 0xFE) > 0)
1508         {
1509             error_code = IHEVC_INVALID_TIMING_INFO_PARAM;
1510             ps_sys_api->ihevce_printf(
1511                 pv_cb_handle, "IHEVCE ERROR: invalid timing info present flag\n");
1512             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1513         }
1514 
1515         if(((ps_static_cfg_prms->s_vui_sei_prms.u1_vui_hrd_parameters_present_flag & 0xFE) > 0) ||
1516            ((ps_static_cfg_prms->s_vui_sei_prms.u1_nal_hrd_parameters_present_flag & 0xFE) > 0))
1517         {
1518             error_code = IHEVC_INVALID_HRD_PRESENT_PARAMS;
1519             ps_sys_api->ihevce_printf(
1520                 pv_cb_handle, "IHEVCE ERROR: invalid vui or vcl hrd parameters present flag\n");
1521             return (IHEVCE_SETUNSUPPORTEDINPUT(error_code));
1522         }
1523     }
1524 
1525     error_code = ihevce_validate_tile_config_params(ps_static_cfg_prms);
1526     if(IHEVCE_SUCCESS != error_code)
1527     {
1528         return error_code;
1529     }
1530 
1531     if(ps_static_cfg_prms->s_slice_params.i4_slice_segment_mode != 0)
1532     {
1533         error_code = IHEVCE_BAD_SLICE_PARAMS;
1534         ps_sys_api->ihevce_printf(
1535             pv_cb_handle, "IHEVCE ERROR: i4_slice_segment_mode should be 0 \n");
1536         return IHEVCE_SETUNSUPPORTEDINPUT(error_code);
1537     }
1538 
1539     return IHEVCE_SUCCESS;
1540 }
1541 
1542 /*!
1543 ******************************************************************************
1544 * \if Function name : ihevce_get_level_index \endif
1545 *
1546 * \brief
1547 *    This function returns the index of level based on codec_level value
1548 *    Please see the LEVEL_T enum def
1549 *
1550 * \param[in] Codec Level
1551 *
1552 * \return
1553 *    Index of Codec level
1554 *
1555 * \author
1556 *    Ittiam
1557 *
1558 *****************************************************************************
1559 */
ihevce_get_level_index(WORD32 i4_codec_level)1560 WORD32 ihevce_get_level_index(WORD32 i4_codec_level)
1561 {
1562     switch(i4_codec_level)
1563     {
1564     case LEVEL1:
1565         return 0;
1566     case LEVEL2:
1567         return 1;
1568     case LEVEL2_1:
1569         return 2;
1570     case LEVEL3:
1571         return 3;
1572     case LEVEL3_1:
1573         return 4;
1574     case LEVEL4:
1575         return 5;
1576     case LEVEL4_1:
1577         return 6;
1578     case LEVEL5:
1579         return 7;
1580     case LEVEL5_1:
1581         return 8;
1582     case LEVEL5_2:
1583         return 9;
1584     case LEVEL6:
1585         return 10;
1586     case LEVEL6_1:
1587         return 11;
1588     case LEVEL6_2:
1589         return 12;
1590     default:
1591         return 0;
1592     }
1593 }
1594