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