├── .bazelrc ├── .github └── workflows │ ├── build.yaml │ └── fuzz.yaml ├── .gitignore ├── AUTHORS ├── BUILD.bazel ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── README ├── WORKSPACE.bazel ├── docs ├── Ahead AAC Decoder library documentation.doc ├── Ahead AAC Decoder library documentation.pdf └── libfaad.3 ├── frontend ├── audio.c ├── audio.h ├── faad.man ├── getopt.c ├── getopt.h ├── main.c ├── mp4read.c ├── mp4read.h ├── unicode_support.c └── unicode_support.h ├── fuzz ├── fuzz_config.c └── fuzz_decode.c ├── include ├── faad.h.in └── neaacdec.h ├── libfaad ├── analysis.h ├── bits.c ├── bits.h ├── cfft.c ├── cfft.h ├── cfft_tab.h ├── codebook │ ├── hcb.h │ ├── hcb_1.h │ ├── hcb_10.h │ ├── hcb_11.h │ ├── hcb_2.h │ ├── hcb_3.h │ ├── hcb_4.h │ ├── hcb_5.h │ ├── hcb_6.h │ ├── hcb_7.h │ ├── hcb_8.h │ ├── hcb_9.h │ └── hcb_sf.h ├── common.c ├── common.h ├── decoder.c ├── drc.c ├── drc.h ├── drm_dec.c ├── drm_dec.h ├── error.c ├── error.h ├── faad2.pc.in ├── filtbank.c ├── filtbank.h ├── fixed.h ├── hcr.c ├── huffman.c ├── huffman.h ├── ic_predict.c ├── ic_predict.h ├── iq_table.h ├── is.c ├── is.h ├── kbd_win.h ├── lt_predict.c ├── lt_predict.h ├── mdct.c ├── mdct.h ├── mdct_tab.h ├── mp4.c ├── mp4.h ├── ms.c ├── ms.h ├── output.c ├── output.h ├── pns.c ├── pns.h ├── ps_dec.c ├── ps_dec.h ├── ps_syntax.c ├── ps_tables.h ├── pulse.c ├── pulse.h ├── rvlc.c ├── rvlc.h ├── sbr_dct.c ├── sbr_dct.h ├── sbr_dec.c ├── sbr_dec.h ├── sbr_e_nf.c ├── sbr_e_nf.h ├── sbr_fbt.c ├── sbr_fbt.h ├── sbr_hfadj.c ├── sbr_hfadj.h ├── sbr_hfgen.c ├── sbr_hfgen.h ├── sbr_huff.c ├── sbr_huff.h ├── sbr_noise.h ├── sbr_qmf.c ├── sbr_qmf.h ├── sbr_qmf_c.h ├── sbr_syntax.c ├── sbr_syntax.h ├── sbr_tf_grid.c ├── sbr_tf_grid.h ├── sine_win.h ├── specrec.c ├── specrec.h ├── ssr.c ├── ssr.h ├── ssr_fb.c ├── ssr_fb.h ├── ssr_ipqf.c ├── ssr_ipqf.h ├── ssr_win.h ├── structs.h ├── syntax.c ├── syntax.h ├── tns.c └── tns.h ├── libfaad2.def ├── properties.json └── workspace.bzl /.bazelrc: -------------------------------------------------------------------------------- 1 | # Force the use of Clang for C++ builds. 2 | build --action_env=CC=clang 3 | build --action_env=CXX=clang++ 4 | 5 | # Define the --config=asan-libfuzzer configuration. 6 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 7 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 8 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan 9 | 10 | # Define the --config=msan-libfuzzer configuration. 11 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 12 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 13 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan 14 | 15 | # Define the --config=ubsan-libfuzzer configuration. 16 | build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 17 | build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 18 | build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan 19 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | # FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 2 | # Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 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 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | # 18 | # Any non-GPL usage of this software or parts of this software is strictly 19 | # forbidden. 20 | # 21 | # The "appropriate copyright message" mentioned in section 2c of the GPLv2 22 | # must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 23 | # 24 | # Commercial non-GPL licensing of this software is possible. 25 | # For more info contact Nero AG through Mpeg4AAClicense@nero.com. 26 | 27 | name: Build 28 | on: 29 | push: 30 | branches: [master] 31 | pull_request: 32 | types: [opened, reopened, labeled, synchronize] 33 | 34 | concurrency: 35 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} 36 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} 37 | 38 | jobs: 39 | BuildWithBazel: 40 | runs-on: ubuntu-latest 41 | 42 | strategy: 43 | fail-fast: false 44 | 45 | steps: 46 | - name: Checkout the source 47 | uses: actions/checkout@v4 48 | with: 49 | submodules: false 50 | fetch-depth: 1 51 | - name: Configure and build 52 | run: | 53 | bazel build :all 54 | 55 | BuildWithCMake: 56 | runs-on: ${{ matrix.os || 'ubuntu-latest' }} 57 | 58 | strategy: 59 | fail-fast: false 60 | matrix: 61 | include: 62 | - name: Clang Shared 63 | cc: clang 64 | cxx: clang++ 65 | cflags: -Wall -fcolor-diagnostics -fansi-escape-codes 66 | shared: 'true' 67 | - name: Clang Static 68 | cc: clang 69 | cxx: clang++ 70 | cflags: -Wall -fcolor-diagnostics -fansi-escape-codes -O2 -Werror=strict-aliasing 71 | - name: GCC Static 72 | cc: gcc 73 | cxx: g++ 74 | cflags: -Wall -fdiagnostics-color=always -O2 -Werror=strict-aliasing 75 | - name: MSVC 76 | os: windows-latest 77 | cmake_args: >- 78 | -G "Visual Studio 17 2022" -A x64 79 | cmake_build_options: >- 80 | --config Release 81 | - name: OSX 82 | os: macos-latest 83 | 84 | env: 85 | CC: ${{ matrix.cc || 'cc' }} 86 | CXX: ${{ matrix.cxx || 'cxx' }} 87 | CFLAGS: ${{ matrix.cflags || '-Wall' }} 88 | CXXFLAGS: ${{ matrix.cflags || '-Wall' }} 89 | SHARED: ${{ matrix.shared || 'false' }} 90 | 91 | steps: 92 | - name: Checkout the source 93 | uses: actions/checkout@v4 94 | with: 95 | submodules: false 96 | fetch-depth: 1 97 | - name: Configure and build 98 | shell: bash 99 | run: | 100 | export NUM_CORES=`nproc || getconf _NPROCESSORS_ONLN` 101 | cmake -B build . \ 102 | -DCMAKE_INSTALL_PREFIX=$RUNNER_TEMP/usrlocal \ 103 | -DBUILD_SHARED_LIBS=${SHARED} \ 104 | ${{ matrix.cmake_args }} 105 | cmake --build build -j ${NUM_CORES} ${{ matrix.cmake_build_options || '' }} 106 | cmake --install build 107 | 108 | BuildOnMsys: 109 | name: BuildOnMsys (${{ matrix.msystem }}) 110 | runs-on: windows-latest 111 | strategy: 112 | fail-fast: false 113 | matrix: 114 | include: 115 | - msystem: mingw64 116 | - msystem: clang64 117 | - msystem: ucrt64 118 | - msystem: mingw32 119 | defaults: 120 | run: 121 | shell: msys2 {0} 122 | steps: 123 | - name: Checkout the source 124 | uses: actions/checkout@v4 125 | with: 126 | submodules: false 127 | fetch-depth: 1 128 | - uses: msys2/setup-msys2@v2 129 | with: 130 | msystem: ${{ matrix.msystem }} 131 | update: true 132 | path-type: inherit 133 | install: >- 134 | base-devel 135 | pacboy: >- 136 | cmake:p 137 | - name: Configure and build 138 | run: | 139 | mkdir -p temp 140 | cmake -B build . \ 141 | -DCMAKE_INSTALL_PREFIX=$(realpath temp) \ 142 | -DBUILD_SHARED_LIBS='true' 143 | cmake --build build -j `nproc` 144 | cmake --install build 145 | - name: Upload artifacts (Windows) 146 | uses: actions/upload-artifact@v4 147 | if: runner.os == 'Windows' 148 | with: 149 | name: faad2-${{ github.sha }}-${{ matrix.msystem }} 150 | path: temp 151 | -------------------------------------------------------------------------------- /.github/workflows/fuzz.yaml: -------------------------------------------------------------------------------- 1 | # FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 2 | # Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 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 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | # 18 | # Any non-GPL usage of this software or parts of this software is strictly 19 | # forbidden. 20 | # 21 | # The "appropriate copyright message" mentioned in section 2c of the GPLv2 22 | # must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 23 | # 24 | # Commercial non-GPL licensing of this software is possible. 25 | # For more info contact Nero AG through Mpeg4AAClicense@nero.com. 26 | 27 | name: OSS-Fuzz 28 | on: 29 | push: 30 | branches: [master] 31 | pull_request: 32 | types: [opened, reopened, labeled, synchronize] 33 | 34 | concurrency: 35 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} 36 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} 37 | 38 | jobs: 39 | Fuzzing: 40 | runs-on: ubuntu-latest 41 | strategy: 42 | fail-fast: false 43 | matrix: 44 | sanitizer: [address, undefined, memory] 45 | steps: 46 | - name: Build Fuzzers (${{ matrix.sanitizer }}) 47 | id: build 48 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 49 | with: 50 | oss-fuzz-project-name: 'faad2' 51 | language: c 52 | sanitizer: ${{ matrix.sanitizer }} 53 | - name: Run Fuzzers (${{ matrix.sanitizer }}) 54 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 55 | with: 56 | oss-fuzz-project-name: 'faad' 57 | language: c 58 | sanitizer: ${{ matrix.sanitizer }} 59 | fuzz-seconds: 600 60 | - name: Upload Crash 61 | uses: actions/upload-artifact@v3 62 | if: failure() && steps.build.outcome == 'success' 63 | with: 64 | name: ${{ matrix.sanitizer }}-artifacts 65 | path: ./out/artifacts 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | M. Bakker (mbakker(at)nero.com) 3 | - complete library 4 | 5 | Alexander Kurpiers (a.kurpiers(at)nt.tu-darmstadt.de) 6 | - HCR code 7 | - DRM stuff 8 | - lot's of bug fixes 9 | 10 | Volker Fischer (v.fischer(at)nt.tu-darmstadt.de) 11 | - DRM code 12 | - lot's of bug fixes 13 | 14 | Gian-Carlo Pascutto (gpascutto(at)nero.com) 15 | - DRM PS code 16 | - bugfixes 17 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") 2 | load("@properties//:properties.bzl", "PROPERTIES") 3 | 4 | # Unless building for embedded systems all headers / functions should exist. 5 | FAAD_DEFINES = [ 6 | "APPLY_DRC", 7 | "HAVE_INTTYPES_H=1", 8 | "HAVE_MEMCPY=1", 9 | "HAVE_STRING_H=1", 10 | "HAVE_STRINGS_H=1", 11 | "HAVE_SYS_STAT_H=1", 12 | "HAVE_SYS_TYPES_H=1", 13 | "PACKAGE_VERSION=\\\"%s\\\"" % PROPERTIES["PACKAGE_VERSION"], 14 | ] 15 | 16 | FAAD_SOURCES = glob([ 17 | "libfaad/**/*.c", 18 | "libfaad/**/*.h", 19 | ]) 20 | 21 | FAAD_FLAGS = [ 22 | "-Wall", 23 | "-pedantic", 24 | ] 25 | 26 | DRM_AFFIX = [ 27 | "", 28 | "_drm", 29 | ] 30 | 31 | DRM_DEFINES = [ 32 | [], 33 | ["DRM_SUPPORT"], 34 | ] 35 | 36 | FIXED_AFFIX = [ 37 | "", 38 | "_fixed", 39 | ] 40 | 41 | FIXED_DEFINES = [ 42 | [], 43 | ["FIXED_POINT"], 44 | ] 45 | 46 | [cc_library( 47 | name = "faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], 48 | srcs = FAAD_SOURCES, 49 | hdrs = ["include/neaacdec.h"], 50 | copts = FAAD_FLAGS, 51 | includes = ["libfaad"], 52 | local_defines = FAAD_DEFINES + DRM_DEFINES[drm] + FIXED_DEFINES[fixed], 53 | strip_include_prefix = "include", 54 | ) for drm in range(2) for fixed in range(2)] 55 | 56 | # To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_config_run 57 | cc_fuzz_test( 58 | name = "fuzz_config", 59 | srcs = ["fuzz/fuzz_config.c"], 60 | deps = [":faad"], 61 | ) 62 | 63 | # To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_decode_run 64 | [cc_fuzz_test( 65 | name = "fuzz_decode" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], 66 | srcs = ["fuzz/fuzz_decode.c"], 67 | local_defines = DRM_DEFINES[drm], 68 | deps = [":faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed]], 69 | ) for drm in range(2) for fixed in range(2)] 70 | 71 | CLI_SOURCES = glob(["frontend/**/*.c", "frontend/**/*.h"], exclude = ["frontend/**/getopt.*"]) 72 | 73 | [cc_binary( 74 | name = "faad_cli" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], 75 | srcs = CLI_SOURCES, 76 | includes = ["frontend"], 77 | local_defines = FAAD_DEFINES + DRM_DEFINES[drm] + FIXED_DEFINES[fixed], 78 | deps = [":faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed]], 79 | ) for drm in range(2) for fixed in range(2)] 80 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | 4 | FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder. 5 | FAAD2 includes code for SBR (HE AAC) decoding. 6 | FAAD2 is licensed under the GPL. 7 | 8 | 9 | __________ 10 | COPYRIGHTS 11 | 12 | For FAAD2 the following license applies: 13 | 14 | ****************************************************************************** 15 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 16 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 17 | ** 18 | ** This program is free software; you can redistribute it and/or modify 19 | ** it under the terms of the GNU General Public License as published by 20 | ** the Free Software Foundation; either version 2 of the License, or 21 | ** (at your option) any later version. 22 | ** 23 | ** This program is distributed in the hope that it will be useful, 24 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | ** GNU General Public License for more details. 27 | ** 28 | ** You should have received a copy of the GNU General Public License 29 | ** along with this program; if not, write to the Free Software 30 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 31 | ** 32 | ** Any non-GPL usage of this software or parts of this software is strictly 33 | ** forbidden. 34 | ** 35 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 36 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 37 | ** 38 | ** Commercial non-GPL licensing of this software is possible. 39 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 40 | ****************************************************************************** 41 | 42 | 43 | Please note that the use of this software may require the payment of 44 | patent royalties. You need to consider this issue before you start 45 | building derivative works. We are not warranting or indemnifying you in 46 | any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN 47 | ACTIONS! 48 | 49 | 50 | ___________________ 51 | DIRECTORY STRUCTURE 52 | 53 | faad2 - top level directory. 54 | 55 | docs - API documentation. 56 | 57 | frontend - command line frontend to the FAAD2 library, also supports 58 | MPEG-4 file decoding. 59 | 60 | include - inlude file for the FAAD2 library. 61 | 62 | libfaad - the FAAD2 AAC decoder library including SBR. 63 | 64 | codebook - Huffman codebooks. 65 | 66 | project/msvc - Visual Studio 2017 project files. 67 | -------------------------------------------------------------------------------- /WORKSPACE.bazel: -------------------------------------------------------------------------------- 1 | load(":workspace.bzl", "wrap_json_properties") 2 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 3 | 4 | wrap_json_properties(name = "properties", src = "@//:properties.json") 5 | 6 | http_archive( 7 | name = "rules_fuzzing", 8 | sha256 = "ff52ef4845ab00e95d29c02a9e32e9eff4e0a4c9c8a6bcf8407a2f19eb3f9190", 9 | strip_prefix = "rules_fuzzing-0.4.1", 10 | urls = ["https://github.com/bazelbuild/rules_fuzzing/releases/download/v0.4.1/rules_fuzzing-0.4.1.zip"], 11 | ) 12 | 13 | load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") 14 | 15 | rules_fuzzing_dependencies() 16 | 17 | load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") 18 | 19 | rules_fuzzing_init() 20 | 21 | load("@fuzzing_py_deps//:requirements.bzl", "install_deps") 22 | 23 | install_deps() 24 | -------------------------------------------------------------------------------- /docs/Ahead AAC Decoder library documentation.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knik0/faad2/673a22a3c7c33e96e2ff7aae7c4d2bc190dfbf92/docs/Ahead AAC Decoder library documentation.doc -------------------------------------------------------------------------------- /docs/Ahead AAC Decoder library documentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knik0/faad2/673a22a3c7c33e96e2ff7aae7c4d2bc190dfbf92/docs/Ahead AAC Decoder library documentation.pdf -------------------------------------------------------------------------------- /frontend/audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: audio.h,v 1.19 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | #ifndef AUDIO_H_INCLUDED 32 | #define AUDIO_H_INCLUDED 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define MAXWAVESIZE 4294967040LU 39 | 40 | #define OUTPUT_WAV 1 41 | #define OUTPUT_RAW 2 42 | 43 | typedef struct 44 | { 45 | int toStdio; 46 | int outputFormat; 47 | FILE *sndfile; 48 | unsigned int fileType; 49 | unsigned long samplerate; 50 | unsigned int bits_per_sample; 51 | unsigned int channels; 52 | unsigned long total_samples; 53 | long channelMask; 54 | } audio_file; 55 | 56 | audio_file *open_audio_file(char *infile, int samplerate, int channels, 57 | int outputFormat, int fileType, long channelMask); 58 | size_t write_audio_file(audio_file *aufile, void *sample_buffer, int samples); 59 | void close_audio_file(audio_file *aufile); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif 65 | -------------------------------------------------------------------------------- /frontend/faad.man: -------------------------------------------------------------------------------- 1 | .TH FAAD "1" "October 2006" "faad 2.5" "" 2 | .SH NAME 3 | faad \(em Process an Advanced Audio Codec stream 4 | 5 | .SH "SYNOPSIS" 6 | .B faad 7 | [options] [\-w | \-o | \-a ] input_filename 8 | 9 | .SH "DESCRIPTION" 10 | This utility provides a command line interface to libfaad2. This program reads in MPEG\(hy4 AAC files, processes, and outputs them in either Microsoft WAV, MPEG\(hy4 AAC ADTS, or standard PCM formats. 11 | 12 | .SH "OPTIONS" 13 | .TP 14 | .BI \-a " " ", \-\^\-adtsout" " " 15 | Sets the processing to output to the specified file in MPEG\(hy4 AAC ADTS format 16 | .TP 17 | .BI \-b " " ", \-\^\-bits" " " 18 | Set the output (individual) sample format. The number takes one of the following values: 19 | .RS 20 | .RS 21 | 1: 16\(hybit PCM data (default). 22 | .br 23 | 2: 24\(hybit PCM data. 24 | .br 25 | 3: 32\(hybit PCM data. 26 | .br 27 | 4: 32\(hybit floating\(hypoint data. 28 | .br 29 | 5: 64\(hybit floating\(hypoint data. 30 | .RE 31 | .RE 32 | .TP 33 | .B \-d ", \-\^\-downmix" 34 | Set the processing to downsample from 5.1 (surround sound and bass) channels to 2 channels (stereo). 35 | .TP 36 | .BI \-f " " ", \-\^\-format" " " 37 | Set the output file format. The number takes one of the following values: 38 | .RS 39 | .RS 40 | 1: Microsoft WAV format (default). 41 | .br 42 | 2: Raw PCM data. 43 | .RE 44 | .RE 45 | .TP 46 | .BI \-g 47 | Set the processing to not perform gapless decoding. 48 | .TP 49 | .B \-h ", \-\^\-help" 50 | Shows a usage summary. 51 | .TP 52 | .B \-i ", \-\^\-info" 53 | Shows information about the about the input file. 54 | .TP 55 | .BI \-l " " ", \-\^\-objecttype" " " 56 | Sets the MPEG\hy(4 profile and object type for the processing to use. The number takes one of the following values: 57 | .RS 58 | .RS 59 | 1: Main object type. 60 | .br 61 | 2: Low Complexity (LC) object type (default). 62 | .br 63 | 4: Long Term Prediction (LTP) object type. 64 | .br 65 | 23: Low Delay (LD) object type. 66 | .RE 67 | .RE 68 | .TP 69 | .BI \-o " " ", \-\^\-outfile" " " 70 | Sets the filename for processing output. 71 | .TP 72 | .B \-q ", \-\^\-quiet" 73 | Quiet \- Suppresses status messages during processing. 74 | .TP 75 | .B \-t ", \-\^\-oldformat" 76 | Sets the processing to use the old MPEG\(hy4 AAC ADTS format when outputting in said format. 77 | .TP 78 | .B \-w ", \-\^\-stdio" 79 | Sets the processing output to be sent to the standard out. 80 | 81 | .SH "AUTHOR" 82 | Matthew W. S. Bell 83 | 84 | .SH "SEE ALSO" 85 | \fBfaac\fP(1) -------------------------------------------------------------------------------- /frontend/getopt.h: -------------------------------------------------------------------------------- 1 | /* Declarations for getopt. 2 | Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms of the GNU General Public License as published by the 6 | Free Software Foundation; either version 2, or (at your option) any 7 | later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 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 16 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 17 | 18 | #ifndef _GETOPT_H 19 | #define _GETOPT_H 1 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #ifndef __MacOSX__ 26 | 27 | /* For communication from `getopt' to the caller. 28 | When `getopt' finds an option that takes an argument, 29 | the argument value is returned here. 30 | Also, when `ordering' is RETURN_IN_ORDER, 31 | each non-option ARGV-element is returned here. */ 32 | 33 | extern char *optarg; 34 | 35 | /* Index in ARGV of the next element to be scanned. 36 | This is used for communication to and from the caller 37 | and for communication between successive calls to `getopt'. 38 | 39 | On entry to `getopt', zero means this is the first call; initialize. 40 | 41 | When `getopt' returns EOF, this is the index of the first of the 42 | non-option elements that the caller should itself scan. 43 | 44 | Otherwise, `optind' communicates from one call to the next 45 | how much of ARGV has been scanned so far. */ 46 | 47 | extern int optind; 48 | 49 | /* Callers store zero here to inhibit the error message `getopt' prints 50 | for unrecognized options. */ 51 | 52 | extern int opterr; 53 | 54 | /* Set to an option character which was unrecognized. */ 55 | 56 | extern int optopt; 57 | #endif 58 | 59 | /* Describe the long-named options requested by the application. 60 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 61 | of `struct option' terminated by an element containing a name which is 62 | zero. 63 | 64 | The field `has_arg' is: 65 | no_argument (or 0) if the option does not take an argument, 66 | required_argument (or 1) if the option requires an argument, 67 | optional_argument (or 2) if the option takes an optional argument. 68 | 69 | If the field `flag' is not NULL, it points to a variable that is set 70 | to the value given in the field `val' when the option is found, but 71 | left unchanged if the option is not found. 72 | 73 | To have a long-named option do something other than set an `int' to 74 | a compiled-in constant, such as set a value from `optarg', set the 75 | option's `flag' field to zero and its `val' field to a nonzero 76 | value (the equivalent single-letter option character, if there is 77 | one). For long options that have a zero `flag' field, `getopt' 78 | returns the contents of the `val' field. */ 79 | 80 | struct option 81 | { 82 | #if __STDC__ 83 | const char *name; 84 | #else 85 | char *name; 86 | #endif 87 | /* has_arg can't be an enum because some compilers complain about 88 | type mismatches in all the code that assumes it is an int. */ 89 | int has_arg; 90 | int *flag; 91 | int val; 92 | }; 93 | 94 | /* Names for the values of the `has_arg' field of `struct option'. */ 95 | 96 | #define no_argument 0 97 | #define required_argument 1 98 | #define optional_argument 2 99 | 100 | //#if __STDC__ || defined(PROTO) 101 | #if defined(__GNU_LIBRARY__) 102 | /* Many other libraries have conflicting prototypes for getopt, with 103 | differences in the consts, in stdlib.h. To avoid compilation 104 | errors, only prototype getopt for the GNU C library. */ 105 | extern int getopt (int argc, char *const *argv, const char *shortopts); 106 | #endif /* not __GNU_LIBRARY__ */ 107 | extern int getopt_long (int argc, char *const *argv, const char *shortopts, 108 | const struct option *longopts, int *longind); 109 | extern int getopt_long_only (int argc, char *const *argv, 110 | const char *shortopts, 111 | const struct option *longopts, int *longind); 112 | 113 | /* Internal only. Users should not call this directly. */ 114 | extern int _getopt_internal (int argc, char *const *argv, 115 | const char *shortopts, 116 | const struct option *longopts, int *longind, 117 | int long_only); 118 | //#else /* not __STDC__ */ 119 | extern int getopt (int argc, char *const *argv, const char *shortopts); 120 | //extern int getopt_long (); 121 | //extern int getopt_long_only (); 122 | 123 | //extern int _getopt_internal (); 124 | //#endif /* not __STDC__ */ 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* _GETOPT_H */ 131 | -------------------------------------------------------------------------------- /frontend/mp4read.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | MP4 input module 3 | 4 | Copyright (C) 2017 Krzysztof Nikiel 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ****************************************************************************/ 19 | 20 | #include 21 | 22 | typedef struct 23 | { 24 | uint32_t len; 25 | uint32_t offset; 26 | } frame_info_t; 27 | 28 | typedef struct 29 | { 30 | uint32_t firstchunk; 31 | uint32_t samplesperchunk; 32 | } slice_info_t; 33 | 34 | typedef struct 35 | { 36 | uint32_t ctime, mtime; 37 | uint32_t samplerate; 38 | // total sound samples 39 | uint32_t samples; 40 | uint32_t channels; 41 | // sample depth 42 | uint32_t bits; 43 | // buffer config 44 | uint32_t buffersize; 45 | uint32_t bitratemax; 46 | uint32_t bitrateavg; 47 | // frame size / offsets 48 | struct 49 | { 50 | frame_info_t *info; 51 | slice_info_t *map; 52 | uint32_t nsamples; 53 | uint32_t nsclices; 54 | uint32_t current; 55 | uint32_t maxsize; 56 | } frame; 57 | // AudioSpecificConfig data: 58 | struct 59 | { 60 | uint8_t buf[10]; 61 | uint32_t size; 62 | } asc; 63 | struct { 64 | uint32_t size; 65 | uint8_t *data; 66 | } bitbuf; 67 | struct { 68 | int header; 69 | int tags; 70 | } verbose; 71 | } mp4config_t; 72 | 73 | extern mp4config_t mp4config; 74 | 75 | int mp4read_open(char *name); 76 | int mp4read_seek(uint32_t framenum); 77 | int mp4read_frame(void); 78 | int mp4read_close(void); 79 | -------------------------------------------------------------------------------- /frontend/unicode_support.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2012 LoRd_MuldeR 2 | File: unicode_support.c 3 | 4 | This file was originally part of a patch included with LameXP, 5 | released under the same license as the original audio tools. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 22 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #define _CRT_SECURE_NO_WARNINGS 32 | #include 33 | 34 | #if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 35 | 36 | #include "unicode_support.h" 37 | 38 | #include 39 | 40 | #define WIN32_LEAN_AND_MEAN 41 | #include 42 | #include 43 | #include 44 | 45 | static UINT g_old_output_cp = ((UINT)-1); 46 | 47 | static char *utf16_to_utf8(const wchar_t *input) 48 | { 49 | char *Buffer; 50 | int BuffSize = 0, Result = 0; 51 | 52 | BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL); 53 | Buffer = (char*) malloc(sizeof(char) * BuffSize); 54 | if(Buffer) 55 | { 56 | Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL); 57 | } 58 | 59 | return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL; 60 | } 61 | 62 | static wchar_t *utf8_to_utf16(const char *input) 63 | { 64 | wchar_t *Buffer; 65 | int BuffSize = 0, Result = 0; 66 | 67 | BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0); 68 | Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize); 69 | if(Buffer) 70 | { 71 | Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize); 72 | } 73 | 74 | return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL; 75 | } 76 | 77 | void init_commandline_arguments_utf8(int *argc, char ***argv) 78 | { 79 | int i, nArgs; 80 | LPWSTR *szArglist; 81 | 82 | szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); 83 | 84 | if(NULL == szArglist) 85 | { 86 | fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n"); 87 | exit(-1); 88 | } 89 | 90 | *argv = (char**) malloc(sizeof(char*) * nArgs); 91 | *argc = nArgs; 92 | 93 | if(NULL == *argv) 94 | { 95 | fprintf(stderr, "\nFATAL: Malloc failed\n\n"); 96 | exit(-1); 97 | } 98 | 99 | for(i = 0; i < nArgs; i++) 100 | { 101 | (*argv)[i] = utf16_to_utf8(szArglist[i]); 102 | if(NULL == (*argv)[i]) 103 | { 104 | fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n"); 105 | exit(-1); 106 | } 107 | } 108 | 109 | LocalFree(szArglist); 110 | } 111 | 112 | void free_commandline_arguments_utf8(int *argc, char ***argv) 113 | { 114 | int i = 0; 115 | 116 | if(*argv != NULL) 117 | { 118 | for(i = 0; i < *argc; i++) 119 | { 120 | if((*argv)[i] != NULL) 121 | { 122 | free((*argv)[i]); 123 | (*argv)[i] = NULL; 124 | } 125 | } 126 | free(*argv); 127 | *argv = NULL; 128 | } 129 | } 130 | 131 | FILE *faad_fopen(const char *filename, const char *mode) 132 | { 133 | FILE *ret = NULL; 134 | wchar_t *filename_utf16 = utf8_to_utf16(filename); 135 | wchar_t *mode_utf16 = utf8_to_utf16(mode); 136 | 137 | if(filename_utf16 && mode_utf16) 138 | { 139 | ret = _wfopen(filename_utf16, mode_utf16); 140 | } 141 | 142 | if(filename_utf16) free(filename_utf16); 143 | if(mode_utf16) free(mode_utf16); 144 | 145 | return ret; 146 | } 147 | 148 | void init_console_utf8(FILE *const stream) 149 | { 150 | if (_isatty(_fileno(stream))) 151 | { 152 | g_old_output_cp = GetConsoleOutputCP(); 153 | SetConsoleOutputCP(CP_UTF8); 154 | } 155 | } 156 | 157 | void uninit_console_utf8(void) 158 | { 159 | if(g_old_output_cp != ((UINT)-1)) 160 | { 161 | SetConsoleOutputCP(g_old_output_cp); 162 | } 163 | } 164 | 165 | #else 166 | 167 | FILE *faad_fopen(const char *filename, const char *mode) 168 | { 169 | return fopen(filename, mode); 170 | } 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /frontend/unicode_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2012 LoRd_MuldeR 2 | File: unicode_support.h 3 | 4 | This file was originally part of a patch included with LameXP, 5 | released under the same license as the original audio tools. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 22 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef UNICODE_SUPPORT_H_INCLUDED 31 | #define UNICODE_SUPPORT_H_INCLUDED 32 | 33 | #include 34 | 35 | #if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 36 | void init_commandline_arguments_utf8(int *argc, char ***argv); 37 | void free_commandline_arguments_utf8(int *argc, char ***argv); 38 | void init_console_utf8(FILE *const stream); 39 | void uninit_console_utf8(void); 40 | #endif 41 | 42 | FILE *faad_fopen(const char *filename, const char *mode); 43 | 44 | #endif //UNICODE_SUPPORT_H_INCLUDED 45 | -------------------------------------------------------------------------------- /fuzz/fuzz_config.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | **/ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "neaacdec.h" 35 | 36 | int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 37 | long sink = 0; 38 | 39 | if (size < 1) return 0; 40 | unsigned char error_code = *(data++); 41 | size -= 1; 42 | 43 | char* error_message = NeAACDecGetErrorMessage(error_code); 44 | if (error_message) sink += strlen(error_message); 45 | 46 | char* id = NULL; 47 | char* copyright = NULL; 48 | sink += NeAACDecGetVersion(&id, ©right); 49 | sink += strlen(id); 50 | sink += strlen(copyright); 51 | 52 | sink += (long)NeAACDecGetCapabilities(); 53 | 54 | unsigned char* non_const_data = (unsigned char *)malloc(size); 55 | memcpy(non_const_data, data, size); 56 | mp4AudioSpecificConfig mp4ASC; 57 | 58 | NeAACDecAudioSpecificConfig(non_const_data, (unsigned long) size, &mp4ASC); 59 | free(non_const_data); 60 | 61 | return (sink < 0) ? sink : 0; 62 | } 63 | -------------------------------------------------------------------------------- /fuzz/fuzz_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | **/ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "neaacdec.h" 36 | 37 | int feenableexcept(int excepts); 38 | 39 | int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 40 | size_t preamble = 2 + 2 + 1 + sizeof(NeAACDecConfiguration); 41 | NeAACDecConfiguration config; 42 | uint64_t sample_rate; 43 | unsigned char num_channels; 44 | NeAACDecConfigurationPtr config_ptr; 45 | /* feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW); */ 46 | 47 | if (size < preamble) return 0; 48 | size_t len1 = data[0] | (data[1] << 8); 49 | data += 2; 50 | size_t len2 = data[0] | (data[1] << 8); 51 | data += 2; 52 | uint8_t flags = data[0]; 53 | data += 1; 54 | memcpy(&config, data, sizeof(NeAACDecConfiguration)); 55 | data += sizeof(NeAACDecConfiguration); 56 | size -= preamble; 57 | 58 | if (len1 + len2 > size) return 0; 59 | size_t len3 = size - len1 - len2; 60 | int use_init2 = flags & 1; 61 | int seek_before = flags & 2; 62 | int seek_between = flags & 4; 63 | size_t buffer_op = (flags >> 3) & 3; 64 | int use_drm = flags & 32; 65 | int drm_channels = (flags >> 5) & 7; 66 | unsigned long drm_sample_rate = config.defSampleRate; 67 | int res, ok; 68 | const size_t kBufferSize[4] = {0, 0, 16, 16384}; 69 | size_t buffer_size = kBufferSize[buffer_op]; 70 | void* buffer = buffer_size > 0 ? (unsigned char *)malloc(buffer_size) : NULL; 71 | 72 | unsigned char* part1 = (unsigned char *)malloc(len1); 73 | unsigned char* part2 = (unsigned char *)malloc(len2); 74 | unsigned char* part3 = (unsigned char *)malloc(len3); 75 | memcpy(part1, data, len1); 76 | data += len1; 77 | memcpy(part2, data, len2); 78 | data += len2; 79 | memcpy(part3, data, len3); 80 | data += len3; 81 | 82 | NeAACDecHandle decoder = NeAACDecOpen(); 83 | ok = NeAACDecSetConfiguration(decoder, &config); 84 | if (!ok) goto cleanup; 85 | config_ptr = NeAACDecGetCurrentConfiguration(decoder); 86 | if (!config_ptr) __builtin_trap(); 87 | if (use_init2) { 88 | res = NeAACDecInit2(decoder, part1, len1, &sample_rate, &num_channels); 89 | } else { 90 | res = NeAACDecInit(decoder, part1, len1, &sample_rate, &num_channels); 91 | } 92 | if (use_drm) { 93 | #ifdef DRM_SUPPORT 94 | NeAACDecInitDRM(&decoder, drm_channels, drm_sample_rate); 95 | #else 96 | (void)drm_channels; 97 | (void)drm_sample_rate; 98 | #endif 99 | } 100 | 101 | if (res != 0) goto cleanup; 102 | NeAACDecFrameInfo faad_info; 103 | if (seek_before) { 104 | NeAACDecPostSeekReset(decoder, 0x1234567); 105 | } 106 | NeAACDecDecode(decoder, &faad_info, part2, len2); 107 | if (seek_between) { 108 | NeAACDecPostSeekReset(decoder, -0x1234567); 109 | } 110 | if (buffer_op == 0) { 111 | NeAACDecDecode(decoder, &faad_info, part3, len3); 112 | } else { 113 | NeAACDecDecode2(decoder, &faad_info, part3, len3, &buffer, buffer_size); 114 | } 115 | 116 | cleanup: 117 | NeAACDecClose(decoder); 118 | free(part1); 119 | free(part2); 120 | free(part3); 121 | if (buffer) free(buffer); 122 | 123 | return 0; 124 | } 125 | -------------------------------------------------------------------------------- /include/faad.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | **/ 29 | 30 | /* warn people for update */ 31 | #pragma message("please update faad2 include filename and function names!") 32 | 33 | #define FAAD2_VERSION "@VERSION@" 34 | 35 | /* Backwards compatible link */ 36 | #include "neaacdec.h" 37 | -------------------------------------------------------------------------------- /libfaad/analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | #ifndef __ANALYSIS_H__ 32 | #define __ANALYSIS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | #ifdef ANALYSIS 40 | #define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg 41 | #define DEBUGVAR(A,B,C) ,A,B,C 42 | extern uint16_t dbg_count; 43 | #else 44 | #define DEBUGDEC 45 | #define DEBUGVAR(A,B,C) 46 | #endif 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /libfaad/cfft.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | #ifndef __CFFT_H__ 32 | #define __CFFT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | uint16_t n; 41 | uint16_t ifac[15]; 42 | complex_t *work; 43 | complex_t *tab; 44 | } cfft_info; 45 | 46 | 47 | void cfftf(cfft_info *cfft, complex_t *c); 48 | void cfftb(cfft_info *cfft, complex_t *c); 49 | cfft_info *cffti(uint16_t n); 50 | void cfftu(cfft_info *cfft); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $ 29 | **/ 30 | 31 | #ifndef __HCB_H__ 32 | #define __HCB_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* 39 | * Optimal huffman decoding for AAC taken from: 40 | * "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by 41 | * VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO 42 | * AES paper 5436 43 | * 44 | * 2 methods are used for huffman decoding: 45 | * - binary search 46 | * - 2-step table lookup 47 | * 48 | * The choice of the "optimal" method is based on the fact that if the 49 | * memory size for the Two-step is exorbitantly high then the decision 50 | * is Binary search for that codebook. However, for marginally more memory 51 | * size, if Twostep outperforms even the best case of Binary then the 52 | * decision is Two-step for that codebook. 53 | * 54 | * The following methods are used for the different tables. 55 | * codebook "optimal" method 56 | * HCB_1 2-Step 57 | * HCB_2 2-Step 58 | * HCB_3 Binary 59 | * HCB_4 2-Step 60 | * HCB_5 Binary 61 | * HCB_6 2-Step 62 | * HCB_7 Binary 63 | * HCB_8 2-Step 64 | * HCB_9 Binary 65 | * HCB_10 2-Step 66 | * HCB_11 2-Step 67 | * HCB_SF Binary 68 | * 69 | */ 70 | 71 | 72 | #define ZERO_HCB 0 73 | #define FIRST_PAIR_HCB 5 74 | #define ESC_HCB 11 75 | #define QUAD_LEN 4 76 | #define PAIR_LEN 2 77 | #define NOISE_HCB 13 78 | #define INTENSITY_HCB2 14 79 | #define INTENSITY_HCB 15 80 | 81 | /* Maximal accessed codebook index. */ 82 | #define LAST_CB_IDX 11 83 | 84 | /* 1st step table */ 85 | typedef struct 86 | { 87 | uint8_t offset; 88 | uint8_t extra_bits; 89 | } hcb; 90 | 91 | /* 2nd step table with quadruple data */ 92 | typedef struct 93 | { 94 | uint8_t bits; 95 | int8_t x; 96 | int8_t y; 97 | } hcb_2_pair; 98 | 99 | typedef struct 100 | { 101 | uint8_t bits; 102 | int8_t x; 103 | int8_t y; 104 | int8_t v; 105 | int8_t w; 106 | } hcb_2_quad; 107 | 108 | /* binary search table */ 109 | typedef struct 110 | { 111 | uint8_t is_leaf; 112 | int8_t data[4]; 113 | } hcb_bin_quad; 114 | 115 | typedef struct 116 | { 117 | uint8_t is_leaf; 118 | int8_t data[2]; 119 | } hcb_bin_pair; 120 | 121 | #include "codebook/hcb_1.h" 122 | #include "codebook/hcb_2.h" 123 | #include "codebook/hcb_3.h" 124 | #include "codebook/hcb_4.h" 125 | #include "codebook/hcb_5.h" 126 | #include "codebook/hcb_6.h" 127 | #include "codebook/hcb_7.h" 128 | #include "codebook/hcb_8.h" 129 | #include "codebook/hcb_9.h" 130 | #include "codebook/hcb_10.h" 131 | #include "codebook/hcb_11.h" 132 | #include "codebook/hcb_sf.h" 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | #endif 138 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_1.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_1 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static const hcb hcb1_1[32] = { 40 | /* 1 bit codeword */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* */ 0, 0 }, 45 | { /* */ 0, 0 }, 46 | { /* */ 0, 0 }, 47 | { /* */ 0, 0 }, 48 | { /* */ 0, 0 }, 49 | { /* */ 0, 0 }, 50 | { /* */ 0, 0 }, 51 | { /* */ 0, 0 }, 52 | { /* */ 0, 0 }, 53 | { /* */ 0, 0 }, 54 | { /* */ 0, 0 }, 55 | { /* */ 0, 0 }, 56 | { /* */ 0, 0 }, 57 | 58 | /* 5 bit codewords */ 59 | { /* 10000 */ 1, 0 }, 60 | { /* 10001 */ 2, 0 }, 61 | { /* 10010 */ 3, 0 }, 62 | { /* 10011 */ 4, 0 }, 63 | { /* 10100 */ 5, 0 }, 64 | { /* 10101 */ 6, 0 }, 65 | { /* 10110 */ 7, 0 }, 66 | { /* 10111 */ 8, 0 }, 67 | 68 | /* 7 bit codewords */ 69 | { /* 11000 */ 9, 2 }, 70 | { /* 11001 */ 13, 2 }, 71 | { /* 11010 */ 17, 2 }, 72 | { /* 11011 */ 21, 2 }, 73 | { /* 11100 */ 25, 2 }, 74 | { /* 11101 */ 29, 2 }, 75 | 76 | /* 9 bit codewords */ 77 | { /* 11110 */ 33, 4 }, 78 | 79 | /* 9/10/11 bit codewords */ 80 | { /* 11111 */ 49, 6 } 81 | 82 | /* Size of second level table is 49 + 64 = 113 */ 83 | }; 84 | 85 | /* 2nd step table 86 | * 87 | * Gives size of codeword and actual data (x,y,v,w) 88 | */ 89 | static const hcb_2_quad hcb1_2[113] = { 90 | /* 1 bit codeword */ 91 | { 1, 0, 0, 0, 0 }, 92 | 93 | /* 5 bit codewords */ 94 | { 5, 1, 0, 0, 0 }, 95 | { 5, -1, 0, 0, 0 }, 96 | { 5, 0, 0, 0, -1 }, 97 | { 5, 0, 1, 0, 0 }, 98 | { 5, 0, 0, 0, 1 }, 99 | { 5, 0, 0, -1, 0 }, 100 | { 5, 0, 0, 1, 0 }, 101 | { 5, 0, -1, 0, 0 }, 102 | 103 | /* 7 bit codewords */ 104 | /* first 5 bits: 11000 */ 105 | { 7, 1, -1, 0, 0 }, 106 | { 7, -1, 1, 0, 0 }, 107 | { 7, 0, 0, -1, 1 }, 108 | { 7, 0, 1, -1, 0 }, 109 | /* first 5 bits: 11001 */ 110 | { 7, 0, -1, 1, 0 }, 111 | { 7, 0, 0, 1, -1 }, 112 | { 7, 1, 1, 0, 0 }, 113 | { 7, 0, 0, -1, -1 }, 114 | /* first 5 bits: 11010 */ 115 | { 7, -1, -1, 0, 0 }, 116 | { 7, 0, -1, -1, 0 }, 117 | { 7, 1, 0, -1, 0 }, 118 | { 7, 0, 1, 0, -1 }, 119 | /* first 5 bits: 11011 */ 120 | { 7, -1, 0, 1, 0 }, 121 | { 7, 0, 0, 1, 1 }, 122 | { 7, 1, 0, 1, 0 }, 123 | { 7, 0, -1, 0, 1 }, 124 | /* first 5 bits: 11100 */ 125 | { 7, 0, 1, 1, 0 }, 126 | { 7, 0, 1, 0, 1 }, 127 | { 7, -1, 0, -1, 0 }, 128 | { 7, 1, 0, 0, 1 }, 129 | /* first 5 bits: 11101 */ 130 | { 7, -1, 0, 0, -1 }, 131 | { 7, 1, 0, 0, -1 }, 132 | { 7, -1, 0, 0, 1 }, 133 | { 7, 0, -1, 0, -1 }, 134 | 135 | /* 9 bit codeword */ 136 | /* first 5 bits: 11110 */ 137 | { 9, 1, 1, -1, 0 }, 138 | { 9, -1, 1, -1, 0 }, 139 | { 9, 1, -1, 1, 0 }, 140 | { 9, 0, 1, 1, -1 }, 141 | { 9, 0, 1, -1, 1 }, 142 | { 9, 0, -1, 1, 1 }, 143 | { 9, 0, -1, 1, -1 }, 144 | { 9, 1, -1, -1, 0 }, 145 | { 9, 1, 0, -1, 1 }, 146 | { 9, 0, 1, -1, -1 }, 147 | { 9, -1, 1, 1, 0 }, 148 | { 9, -1, 0, 1, -1 }, 149 | { 9, -1, -1, 1, 0 }, 150 | { 9, 0, -1, -1, 1 }, 151 | { 9, 1, -1, 0, 1 }, 152 | { 9, 1, -1, 0, -1 }, 153 | 154 | /* 9/10/11 bit codewords */ 155 | /* first 5 bits: 11111 */ 156 | /* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */ 157 | { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, 158 | { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, 159 | { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, 160 | { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, 161 | { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, 162 | { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, 163 | { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, 164 | { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, 165 | /* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */ 166 | { 10, -1, -1, 0, 1 }, { 10, -1, -1, 0, 1 }, 167 | { 10, -1, 0, -1, -1 }, { 10, -1, 0, -1, -1 }, 168 | { 10, 1, 1, 0, -1 }, { 10, 1, 1, 0, -1 }, 169 | { 10, 1, 0, -1, -1 }, { 10, 1, 0, -1, -1 }, 170 | { 10, -1, 0, -1, 1 }, { 10, -1, 0, -1, 1 }, 171 | { 10, -1, -1, 0, -1 }, { 10, -1, -1, 0, -1 }, 172 | { 10, -1, 0, 1, 1 }, { 10, -1, 0, 1, 1 }, 173 | { 10, 1, 0, 1, 1 }, { 10, 1, 0, 1, 1 }, 174 | /* 11 bit */ 175 | { 11, 1, -1, 1, -1 }, 176 | { 11, -1, 1, -1, 1 }, 177 | { 11, -1, 1, 1, -1 }, 178 | { 11, 1, -1, -1, 1 }, 179 | { 11, 1, 1, 1, 1 }, 180 | { 11, -1, -1, 1, 1 }, 181 | { 11, 1, 1, -1, -1 }, 182 | { 11, -1, -1, 1, -1 }, 183 | { 11, -1, -1, -1, -1 }, 184 | { 11, 1, 1, -1, 1 }, 185 | { 11, 1, -1, 1, 1 }, 186 | { 11, -1, 1, 1, 1 }, 187 | { 11, -1, 1, -1, -1 }, 188 | { 11, -1, -1, -1, 1 }, 189 | { 11, 1, -1, -1, -1 }, 190 | { 11, 1, 1, 1, -1 } 191 | }; 192 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_2.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_2.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_2 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static const hcb hcb2_1[32] = { 40 | /* 3 bit codeword */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* 00011 */ 0, 0 }, 45 | 46 | /* 4 bit codeword */ 47 | { /* 00100 */ 1, 0 }, 48 | { /* 00101 */ 1, 0 }, 49 | 50 | /* 5 bit codewords */ 51 | { /* 00110 */ 2, 0 }, 52 | { /* 00111 */ 3, 0 }, 53 | { /* 01000 */ 4, 0 }, 54 | { /* 01001 */ 5, 0 }, 55 | { /* 01010 */ 6, 0 }, 56 | { /* 01011 */ 7, 0 }, 57 | { /* 01100 */ 8, 0 }, 58 | 59 | /* 6 bit codewords */ 60 | { /* 01101 */ 9, 1 }, 61 | { /* 01110 */ 11, 1 }, 62 | { /* 01111 */ 13, 1 }, 63 | { /* 10000 */ 15, 1 }, 64 | { /* 10001 */ 17, 1 }, 65 | { /* 10010 */ 19, 1 }, 66 | { /* 10011 */ 21, 1 }, 67 | { /* 10100 */ 23, 1 }, 68 | { /* 10101 */ 25, 1 }, 69 | { /* 10110 */ 27, 1 }, 70 | { /* 10111 */ 29, 1 }, 71 | { /* 11000 */ 31, 1 }, 72 | 73 | /* 7 bit codewords */ 74 | { /* 11001 */ 33, 2 }, 75 | { /* 11010 */ 37, 2 }, 76 | { /* 11011 */ 41, 2 }, 77 | 78 | /* 7/8 bit codewords */ 79 | { /* 11100 */ 45, 3 }, 80 | 81 | /* 8 bit codewords */ 82 | { /* 11101 */ 53, 3 }, 83 | { /* 11110 */ 61, 3 }, 84 | 85 | /* 8/9 bit codewords */ 86 | { /* 11111 */ 69, 4 } 87 | 88 | /* Size of second level table is 69 + 16 = 85 */ 89 | }; 90 | 91 | /* 2nd step table 92 | * 93 | * Gives size of codeword and actual data (x,y,v,w) 94 | */ 95 | static const hcb_2_quad hcb2_2[85] = { 96 | /* 3 bit codeword */ 97 | { 3, 0, 0, 0, 0 }, 98 | 99 | /* 4 bit codeword */ 100 | { 4, 1, 0, 0, 0 }, 101 | 102 | /* 5 bit codewords */ 103 | { 5, -1, 0, 0, 0 }, 104 | { 5, 0, 0, 0, 1 }, 105 | { 5, 0, 0, -1, 0 }, 106 | { 5, 0, 0, 0, -1 }, 107 | { 5, 0, -1, 0, 0 }, 108 | { 5, 0, 0, 1, 0 }, 109 | { 5, 0, 1, 0, 0 }, 110 | 111 | /* 6 bit codewords */ 112 | { 6, 0, -1, 1, 0 }, 113 | { 6, -1, 1, 0, 0 }, 114 | { 6, 0, 1, -1, 0 }, 115 | { 6, 0, 0, 1, -1 }, 116 | { 6, 0, 1, 0, -1 }, 117 | { 6, 0, 0, -1, 1 }, 118 | { 6, -1, 0, 0, -1 }, 119 | { 6, 1, -1, 0, 0 }, 120 | { 6, 1, 0, -1, 0 }, 121 | { 6, -1, -1, 0, 0 }, 122 | { 6, 0, 0, -1, -1 }, 123 | { 6, 1, 0, 1, 0 }, 124 | { 6, 1, 0, 0, 1 }, 125 | { 6, 0, -1, 0, 1 }, 126 | { 6, -1, 0, 1, 0 }, 127 | { 6, 0, 1, 0, 1 }, 128 | { 6, 0, -1, -1, 0 }, 129 | { 6, -1, 0, 0, 1 }, 130 | { 6, 0, -1, 0, -1 }, 131 | { 6, -1, 0, -1, 0 }, 132 | { 6, 1, 1, 0, 0 }, 133 | { 6, 0, 1, 1, 0 }, 134 | { 6, 0, 0, 1, 1 }, 135 | { 6, 1, 0, 0, -1 }, 136 | 137 | /* 7 bit codewords */ 138 | { 7, 0, 1, -1, 1 }, 139 | { 7, 1, 0, -1, 1 }, 140 | { 7, -1, 1, -1, 0 }, 141 | { 7, 0, -1, 1, -1 }, 142 | { 7, 1, -1, 1, 0 }, 143 | { 7, 1, 1, 0, -1 }, 144 | { 7, 1, 0, 1, 1 }, 145 | { 7, -1, 1, 1, 0 }, 146 | { 7, 0, -1, -1, 1 }, 147 | { 7, 1, 1, 1, 0 }, 148 | { 7, -1, 0, 1, -1 }, 149 | { 7, -1, -1, -1, 0 }, 150 | 151 | /* 7/8 bit codewords */ 152 | { 7, -1, 0, -1, 1 }, { 7, -1, 0, -1, 1 }, 153 | { 7, 1, -1, -1, 0 }, { 7, 1, -1, -1, 0 }, 154 | { 7, 1, 1, -1, 0 }, { 7, 1, 1, -1, 0 }, 155 | { 8, 1, -1, 0, 1 }, 156 | { 8, -1, 1, 0, -1 }, 157 | 158 | /* 8 bit codewords */ 159 | { 8, -1, -1, 1, 0 }, 160 | { 8, -1, 0, 1, 1 }, 161 | { 8, -1, -1, 0, 1 }, 162 | { 8, -1, -1, 0, -1 }, 163 | { 8, 0, -1, -1, -1 }, 164 | { 8, 1, 0, 1, -1 }, 165 | { 8, 1, 0, -1, -1 }, 166 | { 8, 0, 1, -1, -1 }, 167 | { 8, 0, 1, 1, 1 }, 168 | { 8, -1, 1, 0, 1 }, 169 | { 8, -1, 0, -1, -1 }, 170 | { 8, 0, 1, 1, -1 }, 171 | { 8, 1, -1, 0, -1 }, 172 | { 8, 0, -1, 1, 1 }, 173 | { 8, 1, 1, 0, 1 }, 174 | { 8, 1, -1, 1, -1 }, 175 | 176 | /* 8/9 bit codewords */ 177 | { 8, -1, 1, -1, 1 }, { 8, -1, 1, -1, 1 }, 178 | { 9, 1, -1, -1, 1 }, 179 | { 9, -1, -1, -1, -1 }, 180 | { 9, -1, 1, 1, -1 }, 181 | { 9, -1, 1, 1, 1 }, 182 | { 9, 1, 1, 1, 1 }, 183 | { 9, -1, -1, 1, -1 }, 184 | { 9, 1, -1, 1, 1 }, 185 | { 9, -1, 1, -1, -1 }, 186 | { 9, -1, -1, 1, 1 }, 187 | { 9, 1, 1, -1, -1 }, 188 | { 9, 1, -1, -1, -1 }, 189 | { 9, -1, -1, -1, 1 }, 190 | { 9, 1, 1, -1, 1 }, 191 | { 9, 1, 1, 1, -1 } 192 | }; 193 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_5.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_5.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* Binary search huffman table HCB_5 */ 32 | 33 | 34 | static const hcb_bin_pair hcb5[161] = { 35 | { /* 0 */ 0, { 1, 2 } }, 36 | { /* 1 */ 1, { 0, 0 } }, /* 0 */ 37 | { /* 2 */ 0, { 1, 2 } }, 38 | { /* 3 */ 0, { 2, 3 } }, 39 | { /* 4 */ 0, { 3, 4 } }, 40 | { /* 5 */ 0, { 4, 5 } }, 41 | { /* 6 */ 0, { 5, 6 } }, 42 | { /* 7 */ 0, { 6, 7 } }, 43 | { /* 8 */ 0, { 7, 8 } }, 44 | { /* 9 */ 1, { -1, 0 } }, /* 1000 */ 45 | { /* 10 */ 1, { 1, 0 } }, /* 1001 */ 46 | { /* 11 */ 1, { 0, 1 } }, /* 1010 */ 47 | { /* 12 */ 1, { 0, -1 } }, /* 1011 */ 48 | { /* 13 */ 0, { 4, 5 } }, 49 | { /* 14 */ 0, { 5, 6 } }, 50 | { /* 15 */ 0, { 6, 7 } }, 51 | { /* 16 */ 0, { 7, 8 } }, 52 | { /* 17 */ 1, { 1, -1 } }, 53 | { /* 18 */ 1, { -1, 1 } }, 54 | { /* 19 */ 1, { -1, -1 } }, 55 | { /* 20 */ 1, { 1, 1 } }, 56 | { /* 21 */ 0, { 4, 5 } }, 57 | { /* 22 */ 0, { 5, 6 } }, 58 | { /* 23 */ 0, { 6, 7 } }, 59 | { /* 24 */ 0, { 7, 8 } }, 60 | { /* 25 */ 0, { 8, 9 } }, 61 | { /* 26 */ 0, { 9, 10 } }, 62 | { /* 27 */ 0, { 10, 11 } }, 63 | { /* 28 */ 0, { 11, 12 } }, 64 | { /* 29 */ 0, { 12, 13 } }, 65 | { /* 30 */ 0, { 13, 14 } }, 66 | { /* 31 */ 0, { 14, 15 } }, 67 | { /* 32 */ 0, { 15, 16 } }, 68 | { /* 33 */ 1, { -2, 0 } }, 69 | { /* 34 */ 1, { 0, 2 } }, 70 | { /* 35 */ 1, { 2, 0 } }, 71 | { /* 36 */ 1, { 0, -2 } }, 72 | { /* 37 */ 0, { 12, 13 } }, 73 | { /* 38 */ 0, { 13, 14 } }, 74 | { /* 39 */ 0, { 14, 15 } }, 75 | { /* 40 */ 0, { 15, 16 } }, 76 | { /* 41 */ 0, { 16, 17 } }, 77 | { /* 42 */ 0, { 17, 18 } }, 78 | { /* 43 */ 0, { 18, 19 } }, 79 | { /* 44 */ 0, { 19, 20 } }, 80 | { /* 45 */ 0, { 20, 21 } }, 81 | { /* 46 */ 0, { 21, 22 } }, 82 | { /* 47 */ 0, { 22, 23 } }, 83 | { /* 48 */ 0, { 23, 24 } }, 84 | { /* 49 */ 1, { -2, -1 } }, 85 | { /* 50 */ 1, { 2, 1 } }, 86 | { /* 51 */ 1, { -1, -2 } }, 87 | { /* 52 */ 1, { 1, 2 } }, 88 | { /* 53 */ 1, { -2, 1 } }, 89 | { /* 54 */ 1, { 2, -1 } }, 90 | { /* 55 */ 1, { -1, 2 } }, 91 | { /* 56 */ 1, { 1, -2 } }, 92 | { /* 57 */ 1, { -3, 0 } }, 93 | { /* 58 */ 1, { 3, 0 } }, 94 | { /* 59 */ 1, { 0, -3 } }, 95 | { /* 60 */ 1, { 0, 3 } }, 96 | { /* 61 */ 0, { 12, 13 } }, 97 | { /* 62 */ 0, { 13, 14 } }, 98 | { /* 63 */ 0, { 14, 15 } }, 99 | { /* 64 */ 0, { 15, 16 } }, 100 | { /* 65 */ 0, { 16, 17 } }, 101 | { /* 66 */ 0, { 17, 18 } }, 102 | { /* 67 */ 0, { 18, 19 } }, 103 | { /* 68 */ 0, { 19, 20 } }, 104 | { /* 69 */ 0, { 20, 21 } }, 105 | { /* 70 */ 0, { 21, 22 } }, 106 | { /* 71 */ 0, { 22, 23 } }, 107 | { /* 72 */ 0, { 23, 24 } }, 108 | { /* 73 */ 1, { -3, -1 } }, 109 | { /* 74 */ 1, { 1, 3 } }, 110 | { /* 75 */ 1, { 3, 1 } }, 111 | { /* 76 */ 1, { -1, -3 } }, 112 | { /* 77 */ 1, { -3, 1 } }, 113 | { /* 78 */ 1, { 3, -1 } }, 114 | { /* 79 */ 1, { 1, -3 } }, 115 | { /* 80 */ 1, { -1, 3 } }, 116 | { /* 81 */ 1, { -2, 2 } }, 117 | { /* 82 */ 1, { 2, 2 } }, 118 | { /* 83 */ 1, { -2, -2 } }, 119 | { /* 84 */ 1, { 2, -2 } }, 120 | { /* 85 */ 0, { 12, 13 } }, 121 | { /* 86 */ 0, { 13, 14 } }, 122 | { /* 87 */ 0, { 14, 15 } }, 123 | { /* 88 */ 0, { 15, 16 } }, 124 | { /* 89 */ 0, { 16, 17 } }, 125 | { /* 90 */ 0, { 17, 18 } }, 126 | { /* 91 */ 0, { 18, 19 } }, 127 | { /* 92 */ 0, { 19, 20 } }, 128 | { /* 93 */ 0, { 20, 21 } }, 129 | { /* 94 */ 0, { 21, 22 } }, 130 | { /* 95 */ 0, { 22, 23 } }, 131 | { /* 96 */ 0, { 23, 24 } }, 132 | { /* 97 */ 1, { -3, -2 } }, 133 | { /* 98 */ 1, { 3, -2 } }, 134 | { /* 99 */ 1, { -2, 3 } }, 135 | { /* 100 */ 1, { 2, -3 } }, 136 | { /* 101 */ 1, { 3, 2 } }, 137 | { /* 102 */ 1, { 2, 3 } }, 138 | { /* 103 */ 1, { -3, 2 } }, 139 | { /* 104 */ 1, { -2, -3 } }, 140 | { /* 105 */ 1, { 0, -4 } }, 141 | { /* 106 */ 1, { -4, 0 } }, 142 | { /* 107 */ 1, { 4, 1 } }, 143 | { /* 108 */ 1, { 4, 0 } }, 144 | { /* 109 */ 0, { 12, 13 } }, 145 | { /* 110 */ 0, { 13, 14 } }, 146 | { /* 111 */ 0, { 14, 15 } }, 147 | { /* 112 */ 0, { 15, 16 } }, 148 | { /* 113 */ 0, { 16, 17 } }, 149 | { /* 114 */ 0, { 17, 18 } }, 150 | { /* 115 */ 0, { 18, 19 } }, 151 | { /* 116 */ 0, { 19, 20 } }, 152 | { /* 117 */ 0, { 20, 21 } }, 153 | { /* 118 */ 0, { 21, 22 } }, 154 | { /* 119 */ 0, { 22, 23 } }, 155 | { /* 120 */ 0, { 23, 24 } }, 156 | { /* 121 */ 1, { -4, -1 } }, 157 | { /* 122 */ 1, { 0, 4 } }, 158 | { /* 123 */ 1, { 4, -1 } }, 159 | { /* 124 */ 1, { -1, -4 } }, 160 | { /* 125 */ 1, { 1, 4 } }, 161 | { /* 126 */ 1, { -1, 4 } }, 162 | { /* 127 */ 1, { -4, 1 } }, 163 | { /* 128 */ 1, { 1, -4 } }, 164 | { /* 129 */ 1, { 3, -3 } }, 165 | { /* 130 */ 1, { -3, -3 } }, 166 | { /* 131 */ 1, { -3, 3 } }, 167 | { /* 132 */ 1, { -2, 4 } }, 168 | { /* 133 */ 1, { -4, -2 } }, 169 | { /* 134 */ 1, { 4, 2 } }, 170 | { /* 135 */ 1, { 2, -4 } }, 171 | { /* 136 */ 1, { 2, 4 } }, 172 | { /* 137 */ 1, { 3, 3 } }, 173 | { /* 138 */ 1, { -4, 2 } }, 174 | { /* 139 */ 0, { 6, 7 } }, 175 | { /* 140 */ 0, { 7, 8 } }, 176 | { /* 141 */ 0, { 8, 9 } }, 177 | { /* 142 */ 0, { 9, 10 } }, 178 | { /* 143 */ 0, { 10, 11 } }, 179 | { /* 144 */ 0, { 11, 12 } }, 180 | { /* 145 */ 1, { -2, -4 } }, 181 | { /* 146 */ 1, { 4, -2 } }, 182 | { /* 147 */ 1, { 3, -4 } }, 183 | { /* 148 */ 1, { -4, -3 } }, 184 | { /* 149 */ 1, { -4, 3 } }, 185 | { /* 150 */ 1, { 3, 4 } }, 186 | { /* 151 */ 1, { -3, 4 } }, 187 | { /* 152 */ 1, { 4, 3 } }, 188 | { /* 153 */ 1, { 4, -3 } }, 189 | { /* 154 */ 1, { -3, -4 } }, 190 | { /* 155 */ 0, { 2, 3 } }, 191 | { /* 156 */ 0, { 3, 4 } }, 192 | { /* 157 */ 1, { 4, -4 } }, 193 | { /* 158 */ 1, { -4, 4 } }, 194 | { /* 159 */ 1, { 4, 4 } }, 195 | { /* 160 */ 1, { -4, -4 } } 196 | }; 197 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_6.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_6.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_6 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static const hcb hcb6_1[32] = { 40 | /* 4 bit codewords */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* 00010 */ 1, 0 }, 44 | { /* */ 1, 0 }, 45 | { /* 00100 */ 2, 0 }, 46 | { /* */ 2, 0 }, 47 | { /* 00110 */ 3, 0 }, 48 | { /* */ 3, 0 }, 49 | { /* 01000 */ 4, 0 }, 50 | { /* */ 4, 0 }, 51 | { /* 01010 */ 5, 0 }, 52 | { /* */ 5, 0 }, 53 | { /* 01100 */ 6, 0 }, 54 | { /* */ 6, 0 }, 55 | { /* 01110 */ 7, 0 }, 56 | { /* */ 7, 0 }, 57 | { /* 10000 */ 8, 0 }, 58 | { /* */ 8, 0 }, 59 | 60 | /* 6 bit codewords */ 61 | { /* 10010 */ 9, 1 }, 62 | { /* 10011 */ 11, 1 }, 63 | { /* 10100 */ 13, 1 }, 64 | { /* 10101 */ 15, 1 }, 65 | { /* 10110 */ 17, 1 }, 66 | { /* 10111 */ 19, 1 }, 67 | { /* 11000 */ 21, 1 }, 68 | { /* 11001 */ 23, 1 }, 69 | 70 | /* 7 bit codewords */ 71 | { /* 11010 */ 25, 2 }, 72 | { /* 11011 */ 29, 2 }, 73 | { /* 11100 */ 33, 2 }, 74 | 75 | /* 7/8 bit codewords */ 76 | { /* 11101 */ 37, 3 }, 77 | 78 | /* 8/9 bit codewords */ 79 | { /* 11110 */ 45, 4 }, 80 | 81 | /* 9/10/11 bit codewords */ 82 | { /* 11111 */ 61, 6 } 83 | 84 | /* Size of second level table is 61 + 64 = 125 */ 85 | }; 86 | 87 | /* 2nd step table 88 | * 89 | * Gives size of codeword and actual data (x,y,v,w) 90 | */ 91 | static const hcb_2_pair hcb6_2[125] = { 92 | /* 4 bit codewords */ 93 | { 4, 0, 0 }, 94 | { 4, 1, 0 }, 95 | { 4, 0, -1 }, 96 | { 4, 0, 1 }, 97 | { 4, -1, 0 }, 98 | { 4, 1, 1 }, 99 | { 4, -1, 1 }, 100 | { 4, 1, -1 }, 101 | { 4, -1, -1 }, 102 | 103 | /* 6 bit codewords */ 104 | { 6, 2, -1 }, 105 | { 6, 2, 1 }, 106 | { 6, -2, 1 }, 107 | { 6, -2, -1 }, 108 | { 6, -2, 0 }, 109 | { 6, -1, 2 }, 110 | { 6, 2, 0 }, 111 | { 6, 1, -2 }, 112 | { 6, 1, 2 }, 113 | { 6, 0, -2 }, 114 | { 6, -1, -2 }, 115 | { 6, 0, 2 }, 116 | { 6, 2, -2 }, 117 | { 6, -2, 2 }, 118 | { 6, -2, -2 }, 119 | { 6, 2, 2 }, 120 | 121 | /* 7 bit codewords */ 122 | { 7, -3, 1 }, 123 | { 7, 3, 1 }, 124 | { 7, 3, -1 }, 125 | { 7, -1, 3 }, 126 | { 7, -3, -1 }, 127 | { 7, 1, 3 }, 128 | { 7, 1, -3 }, 129 | { 7, -1, -3 }, 130 | { 7, 3, 0 }, 131 | { 7, -3, 0 }, 132 | { 7, 0, -3 }, 133 | { 7, 0, 3 }, 134 | 135 | /* 7/8 bit codewords */ 136 | { 7, 3, 2 }, { 7, 3, 2 }, 137 | { 8, -3, -2 }, 138 | { 8, -2, 3 }, 139 | { 8, 2, 3 }, 140 | { 8, 3, -2 }, 141 | { 8, 2, -3 }, 142 | { 8, -2, -3 }, 143 | 144 | /* 8 bit codewords */ 145 | { 8, -3, 2 }, { 8, -3, 2 }, 146 | { 8, 3, 3 }, { 8, 3, 3 }, 147 | { 9, 3, -3 }, 148 | { 9, -3, -3 }, 149 | { 9, -3, 3 }, 150 | { 9, 1, -4 }, 151 | { 9, -1, -4 }, 152 | { 9, 4, 1 }, 153 | { 9, -4, 1 }, 154 | { 9, -4, -1 }, 155 | { 9, 1, 4 }, 156 | { 9, 4, -1 }, 157 | { 9, -1, 4 }, 158 | { 9, 0, -4 }, 159 | 160 | /* 9/10/11 bit codewords */ 161 | { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, 162 | { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, 163 | { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, 164 | { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, 165 | { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, 166 | { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, 167 | { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, 168 | { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, 169 | { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, 170 | { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, 171 | { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, 172 | { 10, -3, -4 }, { 10, -3, -4 }, 173 | { 10, -3, 4 }, { 10, -3, 4 }, 174 | { 10, 3, -4 }, { 10, 3, -4 }, 175 | { 10, 4, -3 }, { 10, 4, -3 }, 176 | { 10, 3, 4 }, { 10, 3, 4 }, 177 | { 10, 4, 3 }, { 10, 4, 3 }, 178 | { 10, -4, 3 }, { 10, -4, 3 }, 179 | { 10, -4, -3 }, { 10, -4, -3 }, 180 | { 11, 4, 4 }, 181 | { 11, -4, 4 }, 182 | { 11, -4, -4 }, 183 | { 11, 4, -4 } 184 | }; 185 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_7.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_7.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* Binary search huffman table HCB_7 */ 32 | 33 | 34 | static const hcb_bin_pair hcb7[127] = { 35 | { /* 0 */ 0, { 1, 2 } }, 36 | { /* 1 */ 1, { 0, 0 } }, 37 | { /* 2 */ 0, { 1, 2 } }, 38 | { /* 3 */ 0, { 2, 3 } }, 39 | { /* 4 */ 0, { 3, 4 } }, 40 | { /* 5 */ 1, { 1, 0 } }, 41 | { /* 6 */ 1, { 0, 1 } }, 42 | { /* 7 */ 0, { 2, 3 } }, 43 | { /* 8 */ 0, { 3, 4 } }, 44 | { /* 9 */ 1, { 1, 1 } }, 45 | { /* 10 */ 0, { 3, 4 } }, 46 | { /* 11 */ 0, { 4, 5 } }, 47 | { /* 12 */ 0, { 5, 6 } }, 48 | { /* 13 */ 0, { 6, 7 } }, 49 | { /* 14 */ 0, { 7, 8 } }, 50 | { /* 15 */ 0, { 8, 9 } }, 51 | { /* 16 */ 0, { 9, 10 } }, 52 | { /* 17 */ 0, { 10, 11 } }, 53 | { /* 18 */ 0, { 11, 12 } }, 54 | { /* 19 */ 1, { 2, 1 } }, 55 | { /* 20 */ 1, { 1, 2 } }, 56 | { /* 21 */ 1, { 2, 0 } }, 57 | { /* 22 */ 1, { 0, 2 } }, 58 | { /* 23 */ 0, { 8, 9 } }, 59 | { /* 24 */ 0, { 9, 10 } }, 60 | { /* 25 */ 0, { 10, 11 } }, 61 | { /* 26 */ 0, { 11, 12 } }, 62 | { /* 27 */ 0, { 12, 13 } }, 63 | { /* 28 */ 0, { 13, 14 } }, 64 | { /* 29 */ 0, { 14, 15 } }, 65 | { /* 30 */ 0, { 15, 16 } }, 66 | { /* 31 */ 1, { 3, 1 } }, 67 | { /* 32 */ 1, { 1, 3 } }, 68 | { /* 33 */ 1, { 2, 2 } }, 69 | { /* 34 */ 1, { 3, 0 } }, 70 | { /* 35 */ 1, { 0, 3 } }, 71 | { /* 36 */ 0, { 11, 12 } }, 72 | { /* 37 */ 0, { 12, 13 } }, 73 | { /* 38 */ 0, { 13, 14 } }, 74 | { /* 39 */ 0, { 14, 15 } }, 75 | { /* 40 */ 0, { 15, 16 } }, 76 | { /* 41 */ 0, { 16, 17 } }, 77 | { /* 42 */ 0, { 17, 18 } }, 78 | { /* 43 */ 0, { 18, 19 } }, 79 | { /* 44 */ 0, { 19, 20 } }, 80 | { /* 45 */ 0, { 20, 21 } }, 81 | { /* 46 */ 0, { 21, 22 } }, 82 | { /* 47 */ 1, { 2, 3 } }, 83 | { /* 48 */ 1, { 3, 2 } }, 84 | { /* 49 */ 1, { 1, 4 } }, 85 | { /* 50 */ 1, { 4, 1 } }, 86 | { /* 51 */ 1, { 1, 5 } }, 87 | { /* 52 */ 1, { 5, 1 } }, 88 | { /* 53 */ 1, { 3, 3 } }, 89 | { /* 54 */ 1, { 2, 4 } }, 90 | { /* 55 */ 1, { 0, 4 } }, 91 | { /* 56 */ 1, { 4, 0 } }, 92 | { /* 57 */ 0, { 12, 13 } }, 93 | { /* 58 */ 0, { 13, 14 } }, 94 | { /* 59 */ 0, { 14, 15 } }, 95 | { /* 60 */ 0, { 15, 16 } }, 96 | { /* 61 */ 0, { 16, 17 } }, 97 | { /* 62 */ 0, { 17, 18 } }, 98 | { /* 63 */ 0, { 18, 19 } }, 99 | { /* 64 */ 0, { 19, 20 } }, 100 | { /* 65 */ 0, { 20, 21 } }, 101 | { /* 66 */ 0, { 21, 22 } }, 102 | { /* 67 */ 0, { 22, 23 } }, 103 | { /* 68 */ 0, { 23, 24 } }, 104 | { /* 69 */ 1, { 4, 2 } }, 105 | { /* 70 */ 1, { 2, 5 } }, 106 | { /* 71 */ 1, { 5, 2 } }, 107 | { /* 72 */ 1, { 0, 5 } }, 108 | { /* 73 */ 1, { 6, 1 } }, 109 | { /* 74 */ 1, { 5, 0 } }, 110 | { /* 75 */ 1, { 1, 6 } }, 111 | { /* 76 */ 1, { 4, 3 } }, 112 | { /* 77 */ 1, { 3, 5 } }, 113 | { /* 78 */ 1, { 3, 4 } }, 114 | { /* 79 */ 1, { 5, 3 } }, 115 | { /* 80 */ 1, { 2, 6 } }, 116 | { /* 81 */ 1, { 6, 2 } }, 117 | { /* 82 */ 1, { 1, 7 } }, 118 | { /* 83 */ 0, { 10, 11 } }, 119 | { /* 84 */ 0, { 11, 12 } }, 120 | { /* 85 */ 0, { 12, 13 } }, 121 | { /* 86 */ 0, { 13, 14 } }, 122 | { /* 87 */ 0, { 14, 15 } }, 123 | { /* 88 */ 0, { 15, 16 } }, 124 | { /* 89 */ 0, { 16, 17 } }, 125 | { /* 90 */ 0, { 17, 18 } }, 126 | { /* 91 */ 0, { 18, 19 } }, 127 | { /* 92 */ 0, { 19, 20 } }, 128 | { /* 93 */ 1, { 3, 6 } }, 129 | { /* 94 */ 1, { 0, 6 } }, 130 | { /* 95 */ 1, { 6, 0 } }, 131 | { /* 96 */ 1, { 4, 4 } }, 132 | { /* 97 */ 1, { 7, 1 } }, 133 | { /* 98 */ 1, { 4, 5 } }, 134 | { /* 99 */ 1, { 7, 2 } }, 135 | { /* 100 */ 1, { 5, 4 } }, 136 | { /* 101 */ 1, { 6, 3 } }, 137 | { /* 102 */ 1, { 2, 7 } }, 138 | { /* 103 */ 1, { 7, 3 } }, 139 | { /* 104 */ 1, { 6, 4 } }, 140 | { /* 105 */ 1, { 5, 5 } }, 141 | { /* 106 */ 1, { 4, 6 } }, 142 | { /* 107 */ 1, { 3, 7 } }, 143 | { /* 108 */ 0, { 5, 6 } }, 144 | { /* 109 */ 0, { 6, 7 } }, 145 | { /* 110 */ 0, { 7, 8 } }, 146 | { /* 111 */ 0, { 8, 9 } }, 147 | { /* 112 */ 0, { 9, 10 } }, 148 | { /* 113 */ 1, { 7, 0 } }, 149 | { /* 114 */ 1, { 0, 7 } }, 150 | { /* 115 */ 1, { 6, 5 } }, 151 | { /* 116 */ 1, { 5, 6 } }, 152 | { /* 117 */ 1, { 7, 4 } }, 153 | { /* 118 */ 1, { 4, 7 } }, 154 | { /* 119 */ 1, { 5, 7 } }, 155 | { /* 120 */ 1, { 7, 5 } }, 156 | { /* 121 */ 0, { 2, 3 } }, 157 | { /* 122 */ 0, { 3, 4 } }, 158 | { /* 123 */ 1, { 7, 6 } }, 159 | { /* 124 */ 1, { 6, 6 } }, 160 | { /* 125 */ 1, { 6, 7 } }, 161 | { /* 126 */ 1, { 7, 7 } } 162 | }; 163 | -------------------------------------------------------------------------------- /libfaad/codebook/hcb_8.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_8.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_8 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static const hcb hcb8_1[32] = { 40 | /* 3 bit codeword */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* */ 0, 0 }, 45 | 46 | /* 4 bit codewords */ 47 | { /* 00100 */ 1, 0 }, 48 | { /* */ 1, 0 }, 49 | { /* 00110 */ 2, 0 }, 50 | { /* */ 2, 0 }, 51 | { /* 01000 */ 3, 0 }, 52 | { /* */ 3, 0 }, 53 | { /* 01010 */ 4, 0 }, 54 | { /* */ 4, 0 }, 55 | { /* 01100 */ 5, 0 }, 56 | { /* */ 5, 0 }, 57 | 58 | /* 5 bit codewords */ 59 | { /* 01110 */ 6, 0 }, 60 | { /* 01111 */ 7, 0 }, 61 | { /* 10000 */ 8, 0 }, 62 | { /* 10001 */ 9, 0 }, 63 | { /* 10010 */ 10, 0 }, 64 | { /* 10011 */ 11, 0 }, 65 | { /* 10100 */ 12, 0 }, 66 | 67 | /* 6 bit codewords */ 68 | { /* 10101 */ 13, 1 }, 69 | { /* 10110 */ 15, 1 }, 70 | { /* 10111 */ 17, 1 }, 71 | { /* 11000 */ 19, 1 }, 72 | { /* 11001 */ 21, 1 }, 73 | 74 | /* 7 bit codewords */ 75 | { /* 11010 */ 23, 2 }, 76 | { /* 11011 */ 27, 2 }, 77 | { /* 11100 */ 31, 2 }, 78 | 79 | /* 7/8 bit codewords */ 80 | { /* 11101 */ 35, 3 }, 81 | 82 | /* 8 bit codewords */ 83 | { /* 11110 */ 43, 3 }, 84 | 85 | /* 8/9/10 bit codewords */ 86 | { /* 11111 */ 51, 5 } 87 | 88 | /* Size of second level table is 51 + 32 = 83 */ 89 | }; 90 | 91 | /* 2nd step table 92 | * 93 | * Gives size of codeword and actual data (x,y,v,w) 94 | */ 95 | static const hcb_2_pair hcb8_2[83] = { 96 | /* 3 bit codeword */ 97 | { 3, 1, 1 }, 98 | 99 | /* 4 bit codewords */ 100 | { 4, 2, 1 }, 101 | { 4, 1, 0 }, 102 | { 4, 1, 2 }, 103 | { 4, 0, 1 }, 104 | { 4, 2, 2 }, 105 | 106 | /* 5 bit codewords */ 107 | { 5, 0, 0 }, 108 | { 5, 2, 0 }, 109 | { 5, 0, 2 }, 110 | { 5, 3, 1 }, 111 | { 5, 1, 3 }, 112 | { 5, 3, 2 }, 113 | { 5, 2, 3 }, 114 | 115 | /* 6 bit codewords */ 116 | { 6, 3, 3 }, 117 | { 6, 4, 1 }, 118 | { 6, 1, 4 }, 119 | { 6, 4, 2 }, 120 | { 6, 2, 4 }, 121 | { 6, 3, 0 }, 122 | { 6, 0, 3 }, 123 | { 6, 4, 3 }, 124 | { 6, 3, 4 }, 125 | { 6, 5, 2 }, 126 | 127 | /* 7 bit codewords */ 128 | { 7, 5, 1 }, 129 | { 7, 2, 5 }, 130 | { 7, 1, 5 }, 131 | { 7, 5, 3 }, 132 | { 7, 3, 5 }, 133 | { 7, 4, 4 }, 134 | { 7, 5, 4 }, 135 | { 7, 0, 4 }, 136 | { 7, 4, 5 }, 137 | { 7, 4, 0 }, 138 | { 7, 2, 6 }, 139 | { 7, 6, 2 }, 140 | 141 | /* 7/8 bit codewords */ 142 | { 7, 6, 1 }, { 7, 6, 1 }, 143 | { 7, 1, 6 }, { 7, 1, 6 }, 144 | { 8, 3, 6 }, 145 | { 8, 6, 3 }, 146 | { 8, 5, 5 }, 147 | { 8, 5, 0 }, 148 | 149 | /* 8 bit codewords */ 150 | { 8, 6, 4 }, 151 | { 8, 0, 5 }, 152 | { 8, 4, 6 }, 153 | { 8, 7, 1 }, 154 | { 8, 7, 2 }, 155 | { 8, 2, 7 }, 156 | { 8, 6, 5 }, 157 | { 8, 7, 3 }, 158 | 159 | /* 8/9/10 bit codewords */ 160 | { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, 161 | { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, 162 | { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, 163 | { 9, 6, 6 }, { 9, 6, 6 }, 164 | { 9, 7, 4 }, { 9, 7, 4 }, 165 | { 9, 6, 0 }, { 9, 6, 0 }, 166 | { 9, 4, 7 }, { 9, 4, 7 }, 167 | { 9, 0, 6 }, { 9, 0, 6 }, 168 | { 9, 7, 5 }, { 9, 7, 5 }, 169 | { 9, 7, 6 }, { 9, 7, 6 }, 170 | { 9, 6, 7 }, { 9, 6, 7 }, 171 | { 10, 5, 7 }, 172 | { 10, 7, 0 }, 173 | { 10, 0, 7 }, 174 | { 10, 7, 7 } 175 | }; 176 | -------------------------------------------------------------------------------- /libfaad/drc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drc.c,v 1.29 2015/02/22 10:09:29 knik Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include 35 | #include "syntax.h" 36 | #include "drc.h" 37 | 38 | drc_info *drc_init(real_t cut, real_t boost) 39 | { 40 | drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info)); 41 | memset(drc, 0, sizeof(drc_info)); 42 | 43 | drc->ctrl1 = cut; 44 | drc->ctrl2 = boost; 45 | 46 | drc->num_bands = 1; 47 | drc->band_top[0] = 1024/4 - 1; 48 | drc->dyn_rng_sgn[0] = 1; 49 | drc->dyn_rng_ctl[0] = 0; 50 | 51 | return drc; 52 | } 53 | 54 | void drc_end(drc_info *drc) 55 | { 56 | if (drc) faad_free(drc); 57 | } 58 | 59 | #ifdef FIXED_POINT 60 | static real_t drc_pow2_table[] = 61 | { 62 | COEF_CONST(0.5146511183), 63 | COEF_CONST(0.5297315472), 64 | COEF_CONST(0.5452538663), 65 | COEF_CONST(0.5612310242), 66 | COEF_CONST(0.5776763484), 67 | COEF_CONST(0.5946035575), 68 | COEF_CONST(0.6120267717), 69 | COEF_CONST(0.6299605249), 70 | COEF_CONST(0.6484197773), 71 | COEF_CONST(0.6674199271), 72 | COEF_CONST(0.6869768237), 73 | COEF_CONST(0.7071067812), 74 | COEF_CONST(0.7278265914), 75 | COEF_CONST(0.7491535384), 76 | COEF_CONST(0.7711054127), 77 | COEF_CONST(0.7937005260), 78 | COEF_CONST(0.8169577266), 79 | COEF_CONST(0.8408964153), 80 | COEF_CONST(0.8655365610), 81 | COEF_CONST(0.8908987181), 82 | COEF_CONST(0.9170040432), 83 | COEF_CONST(0.9438743127), 84 | COEF_CONST(0.9715319412), 85 | COEF_CONST(1.0000000000), 86 | COEF_CONST(1.0293022366), 87 | COEF_CONST(1.0594630944), 88 | COEF_CONST(1.0905077327), 89 | COEF_CONST(1.1224620483), 90 | COEF_CONST(1.1553526969), 91 | COEF_CONST(1.1892071150), 92 | COEF_CONST(1.2240535433), 93 | COEF_CONST(1.2599210499), 94 | COEF_CONST(1.2968395547), 95 | COEF_CONST(1.3348398542), 96 | COEF_CONST(1.3739536475), 97 | COEF_CONST(1.4142135624), 98 | COEF_CONST(1.4556531828), 99 | COEF_CONST(1.4983070769), 100 | COEF_CONST(1.5422108254), 101 | COEF_CONST(1.5874010520), 102 | COEF_CONST(1.6339154532), 103 | COEF_CONST(1.6817928305), 104 | COEF_CONST(1.7310731220), 105 | COEF_CONST(1.7817974363), 106 | COEF_CONST(1.8340080864), 107 | COEF_CONST(1.8877486254), 108 | COEF_CONST(1.9430638823) 109 | }; 110 | #endif 111 | 112 | void drc_decode(drc_info *drc, real_t *spec) 113 | { 114 | uint16_t i, bd, top; 115 | #ifdef FIXED_POINT 116 | int32_t exp, frac; 117 | #else 118 | real_t factor, exp; 119 | #endif 120 | uint16_t bottom = 0; 121 | 122 | if (drc->num_bands == 1) 123 | drc->band_top[0] = 1024/4 - 1; 124 | 125 | for (bd = 0; bd < drc->num_bands; bd++) 126 | { 127 | top = 4 * (drc->band_top[bd] + 1); 128 | 129 | #ifndef FIXED_POINT 130 | /* Decode DRC gain factor */ 131 | if (drc->dyn_rng_sgn[bd]) /* compress */ 132 | exp = ((-drc->ctrl1 * drc->dyn_rng_ctl[bd]) - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); 133 | else /* boost */ 134 | exp = ((drc->ctrl2 * drc->dyn_rng_ctl[bd]) - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); 135 | factor = (real_t)pow(2.0, exp); 136 | 137 | /* Apply gain factor */ 138 | for (i = bottom; i < top; i++) 139 | spec[i] *= factor; 140 | #else 141 | /* Decode DRC gain factor */ 142 | if (drc->dyn_rng_sgn[bd]) /* compress */ 143 | { 144 | exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; 145 | frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; 146 | } else { /* boost */ 147 | exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; 148 | frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; 149 | } 150 | 151 | /* Apply gain factor */ 152 | if (exp < 0) 153 | { 154 | for (i = bottom; i < top; i++) 155 | { 156 | spec[i] >>= -exp; 157 | if (frac) 158 | spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); 159 | } 160 | } else { 161 | for (i = bottom; i < top; i++) 162 | { 163 | spec[i] = (int32_t)(((uint32_t)spec[i]) << exp); 164 | if (frac) 165 | spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); 166 | } 167 | } 168 | #endif 169 | 170 | bottom = top; 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /libfaad/drc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drc.h,v 1.22 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __DRC_H__ 32 | #define __DRC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define DRC_REF_LEVEL 20*4 /* -20 dB */ 39 | 40 | 41 | drc_info *drc_init(real_t cut, real_t boost); 42 | void drc_end(drc_info *drc); 43 | void drc_decode(drc_info *drc, real_t *spec); 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /libfaad/drm_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drm_dec.h,v 1.8 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __DRM_DEC_H__ 32 | #define __DRM_DEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define DRM_PARAMETRIC_STEREO 0 41 | #define DRM_NUM_SA_BANDS 8 42 | #define DRM_NUM_PAN_BANDS 20 43 | #define NUM_OF_LINKS 3 44 | #define NUM_OF_QMF_CHANNELS 64 45 | #define NUM_OF_SUBSAMPLES 30 46 | #define MAX_SA_BAND 46 47 | #define MAX_PAN_BAND 64 48 | #define MAX_DELAY 5 49 | 50 | typedef struct 51 | { 52 | uint8_t drm_ps_data_available; 53 | uint8_t bs_enable_sa; 54 | uint8_t bs_enable_pan; 55 | 56 | uint8_t bs_sa_dt_flag; 57 | uint8_t bs_pan_dt_flag; 58 | 59 | uint8_t g_last_had_sa; 60 | uint8_t g_last_had_pan; 61 | 62 | int8_t bs_sa_data[DRM_NUM_SA_BANDS]; 63 | int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; 64 | 65 | int8_t g_sa_index[DRM_NUM_SA_BANDS]; 66 | int8_t g_pan_index[DRM_NUM_PAN_BANDS]; 67 | int8_t g_prev_sa_index[DRM_NUM_SA_BANDS]; 68 | int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS]; 69 | 70 | int8_t sa_decode_error; 71 | int8_t pan_decode_error; 72 | 73 | int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; 74 | int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS]; 75 | 76 | uint8_t delay_buf_index_ser[NUM_OF_LINKS]; 77 | 78 | qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND]; 79 | 80 | complex_t d_buff[2][MAX_SA_BAND]; 81 | complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; 82 | 83 | real_t prev_nrg[MAX_SA_BAND]; 84 | real_t prev_peakdiff[MAX_SA_BAND]; 85 | real_t peakdecay_fast[MAX_SA_BAND]; 86 | } drm_ps_info; 87 | 88 | 89 | uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); 90 | 91 | drm_ps_info *drm_ps_init(void); 92 | void drm_ps_free(drm_ps_info *ps); 93 | 94 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /libfaad/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: error.c,v 1.33 2008/09/19 23:31:39 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "error.h" 33 | 34 | char *err_msg[] = { 35 | "No error", 36 | "Gain control not yet implemented", 37 | "Pulse coding not allowed in short blocks", 38 | "Invalid huffman codebook", 39 | "Scalefactor out of range", 40 | "Unable to find ADTS syncword", 41 | "Channel coupling not yet implemented", 42 | "Channel configuration not allowed in error resilient frame", 43 | "Bit error in error resilient scalefactor decoding", 44 | "Error decoding huffman scalefactor (bitstream error)", 45 | "Error decoding huffman codeword (bitstream error)", 46 | "Non existent huffman codebook number found", 47 | "Invalid number of channels", 48 | "Maximum number of bitstream elements exceeded", 49 | "Input data buffer too small", 50 | "Array index out of range", 51 | "Maximum number of scalefactor bands exceeded", 52 | "Quantised value out of range", 53 | "LTP lag out of range", 54 | "Invalid SBR parameter decoded", 55 | "SBR called without being initialised", 56 | "Unexpected channel configuration change", 57 | "Error in program_config_element", 58 | "First SBR frame is not the same as first AAC frame", 59 | "Unexpected fill element with SBR data", 60 | "Not all elements were provided with SBR data", 61 | "LTP decoding not available", 62 | "Output data buffer too small", 63 | "CRC error in DRM data", 64 | "PNS not allowed in DRM data stream", 65 | "No standard extension payload allowed in DRM", 66 | "PCE shall be the first element in a frame", 67 | "Bitstream value not allowed by specification", 68 | "MAIN prediction not initialised" 69 | }; 70 | 71 | -------------------------------------------------------------------------------- /libfaad/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: error.h,v 1.27 2008/09/19 23:31:40 menno Exp $ 29 | **/ 30 | 31 | #ifndef __ERROR_H__ 32 | #define __ERROR_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define NUM_ERROR_MESSAGES 34 39 | extern char *err_msg[]; 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /libfaad/faad2.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: FAAD2 7 | Description: Freeware Advanced Audio (AAC) Decoder 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lfaad 10 | Libs.private: -lm 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libfaad/filtbank.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: filtbank.h,v 1.27 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __FILTBANK_H__ 32 | #define __FILTBANK_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | fb_info *filter_bank_init(uint16_t frame_len); 40 | void filter_bank_end(fb_info *fb); 41 | 42 | #ifdef LTP_DEC 43 | void filter_bank_ltp(fb_info *fb, 44 | uint8_t window_sequence, 45 | uint8_t window_shape, 46 | uint8_t window_shape_prev, 47 | real_t *in_data, 48 | real_t *out_mdct, 49 | uint8_t object_type, 50 | uint16_t frame_len); 51 | #endif 52 | 53 | void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, 54 | uint8_t window_shape_prev, real_t *freq_in, 55 | real_t *time_out, real_t *overlap, 56 | uint8_t object_type, uint16_t frame_len); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /libfaad/huffman.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: huffman.h,v 1.28 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __HUFFMAN_H__ 32 | #define __HUFFMAN_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | int8_t huffman_scale_factor(bitfile *ld); 39 | uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp); 40 | #ifdef ERROR_RESILIENCE 41 | int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /libfaad/is.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: is.c,v 1.28 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include "syntax.h" 35 | #include "is.h" 36 | 37 | #ifdef FIXED_POINT 38 | static real_t pow05_table[] = { 39 | COEF_CONST(1.0), /* 0.5^( 0/4) */ 40 | COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */ 41 | COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */ 42 | COEF_CONST(0.59460355750136) /* 0.5^(+3/4) */ 43 | }; 44 | #endif 45 | 46 | void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 47 | uint16_t frame_len) 48 | { 49 | uint8_t g, sfb, b; 50 | uint16_t i; 51 | real_t scale; 52 | #ifdef FIXED_POINT 53 | int32_t exp, frac; 54 | #endif 55 | 56 | uint16_t nshort = frame_len/8; 57 | uint8_t group = 0; 58 | 59 | for (g = 0; g < icsr->num_window_groups; g++) 60 | { 61 | /* Do intensity stereo decoding */ 62 | for (b = 0; b < icsr->window_group_length[g]; b++) 63 | { 64 | for (sfb = 0; sfb < icsr->max_sfb; sfb++) 65 | { 66 | if (is_intensity(icsr, g, sfb)) 67 | { 68 | int16_t scale_factor = icsr->scale_factors[g][sfb]; 69 | #ifdef MAIN_DEC 70 | /* For scalefactor bands coded in intensity stereo the 71 | corresponding predictors in the right channel are 72 | switched to "off". 73 | */ 74 | ics->pred.prediction_used[sfb] = 0; 75 | icsr->pred.prediction_used[sfb] = 0; 76 | #endif 77 | 78 | #ifndef FIXED_POINT 79 | scale_factor = min(max(scale_factor, -120), 120); 80 | scale = (real_t)pow(0.5, (0.25*scale_factor)); 81 | #else 82 | scale_factor = min(max(scale_factor, -60), 60); 83 | exp = scale_factor >> 2; /* exp is -15..15 */ 84 | frac = scale_factor & 3; 85 | scale = pow05_table[frac]; 86 | exp += COEF_BITS - REAL_BITS; /* exp is -1..29 */ 87 | if (exp < 0) 88 | scale <<= -exp; 89 | else 90 | scale >>= exp; 91 | #endif 92 | 93 | /* Scale from left to right channel, 94 | do not touch left channel */ 95 | for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb+1], ics->swb_offset_max); i++) 96 | { 97 | r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale); 98 | if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) 99 | r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i]; 100 | } 101 | } 102 | } 103 | group++; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /libfaad/is.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: is.h,v 1.20 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __IS_H__ 32 | #define __IS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 41 | uint16_t frame_len); 42 | 43 | static INLINE int8_t is_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) 44 | { 45 | switch (ics->sfb_cb[group][sfb]) 46 | { 47 | case INTENSITY_HCB: 48 | return 1; 49 | case INTENSITY_HCB2: 50 | return -1; 51 | default: 52 | return 0; 53 | } 54 | } 55 | 56 | static INLINE int8_t invert_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) 57 | { 58 | if (ics->ms_mask_present == 1) 59 | return (1-2*ics->ms_used[group][sfb]); 60 | return 1; 61 | } 62 | 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /libfaad/lt_predict.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: lt_predict.c,v 1.27 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | 32 | #include "common.h" 33 | #include "structs.h" 34 | 35 | #ifdef LTP_DEC 36 | 37 | #include 38 | #include "syntax.h" 39 | #include "lt_predict.h" 40 | #include "filtbank.h" 41 | #include "tns.h" 42 | 43 | 44 | /* static function declarations */ 45 | static int16_t real_to_int16(real_t sig_in); 46 | 47 | 48 | /* check if the object type is an object type that can have LTP */ 49 | uint8_t is_ltp_ot(uint8_t object_type) 50 | { 51 | #ifdef LTP_DEC 52 | if ((object_type == LTP) 53 | #ifdef ERROR_RESILIENCE 54 | || (object_type == ER_LTP) 55 | #endif 56 | #ifdef LD_DEC 57 | || (object_type == LD) 58 | #endif 59 | ) 60 | { 61 | return 1; 62 | } 63 | #endif 64 | 65 | return 0; 66 | } 67 | 68 | ALIGN static const real_t codebook[8] = 69 | { 70 | REAL_CONST(0.570829), 71 | REAL_CONST(0.696616), 72 | REAL_CONST(0.813004), 73 | REAL_CONST(0.911304), 74 | REAL_CONST(0.984900), 75 | REAL_CONST(1.067894), 76 | REAL_CONST(1.194601), 77 | REAL_CONST(1.369533) 78 | }; 79 | 80 | void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, 81 | int16_t *lt_pred_stat, fb_info *fb, uint8_t win_shape, 82 | uint8_t win_shape_prev, uint8_t sr_index, 83 | uint8_t object_type, uint16_t frame_len) 84 | { 85 | uint8_t sfb; 86 | uint16_t bin, i, num_samples; 87 | ALIGN real_t x_est[2048]; 88 | ALIGN real_t X_est[2048]; 89 | 90 | if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) 91 | { 92 | if (ltp->data_present) 93 | { 94 | num_samples = frame_len << 1; 95 | 96 | for(i = 0; i < num_samples; i++) 97 | { 98 | /* The extra lookback M (N/2 for LD, 0 for LTP) is handled 99 | in the buffer updating */ 100 | 101 | #if 0 102 | x_est[i] = MUL_R_C(lt_pred_stat[num_samples + i - ltp->lag], 103 | codebook[ltp->coef]); 104 | #else 105 | /* lt_pred_stat is a 16 bit int, multiplied with the fixed point real 106 | this gives a real for x_est 107 | */ 108 | x_est[i] = (real_t)lt_pred_stat[num_samples + i - ltp->lag] * codebook[ltp->coef]; 109 | #endif 110 | } 111 | 112 | filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev, 113 | x_est, X_est, object_type, frame_len); 114 | 115 | tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est, 116 | frame_len); 117 | 118 | for (sfb = 0; sfb < ltp->last_band; sfb++) 119 | { 120 | if (ltp->long_used[sfb]) 121 | { 122 | uint16_t low = ics->swb_offset[sfb]; 123 | uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); 124 | 125 | for (bin = low; bin < high; bin++) 126 | { 127 | spec[bin] += X_est[bin]; 128 | } 129 | } 130 | } 131 | } 132 | } 133 | } 134 | 135 | #ifdef FIXED_POINT 136 | static INLINE int16_t real_to_int16(real_t sig_in) 137 | { 138 | if (sig_in >= 0) 139 | { 140 | sig_in += (1 << (REAL_BITS-1)); 141 | if (sig_in >= REAL_CONST(32768)) 142 | return 32767; 143 | } else { 144 | sig_in += -(1 << (REAL_BITS-1)); 145 | if (sig_in <= REAL_CONST(-32768)) 146 | return -32768; 147 | } 148 | 149 | return (int16_t)(sig_in >> REAL_BITS); 150 | } 151 | #else 152 | static INLINE int16_t real_to_int16(real_t sig_in) 153 | { 154 | if (sig_in >= 0) 155 | { 156 | #ifndef HAS_LRINTF 157 | sig_in += 0.5f; 158 | #endif 159 | if (sig_in >= 32768.0f) 160 | return 32767; 161 | } else { 162 | #ifndef HAS_LRINTF 163 | sig_in += -0.5f; 164 | #endif 165 | if (sig_in <= -32768.0f) 166 | return -32768; 167 | } 168 | 169 | return (int16_t)lrintf(sig_in); 170 | } 171 | #endif 172 | 173 | void lt_update_state(int16_t *lt_pred_stat, real_t *time, real_t *overlap, 174 | uint16_t frame_len, uint8_t object_type) 175 | { 176 | uint16_t i; 177 | 178 | /* 179 | * The reference point for index i and the content of the buffer 180 | * lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the 181 | * last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1) 182 | * is always all zeros. The rest of lt_pred_stat (i<0) contains the previous 183 | * fully reconstructed time domain samples, i.e., output of the decoder. 184 | * 185 | * These values are shifted up by N*2 to avoid (i<0) 186 | * 187 | * For the LD object type an extra 512 samples lookback is accomodated here. 188 | */ 189 | #ifdef LD_DEC 190 | if (object_type == LD) 191 | { 192 | for (i = 0; i < frame_len; i++) 193 | { 194 | lt_pred_stat[i] /* extra 512 */ = lt_pred_stat[i + frame_len]; 195 | lt_pred_stat[frame_len + i] = lt_pred_stat[i + (frame_len * 2)]; 196 | lt_pred_stat[(frame_len * 2) + i] = real_to_int16(time[i]); 197 | lt_pred_stat[(frame_len * 3) + i] = real_to_int16(overlap[i]); 198 | } 199 | } else { 200 | #endif 201 | for (i = 0; i < frame_len; i++) 202 | { 203 | lt_pred_stat[i] = lt_pred_stat[i + frame_len]; 204 | lt_pred_stat[frame_len + i] = real_to_int16(time[i]); 205 | lt_pred_stat[(frame_len * 2) + i] = real_to_int16(overlap[i]); 206 | #if 0 /* set to zero once upon initialisation */ 207 | lt_pred_stat[(frame_len * 3) + i] = 0; 208 | #endif 209 | } 210 | #ifdef LD_DEC 211 | } 212 | #endif 213 | } 214 | 215 | #endif 216 | -------------------------------------------------------------------------------- /libfaad/lt_predict.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: lt_predict.h,v 1.20 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifdef LTP_DEC 32 | 33 | #ifndef __LT_PREDICT_H__ 34 | #define __LT_PREDICT_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include "filtbank.h" 41 | 42 | uint8_t is_ltp_ot(uint8_t object_type); 43 | 44 | void lt_prediction(ic_stream *ics, 45 | ltp_info *ltp, 46 | real_t *spec, 47 | int16_t *lt_pred_stat, 48 | fb_info *fb, 49 | uint8_t win_shape, 50 | uint8_t win_shape_prev, 51 | uint8_t sr_index, 52 | uint8_t object_type, 53 | uint16_t frame_len); 54 | 55 | void lt_update_state(int16_t *lt_pred_stat, 56 | real_t *time, 57 | real_t *overlap, 58 | uint16_t frame_len, 59 | uint8_t object_type); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libfaad/mdct.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mdct.h,v 1.30 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MDCT_H__ 32 | #define __MDCT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | mdct_info *faad_mdct_init(uint16_t N); 40 | void faad_mdct_end(mdct_info *mdct); 41 | void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out); 42 | void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out); 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /libfaad/mp4.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mp4.h,v 1.28 2009/02/05 00:51:03 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MP4_H__ 32 | #define __MP4_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | #include "neaacdec.h" 40 | 41 | int8_t AudioSpecificConfig2(uint8_t *pBuffer, 42 | uint32_t buffer_size, 43 | mp4AudioSpecificConfig *mp4ASC, 44 | program_config *pce, uint8_t short_form); 45 | 46 | int8_t AudioSpecificConfigFromBitfile(bitfile *ld, 47 | mp4AudioSpecificConfig *mp4ASC, 48 | program_config *pce, uint32_t bsize, uint8_t short_form); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /libfaad/ms.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ms.c,v 1.21 2007/11/01 12:33:32 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include "syntax.h" 35 | #include "ms.h" 36 | #include "is.h" 37 | #include "pns.h" 38 | 39 | void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 40 | uint16_t frame_len) 41 | { 42 | uint8_t g, b, sfb; 43 | uint8_t group = 0; 44 | uint16_t nshort = frame_len/8; 45 | 46 | uint16_t i, k; 47 | real_t tmp; 48 | 49 | if (ics->ms_mask_present >= 1) 50 | { 51 | for (g = 0; g < ics->num_window_groups; g++) 52 | { 53 | for (b = 0; b < ics->window_group_length[g]; b++) 54 | { 55 | for (sfb = 0; sfb < ics->max_sfb; sfb++) 56 | { 57 | /* If intensity stereo coding or noise substitution is on 58 | for a particular scalefactor band, no M/S stereo decoding 59 | is carried out. 60 | */ 61 | if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && 62 | !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) 63 | { 64 | for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb+1], ics->swb_offset_max); i++) 65 | { 66 | k = (group*nshort) + i; 67 | tmp = l_spec[k] - r_spec[k]; 68 | l_spec[k] = l_spec[k] + r_spec[k]; 69 | r_spec[k] = tmp; 70 | } 71 | } 72 | } 73 | group++; 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libfaad/ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ms.h,v 1.19 2007/11/01 12:33:32 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MS_H__ 32 | #define __MS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 39 | uint16_t frame_len); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /libfaad/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: output.h,v 1.26 2009/01/26 23:51:15 menno Exp $ 29 | **/ 30 | 31 | #ifndef __OUTPUT_H__ 32 | #define __OUTPUT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void* output_to_PCM(NeAACDecStruct *hDecoder, 39 | real_t **input, 40 | void *samplebuffer, 41 | uint8_t channels, 42 | uint16_t frame_len, 43 | uint8_t format); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /libfaad/pns.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pns.h,v 1.27 2007/11/01 12:33:33 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PNS_H__ 32 | #define __PNS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | #define NOISE_OFFSET 90 41 | 42 | void pns_decode(ic_stream *ics_left, ic_stream *ics_right, 43 | real_t *spec_left, real_t *spec_right, uint16_t frame_len, 44 | uint8_t channel_pair, uint8_t object_type, 45 | /* RNG states */ uint32_t *__r1, uint32_t *__r2); 46 | 47 | static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) 48 | { 49 | if (ics->sfb_cb[group][sfb] == NOISE_HCB) 50 | return 1; 51 | return 0; 52 | } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif 58 | -------------------------------------------------------------------------------- /libfaad/ps_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ps_dec.h,v 1.13 2009/01/26 22:32:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PS_DEC_H__ 32 | #define __PS_DEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define EXTENSION_ID_PS 2 41 | 42 | #define MAX_PS_ENVELOPES 5 43 | #define NO_ALLPASS_LINKS 3 44 | 45 | typedef struct 46 | { 47 | /* bitstream parameters */ 48 | uint8_t enable_iid; 49 | uint8_t enable_icc; 50 | uint8_t enable_ext; 51 | 52 | uint8_t iid_mode; 53 | uint8_t icc_mode; 54 | uint8_t nr_iid_par; 55 | uint8_t nr_ipdopd_par; 56 | uint8_t nr_icc_par; 57 | 58 | uint8_t frame_class; 59 | uint8_t num_env; 60 | 61 | uint8_t border_position[MAX_PS_ENVELOPES+1]; 62 | 63 | uint8_t iid_dt[MAX_PS_ENVELOPES]; 64 | uint8_t icc_dt[MAX_PS_ENVELOPES]; 65 | 66 | uint8_t enable_ipdopd; 67 | uint8_t ipd_mode; 68 | uint8_t ipd_dt[MAX_PS_ENVELOPES]; 69 | uint8_t opd_dt[MAX_PS_ENVELOPES]; 70 | 71 | /* indices */ 72 | int8_t iid_index_prev[34]; 73 | int8_t icc_index_prev[34]; 74 | int8_t ipd_index_prev[17]; 75 | int8_t opd_index_prev[17]; 76 | int8_t iid_index[MAX_PS_ENVELOPES][34]; 77 | int8_t icc_index[MAX_PS_ENVELOPES][34]; 78 | int8_t ipd_index[MAX_PS_ENVELOPES][17]; 79 | int8_t opd_index[MAX_PS_ENVELOPES][17]; 80 | 81 | int8_t ipd_index_1[17]; 82 | int8_t opd_index_1[17]; 83 | int8_t ipd_index_2[17]; 84 | int8_t opd_index_2[17]; 85 | 86 | /* ps data was correctly read */ 87 | uint8_t ps_data_available; 88 | 89 | /* a header has been read */ 90 | uint8_t header_read; 91 | 92 | /**/ 93 | uint8_t num_groups; 94 | uint8_t num_hybrid_groups; 95 | uint8_t nr_par_bands; 96 | uint8_t nr_allpass_bands; 97 | uint8_t decay_cutoff; 98 | 99 | /* filter delay handling */ 100 | uint8_t saved_delay; 101 | uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS]; 102 | uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS]; 103 | uint8_t delay_D[64]; 104 | uint8_t delay_buf_index_delay[64]; 105 | 106 | /* mixing and phase */ 107 | uint8_t phase_hist; 108 | 109 | /* hybrid filterbank parameters */ 110 | uint8_t use34hybrid_bands; 111 | uint8_t numTimeSlotsRate; 112 | 113 | uint8_t *group_border; 114 | uint16_t *map_group2bk; 115 | 116 | complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */ 117 | complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */ 118 | complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */ 119 | complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */ 120 | 121 | /* transients */ 122 | real_t alpha_decay; 123 | real_t alpha_smooth; 124 | 125 | real_t P_PeakDecayNrg[34]; 126 | real_t P_prev[34]; 127 | real_t P_SmoothPeakDecayDiffNrg_prev[34]; 128 | 129 | /* mixing and phase */ 130 | complex_t h11_prev[50]; 131 | complex_t h12_prev[50]; 132 | complex_t h21_prev[50]; 133 | complex_t h22_prev[50]; 134 | complex_t ipd_prev[20][2]; 135 | complex_t opd_prev[20][2]; 136 | 137 | /* hybrid filterbank parameters */ 138 | void *hyb; 139 | } ps_info; 140 | 141 | /* ps_syntax.c */ 142 | uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); 143 | 144 | /* ps_dec.c */ 145 | ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate); 146 | void ps_free(ps_info *ps); 147 | 148 | uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]); 149 | 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | #endif 155 | 156 | -------------------------------------------------------------------------------- /libfaad/pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pulse.c,v 1.21 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | #include "common.h" 31 | #include "structs.h" 32 | 33 | #include "syntax.h" 34 | #include "pulse.h" 35 | 36 | uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) 37 | { 38 | uint8_t i; 39 | uint16_t k; 40 | pulse_info *pul = &(ics->pul); 41 | 42 | k = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max); 43 | 44 | for (i = 0; i <= pul->number_pulse; i++) 45 | { 46 | k += pul->pulse_offset[i]; 47 | 48 | if (k >= framelen) 49 | return 15; /* should not be possible */ 50 | 51 | if (spec_data[k] > 0) 52 | spec_data[k] += pul->pulse_amp[i]; 53 | else 54 | spec_data[k] -= pul->pulse_amp[i]; 55 | } 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /libfaad/pulse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pulse.h,v 1.20 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PULSE_H__ 32 | #define __PULSE_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif 44 | -------------------------------------------------------------------------------- /libfaad/rvlc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: rvlc.h,v 1.17 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __RVLC_SCF_H__ 32 | #define __RVLC_SCF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | int16_t index; 41 | uint16_t len; 42 | uint32_t cw; 43 | } rvlc_huff_table; 44 | 45 | 46 | #define ESC_VAL 7 47 | 48 | 49 | uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld); 50 | uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /libfaad/sbr_dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_dct.h,v 1.19 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_DCT_H__ 32 | #define __SBR_DCT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag); 39 | 40 | void DCT3_32_unscaled(real_t *y, real_t *x); 41 | void DCT4_32(real_t *y, real_t *x); 42 | void DST4_32(real_t *y, real_t *x); 43 | void DCT2_32_unscaled(real_t *y, real_t *x); 44 | void DCT4_16(real_t *y, real_t *x); 45 | void DCT2_16_unscaled(real_t *y, real_t *x); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /libfaad/sbr_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_DEC_H__ 32 | #define __SBR_DEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #ifdef PS_DEC 39 | #include "ps_dec.h" 40 | #endif 41 | #ifdef DRM_PS 42 | #include "drm_dec.h" 43 | #endif 44 | 45 | /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */ 46 | #define MAX_NTSRHFG 40 47 | #define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */ 48 | 49 | /* MAX_M: maximum value for M */ 50 | #define MAX_M 49 51 | /* MAX_L_E: maximum value for L_E */ 52 | #define MAX_L_E 5 53 | 54 | typedef struct { 55 | real_t *x; 56 | int16_t x_index; 57 | uint8_t channels; 58 | } qmfa_info; 59 | 60 | typedef struct { 61 | real_t *v; 62 | int16_t v_index; 63 | uint8_t channels; 64 | } qmfs_info; 65 | 66 | typedef struct 67 | { 68 | uint32_t sample_rate; 69 | uint32_t maxAACLine; 70 | 71 | uint8_t rate; 72 | uint8_t just_seeked; 73 | uint8_t ret; 74 | 75 | uint8_t amp_res[2]; 76 | 77 | uint8_t k0; 78 | uint8_t kx; 79 | uint8_t M; 80 | uint8_t N_master; 81 | uint8_t N_high; 82 | uint8_t N_low; 83 | uint8_t N_Q; 84 | uint8_t N_L[4]; 85 | uint8_t n[2]; 86 | 87 | uint8_t f_master[64]; 88 | uint8_t f_table_res[2][64]; 89 | uint8_t f_table_noise[64]; 90 | uint8_t f_table_lim[4][64]; 91 | #ifdef SBR_LOW_POWER 92 | uint8_t f_group[5][64]; 93 | uint8_t N_G[5]; 94 | #endif 95 | 96 | uint8_t table_map_k_to_g[64]; 97 | 98 | uint8_t abs_bord_lead[2]; 99 | uint8_t abs_bord_trail[2]; 100 | uint8_t n_rel_lead[2]; 101 | uint8_t n_rel_trail[2]; 102 | 103 | uint8_t L_E[2]; 104 | uint8_t L_E_prev[2]; 105 | uint8_t L_Q[2]; 106 | 107 | uint8_t t_E[2][MAX_L_E+1]; 108 | uint8_t t_Q[2][3]; 109 | uint8_t f[2][MAX_L_E+1]; 110 | uint8_t f_prev[2]; 111 | 112 | real_t *G_temp_prev[2][5]; 113 | real_t *Q_temp_prev[2][5]; 114 | 115 | int16_t E[2][64][MAX_L_E]; 116 | int16_t E_prev[2][64]; 117 | #ifndef FIXED_POINT 118 | real_t E_orig[2][64][MAX_L_E]; 119 | #endif 120 | real_t E_curr[2][64][MAX_L_E]; 121 | int32_t Q[2][64][2]; 122 | #ifndef FIXED_POINT 123 | real_t Q_div[2][64][2]; 124 | real_t Q_div2[2][64][2]; 125 | #endif 126 | int32_t Q_prev[2][64]; 127 | 128 | int8_t l_A[2]; 129 | int8_t l_A_prev[2]; 130 | 131 | uint8_t bs_invf_mode[2][MAX_L_E]; 132 | uint8_t bs_invf_mode_prev[2][MAX_L_E]; 133 | real_t bwArray[2][64]; 134 | real_t bwArray_prev[2][64]; 135 | 136 | uint8_t noPatches; 137 | uint8_t patchNoSubbands[64]; 138 | uint8_t patchStartSubband[64]; 139 | 140 | uint8_t bs_add_harmonic[2][64]; 141 | uint8_t bs_add_harmonic_prev[2][64]; 142 | 143 | int8_t GQ_ringbuf_index[2]; 144 | 145 | uint16_t index_noise_prev[2]; 146 | uint8_t psi_is_prev[2]; 147 | 148 | uint8_t bs_start_freq_prev; 149 | uint8_t bs_stop_freq_prev; 150 | uint8_t bs_xover_band_prev; 151 | uint8_t bs_freq_scale_prev; 152 | uint8_t bs_alter_scale_prev; 153 | uint8_t bs_noise_bands_prev; 154 | 155 | int8_t prevEnvIsShort[2]; 156 | 157 | int8_t kx_prev; 158 | uint8_t bsco; 159 | uint8_t bsco_prev; 160 | uint8_t M_prev; 161 | uint16_t frame_len; 162 | 163 | uint32_t frame; 164 | uint32_t header_count; 165 | 166 | qmfa_info *qmfa[2]; 167 | qmfs_info *qmfs[2]; 168 | 169 | qmf_t Xsbr[2][MAX_NTSRHFG][64]; 170 | 171 | #if defined(DRM) && defined(DRM_PS) 172 | drm_ps_info *drm_ps; 173 | #endif 174 | 175 | #ifdef PS_DEC 176 | ps_info *ps; 177 | #endif 178 | 179 | uint8_t numTimeSlotsRate; 180 | uint8_t numTimeSlots; 181 | uint8_t tHFGen; 182 | uint8_t tHFAdj; 183 | 184 | #if (defined(PS_DEC) || defined(DRM_PS)) 185 | uint8_t ps_used; 186 | uint8_t psResetFlag; 187 | #endif 188 | 189 | /* to get it compiling */ 190 | /* we'll see during the coding of all the tools, whether 191 | these are all used or not. 192 | */ 193 | uint8_t bs_header_flag; 194 | uint8_t bs_crc_flag; 195 | uint16_t bs_sbr_crc_bits; 196 | uint8_t bs_protocol_version; 197 | uint8_t bs_amp_res; 198 | uint8_t bs_start_freq; 199 | uint8_t bs_stop_freq; 200 | uint8_t bs_xover_band; 201 | uint8_t bs_freq_scale; 202 | uint8_t bs_alter_scale; 203 | uint8_t bs_noise_bands; 204 | uint8_t bs_limiter_bands; 205 | uint8_t bs_limiter_gains; 206 | uint8_t bs_interpol_freq; 207 | uint8_t bs_smoothing_mode; 208 | uint8_t bs_samplerate_mode; 209 | uint8_t bs_add_harmonic_flag[2]; 210 | uint8_t bs_add_harmonic_flag_prev[2]; 211 | uint8_t bs_extended_data; 212 | uint8_t bs_extension_id; 213 | uint8_t bs_extension_data; 214 | uint8_t bs_coupling; 215 | uint8_t bs_frame_class[2]; 216 | uint8_t bs_rel_bord[2][9]; 217 | uint8_t bs_rel_bord_0[2][9]; 218 | uint8_t bs_rel_bord_1[2][9]; 219 | uint8_t bs_pointer[2]; 220 | uint8_t bs_abs_bord_0[2]; 221 | uint8_t bs_abs_bord_1[2]; 222 | uint8_t bs_num_rel_0[2]; 223 | uint8_t bs_num_rel_1[2]; 224 | uint8_t bs_df_env[2][9]; 225 | uint8_t bs_df_noise[2][3]; 226 | 227 | uint8_t Reset; 228 | uint8_t id_aac; 229 | 230 | #ifdef DRM 231 | uint8_t Is_DRM_SBR; 232 | #endif 233 | } sbr_info; 234 | 235 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, 236 | uint32_t sample_rate, uint8_t downSampledSBR 237 | #ifdef DRM 238 | , uint8_t IsDRM 239 | #endif 240 | ); 241 | void sbrDecodeEnd(sbr_info *sbr); 242 | void sbrReset(sbr_info *sbr); 243 | 244 | uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, 245 | const uint8_t just_seeked, const uint8_t downSampledSBR); 246 | uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, 247 | const uint8_t just_seeked, const uint8_t downSampledSBR); 248 | #if (defined(PS_DEC) || defined(DRM_PS)) 249 | uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, 250 | const uint8_t just_seeked, const uint8_t downSampledSBR); 251 | #endif 252 | 253 | 254 | #ifdef __cplusplus 255 | } 256 | #endif 257 | #endif 258 | 259 | -------------------------------------------------------------------------------- /libfaad/sbr_e_nf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_E_NF_H__ 32 | #define __SBR_E_NF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | void extract_envelope_data(sbr_info *sbr, uint8_t ch); 40 | void extract_noise_floor_data(sbr_info *sbr, uint8_t ch); 41 | #ifndef FIXED_POINT 42 | void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch); 43 | void unmap_envelope_noise(sbr_info *sbr); 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /libfaad/sbr_fbt.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_FBT_H__ 32 | #define __SBR_FBT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, 39 | uint32_t sample_rate); 40 | uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, 41 | uint8_t k0); 42 | uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, 43 | uint8_t bs_alter_scale); 44 | uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, 45 | uint8_t bs_freq_scale, uint8_t bs_alter_scale); 46 | uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, 47 | uint8_t k2); 48 | void limiter_frequency_table(sbr_info *sbr); 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /libfaad/sbr_hfadj.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HFADJ_H__ 32 | #define __SBR_HFADJ_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | real_t G_lim_boost[MAX_L_E][MAX_M]; 41 | real_t Q_M_lim_boost[MAX_L_E][MAX_M]; 42 | real_t S_M_boost[MAX_L_E][MAX_M]; 43 | } sbr_hfadj_info; 44 | 45 | 46 | uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] 47 | #ifdef SBR_LOW_POWER 48 | ,real_t *deg 49 | #endif 50 | ,uint8_t ch); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /libfaad/sbr_hfgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HFGEN_H__ 32 | #define __SBR_HFGEN_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], 39 | qmf_t Xhigh[MAX_NTSRHFG][64] 40 | #ifdef SBR_LOW_POWER 41 | ,real_t *deg 42 | #endif 43 | ,uint8_t ch); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /libfaad/sbr_huff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_huff.h,v 1.21 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HUFF_H__ 32 | #define __SBR_HUFF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch); 40 | void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /libfaad/sbr_qmf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_qmf.h,v 1.25 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_QMF_H__ 32 | #define __SBR_QMF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | qmfa_info *qmfa_init(uint8_t channels); 39 | void qmfa_end(qmfa_info *qmfa); 40 | qmfs_info *qmfs_init(uint8_t channels); 41 | void qmfs_end(qmfs_info *qmfs); 42 | 43 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, 44 | qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx); 45 | void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 46 | real_t *output); 47 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 48 | real_t *output); 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /libfaad/sbr_syntax.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_syntax.h,v 1.23 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_SYNTAX_H__ 32 | #define __SBR_SYNTAX_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define T_HFGEN 8 41 | #define T_HFADJ 2 42 | 43 | #define EXT_SBR_DATA 13 44 | #define EXT_SBR_DATA_CRC 14 45 | 46 | #define FIXFIX 0 47 | #define FIXVAR 1 48 | #define VARFIX 2 49 | #define VARVAR 3 50 | 51 | #define LO_RES 0 52 | #define HI_RES 1 53 | 54 | #define NO_TIME_SLOTS_960 15 55 | #define NO_TIME_SLOTS 16 56 | #define RATE 2 57 | 58 | #define NOISE_FLOOR_OFFSET 6 59 | 60 | 61 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt, 62 | uint8_t resetFlag); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif /* __SBR_SYNTAX_H__ */ 68 | 69 | -------------------------------------------------------------------------------- /libfaad/sbr_tf_grid.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_tf_grid.c,v 1.20 2008/09/19 22:50:20 menno Exp $ 29 | **/ 30 | 31 | /* Time/Frequency grid */ 32 | 33 | #include "common.h" 34 | #include "structs.h" 35 | 36 | #ifdef SBR_DEC 37 | 38 | #include 39 | 40 | #include "sbr_syntax.h" 41 | #include "sbr_tf_grid.h" 42 | 43 | 44 | /* static function declarations */ 45 | #if 0 46 | static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); 47 | static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); 48 | #endif 49 | static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); 50 | 51 | 52 | /* function constructs new time border vector */ 53 | /* first build into temp vector to be able to use previous vector on error */ 54 | uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) 55 | { 56 | uint8_t l, border, temp, trail; 57 | uint8_t t_E_temp[6] = {0}; 58 | 59 | trail = sbr->abs_bord_trail[ch]; 60 | t_E_temp[0] = sbr->rate * sbr->abs_bord_lead[ch]; 61 | t_E_temp[sbr->L_E[ch]] = sbr->rate * trail; 62 | 63 | switch (sbr->bs_frame_class[ch]) 64 | { 65 | case FIXFIX: 66 | switch (sbr->L_E[ch]) 67 | { 68 | case 4: 69 | temp = (sbr->numTimeSlots / 4); 70 | t_E_temp[3] = sbr->rate * 3 * temp; 71 | t_E_temp[2] = sbr->rate * 2 * temp; 72 | t_E_temp[1] = sbr->rate * temp; 73 | break; 74 | case 2: 75 | t_E_temp[1] = sbr->rate * (sbr->numTimeSlots / 2); 76 | break; 77 | default: 78 | break; 79 | } 80 | break; 81 | 82 | case FIXVAR: 83 | if (sbr->L_E[ch] > 1) 84 | { 85 | int8_t i = sbr->L_E[ch]; 86 | border = sbr->abs_bord_trail[ch]; 87 | 88 | for (l = 0; l < (sbr->L_E[ch] - 1); l++) 89 | { 90 | if (border < sbr->bs_rel_bord[ch][l]) 91 | return 1; 92 | 93 | border -= sbr->bs_rel_bord[ch][l]; 94 | t_E_temp[--i] = sbr->rate * border; 95 | } 96 | } 97 | break; 98 | 99 | case VARFIX: 100 | if (sbr->L_E[ch] > 1) 101 | { 102 | int8_t i = 1; 103 | border = sbr->abs_bord_lead[ch]; 104 | 105 | for (l = 0; l < (sbr->L_E[ch] - 1); l++) 106 | { 107 | border += sbr->bs_rel_bord[ch][l]; 108 | 109 | if (border > trail) 110 | return 1; 111 | 112 | t_E_temp[i++] = sbr->rate * border; 113 | } 114 | } 115 | break; 116 | 117 | case VARVAR: 118 | if (sbr->bs_num_rel_0[ch]) 119 | { 120 | int8_t i = 1; 121 | border = sbr->abs_bord_lead[ch]; 122 | 123 | for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) 124 | { 125 | border += sbr->bs_rel_bord_0[ch][l]; 126 | 127 | if (border > trail) 128 | return 1; 129 | 130 | t_E_temp[i++] = sbr->rate * border; 131 | } 132 | } 133 | 134 | if (sbr->bs_num_rel_1[ch]) 135 | { 136 | int8_t i = sbr->L_E[ch]; 137 | border = sbr->abs_bord_trail[ch]; 138 | 139 | for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) 140 | { 141 | if (border < sbr->bs_rel_bord_1[ch][l]) 142 | return 1; 143 | 144 | border -= sbr->bs_rel_bord_1[ch][l]; 145 | t_E_temp[--i] = sbr->rate * border; 146 | } 147 | } 148 | break; 149 | } 150 | 151 | /* no error occured, we can safely use this t_E vector */ 152 | for (l = 0; l < 6; l++) 153 | { 154 | sbr->t_E[ch][l] = t_E_temp[l]; 155 | } 156 | 157 | return 0; 158 | } 159 | 160 | void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) 161 | { 162 | sbr->t_Q[ch][0] = sbr->t_E[ch][0]; 163 | 164 | if (sbr->L_E[ch] == 1) 165 | { 166 | sbr->t_Q[ch][1] = sbr->t_E[ch][1]; 167 | sbr->t_Q[ch][2] = 0; 168 | } else { 169 | uint8_t index = middleBorder(sbr, ch); 170 | sbr->t_Q[ch][1] = sbr->t_E[ch][index]; 171 | sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; 172 | } 173 | } 174 | 175 | #if 0 176 | static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) 177 | { 178 | uint8_t i; 179 | int16_t acc = 0; 180 | 181 | switch (sbr->bs_frame_class[ch]) 182 | { 183 | case FIXFIX: 184 | return sbr->numTimeSlots/sbr->L_E[ch]; 185 | case FIXVAR: 186 | return 0; 187 | case VARFIX: 188 | for (i = 0; i < l; i++) 189 | { 190 | acc += sbr->bs_rel_bord[ch][i]; 191 | } 192 | return acc; 193 | case VARVAR: 194 | for (i = 0; i < l; i++) 195 | { 196 | acc += sbr->bs_rel_bord_0[ch][i]; 197 | } 198 | return acc; 199 | } 200 | 201 | return 0; 202 | } 203 | 204 | static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) 205 | { 206 | uint8_t i; 207 | int16_t acc = 0; 208 | 209 | switch (sbr->bs_frame_class[ch]) 210 | { 211 | case FIXFIX: 212 | case VARFIX: 213 | return 0; 214 | case FIXVAR: 215 | for (i = 0; i < l; i++) 216 | { 217 | acc += sbr->bs_rel_bord[ch][i]; 218 | } 219 | return acc; 220 | case VARVAR: 221 | for (i = 0; i < l; i++) 222 | { 223 | acc += sbr->bs_rel_bord_1[ch][i]; 224 | } 225 | return acc; 226 | } 227 | 228 | return 0; 229 | } 230 | #endif 231 | 232 | static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) 233 | { 234 | int8_t retval = 0; 235 | 236 | switch (sbr->bs_frame_class[ch]) 237 | { 238 | case FIXFIX: 239 | retval = sbr->L_E[ch]/2; 240 | break; 241 | case VARFIX: 242 | if (sbr->bs_pointer[ch] == 0) 243 | retval = 1; 244 | else if (sbr->bs_pointer[ch] == 1) 245 | retval = sbr->L_E[ch] - 1; 246 | else 247 | retval = sbr->bs_pointer[ch] - 1; 248 | break; 249 | case FIXVAR: 250 | case VARVAR: 251 | if (sbr->bs_pointer[ch] > 1) 252 | retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; 253 | else 254 | retval = sbr->L_E[ch] - 1; 255 | break; 256 | } 257 | 258 | return (retval > 0) ? retval : 0; 259 | } 260 | 261 | 262 | #endif 263 | -------------------------------------------------------------------------------- /libfaad/sbr_tf_grid.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_tf_grid.h,v 1.17 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_TF_GRID_H__ 32 | #define __SBR_TF_GRID_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch); 40 | void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /libfaad/specrec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: specrec.h,v 1.33 2009/01/26 23:51:15 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SPECREC_H__ 32 | #define __SPECREC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | uint8_t window_grouping_info(NeAACDecStruct *hDecoder, ic_stream *ics); 41 | uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_stream *ics2, 42 | element *cpe, int16_t *spec_data1, int16_t *spec_data2); 43 | uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics, element *sce, 44 | int16_t *spec_data); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /libfaad/ssr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr.c,v 1.19 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #ifdef SSR_DEC 35 | 36 | #include "syntax.h" 37 | #include "filtbank.h" 38 | #include "ssr.h" 39 | #include "ssr_fb.h" 40 | 41 | void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, 42 | uint8_t window_shape, uint8_t window_shape_prev, 43 | real_t *freq_in, real_t *time_out, real_t *overlap, 44 | real_t ipqf_buffer[SSR_BANDS][96/4], 45 | real_t *prev_fmd, uint16_t frame_len) 46 | { 47 | uint8_t band; 48 | uint16_t ssr_frame_len = frame_len/SSR_BANDS; 49 | real_t time_tmp[2048] = {0}; 50 | real_t output[1024] = {0}; 51 | 52 | for (band = 0; band < SSR_BANDS; band++) 53 | { 54 | int16_t j; 55 | 56 | /* uneven bands have inverted frequency scale */ 57 | if (band == 1 || band == 3) 58 | { 59 | for (j = 0; j < ssr_frame_len/2; j++) 60 | { 61 | real_t tmp; 62 | tmp = freq_in[j + ssr_frame_len*band]; 63 | freq_in[j + ssr_frame_len*band] = 64 | freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band]; 65 | freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band] = tmp; 66 | } 67 | } 68 | 69 | /* non-overlapping inverse filterbank for SSR */ 70 | ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev, 71 | freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len, 72 | ssr_frame_len); 73 | 74 | /* gain control */ 75 | ssr_gain_control(ssr, time_tmp, output, overlap, prev_fmd, 76 | band, window_sequence, ssr_frame_len); 77 | } 78 | 79 | /* inverse pqf to bring subbands together again */ 80 | ssr_ipqf(ssr, output, time_out, ipqf_buffer, frame_len, SSR_BANDS); 81 | } 82 | 83 | static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, 84 | real_t *overlap, real_t *prev_fmd, uint8_t band, 85 | uint8_t window_sequence, uint16_t frame_len) 86 | { 87 | uint16_t i; 88 | real_t gc_function[2*1024/SSR_BANDS]; 89 | 90 | if (window_sequence != EIGHT_SHORT_SEQUENCE) 91 | { 92 | ssr_gc_function(ssr, &prev_fmd[band * frame_len*2], 93 | gc_function, window_sequence, band, frame_len); 94 | 95 | for (i = 0; i < frame_len*2; i++) 96 | data[band * frame_len*2 + i] *= gc_function[i]; 97 | for (i = 0; i < frame_len; i++) 98 | { 99 | output[band*frame_len + i] = overlap[band*frame_len + i] + 100 | data[band*frame_len*2 + i]; 101 | } 102 | for (i = 0; i < frame_len; i++) 103 | { 104 | overlap[band*frame_len + i] = 105 | data[band*frame_len*2 + frame_len + i]; 106 | } 107 | } else { 108 | uint8_t w; 109 | for (w = 0; w < 8; w++) 110 | { 111 | uint16_t frame_len8 = frame_len/8; 112 | uint16_t frame_len16 = frame_len/16; 113 | 114 | ssr_gc_function(ssr, &prev_fmd[band*frame_len*2 + w*frame_len*2/8], 115 | gc_function, window_sequence, frame_len); 116 | 117 | for (i = 0; i < frame_len8*2; i++) 118 | data[band*frame_len*2 + w*frame_len8*2+i] *= gc_function[i]; 119 | for (i = 0; i < frame_len8; i++) 120 | { 121 | overlap[band*frame_len + i + 7*frame_len16 + w*frame_len8] += 122 | data[band*frame_len*2 + 2*w*frame_len8 + i]; 123 | } 124 | for (i = 0; i < frame_len8; i++) 125 | { 126 | overlap[band*frame_len + i + 7*frame_len16 + (w+1)*frame_len8] = 127 | data[band*frame_len*2 + 2*w*frame_len8 + frame_len8 + i]; 128 | } 129 | } 130 | for (i = 0; i < frame_len; i++) 131 | output[band*frame_len + i] = overlap[band*frame_len + i]; 132 | for (i = 0; i < frame_len; i++) 133 | overlap[band*frame_len + i] = overlap[band*frame_len + i + frame_len]; 134 | } 135 | } 136 | 137 | static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, 138 | real_t *gc_function, uint8_t window_sequence, 139 | uint8_t band, uint16_t frame_len) 140 | { 141 | uint16_t i; 142 | uint16_t len_area1, len_area2; 143 | int32_t aloc[10]; 144 | real_t alev[10]; 145 | 146 | switch (window_sequence) 147 | { 148 | case ONLY_LONG_SEQUENCE: 149 | len_area1 = frame_len/SSR_BANDS; 150 | len_area2 = 0; 151 | break; 152 | case LONG_START_SEQUENCE: 153 | len_area1 = (frame_len/SSR_BANDS)*7/32; 154 | len_area2 = (frame_len/SSR_BANDS)/16; 155 | break; 156 | case EIGHT_SHORT_SEQUENCE: 157 | len_area1 = (frame_len/8)/SSR_BANDS; 158 | len_area2 = 0; 159 | break; 160 | case LONG_STOP_SEQUENCE: 161 | len_area1 = (frame_len/SSR_BANDS); 162 | len_area2 = 0; 163 | break; 164 | } 165 | 166 | /* decode bitstream information */ 167 | 168 | /* build array M */ 169 | 170 | 171 | for (i = 0; i < frame_len*2; i++) 172 | gc_function[i] = 1; 173 | } 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /libfaad/ssr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr.h,v 1.19 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_H__ 32 | #define __SSR_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define SSR_BANDS 4 39 | #define PQFTAPS 96 40 | 41 | void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, 42 | uint8_t window_shape, uint8_t window_shape_prev, 43 | real_t *freq_in, real_t *time_out, real_t *overlap, 44 | real_t ipqf_buffer[SSR_BANDS][96/4], 45 | real_t *prev_fmd, uint16_t frame_len); 46 | 47 | 48 | static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, 49 | real_t *overlap, real_t *prev_fmd, uint8_t band, 50 | uint8_t window_sequence, uint16_t frame_len); 51 | static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, 52 | real_t *gc_function, uint8_t window_sequence, 53 | uint16_t frame_len); 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif 60 | -------------------------------------------------------------------------------- /libfaad/ssr_fb.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_fb.c,v 1.17 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #ifdef SSR_DEC 35 | 36 | #include 37 | #include "syntax.h" 38 | #include "filtbank.h" 39 | #include "mdct.h" 40 | #include "ssr_fb.h" 41 | #include "ssr_win.h" 42 | 43 | fb_info *ssr_filter_bank_init(uint16_t frame_len) 44 | { 45 | uint16_t nshort = frame_len/8; 46 | 47 | fb_info *fb = (fb_info*)faad_malloc(sizeof(fb_info)); 48 | memset(fb, 0, sizeof(fb_info)); 49 | 50 | /* normal */ 51 | fb->mdct256 = faad_mdct_init(2*nshort); 52 | fb->mdct2048 = faad_mdct_init(2*frame_len); 53 | 54 | fb->long_window[0] = sine_long_256; 55 | fb->short_window[0] = sine_short_32; 56 | fb->long_window[1] = kbd_long_256; 57 | fb->short_window[1] = kbd_short_32; 58 | 59 | return fb; 60 | } 61 | 62 | void ssr_filter_bank_end(fb_info *fb) 63 | { 64 | faad_mdct_end(fb->mdct256); 65 | faad_mdct_end(fb->mdct2048); 66 | 67 | if (fb) faad_free(fb); 68 | } 69 | 70 | static INLINE void imdct_ssr(fb_info *fb, real_t *in_data, 71 | real_t *out_data, uint16_t len) 72 | { 73 | mdct_info *mdct; 74 | 75 | switch (len) 76 | { 77 | case 512: 78 | mdct = fb->mdct2048; 79 | break; 80 | case 64: 81 | mdct = fb->mdct256; 82 | break; 83 | } 84 | 85 | faad_imdct(mdct, in_data, out_data); 86 | } 87 | 88 | /* NON-overlapping inverse filterbank for use with SSR */ 89 | void ssr_ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, 90 | uint8_t window_shape_prev, real_t *freq_in, 91 | real_t *time_out, uint16_t frame_len) 92 | { 93 | int16_t i; 94 | real_t *transf_buf; 95 | 96 | real_t *window_long; 97 | real_t *window_long_prev; 98 | real_t *window_short; 99 | real_t *window_short_prev; 100 | 101 | uint16_t nlong = frame_len; 102 | uint16_t nshort = frame_len/8; 103 | uint16_t trans = nshort/2; 104 | 105 | uint16_t nflat_ls = (nlong-nshort)/2; 106 | 107 | transf_buf = (real_t*)faad_malloc(2*nlong*sizeof(real_t)); 108 | 109 | window_long = fb->long_window[window_shape]; 110 | window_long_prev = fb->long_window[window_shape_prev]; 111 | window_short = fb->short_window[window_shape]; 112 | window_short_prev = fb->short_window[window_shape_prev]; 113 | 114 | switch (window_sequence) 115 | { 116 | case ONLY_LONG_SEQUENCE: 117 | imdct_ssr(fb, freq_in, transf_buf, 2*nlong); 118 | for (i = nlong-1; i >= 0; i--) 119 | { 120 | time_out[i] = MUL_R_C(transf_buf[i],window_long_prev[i]); 121 | time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]); 122 | } 123 | break; 124 | 125 | case LONG_START_SEQUENCE: 126 | imdct_ssr(fb, freq_in, transf_buf, 2*nlong); 127 | for (i = 0; i < nlong; i++) 128 | time_out[i] = MUL_R_C(transf_buf[i],window_long_prev[i]); 129 | for (i = 0; i < nflat_ls; i++) 130 | time_out[nlong+i] = transf_buf[nlong+i]; 131 | for (i = 0; i < nshort; i++) 132 | time_out[nlong+nflat_ls+i] = MUL_R_C(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); 133 | for (i = 0; i < nflat_ls; i++) 134 | time_out[nlong+nflat_ls+nshort+i] = 0; 135 | break; 136 | 137 | case EIGHT_SHORT_SEQUENCE: 138 | imdct_ssr(fb, freq_in+0*nshort, transf_buf+2*nshort*0, 2*nshort); 139 | imdct_ssr(fb, freq_in+1*nshort, transf_buf+2*nshort*1, 2*nshort); 140 | imdct_ssr(fb, freq_in+2*nshort, transf_buf+2*nshort*2, 2*nshort); 141 | imdct_ssr(fb, freq_in+3*nshort, transf_buf+2*nshort*3, 2*nshort); 142 | imdct_ssr(fb, freq_in+4*nshort, transf_buf+2*nshort*4, 2*nshort); 143 | imdct_ssr(fb, freq_in+5*nshort, transf_buf+2*nshort*5, 2*nshort); 144 | imdct_ssr(fb, freq_in+6*nshort, transf_buf+2*nshort*6, 2*nshort); 145 | imdct_ssr(fb, freq_in+7*nshort, transf_buf+2*nshort*7, 2*nshort); 146 | for(i = nshort-1; i >= 0; i--) 147 | { 148 | time_out[i+0*nshort] = MUL_R_C(transf_buf[nshort*0+i],window_short_prev[i]); 149 | time_out[i+1*nshort] = MUL_R_C(transf_buf[nshort*1+i],window_short[i]); 150 | time_out[i+2*nshort] = MUL_R_C(transf_buf[nshort*2+i],window_short_prev[i]); 151 | time_out[i+3*nshort] = MUL_R_C(transf_buf[nshort*3+i],window_short[i]); 152 | time_out[i+4*nshort] = MUL_R_C(transf_buf[nshort*4+i],window_short_prev[i]); 153 | time_out[i+5*nshort] = MUL_R_C(transf_buf[nshort*5+i],window_short[i]); 154 | time_out[i+6*nshort] = MUL_R_C(transf_buf[nshort*6+i],window_short_prev[i]); 155 | time_out[i+7*nshort] = MUL_R_C(transf_buf[nshort*7+i],window_short[i]); 156 | time_out[i+8*nshort] = MUL_R_C(transf_buf[nshort*8+i],window_short_prev[i]); 157 | time_out[i+9*nshort] = MUL_R_C(transf_buf[nshort*9+i],window_short[i]); 158 | time_out[i+10*nshort] = MUL_R_C(transf_buf[nshort*10+i],window_short_prev[i]); 159 | time_out[i+11*nshort] = MUL_R_C(transf_buf[nshort*11+i],window_short[i]); 160 | time_out[i+12*nshort] = MUL_R_C(transf_buf[nshort*12+i],window_short_prev[i]); 161 | time_out[i+13*nshort] = MUL_R_C(transf_buf[nshort*13+i],window_short[i]); 162 | time_out[i+14*nshort] = MUL_R_C(transf_buf[nshort*14+i],window_short_prev[i]); 163 | time_out[i+15*nshort] = MUL_R_C(transf_buf[nshort*15+i],window_short[i]); 164 | } 165 | break; 166 | 167 | case LONG_STOP_SEQUENCE: 168 | imdct_ssr(fb, freq_in, transf_buf, 2*nlong); 169 | for (i = 0; i < nflat_ls; i++) 170 | time_out[i] = 0; 171 | for (i = 0; i < nshort; i++) 172 | time_out[nflat_ls+i] = MUL_R_C(transf_buf[nflat_ls+i],window_short_prev[i]); 173 | for (i = 0; i < nflat_ls; i++) 174 | time_out[nflat_ls+nshort+i] = transf_buf[nflat_ls+nshort+i]; 175 | for (i = 0; i < nlong; i++) 176 | time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]); 177 | break; 178 | } 179 | 180 | faad_free(transf_buf); 181 | } 182 | 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /libfaad/ssr_fb.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_fb.h,v 1.16 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_FB_H__ 32 | #define __SSR_FB_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | fb_info *ssr_filter_bank_init(uint16_t frame_len); 39 | void ssr_filter_bank_end(fb_info *fb); 40 | 41 | /*non overlapping inverse filterbank */ 42 | void ssr_ifilter_bank(fb_info *fb, 43 | uint8_t window_sequence, 44 | uint8_t window_shape, 45 | uint8_t window_shape_prev, 46 | real_t *freq_in, 47 | real_t *time_out, 48 | uint16_t frame_len); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /libfaad/ssr_ipqf.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_ipqf.c,v 1.18 2007/11/01 12:33:39 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #ifdef SSR_DEC 35 | 36 | #include "ssr.h" 37 | #include "ssr_ipqf.h" 38 | 39 | static real_t **app_pqfbuf; 40 | static real_t **pp_q0, **pp_t0, **pp_t1; 41 | 42 | void gc_set_protopqf(real_t *p_proto) 43 | { 44 | int j; 45 | static real_t a_half[48] = 46 | { 47 | 1.2206911375946939E-05, 1.7261986723798209E-05, 1.2300093657077942E-05, 48 | -1.0833943097791965E-05, -5.7772498639901686E-05, -1.2764767618947719E-04, 49 | -2.0965186675013334E-04, -2.8166673689263850E-04, -3.1234860429017460E-04, 50 | -2.6738519958452353E-04, -1.1949424681824722E-04, 1.3965139412648678E-04, 51 | 4.8864136409185725E-04, 8.7044629275148344E-04, 1.1949430269934793E-03, 52 | 1.3519708175026700E-03, 1.2346314373964412E-03, 7.6953209114159191E-04, 53 | -5.2242432579537141E-05, -1.1516092887213454E-03, -2.3538469841711277E-03, 54 | -3.4033123072127277E-03, -4.0028551071986133E-03, -3.8745415659693259E-03, 55 | -2.8321073426874310E-03, -8.5038892323704195E-04, 1.8856751185350931E-03, 56 | 4.9688741735340923E-03, 7.8056704536795926E-03, 9.7027909685901654E-03, 57 | 9.9960423120166159E-03, 8.2019366335594487E-03, 4.1642072876103365E-03, 58 | -1.8364453822737758E-03, -9.0384863094167686E-03, -1.6241528177129844E-02, 59 | -2.1939551286300665E-02, -2.4533179947088161E-02, -2.2591663337768787E-02, 60 | -1.5122066420044672E-02, -1.7971713448186293E-03, 1.6903413428575379E-02, 61 | 3.9672315874127042E-02, 6.4487527248102796E-02, 8.8850025474701726E-02, 62 | 0.1101132906105560 , 0.1258540205143761 , 0.1342239368467012 63 | }; 64 | 65 | for (j = 0; j < 48; ++j) 66 | { 67 | p_proto[j] = p_proto[95-j] = a_half[j]; 68 | } 69 | } 70 | 71 | void gc_setcoef_eff_pqfsyn(int mm, 72 | int kk, 73 | real_t *p_proto, 74 | real_t ***ppp_q0, 75 | real_t ***ppp_t0, 76 | real_t ***ppp_t1) 77 | { 78 | int i, k, n; 79 | real_t w; 80 | 81 | /* Set 1st Mul&Acc Coef's */ 82 | *ppp_q0 = (real_t **) calloc(mm, sizeof(real_t *)); 83 | for (n = 0; n < mm; ++n) 84 | { 85 | (*ppp_q0)[n] = (real_t *) calloc(mm, sizeof(real_t)); 86 | } 87 | for (n = 0; n < mm/2; ++n) 88 | { 89 | for (i = 0; i < mm; ++i) 90 | { 91 | w = (2*i+1)*(2*n+1-mm)*M_PI/(4*mm); 92 | (*ppp_q0)[n][i] = 2.0 * cos((real_t) w); 93 | 94 | w = (2*i+1)*(2*(mm+n)+1-mm)*M_PI/(4*mm); 95 | (*ppp_q0)[n + mm/2][i] = 2.0 * cos((real_t) w); 96 | } 97 | } 98 | 99 | /* Set 2nd Mul&Acc Coef's */ 100 | *ppp_t0 = (real_t **) calloc(mm, sizeof(real_t *)); 101 | *ppp_t1 = (real_t **) calloc(mm, sizeof(real_t *)); 102 | for (n = 0; n < mm; ++n) 103 | { 104 | (*ppp_t0)[n] = (real_t *) calloc(kk, sizeof(real_t)); 105 | (*ppp_t1)[n] = (real_t *) calloc(kk, sizeof(real_t)); 106 | } 107 | for (n = 0; n < mm; ++n) 108 | { 109 | for (k = 0; k < kk; ++k) 110 | { 111 | (*ppp_t0)[n][k] = mm * p_proto[2*k *mm + n]; 112 | (*ppp_t1)[n][k] = mm * p_proto[(2*k+1)*mm + n]; 113 | 114 | if (k%2 != 0) 115 | { 116 | (*ppp_t0)[n][k] = -(*ppp_t0)[n][k]; 117 | (*ppp_t1)[n][k] = -(*ppp_t1)[n][k]; 118 | } 119 | } 120 | } 121 | } 122 | 123 | void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data, 124 | real_t buffer[SSR_BANDS][96/4], 125 | uint16_t frame_len, uint8_t bands) 126 | { 127 | static int initFlag = 0; 128 | real_t a_pqfproto[PQFTAPS]; 129 | 130 | int i; 131 | 132 | if (initFlag == 0) 133 | { 134 | gc_set_protopqf(a_pqfproto); 135 | gc_setcoef_eff_pqfsyn(SSR_BANDS, PQFTAPS/(2*SSR_BANDS), a_pqfproto, 136 | &pp_q0, &pp_t0, &pp_t1); 137 | initFlag = 1; 138 | } 139 | 140 | for (i = 0; i < frame_len / SSR_BANDS; i++) 141 | { 142 | int l, n, k; 143 | int mm = SSR_BANDS; 144 | int kk = PQFTAPS/(2*SSR_BANDS); 145 | 146 | for (n = 0; n < mm; n++) 147 | { 148 | for (k = 0; k < 2*kk-1; k++) 149 | { 150 | buffer[n][k] = buffer[n][k+1]; 151 | } 152 | } 153 | 154 | for (n = 0; n < mm; n++) 155 | { 156 | real_t acc = 0.0; 157 | for (l = 0; l < mm; l++) 158 | { 159 | acc += pp_q0[n][l] * in_data[l*frame_len/SSR_BANDS + i]; 160 | } 161 | buffer[n][2*kk-1] = acc; 162 | } 163 | 164 | for (n = 0; n < mm/2; n++) 165 | { 166 | real_t acc = 0.0; 167 | for (k = 0; k < kk; k++) 168 | { 169 | acc += pp_t0[n][k] * buffer[n][2*kk-1-2*k]; 170 | } 171 | for (k = 0; k < kk; ++k) 172 | { 173 | acc += pp_t1[n][k] * buffer[n + mm/2][2*kk-2-2*k]; 174 | } 175 | out_data[i*SSR_BANDS + n] = acc; 176 | 177 | acc = 0.0; 178 | for (k = 0; k < kk; k++) 179 | { 180 | acc += pp_t0[mm-1-n][k] * buffer[n][2*kk-1-2*k]; 181 | } 182 | for (k = 0; k < kk; k++) 183 | { 184 | acc -= pp_t1[mm-1-n][k] * buffer[n + mm/2][2*kk-2-2*k]; 185 | } 186 | out_data[i*SSR_BANDS + mm-1-n] = acc; 187 | } 188 | } 189 | } 190 | 191 | #endif 192 | -------------------------------------------------------------------------------- /libfaad/ssr_ipqf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_ipqf.h,v 1.17 2007/11/01 12:33:39 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_IPQF_H__ 32 | #define __SSR_IPQF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data, 39 | real_t buffer[SSR_BANDS][96/4], 40 | uint16_t frame_len, uint8_t bands); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /libfaad/syntax.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: syntax.h,v 1.60 2009/01/26 23:51:17 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SYNTAX_H__ 32 | #define __SYNTAX_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define MAIN 1 41 | #define LC 2 42 | #define SSR 3 43 | #define LTP 4 44 | #define HE_AAC 5 45 | #define LD 23 46 | #define ER_LC 17 47 | #define ER_LTP 19 48 | #define DRM_ER_LC 27 /* special object type for DRM */ 49 | 50 | /* header types */ 51 | #define RAW 0 52 | #define ADIF 1 53 | #define ADTS 2 54 | #define LATM 3 55 | 56 | /* SBR signalling */ 57 | #define NO_SBR 0 58 | #define SBR_UPSAMPLED 1 59 | #define SBR_DOWNSAMPLED 2 60 | #define NO_SBR_UPSAMPLED 3 61 | 62 | /* DRM channel definitions */ 63 | #define DRMCH_MONO 1 64 | #define DRMCH_STEREO 2 65 | #define DRMCH_SBR_MONO 3 66 | #define DRMCH_SBR_STEREO 4 67 | #define DRMCH_SBR_PS_STEREO 5 68 | 69 | 70 | /* First object type that has ER */ 71 | #define ER_OBJECT_START 17 72 | 73 | 74 | /* Bitstream */ 75 | #define LEN_SE_ID 3 76 | #define LEN_TAG 4 77 | #define LEN_BYTE 8 78 | 79 | #define EXT_FIL 0 80 | #define EXT_FILL_DATA 1 81 | #define EXT_DATA_ELEMENT 2 82 | #define EXT_DYNAMIC_RANGE 11 83 | #define ANC_DATA 0 84 | 85 | /* Syntax elements */ 86 | #define ID_SCE 0x0 87 | #define ID_CPE 0x1 88 | #define ID_CCE 0x2 89 | #define ID_LFE 0x3 90 | #define ID_DSE 0x4 91 | #define ID_PCE 0x5 92 | #define ID_FIL 0x6 93 | #define ID_END 0x7 94 | #define INVALID_ELEMENT_ID 255 95 | 96 | #define ONLY_LONG_SEQUENCE 0x0 97 | #define LONG_START_SEQUENCE 0x1 98 | #define EIGHT_SHORT_SEQUENCE 0x2 99 | #define LONG_STOP_SEQUENCE 0x3 100 | 101 | #define ZERO_HCB 0 102 | #define FIRST_PAIR_HCB 5 103 | #define ESC_HCB 11 104 | #define QUAD_LEN 4 105 | #define PAIR_LEN 2 106 | #define NOISE_HCB 13 107 | #define INTENSITY_HCB2 14 108 | #define INTENSITY_HCB 15 109 | 110 | #define INVALID_SBR_ELEMENT 255 111 | 112 | int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, 113 | program_config *pce); 114 | 115 | uint8_t adts_frame(adts_header *adts, bitfile *ld); 116 | void get_adif_header(adif_header *adif, bitfile *ld); 117 | void raw_data_block(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, 118 | bitfile *ld, program_config *pce, drc_info *drc); 119 | uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld, 120 | int16_t *spectral_data); 121 | #ifdef DRM 122 | void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, 123 | bitfile *ld, program_config *pce, drc_info *drc); 124 | #endif 125 | #if 0 126 | uint32_t faad_latm_frame(latm_header *latm, bitfile *ld); 127 | #endif 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #endif 133 | -------------------------------------------------------------------------------- /libfaad/tns.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: tns.h,v 1.23 2007/11/01 12:33:41 menno Exp $ 29 | **/ 30 | 31 | #ifndef __TNS_H__ 32 | #define __TNS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | #define TNS_MAX_ORDER 20 40 | 41 | 42 | void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, 43 | uint8_t object_type, real_t *spec, uint16_t frame_len); 44 | void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, 45 | uint8_t object_type, real_t *spec, uint16_t frame_len); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /libfaad2.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | ; 3 | ; libfaad2 exports 4 | ; 5 | NeAACDecOpen @1 6 | NeAACDecGetCurrentConfiguration @2 7 | NeAACDecSetConfiguration @3 8 | NeAACDecInit @4 9 | NeAACDecInit2 @5 10 | NeAACDecDecode @6 11 | NeAACDecClose @7 12 | NeAACDecGetErrorMessage @8 13 | NeAACDecAudioSpecificConfig @9 14 | NeAACDecPostSeekReset @10 15 | NeAACDecDecode2 @11 16 | -------------------------------------------------------------------------------- /properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "This file contains properties used in build / release process", 3 | "PACKAGE_VERSION": "2.11.2" 4 | } 5 | -------------------------------------------------------------------------------- /workspace.bzl: -------------------------------------------------------------------------------- 1 | def _wrap_json_properties_impl(ctx): 2 | content = ctx.read(ctx.attr.src) 3 | bzl = "PROPERTIES = %s" % (content) 4 | ctx.file("BUILD", content = "", executable = False) 5 | ctx.file("properties.bzl", content = bzl, executable = False) 6 | 7 | wrap_json_properties = repository_rule( 8 | attrs = { 9 | "src": attr.label(mandatory = True), 10 | }, 11 | implementation = _wrap_json_properties_impl, 12 | ) 13 | --------------------------------------------------------------------------------