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