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 #include <stdio.h>
21 #include "ixheaac_type_def.h"
22 #include "ixheaac_error_standards.h"
23 #include "ixheaacd_error_handler.h"
24
25 /*****************************************************************************/
26 /* Global memory constants */
27 /*****************************************************************************/
28 /*****************************************************************************/
29 /* Ittiam enhaacplus_dec ErrorCode Definitions */
30 /*****************************************************************************/
31 /*****************************************************************************/
32 /* Class 0: API Errors
33 */
34 /*****************************************************************************/
35 /* Non Fatal Errors */
36 pWORD8 ixheaacd_ppb_api_non_fatal[IA_MAX_ERROR_SUB_CODE] = {
37 (pWORD8) "No Error",
38 (pWORD8) "API Command not supported",
39 (pWORD8) "API Command type not supported"};
40 /* Fatal Errors */
41 pWORD8 ixheaacd_ppb_api_fatal[IA_MAX_ERROR_SUB_CODE] = {
42 (pWORD8) "Invalid Memory Table Index",
43 (pWORD8) "Invalid Library ID String Index",
44 (pWORD8) "NULL Pointer: Memory Allocation Error",
45 (pWORD8) "Invalid Config Param",
46 (pWORD8) "Invalid Execute type",
47 (pWORD8) "Invalid Command",
48 (pWORD8) "Memory Allocation Error: Alignment requirement not met"};
49 /*****************************************************************************/
50 /* Class 1: Configuration Errors
51 */
52 /*****************************************************************************/
53 /* Non Fatal Errors */
54 pWORD8 ixheaacd_ppb_config_non_fatal[IA_MAX_ERROR_SUB_CODE] = {
55 (pWORD8) "Invalid Output PCM WORD Size. Setting to default, 16 ",
56 (pWORD8) "Invalid Down-mix flag option. Setting to default, 0 ",
57 (pWORD8) "Invalid eSBR PS flag option. Setting to default, 0 ",
58 (pWORD8) "Invalid downmix to stereo flag option. Setting to default, 0 ",
59 (pWORD8) "Invalid interleave to stereo flag option. Setting to default, 1 ",
60 (pWORD8) "Invalid downsample flag option. Setting to default, 0 ",
61 (pWORD8) "Invalid peak limiter flag option. Setting to default, 1 ",
62 (pWORD8) "Invalid MP4 flag option. Setting to default, 0 ",
63 (pWORD8) "Invalid maximum number of channels. limiting to between 2 and 8",
64 (pWORD8) "Invalid instance for coupling channel. Setting to default 1",
65 (pWORD8) "Invalid error concealment flag option. Setting to default 0",
66 (pWORD8) "Invalid Disable Sync flag option. Setting to default, 0 ",
67 (pWORD8) "Invalid Auto SBR upsample option. Setting to default, 1 ",
68 (pWORD8) "Invalid DRC heavy compression flag option. Setting to default 0",
69 (pWORD8) "Invalid DRC cut value",
70 (pWORD8) "Invalid DRC boost value",
71 (pWORD8) "Invalid DRC target",
72 (pWORD8) "Invalid Frame size",
73 (pWORD8) "Invalid LD testing flag option. Setting to default 0",
74 (pWORD8) "Invalid effect type",
75 (pWORD8) "Invalid target loudness value",
76 (pWORD8) "Invalid HQ eSBR flag option. Setting to default 0",
77 (pWORD8) "Invalid frame length flag option. Setting to default 0",
78 (pWORD8) "Invalid eSBR flag option. Setting to default 1"};
79 /* Fatal Errors */
80 pWORD8 ixheaacd_ppb_config_fatal[IA_MAX_ERROR_SUB_CODE] = {
81 (pWORD8) "Invalid Sample rate specified for RAW decoding"};
82 /*****************************************************************************/
83 /* Class 2: Initialization Errors
84 */
85 /*****************************************************************************/
86 /* Non Fatal Errors */
87 pWORD8 ixheaacd_ppb_init_non_fatal[IA_MAX_ERROR_SUB_CODE] = {
88 (pWORD8) "Header not found at the beginning of input data continuing syncing",
89 (pWORD8) "Invalid number of QMF bands", (pWORD8) "Decoder initialization failed",
90 (pWORD8) "Input bytes insufficient for decoding", (pWORD8) "Error in AAC decoding"};
91 /* Fatal Errors */
92 pWORD8 ixheaacd_ppb_init_fatal[IA_MAX_ERROR_SUB_CODE] = {
93 (pWORD8) "AAC Decoder initialization failed",
94 (pWORD8) "End of input reached during initialization",
95 (pWORD8) "No. of channels in stream greater than max channels defined",
96 (pWORD8) "Audio object type is not supported",
97 (pWORD8) "Decoder initialization failed",
98 (pWORD8) "Channel coupling not supported"};
99 /*****************************************************************************/
100 /* Class 3: Execution Errors
101 */
102 /*****************************************************************************/
103 /* Non Fatal Errors */
104 pWORD8 ixheaacd_ppb_exe_non_fatal[IA_MAX_ERROR_SUB_CODE] = {
105 (pWORD8) "ADTS syncronization is lost. Re-syncing",
106 (pWORD8) "Though SBR was present in previous frame, not present in current"
107 "frame (SBR turned off)",
108 (pWORD8) "SBR was not present in previous frame, but it is present in"
109 "current frame (SBR turned on)",
110 (pWORD8) "ADTS Header CRC failed.Re-syncing",
111 (pWORD8) "Input bytes insufficient for decoding",
112 (pWORD8) "Element instance tag mismatch, because of new channel mode",
113 (pWORD8) "max huffman decoded value exceeded",
114 (pWORD8) "Error in AAC decoding",
115 (pWORD8) "Scale factor exceeds the transmitted boundary",
116 (pWORD8) "Gain control not supported",
117 (pWORD8) "Filter Order of TNS data is greater than maximum order",
118 (pWORD8) "LTP data found, not supported",
119 (pWORD8) "The base sampling frequency has changed in ADTS header",
120 (pWORD8) "Pulse Data exceeds the permitted boundary",
121 (pWORD8) "Invalid code ixheaacd_book number in ia_huffman_data_type decoding",
122 (pWORD8) "Channel index not within allowed range",
123 (pWORD8) "Smoothing mode not within allowed range",
124 (pWORD8) "Smoothing time not within allowed range",
125 (pWORD8) "Extension type in the bitstream not within allowed range",
126 (pWORD8) "QMF update type in the bitstream not within allowed range",
127 (pWORD8) "Window type in the bitstream not within allowed range",
128 (pWORD8) "Evaluated sine parameter not within allowed range"};
129 /* Fatal Errors */
130 pWORD8 ixheaacd_ppb_exe_fatal[IA_MAX_ERROR_SUB_CODE] = {
131 (pWORD8) "Channel coupling not supported",
132 (pWORD8) "TNS data range is errorneous",
133 (pWORD8) "Invalid LOAS header",
134 (pWORD8) "Invalid DRC data",
135 (pWORD8) "MPS reshaping input not valid",
136 (pWORD8) "Tree config present in bit stream not valid",
137 (pWORD8) "Number of timeslots not valid",
138 (pWORD8) "MPS dequantization parameter not valid",
139 (pWORD8) "MPS quantization mode not valid",
140 (pWORD8) "MPS input channels not valid",
141 (pWORD8) "Bitstream data in arbitrary downmix spatial frame not valid",
142 (pWORD8) "Window sequence value not valid",
143 (pWORD8) "Temporal shape config in the bitstream not valid",
144 (pWORD8) "3D audio HRTF set present in the bitstream not valid",
145 (pWORD8) "TTT mode read from the bitstream not valid",
146 (pWORD8) "Number of OTT boxes in the bitstream not valid",
147 (pWORD8) "Number of parameter sets present in the bitstream not valid",
148 (pWORD8) "Mapping of index data failed during decoding",
149 (pWORD8) "Number of parameter bands present in the bitstream not valid"};
150
151 /*****************************************************************************/
152 /* error info structure */
153 /*****************************************************************************/
154 /* The Module's Error Info Structure */
155 ia_error_info_struct ixheaacd_error_info = {
156 /* The Module Name */
157 (pWORD8) "Ittiam xheaac_dec",
158 {/* The Class Names */
159 (pWORD8) "API", (pWORD8) "Configuration", (pWORD8) "Initialization",
160 (pWORD8) "Execution", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "",
161 (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "",
162 (pWORD8) "", (pWORD8) "", (pWORD8) "xHeaac"},
163 {/* The Message Pointers */
164 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
165 NULL, NULL, NULL, NULL},
166 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
167 NULL, NULL, NULL, NULL}}};
168
169 /*****************************************************************************/
170 /* */
171 /* Function name : ixheaacd_error_handler_init */
172 /* */
173 /* Description : Initialize the error struct with string pointers */
174 /* */
175 /* Inputs : none */
176 /* */
177 /* Globals : ia_error_info_struct ixheaacd_error_info */
178 /* pWORD8 ixheaacd_ppb_api_non_fatal */
179 /* pWORD8 ixheaacd_ppb_api_fatal */
180 /* pWORD8 ixheaacd_ppb_config_non_fatal */
181 /* pWORD8 ixheaacd_ppb_config_fatal */
182 /* pWORD8 ixheaacd_ppb_init_non_fatal */
183 /* pWORD8 ixheaacd_ppb_init_fatal */
184 /* pWORD8 ixheaacd_ppb_exe_non_fatal */
185 /* pWORD8 ixheaacd_ppb_exe_fatal */
186 /* */
187 /* Processing : Init the struct with error string pointers */
188 /* */
189 /* Outputs : none */
190 /* */
191 /* Returns : none */
192 /* */
193 /* Issues : none */
194 /* */
195 /* Revision history : */
196 /* */
197 /* DD MM YYYY Author Changes */
198 /* 29 07 2005 Ittiam Created */
199 /* */
200 /*****************************************************************************/
201
ixheaacd_error_handler_init()202 VOID ixheaacd_error_handler_init() {
203 /* The Message Pointers */
204 ixheaacd_error_info.ppppb_error_msg_pointers[0][0] =
205 ixheaacd_ppb_api_non_fatal;
206 ixheaacd_error_info.ppppb_error_msg_pointers[1][0] = ixheaacd_ppb_api_fatal;
207 ixheaacd_error_info.ppppb_error_msg_pointers[0][1] =
208 ixheaacd_ppb_config_non_fatal;
209 ixheaacd_error_info.ppppb_error_msg_pointers[1][1] =
210 ixheaacd_ppb_config_fatal;
211 ixheaacd_error_info.ppppb_error_msg_pointers[0][2] =
212 ixheaacd_ppb_init_non_fatal;
213 ixheaacd_error_info.ppppb_error_msg_pointers[1][2] = ixheaacd_ppb_init_fatal;
214 ixheaacd_error_info.ppppb_error_msg_pointers[0][3] =
215 ixheaacd_ppb_exe_non_fatal;
216 ixheaacd_error_info.ppppb_error_msg_pointers[1][3] = ixheaacd_ppb_exe_fatal;
217 }
218
219 /*****************************************************************************/
220 /* ia_testbench ErrorCode Definitions */
221 /*****************************************************************************/
222 /*****************************************************************************/
223 /* Class 0: Memory & File Manager Errors
224 */
225 /*****************************************************************************/
226 /* Non Fatal Errors */
227 /* Fatal Errors */
228 pWORD8 ixheaacd_ppb_ia_testbench_mem_file_man_fatal[IA_MAX_ERROR_SUB_CODE] = {
229 (pWORD8) "Memory Allocation Error", (pWORD8) "File Open Failed"};
230
231 /*****************************************************************************/
232 /* error info structure */
233 /*****************************************************************************/
234 /* The Module's Error Info Structure */
235 ia_error_info_struct ixheaacd_ia_testbench_error_info = {
236 /* The Module Name */
237 (pWORD8) "ia_testbench",
238 {/* The Class Names */
239 (pWORD8) "Memory & File Manager", (pWORD8) "", (pWORD8) "", (pWORD8) "",
240 (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "",
241 (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "",
242 (pWORD8) "", (pWORD8) ""},
243 {/* The Message Pointers */
244 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
245 NULL, NULL, NULL, NULL},
246 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
247 NULL, NULL, NULL, NULL}}};
248
249 /*****************************************************************************/
250 /* */
251 /* Function name : ia_testbench_error_handler_init */
252 /* */
253 /* Description : Initialize the error struct with string pointers */
254 /* */
255 /* Inputs : none */
256 /* */
257 /* Globals : ia_error_info_struct ixheaacd_ia_testbench_error_info */
258 /* pWORD8 ixheaacd_ppb_ia_testbench_mem_file_man_fatal */
259 /* */
260 /* Processing : Init the struct with error string pointers */
261 /* */
262 /* Outputs : none */
263 /* */
264 /* Returns : none */
265 /* */
266 /* Issues : none */
267 /* */
268 /* Revision history : */
269 /* */
270 /* DD MM YYYY Author Changes */
271 /* 29 07 2005 Ittiam Created */
272 /* */
273 /*****************************************************************************/
274
ia_testbench_error_handler_init()275 VOID ia_testbench_error_handler_init() {
276 /* The Message Pointers */
277 ixheaacd_ia_testbench_error_info.ppppb_error_msg_pointers[1][0] =
278 ixheaacd_ppb_ia_testbench_mem_file_man_fatal;
279 }
280
281 /*****************************************************************************/
282 /* */
283 /* Function name : ixheaacd_error_handler */
284 /* */
285 /* Description : Called Prints the status error code from the err_info */
286 /* */
287 /* Inputs : ia_error_info_struct *p_mod_err_info (Error info struct) */
288 /* WORD8 *pb_context (Context of error) */
289 /* IA_ERRORCODE code (Error code) */
290 /* */
291 /* Globals : none */
292 /* */
293 /* Processing : whenever any module calls the errorhandler, it informs */
294 /* it about the module for which it is called and a context */
295 /* in which it was called in addition to the error_code */
296 /* the message is displayed based on the module's error */
297 /* message array that maps to the error_code the context */
298 /* gives specific info in which the error occured e.g. for */
299 /* testbench module, memory allocator can call the */
300 /* errorhandler for memory inavailability in various */
301 /* contexts like input_buf or output_buf e.g. for mp3_enc */
302 /* module, there can be various instances running. context */
303 /* can be used to identify the particular instance the */
304 /* error handler is being called for */
305 /* */
306 /* Outputs : None */
307 /* */
308 /* Returns : IA_ERRORCODE error_value (Error value) */
309 /* */
310 /* Issues : none */
311 /* */
312 /* Revision history : */
313 /* */
314 /* DD MM YYYY Author Changes */
315 /* 29 07 2005 Tejaswi/Vishal Created */
316 /* */
317 /*****************************************************************************/
318
ixheaacd_error_handler(ia_error_info_struct * p_mod_err_info,WORD8 * pb_context,IA_ERRORCODE code)319 IA_ERRORCODE ixheaacd_error_handler(ia_error_info_struct *p_mod_err_info,
320 WORD8 *pb_context, IA_ERRORCODE code) {
321 if (code == IA_NO_ERROR) {
322 return IA_NO_ERROR;
323 }
324 {
325 WORD is_fatal, err_class, err_sub_code;
326
327 if (code == IA_FATAL_ERROR)
328 is_fatal = 1;
329 else
330 is_fatal = (((UWORD)code & 0x8000) >> 15);
331
332 err_class = (((UWORD)code & 0x7800) >> 11);
333 err_sub_code = (((UWORD)code & 0x07FF));
334
335 if (!is_fatal) {
336 printf("non ");
337 }
338 printf("fatal error: ");
339
340 if (p_mod_err_info->pb_module_name != NULL) {
341 printf("%s: ", p_mod_err_info->pb_module_name);
342 }
343 if (p_mod_err_info->ppb_class_names[err_class] != NULL) {
344 printf("%s: ", p_mod_err_info->ppb_class_names[err_class]);
345 }
346 if (pb_context != NULL) {
347 printf("%s: ", pb_context);
348 }
349 if (err_sub_code >= IA_MAX_ERROR_SUB_CODE ||
350 p_mod_err_info->ppppb_error_msg_pointers[is_fatal][err_class]
351 [err_sub_code] == NULL) {
352 printf("error unlisted");
353 } else {
354 printf("%s\n",
355 p_mod_err_info
356 ->ppppb_error_msg_pointers[is_fatal][err_class][err_sub_code]);
357 }
358 }
359 return IA_NO_ERROR;
360 }