Package list faad2 / 1d3b94e
Update upstream source from tag 'upstream/2.10.0' Update to upstream version '2.10.0' with Debian dir 9db1d6b1b57c33956d04cb258118ab29239b7541 Fabian Greffrath 9 months ago
139 changed file(s) with 1314 addition(s) and 922 deletion(s). Raw diff Collapse all Expand all
0 2.10.0:
1 [ tatsuz ]
2 * updated Visual Studio projects to VS 2019 (#54)
3
4 [ Fabian Greffrath ]
5 * mp4read.c: fix stack-buffer-overflow in stringin()/ftypin()
6 * fix heap-buffer-overflow in mp4read.c
7
8 [ Clayton Smith ]
9 * Remove non-ASCII characters
10 * Remove trailing whitespace
11
12 [ Andrew Wesie ]
13 * Check return value of ltp_data.
14 * Restrict SBR frame length to 960 and 1024 samples.
15 * Support object type 29.
16 * Support implicit SBR signaling in frontend.
17 * Fix PNS decoding when only right channel is noise.
18 * Initialize element_id array with an invalid id.
19 * Fix NULL pointer dereferences.
20 * Fix infinite loop in adts_parse.
21 * Fix infinite loop in huffman_getescape.
22 * Check for error after each channel decode.
23 * Check for inconsistent number of channels.
24
025 2.9.2:
126 [ Michał Janiszewski ]
227 * Only use x86-assembly when explicitly on x86
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
182182 numfiles = 0;
183183
184184 Sleep(500);
185 }
185 }
186186
187187 DeleteCriticalSection(&mutex);
188188
2727 #define CREATEFONT(sz) \
2828 CreateFont((sz), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
2929 VARIABLE_PITCH | FF_SWISS, "")
30
30
3131 HANDLE event = NULL;
3232 int width = 130, height = 130;
3333 RECT bar1, bar2, vbrBR;
231231 set_outputFormat(iniSettings.outputFormat);
232232 set_fileType(iniSettings.fileType);
233233 set_object_type(iniSettings.object_type);
234
234
235235 for (frame = 0; frame < 8; frame++)
236236 hbm[frame] = LoadImage(hinst, MAKEINTRESOURCE(IDB_TF01 + frame), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
237237 frame = 0;
242242 DispatchMessage(&msg);
243243 }
244244
245 for (frame = 0; frame < 8; frame++)
245 for (frame = 0; frame < 8; frame++)
246246 DeleteObject(hbm[frame]);
247247
248248 return msg.wParam;
372372 if (animate || frame)
373373 {
374374 frame++;
375 if (frame > 7)
375 if (frame > 7)
376376 frame -= 8;
377377 }
378378 else
436436 return 0;
437437
438438 case WM_COMMAND:
439 switch (LOWORD(wParam))
439 switch (LOWORD(wParam))
440440 {
441441 case IDM_QUIT:
442442 WriteIniFile(INI_FILE);
445445 break;
446446 case IDM_ONTOP:
447447 set_always_on_top(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED);
448 break;
448 break;
449449 case IDM_LOGERR:
450450 set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED);
451451 break;
458458 }
459459 case IDM_VOLUME:
460460 {
461 int value =
461 int value =
462462 DialogBox(
463 hinst,
464 MAKEINTRESOURCE(IDD_VOLUME),
463 hinst,
464 MAKEINTRESOURCE(IDD_VOLUME),
465465 hwnd, QCProc);
466466
467467 if (value == -2)
483483 hdrop = (HANDLE)wParam;
484484 HandleDrag(hwnd, hdrop);
485485 return 0;
486
486
487487 case WM_DESTROY:
488488 decoding_done = 1;
489489 PostQuitMessage(0);
497497 * Encode parameters dialog procedures.
498498 */
499499
500 BOOL CALLBACK QCProc(HWND hwndDlg, UINT message,
501 WPARAM wParam, LPARAM lParam)
502 {
503 switch (message)
504 {
505 case WM_INITDIALOG:
506
500 BOOL CALLBACK QCProc(HWND hwndDlg, UINT message,
501 WPARAM wParam, LPARAM lParam)
502 {
503 switch (message)
504 {
505 case WM_INITDIALOG:
506
507507 if(iniSettings.decode_mode == 0)
508508 {
509509 CheckDlgButton(hwndDlg,IDC_PLAYBACK,TRUE);
578578 EndDialog(hwndDlg, -1);
579579 break;
580580
581 case WM_COMMAND:
582 switch (LOWORD(wParam))
581 case WM_COMMAND:
582 switch (LOWORD(wParam))
583583 {
584584 case IDC_BUTTON1:
585585 {
669669 break;
670670 }
671671 }
672 return FALSE;
672 return FALSE;
673673 }
674674
675675
3838 if (strlen(fmt) > 750)
3939 {
4040 sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
41 }
42 else
41 }
42 else
4343 {
4444 if (_filename != NULL && strlen(_filename) < 255)
4545 {
4848 }
4949
5050 va_start(ap, fmt);
51
51
5252 vsprintf(bufp, fmt, ap);
5353
5454 va_end(ap);
4141 #define IDM_QUIT 40019
4242
4343 // Next default values for new objects
44 //
44 //
4545 #ifdef APSTUDIO_INVOKED
4646 #ifndef APSTUDIO_READONLY_SYMBOLS
4747 #define _APS_NO_MFC 1
77 dnl - mpeg4ip plugin (requires mpeg4ip's libmp4v2 to be installed)
88
99 AC_PREREQ(2.50)
10 AC_INIT(faad2, 2.9.2)
10 AC_INIT(faad2, 2.10.0)
1111 AC_CONFIG_AUX_DIR(.)
1212 AM_INIT_AUTOMAKE([subdir-objects])
1313
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
203203 }
204204
205205 #endif /* GNU C library. */
206
206
207207 /* Handle permutation of arguments. */
208208
209209 /* Describe the part of ARGV that contains non-options that have
264264 temp = *first; *first = *last; *last = temp; first++; last--;
265265 }
266266 }
267
267
268268 /* Scan elements of ARGV (whose length is ARGC) for option characters
269269 given in OPTSTRING.
270270
679679 }
680680
681681 #endif /* _LIBC or not __GNU_LIBRARY__. */
682
682
683683 #ifdef TEST
684684
685685 /* Compile with -DTEST to make an executable for use in testing
153153 while ((b->bytes_into_buffer > 0) && (bytes > 0))
154154 {
155155 int chunk = min(bytes, b->bytes_into_buffer);
156
156
157157 bytes -= chunk;
158158 b->file_offset += chunk;
159159 b->bytes_consumed = chunk;
216216
217217 frame_length = ((((unsigned int)b->buffer[3] & 0x3)) << 11)
218218 | (((unsigned int)b->buffer[4]) << 3) | (b->buffer[5] >> 5);
219 if (frame_length == 0)
220 break;
219221
220222 t_framelength += frame_length;
221223
696698 /* update buffer indices */
697699 advance_buffer(&b, frameInfo.bytesconsumed);
698700
701 /* check if the inconsistent number of channels */
702 if (aufile != NULL && frameInfo.channels != aufile->channels)
703 frameInfo.error = 12;
704
699705 if (frameInfo.error > 0)
700706 {
701707 faad_fprintf(stderr, "Error: %s\n",
871877 if (NeAACDecAudioSpecificConfig(mp4config.asc.buf, mp4config.asc.size, &mp4ASC) >= 0)
872878 {
873879 if (mp4ASC.frameLengthFlag == 1) framesize = 960;
874 if (mp4ASC.sbr_present_flag == 1) framesize *= 2;
880 if (mp4ASC.sbr_present_flag == 1 || mp4ASC.forceUpSampling) framesize *= 2;
875881 }
876882 }
877883
9494 if (!txt[size])
9595 break;
9696 }
97 txt[sizemax-1] = '\0';
9798
9899 return size;
99100 }
342343 u32in();
343344 // Number of entries
344345 mp4config.frame.ents = u32in();
345 // fixme: check atom size
346
347 if (!(mp4config.frame.ents + 1))
348 return ERR_FAIL;
349
346350 mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)
347351 * (mp4config.frame.ents + 1));
348352
101101 fprintf(stderr, "\nFATAL: Malloc failed\n\n");
102102 exit(-1);
103103 }
104
104
105105 for(i = 0; i < nArgs; i++)
106106 {
107107 (*argv)[i] = utf16_to_utf8(szArglist[i]);
118118 void free_commandline_arguments_utf8(int *argc, char ***argv)
119119 {
120120 int i = 0;
121
121
122122 if(*argv != NULL)
123123 {
124124 for(i = 0; i < *argc; i++)
139139 FILE *ret = NULL;
140140 wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
141141 wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8);
142
142
143143 if(filename_utf16 && mode_utf16)
144144 {
145145 ret = _wfopen(filename_utf16, mode_utf16);
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
152152
153153 for (i = 0; i < MAX_CHANNELS; i++)
154154 {
155 hDecoder->element_id[i] = INVALID_ELEMENT_ID;
155156 hDecoder->window_shape_prev[i] = 0;
156157 hDecoder->time_out[i] = NULL;
157158 hDecoder->fb_intermed[i] = NULL;
285286 #endif
286287
287288 faad_initbits(&ld, buffer, buffer_size);
288
289
289290 #if 0
290291 memset(l, 0, sizeof(latm_header));
291292 is_latm = latmCheck(l, &ld);
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
4848
4949
5050 /* binary search huffman tables */
51 static const int8_t f_huffman_sa[][2] =
51 static const int8_t f_huffman_sa[][2] =
5252 {
5353 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */
5454 { 2, 3 }, /* index 1: 2 bits: 1x */
6666 { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */
6767 };
6868
69 static const int8_t t_huffman_sa[][2] =
69 static const int8_t t_huffman_sa[][2] =
7070 {
7171 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */
7272 { 2, 3 }, /* index 1: 2 bits: 1x */
8484 { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */
8585 };
8686
87 static const int8_t f_huffman_pan[][2] =
87 static const int8_t f_huffman_pan[][2] =
8888 {
8989 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */
9090 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */
116116 { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */
117117 };
118118
119 static const int8_t t_huffman_pan[][2] =
119 static const int8_t t_huffman_pan[][2] =
120120 {
121121 { /*0*/ -15, 1 }, /* index 0: 1 bits: x */
122122 { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */
149149 };
150150
151151 /* There are 3 classes in the standard but the last 2 are identical */
152 static const real_t sa_quant[8][2] =
152 static const real_t sa_quant[8][2] =
153153 {
154154 { FRAC_CONST(0.0000), FRAC_CONST(0.0000) },
155155 { FRAC_CONST(0.0501), FRAC_CONST(0.1778) },
163163
164164 /* We don't need the actual quantizer values */
165165 #if 0
166 static const real_t pan_quant[8][5] =
166 static const real_t pan_quant[8][5] =
167167 {
168168 { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) },
169169 { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) },
202202
203203 /* 2^(pan_quant[x][y]/30) */
204204 static const real_t pan_pow_2_30_pos[8][5] = {
205 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) },
206 { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) },
207 { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) },
208 { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) },
205 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) },
206 { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) },
207 { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) },
208 { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) },
209209 { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) },
210 { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) },
211 { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) },
210 { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) },
211 { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) },
212212 { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) }
213213 };
214214
215215 /* 2^(-pan_quant[x][y]/30) */
216216 static const real_t pan_pow_2_30_neg[8][5] = {
217217 { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) },
218 { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) },
219 { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) },
220 { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) },
221 { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) },
222 { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) },
223 { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) },
218 { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) },
219 { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) },
220 { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) },
221 { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) },
222 { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) },
223 { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) },
224224 { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) }
225225 };
226226
227227 static const real_t g_decayslope[MAX_SA_BAND] = {
228 FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8),
229 FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45),
228 FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8),
229 FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45),
230230 FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1),
231 FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
232 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
233 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
231 FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
232 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
233 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0),
234234 FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0)
235235 };
236236
245245 { FRAC_CONST(0.929071574), FRAC_CONST(0) }
246246 };
247247
248 static const uint8_t sa_freq_scale[9] =
248 static const uint8_t sa_freq_scale[9] =
249249 {
250250 0, 1, 2, 3, 5, 7, 10, 13, 23
251251 };
252252
253 static const uint8_t pan_freq_scale[21] =
253 static const uint8_t pan_freq_scale[21] =
254254 {
255255 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
256256 11, 12, 13, 14, 15, 18, 22, 26, 32, 64
257257 };
258258
259 static const uint8_t pan_quant_class[20] =
259 static const uint8_t pan_quant_class[20] =
260260 {
261261 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
262262 2, 2, 2, 2, 3, 3, 3, 4, 4, 4
264264
265265 /* Inverse mapping lookup */
266266 static const uint8_t pan_inv_freq[64] = {
267 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
268 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
267 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
268 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
269269 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
270270 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
271271 };
272272
273273 static const uint8_t sa_inv_freq[MAX_SA_BAND] = {
274274 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6,
275 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
276 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
275 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
276 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
277277 7, 7, 7, 7, 7, 7, 7
278278 };
279279
280 static const real_t filter_coeff[] =
280 static const real_t filter_coeff[] =
281281 {
282282 FRAC_CONST(0.65143905754106),
283283 FRAC_CONST(0.56471812200776),
284284 FRAC_CONST(0.48954165955695)
285285 };
286286
287 static const uint8_t delay_length[3] =
287 static const uint8_t delay_length[3] =
288288 {
289289 3, 4, 5
290290 };
291291
292 static const real_t delay_fraction[] =
292 static const real_t delay_fraction[] =
293293 {
294294 FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347)
295295 };
533533 }
534534
535535 static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i)
536 {
536 {
537537 if (i < -7) {
538538 /* printf(" PANminclip %d", i); */
539539 ps->pan_decode_error = 1;
546546 return i;
547547 }
548548
549 static void drm_ps_delta_decode(drm_ps_info *ps)
550 {
551 uint8_t band;
552
553 if (ps->bs_enable_sa)
554 {
555 if (ps->bs_sa_dt_flag && !ps->g_last_had_sa)
556 {
549 static void drm_ps_delta_decode(drm_ps_info *ps)
550 {
551 uint8_t band;
552
553 if (ps->bs_enable_sa)
554 {
555 if (ps->bs_sa_dt_flag && !ps->g_last_had_sa)
556 {
557557 /* wait until we get a DT frame */
558558 ps->bs_enable_sa = 0;
559559 } else if (ps->bs_sa_dt_flag) {
560560 /* DT frame, we have a last frame, so we can decode */
561 ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]);
561 ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]);
562562 } else {
563563 /* DF always decodable */
564 ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]);
565 }
566
564 ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]);
565 }
566
567567 for (band = 1; band < DRM_NUM_SA_BANDS; band++)
568 {
568 {
569569 if (ps->bs_sa_dt_flag && ps->g_last_had_sa)
570570 {
571571 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]);
572572 } else if (!ps->bs_sa_dt_flag) {
573 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]);
573 ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]);
574574 }
575575 }
576576 }
582582 ps->bs_enable_pan = ps->g_last_had_pan;
583583 ps->bs_enable_sa = ps->g_last_had_sa;
584584 }
585
586
587 if (ps->bs_enable_sa)
588 {
585
586
587 if (ps->bs_enable_sa)
588 {
589589 if (ps->sa_decode_error) {
590590 for (band = 0; band < DRM_NUM_SA_BANDS; band++)
591 {
591 {
592592 ps->g_sa_index[band] = ps->g_last_good_sa_index[band];
593593 }
594594 } else {
595595 for (band = 0; band < DRM_NUM_SA_BANDS; band++)
596 {
596 {
597597 ps->g_last_good_sa_index[band] = ps->g_sa_index[band];
598598 }
599599 }
600600 }
601
602 if (ps->bs_enable_pan)
603 {
604 if (ps->bs_pan_dt_flag && !ps->g_last_had_pan)
601
602 if (ps->bs_enable_pan)
603 {
604 if (ps->bs_pan_dt_flag && !ps->g_last_had_pan)
605605 {
606606 ps->bs_enable_pan = 0;
607 } else if (ps->bs_pan_dt_flag) {
607 } else if (ps->bs_pan_dt_flag) {
608608 ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]);
609609 } else {
610610 ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]);
611611 }
612
612
613613 for (band = 1; band < DRM_NUM_PAN_BANDS; band++)
614 {
614 {
615615 if (ps->bs_pan_dt_flag && ps->g_last_had_pan)
616616 {
617617 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]);
619619 ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]);
620620 }
621621 }
622
622
623623 if (ps->pan_decode_error) {
624624 for (band = 0; band < DRM_NUM_PAN_BANDS; band++)
625 {
625 {
626626 ps->g_pan_index[band] = ps->g_last_good_pan_index[band];
627627 }
628628 } else {
629629 for (band = 0; band < DRM_NUM_PAN_BANDS; band++)
630 {
630 {
631631 ps->g_last_good_pan_index[band] = ps->g_pan_index[band];
632632 }
633633 }
634634 }
635635 }
636636
637 static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64])
638 {
637 static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64])
638 {
639639 uint8_t s, b, k;
640640 complex_t qfrac, tmp0, tmp, in, R0;
641641 real_t peakdiff;
651651
652652 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++)
653653 {
654 /* set delay indices */
654 /* set delay indices */
655655 for (k = 0; k < NUM_OF_LINKS; k++)
656656 temp_delay_ser[k] = ps->delay_buf_index_ser[k];
657657
659659 IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]);
660660
661661 for (s = 0; s < NUM_OF_SUBSAMPLES; s++)
662 {
662 {
663663 const real_t gamma = REAL_CONST(1.5);
664664 const real_t sigma = REAL_CONST(1.5625);
665665
694694 } else {
695695 transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma);
696696 }
697
698 for (k = 0; k < NUM_OF_LINKS; k++)
697
698 for (k = 0; k < NUM_OF_LINKS; k++)
699699 {
700700 new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]);
701701 }
707707 IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]);
708708
709709 RE(ps->d_buff[1][b]) = RE(in);
710 IM(ps->d_buff[1][b]) = IM(in);
710 IM(ps->d_buff[1][b]) = IM(in);
711711
712712 ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract));
713713
714714 RE(R0) = RE(tmp);
715715 IM(R0) = IM(tmp);
716716
717 for (k = 0; k < NUM_OF_LINKS; k++)
717 for (k = 0; k < NUM_OF_LINKS; k++)
718718 {
719719 RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]);
720720 IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]);
742742 if (++temp_delay_ser[k] >= delay_length[k])
743743 temp_delay_ser[k] = 0;
744744 }
745 }
745 }
746746 }
747747
748748 for (k = 0; k < NUM_OF_LINKS; k++)
749749 ps->delay_buf_index_ser[k] = temp_delay_ser[k];
750750 }
751751
752 static void drm_add_ambiance(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
753 {
754 uint8_t s, b, ifreq, qclass;
752 static void drm_add_ambiance(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
753 {
754 uint8_t s, b, ifreq, qclass;
755755 real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND];
756756 real_t new_dir_map, new_sa_map;
757
757
758758 if (ps->bs_enable_sa)
759759 {
760760 /* Instead of dequantization and mapping, we use an inverse mapping
769769 sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass];
770770 new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass];
771771
772 k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b]));
773
774 sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass];
772 k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b]));
773
774 sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass];
775775 new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass];
776
776
777777 k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b]));
778778
779779 }
781781 for (s = 0; s < NUM_OF_SUBSAMPLES; s++)
782782 {
783783 for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++)
784 {
784 {
785785 QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]);
786786 QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]);
787787 QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]);
788788 QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]);
789
789
790790 sa_map[b] += k_sa_map[b];
791791 sa_dir_map[b] += k_sa_dir_map[b];
792792 }
793793 for (b = sa_freq_scale[DRM_NUM_SA_BANDS]; b < NUM_OF_QMF_CHANNELS; b++)
794 {
794 {
795795 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]);
796796 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]);
797797 }
798798 }
799 }
799 }
800800 else {
801801 for (s = 0; s < NUM_OF_SUBSAMPLES; s++)
802802 {
803803 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++)
804804 {
805805 QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]);
806 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]);
807 }
808 }
809 }
810 }
811
812 static void drm_add_pan(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
806 QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]);
807 }
808 }
809 }
810 }
811
812 static void drm_add_pan(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
813813 {
814814 uint8_t s, b, qclass, ifreq;
815815 real_t tmp, coeff1, coeff2;
819819
820820 if (ps->bs_enable_pan)
821821 {
822 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++)
822 for (b = 0; b < NUM_OF_QMF_CHANNELS; b++)
823823 {
824824 /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an
825825 inverse mapping 64->20 and look up the 2^G(x,y) values directly */
828828
829829 if (ps->g_prev_pan_index[ifreq] >= 0)
830830 {
831 pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass];
831 pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass];
832832 } else {
833833 pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass];
834834 }
837837 /* a en b can be negative so we may need to inverse parts */
838838 if (ps->g_pan_index[ifreq] >= 0)
839839 {
840 if (ps->g_prev_pan_index[ifreq] >= 0)
840 if (ps->g_prev_pan_index[ifreq] >= 0)
841841 {
842842 pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass],
843843 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]);
846846 pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]);
847847 }
848848 } else {
849 if (ps->g_prev_pan_index[ifreq] >= 0)
849 if (ps->g_prev_pan_index[ifreq] >= 0)
850850 {
851851 pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass],
852852 pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]);
865865 tmp = pan_base[b];
866866
867867 coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp));
868 coeff1 = MUL_R(coeff2, tmp);
868 coeff1 = MUL_R(coeff2, tmp);
869869
870870 QMF_RE(temp_l) = QMF_RE(X_left[s][b]);
871871 QMF_IM(temp_l) = QMF_IM(X_left[s][b]);
876876 QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1);
877877 QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2);
878878 QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2);
879
879
880880 /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */
881881 /* ^^^^^^^^^^^^^^^ k times */
882882 pan_base[b] = MUL_C(pan_base[b], pan_delta[b]);
883 }
884 }
885 }
883 }
884 }
885 }
886886 }
887887
888888 drm_ps_info *drm_ps_init(void)
889889 {
890890 drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info));
891891
892 memset(ps, 0, sizeof(drm_ps_info));
892 memset(ps, 0, sizeof(drm_ps_info));
893893
894894 return ps;
895895 }
901901
902902 /* main DRM PS decoding function */
903903 uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64])
904 {
905 if (ps == NULL)
904 {
905 if (ps == NULL)
906906 {
907907 memcpy(X_right, X_left, sizeof(qmf_t)*30*64);
908 return 0;
909 }
910
911 if (!ps->drm_ps_data_available && !guess)
908 return 0;
909 }
910
911 if (!ps->drm_ps_data_available && !guess)
912912 {
913913 memcpy(X_right, X_left, sizeof(qmf_t)*30*64);
914914 memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index));
923923 ps->sa_decode_error = 0;
924924 ps->pan_decode_error = 0;
925925 drm_ps_delta_decode(ps);
926 } else
926 } else
927927 {
928928 ps->sa_decode_error = 1;
929929 ps->pan_decode_error = 1;
930930 /* don't even bother decoding */
931931 }
932
932
933933 ps->drm_ps_data_available = 0;
934934
935935 drm_calc_sa_side_signal(ps, X_left);
937937
938938 if (ps->bs_enable_sa)
939939 {
940 ps->g_last_had_sa = 1;
941
942 memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS);
940 ps->g_last_had_sa = 1;
941
942 memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS);
943943
944944 } else {
945945 ps->g_last_had_sa = 0;
946946 }
947
947
948948 if (ps->bs_enable_pan)
949949 {
950950 drm_add_pan(ps, X_left, X_right);
951
952 ps->g_last_had_pan = 1;
951
952 ps->g_last_had_pan = 1;
953953
954954 memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS);
955955
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
4747 #define MAX_DELAY 5
4848
4949 typedef struct
50 {
50 {
5151 uint8_t drm_ps_data_available;
5252 uint8_t bs_enable_sa;
5353 uint8_t bs_enable_pan;
6060
6161 int8_t bs_sa_data[DRM_NUM_SA_BANDS];
6262 int8_t bs_pan_data[DRM_NUM_PAN_BANDS];
63
63
6464 int8_t g_sa_index[DRM_NUM_SA_BANDS];
65 int8_t g_pan_index[DRM_NUM_PAN_BANDS];
65 int8_t g_pan_index[DRM_NUM_PAN_BANDS];
6666 int8_t g_prev_sa_index[DRM_NUM_SA_BANDS];
67 int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS];
67 int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS];
6868
6969 int8_t sa_decode_error;
7070 int8_t pan_decode_error;
7171
7272 int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS];
7373 int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS];
74
75 qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND];
74
75 qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND];
7676
7777 complex_t d_buff[2][MAX_SA_BAND];
7878 complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND];
7979
80 uint8_t delay_buf_index_ser[NUM_OF_LINKS];
81
80 uint8_t delay_buf_index_ser[NUM_OF_LINKS];
81
8282 real_t prev_nrg[MAX_SA_BAND];
8383 real_t prev_peakdiff[MAX_SA_BAND];
84 real_t peakdecay_fast[MAX_SA_BAND];
84 real_t peakdecay_fast[MAX_SA_BAND];
8585 } drm_ps_info;
8686
8787
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
3636 #include "specrec.h"
3737 #include "huffman.h"
3838
39 /* ISO/IEC 14496-3/Amd.1
40 * 8.5.3.3: Huffman Codeword Reordering for AAC spectral data (HCR)
39 /* ISO/IEC 14496-3/Amd.1
40 * 8.5.3.3: Huffman Codeword Reordering for AAC spectral data (HCR)
4141 *
42 * HCR devides the spectral data in known fixed size segments, and
43 * sorts it by the importance of the data. The importance is firstly
44 * the (lower) position in the spectrum, and secondly the largest
45 * value in the used codebook.
42 * HCR devides the spectral data in known fixed size segments, and
43 * sorts it by the importance of the data. The importance is firstly
44 * the (lower) position in the spectrum, and secondly the largest
45 * value in the used codebook.
4646 * The most important data is written at the start of each segment
47 * (at known positions), the remaining data is interleaved inbetween,
47 * (at known positions), the remaining data is interleaved inbetween,
4848 * with the writing direction alternating.
4949 * Data length is not increased.
5050 */
5959 #define VCB11_FIRST 16
6060 #define VCB11_LAST 31
6161
62 static const uint8_t PreSortCB_STD[NUM_CB] =
62 static const uint8_t PreSortCB_STD[NUM_CB] =
6363 { 11, 9, 7, 5, 3, 1};
6464
65 static const uint8_t PreSortCB_ER[NUM_CB_ER] =
65 static const uint8_t PreSortCB_ER[NUM_CB_ER] =
6666 { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1};
6767
6868 /* 8.5.3.3.2 Derivation of segment width */
7373 #define segmentWidth(cb) min(maxCwLen[cb], ics->length_of_longest_codeword)
7474
7575 /* bit-twiddling helpers */
76 static const uint8_t S[] = {1, 2, 4, 8, 16};
76 static const uint8_t S[] = {1, 2, 4, 8, 16};
7777 static const uint32_t B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF};
7878
7979 typedef struct
8787 /* rewind and reverse */
8888 /* 32 bit version */
8989 static uint32_t rewrev_word(uint32_t v, const uint8_t len)
90 {
90 {
9191 /* 32 bit reverse */
92 v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]);
93 v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]);
94 v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]);
92 v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]);
93 v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]);
94 v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]);
9595 v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]);
9696 v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]);
9797
103103
104104 /* 64 bit version */
105105 static void rewrev_lword(uint32_t *hi, uint32_t *lo, const uint8_t len)
106 {
106 {
107107 if (len <= 32) {
108108 *hi = 0;
109109 *lo = rewrev_word(*lo, len);
112112 uint32_t t = *hi, v = *lo;
113113
114114 /* double 32 bit reverse */
115 v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]);
116 t = ((t >> S[0]) & B[0]) | ((t << S[0]) & ~B[0]);
117 v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]);
118 t = ((t >> S[1]) & B[1]) | ((t << S[1]) & ~B[1]);
119 v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]);
120 t = ((t >> S[2]) & B[2]) | ((t << S[2]) & ~B[2]);
115 v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]);
116 t = ((t >> S[0]) & B[0]) | ((t << S[0]) & ~B[0]);
117 v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]);
118 t = ((t >> S[1]) & B[1]) | ((t << S[1]) & ~B[1]);
119 v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]);
120 t = ((t >> S[2]) & B[2]) | ((t << S[2]) & ~B[2]);
121121 v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]);
122122 t = ((t >> S[3]) & B[3]) | ((t << S[3]) & ~B[3]);
123 v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]);
123 v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]);
124124 t = ((t >> S[4]) & B[4]) | ((t << S[4]) & ~B[4]);
125125
126126 /* last 32<>32 bit swap is implicit below */
127
127
128128 /* shift off low bits (this is really only one 64 bit shift) */
129129 *lo = (t >> (64 - len)) | (v << (len - 32));
130 *hi = v >> (64 - len);
130 *hi = v >> (64 - len);
131131 }
132132 }
133133
149149
150150 al = a->bufa;
151151 ah = a->bufb;
152
152
153153 if (b->len > 32)
154154 {
155155 /* maskoff superfluous high b bits */
160160 al = 0;
161161 } else {
162162 bl = b->bufa & ((1 << (b->len)) - 1);
163 bh = 0;
163 bh = 0;
164164 ah = (ah << (b->len)) | (al >> (32 - b->len));
165165 al = al << b->len;
166166 }
171171
172172 b->len += a->len;
173173 }
174
174
175175 static uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB)
176176 {
177177 /* only want spectral data CB's */
189189 }
190190 return 0;
191191 }
192
192
193193 static void read_segment(bits_t *segment, uint8_t segwidth, bitfile *ld)
194194 {
195195 segment->len = segwidth;
196196
197197 if (segwidth > 32)
198198 {
199 segment->bufb = faad_getbits(ld, segwidth - 32);
200 segment->bufa = faad_getbits(ld, 32);
199 segment->bufb = faad_getbits(ld, segwidth - 32);
200 segment->bufa = faad_getbits(ld, 32);
201201
202202 } else {
203203 segment->bufa = faad_getbits(ld, segwidth);
204 segment->bufb = 0;
205 }
204 segment->bufb = 0;
205 }
206206 }
207207
208208 static void fill_in_codeword(codeword_t *codeword, uint16_t index, uint16_t sp, uint8_t cb)
213213 codeword[index].bits.len = 0;
214214 }
215215
216 uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics,
216 uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics,
217217 bitfile *ld, int16_t *spectral_data)
218 {
218 {
219219 uint16_t PCWs_done;
220 uint16_t numberOfSegments, numberOfSets, numberOfCodewords;
220 uint16_t numberOfSegments, numberOfSets, numberOfCodewords;
221221
222222 codeword_t codeword[512];
223223 bits_t segment[512];
225225 uint16_t sp_offset[8];
226226 uint16_t g, i, sortloop, set, bitsread;
227227 /*uint16_t bitsleft, codewordsleft*/;
228 uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB;
229
228 uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB;
229
230230 const uint16_t nshort = hDecoder->frameLength/8;
231231 const uint16_t sp_data_len = ics->length_of_reordered_spectral_data;
232
232
233233 const uint8_t *PreSortCb;
234234
235235 /* no data (e.g. silence) */
241241 return 10;
242242
243243 if (sp_data_len < ics->length_of_longest_codeword)
244 return 10;
244 return 10;
245245
246246 sp_offset[0] = 0;
247247 for (g = 1; g < ics->num_window_groups; g++)
264264 PreSortCb = PreSortCB_STD;
265265 last_CB = NUM_CB;
266266 }
267
267
268268 /* step 1: decode PCW's (set 0), and stuff data in easier-to-use format */
269269 for (sortloop = 0; sortloop < last_CB; sortloop++)
270270 {
271271 /* select codebook to process this pass */
272272 this_CB = PreSortCb[sortloop];
273
273
274274 /* loop over sfbs */
275275 for (sfb = 0; sfb < ics->max_sfb; sfb++)
276276 {
283283 {
284284 /* check whether sfb used here is the one we want to process */
285285 if ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb))
286 {
286 {
287287 /* check whether codebook used here is the one we want to process */
288288 this_sec_CB = ics->sect_cb[g][i];
289
290 if (is_good_cb(this_CB, this_sec_CB))
289
290 if (is_good_cb(this_CB, this_sec_CB))
291291 {
292292 /* precalculate some stuff */
293293 uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb];
294294 uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN;
295295 uint16_t group_cws_count = (4*ics->window_group_length[g])/inc;
296296 uint8_t segwidth = segmentWidth(this_sec_CB);
297 uint16_t cws;
298
299 /* read codewords until end of sfb or end of window group (shouldn't only 1 trigger?) */
297 uint16_t cws;
298
299 /* read codewords until end of sfb or end of window group (shouldn't only 1 trigger?) */
300300 for (cws = 0; (cws < group_cws_count) && ((cws + w_idx*group_cws_count) < sect_sfb_size); cws++)
301301 {
302 uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc * (cws + w_idx*group_cws_count);
302 uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc * (cws + w_idx*group_cws_count);
303303
304304 /* read and decode PCW */
305305 if (!PCWs_done)
306 {
306 {
307307 /* read in normal segments */
308308 if (bitsread + segwidth <= sp_data_len)
309 {
310 read_segment(&segment[numberOfSegments], segwidth, ld);
309 {
310 read_segment(&segment[numberOfSegments], segwidth, ld);
311311 bitsread += segwidth;
312
313 huffman_spectral_data_2(this_sec_CB, &segment[numberOfSegments], &spectral_data[sp]);
312
313 huffman_spectral_data_2(this_sec_CB, &segment[numberOfSegments], &spectral_data[sp]);
314314
315315 /* keep leftover bits */
316316 rewrev_bits(&segment[numberOfSegments]);
321321 this in earlier because it might not fit in 64 bits. since we already
322322 decoded (and removed) the PCW it is now guaranteed to fit */
323323 if (bitsread < sp_data_len)
324 {
325 const uint8_t additional_bits = sp_data_len - bitsread;
326
327 read_segment(&segment[numberOfSegments], additional_bits, ld);
324 {
325 const uint8_t additional_bits = sp_data_len - bitsread;
326
327 read_segment(&segment[numberOfSegments], additional_bits, ld);
328328 segment[numberOfSegments].len += segment[numberOfSegments-1].len;
329 rewrev_bits(&segment[numberOfSegments]);
329 rewrev_bits(&segment[numberOfSegments]);
330330
331331 if (segment[numberOfSegments-1].len > 32)
332332 {
333 segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb +
333 segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb +
334334 showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len - 32);
335 segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa +
335 segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa +
336336 showbits_hcr(&segment[numberOfSegments-1], 32);
337337 } else {
338 segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa +
338 segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa +
339339 showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len);
340340 segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb;
341 }
341 }
342342 segment[numberOfSegments-1].len += additional_bits;
343343 }
344344 bitsread = sp_data_len;
345345 PCWs_done = 1;
346346
347 fill_in_codeword(codeword, 0, sp, this_sec_CB);
347 fill_in_codeword(codeword, 0, sp, this_sec_CB);
348348 }
349 } else {
350 fill_in_codeword(codeword, numberOfCodewords - numberOfSegments, sp, this_sec_CB);
349 } else {
350 fill_in_codeword(codeword, numberOfCodewords - numberOfSegments, sp, this_sec_CB);
351351 }
352352 numberOfCodewords++;
353 }
353 }
354354 }
355355 }
356 }
357 }
356 }
357 }
358358 }
359359 }
360360 }
361361
362362 if (numberOfSegments == 0)
363 return 10;
364
365 numberOfSets = numberOfCodewords / numberOfSegments;
363 return 10;
364
365 numberOfSets = numberOfCodewords / numberOfSegments;
366366
367367 /* step 2: decode nonPCWs */
368368 for (set = 1; set <= numberOfSets; set++)
385385 {
386386 uint8_t tmplen;
387387
388 if (codeword[codeword_idx].bits.len != 0)
389 concat_bits(&segment[segment_idx], &codeword[codeword_idx].bits);
390
388 if (codeword[codeword_idx].bits.len != 0)
389 concat_bits(&segment[segment_idx], &codeword[codeword_idx].bits);
390
391391 tmplen = segment[segment_idx].len;
392392
393393 if (huffman_spectral_data_2(codeword[codeword_idx].cb, &segment[segment_idx],
394394 &spectral_data[codeword[codeword_idx].sp_offset]) >= 0)
395395 {
396396 codeword[codeword_idx].decoded = 1;
397 } else
398 {
397 } else
398 {
399399 codeword[codeword_idx].bits = segment[segment_idx];
400 codeword[codeword_idx].bits.len = tmplen;
400 codeword[codeword_idx].bits.len = tmplen;
401401 }
402
402
403403 }
404404 }
405405 }
408408 }
409409
410410 #if 0 // Seems to give false errors
411 bitsleft = 0;
412
411 bitsleft = 0;
412
413413 for (i = 0; i < numberOfSegments && !bitsleft; i++)
414414 bitsleft += segment[i].len;
415415
417417
418418 codewordsleft = 0;
419419
420 for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++)
421 if (!codeword[i].decoded)
422 codewordsleft++;
420 for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++)
421 if (!codeword[i].decoded)
422 codewordsleft++;
423423
424424 if (codewordsleft) return 10;
425425 #endif
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
4242
4343 /* static function declarations */
4444 static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
45 static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp);
45 static INLINE uint8_t huffman_getescape(bitfile *ld, int16_t *sp);
4646 static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
4747 static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
4848 static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
120120 }
121121 }
122122
123 static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
123 static INLINE uint8_t huffman_getescape(bitfile *ld, int16_t *sp)
124124 {
125125 uint8_t neg, i;
126126 int16_t j;
127127 int16_t off;
128
129 if (sp < 0)
130 {
131 if (sp != -16)
132 return sp;
128 int16_t x = *sp;
129
130 if (x < 0)
131 {
132 if (x != -16)
133 return 0;
133134 neg = 1;
134135 } else {
135 if (sp != 16)
136 return sp;
136 if (x != 16)
137 return 0;
137138 neg = 0;
138139 }
139140
140 for (i = 4; ; i++)
141 for (i = 4; i < 16; i++)
141142 {
142143 if (faad_get1bit(ld
143144 DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0)
145146 break;
146147 }
147148 }
149 if (i >= 16)
150 return 10;
148151
149152 off = (int16_t)faad_getbits(ld, i
150153 DEBUGVAR(1,9,"huffman_getescape(): escape"));
153156 if (neg)
154157 j = -j;
155158
156 return j;
159 *sp = j;
160 return 0;
157161 }
158162
159163 static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp)
356360 return huffman_2step_pair_sign(cb, ld, sp);
357361 case 12: {
358362 uint8_t err = huffman_2step_pair(11, ld, sp);
359 sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1);
363 sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1);
360364 return err; }
361365 case 11:
362366 {
363367 uint8_t err = huffman_2step_pair_sign(11, ld, sp);
364 sp[0] = huffman_getescape(ld, sp[0]);
365 sp[1] = huffman_getescape(ld, sp[1]);
368 if (!err)
369 err = huffman_getescape(ld, &sp[0]);
370 if (!err)
371 err = huffman_getescape(ld, &sp[1]);
366372 return err;
367373 }
368374 #ifdef ERROR_RESILIENCE
371377 case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:
372378 {
373379 uint8_t err = huffman_2step_pair_sign(11, ld, sp);
374 sp[0] = huffman_getescape(ld, sp[0]);
375 sp[1] = huffman_getescape(ld, sp[1]);
380 if (!err)
381 err = huffman_getescape(ld, &sp[0]);
382 if (!err)
383 err = huffman_getescape(ld, &sp[1]);
376384
377385 /* check LAV (Largest Absolute Value) */
378386 /* this finds errors in the ESCAPE signal */
445453 vcb11 = cb;
446454 cb = 11;
447455 }
448
456
449457 cw = showbits_hcr(ld, hcbN[cb]);
450458 offset = hcb_table[cb][cw].offset;
451459 extra_bits = hcb_table[cb][cw].extra_bits;
468476 while (!hcb3[offset].is_leaf)
469477 {
470478 uint8_t b;
471
479
472480 if ( get1bit_hcr(ld, &b) ) return -1;
473481 offset += hcb3[offset].data[b];
474482 }
487495 while (!hcb_bin_table[cb][offset].is_leaf)
488496 {
489497 uint8_t b;
490
498
491499 if (get1bit_hcr(ld, &b) ) return -1;
492500 offset += hcb_bin_table[cb][offset].data[b];
493501 }
526534 int32_t j;
527535 uint32_t off;
528536
529 neg = (sp[k] < 0) ? 1 : 0;
537 neg = (sp[k] < 0) ? 1 : 0;
530538
531539 for (i = 4; ; i++)
532540 {
550558 /* this finds errors in the ESCAPE signal */
551559 vcb11_check_LAV(vcb11, sp);
552560 }
553 }
561 }
554562 return ld->len;
555563 }
556564
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
5353 tmp |= (uint32_t)0x00010000; /* insert 1 lsb */
5454 tmp2 = tmp; /* add 1 lsb and elided one */
5555 tmp &= (uint32_t)0xff800000; /* extract exponent and sign */
56
56
5757 *pf = *(float32_t*)&tmp1 + *(float32_t*)&tmp2 - *(float32_t*)&tmp;
5858 } else {
5959 *pf = *(float32_t*)&tmp;
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
3131 * Fast (I)MDCT Implementation using (I)FFT ((Inverse) Fast Fourier Transform)
3232 * and consists of three steps: pre-(I)FFT complex multiplication, complex
3333 * (I)FFT, post-(I)FFT complex multiplication,
34 *
34 *
3535 * As described in:
3636 * P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the
3737 * Implementation of Filter Banks Based on 'Time Domain Aliasing
38 * Cancellation’," IEEE Proc. on ICASSP‘91, 1991, pp. 2209-2212.
38 * Cancellation'," IEEE Proc. on ICASSP'91, 1991, pp. 2209-2212.
3939 *
4040 *
4141 * As of April 6th 2002 completely rewritten.
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
106106 0, /* 27 ER Parametric */
107107 #endif
108108 0, /* 28 (Reserved) */
109 0, /* 29 (Reserved) */
109 #ifdef PS_DEC
110 1, /* 29 AAC LC + SBR + PS */
111 #else
112 0, /* 29 AAC LC + SBR + PS */
113 #endif
110114 0, /* 30 (Reserved) */
111115 0 /* 31 (Reserved) */
112116 };
173177
174178 #ifdef SBR_DEC
175179 mp4ASC->sbr_present_flag = -1;
176 if (mp4ASC->objectTypeIndex == 5)
180 if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29)
177181 {
178182 uint8_t tmp;
179183
230234 else
231235 bits_to_decode = (int8_t)(buffer_size*8 - (startpos-faad_get_processed_bits(ld)));
232236
233 if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16))
237 if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16))
234238 {
235239 int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11
236240 DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
4141 uint32_t buffer_size,
4242 mp4AudioSpecificConfig *mp4ASC,
4343 program_config *pce, uint8_t short_form);
44
44
4545 int8_t AudioSpecificConfigFromBitfile(bitfile *ld,
4646 mp4AudioSpecificConfig *mp4ASC,
4747 program_config *pce, uint32_t bsize, uint8_t short_form);
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
4747
4848 if (ics->ms_mask_present >= 1)
4949 {
50 for (g = 0; g < ics->num_window_groups; g++)
50 for (g = 0; g < ics->num_window_groups; g++)
5151 {
5252 for (b = 0; b < ics->window_group_length[g]; b++)
5353 {
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
235235 if ((ics_right != NULL)
236236 && is_noise(ics_right, g, sfb))
237237 {
238 if (channel_pair &&
238 #ifdef LTP_DEC
239 /* See comment above. */
240 ics_right->ltp.long_used[sfb] = 0;
241 ics_right->ltp2.long_used[sfb] = 0;
242 #endif
243 #ifdef MAIN_DEC
244 /* See comment above. */
245 ics_right->pred.prediction_used[sfb] = 0;
246 #endif
247
248 if (channel_pair && is_noise(ics_left, g, sfb) &&
239249 (((ics_left->ms_mask_present == 1) &&
240250 (ics_left->ms_used[g][sfb])) ||
241251 (ics_left->ms_mask_present == 2)))
250260 ics_right->scale_factors[g][sfb], size, sub, &r1_dep, &r2_dep);
251261
252262 } else /*if (ics_left->ms_mask_present == 0)*/ {
253
254 #ifdef LTP_DEC
255 ics_right->ltp.long_used[sfb] = 0;
256 ics_right->ltp2.long_used[sfb] = 0;
257 #endif
258 #ifdef MAIN_DEC
259 ics_right->pred.prediction_used[sfb] = 0;
260 #endif
261263
262264 offs = ics_right->swb_offset[sfb];
263265 size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
453453 int8_t index;
454454 uint32_t cw;
455455 rvlc_huff_table *h = book_rvlc;
456
456
457457 i = h->len;
458458 if (direction > 0)
459459 cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,""));
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818 ** Any non-GPL usage of this software or parts of this software is strictly
9696 {
9797 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
9898 sbr->numTimeSlots = NO_TIME_SLOTS_960;
99 } else {
99 }
100 else if (framelength == 1024)
101 {
100102 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
101103 sbr->numTimeSlots = NO_TIME_SLOTS;
104 }
105 else
106 {
107 faad_free(sbr);
108 return NULL;
102109 }
103110
104111 sbr->GQ_ringbuf_index[0] = 0;
165172 }
166173
167174 #ifdef PS_DEC
168 if (sbr->ps != NULL)
175 if (sbr->ps != NULL)
169176 ps_free(sbr->ps);
170177 #endif
171178
204211
205212 memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
206213 memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
207
214
208215 sbr->GQ_ringbuf_index[0] = 0;
209216 sbr->GQ_ringbuf_index[1] = 0;
210217 sbr->header_count = 0;
00 /*
11 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
22 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
3 **
3 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
66 ** the Free Software Foundation; either version 2 of the License, or
77 ** (at your option) any later version.
8 **
8 **
99 ** This program is distributed in the hope that it will be useful,
1010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 ** GNU General Public License for more details.
13 **
13 **
1414 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
15 ** along with this program; if not, write to the Free Software
1616 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717 **
1818