New upstream version 2.10.0
Fabian Greffrath
2 years ago
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 | ||
0 | 25 | 2.9.2: |
1 | 26 | [ MichaĆ Janiszewski ] |
2 | 27 | * Only use x86-assembly when explicitly on x86 |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
182 | 182 | numfiles = 0; |
183 | 183 | |
184 | 184 | Sleep(500); |
185 | } | |
185 | } | |
186 | 186 | |
187 | 187 | DeleteCriticalSection(&mutex); |
188 | 188 |
27 | 27 | #define CREATEFONT(sz) \ |
28 | 28 | CreateFont((sz), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
29 | 29 | VARIABLE_PITCH | FF_SWISS, "") |
30 | ||
30 | ||
31 | 31 | HANDLE event = NULL; |
32 | 32 | int width = 130, height = 130; |
33 | 33 | RECT bar1, bar2, vbrBR; |
231 | 231 | set_outputFormat(iniSettings.outputFormat); |
232 | 232 | set_fileType(iniSettings.fileType); |
233 | 233 | set_object_type(iniSettings.object_type); |
234 | ||
234 | ||
235 | 235 | for (frame = 0; frame < 8; frame++) |
236 | 236 | hbm[frame] = LoadImage(hinst, MAKEINTRESOURCE(IDB_TF01 + frame), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); |
237 | 237 | frame = 0; |
242 | 242 | DispatchMessage(&msg); |
243 | 243 | } |
244 | 244 | |
245 | for (frame = 0; frame < 8; frame++) | |
245 | for (frame = 0; frame < 8; frame++) | |
246 | 246 | DeleteObject(hbm[frame]); |
247 | 247 | |
248 | 248 | return msg.wParam; |
372 | 372 | if (animate || frame) |
373 | 373 | { |
374 | 374 | frame++; |
375 | if (frame > 7) | |
375 | if (frame > 7) | |
376 | 376 | frame -= 8; |
377 | 377 | } |
378 | 378 | else |
436 | 436 | return 0; |
437 | 437 | |
438 | 438 | case WM_COMMAND: |
439 | switch (LOWORD(wParam)) | |
439 | switch (LOWORD(wParam)) | |
440 | 440 | { |
441 | 441 | case IDM_QUIT: |
442 | 442 | WriteIniFile(INI_FILE); |
445 | 445 | break; |
446 | 446 | case IDM_ONTOP: |
447 | 447 | set_always_on_top(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); |
448 | break; | |
448 | break; | |
449 | 449 | case IDM_LOGERR: |
450 | 450 | set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); |
451 | 451 | break; |
458 | 458 | } |
459 | 459 | case IDM_VOLUME: |
460 | 460 | { |
461 | int value = | |
461 | int value = | |
462 | 462 | DialogBox( |
463 | hinst, | |
464 | MAKEINTRESOURCE(IDD_VOLUME), | |
463 | hinst, | |
464 | MAKEINTRESOURCE(IDD_VOLUME), | |
465 | 465 | hwnd, QCProc); |
466 | 466 | |
467 | 467 | if (value == -2) |
483 | 483 | hdrop = (HANDLE)wParam; |
484 | 484 | HandleDrag(hwnd, hdrop); |
485 | 485 | return 0; |
486 | ||
486 | ||
487 | 487 | case WM_DESTROY: |
488 | 488 | decoding_done = 1; |
489 | 489 | PostQuitMessage(0); |
497 | 497 | * Encode parameters dialog procedures. |
498 | 498 | */ |
499 | 499 | |
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 | ||
507 | 507 | if(iniSettings.decode_mode == 0) |
508 | 508 | { |
509 | 509 | CheckDlgButton(hwndDlg,IDC_PLAYBACK,TRUE); |
578 | 578 | EndDialog(hwndDlg, -1); |
579 | 579 | break; |
580 | 580 | |
581 | case WM_COMMAND: | |
582 | switch (LOWORD(wParam)) | |
581 | case WM_COMMAND: | |
582 | switch (LOWORD(wParam)) | |
583 | 583 | { |
584 | 584 | case IDC_BUTTON1: |
585 | 585 | { |
669 | 669 | break; |
670 | 670 | } |
671 | 671 | } |
672 | return FALSE; | |
672 | return FALSE; | |
673 | 673 | } |
674 | 674 | |
675 | 675 |
38 | 38 | if (strlen(fmt) > 750) |
39 | 39 | { |
40 | 40 | sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt); |
41 | } | |
42 | else | |
41 | } | |
42 | else | |
43 | 43 | { |
44 | 44 | if (_filename != NULL && strlen(_filename) < 255) |
45 | 45 | { |
48 | 48 | } |
49 | 49 | |
50 | 50 | va_start(ap, fmt); |
51 | ||
51 | ||
52 | 52 | vsprintf(bufp, fmt, ap); |
53 | 53 | |
54 | 54 | va_end(ap); |
41 | 41 | #define IDM_QUIT 40019 |
42 | 42 | |
43 | 43 | // Next default values for new objects |
44 | // | |
44 | // | |
45 | 45 | #ifdef APSTUDIO_INVOKED |
46 | 46 | #ifndef APSTUDIO_READONLY_SYMBOLS |
47 | 47 | #define _APS_NO_MFC 1 |
7 | 7 | dnl - mpeg4ip plugin (requires mpeg4ip's libmp4v2 to be installed) |
8 | 8 | |
9 | 9 | AC_PREREQ(2.50) |
10 | AC_INIT(faad2, 2.9.2) | |
10 | AC_INIT(faad2, 2.10.0) | |
11 | 11 | AC_CONFIG_AUX_DIR(.) |
12 | 12 | AM_INIT_AUTOMAKE([subdir-objects]) |
13 | 13 |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
203 | 203 | } |
204 | 204 | |
205 | 205 | #endif /* GNU C library. */ |
206 | ||
206 | ||
207 | 207 | /* Handle permutation of arguments. */ |
208 | 208 | |
209 | 209 | /* Describe the part of ARGV that contains non-options that have |
264 | 264 | temp = *first; *first = *last; *last = temp; first++; last--; |
265 | 265 | } |
266 | 266 | } |
267 | ||
267 | ||
268 | 268 | /* Scan elements of ARGV (whose length is ARGC) for option characters |
269 | 269 | given in OPTSTRING. |
270 | 270 | |
679 | 679 | } |
680 | 680 | |
681 | 681 | #endif /* _LIBC or not __GNU_LIBRARY__. */ |
682 | ||
682 | ||
683 | 683 | #ifdef TEST |
684 | 684 | |
685 | 685 | /* Compile with -DTEST to make an executable for use in testing |
153 | 153 | while ((b->bytes_into_buffer > 0) && (bytes > 0)) |
154 | 154 | { |
155 | 155 | int chunk = min(bytes, b->bytes_into_buffer); |
156 | ||
156 | ||
157 | 157 | bytes -= chunk; |
158 | 158 | b->file_offset += chunk; |
159 | 159 | b->bytes_consumed = chunk; |
216 | 216 | |
217 | 217 | frame_length = ((((unsigned int)b->buffer[3] & 0x3)) << 11) |
218 | 218 | | (((unsigned int)b->buffer[4]) << 3) | (b->buffer[5] >> 5); |
219 | if (frame_length == 0) | |
220 | break; | |
219 | 221 | |
220 | 222 | t_framelength += frame_length; |
221 | 223 | |
696 | 698 | /* update buffer indices */ |
697 | 699 | advance_buffer(&b, frameInfo.bytesconsumed); |
698 | 700 | |
701 | /* check if the inconsistent number of channels */ | |
702 | if (aufile != NULL && frameInfo.channels != aufile->channels) | |
703 | frameInfo.error = 12; | |
704 | ||
699 | 705 | if (frameInfo.error > 0) |
700 | 706 | { |
701 | 707 | faad_fprintf(stderr, "Error: %s\n", |
871 | 877 | if (NeAACDecAudioSpecificConfig(mp4config.asc.buf, mp4config.asc.size, &mp4ASC) >= 0) |
872 | 878 | { |
873 | 879 | 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; | |
875 | 881 | } |
876 | 882 | } |
877 | 883 |
94 | 94 | if (!txt[size]) |
95 | 95 | break; |
96 | 96 | } |
97 | txt[sizemax-1] = '\0'; | |
97 | 98 | |
98 | 99 | return size; |
99 | 100 | } |
342 | 343 | u32in(); |
343 | 344 | // Number of entries |
344 | 345 | mp4config.frame.ents = u32in(); |
345 | // fixme: check atom size | |
346 | ||
347 | if (!(mp4config.frame.ents + 1)) | |
348 | return ERR_FAIL; | |
349 | ||
346 | 350 | mp4config.frame.data = malloc(sizeof(*mp4config.frame.data) |
347 | 351 | * (mp4config.frame.ents + 1)); |
348 | 352 |
101 | 101 | fprintf(stderr, "\nFATAL: Malloc failed\n\n"); |
102 | 102 | exit(-1); |
103 | 103 | } |
104 | ||
104 | ||
105 | 105 | for(i = 0; i < nArgs; i++) |
106 | 106 | { |
107 | 107 | (*argv)[i] = utf16_to_utf8(szArglist[i]); |
118 | 118 | void free_commandline_arguments_utf8(int *argc, char ***argv) |
119 | 119 | { |
120 | 120 | int i = 0; |
121 | ||
121 | ||
122 | 122 | if(*argv != NULL) |
123 | 123 | { |
124 | 124 | for(i = 0; i < *argc; i++) |
139 | 139 | FILE *ret = NULL; |
140 | 140 | wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8); |
141 | 141 | wchar_t *mode_utf16 = utf8_to_utf16(mode_utf8); |
142 | ||
142 | ||
143 | 143 | if(filename_utf16 && mode_utf16) |
144 | 144 | { |
145 | 145 | ret = _wfopen(filename_utf16, mode_utf16); |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
152 | 152 | |
153 | 153 | for (i = 0; i < MAX_CHANNELS; i++) |
154 | 154 | { |
155 | hDecoder->element_id[i] = INVALID_ELEMENT_ID; | |
155 | 156 | hDecoder->window_shape_prev[i] = 0; |
156 | 157 | hDecoder->time_out[i] = NULL; |
157 | 158 | hDecoder->fb_intermed[i] = NULL; |
285 | 286 | #endif |
286 | 287 | |
287 | 288 | faad_initbits(&ld, buffer, buffer_size); |
288 | ||
289 | ||
289 | 290 | #if 0 |
290 | 291 | memset(l, 0, sizeof(latm_header)); |
291 | 292 | is_latm = latmCheck(l, &ld); |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
48 | 48 | |
49 | 49 | |
50 | 50 | /* binary search huffman tables */ |
51 | static const int8_t f_huffman_sa[][2] = | |
51 | static const int8_t f_huffman_sa[][2] = | |
52 | 52 | { |
53 | 53 | { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
54 | 54 | { 2, 3 }, /* index 1: 2 bits: 1x */ |
66 | 66 | { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ |
67 | 67 | }; |
68 | 68 | |
69 | static const int8_t t_huffman_sa[][2] = | |
69 | static const int8_t t_huffman_sa[][2] = | |
70 | 70 | { |
71 | 71 | { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
72 | 72 | { 2, 3 }, /* index 1: 2 bits: 1x */ |
84 | 84 | { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ |
85 | 85 | }; |
86 | 86 | |
87 | static const int8_t f_huffman_pan[][2] = | |
87 | static const int8_t f_huffman_pan[][2] = | |
88 | 88 | { |
89 | 89 | { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
90 | 90 | { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
116 | 116 | { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ |
117 | 117 | }; |
118 | 118 | |
119 | static const int8_t t_huffman_pan[][2] = | |
119 | static const int8_t t_huffman_pan[][2] = | |
120 | 120 | { |
121 | 121 | { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
122 | 122 | { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
149 | 149 | }; |
150 | 150 | |
151 | 151 | /* 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] = | |
153 | 153 | { |
154 | 154 | { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, |
155 | 155 | { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, |
163 | 163 | |
164 | 164 | /* We don't need the actual quantizer values */ |
165 | 165 | #if 0 |
166 | static const real_t pan_quant[8][5] = | |
166 | static const real_t pan_quant[8][5] = | |
167 | 167 | { |
168 | 168 | { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, |
169 | 169 | { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, |
202 | 202 | |
203 | 203 | /* 2^(pan_quant[x][y]/30) */ |
204 | 204 | 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) }, | |
209 | 209 | { 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) }, | |
212 | 212 | { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } |
213 | 213 | }; |
214 | 214 | |
215 | 215 | /* 2^(-pan_quant[x][y]/30) */ |
216 | 216 | static const real_t pan_pow_2_30_neg[8][5] = { |
217 | 217 | { 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) }, | |
224 | 224 | { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } |
225 | 225 | }; |
226 | 226 | |
227 | 227 | 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), | |
230 | 230 | 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), | |
234 | 234 | FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) |
235 | 235 | }; |
236 | 236 | |
245 | 245 | { FRAC_CONST(0.929071574), FRAC_CONST(0) } |
246 | 246 | }; |
247 | 247 | |
248 | static const uint8_t sa_freq_scale[9] = | |
248 | static const uint8_t sa_freq_scale[9] = | |
249 | 249 | { |
250 | 250 | 0, 1, 2, 3, 5, 7, 10, 13, 23 |
251 | 251 | }; |
252 | 252 | |
253 | static const uint8_t pan_freq_scale[21] = | |
253 | static const uint8_t pan_freq_scale[21] = | |
254 | 254 | { |
255 | 255 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
256 | 256 | 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 |
257 | 257 | }; |
258 | 258 | |
259 | static const uint8_t pan_quant_class[20] = | |
259 | static const uint8_t pan_quant_class[20] = | |
260 | 260 | { |
261 | 261 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
262 | 262 | 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 |
264 | 264 | |
265 | 265 | /* Inverse mapping lookup */ |
266 | 266 | 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, | |
269 | 269 | 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
270 | 270 | 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 |
271 | 271 | }; |
272 | 272 | |
273 | 273 | static const uint8_t sa_inv_freq[MAX_SA_BAND] = { |
274 | 274 | 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, | |
277 | 277 | 7, 7, 7, 7, 7, 7, 7 |
278 | 278 | }; |
279 | 279 | |
280 | static const real_t filter_coeff[] = | |
280 | static const real_t filter_coeff[] = | |
281 | 281 | { |
282 | 282 | FRAC_CONST(0.65143905754106), |
283 | 283 | FRAC_CONST(0.56471812200776), |
284 | 284 | FRAC_CONST(0.48954165955695) |
285 | 285 | }; |
286 | 286 | |
287 | static const uint8_t delay_length[3] = | |
287 | static const uint8_t delay_length[3] = | |
288 | 288 | { |
289 | 289 | 3, 4, 5 |
290 | 290 | }; |
291 | 291 | |
292 | static const real_t delay_fraction[] = | |
292 | static const real_t delay_fraction[] = | |
293 | 293 | { |
294 | 294 | FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) |
295 | 295 | }; |
533 | 533 | } |
534 | 534 | |
535 | 535 | static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) |
536 | { | |
536 | { | |
537 | 537 | if (i < -7) { |
538 | 538 | /* printf(" PANminclip %d", i); */ |
539 | 539 | ps->pan_decode_error = 1; |
546 | 546 | return i; |
547 | 547 | } |
548 | 548 | |
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 | { | |
557 | 557 | /* wait until we get a DT frame */ |
558 | 558 | ps->bs_enable_sa = 0; |
559 | 559 | } else if (ps->bs_sa_dt_flag) { |
560 | 560 | /* 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]); | |
562 | 562 | } else { |
563 | 563 | /* 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 | ||
567 | 567 | for (band = 1; band < DRM_NUM_SA_BANDS; band++) |
568 | { | |
568 | { | |
569 | 569 | if (ps->bs_sa_dt_flag && ps->g_last_had_sa) |
570 | 570 | { |
571 | 571 | ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); |
572 | 572 | } 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]); | |
574 | 574 | } |
575 | 575 | } |
576 | 576 | } |
582 | 582 | ps->bs_enable_pan = ps->g_last_had_pan; |
583 | 583 | ps->bs_enable_sa = ps->g_last_had_sa; |
584 | 584 | } |
585 | ||
586 | ||
587 | if (ps->bs_enable_sa) | |
588 | { | |
585 | ||
586 | ||
587 | if (ps->bs_enable_sa) | |
588 | { | |
589 | 589 | if (ps->sa_decode_error) { |
590 | 590 | for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
591 | { | |
591 | { | |
592 | 592 | ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; |
593 | 593 | } |
594 | 594 | } else { |
595 | 595 | for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
596 | { | |
596 | { | |
597 | 597 | ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; |
598 | 598 | } |
599 | 599 | } |
600 | 600 | } |
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) | |
605 | 605 | { |
606 | 606 | ps->bs_enable_pan = 0; |
607 | } else if (ps->bs_pan_dt_flag) { | |
607 | } else if (ps->bs_pan_dt_flag) { | |
608 | 608 | ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); |
609 | 609 | } else { |
610 | 610 | ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); |
611 | 611 | } |
612 | ||
612 | ||
613 | 613 | for (band = 1; band < DRM_NUM_PAN_BANDS; band++) |
614 | { | |
614 | { | |
615 | 615 | if (ps->bs_pan_dt_flag && ps->g_last_had_pan) |
616 | 616 | { |
617 | 617 | ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); |
619 | 619 | ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); |
620 | 620 | } |
621 | 621 | } |
622 | ||
622 | ||
623 | 623 | if (ps->pan_decode_error) { |
624 | 624 | for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
625 | { | |
625 | { | |
626 | 626 | ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; |
627 | 627 | } |
628 | 628 | } else { |
629 | 629 | for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
630 | { | |
630 | { | |
631 | 631 | ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; |
632 | 632 | } |
633 | 633 | } |
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
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 | { | |
639 | 639 | uint8_t s, b, k; |
640 | 640 | complex_t qfrac, tmp0, tmp, in, R0; |
641 | 641 | real_t peakdiff; |
651 | 651 | |
652 | 652 | for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) |
653 | 653 | { |
654 | /* set delay indices */ | |
654 | /* set delay indices */ | |
655 | 655 | for (k = 0; k < NUM_OF_LINKS; k++) |
656 | 656 | temp_delay_ser[k] = ps->delay_buf_index_ser[k]; |
657 | 657 | |
659 | 659 | IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); |
660 | 660 | |
661 | 661 | for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
662 | { | |
662 | { | |
663 | 663 | const real_t gamma = REAL_CONST(1.5); |
664 | 664 | const real_t sigma = REAL_CONST(1.5625); |
665 | 665 | |
694 | 694 | } else { |
695 | 695 | transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); |
696 | 696 | } |
697 | ||
698 | for (k = 0; k < NUM_OF_LINKS; k++) | |
697 | ||
698 | for (k = 0; k < NUM_OF_LINKS; k++) | |
699 | 699 | { |
700 | 700 | new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); |
701 | 701 | } |
707 | 707 | IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); |
708 | 708 | |
709 | 709 | 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); | |
711 | 711 | |
712 | 712 | ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); |
713 | 713 | |
714 | 714 | RE(R0) = RE(tmp); |
715 | 715 | IM(R0) = IM(tmp); |
716 | 716 | |
717 | for (k = 0; k < NUM_OF_LINKS; k++) | |
717 | for (k = 0; k < NUM_OF_LINKS; k++) | |
718 | 718 | { |
719 | 719 | RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); |
720 | 720 | IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); |
742 | 742 | if (++temp_delay_ser[k] >= delay_length[k]) |
743 | 743 | temp_delay_ser[k] = 0; |
744 | 744 | } |
745 | } | |
745 | } | |
746 | 746 | } |
747 | 747 | |
748 | 748 | for (k = 0; k < NUM_OF_LINKS; k++) |
749 | 749 | ps->delay_buf_index_ser[k] = temp_delay_ser[k]; |
750 | 750 | } |
751 | 751 | |
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; | |
755 | 755 | 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]; |
756 | 756 | real_t new_dir_map, new_sa_map; |
757 | ||
757 | ||
758 | 758 | if (ps->bs_enable_sa) |
759 | 759 | { |
760 | 760 | /* Instead of dequantization and mapping, we use an inverse mapping |
769 | 769 | sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; |
770 | 770 | new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; |
771 | 771 | |
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]; | |
775 | 775 | new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; |
776 | ||
776 | ||
777 | 777 | k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); |
778 | 778 | |
779 | 779 | } |
781 | 781 | for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
782 | 782 | { |
783 | 783 | for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) |
784 | { | |
784 | { | |
785 | 785 | 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]); |
786 | 786 | 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]); |
787 | 787 | 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]); |
788 | 788 | 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 | ||
790 | 790 | sa_map[b] += k_sa_map[b]; |
791 | 791 | sa_dir_map[b] += k_sa_dir_map[b]; |
792 | 792 | } |
793 | 793 | for (b = sa_freq_scale[DRM_NUM_SA_BANDS]; b < NUM_OF_QMF_CHANNELS; b++) |
794 | { | |
794 | { | |
795 | 795 | QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); |
796 | 796 | QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); |
797 | 797 | } |
798 | 798 | } |
799 | } | |
799 | } | |
800 | 800 | else { |
801 | 801 | for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
802 | 802 | { |
803 | 803 | for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
804 | 804 | { |
805 | 805 | 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]) | |
813 | 813 | { |
814 | 814 | uint8_t s, b, qclass, ifreq; |
815 | 815 | real_t tmp, coeff1, coeff2; |
819 | 819 | |
820 | 820 | if (ps->bs_enable_pan) |
821 | 821 | { |
822 | for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) | |
822 | for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) | |
823 | 823 | { |
824 | 824 | /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an |
825 | 825 | inverse mapping 64->20 and look up the 2^G(x,y) values directly */ |
828 | 828 | |
829 | 829 | if (ps->g_prev_pan_index[ifreq] >= 0) |
830 | 830 | { |
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]; | |
832 | 832 | } else { |
833 | 833 | pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; |
834 | 834 | } |
837 | 837 | /* a en b can be negative so we may need to inverse parts */ |
838 | 838 | if (ps->g_pan_index[ifreq] >= 0) |
839 | 839 | { |
840 | if (ps->g_prev_pan_index[ifreq] >= 0) | |
840 | if (ps->g_prev_pan_index[ifreq] >= 0) | |
841 | 841 | { |
842 | 842 | pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], |
843 | 843 | pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
846 | 846 | pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); |
847 | 847 | } |
848 | 848 | } else { |
849 | if (ps->g_prev_pan_index[ifreq] >= 0) | |
849 | if (ps->g_prev_pan_index[ifreq] >= 0) | |
850 | 850 | { |
851 | 851 | pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], |
852 | 852 | pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
865 | 865 | tmp = pan_base[b]; |
866 | 866 | |
867 | 867 | coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); |
868 | coeff1 = MUL_R(coeff2, tmp); | |
868 | coeff1 = MUL_R(coeff2, tmp); | |
869 | 869 | |
870 | 870 | QMF_RE(temp_l) = QMF_RE(X_left[s][b]); |
871 | 871 | QMF_IM(temp_l) = QMF_IM(X_left[s][b]); |
876 | 876 | QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); |
877 | 877 | QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); |
878 | 878 | QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); |
879 | ||
879 | ||
880 | 880 | /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ |
881 | 881 | /* ^^^^^^^^^^^^^^^ k times */ |
882 | 882 | pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); |
883 | } | |
884 | } | |
885 | } | |
883 | } | |
884 | } | |
885 | } | |
886 | 886 | } |
887 | 887 | |
888 | 888 | drm_ps_info *drm_ps_init(void) |
889 | 889 | { |
890 | 890 | drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info)); |
891 | 891 | |
892 | memset(ps, 0, sizeof(drm_ps_info)); | |
892 | memset(ps, 0, sizeof(drm_ps_info)); | |
893 | 893 | |
894 | 894 | return ps; |
895 | 895 | } |
901 | 901 | |
902 | 902 | /* main DRM PS decoding function */ |
903 | 903 | 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) | |
906 | 906 | { |
907 | 907 | 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) | |
912 | 912 | { |
913 | 913 | memcpy(X_right, X_left, sizeof(qmf_t)*30*64); |
914 | 914 | memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); |
923 | 923 | ps->sa_decode_error = 0; |
924 | 924 | ps->pan_decode_error = 0; |
925 | 925 | drm_ps_delta_decode(ps); |
926 | } else | |
926 | } else | |
927 | 927 | { |
928 | 928 | ps->sa_decode_error = 1; |
929 | 929 | ps->pan_decode_error = 1; |
930 | 930 | /* don't even bother decoding */ |
931 | 931 | } |
932 | ||
932 | ||
933 | 933 | ps->drm_ps_data_available = 0; |
934 | 934 | |
935 | 935 | drm_calc_sa_side_signal(ps, X_left); |
937 | 937 | |
938 | 938 | if (ps->bs_enable_sa) |
939 | 939 | { |
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); | |
943 | 943 | |
944 | 944 | } else { |
945 | 945 | ps->g_last_had_sa = 0; |
946 | 946 | } |
947 | ||
947 | ||
948 | 948 | if (ps->bs_enable_pan) |
949 | 949 | { |
950 | 950 | drm_add_pan(ps, X_left, X_right); |
951 | ||
952 | ps->g_last_had_pan = 1; | |
951 | ||
952 | ps->g_last_had_pan = 1; | |
953 | 953 | |
954 | 954 | memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); |
955 | 955 |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
47 | 47 | #define MAX_DELAY 5 |
48 | 48 | |
49 | 49 | typedef struct |
50 | { | |
50 | { | |
51 | 51 | uint8_t drm_ps_data_available; |
52 | 52 | uint8_t bs_enable_sa; |
53 | 53 | uint8_t bs_enable_pan; |
60 | 60 | |
61 | 61 | int8_t bs_sa_data[DRM_NUM_SA_BANDS]; |
62 | 62 | int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; |
63 | ||
63 | ||
64 | 64 | 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]; | |
66 | 66 | 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]; | |
68 | 68 | |
69 | 69 | int8_t sa_decode_error; |
70 | 70 | int8_t pan_decode_error; |
71 | 71 | |
72 | 72 | int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; |
73 | 73 | 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]; | |
76 | 76 | |
77 | 77 | complex_t d_buff[2][MAX_SA_BAND]; |
78 | 78 | complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; |
79 | 79 | |
80 | uint8_t delay_buf_index_ser[NUM_OF_LINKS]; | |
81 | ||
80 | uint8_t delay_buf_index_ser[NUM_OF_LINKS]; | |
81 | ||
82 | 82 | real_t prev_nrg[MAX_SA_BAND]; |
83 | 83 | real_t prev_peakdiff[MAX_SA_BAND]; |
84 | real_t peakdecay_fast[MAX_SA_BAND]; | |
84 | real_t peakdecay_fast[MAX_SA_BAND]; | |
85 | 85 | } drm_ps_info; |
86 | 86 | |
87 | 87 |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
36 | 36 | #include "specrec.h" |
37 | 37 | #include "huffman.h" |
38 | 38 | |
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) | |
41 | 41 | * |
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. | |
46 | 46 | * 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, | |
48 | 48 | * with the writing direction alternating. |
49 | 49 | * Data length is not increased. |
50 | 50 | */ |
59 | 59 | #define VCB11_FIRST 16 |
60 | 60 | #define VCB11_LAST 31 |
61 | 61 | |
62 | static const uint8_t PreSortCB_STD[NUM_CB] = | |
62 | static const uint8_t PreSortCB_STD[NUM_CB] = | |
63 | 63 | { 11, 9, 7, 5, 3, 1}; |
64 | 64 | |
65 | static const uint8_t PreSortCB_ER[NUM_CB_ER] = | |
65 | static const uint8_t PreSortCB_ER[NUM_CB_ER] = | |
66 | 66 | { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1}; |
67 | 67 | |
68 | 68 | /* 8.5.3.3.2 Derivation of segment width */ |
73 | 73 | #define segmentWidth(cb) min(maxCwLen[cb], ics->length_of_longest_codeword) |
74 | 74 | |
75 | 75 | /* 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}; | |
77 | 77 | static const uint32_t B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; |
78 | 78 | |
79 | 79 | typedef struct |
87 | 87 | /* rewind and reverse */ |
88 | 88 | /* 32 bit version */ |
89 | 89 | static uint32_t rewrev_word(uint32_t v, const uint8_t len) |
90 | { | |
90 | { | |
91 | 91 | /* 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]); | |
95 | 95 | v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); |
96 | 96 | v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); |
97 | 97 | |
103 | 103 | |
104 | 104 | /* 64 bit version */ |
105 | 105 | static void rewrev_lword(uint32_t *hi, uint32_t *lo, const uint8_t len) |
106 | { | |
106 | { | |
107 | 107 | if (len <= 32) { |
108 | 108 | *hi = 0; |
109 | 109 | *lo = rewrev_word(*lo, len); |
112 | 112 | uint32_t t = *hi, v = *lo; |
113 | 113 | |
114 | 114 | /* 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]); | |
121 | 121 | v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); |
122 | 122 | 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]); | |
124 | 124 | t = ((t >> S[4]) & B[4]) | ((t << S[4]) & ~B[4]); |
125 | 125 | |
126 | 126 | /* last 32<>32 bit swap is implicit below */ |
127 | ||
127 | ||
128 | 128 | /* shift off low bits (this is really only one 64 bit shift) */ |
129 | 129 | *lo = (t >> (64 - len)) | (v << (len - 32)); |
130 | *hi = v >> (64 - len); | |
130 | *hi = v >> (64 - len); | |
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
149 | 149 | |
150 | 150 | al = a->bufa; |
151 | 151 | ah = a->bufb; |
152 | ||
152 | ||
153 | 153 | if (b->len > 32) |
154 | 154 | { |
155 | 155 | /* maskoff superfluous high b bits */ |
160 | 160 | al = 0; |
161 | 161 | } else { |
162 | 162 | bl = b->bufa & ((1 << (b->len)) - 1); |
163 | bh = 0; | |
163 | bh = 0; | |
164 | 164 | ah = (ah << (b->len)) | (al >> (32 - b->len)); |
165 | 165 | al = al << b->len; |
166 | 166 | } |
171 | 171 | |
172 | 172 | b->len += a->len; |
173 | 173 | } |
174 | ||
174 | ||
175 | 175 | static uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB) |
176 | 176 | { |
177 | 177 | /* only want spectral data CB's */ |
189 | 189 | } |
190 | 190 | return 0; |
191 | 191 | } |
192 | ||
192 | ||
193 | 193 | static void read_segment(bits_t *segment, uint8_t segwidth, bitfile *ld) |
194 | 194 | { |
195 | 195 | segment->len = segwidth; |
196 | 196 | |
197 | 197 | if (segwidth > 32) |
198 | 198 | { |
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); | |
201 | 201 | |
202 | 202 | } else { |
203 | 203 | segment->bufa = faad_getbits(ld, segwidth); |
204 | segment->bufb = 0; | |
205 | } | |
204 | segment->bufb = 0; | |
205 | } | |
206 | 206 | } |
207 | 207 | |
208 | 208 | static void fill_in_codeword(codeword_t *codeword, uint16_t index, uint16_t sp, uint8_t cb) |
213 | 213 | codeword[index].bits.len = 0; |
214 | 214 | } |
215 | 215 | |
216 | uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, | |
216 | uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, | |
217 | 217 | bitfile *ld, int16_t *spectral_data) |
218 | { | |
218 | { | |
219 | 219 | uint16_t PCWs_done; |
220 | uint16_t numberOfSegments, numberOfSets, numberOfCodewords; | |
220 | uint16_t numberOfSegments, numberOfSets, numberOfCodewords; | |
221 | 221 | |
222 | 222 | codeword_t codeword[512]; |
223 | 223 | bits_t segment[512]; |
225 | 225 | uint16_t sp_offset[8]; |
226 | 226 | uint16_t g, i, sortloop, set, bitsread; |
227 | 227 | /*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 | ||
230 | 230 | const uint16_t nshort = hDecoder->frameLength/8; |
231 | 231 | const uint16_t sp_data_len = ics->length_of_reordered_spectral_data; |
232 | ||
232 | ||
233 | 233 | const uint8_t *PreSortCb; |
234 | 234 | |
235 | 235 | /* no data (e.g. silence) */ |
241 | 241 | return 10; |
242 | 242 | |
243 | 243 | if (sp_data_len < ics->length_of_longest_codeword) |
244 | return 10; | |
244 | return 10; | |
245 | 245 | |
246 | 246 | sp_offset[0] = 0; |
247 | 247 | for (g = 1; g < ics->num_window_groups; g++) |
264 | 264 | PreSortCb = PreSortCB_STD; |
265 | 265 | last_CB = NUM_CB; |
266 | 266 | } |
267 | ||
267 | ||
268 | 268 | /* step 1: decode PCW's (set 0), and stuff data in easier-to-use format */ |
269 | 269 | for (sortloop = 0; sortloop < last_CB; sortloop++) |
270 | 270 | { |
271 | 271 | /* select codebook to process this pass */ |
272 | 272 | this_CB = PreSortCb[sortloop]; |
273 | ||
273 | ||
274 | 274 | /* loop over sfbs */ |
275 | 275 | for (sfb = 0; sfb < ics->max_sfb; sfb++) |
276 | 276 | { |
283 | 283 | { |
284 | 284 | /* check whether sfb used here is the one we want to process */ |
285 | 285 | if ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb)) |
286 | { | |
286 | { | |
287 | 287 | /* check whether codebook used here is the one we want to process */ |
288 | 288 | 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)) | |
291 | 291 | { |
292 | 292 | /* precalculate some stuff */ |
293 | 293 | uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb]; |
294 | 294 | uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN; |
295 | 295 | uint16_t group_cws_count = (4*ics->window_group_length[g])/inc; |
296 | 296 | 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?) */ | |
300 | 300 | for (cws = 0; (cws < group_cws_count) && ((cws + w_idx*group_cws_count) < sect_sfb_size); cws++) |
301 | 301 | { |
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); | |
303 | 303 | |
304 | 304 | /* read and decode PCW */ |
305 | 305 | if (!PCWs_done) |
306 | { | |
306 | { | |
307 | 307 | /* read in normal segments */ |
308 | 308 | if (bitsread + segwidth <= sp_data_len) |
309 | { | |
310 | read_segment(&segment[numberOfSegments], segwidth, ld); | |
309 | { | |
310 | read_segment(&segment[numberOfSegments], segwidth, ld); | |
311 | 311 | 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]); | |
314 | 314 | |
315 | 315 | /* keep leftover bits */ |
316 | 316 | rewrev_bits(&segment[numberOfSegments]); |
321 | 321 | this in earlier because it might not fit in 64 bits. since we already |
322 | 322 | decoded (and removed) the PCW it is now guaranteed to fit */ |
323 | 323 | 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); | |
328 | 328 | segment[numberOfSegments].len += segment[numberOfSegments-1].len; |
329 | rewrev_bits(&segment[numberOfSegments]); | |
329 | rewrev_bits(&segment[numberOfSegments]); | |
330 | 330 | |
331 | 331 | if (segment[numberOfSegments-1].len > 32) |
332 | 332 | { |
333 | segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb + | |
333 | segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb + | |
334 | 334 | 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 + | |
336 | 336 | showbits_hcr(&segment[numberOfSegments-1], 32); |
337 | 337 | } else { |
338 | segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + | |
338 | segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + | |
339 | 339 | showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len); |
340 | 340 | segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb; |
341 | } | |
341 | } | |
342 | 342 | segment[numberOfSegments-1].len += additional_bits; |
343 | 343 | } |
344 | 344 | bitsread = sp_data_len; |
345 | 345 | PCWs_done = 1; |
346 | 346 | |
347 | fill_in_codeword(codeword, 0, sp, this_sec_CB); | |
347 | fill_in_codeword(codeword, 0, sp, this_sec_CB); | |
348 | 348 | } |
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); | |
351 | 351 | } |
352 | 352 | numberOfCodewords++; |
353 | } | |
353 | } | |
354 | 354 | } |
355 | 355 | } |
356 | } | |
357 | } | |
356 | } | |
357 | } | |
358 | 358 | } |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | if (numberOfSegments == 0) |
363 | return 10; | |
364 | ||
365 | numberOfSets = numberOfCodewords / numberOfSegments; | |
363 | return 10; | |
364 | ||
365 | numberOfSets = numberOfCodewords / numberOfSegments; | |
366 | 366 | |
367 | 367 | /* step 2: decode nonPCWs */ |
368 | 368 | for (set = 1; set <= numberOfSets; set++) |
385 | 385 | { |
386 | 386 | uint8_t tmplen; |
387 | 387 | |
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 | ||
391 | 391 | tmplen = segment[segment_idx].len; |
392 | 392 | |
393 | 393 | if (huffman_spectral_data_2(codeword[codeword_idx].cb, &segment[segment_idx], |
394 | 394 | &spectral_data[codeword[codeword_idx].sp_offset]) >= 0) |
395 | 395 | { |
396 | 396 | codeword[codeword_idx].decoded = 1; |
397 | } else | |
398 | { | |
397 | } else | |
398 | { | |
399 | 399 | codeword[codeword_idx].bits = segment[segment_idx]; |
400 | codeword[codeword_idx].bits.len = tmplen; | |
400 | codeword[codeword_idx].bits.len = tmplen; | |
401 | 401 | } |
402 | ||
402 | ||
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
408 | 408 | } |
409 | 409 | |
410 | 410 | #if 0 // Seems to give false errors |
411 | bitsleft = 0; | |
412 | ||
411 | bitsleft = 0; | |
412 | ||
413 | 413 | for (i = 0; i < numberOfSegments && !bitsleft; i++) |
414 | 414 | bitsleft += segment[i].len; |
415 | 415 | |
417 | 417 | |
418 | 418 | codewordsleft = 0; |
419 | 419 | |
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++; | |
423 | 423 | |
424 | 424 | if (codewordsleft) return 10; |
425 | 425 | #endif |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
42 | 42 | |
43 | 43 | /* static function declarations */ |
44 | 44 | 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); | |
46 | 46 | static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp); |
47 | 47 | static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); |
48 | 48 | static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp); |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) | |
123 | static INLINE uint8_t huffman_getescape(bitfile *ld, int16_t *sp) | |
124 | 124 | { |
125 | 125 | uint8_t neg, i; |
126 | 126 | int16_t j; |
127 | 127 | 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; | |
133 | 134 | neg = 1; |
134 | 135 | } else { |
135 | if (sp != 16) | |
136 | return sp; | |
136 | if (x != 16) | |
137 | return 0; | |
137 | 138 | neg = 0; |
138 | 139 | } |
139 | 140 | |
140 | for (i = 4; ; i++) | |
141 | for (i = 4; i < 16; i++) | |
141 | 142 | { |
142 | 143 | if (faad_get1bit(ld |
143 | 144 | DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0) |
145 | 146 | break; |
146 | 147 | } |
147 | 148 | } |
149 | if (i >= 16) | |
150 | return 10; | |
148 | 151 | |
149 | 152 | off = (int16_t)faad_getbits(ld, i |
150 | 153 | DEBUGVAR(1,9,"huffman_getescape(): escape")); |
153 | 156 | if (neg) |
154 | 157 | j = -j; |
155 | 158 | |
156 | return j; | |
159 | *sp = j; | |
160 | return 0; | |
157 | 161 | } |
158 | 162 | |
159 | 163 | static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp) |
356 | 360 | return huffman_2step_pair_sign(cb, ld, sp); |
357 | 361 | case 12: { |
358 | 362 | 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); | |
360 | 364 | return err; } |
361 | 365 | case 11: |
362 | 366 | { |
363 | 367 | 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]); | |
366 | 372 | return err; |
367 | 373 | } |
368 | 374 | #ifdef ERROR_RESILIENCE |
371 | 377 | case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: |
372 | 378 | { |
373 | 379 | 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]); | |
376 | 384 | |
377 | 385 | /* check LAV (Largest Absolute Value) */ |
378 | 386 | /* this finds errors in the ESCAPE signal */ |
445 | 453 | vcb11 = cb; |
446 | 454 | cb = 11; |
447 | 455 | } |
448 | ||
456 | ||
449 | 457 | cw = showbits_hcr(ld, hcbN[cb]); |
450 | 458 | offset = hcb_table[cb][cw].offset; |
451 | 459 | extra_bits = hcb_table[cb][cw].extra_bits; |
468 | 476 | while (!hcb3[offset].is_leaf) |
469 | 477 | { |
470 | 478 | uint8_t b; |
471 | ||
479 | ||
472 | 480 | if ( get1bit_hcr(ld, &b) ) return -1; |
473 | 481 | offset += hcb3[offset].data[b]; |
474 | 482 | } |
487 | 495 | while (!hcb_bin_table[cb][offset].is_leaf) |
488 | 496 | { |
489 | 497 | uint8_t b; |
490 | ||
498 | ||
491 | 499 | if (get1bit_hcr(ld, &b) ) return -1; |
492 | 500 | offset += hcb_bin_table[cb][offset].data[b]; |
493 | 501 | } |
526 | 534 | int32_t j; |
527 | 535 | uint32_t off; |
528 | 536 | |
529 | neg = (sp[k] < 0) ? 1 : 0; | |
537 | neg = (sp[k] < 0) ? 1 : 0; | |
530 | 538 | |
531 | 539 | for (i = 4; ; i++) |
532 | 540 | { |
550 | 558 | /* this finds errors in the ESCAPE signal */ |
551 | 559 | vcb11_check_LAV(vcb11, sp); |
552 | 560 | } |
553 | } | |
561 | } | |
554 | 562 | return ld->len; |
555 | 563 | } |
556 | 564 |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
53 | 53 | tmp |= (uint32_t)0x00010000; /* insert 1 lsb */ |
54 | 54 | tmp2 = tmp; /* add 1 lsb and elided one */ |
55 | 55 | tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ |
56 | ||
56 | ||
57 | 57 | *pf = *(float32_t*)&tmp1 + *(float32_t*)&tmp2 - *(float32_t*)&tmp; |
58 | 58 | } else { |
59 | 59 | *pf = *(float32_t*)&tmp; |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
31 | 31 | * Fast (I)MDCT Implementation using (I)FFT ((Inverse) Fast Fourier Transform) |
32 | 32 | * and consists of three steps: pre-(I)FFT complex multiplication, complex |
33 | 33 | * (I)FFT, post-(I)FFT complex multiplication, |
34 | * | |
34 | * | |
35 | 35 | * As described in: |
36 | 36 | * P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the |
37 | 37 | * 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. | |
39 | 39 | * |
40 | 40 | * |
41 | 41 | * As of April 6th 2002 completely rewritten. |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
106 | 106 | 0, /* 27 ER Parametric */ |
107 | 107 | #endif |
108 | 108 | 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 | |
110 | 114 | 0, /* 30 (Reserved) */ |
111 | 115 | 0 /* 31 (Reserved) */ |
112 | 116 | }; |
173 | 177 | |
174 | 178 | #ifdef SBR_DEC |
175 | 179 | mp4ASC->sbr_present_flag = -1; |
176 | if (mp4ASC->objectTypeIndex == 5) | |
180 | if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29) | |
177 | 181 | { |
178 | 182 | uint8_t tmp; |
179 | 183 | |
230 | 234 | else |
231 | 235 | bits_to_decode = (int8_t)(buffer_size*8 - (startpos-faad_get_processed_bits(ld))); |
232 | 236 | |
233 | if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16)) | |
237 | if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16)) | |
234 | 238 | { |
235 | 239 | int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11 |
236 | 240 | DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType")); |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
41 | 41 | uint32_t buffer_size, |
42 | 42 | mp4AudioSpecificConfig *mp4ASC, |
43 | 43 | program_config *pce, uint8_t short_form); |
44 | ||
44 | ||
45 | 45 | int8_t AudioSpecificConfigFromBitfile(bitfile *ld, |
46 | 46 | mp4AudioSpecificConfig *mp4ASC, |
47 | 47 | program_config *pce, uint32_t bsize, uint8_t short_form); |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
47 | 47 | |
48 | 48 | if (ics->ms_mask_present >= 1) |
49 | 49 | { |
50 | for (g = 0; g < ics->num_window_groups; g++) | |
50 | for (g = 0; g < ics->num_window_groups; g++) | |
51 | 51 | { |
52 | 52 | for (b = 0; b < ics->window_group_length[g]; b++) |
53 | 53 | { |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
235 | 235 | if ((ics_right != NULL) |
236 | 236 | && is_noise(ics_right, g, sfb)) |
237 | 237 | { |
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) && | |
239 | 249 | (((ics_left->ms_mask_present == 1) && |
240 | 250 | (ics_left->ms_used[g][sfb])) || |
241 | 251 | (ics_left->ms_mask_present == 2))) |
250 | 260 | ics_right->scale_factors[g][sfb], size, sub, &r1_dep, &r2_dep); |
251 | 261 | |
252 | 262 | } 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 | |
261 | 263 | |
262 | 264 | offs = ics_right->swb_offset[sfb]; |
263 | 265 | size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs; |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
453 | 453 | int8_t index; |
454 | 454 | uint32_t cw; |
455 | 455 | rvlc_huff_table *h = book_rvlc; |
456 | ||
456 | ||
457 | 457 | i = h->len; |
458 | 458 | if (direction > 0) |
459 | 459 | cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,"")); |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |
96 | 96 | { |
97 | 97 | sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; |
98 | 98 | sbr->numTimeSlots = NO_TIME_SLOTS_960; |
99 | } else { | |
99 | } | |
100 | else if (framelength == 1024) | |
101 | { | |
100 | 102 | sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; |
101 | 103 | sbr->numTimeSlots = NO_TIME_SLOTS; |
104 | } | |
105 | else | |
106 | { | |
107 | faad_free(sbr); | |
108 | return NULL; | |
102 | 109 | } |
103 | 110 | |
104 | 111 | sbr->GQ_ringbuf_index[0] = 0; |
165 | 172 | } |
166 | 173 | |
167 | 174 | #ifdef PS_DEC |
168 | if (sbr->ps != NULL) | |
175 | if (sbr->ps != NULL) | |
169 | 176 | ps_free(sbr->ps); |
170 | 177 | #endif |
171 | 178 | |
204 | 211 | |
205 | 212 | memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
206 | 213 | memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
207 | ||
214 | ||
208 | 215 | sbr->GQ_ringbuf_index[0] = 0; |
209 | 216 | sbr->GQ_ringbuf_index[1] = 0; |
210 | 217 | sbr->header_count = 0; |
0 | 0 | /* |
1 | 1 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
2 | 2 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
3 | ** | |
3 | ** | |
4 | 4 | ** This program is free software; you can redistribute it and/or modify |
5 | 5 | ** it under the terms of the GNU General Public License as published by |
6 | 6 | ** the Free Software Foundation; either version 2 of the License, or |
7 | 7 | ** (at your option) any later version. |
8 | ** | |
8 | ** | |
9 | 9 | ** This program is distributed in the hope that it will be useful, |
10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | ** GNU General Public License for more details. |
13 | ** | |
13 | ** | |
14 | 14 | ** 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 | |
16 | 16 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | 17 | ** |
18 | 18 | ** Any non-GPL usage of this software or parts of this software is strictly |