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