parent
44fdf69674
commit
abdc00fd2d
@ -0,0 +1,18 @@ |
||||
# Force the use of Clang for C++ builds. |
||||
build --action_env=CC=clang |
||||
build --action_env=CXX=clang++ |
||||
|
||||
# Define the --config=asan-libfuzzer configuration. |
||||
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer |
||||
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer |
||||
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan |
||||
|
||||
# Define the --config=msan-libfuzzer configuration. |
||||
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer |
||||
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer |
||||
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan |
||||
|
||||
# Define the --config=ubsan-libfuzzer configuration. |
||||
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer |
||||
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer |
||||
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan |
@ -0,0 +1,142 @@ |
||||
# FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
# Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
# |
||||
# Any non-GPL usage of this software or parts of this software is strictly |
||||
# forbidden. |
||||
# |
||||
# The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
# must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
# |
||||
# Commercial non-GPL licensing of this software is possible. |
||||
# For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
|
||||
name: Build |
||||
on: |
||||
push: |
||||
branches: [master] |
||||
pull_request: |
||||
types: [opened, reopened, labeled, synchronize] |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} |
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
||||
|
||||
jobs: |
||||
BuildWithBazel: |
||||
runs-on: ubuntu-latest |
||||
|
||||
strategy: |
||||
fail-fast: false |
||||
|
||||
steps: |
||||
- name: Checkout the source |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
submodules: false |
||||
fetch-depth: 1 |
||||
- name: Configure and build |
||||
run: | |
||||
bazel build :all |
||||
|
||||
BuildWithCMake: |
||||
runs-on: ${{ matrix.os || 'ubuntu-latest' }} |
||||
|
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
include: |
||||
- name: Clang Shared |
||||
cc: clang |
||||
cxx: clang++ |
||||
cflags: -Wall -fcolor-diagnostics -fansi-escape-codes |
||||
shared: 'true' |
||||
- name: Clang Static |
||||
cc: clang |
||||
cxx: clang++ |
||||
cflags: -Wall -fcolor-diagnostics -fansi-escape-codes -O2 -Werror=strict-aliasing |
||||
- name: GCC Static |
||||
cc: gcc |
||||
cxx: g++ |
||||
cflags: -Wall -fdiagnostics-color=always -O2 -Werror=strict-aliasing |
||||
- name: MSVC |
||||
os: windows-latest |
||||
cmake_args: >- |
||||
-G "Visual Studio 17 2022" -A x64 |
||||
- name: OSX |
||||
os: macos-latest |
||||
|
||||
env: |
||||
CC: ${{ matrix.cc || 'cc' }} |
||||
CXX: ${{ matrix.cxx || 'cxx' }} |
||||
CFLAGS: ${{ matrix.cflags || '-Wall' }} |
||||
CXXFLAGS: ${{ matrix.cflags || '-Wall' }} |
||||
SHARED: ${{ matrix.shared || 'false' }} |
||||
|
||||
steps: |
||||
- name: Checkout the source |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
submodules: false |
||||
fetch-depth: 1 |
||||
- name: Configure and build |
||||
shell: bash |
||||
run: | |
||||
export NUM_CORES=`nproc || getconf _NPROCESSORS_ONLN` |
||||
cmake -B build . \ |
||||
-DCMAKE_INSTALL_PREFIX=$RUNNER_TEMP/usrlocal \ |
||||
-DBUILD_SHARED_LIBS=${SHARED} \ |
||||
${{ matrix.cmake_args }} |
||||
cmake --build build -j ${NUM_CORES} |
||||
cmake --install build |
||||
|
||||
BuildOnMsys: |
||||
name: BuildOnMsys (${{ matrix.msystem }}) |
||||
runs-on: windows-latest |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
include: |
||||
- msystem: mingw64 |
||||
- msystem: clang64 |
||||
- msystem: ucrt64 |
||||
- msystem: mingw32 |
||||
- msystem: clang32 |
||||
defaults: |
||||
run: |
||||
shell: msys2 {0} |
||||
steps: |
||||
- name: Checkout the source |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
submodules: false |
||||
fetch-depth: 1 |
||||
- uses: msys2/setup-msys2@v2 |
||||
with: |
||||
msystem: ${{ matrix.msystem }} |
||||
update: true |
||||
path-type: inherit |
||||
install: >- |
||||
base-devel |
||||
pacboy: >- |
||||
cmake:p |
||||
- name: Configure and build |
||||
run: | |
||||
cmake -B build . \ |
||||
-DCMAKE_INSTALL_PREFIX=$RUNNER_TEMP/usrlocal \ |
||||
-DBUILD_SHARED_LIBS=${SHARED} |
||||
cmake --build build -j `nproc` |
||||
cmake --install build |
@ -0,0 +1,65 @@ |
||||
# FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
# Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
# |
||||
# Any non-GPL usage of this software or parts of this software is strictly |
||||
# forbidden. |
||||
# |
||||
# The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
# must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
# |
||||
# Commercial non-GPL licensing of this software is possible. |
||||
# For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
|
||||
name: OSS-Fuzz |
||||
on: |
||||
push: |
||||
branches: [master] |
||||
pull_request: |
||||
types: [opened, reopened, labeled, synchronize] |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} |
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
||||
|
||||
jobs: |
||||
Fuzzing: |
||||
runs-on: ubuntu-latest |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
sanitizer: [address, undefined, memory] |
||||
steps: |
||||
- name: Build Fuzzers (${{ matrix.sanitizer }}) |
||||
id: build |
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master |
||||
with: |
||||
oss-fuzz-project-name: 'faad2' |
||||
language: c |
||||
sanitizer: ${{ matrix.sanitizer }} |
||||
- name: Run Fuzzers (${{ matrix.sanitizer }}) |
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master |
||||
with: |
||||
oss-fuzz-project-name: 'faad' |
||||
language: c |
||||
sanitizer: ${{ matrix.sanitizer }} |
||||
fuzz-seconds: 600 |
||||
- name: Upload Crash |
||||
uses: actions/upload-artifact@v3 |
||||
if: failure() && steps.build.outcome == 'success' |
||||
with: |
||||
name: ${{ matrix.sanitizer }}-artifacts |
||||
path: ./out/artifacts |
@ -0,0 +1 @@ |
||||
bazel-* |
@ -0,0 +1,17 @@ |
||||
|
||||
M. Bakker (mbakker(at)nero.com) |
||||
- complete library |
||||
|
||||
Alexander Kurpiers (a.kurpiers(at)nt.tu-darmstadt.de) |
||||
- HCR code |
||||
- DRM stuff |
||||
- lot's of bug fixes |
||||
|
||||
Volker Fischer (v.fischer(at)nt.tu-darmstadt.de) |
||||
- DRM code |
||||
- lot's of bug fixes |
||||
|
||||
Gian-Carlo Pascutto (gpascutto(at)nero.com) |
||||
- DRM PS code |
||||
- bugfixes |
||||
|
@ -0,0 +1,80 @@ |
||||
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") |
||||
load("@properties//:properties.bzl", "PROPERTIES") |
||||
|
||||
# Unless building for embedded systems all headers / functions should exist. |
||||
FAAD_DEFINES = [ |
||||
"APPLY_DRC", |
||||
"HAVE_INTTYPES_H=1", |
||||
"HAVE_MEMCPY=1", |
||||
"HAVE_STRING_H=1", |
||||
"HAVE_STRINGS_H=1", |
||||
"HAVE_SYS_STAT_H=1", |
||||
"HAVE_SYS_TYPES_H=1", |
||||
"STDC_HEADERS=1", |
||||
"PACKAGE_VERSION=\\\"%s\\\"" % PROPERTIES["PACKAGE_VERSION"], |
||||
] |
||||
|
||||
FAAD_SOURCES = glob([ |
||||
"libfaad/**/*.c", |
||||
"libfaad/**/*.h", |
||||
]) |
||||
|
||||
FAAD_FLAGS = [ |
||||
"-Wall", |
||||
"-pedantic", |
||||
] |
||||
|
||||
DRM_AFFIX = [ |
||||
"", |
||||
"_drm", |
||||
] |
||||
|
||||
DRM_DEFINES = [ |
||||
[], |
||||
["DRM_SUPPORT"], |
||||
] |
||||
|
||||
FIXED_AFFIX = [ |
||||
"", |
||||
"_fixed", |
||||
] |
||||
|
||||
FIXED_DEFINES = [ |
||||
[], |
||||
["FIXED_POINT"], |
||||
] |
||||
|
||||
[cc_library( |
||||
name = "faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], |
||||
srcs = FAAD_SOURCES, |
||||
hdrs = ["include/neaacdec.h"], |
||||
copts = FAAD_FLAGS, |
||||
includes = ["libfaad"], |
||||
local_defines = FAAD_DEFINES + DRM_DEFINES[drm] + FIXED_DEFINES[fixed], |
||||
strip_include_prefix = "include", |
||||
) for drm in range(2) for fixed in range(2)] |
||||
|
||||
# To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_config_run |
||||
cc_fuzz_test( |
||||
name = "fuzz_config", |
||||
srcs = ["fuzz/fuzz_config.c"], |
||||
deps = [":faad"], |
||||
) |
||||
|
||||
# To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_decode_run |
||||
[cc_fuzz_test( |
||||
name = "fuzz_decode" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], |
||||
srcs = ["fuzz/fuzz_decode.c"], |
||||
local_defines = DRM_DEFINES[drm], |
||||
deps = [":faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed]], |
||||
) for drm in range(2) for fixed in range(2)] |
||||
|
||||
CLI_SOURCES = glob(["frontend/**/*.c", "frontend/**/*.h"], exclude = ["frontend/**/getopt.*"]) |
||||
|
||||
[cc_binary( |
||||
name = "faad_cli" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed], |
||||
srcs = CLI_SOURCES, |
||||
includes = ["frontend"], |
||||
local_defines = FAAD_DEFINES + DRM_DEFINES[drm] + FIXED_DEFINES[fixed], |
||||
deps = [":faad" + DRM_AFFIX[drm] + FIXED_AFFIX[fixed]], |
||||
) for drm in range(2) for fixed in range(2)] |
@ -0,0 +1,272 @@ |
||||
# Available CMake versions: |
||||
# - Ubuntu 20.04 LTS : 3.16.3 |
||||
# - Solaris 11.4 SRU 15 : 3.15 |
||||
cmake_minimum_required(VERSION 3.15) |
||||
|
||||
include(CheckLibraryExists) |
||||
include(CheckSymbolExists) |
||||
|
||||
project(LIBFAAD2 LANGUAGES C) |
||||
|
||||
# Set a default build type if none was specified |
||||
set(default_build_type "RelWithDebInfo") |
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.") |
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE |
||||
STRING "Choose the type of build." FORCE) |
||||
# Set the possible values of build type for cmake-gui |
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS |
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo") |
||||
endif() |
||||
|
||||
# If FAAD is being bundled in another project, we don't want to |
||||
# install anything. However, we want to let people override this, so |
||||
# we'll use the FAAD_BUNDLED_MODE variable to let them do that; just |
||||
# set it to OFF in your project before you add_subdirectory(faad2). |
||||
get_directory_property(FAAD_PARENT_DIRECTORY PARENT_DIRECTORY) |
||||
if(NOT DEFINED FAAD_BUNDLED_MODE) |
||||
# Bundled mode hasn't been set one way or the other, set the default |
||||
# depending on whether or not we are the top-level project. |
||||
if(FAAD_PARENT_DIRECTORY) |
||||
set(FAAD_BUNDLED_MODE ON) |
||||
if(NOT DEFINED BUILD_SHARED_LIBS) |
||||
set(BUILD_SHARED_LIBS OFF) |
||||
endif() |
||||
else() |
||||
set(FAAD_BUNDLED_MODE OFF) |
||||
if(NOT DEFINED BUILD_SHARED_LIBS) |
||||
set(BUILD_SHARED_LIBS ON) |
||||
endif() |
||||
endif() |
||||
endif() |
||||
mark_as_advanced(FAAD_BUNDLED_MODE) |
||||
|
||||
if(BUILD_SHARED_LIBS) |
||||
if(NOT DEFINED CMAKE_C_VISIBILITY_PRESET) |
||||
set(CMAKE_C_VISIBILITY_PRESET hidden) |
||||
endif() |
||||
if (WIN32 AND NOT DEFINED CMAKE_DLL_NAME_WITH_SOVERSION) |
||||
set(CMAKE_DLL_NAME_WITH_SOVERSION ON) |
||||
endif() |
||||
endif() |
||||
|
||||
find_library(MATH_LIBRARY m) |
||||
|
||||
include(GNUInstallDirs) |
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
||||
set(CMAKE_MACOS_RPATH TRUE) |
||||
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") |
||||
endif() |
||||
|
||||
# Extract version information |
||||
|
||||
set(CAPTURE_PACKAGE_VERSION "[ \\t]*\"PACKAGE_VERSION\"[ \\t]*:[ \\t]\"(.*)\"") |
||||
file(STRINGS "properties.json" _faad_version_line REGEX "${CAPTURE_PACKAGE_VERSION}") |
||||
string(REGEX REPLACE "${CAPTURE_PACKAGE_VERSION}" "\\1" FAAD_VERSION "${_faad_version_line}") |
||||
string(REPLACE "\." ";" FAAD_VERSION_PARTS ${FAAD_VERSION}) |
||||
list(GET FAAD_VERSION_PARTS 0 FAAD_VERSION_MAJOR) |
||||
list(GET FAAD_VERSION_PARTS 1 FAAD_VERSION_MINOR) |
||||
list(GET FAAD_VERSION_PARTS 2 FAAD_VERSION_PATCH) |
||||
# Semantic -> library version |
||||
# NB(eustas): likely that will be always OK; if not, we could read "overrides" from properties.json |
||||
math(EXPR FAAD_ABI_VERSION_CURRENT "${FAAD_VERSION_MAJOR} + ${FAAD_VERSION_MINOR}") |
||||
set(FAAD_ABI_VERSION_AGE "${FAAD_VERSION_MINOR}") |
||||
set(FAAD_ABI_VERSION_REVISION "${FAAD_VERSION_PATCH}") |
||||
set(FAAD_ABI_COMPATIBILITY "${FAAD_VERSION_MAJOR}") |
||||
|
||||
message(STATUS "FAAD PACKAGE_VERSION: ${FAAD_VERSION}") |
||||
mark_as_advanced(FAAD_VERSION FAAD_ABI_COMPATIBILITY FAAD_ABI_VERSION_AGE FAAD_ABI_VERSION_REVISION) |
||||
|
||||
file(READ include/faad.h.in FAAD_H_SRC) |
||||
string(REGEX REPLACE "@VERSION@" "${FAAD_VERSION}" FAAD_H_SRC ${FAAD_H_SRC}) |
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/include/faad.h ${FAAD_H_SRC}) |
||||
|
||||
# Read sources list |
||||
|
||||
file(GLOB_RECURSE LIBFAAD_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} libfaad/*.c libfaad/*.h) |
||||
mark_as_advanced(LIBFAAD_SOURCES) |
||||
|
||||
file(GLOB_RECURSE FAAD_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} frontend/*.c frontend/*.h) |
||||
if (NOT MSVC) |
||||
list(FILTER FAAD_SOURCES EXCLUDE REGEX ".*getopt\\.[ch]$") |
||||
endif() |
||||
|
||||
# Build |
||||
|
||||
# Lets stick to predefined config, until more flexibility is actually requested. |
||||
set(FAAD_DEFINES |
||||
APPLY_DRC |
||||
HAVE_INTTYPES_H=1 |
||||
HAVE_MEMCPY=1 |
||||
HAVE_STRING_H=1 |
||||
HAVE_STRINGS_H=1 |
||||
HAVE_SYS_STAT_H=1 |
||||
HAVE_SYS_TYPES_H=1 |
||||
STDC_HEADERS=1 |
||||
PACKAGE_VERSION=\"${FAAD_VERSION}\" |
||||
) |
||||
|
||||
check_library_exists(m lrintf "" HAVE_LIBM) |
||||
if(HAVE_LIBM) |
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES m) |
||||
endif() |
||||
|
||||
check_symbol_exists(lrintf "math.h" HAVE_LRINTF) |
||||
if(HAVE_LRINTF) |
||||
list(APPEND FAAD_DEFINES |
||||
HAVE_LRINTF=1 |
||||
) |
||||
endif() |
||||
|
||||
set(FAAD_FLAGS |
||||
-Wall |
||||
) |
||||
if(MSVC) |
||||
list(APPEND FAAD_FLAGS |
||||
/wd4702 # unreachable code; there is a false-positive report |
||||
/wd4820 # implicit padding in structs |
||||
/wd5045 # Spectre nonsense |
||||
) |
||||
else() |
||||
list(APPEND FAAD_FLAGS |
||||
-pedantic |
||||
) |
||||
endif() |
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU") |
||||
list(APPEND FAAD_FLAGS -ffloat-store) |
||||
endif() # GCC |
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/include/neaacdec.h |
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include) |
||||
|
||||
foreach(LIB faad faad_drm faad_fixed faad_drm_fixed) |
||||
add_library(${LIB} ${LIBFAAD_SOURCES}) |
||||
if(MATH_LIBRARY) |
||||
target_link_libraries(${LIB} PUBLIC ${MATH_LIBRARY}) |
||||
endif() |
||||
target_include_directories(${LIB} PUBLIC |
||||
${CMAKE_CURRENT_BINARY_DIR}/include |
||||
) |
||||
target_include_directories(${LIB} PRIVATE |
||||
libfaad |
||||
) |
||||
target_compile_definitions(${LIB} PRIVATE |
||||
${FAAD_DEFINES} |
||||
) |
||||
target_compile_options(${LIB} PRIVATE |
||||
${FAAD_FLAGS} |
||||
) |
||||
endforeach() |
||||
|
||||
foreach(LIB faad_drm faad_drm_fixed) |
||||
target_compile_definitions(${LIB} PRIVATE |
||||
DRM_SUPPORT |
||||
) |
||||
endforeach() |
||||
|
||||
foreach(LIB faad_fixed faad_drm_fixed) |
||||
target_compile_definitions(${LIB} PRIVATE |
||||
FIXED_POINT |
||||
) |
||||
endforeach() |
||||
|
||||
# Generate a pkg-config files |
||||
|
||||
function(generate_pkg_config_path outvar path) |
||||
string(LENGTH "${path}" path_length) |
||||
|
||||
set(path_args ${ARGV}) |
||||
list(REMOVE_AT path_args 0 1) |
||||
list(LENGTH path_args path_args_remaining) |
||||
|
||||
set("${outvar}" "${path}") |
||||
|
||||
while(path_args_remaining GREATER 1) |
||||
list(GET path_args 0 name) |
||||
list(GET path_args 1 value) |
||||
|
||||
get_filename_component(value_full "${value}" ABSOLUTE) |
||||
string(LENGTH "${value}" value_length) |
||||
|
||||
if(path_length EQUAL value_length AND path STREQUAL value) |
||||
set("${outvar}" "\${${name}}") |
||||
break() |
||||
elseif(path_length GREATER value_length) |
||||
# We might be in a subdirectory of the value, but we have to be |
||||
# careful about a prefix matching but not being a subdirectory |
||||
# (for example, /usr/lib64 is not a subdirectory of /usr/lib). |
||||
# We'll do this by making sure the next character is a directory |
||||
# separator. |
||||
string(SUBSTRING "${path}" ${value_length} 1 sep) |
||||
if(sep STREQUAL "/") |
||||
string(SUBSTRING "${path}" 0 ${value_length} s) |
||||
if(s STREQUAL value) |
||||
string(SUBSTRING "${path}" "${value_length}" -1 suffix) |
||||
set("${outvar}" "\${${name}}${suffix}") |
||||
break() |
||||
endif() |
||||
endif() |
||||
endif() |
||||
|
||||
list(REMOVE_AT path_args 0 1) |
||||
list(LENGTH path_args path_args_remaining) |
||||
endwhile() |
||||
|
||||
set("${outvar}" "${${outvar}}" PARENT_SCOPE) |
||||
endfunction(generate_pkg_config_path) |
||||
|
||||
function(transform_pc_file INPUT_FILE OUTPUT_FILE VERSION) |
||||
file(READ ${INPUT_FILE} TEXT) |
||||
|
||||
set(PREFIX "${CMAKE_INSTALL_PREFIX}") |
||||
string(REGEX REPLACE "@prefix@" "${PREFIX}" TEXT ${TEXT}) |
||||
string(REGEX REPLACE "@exec_prefix@" "\${prefix}" TEXT ${TEXT}) |
||||
|
||||
generate_pkg_config_path(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" exec_prefix "${PREFIX}") |
||||
string(REGEX REPLACE "@libdir@" "${LIBDIR}" TEXT ${TEXT}) |
||||
|
||||
generate_pkg_config_path(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" prefix "${PREFIX}") |
||||
string(REGEX REPLACE "@includedir@" "${INCLUDEDIR}" TEXT ${TEXT}) |
||||
|
||||
string(REGEX REPLACE "@VERSION@" "${VERSION}" TEXT ${TEXT}) |
||||
|
||||
file(WRITE ${OUTPUT_FILE} ${TEXT}) |
||||
endfunction() |
||||
|
||||
transform_pc_file("libfaad/faad2.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/faad2.pc" "${FAAD_VERSION}") |
||||
|
||||
foreach(LIB faad faad_drm faad_fixed faad_drm_fixed) |
||||
set_target_properties(${LIB} PROPERTIES |
||||
VERSION "${FAAD_ABI_COMPATIBILITY}.${FAAD_ABI_VERSION_AGE}.${FAAD_ABI_VERSION_REVISION}" |
||||
SOVERSION "${FAAD_ABI_COMPATIBILITY}" |
||||
) |
||||
endforeach() |
||||
|
||||
# Installation |
||||
|
||||
if(NOT FAAD_BUNDLED_MODE AND NOT MSVC) |
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/faad2.pc" |
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
||||
|
||||
install( |
||||
TARGETS faad faad_cli faad_drm |
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
||||
) |
||||
|
||||
# exclude faad.h.in |
||||
install( |
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/faad.h |
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/neaacdec.h |
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" |
||||
) |
||||
|
||||
install( |
||||
FILES frontend/faad.man |
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 |
||||
RENAME faad.1 |
||||
) |
||||
endif() # FAAD_BUNDLED_MODE |
@ -0,0 +1,221 @@ |
||||
2.11.1 (2023-11-14): |
||||
[ Fabian Greffrath ] |
||||
* Build shared libraries and hide symbols by default. |
||||
* Install man page by default. |
||||
* Check for `lrintf()` availability, link with `-lm` and define `HAVE_LRINTF` accordingly. |
||||
* Set a default build type if none was specified. |
||||
* Build DLL name with SOVERSION by default on Windows. |
||||
* Fix inlined `lrintf()` function signatures. |
||||
|
||||
2.11.0 (2023-11-07): |
||||
[ Eugène Filin ] |
||||
* Fix incorrect variable initialization |
||||
|
||||
[ Eugene Kliuchnikov ] |
||||
* CI/CD, build, etc |
||||
|
||||
- setup GitHub workflows; test build under MSVC, OSX, MSYS2, Linux |
||||
- add CMake build system |
||||
- additionally add Bazel build |
||||
- remove automake and MSVC project files |
||||
- add fuzzers that cover almost all decoder code |
||||
- setup fuzzing for various builds: (no-)FIXED_POINT / (no-)DRM |
||||
- remove dead code |
||||
- address differes compilers warnings |
||||
- move version to distingished place that different build systems can read |
||||
|
||||
* "Safe" bugs |
||||
|
||||
"Safe" means that it is unlikely to be exploited; those affect the decoded |
||||
result for (most likely) extreme inputs. Some fixes are useful only for |
||||
"FIXED_POINT" build, since it has more restrictions on intermediate values. |
||||
|
||||
- "negative range" in estimate_current_envelope |
||||
- integer overflow in channel downmixing |
||||
- integer overflow in estimate_envelope |
||||
- integer overflows caused by "practical infinite" gain |
||||
- integer overflows in HF adjustment code |
||||
- several "left shift of negative value" |
||||
- priming RNG to avoid using values that does not look random at all |
||||
- do not drop the first frame of output; other decoders don't do this |
||||
- touching uninitialized values in lt_update_state |
||||
- touching uninitialized values in bit-reader buffers |
||||
|
||||
* "Almost Safe" bugs |
||||
|
||||
"Almost safe" means that those are unlinkly to be exploited; if those surface |
||||
depends on build options / environment. |
||||
|
||||
- division by zero in HF (noise?) generator and scale factor adjustment |
||||
- division by zero gen_rand_vector |
||||
|
||||
* "Unsafe" bugs |
||||
|
||||
"Unsafe" means that those can cause crash, or could somehow else be exploited. |
||||
|
||||
- CLI: accessing unallocated memory in mp4info (corrupted / zero-samples input) (CVE-2023-38857) |
||||
- CLI: out-of-bounds when parsing mp4 header |
||||
- CLI: crash because of wrong mp4 frame offset calculation (CVE-2023-38857) |
||||
- error handling rvlc_decode_scale_factors (CPU bomb?) |
||||
- null pointer dereference (in DRM + PS build) |
||||
- index-out-of-bounds / stack-buffer-overflow in decode_sce_lfe |
||||
(for streams with PCE) |
||||
- stack-buffer-overflow in pns_decode |
||||
- null pointer derefernce (when channels change their type in the middle |
||||
of the stream) |
||||
- infinite loop on currupted stream |
||||
- add practial limits for scale factors; otherwise calculated NaN/Inf values |
||||
could confuse further logic, resulting in access-out-of-bounds |
||||
- check sf_index in window_grouping_info to avoid access-out-of-bounds |
||||
- clamp bs_pointer values to avoid access-out-of-bounds |
||||
- infinite loop in fill_element |
||||
- sanitize input values in ps_mix_phase to avoid access-out-of-bounds |
||||
- fix internal decoder buffer size calculation to avoid heap-out-of-bounds |
||||
- calculate channel length multiplier even if main channel is already allocated |
||||
to avoid heap-out-of-bounds |
||||
- reserve enough slots for channels in decode_sce_lfe |
||||
to avoid heap-out-of-bounds |
||||
|
||||
[ David Korczynski ] |
||||
* Fuzzing integration with oss-fuzz |
||||
|
||||
[ Steveice10 ] |
||||
* Add define option to disable SBR/PS support |
||||
* Fix coefficient table selection in tns_decode_coef |
||||
|
||||
2.10.1 (2022-10-20): |
||||
[David Korczynski] |
||||
* Reject buffers of zero size. |
||||
|
||||
[François Cartegnie] |
||||
* Fix 7.1 with PCE mapping. |
||||
* Have proper version string in `faad.h`. |
||||
* Add conditional build with DRC. |
||||
|
||||
2.10.0 (2020-10-20): |
||||
[ tatsuz ] |
||||
* updated Visual Studio projects to VS 2019 (#54) |
||||
|
||||
[ Fabian Greffrath ] |
||||
* mp4read.c: fix stack-buffer-overflow in stringin()/ftypin() |
||||
* fix heap-buffer-overflow in mp4read.c |
||||
|
||||
[ Clayton Smith ] |
||||
* Remove non-ASCII characters |
||||
* Remove trailing whitespace |
||||
|
||||
[ Andrew Wesie ] |
||||
* Check return value of ltp_data. |
||||
* Restrict SBR frame length to 960 and 1024 samples. |
||||
* Support object type 29. |
||||
* Support implicit SBR signaling in frontend. |
||||
* Fix PNS decoding when only right channel is noise. |
||||
* Initialize element_id array with an invalid id. |
||||
* Fix NULL pointer dereferences. |
||||
* Fix infinite loop in adts_parse. |
||||
* Fix infinite loop in huffman_getescape. |
||||
* Check for error after each channel decode. |
||||
* Check for inconsistent number of channels. |
||||
|
||||
2.9.2 (2020-05-04): |
||||
[ Michał Janiszewski ] |
||||
* Only use x86-assembly when explicitly on x86 |
||||
* Use unsigned integers correctly |
||||
* Initialize pointers that might otherwise not be |
||||
|
||||
[ Fabian Greffrath ] |
||||
* update README esp. WRT directory structure |
||||
|
||||
[ Rosen Penev ] |
||||
* fix compilation without SBR/PS_DEC (#48) |
||||
* fix compilation with LC_ONLY_DECODER (#47) |
||||
|
||||
[ Fabian Greffrath ] |
||||
* fix "inline function 'cfftf1' declared but never defined" compiler warning |
||||
* fix some inconsistencies in the frontend output |
||||
* mp4read_open: add check for failed frame buffer allocation |
||||
* stszin: add check for allocation error and integer overflow |
||||
* add a pkg-config file |
||||
|
||||
[ Stefan Pöschel ] |
||||
* frontend: address compile warning + add missing LF (#50) |
||||
|
||||
[ François Cartegnie ] |
||||
* library name is faad (#52) |
||||
* Unbreak PS audio (#51) |
||||
|
||||
2.9.1 (2019-11-04): |
||||
[ Fabian Greffrath ] |
||||
* Include stdio.h in libfaad/ps_dec.c for stderr (Michael Fink) |
||||
* Fix Tille -> Title typo in frontend/mp4read.c (Alexander Thomas) |
||||
|
||||
2.9.0 (2019-09-09): |
||||
[ Krzysztof Nikiel ] |
||||
* Build system fixes and code clean-up |
||||
|
||||
[ LoRd_MuldeR ] |
||||
* Fix compiler warnings and code indentation |
||||
* Fix compilation with GCC <= 4.7.3 |
||||
* MSVC solution file clean-up |
||||
|
||||
[ Cameron Cawley ] |
||||
* Fix compilation with GCC 4.7.4 |
||||
* Fix compilation with MinGW |
||||
|
||||
[ Michael Fink ] |
||||
* MSVC 2017 project file update |
||||
|
||||
[ Hugo Lefeuvre ] |
||||
* Fix crash with unsupported MP4 files (NULL pointer dereference, |
||||
division by zero) |
||||
* CVE-2019-6956: ps_dec: sanitize iid_index before mixing |
||||
* CVE-2018-20196: sbr_fbt: sanitize sbr->M (should not exceed MAX_M) |
||||
* CVE-2018-20199, CVE-2018-20360: specrec: better handle unexpected |
||||
parametric stereo (PS) |
||||
* CVE-2018-20362, CVE-2018-19504, CVE-2018-20195, CVE-2018-20198, |
||||
CVE-2018-20358: syntax.c: check for syntax element inconsistencies |
||||
* CVE-2018-20194, CVE-2018-19503, CVE-2018-20197, CVE-2018-20357, |
||||
CVE-2018-20359, CVE-2018-20361: sbr_hfadj: sanitize frequency band |
||||
borders |
||||
|
||||
[ Hugo Beauzée-Luyssen ] |
||||
* CVE-2019-15296, CVE-2018-19502: Fix a couple buffer overflows |
||||
|
||||
[ Filip Roséen ] |
||||
* Prevent crash on SCE followed by CPE |
||||
|
||||
[ Gianfranco Costamagna ] |
||||
* Fix linking with GCC 9 and "-Wl,--as-needed" |
||||
|
||||
[ Fabian Greffrath ] |
||||
* Enable the frontend to be built reproducibly |
||||
|
||||
2.8.8: |
||||
2.8.7: |
||||
- MSVC build fixes |
||||
- fixed a coulple bugs |
||||
2.8.6: |
||||
2.8.5: |
||||
- another package fix |
||||
2.8.4: |
||||
- minor fix to released packages |
||||
2.8.3 |
||||
- better autotools support |
||||
2.8.2 |
||||
- PNS bug fixed |
||||
- New MP4 input module |
||||
- NeAACDecGetVersion: |
||||
new api function to get version and copyright strings |
||||
|
||||
2.8.1: |
||||
- seeking support for MP4 files |
||||
2.8.0: |
||||
- patches and fixed bugs |
||||
|
||||
2009-02-02 - Version 2.7 |
||||
* DAB+ support |
||||
* Use public headers internally to prevent duplicate declarations |
||||
* Explicitly typedef all types as signed |
||||
* Made sure MAIN prediction can't be started after the first frame |
||||
* Lot's of compilation issues solved |
||||
* Bugfix in SBR envelope border calculation |
@ -0,0 +1,66 @@ |
||||
|
||||
Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
|
||||
FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder. |
||||
FAAD2 includes code for SBR (HE AAC) decoding. |
||||
FAAD2 is licensed under the GPL. |
||||
|
||||
|
||||
__________ |
||||
COPYRIGHTS |
||||
|
||||
For FAAD2 the following license applies: |
||||
|
||||
****************************************************************************** |
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
****************************************************************************** |
||||
|
||||
|
||||
Please note that the use of this software may require the payment of |
||||
patent royalties. You need to consider this issue before you start |
||||
building derivative works. We are not warranting or indemnifying you in |
||||
any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN |
||||
ACTIONS! |
||||
|
||||
|
||||
___________________ |
||||
DIRECTORY STRUCTURE |
||||
|
||||
faad2 - top level directory. |
||||
|
||||
docs - API documentation. |
||||
|
||||
frontend - command line frontend to the FAAD2 library, also supports |
||||
MPEG-4 file decoding. |
||||
|
||||
include - inlude file for the FAAD2 library. |
||||
|
||||
libfaad - the FAAD2 AAC decoder library including SBR. |
||||
|
||||
codebook - Huffman codebooks. |
||||
|
||||
project/msvc - Visual Studio 2017 project files. |
@ -0,0 +1,23 @@ |
||||
load(":workspace.bzl", "wrap_json_properties") |
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
||||
|
||||
wrap_json_properties(name = "properties", src = "@//:properties.json") |
||||
|
||||
http_archive( |
||||
name = "rules_fuzzing", |
||||
sha256 = "ff52ef4845ab00e95d29c02a9e32e9eff4e0a4c9c8a6bcf8407a2f19eb3f9190", |
||||
strip_prefix = "rules_fuzzing-0.4.1", |
||||
urls = ["https://github.com/bazelbuild/rules_fuzzing/releases/download/v0.4.1/rules_fuzzing-0.4.1.zip"], |
||||
) |
||||
|
||||
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") |
||||
|
||||
rules_fuzzing_dependencies() |
||||
|
||||
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") |
||||
|
||||
rules_fuzzing_init() |
||||
|
||||
load("@fuzzing_py_deps//:requirements.bzl", "install_deps") |
||||
|
||||
install_deps() |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,531 @@ |
||||
.TH man 3 "15 Nov 2014" "The Debian Project" "libfaad Documentation" |
||||
.SH "NAME" |
||||
libfaad \- C library for AAC Decoding |
||||
.SH "SYNOPSIS" |
||||
.sp |
||||
.ft B |
||||
.nf |
||||
|
||||
#include <neaacec\&.h> |
||||
|
||||
.HP |
||||
.BI "char NEAACDECAPI *NeAACDecGetErrorMessage(" "" "unsigned char " errcode ); |
||||
|
||||
.HP |
||||
.B "unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);" |
||||
|
||||
.HP |
||||
.B "NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);" |
||||
|
||||
.HP |
||||
.B "NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(" |
||||
.BI "NeAACDecHandle " hDecoder ");" |
||||
|
||||
.HP |
||||
.B "unsigned char NEAACDECAPI NeAACDecSetConfiguration(" |
||||
.BI "NeAACDecHandle " "hDecoder" ", NeAACDecConfigurationPtr " config ");" |
||||
|
||||
.HP |
||||
/* Init the library based on info from the AAC file (ADTS/ADIF) */ |
||||
.B "long NEAACDECAPI NeAACDecInit(" |
||||
.BI "NeAACDecHandle " hDecoder ", unsigned char *" buffer ", unsigned long " "buffer_size" "," |
||||
.BI "unsigned long *" "samplerate" ", unsigned char *" "channels" ");" |
||||
.HP |
||||
/* Init the library using a DecoderSpecificInfo */ |
||||
.B "char NEAACDECAPI NeAACDecInit2(" |
||||
.BI "NeAACDecHandle " "hDecoder" ", unsigned char *" "pBuffer" "," |
||||
.BI "unsigned long " "SizeOfDecoderSpecificInfo" "," |
||||
.BI "unsigned long *" "samplerate" ", unsigned char *"channels" ");" |
||||
.HP |
||||
/* Init the library for DRM */ |
||||
.B "char NEAACDECAPI NeAACDecInitDRM(" |
||||
.BI "NeAACDecHandle *" "hDecoder" ", unsigned long " "samplerate" ", unsigned char " "channels" ");" |
||||
.HP |
||||
.B "void NEAACDECAPI NeAACDecPostSeekReset(" |
||||
.BI "NeAACDecHandle " "hDecoder" ", long "frame" ");" |
||||
.HP |
||||
.BI "void NEAACDECAPI NeAACDecClose(NeAACDecHandle " "hDecoder" ");" |
||||
.HP |
||||
.B "void NEAACDECAPI *NeAACDecDecode(" |
||||
.BI "NeAACDecHandle " "hDecoder" ", NeAACDecFrameInfo *" "hInfo" "," |
||||
.BI "unsigned char *" "buffer" "," |
||||
.BI "unsigned long " "buffer_size" ");" |
||||
.HP |
||||
.B "void NEAACDECAPI *NeAACDecDecode2(" |
||||
.BI "NeAACDecHandle " "hDecoder" ", NeAACDecFrameInfo *" "hInfo" "," |
||||
.BI "unsigned char *" "buffer" ", unsigned long " "buffer_size" "," |
||||
.BI "void **" "sample_buffer" ", unsigned long " "sample_buffer_size" ");" |
||||
.HP |
||||
.B "char NEAACDECAPI NeAACDecAudioSpecificConfig(" |
||||
.BI "unsigned char *" "pBuffer" ", unsigned long " "buffer_size" "," |
||||
.BI "mp4AudioSpecificConfig *" "mp4ASC" ");" |
||||
.PP |
||||
For normal use link it with the linker option \-lfaad\&. |
||||
.PP |
||||
For Digital Radio Mondiale link it with the linker option \-lfaad_drm\&. |
||||
.sp |
||||
.SH "DESCRIPTION" |
||||
.PP |
||||
.B NeAACDecGetErrorMessage |
||||
.PP |
||||
.B char NEAACDECAPI *NeAACDecGetErrorMessage(unsigned char errcode); |
||||
.PP |
||||
Convert an error code to text. |
||||
.PP |
||||
.B NeAACDecGetCapabilities |
||||
.PP |
||||
unsigned long NEAACAPI NeAACDecGetCapabilities(void); |
||||
.PP |
||||
|
||||
.PP |
||||
This function returns the capabilities of the decoder in a 32 bit |
||||
unsigned integer. |
||||
The bits that are set in the 32 bit unsigned integer define with which |
||||
capabilities the library has been compiled. |
||||
.PP |
||||
The following capabilities are defined: |
||||
.PP |
||||
\ |
||||
.PP |
||||
#define LC_DEC_CAP \ \ \ \ \ (1<<0) /* Can decode LC */ |
||||
.PP |
||||
#define MAIN_DEC_CAP \ \ \ \ (1<<1) /* Can decode MAIN */ |
||||
.PP |
||||
#define LTP_DEC_CAP \ \ \ \ \ (1<<2) /* Can decode LTP */ |
||||
.PP |
||||
#define LD_DEC_CAP \ \ \ \ \ (1<<3) /* Can decode LD */ |
||||
.PP |
||||
#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */ |
||||
.PP |
||||
#define FIXED_POINT_CAP \ \ \ (1<<5) /* Fixed point */ |
||||
.PP |
||||
.PP |
||||
This function can be called anytime. |
||||
.PP |
||||
.B NeAACDecOpen |
||||
.PP NeAACDecHandle NEAACAPI NeAACDecOpen(void); |
||||
.PP |
||||
Returns a handle to a decoder context. |
||||
.PP |
||||
.B NeAACDecClose |
||||
.PP void NEAACAPI NeAACDecClose(NeAACDecHandle hDecoder); |
||||
.PP |
||||
Closes a decoder context that has been opened by NeAACDecOpen. |
||||
.PP |
||||
.B NeAACDecGetCurrentConfiguration |
||||
.PP |
||||
NeAACDecConfigurationPtr NEAACAPI |
||||
NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); |
||||
.PP |
||||
Returns the current decoder library configuration. |
||||
.PP |
||||
.B NeAACDecSetConfiguration |
||||
.PP unsigned char NEAACAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, NeAACDecConfigurationPtr config); |
||||
.PP |
||||
.PP |
||||
Sets a new configuration structure for the decoder library. |
||||
.PP |
||||
\ |
||||
.PP |
||||
Return values: |
||||
.PP 0 \[en] Error, invalid configuration. |
||||
.PP 1 \[en] OK |
||||
.PP |
||||
.B NeAACDecInit |
||||
.PP |
||||
long NEAACAPI NeAACDecInit(NeAACDecHandle hDecoder, unsigned char |
||||
*buffer, unsigned long buffer_size, unsigned long *samplerate, unsigned |
||||
char *channels); |
||||
.PP |
||||
.PP |
||||
.PP |
||||
Initialises the decoder library using information from the AAC file. |
||||
The buffer parameter should hold a small part of the AAC file, so that |
||||
the initialization can be done based on the ADTS or ADIF header. |
||||
Buffer can also be NULL, but then default initialization parameters will |
||||
be used. |
||||
.PP |
||||
Return values: |
||||
.PP |
||||
< 0 \[en] Error |
||||
.PP |
||||
>= 0 \[en] Number of bytes read. |
||||
This amount of bytes should be skipped by the program using the decoder |
||||
library. |
||||
.PP |
||||
This function fills the samplerate and channels parameters with the |
||||
detected values. |
||||
.PP |
||||
.B NeAACDecInit2 |
||||
.PP |
||||
char NEAACAPI NeAACDecInit2(NeAACDecHandle hDecoder, unsigned char |
||||
*pBuffer, unsigned long SizeOfDecoderSpecificInfo, unsigned long |
||||
*samplerate, unsigned char *channels); |
||||
.PP |
||||
Initialises the decoder library based on an AudioSpecificConfig as found |
||||
inside a MP4 file. |
||||
.PP |
||||
Return values: |
||||
.PP |
||||
< 0 \[en] Error |
||||
.PP |
||||
0 \- OK |
||||
.PP |
||||
This function fills the samplerate and channels parameters with the |
||||
detected values. |
||||
.PP |
||||
.B NeAACDecInitDRM |
||||
.PP |
||||
char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate, unsigned char channels); |
||||
.PP |
||||
Initialises the decoder library for Digital Radio Mondiale using the specified sample rate |
||||
and a DRM specific channel configuration. |
||||
.PP |
||||
Return values: |
||||
.PP |
||||
< 0 \[en] Error |
||||
.PP |
||||
0 \- OK |
||||
.PP |
||||
Values for the channel configuration: |
||||
.PP |
||||
#define DRMCH_MONO 1 |
||||
.PP |
||||
#define DRMCH_STEREO 2 |
||||
.PP |
||||
#define DRMCH_SBR_MONO 3 |
||||
.PP |
||||
#define DRMCH_SBR_STEREO 4 |
||||
.PP |
||||
#define DRMCH_SBR_PS_STEREO 5 |
||||
.PP |
||||
.B NeAACDecDecode |
||||
.PP |
||||
void* NEAACAPI NeAACDecDecode(NeAACDecHandle hDecoder, NeAACDecFrameInfo |
||||
*hInfo, unsigned char *buffer, unsigned long buffer_size); |
||||
.PP |
||||
.PP |
||||
Decodes the AAC data passed in buffer. |
||||
.PP |
||||
Returns a pointer to a sample buffer or NULL. |
||||
Info about the decoded frame is filled in in the NeAACDecFrameInfo |
||||
structure. |
||||
This structure holds information about errors during decoding, number of |
||||
sample, number of channels and samplerate. |
||||
The returned buffer contains the channel interleaved samples of the |
||||
frame. |
||||
.PP |
||||
.B NeAACDecDecode2 |
||||
.PP |
||||
void NEAACDECAPI *NeAACDecDecode2(NeAACDecHandle hDecoder, |
||||
NeAACDecFrameInfo *hInfo, |
||||
unsigned char *buffer, |
||||
unsigned long buffer_size, |
||||
void **sample_buffer, |
||||
unsigned long sample_buffer_size); |
||||
|
||||
|
||||
|
||||
.PP |
||||
.B NeAACDecAudioSpecificConfig |
||||
.PP |
||||
char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer, |
||||
unsigned long buffer_size, |
||||
mp4AudioSpecificConfig *mp4ASC); |
||||
.PP |
||||
.B Structures |
||||
.RS 4 |
||||
.PP NeAACDecConfiguration |
||||
.RE |
||||
.PP |
||||
typedef struct NeAACDecConfiguration |
||||
.PP |
||||
{ |
||||
.PP |
||||
\ \ unsigned char defObjectType; |
||||
.PP |
||||
\ \ unsigned long defSampleRate; |
||||
.PP |
||||
\ \ unsigned char outputFormat; |
||||
.PP |
||||
\ \ unsigned char downMatrix; |
||||
.PP |
||||
\ \ unsigned char useOldADTSFormat; |
||||
.PP |
||||
} NeAACDecConfiguration, *NeAACDecConfigurationPtr; |
||||
.PP |
||||
|
||||
.PP |
||||
Members: |
||||
.PP |
||||
defObjectType: determines the default object type assumed when the |
||||
library is initialized without any data from the AAC file (eg: when NULL |
||||
is passed as buffer in NeAACDecInit()). |
||||
Can be any of the following values: |
||||
.PP |
||||
#define MAIN \ \ \ 1 /* MAIN */ |
||||
.PP |
||||
#define LC \ \ \ \ 2 /* Low Complexity (default) */ |
||||
.PP |
||||
#define SSR \ \ \ \ 3 /* Scalable SampleRate */ |
||||
.PP |
||||
#define LTP \ \ \ \ 4 /* Long Term Predition */ |
||||
.PP |
||||
#define HE_AAC \ \ 5 /* High Efficiency (SBR) */ |
||||
.PP |
||||
#define ER_LC \ \ 17 /* Error Resilient Low Complexity */ |
||||
.PP |
||||
#define ER_LTP \ \ 19 /* Error Resilient Long Term Prediction */ |
||||
.PP |
||||
#define LD \ \ \ \ 23 /* Low Delay */ |
||||
.PP |
||||
#define DRM_ER_LC 27 /* special object type for DRM only if linking with \-lfaad_drm */ |
||||
.PP |
||||
defSampleRate: determines the default samplerate assumed when the |
||||
library is initialized. |
||||
Default value is 44100. |
||||
.PP |
||||
outputFormat: determines the output format returned by the decoder |
||||
library. |
||||
Can be any of the following values: |
||||
.PP |
||||
#define FAAD_FMT_16BIT \ 1 /* 16 bit integers */ |
||||
.PP |
||||
#define FAAD_FMT_24BIT \ 2 /* 24 bit values packed in 32 bit integers */ |
||||
.PP |
||||
#define FAAD_FMT_32BIT \ 3 /* 32 bit integers */ |
||||
.PP |
||||
#define FAAD_FMT_FLOAT \ 4 /* single precision floating point */ |
||||
.PP |
||||
#define FAAD_FMT_DOUBLE 5 /* double precision floating point */ |
||||
.PP |
||||
downMatrix: determines whether a 5.1 channel AAC file should be |
||||
downmatrixed to 2 channel output (value: 1) or whether the output should |
||||
stay as 5.1 channels (value: 0). |
||||
.PP |
||||
useOldADTSFormat: determines whether the decoder should assume the |
||||
currently defined 56 bit ADTS header (value: 0) or the 58 bit ADTS |
||||
header (value: 1) defined in previous versions of the AAC standard. |
||||
This value should normally always stay at the value 0, it only exists to |
||||
provide playback capabilities for people that have AAC files with the |
||||
old header format. |
||||
All current encoders should output the new ADTS format. |
||||
NeAACDecFrameInfo\ |
||||
.PP |
||||
This structure is returned after decoding a frame and provides info |
||||
about the decoded frame. |
||||
.PP |
||||
typedef struct NeAACDecFrameInfo |
||||
.PP |
||||
{ |
||||
.PP |
||||
\ \ unsigned long bytesconsumed; |
||||
.PP |
||||
\ \ unsigned long samples; |
||||
.PP |
||||
\ \ unsigned char channels; |
||||
.PP |
||||
\ \ unsigned char error; |
||||
.PP |
||||
\ \ unsigned long samplerate; |
||||
.PP |
||||
\ \ unsigned char sbr; |
||||
.PP |
||||
\ \ unsigned char object_type; |
||||
.PP |
||||
\ \ unsigned char header_type; |
||||
.PP |
||||
\ \ unsigned char num_front_channels; |
||||
.PP |
||||
\ \ unsigned char num_side_channels; |
||||
.PP |
||||
\ \ unsigned char num_back_channels; |
||||
.PP |
||||
\ \ unsigned char num_lfe_channels; |
||||
.PP |
||||
\ \ unsigned char channel_position[64]; |
||||
.PP |
||||
\ \ unsigned char ps; |
||||
.PP |
||||
} NeAACDecFrameInfo; |
||||
.PP |
||||
\ |
||||
.PP |
||||
Members: |
||||
.PP |
||||
bytesconsumed: the number of bytes consumed for decoding this frame. |
||||
.PP |
||||
samples: the number of audio samples in this frame. |
||||
Each channel is counted separately. |
||||
So when a single channel has 1024 samples and the file has 2 channels, |
||||
this value will be 2*1024 = 2048. |
||||
.PP |
||||
channels: number of audio channels in this frame |
||||
.PP |
||||
error: contains an error value if an error occurred, 0 otherwise. |
||||
.PP |
||||
samplerate: the samplerate of the frame. |
||||
.PP |
||||
sbr: tells whether sbr is used in this file or not. |
||||
Can contain any of the following values: |
||||
.PP |
||||
#define NO_SBR \ \ \ \ \ 0 /* no SBR used in this file */ |
||||
.PP |
||||
#define SBR_UPSAMPLED \ \ 1 /* upsampled SBR used */ |
||||
.PP |
||||
#define SBR_DOWNSAMPLED \ 2 /* downsampled SBR used */ |
||||
.PP |
||||
#define NO_SBR_UPSAMPLED 3 /* no SBR used, but file is upsampled by a |
||||
factor 2 anyway */ |
||||
.PP |
||||
object_type: contains the object type of the AAC file. |
||||
Can be any of the values as defined in 1.9.1. |
||||
.PP |
||||
header_type: contains the header type of the file that is being decoded. |
||||
Can contain any of the following values: |
||||
.PP |
||||
#define RAW \ \ \ \ 0 /* No header */ |
||||
.PP |
||||
#define ADIF \ \ \ 1 /* single ADIF header at the beginning of the |
||||
file */ |
||||
.PP |
||||
#define ADTS \ \ \ 2 /* ADTS header at the beginning of each frame */ |
||||
.PP |
||||
num_front_channels, num_side_channels, num_back_channels, |
||||
num_lfe_channels: each of these values contain the number of channels of |
||||
a certain type. |
||||
.PP |
||||
channel_position[64]: contains the position of each of the channels that |
||||
is returned by the frame decode function. |
||||
Can contain any of the following values: |
||||
.PP |
||||
#define FRONT_CHANNEL_CENTER (1) |
||||
.PP |
||||
#define FRONT_CHANNEL_LEFT \ (2) |
||||
.PP |
||||
#define FRONT_CHANNEL_RIGHT \ (3) |
||||
.PP |
||||
#define SIDE_CHANNEL_LEFT \ \ (4) |
||||
.PP |
||||
#define SIDE_CHANNEL_RIGHT \ (5) |
||||
.PP |
||||
#define BACK_CHANNEL_LEFT \ \ (6) |
||||
.PP |
||||
#define BACK_CHANNEL_RIGHT \ (7) |
||||
.PP |
||||
#define BACK_CHANNEL_CENTER \ (8) |
||||
.PP |
||||
#define LFE_CHANNEL \ \ \ \ \ (9) |
||||
.PP |
||||
#define UNKNOWN_CHANNEL \ \ \ (0) |
||||
.PP |
||||
ps: PS not used (0) or used (1). |
||||
API usage\ |
||||
.PP |
||||
The following pseudo\-code describes how and in which order to use the |
||||
different library functions. |
||||
.PP |
||||
\ |
||||
.PP |
||||
unsigned long cap = NeAACDecGetCapabilities(); |
||||
.PP |
||||
// Check if decoder has the needed capabilities |
||||
.PP |
||||
\ |
||||
.PP |
||||
// Open the library |
||||
.PP |
||||
NeAACDecHandle hAac = NeAACDecOpen(); |
||||
.PP |
||||
\ |
||||
.PP |
||||
// Get the current config |
||||
.PP |
||||
NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hAac); |
||||
.PP |
||||
\ |
||||
.PP |
||||
// |
||||
.PP |
||||
// If needed change some of the values in conf |
||||
.PP |
||||
// |
||||
.PP |
||||
\ |
||||
.PP |
||||
// Set the new configuration |
||||
.PP |
||||
NeAACDecSetConfiguration(hAac, conf); |
||||
.PP |
||||
.PP |
||||
// Initialise the library using one of the initialization functions |
||||
.PP |
||||
char err = NeAACDecInit2(hAac, asc, asc_size, &samplerate, &channels); |
||||
.PP |
||||
if (err != 0) |
||||
.PP |
||||
{ |
||||
.PP |
||||
\ // |
||||
.PP |
||||
\ // Handle error |
||||
.PP |
||||
\ // |
||||
.PP |
||||
} |
||||
.PP |
||||
\ |
||||
.PP |
||||
// Loop until decoding finished |
||||
.PP |
||||
do { |
||||
.PP |
||||
\ // |
||||
.PP |
||||
\ // Put next frame in buffer |
||||
.PP |
||||
\ // |
||||
.PP |
||||
\ |
||||
.PP |
||||
\ // Decode the frame in buffer |
||||
.PP |
||||
\ \ \ \ samplebuffer = NeAACDecDecode(hAac, &hInfo, buffer, |
||||
.PP |
||||
buffer_size); |
||||
.PP |
||||
\ |
||||
.PP |
||||
if ((hInfo.error == 0) && (hInfo.samples > 0)) |
||||
.PP |
||||
{ |
||||
.PP |
||||
\ // |
||||
.PP |
||||
\ // do what you need to do with the decoded samples |
||||
.PP |
||||
\ // |
||||
.PP |
||||
} else if (hInfo.error != 0) { |
||||
.PP |
||||
\ // |
||||
.PP |
||||
\ // Some error occurred while decoding this frame |
||||
.PP |
||||
\ // |
||||
.PP |
||||
} |
||||
.PP |
||||
} while (more data available); |
||||
.PP |
||||
\ |
||||
.PP |
||||
NeAACDecClose(hAac); |
||||
.SH "SEE ALSO" |
||||
.PP |
||||
\fBlibfaad_drm\fR(3), |
||||
\fBlibfaac\fR(3)\&. |
||||
.SH "AUTHOR" |
||||
.PP |
||||
Menno Bakker <mbakker@nero.com> |
||||
.PP Man Page by Julian Cable <jcable@users.sf.net> |
@ -0,0 +1,512 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: audio.c,v 1.30 2015/01/22 09:40:52 knik Exp $ |
||||
**/ |
||||
|
||||
#ifdef _WIN32 |
||||
#include <io.h> |
||||
#endif |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <fcntl.h> |
||||
#include <math.h> |
||||
#include <neaacdec.h> |
||||
#include <stdint.h> |
||||
|
||||
#include "unicode_support.h" |
||||
#include "audio.h" |
||||
|
||||
static size_t write_wav_header(audio_file *aufile); |
||||
static size_t write_wav_extensible_header(audio_file *aufile, long channelMask); |
||||
static size_t write_audio_16bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples); |
||||
static size_t write_audio_24bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples); |
||||
static size_t write_audio_32bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples); |
||||
static size_t write_audio_float(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples); |
||||
|
||||
audio_file *open_audio_file(char *infile, int samplerate, int channels, |
||||
int outputFormat, int fileType, long channelMask) |
||||
{ |
||||
audio_file *aufile = malloc(sizeof(audio_file)); |
||||
|
||||
aufile->outputFormat = outputFormat; |
||||
|
||||
aufile->samplerate = samplerate; |
||||
aufile->channels = channels; |
||||
aufile->total_samples = 0; |
||||
aufile->fileType = fileType; |
||||
aufile->channelMask = channelMask; |
||||
|
||||
switch (outputFormat) |
||||
{ |
||||
case FAAD_FMT_16BIT: |
||||
aufile->bits_per_sample = 16; |
||||
break; |
||||
case FAAD_FMT_24BIT: |
||||
aufile->bits_per_sample = 24; |
||||
break; |
||||
case FAAD_FMT_32BIT: |
||||
case FAAD_FMT_FLOAT: |
||||
aufile->bits_per_sample = 32; |
||||
break; |
||||
default: |
||||
if (aufile) free(aufile); |
||||
return NULL; |
||||
} |
||||
|
||||
if(infile[0] == '-') |
||||
{ |
||||
#ifdef _WIN32 |
||||
_setmode(_fileno(stdout), O_BINARY); |
||||
#endif |
||||
aufile->sndfile = stdout; |
||||
aufile->toStdio = 1; |
||||
} else { |
||||
aufile->toStdio = 0; |
||||
aufile->sndfile = faad_fopen(infile, "wb"); |
||||
} |
||||
|
||||
if (aufile->sndfile == NULL) |
||||
{ |
||||
if (aufile) free(aufile); |
||||
return NULL; |
||||
} |
||||
|
||||
if (aufile->fileType == OUTPUT_WAV) |
||||
{ |
||||
if (aufile->channelMask) |
||||
write_wav_extensible_header(aufile, aufile->channelMask); |
||||
else |
||||
write_wav_header(aufile); |
||||
} |
||||
|
||||
return aufile; |
||||
} |
||||
|
||||
size_t write_audio_file(audio_file *aufile, void *sample_buffer, int samples) |
||||
{ |
||||
char *buf = (char *)sample_buffer; |
||||
switch (aufile->outputFormat) |
||||
{ |
||||
case FAAD_FMT_16BIT: |
||||
return write_audio_16bit(aufile, buf, samples); |
||||
case FAAD_FMT_24BIT: |
||||
return write_audio_24bit(aufile, buf, samples); |
||||
case FAAD_FMT_32BIT: |
||||
return write_audio_32bit(aufile, buf, samples); |
||||
case FAAD_FMT_FLOAT: |
||||
return write_audio_float(aufile, buf, samples); |
||||
default: |
||||
return 0; |
||||
} |
||||
// return 0;
|
||||
} |
||||
|
||||
void close_audio_file(audio_file *aufile) |
||||
{ |
||||
if ((aufile->fileType == OUTPUT_WAV) && (aufile->toStdio == 0)) |
||||
{ |
||||
fseek(aufile->sndfile, 0, SEEK_SET); |
||||
|
||||
if (aufile->channelMask) |
||||
write_wav_extensible_header(aufile, aufile->channelMask); |
||||
else |
||||
write_wav_header(aufile); |
||||
} |
||||
|
||||
if (aufile->toStdio == 0) |
||||
fclose(aufile->sndfile); |
||||
|
||||
if (aufile) free(aufile); |
||||
} |
||||
|
||||
static size_t write_wav_header(audio_file *aufile) |
||||
{ |
||||
unsigned char header[44]; |
||||
unsigned char* p = header; |
||||
unsigned int bytes = (aufile->bits_per_sample + 7) / 8; |
||||
float data_size = (float)bytes * aufile->total_samples; |
||||
unsigned long word32; |
||||
|
||||
*p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F'; |
||||
|
||||
word32 = (data_size + (44 - 8) < (float)MAXWAVESIZE) ? |
||||
(unsigned long)data_size + (44 - 8) : (unsigned long)MAXWAVESIZE; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
*p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E'; |
||||
|
||||
*p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' '; |
||||
|
||||
*p++ = 0x10; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; |
||||
|
||||
if (aufile->outputFormat == FAAD_FMT_FLOAT) |
||||
{ |
||||
*p++ = 0x03; *p++ = 0x00; |
||||
} else { |
||||
*p++ = 0x01; *p++ = 0x00; |
||||
} |
||||
|
||||
*p++ = (unsigned char)(aufile->channels >> 0); |
||||
*p++ = (unsigned char)(aufile->channels >> 8); |
||||
|
||||
word32 = (unsigned long)(aufile->samplerate + 0.5); |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
word32 = aufile->samplerate * bytes * aufile->channels; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
word32 = bytes * aufile->channels; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0); |
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8); |
||||
|
||||
*p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a'; |
||||
|
||||
word32 = data_size < MAXWAVESIZE ? |
||||
(unsigned long)data_size : (unsigned long)MAXWAVESIZE; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
return fwrite(header, sizeof(header), 1, aufile->sndfile); |
||||
} |
||||
|
||||
static size_t write_wav_extensible_header(audio_file *aufile, long channelMask) |
||||
{ |
||||
unsigned char header[68]; |
||||
unsigned char* p = header; |
||||
unsigned int bytes = (aufile->bits_per_sample + 7) / 8; |
||||
float data_size = (float)bytes * aufile->total_samples; |
||||
unsigned long word32; |
||||
|
||||
*p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F'; |
||||
|
||||
word32 = (data_size + (68 - 8) < (float)MAXWAVESIZE) ? |
||||
(unsigned long)data_size + (68 - 8) : (unsigned long)MAXWAVESIZE; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
*p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E'; |
||||
|
||||
*p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' '; |
||||
|
||||
*p++ = /*0x10*/0x28; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; |
||||
|
||||
/* WAVE_FORMAT_EXTENSIBLE */ |
||||
*p++ = 0xFE; *p++ = 0xFF; |
||||
|
||||
*p++ = (unsigned char)(aufile->channels >> 0); |
||||
*p++ = (unsigned char)(aufile->channels >> 8); |
||||
|
||||
word32 = (unsigned long)(aufile->samplerate + 0.5); |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
word32 = aufile->samplerate * bytes * aufile->channels; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
word32 = bytes * aufile->channels; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0); |
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8); |
||||
|
||||
/* cbSize */ |
||||
*p++ = (unsigned char)(22); |
||||
*p++ = (unsigned char)(0); |
||||
|
||||
/* WAVEFORMATEXTENSIBLE */ |
||||
|
||||
/* wValidBitsPerSample */ |
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0); |
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8); |
||||
|
||||
/* dwChannelMask */ |
||||
word32 = channelMask; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
/* SubFormat */ |
||||
if (aufile->outputFormat == FAAD_FMT_FLOAT) |
||||
{ |
||||
/* KSDATAFORMAT_SUBTYPE_IEEE_FLOAT: 00000003-0000-0010-8000-00aa00389b71 */ |
||||
*p++ = 0x03; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00; |
||||
*p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71; |
||||
} else { |
||||
/* KSDATAFORMAT_SUBTYPE_PCM: 00000001-0000-0010-8000-00aa00389b71 */ |
||||
*p++ = 0x01; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; |
||||
*p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00; |
||||
*p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71; |
||||
} |
||||
|
||||
/* end WAVEFORMATEXTENSIBLE */ |
||||
|
||||
*p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a'; |
||||
|
||||
word32 = data_size < MAXWAVESIZE ? |
||||
(unsigned long)data_size : (unsigned long)MAXWAVESIZE; |
||||
*p++ = (unsigned char)(word32 >> 0); |
||||
*p++ = (unsigned char)(word32 >> 8); |
||||
*p++ = (unsigned char)(word32 >> 16); |
||||
*p++ = (unsigned char)(word32 >> 24); |
||||
|
||||
return fwrite(header, sizeof(header), 1, aufile->sndfile); |
||||
} |
||||
|
||||
static size_t write_audio_16bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples) |
||||
{ |
||||
size_t ret; |
||||
unsigned int i; |
||||
short *sample_buffer16 = (short*)sample_buffer; |
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); |
||||
|
||||
aufile->total_samples += samples; |
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask) |
||||
{ |
||||
for (i = 0; i < samples; i += aufile->channels) |
||||
{ |
||||
short r1, r2, r3, r4, r5, r6; |
||||
r1 = sample_buffer16[i]; |
||||
r2 = sample_buffer16[i+1]; |
||||
r3 = sample_buffer16[i+2]; |
||||
r4 = sample_buffer16[i+3]; |
||||
r5 = sample_buffer16[i+4]; |
||||
r6 = sample_buffer16[i+5]; |
||||
sample_buffer16[i] = r2; |
||||
sample_buffer16[i+1] = r3; |
||||
sample_buffer16[i+2] = r1; |
||||
sample_buffer16[i+3] = r6; |
||||
sample_buffer16[i+4] = r4; |
||||
sample_buffer16[i+5] = r5; |
||||
} |
||||
} |
||||
|
||||
for (i = 0; i < samples; i++) |
||||
{ |
||||
data[i*2] = (char)(sample_buffer16[i] & 0xFF); |
||||
data[i*2+1] = (char)((sample_buffer16[i] >> 8) & 0xFF); |
||||
} |
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile); |
||||
|
||||
if (data) free(data); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
static size_t write_audio_24bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples) |
||||
{ |
||||
size_t ret; |
||||
unsigned int i; |
||||
int32_t *sample_buffer24 = (int32_t*)sample_buffer; |
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); |
||||
|
||||
aufile->total_samples += samples; |
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask) |
||||
{ |
||||
for (i = 0; i < samples; i += aufile->channels) |
||||
{ |
||||
long r1, r2, r3, r4, r5, r6; |
||||
r1 = sample_buffer24[i]; |
||||
r2 = sample_buffer24[i+1]; |
||||
r3 = sample_buffer24[i+2]; |
||||
r4 = sample_buffer24[i+3]; |
||||
r5 = sample_buffer24[i+4]; |
||||
r6 = sample_buffer24[i+5]; |
||||
sample_buffer24[i] = r2; |
||||
sample_buffer24[i+1] = r3; |
||||
sample_buffer24[i+2] = r1; |
||||
sample_buffer24[i+3] = r6; |
||||
sample_buffer24[i+4] = r4; |
||||
sample_buffer24[i+5] = r5; |
||||
} |
||||
} |
||||
|
||||
for (i = 0; i < samples; i++) |
||||
{ |
||||
data[i*3] = (char)(sample_buffer24[i] & 0xFF); |
||||
data[i*3+1] = (char)((sample_buffer24[i] >> 8) & 0xFF); |
||||
data[i*3+2] = (char)((sample_buffer24[i] >> 16) & 0xFF); |
||||
} |
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile); |
||||
|
||||
if (data) free(data); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
static size_t write_audio_32bit(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples) |
||||
{ |
||||
size_t ret; |
||||
unsigned int i; |
||||
int32_t *sample_buffer32 = (int32_t*)sample_buffer; |
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); |
||||
|
||||
aufile->total_samples += samples; |
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask) |
||||
{ |
||||
for (i = 0; i < samples; i += aufile->channels) |
||||
{ |
||||
long r1, r2, r3, r4, r5, r6; |
||||
r1 = sample_buffer32[i]; |
||||
r2 = sample_buffer32[i+1]; |
||||
r3 = sample_buffer32[i+2]; |
||||
r4 = sample_buffer32[i+3]; |
||||
r5 = sample_buffer32[i+4]; |
||||
r6 = sample_buffer32[i+5]; |
||||
sample_buffer32[i] = r2; |
||||
sample_buffer32[i+1] = r3; |
||||
sample_buffer32[i+2] = r1; |
||||
sample_buffer32[i+3] = r6; |
||||
sample_buffer32[i+4] = r4; |
||||
sample_buffer32[i+5] = r5; |
||||
} |
||||
} |
||||
|
||||
for (i = 0; i < samples; i++) |
||||
{ |
||||
data[i*4] = (char)(sample_buffer32[i] & 0xFF); |
||||
data[i*4+1] = (char)((sample_buffer32[i] >> 8) & 0xFF); |
||||
data[i*4+2] = (char)((sample_buffer32[i] >> 16) & 0xFF); |
||||
data[i*4+3] = (char)((sample_buffer32[i] >> 24) & 0xFF); |
||||
} |
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile); |
||||
|
||||
if (data) free(data); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
static size_t write_audio_float(audio_file *aufile, void *sample_buffer, |
||||
unsigned int samples) |
||||
{ |
||||
size_t ret; |
||||
unsigned int i; |
||||
float *sample_buffer_f = (float*)sample_buffer; |
||||
unsigned char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); |
||||
|
||||
aufile->total_samples += samples; |
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask) |
||||
{ |
||||
for (i = 0; i < samples; i += aufile->channels) |
||||
{ |
||||
float r1, r2, r3, r4, r5, r6; |
||||
r1 = sample_buffer_f[i]; |
||||
r2 = sample_buffer_f[i+1]; |
||||
r3 = sample_buffer_f[i+2]; |
||||
r4 = sample_buffer_f[i+3]; |
||||
r5 = sample_buffer_f[i+4]; |
||||
r6 = sample_buffer_f[i+5]; |
||||
sample_buffer_f[i] = r2; |
||||
sample_buffer_f[i+1] = r3; |
||||
sample_buffer_f[i+2] = r1; |
||||
sample_buffer_f[i+3] = r6; |
||||
sample_buffer_f[i+4] = r4; |
||||
sample_buffer_f[i+5] = r5; |
||||
} |
||||
} |
||||
|
||||
for (i = 0; i < samples; i++) |
||||
{ |
||||
int exponent, mantissa, negative = 0 ; |
||||
float in = sample_buffer_f[i]; |
||||
|
||||
data[i*4] = 0; data[i*4+1] = 0; data[i*4+2] = 0; data[i*4+3] = 0; |
||||
if (in == 0.0) |
||||
continue; |
||||
|
||||
if (in < 0.0) |
||||
{ |
||||
in *= -1.0; |
||||
negative = 1; |
||||
} |
||||
in = (float)frexp(in, &exponent); |
||||
exponent += 126; |
||||
in *= (float)0x1000000; |
||||
mantissa = (((int)in) & 0x7FFFFF); |
||||
|
||||
if (negative) |
||||
data[i*4+3] |= 0x80; |
||||
|
||||
if (exponent & 0x01) |
||||
data[i*4+2] |= 0x80; |
||||
|
||||
data[i*4] = mantissa & 0xFF; |
||||
data[i*4+1] = (mantissa >> 8) & 0xFF; |
||||
data[i*4+2] |= (mantissa >> 16) & 0x7F; |
||||
data[i*4+3] |= (exponent >> 1) & 0x7F; |
||||
} |
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile); |
||||
|
||||
if (data) free(data); |
||||
|
||||
return ret; |
||||
} |
@ -0,0 +1,64 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: audio.h,v 1.19 2007/11/01 12:33:29 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef AUDIO_H_INCLUDED |
||||
#define AUDIO_H_INCLUDED |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define MAXWAVESIZE 4294967040LU |
||||
|
||||
#define OUTPUT_WAV 1 |
||||
#define OUTPUT_RAW 2 |
||||
|
||||
typedef struct |
||||
{ |
||||
int toStdio; |
||||
int outputFormat; |
||||
FILE *sndfile; |
||||
unsigned int fileType; |
||||
unsigned long samplerate; |
||||
unsigned int bits_per_sample; |
||||
unsigned int channels; |
||||
unsigned long total_samples; |
||||
long channelMask; |
||||
} audio_file; |
||||
|
||||
audio_file *open_audio_file(char *infile, int samplerate, int channels, |
||||
int outputFormat, int fileType, long channelMask); |
||||
size_t write_audio_file(audio_file *aufile, void *sample_buffer, int samples); |
||||
void close_audio_file(audio_file *aufile); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,85 @@ |
||||
.TH FAAD "1" "October 2006" "faad 2.5" "" |
||||
.SH NAME |
||||
faad \(em Process an Advanced Audio Codec stream |
||||
|
||||
.SH "SYNOPSIS" |
||||
.B faad |
||||
[options] [\-w | \-o <output_filename> | \-a <output_filename>] input_filename |
||||
|
||||
.SH "DESCRIPTION" |
||||
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. |
||||
|
||||
.SH "OPTIONS" |
||||
.TP |
||||
.BI \-a " <filename>" ", \-\^\-adtsout" " <filename>" |
||||
Sets the processing to output to the specified file in MPEG\(hy4 AAC ADTS format |
||||
.TP |
||||
.BI \-b " <number>" ", \-\^\-bits" " <number>" |
||||
Set the output (individual) sample format. The number takes one of the following values: |
||||
.RS |
||||
.RS |
||||
1: 16\(hybit PCM data (default). |
||||
.br |
||||
2: 24\(hybit PCM data. |
||||
.br |
||||
3: 32\(hybit PCM data. |
||||
.br |
||||
4: 32\(hybit floating\(hypoint data. |
||||
.br |
||||
5: 64\(hybit floating\(hypoint data. |
||||
.RE |
||||
.RE |
||||
.TP |
||||
.B \-d ", \-\^\-downmix" |
||||
Set the processing to downsample from 5.1 (surround sound and bass) channels to 2 channels (stereo). |
||||
.TP |
||||
.BI \-f " <number>" ", \-\^\-format" " <number>" |
||||
Set the output file format. The number takes one of the following values: |
||||
.RS |
||||
.RS |
||||
1: Microsoft WAV format (default). |
||||
.br |
||||
2: Raw PCM data. |
||||
.RE |
||||
.RE |
||||
.TP |
||||
.BI \-g |
||||
Set the processing to not perform gapless decoding. |
||||
.TP |
||||
.B \-h ", \-\^\-help" |
||||
Shows a usage summary. |
||||
.TP |
||||
.B \-i ", \-\^\-info" |
||||
Shows information about the about the input file. |
||||
.TP |
||||
.BI \-l " <number>" ", \-\^\-objecttype" " <number>" |
||||
Sets the MPEG\hy(4 profile and object type for the processing to use. The number takes one of the following values: |
||||
.RS |
||||
.RS |
||||
1: Main object type. |
||||
.br |
||||
2: Low Complexity (LC) object type (default). |
||||
.br |
||||
4: Long Term Prediction (LTP) object type. |
||||
.br |
||||
23: Low Delay (LD) object type. |
||||
.RE |
||||
.RE |
||||
.TP |
||||
.BI \-o " <filename>" ", \-\^\-outfile" " <number>" |
||||
Sets the filename for processing output. |
||||
.TP |
||||
.B \-q ", \-\^\-quiet" |
||||
Quiet \- Suppresses status messages during processing. |
||||
.TP |
||||
.B \-t ", \-\^\-oldformat" |
||||
Sets the processing to use the old MPEG\(hy4 AAC ADTS format when outputting in said format. |
||||
.TP |
||||
.B \-w ", \-\^\-stdio" |
||||
Sets the processing output to be sent to the standard out. |
||||
|
||||
.SH "AUTHOR" |
||||
Matthew W. S. Bell <matthew (at) bells23.org.uk> |
||||
|
||||
.SH "SEE ALSO" |
||||
\fBfaac\fP(1) |
@ -0,0 +1,725 @@ |
||||
/* Getopt for GNU.
|
||||
NOTE: getopt is now part of the C library, so if you don't know what |
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu |
||||
before changing it! |
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 |
||||
Free Software Foundation, Inc. |
||||
|
||||
This program is free software; you can redistribute it and/or modify it |
||||
under the terms of the GNU General Public License as published by the |
||||
Free Software Foundation; either version 2, or (at your option) any |
||||
later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program; if not, write to the Free Software |
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
#include "config.h" |
||||
#endif |
||||
|
||||
#ifndef __STDC__ |
||||
# ifndef const |
||||
# define const |
||||
# endif |
||||
#endif |
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */ |
||||
#ifndef _NO_PROTO |
||||
#define _NO_PROTO |
||||
#endif |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C |
||||
Library, but also included in many other GNU distributions. Compiling |
||||
and linking in this code is a waste when using the GNU C library |
||||
(especially if it is a shared library). Rather than having every GNU |
||||
program understand `configure --with-gnu-libc' and omit the object files, |
||||
it is simpler to just do this in the source for each such file. */ |
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || !__MacOSX__ |
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */ |
||||
#ifdef __GNU_LIBRARY__ |
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */ |
||||
#include <stdlib.h> |
||||
#endif /* GNU C library. */ |
||||
|
||||
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
||||
long-named option. Because this is not POSIX.2 compliant, it is |
||||
being phased out. */ |
||||
/* #define GETOPT_COMPAT */ |
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
but it behaves differently for the user, since it allows the user |
||||
to intersperse the options with the other arguments. |
||||
|
||||
As `getopt' works, it permutes the elements of ARGV so that, |
||||
when it is done, all the options precede everything else. Thus |
||||
all application programs are extended to handle flexible argument order. |
||||
|
||||
Setting the environment variable POSIXLY_CORRECT disables permutation. |
||||
Then the behavior is completely standard. |
||||
|
||||
GNU application programs can use a third alternative mode in which |
||||
they can distinguish the relative order of options and other arguments. */ |
||||
|
||||
#include "getopt.h" |
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument, |
||||
the argument value is returned here. |
||||
Also, when `ordering' is RETURN_IN_ORDER, |
||||
each non-option ARGV-element is returned here. */ |
||||
|
||||
char *optarg = 0; |
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller |
||||
and for communication between successive calls to `getopt'. |
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize. |
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the |
||||
non-option elements that the caller should itself scan. |
||||
|
||||
Otherwise, `optind' communicates from one call to the next |
||||
how much of ARGV has been scanned so far. */ |
||||
|
||||
/* XXX 1003.2 says this must be 1 before any call. */ |
||||
int optind = 0; |
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found. |
||||
This allows us to pick up the scan where we left off. |
||||
|
||||
If this is zero, or a null string, it means resume the scan |
||||
by advancing to the next ARGV-element. */ |
||||
|
||||
static char *nextchar; |
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options. */ |
||||
|
||||
int opterr = 1; |
||||
|
||||
/* Set to an option character which was unrecognized.
|
||||
This must be initialized on some systems to avoid linking in the |
||||
system's own getopt implementation. */ |
||||
|
||||
#define BAD_OPTION '\0' |
||||
int optopt = BAD_OPTION; |
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything, |
||||
the default is REQUIRE_ORDER if the environment variable |
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise. |
||||
|
||||
REQUIRE_ORDER means don't recognize them as options; |
||||
stop option processing when the first non-option is seen. |
||||
This is what Unix does. |
||||
This mode of operation is selected by either setting the environment |
||||
variable POSIXLY_CORRECT, or using `+' as the first character |
||||
of the list of option characters. |
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we scan, |
||||
so that eventually all the non-options are at the end. This allows options |
||||
to be given in any order, even with programs that were not written to |
||||
expect this. |
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were written |
||||
to expect options and other ARGV-elements in any order and that care about |
||||
the ordering of the two. We describe each non-option ARGV-element |
||||
as if it were the argument of an option with character code 1. |
||||
Using `-' as the first character of the list of option characters |
||||
selects this mode of operation. |
||||
|
||||
The special argument `--' forces an end of option-scanning regardless |
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only |
||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */ |
||||
|
||||
static enum |
||||
{ |
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER |
||||
} ordering; |
||||
|
||||
#ifdef __GNU_LIBRARY__ |
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble. |
||||
On some systems, it contains special magic macros that don't work |
||||
in GCC. */ |
||||
#include <string.h> |
||||
#define my_index strchr |
||||
#define my_strlen strlen |
||||
#else |
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */ |
||||
|
||||
#if __STDC__ || defined(PROTO) |
||||
extern char *getenv(const char *name); |
||||
extern int strcmp (const char *s1, const char *s2); |
||||
|
||||
static int my_strlen(const char *s); |
||||
static char *my_index (const char *str, int chr); |
||||
#else |
||||
extern char *getenv (const char *name); |
||||
#endif |
||||
|
||||
static int my_strlen(const char *str) { |
||||
int n = 0; |
||||
while (*str++) |
||||
n++; |
||||
return n; |
||||
} |
||||
|
||||
static char *my_index(const char *str, int chr) { |
||||
while (*str) |
||||
{ |
||||
if (*str == chr) |
||||
return (char *) str; |
||||
str++; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
#endif /* GNU C library. */ |
||||
|
||||
/* Handle permutation of arguments. */ |
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them; |
||||
`last_nonopt' is the index after the last of them. */ |
||||
|
||||
static int first_nonopt; |
||||
static int last_nonopt; |
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt) |
||||
which contains all the non-options that have been skipped so far. |
||||
The other is elements [last_nonopt,optind), which contains all |
||||
the options processed since those non-options were skipped. |
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe |
||||
the new indices of the non-options in ARGV after they are moved. |
||||
|
||||
To perform the swap, we first reverse the order of all elements. So |
||||
all options now come before all non options, but they are in the |
||||
wrong order. So we put back the options and non options in original |
||||
order by reversing them again. For example: |
||||
original input: a b c -x -y |
||||
reverse all: -y -x c b a |
||||
reverse options: -x -y c b a |
||||
reverse non options: -x -y a b c |
||||
*/ |
||||
|
||||
#if __STDC__ || defined(PROTO) |
||||
static void exchange (char **argv); |
||||
#endif |
||||
|
||||
static void exchange (char **argv) { |
||||
char *temp, **first, **last; |
||||
|
||||
/* Reverse all the elements [first_nonopt, optind) */ |
||||
first = &argv[first_nonopt]; |
||||
last = &argv[optind-1]; |
||||
while (first < last) { |
||||
temp = *first; *first = *last; *last = temp; first++; last--; |
||||
} |
||||
/* Put back the options in order */ |
||||
first = &argv[first_nonopt]; |
||||
first_nonopt += (optind - last_nonopt); |
||||
last = &argv[first_nonopt - 1]; |
||||
while (first < last) { |
||||
temp = *first; *first = *last; *last = temp; first++; last--; |
||||
} |
||||
|
||||
/* Put back the non options in order */ |
||||
first = &argv[first_nonopt]; |
||||
last_nonopt = optind; |
||||
last = &argv[last_nonopt-1]; |
||||
while (first < last) { |
||||
temp = *first; *first = *last; *last = temp; first++; last--; |
||||
} |
||||
} |
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING. |
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--", |
||||
then it is an option element. The characters of this element |
||||
(aside from the initial '-') are option characters. If `getopt' |
||||
is called repeatedly, it returns successively each of the option characters |
||||
from each of the option elements. |
||||
|
||||
If `getopt' finds another option character, it returns that character, |
||||
updating `optind' and `nextchar' so that the next call to `getopt' can |
||||
resume the scan with the following option character or ARGV-element. |
||||
|
||||
If there are no more option characters, `getopt' returns `EOF'. |
||||
Then `optind' is the index in ARGV of the first ARGV-element |
||||
that is not an option. (The ARGV-elements have been permuted |
||||
so that those that are not options now come last.) |
||||
|
||||
OPTSTRING is a string containing the legitimate option characters. |
||||
If an option character is seen that is not listed in OPTSTRING, |
||||
return BAD_OPTION after printing an error message. If you set `opterr' to |
||||
zero, the error message is suppressed but we still return BAD_OPTION. |
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg, |
||||
so the following text in the same ARGV-element, or the text of the following |
||||
ARGV-element, is returned in `optarg'. Two colons mean an option that |
||||
wants an optional arg; if there is text in the current ARGV-element, |
||||
it is returned in `optarg', otherwise `optarg' is set to zero. |
||||
|
||||
If OPTSTRING starts with `-' or `+', it requests different methods of |
||||
handling the non-option ARGV-elements. |
||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. |
||||
|
||||
Long-named options begin with `--' instead of `-'. |
||||
Their names may be abbreviated as long as the abbreviation is unique |
||||
or is an exact match for some defined option. If they have an |
||||
argument, it follows the option name in the same ARGV-element, separated |
||||
from the option name by a `=', or else the in next ARGV-element. |
||||
When `getopt' finds a long-named option, it returns 0 if that option's |
||||
`flag' field is nonzero, the value of the option's `val' field |
||||
if the `flag' field is zero. |
||||
|
||||
The elements of ARGV aren't really const, because we permute them. |
||||
But we pretend they're const in the prototype to be compatible |
||||
with other systems. |
||||
|
||||
LONGOPTS is a vector of `struct option' terminated by an |
||||
element containing a name which is zero. |
||||
|
||||
LONGIND returns the index in LONGOPT of the long-named option found. |
||||
It is only valid when a long-named option has been found by the most |
||||
recent call. |
||||
|
||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce |
||||
long-named options. */ |
||||
|
||||
int _getopt_internal(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only) { |
||||
int option_index; |
||||
|
||||
optarg = 0; |
||||
|
||||
/* Initialize the internal data when the first call is made.
|
||||
Start processing options with ARGV-element 1 (since ARGV-element 0 |
||||
is the program name); the sequence of previously skipped |
||||
non-option ARGV-elements is empty. */ |
||||
|
||||
if (optind == 0) |
||||
{ |
||||
first_nonopt = last_nonopt = optind = 1; |
||||
|
||||
nextchar = NULL; |
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */ |
||||
|
||||
if (optstring[0] == '-') |
||||
{ |
||||
ordering = RETURN_IN_ORDER; |
||||
++optstring; |
||||
} |
||||
else if (optstring[0] == '+') |
||||
{ |
||||
ordering = REQUIRE_ORDER; |
||||
++optstring; |
||||
} |
||||
else if (getenv ("POSIXLY_CORRECT") != NULL) |
||||
ordering = REQUIRE_ORDER; |
||||
else |
||||
ordering = PERMUTE; |
||||
} |
||||
|
||||
if (nextchar == NULL || *nextchar == '\0') |
||||
{ |
||||
if (ordering == PERMUTE) |
||||
{ |
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */ |
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind) |
||||
exchange ((char **) argv); |
||||
else if (last_nonopt != optind) |
||||
first_nonopt = optind; |
||||
|
||||
/* Now skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */ |
||||
|
||||
while (optind < argc |
||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0') |
||||
#ifdef GETOPT_COMPAT |
||||
&& (longopts == NULL |
||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0') |
||||
#endif /* GETOPT_COMPAT */ |
||||
) |
||||
optind++; |
||||
last_nonopt = optind; |
||||
} |
||||
|
||||
/* Special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option, |
||||
then exchange with previous non-options as if it were an option, |
||||
then skip everything else like a non-option. */ |
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--")) |
||||
{ |
||||
optind++; |
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind) |
||||
exchange ((char **) argv); |
||||
else if (first_nonopt == last_nonopt) |
||||
first_nonopt = optind; |
||||
last_nonopt = argc; |
||||
|
||||
optind = argc; |
||||
} |
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */ |
||||
|
||||
if (optind == argc) |
||||
{ |
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */ |
||||
if (first_nonopt != last_nonopt) |
||||
optind = first_nonopt; |
||||
return EOF; |
||||
} |
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */ |
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0') |
||||
#ifdef GETOPT_COMPAT |
||||
&& (longopts == NULL |
||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0') |
||||
#endif /* GETOPT_COMPAT */ |
||||
) |
||||
{ |
||||
if (ordering == REQUIRE_ORDER) |
||||
return EOF; |
||||
optarg = argv[optind++]; |
||||
return 1; |
||||
} |
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Start decoding its characters. */ |
||||
|
||||
nextchar = (argv[optind] + 1 |
||||
+ (longopts != NULL && argv[optind][1] == '-')); |
||||
} |
||||
|
||||
if (longopts != NULL |
||||
&& ((argv[optind][0] == '-' |
||||
&& (argv[optind][1] == '-' || long_only)) |
||||
#ifdef GETOPT_COMPAT |
||||
|| argv[optind][0] == '+' |
||||
#endif /* GETOPT_COMPAT */ |
||||
)) |
||||
{ |
||||
const struct option *p; |
||||
char *s = nextchar; |
||||
int exact = 0; |
||||
int ambig = 0; |
||||
const struct option *pfound = NULL; |
||||
int indfound = 0; |
||||
|
||||
while (*s && *s != '=') |
||||
s++; |
||||
|
||||
/* Test all options for either exact match or abbreviated matches. */ |
||||
for (p = longopts, option_index = 0; p->name; |
||||
p++, option_index++) |
||||
if (!strncmp (p->name, nextchar, s - nextchar)) |
||||
{ |
||||
if (s - nextchar == my_strlen (p->name)) |
||||
{ |
||||
/* Exact match found. */ |
||||
pfound = p; |
||||
indfound = option_index; |
||||
exact = 1; |
||||
break; |
||||
} |
||||
else if (pfound == NULL) |
||||
{ |
||||
/* First nonexact match found. */ |
||||
pfound = p; |
||||
indfound = option_index; |
||||
} |
||||
else |
||||
/* Second nonexact match found. */ |
||||
ambig = 1; |
||||
} |
||||
|
||||
if (ambig && !exact) |
||||
{ |
||||
if (opterr) |
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n", |
||||
argv[0], argv[optind]); |
||||
nextchar += my_strlen (nextchar); |
||||
optind++; |
||||
return BAD_OPTION; |
||||
} |
||||
|
||||
if (pfound != NULL) |
||||
{ |
||||
option_index = indfound; |
||||
optind++; |
||||
if (*s) |
||||
{ |
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */ |
||||
if (pfound->has_arg) |
||||
optarg = s + 1; |
||||
else |
||||
{ |
||||
if (opterr) |
||||
{ |
||||
if (argv[optind - 1][1] == '-') |
||||
/* --option */ |
||||
fprintf (stderr, |
||||
"%s: option `--%s' doesn't allow an argument\n", |
||||
argv[0], pfound->name); |
||||
else |
||||
/* +option or -option */ |
||||
fprintf (stderr, |
||||
"%s: option `%c%s' doesn't allow an argument\n", |
||||
argv[0], argv[optind - 1][0], pfound->name); |
||||
} |
||||
nextchar += my_strlen (nextchar); |
||||
return BAD_OPTION; |
||||
} |
||||
} |
||||
else if (pfound->has_arg == 1) |
||||
{ |
||||
if (optind < argc) |
||||
optarg = argv[optind++]; |
||||
else |
||||
{ |
||||
if (opterr) |
||||
fprintf (stderr, "%s: option `%s' requires an argument\n", |
||||
argv[0], argv[optind - 1]); |
||||
nextchar += my_strlen (nextchar); |
||||
return optstring[0] == ':' ? ':' : BAD_OPTION; |
||||
} |
||||
} |
||||
nextchar += my_strlen (nextchar); |
||||
if (longind != NULL) |
||||
*longind = option_index; |
||||
if (pfound->flag) |
||||
{ |
||||
*(pfound->flag) = pfound->val; |
||||
return 0; |
||||
} |
||||
return pfound->val; |
||||
} |
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short |
||||
option, then it's an error. |
||||
Otherwise interpret it as a short option. */ |
||||
if (!long_only || argv[optind][1] == '-' |
||||
#ifdef GETOPT_COMPAT |
||||
|| argv[optind][0] == '+' |
||||
#endif /* GETOPT_COMPAT */ |
||||
|| my_index (optstring, *nextchar) == NULL) |
||||
{ |
||||
if (opterr) |
||||
{ |
||||
if (argv[optind][1] == '-') |
||||
/* --option */ |
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n", |
||||
argv[0], nextchar); |
||||
else |
||||
/* +option or -option */ |
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n", |
||||
argv[0], argv[optind][0], nextchar); |
||||
} |
||||
nextchar = (char *) ""; |
||||
optind++; |
||||
return BAD_OPTION; |
||||
} |
||||
} |
||||
|
||||
/* Look at and handle the next option-character. */ |
||||
|
||||
{ |
||||
char c = *nextchar++; |
||||
char *temp = my_index (optstring, c); |
||||
|
||||
/* Increment `optind' when we start to process its last character. */ |
||||
if (*nextchar == '\0') |
||||
++optind; |
||||
|
||||
if (temp == NULL || c == ':') |
||||
{ |
||||
if (opterr) |
||||
{ |
||||
#if 0 |
||||
if (c < 040 || c >= 0177) |
||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n", |
||||
argv[0], c); |
||||
else |
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); |
||||
#else |
||||
/* 1003.2 specifies the format of this message. */ |
||||
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); |
||||
#endif |
||||
} |
||||
optopt = c; |
||||
return BAD_OPTION; |
||||
} |
||||
if (temp[1] == ':') |
||||
{ |
||||
if (temp[2] == ':') |
||||
{ |
||||
/* This is an option that accepts an argument optionally. */ |
||||
if (*nextchar != '\0') |
||||
{ |
||||
optarg = nextchar; |
||||
optind++; |
||||
} |
||||
else |
||||
optarg = 0; |
||||
nextchar = NULL; |
||||
} |
||||
else |
||||
{ |
||||
/* This is an option that requires an argument. */ |
||||
if (*nextchar != '\0') |
||||
{ |
||||
optarg = nextchar; |
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */ |
||||
optind++; |
||||
} |
||||
else if (optind == argc) |
||||
{ |
||||
if (opterr) |
||||
{ |
||||
#if 0 |
||||
fprintf (stderr, "%s: option `-%c' requires an argument\n", |
||||
argv[0], c); |
||||
#else |
||||
/* 1003.2 specifies the format of this message. */ |
||||
fprintf (stderr, "%s: option requires an argument -- %c\n", |
||||
argv[0], c); |
||||
#endif |
||||
} |
||||
optopt = c; |
||||
if (optstring[0] == ':') |
||||
c = ':'; |
||||
else |
||||
c = BAD_OPTION; |
||||
} |
||||
else |
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */ |
||||
optarg = argv[optind++]; |
||||
nextchar = NULL; |
||||
} |
||||
} |
||||
return c; |
||||
} |
||||
} |
||||
|
||||
int getopt (int argc, char *const *argv, const char *optstring) { |
||||
return _getopt_internal (argc, argv, optstring, |
||||
(const struct option *) 0, |
||||
(int *) 0, |
||||
0); |
||||
} |
||||
|
||||
int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index) { |
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
||||
} |
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */ |
||||
|
||||
#ifdef TEST |
||||
|
||||
/* Compile with -DTEST to make an executable for use in testing
|
||||
the above definition of `getopt'. */ |
||||
|
||||
int |
||||
main (argc, argv) |
||||
int argc; |
||||
char **argv; |
||||
{ |
||||
int c; |
||||
int digit_optind = 0; |
||||
|
||||
while (1) |
||||
{ |
||||
int this_option_optind = optind ? optind : 1; |
||||
|
||||
c = getopt (argc, argv, "abc:d:0123456789"); |
||||
if (c == EOF) |
||||
break; |
||||
|
||||
switch (c) |
||||
{ |
||||
case '0': |
||||
case '1': |
||||
case '2': |
||||
case '3': |
||||
case '4': |
||||
case '5': |
||||
case '6': |
||||
case '7': |
||||
case '8': |
||||
case '9': |
||||
if (digit_optind != 0 && digit_optind != this_option_optind) |
||||
printf ("digits occur in two different argv-elements.\n"); |
||||
digit_optind = this_option_optind; |
||||
printf ("option %c\n", c); |
||||
break; |
||||
|
||||
case 'a': |
||||
printf ("option a\n"); |
||||
break; |
||||
|
||||
case 'b': |
||||
printf ("option b\n"); |
||||
break; |
||||
|
||||
case 'c': |
||||
printf ("option c with value `%s'\n", optarg); |
||||
break; |
||||
|
||||
case BAD_OPTION: |
||||
break; |
||||
|
||||
default: |
||||
printf ("?? getopt returned character code 0%o ??\n", c); |
||||
} |
||||
} |
||||
|
||||
if (optind < argc) |
||||
{ |
||||
printf ("non-option ARGV-elements: "); |
||||
while (optind < argc) |
||||
printf ("%s ", argv[optind++]); |
||||
printf ("\n"); |
||||
} |
||||
|
||||
exit (0); |
||||
} |
||||
|
||||
#endif /* TEST */ |
@ -0,0 +1,130 @@ |
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. |
||||
|
||||
This program is free software; you can redistribute it and/or modify it |
||||
under the terms of the GNU General Public License as published by the |
||||
Free Software Foundation; either version 2, or (at your option) any |
||||
later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program; if not, write to the Free Software |
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
||||
|
||||
#ifndef _GETOPT_H |
||||
#define _GETOPT_H 1 |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#ifndef __MacOSX__ |
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument, |
||||
the argument value is returned here. |
||||
Also, when `ordering' is RETURN_IN_ORDER, |
||||
each non-option ARGV-element is returned here. */ |
||||
|
||||
extern char *optarg; |
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller |
||||
and for communication between successive calls to `getopt'. |
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize. |
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the |
||||
non-option elements that the caller should itself scan. |
||||
|
||||
Otherwise, `optind' communicates from one call to the next |
||||
how much of ARGV has been scanned so far. */ |
||||
|
||||
extern int optind; |
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */ |
||||
|
||||
extern int opterr; |
||||
|
||||
/* Set to an option character which was unrecognized. */ |
||||
|
||||
extern int optopt; |
||||
#endif |
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector |
||||
of `struct option' terminated by an element containing a name which is |
||||
zero. |
||||
|
||||
The field `has_arg' is: |
||||
no_argument (or 0) if the option does not take an argument, |
||||
required_argument (or 1) if the option requires an argument, |
||||
optional_argument (or 2) if the option takes an optional argument. |
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set |
||||
to the value given in the field `val' when the option is found, but |
||||
left unchanged if the option is not found. |
||||
|
||||
To have a long-named option do something other than set an `int' to |
||||
a compiled-in constant, such as set a value from `optarg', set the |
||||
option's `flag' field to zero and its `val' field to a nonzero |
||||
value (the equivalent single-letter option character, if there is |
||||
one). For long options that have a zero `flag' field, `getopt' |
||||
returns the contents of the `val' field. */ |
||||
|
||||
struct option |
||||
{ |
||||
#if __STDC__ |
||||
const char *name; |
||||
#else |
||||
char *name; |
||||
#endif |
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */ |
||||
int has_arg; |
||||
int *flag; |
||||
int val; |
||||
}; |
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */ |
||||
|
||||
#define no_argument 0 |
||||
#define required_argument 1 |
||||
#define optional_argument 2 |
||||
|
||||
//#if __STDC__ || defined(PROTO)
|
||||
#if defined(__GNU_LIBRARY__) |
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation |
||||
errors, only prototype getopt for the GNU C library. */ |
||||
extern int getopt (int argc, char *const *argv, const char *shortopts); |
||||
#endif /* not __GNU_LIBRARY__ */ |
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts, |
||||
const struct option *longopts, int *longind); |
||||
extern int getopt_long_only (int argc, char *const *argv, |
||||
const char *shortopts, |
||||
const struct option *longopts, int *longind); |
||||
|
||||
/* Internal only. Users should not call this directly. */ |
||||
extern int _getopt_internal (int argc, char *const *argv, |
||||
const char *shortopts, |
||||
const struct option *longopts, int *longind, |
||||
int long_only); |
||||
//#else /* not __STDC__ */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts); |
||||
//extern int getopt_long ();
|
||||
//extern int getopt_long_only ();
|
||||
|
||||
//extern int _getopt_internal ();
|
||||
//#endif /* not __STDC__ */
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _GETOPT_H */ |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,78 @@ |
||||
/****************************************************************************
|
||||
MP4 input module |
||||
|
||||
Copyright (C) 2017 Krzysztof Nikiel |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/ |
||||
|
||||
#include <stdint.h> |
||||
|
||||
typedef struct |
||||
{ |
||||
uint32_t len; |
||||
uint32_t offset; |
||||
} frame_info_t; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint32_t firstchunk; |
||||
uint32_t samplesperchunk; |
||||
} slice_info_t; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint32_t ctime, mtime; |
||||
uint32_t samplerate; |
||||
// total sound samples
|
||||
uint32_t samples; |
||||
uint32_t channels; |
||||
// sample depth
|
||||
uint32_t bits; |
||||
// buffer config
|
||||
uint32_t buffersize; |
||||
uint32_t bitratemax; |
||||
uint32_t bitrateavg; |
||||
// frame size / offsets
|
||||
struct |
||||
{ |
||||
frame_info_t *info; |
||||
slice_info_t *map; |
||||
uint32_t nsamples; |
||||
uint32_t nsclices; |
||||
uint32_t current; |
||||
uint32_t maxsize; |
||||
} frame; |
||||
// AudioSpecificConfig data:
|
||||
struct |
||||
{ |
||||
uint8_t buf[10]; |
||||
uint32_t size; |
||||
} asc; |
||||
struct { |
||||
uint32_t size; |
||||
uint8_t *data; |
||||
} bitbuf; |
||||
struct { |
||||
int header; |
||||
int tags; |
||||
} verbose; |
||||
} mp4config_t; |
||||
|
||||
extern mp4config_t mp4config; |
||||
|
||||
int mp4read_open(char *name); |
||||
int mp4read_seek(uint32_t framenum); |
||||
int mp4read_frame(void); |
||||
int mp4read_close(void); |
@ -0,0 +1,172 @@ |
||||
/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
|
||||
File: unicode_support.c |
||||
|
||||
This file was originally part of a patch included with LameXP, |
||||
released under the same license as the original audio tools. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
- Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
- Redistributions in binary form must reproduce the above copyright |
||||
notice, this list of conditions and the following disclaimer in the |
||||
documentation and/or other materials provided with the distribution. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS |
||||
#include <stdio.h> |
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 |
||||
|
||||
#include "unicode_support.h" |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#define WIN32_LEAN_AND_MEAN |
||||
#include <windows.h> |
||||
#include <shellapi.h> |
||||
#include <io.h> |
||||
|
||||
static UINT g_old_output_cp = ((UINT)-1); |
||||
|
||||
static char *utf16_to_utf8(const wchar_t *input) |
||||
{ |
||||
char *Buffer; |
||||
int BuffSize = 0, Result = 0; |
||||
|
||||
BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL); |
||||
Buffer = (char*) malloc(sizeof(char) * BuffSize); |
||||
if(Buffer) |
||||
{ |
||||
Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL); |
||||
} |
||||
|
||||
return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL; |
||||
} |
||||
|
||||
static wchar_t *utf8_to_utf16(const char *input) |
||||
{ |
||||
wchar_t *Buffer; |
||||
int BuffSize = 0, Result = 0; |
||||
|
||||
BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0); |
||||
Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize); |
||||
if(Buffer) |
||||
{ |
||||
Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize); |
||||
} |
||||
|
||||
return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL; |
||||
} |
||||
|
||||
void init_commandline_arguments_utf8(int *argc, char ***argv) |
||||
{ |
||||
int i, nArgs; |
||||
LPWSTR *szArglist; |
||||
|
||||
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); |
||||
|
||||
if(NULL == szArglist) |
||||
{ |
||||
fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n"); |
||||
exit(-1); |
||||
} |
||||
|
||||
*argv = (char**) malloc(sizeof(char*) * nArgs); |
||||
*argc = nArgs; |
||||
|
||||
if(NULL == *argv) |
||||
{ |
||||
fprintf(stderr, "\nFATAL: Malloc failed\n\n"); |
||||
exit(-1); |
||||
} |
||||
|
||||
for(i = 0; i < nArgs; i++) |
||||
{ |
||||
(*argv)[i] = utf16_to_utf8(szArglist[i]); |
||||
if(NULL == (*argv)[i]) |
||||
{ |
||||
fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n"); |
||||
exit(-1); |
||||
} |
||||
} |
||||
|
||||
LocalFree(szArglist); |
||||
} |
||||
|
||||
void free_commandline_arguments_utf8(int *argc, char ***argv) |
||||
{ |
||||
int i = 0; |
||||
|
||||
if(*argv != NULL) |
||||
{ |
||||
for(i = 0; i < *argc; i++) |
||||
{ |
||||
if((*argv)[i] != NULL) |
||||
{ |
||||
free((*argv)[i]); |
||||
(*argv)[i] = NULL; |
||||
} |
||||
} |
||||
free(*argv); |
||||
*argv = NULL; |
||||
} |
||||
} |
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode) |
||||
{ |
||||
FILE *ret = NULL; |
||||
wchar_t *filename_utf16 = utf8_to_utf16(filename); |
||||
wchar_t *mode_utf16 = utf8_to_utf16(mode); |
||||
|
||||
if(filename_utf16 && mode_utf16) |
||||
{ |
||||
ret = _wfopen(filename_utf16, mode_utf16); |
||||
} |
||||
|
||||
if(filename_utf16) free(filename_utf16); |
||||
if(mode_utf16) free(mode_utf16); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
void init_console_utf8(FILE *const stream) |
||||
{ |
||||
if (_isatty(_fileno(stream))) |
||||
{ |
||||
g_old_output_cp = GetConsoleOutputCP(); |
||||
SetConsoleOutputCP(CP_UTF8); |
||||
} |
||||
} |
||||
|
||||
void uninit_console_utf8(void) |
||||
{ |
||||
if(g_old_output_cp != ((UINT)-1)) |
||||
{ |
||||
SetConsoleOutputCP(g_old_output_cp); |
||||
} |
||||
} |
||||
|
||||
#else |
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode) |
||||
{ |
||||
return fopen(filename, mode); |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,44 @@ |
||||
/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
|
||||
File: unicode_support.h |
||||
|
||||
This file was originally part of a patch included with LameXP, |
||||
released under the same license as the original audio tools. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
- Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
- Redistributions in binary form must reproduce the above copyright |
||||
notice, this list of conditions and the following disclaimer in the |
||||
documentation and/or other materials provided with the distribution. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
#ifndef UNICODE_SUPPORT_H_INCLUDED |
||||
#define UNICODE_SUPPORT_H_INCLUDED |
||||
|
||||
#include <stdio.h> |
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 |
||||
void init_commandline_arguments_utf8(int *argc, char ***argv); |
||||
void free_commandline_arguments_utf8(int *argc, char ***argv); |
||||
void init_console_utf8(FILE *const stream); |
||||
void uninit_console_utf8(void); |
||||
#endif |
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode); |
||||
|
||||
#endif //UNICODE_SUPPORT_H_INCLUDED
|
@ -0,0 +1,62 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
**/ |
||||
|
||||
#include <stddef.h> |
||||
#include <stdint.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "neaacdec.h" |
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
||||
long sink = 0; |
||||
|
||||
if (size < 1) return 0; |
||||
unsigned char error_code = *(data++); |
||||
size -= 1; |
||||
|
||||
char* error_message = NeAACDecGetErrorMessage(error_code); |
||||
if (error_message) sink += strlen(error_message); |
||||
|
||||
char* id = NULL; |
||||
char* copyright = NULL; |
||||
sink += NeAACDecGetVersion(&id, ©right); |
||||
sink += strlen(id); |
||||
sink += strlen(copyright); |
||||
|
||||
sink += (long)NeAACDecGetCapabilities(); |
||||
|
||||
unsigned char* non_const_data = (unsigned char *)malloc(size); |
||||
memcpy(non_const_data, data, size); |
||||
mp4AudioSpecificConfig mp4ASC; |
||||
|
||||
NeAACDecAudioSpecificConfig(non_const_data, (unsigned long) size, &mp4ASC); |
||||
free(non_const_data); |
||||
|
||||
return (sink < 0) ? sink : 0; |
||||
} |
@ -0,0 +1,124 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
**/ |
||||
|
||||
#include <fenv.h> |
||||
#include <stddef.h> |
||||
#include <stdint.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "neaacdec.h" |
||||
|
||||
int feenableexcept(int excepts); |
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
||||
size_t preamble = 2 + 2 + 1 + sizeof(NeAACDecConfiguration); |
||||
NeAACDecConfiguration config; |
||||
uint64_t sample_rate; |
||||
unsigned char num_channels; |
||||
NeAACDecConfigurationPtr config_ptr; |
||||
/* feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW); */ |
||||
|
||||
if (size < preamble) return 0; |
||||
size_t len1 = data[0] | (data[1] << 8); |
||||
data += 2; |
||||
size_t len2 = data[0] | (data[1] << 8); |
||||
data += 2; |
||||
uint8_t flags = data[0]; |
||||
data += 1; |
||||
memcpy(&config, data, sizeof(NeAACDecConfiguration)); |
||||
data += sizeof(NeAACDecConfiguration); |
||||
size -= preamble; |
||||
|
||||
if (len1 + len2 > size) return 0; |
||||
size_t len3 = size - len1 - len2; |
||||
int use_init2 = flags & 1; |
||||
int seek_before = flags & 2; |
||||
int seek_between = flags & 4; |
||||
size_t buffer_op = (flags >> 3) & 3; |
||||
int use_drm = flags & 32; |
||||
int drm_channels = (flags >> 5) & 7; |
||||
unsigned long drm_sample_rate = config.defSampleRate; |
||||
int res, ok; |
||||
const size_t kBufferSize[4] = {0, 0, 16, 16384}; |
||||
size_t buffer_size = kBufferSize[buffer_op]; |
||||
void* buffer = buffer_size > 0 ? (unsigned char *)malloc(buffer_size) : NULL; |
||||
|
||||
unsigned char* part1 = (unsigned char *)malloc(len1); |
||||
unsigned char* part2 = (unsigned char *)malloc(len2); |
||||
unsigned char* part3 = (unsigned char *)malloc(len3); |
||||
memcpy(part1, data, len1); |
||||
data += len1; |
||||
memcpy(part2, data, len2); |
||||
data += len2; |
||||
memcpy(part3, data, len3); |
||||
data += len3; |
||||
|
||||
NeAACDecHandle decoder = NeAACDecOpen(); |
||||
ok = NeAACDecSetConfiguration(decoder, &config); |
||||
if (!ok) goto cleanup; |
||||
config_ptr = NeAACDecGetCurrentConfiguration(decoder); |
||||
if (!config_ptr) __builtin_trap(); |
||||
if (use_init2) { |
||||
res = NeAACDecInit2(decoder, part1, len1, &sample_rate, &num_channels); |
||||
} else { |
||||
res = NeAACDecInit(decoder, part1, len1, &sample_rate, &num_channels); |
||||
} |
||||
if (use_drm) { |
||||
#ifdef DRM_SUPPORT |
||||
NeAACDecInitDRM(&decoder, drm_channels, drm_sample_rate); |
||||
#else |
||||
(void)drm_channels; |
||||
(void)drm_sample_rate; |
||||
#endif |
||||
} |
||||
|
||||
if (res != 0) goto cleanup; |
||||
NeAACDecFrameInfo faad_info; |
||||
if (seek_before) { |
||||
NeAACDecPostSeekReset(decoder, 0x1234567); |
||||
} |
||||
NeAACDecDecode(decoder, &faad_info, part2, len2); |
||||
if (seek_between) { |
||||
NeAACDecPostSeekReset(decoder, -0x1234567); |
||||
} |
||||
if (buffer_op == 0) { |
||||
NeAACDecDecode(decoder, &faad_info, part3, len3); |
||||
} else { |
||||
NeAACDecDecode2(decoder, &faad_info, part3, len3, &buffer, buffer_size); |
||||
} |
||||
|
||||
cleanup: |
||||
NeAACDecClose(decoder); |
||||
free(part1); |
||||
free(part2); |
||||
free(part3); |
||||
if (buffer) free(buffer); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,36 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
**/ |
||||
|
||||
/* warn people for update */ |
||||
#pragma message("please update faad2 include filename and function names!") |
||||
|
||||
#define FAAD2_VERSION "@VERSION@" |
||||
|
||||
/* Backwards compatible link */ |
||||
#include "neaacdec.h" |
@ -0,0 +1,262 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: neaacdec.h,v 1.14 2012/03/02 15:29:47 knik Exp $ |
||||
**/ |
||||
|
||||
#ifndef __NEAACDEC_H__ |
||||
#define __NEAACDEC_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif /* __cplusplus */ |
||||
|
||||
|
||||
#if 1 |
||||
/* MACROS FOR BACKWARDS COMPATIBILITY */ |
||||
/* structs */ |
||||
#define faacDecHandle NeAACDecHandle |
||||
#define faacDecConfiguration NeAACDecConfiguration |
||||
#define faacDecConfigurationPtr NeAACDecConfigurationPtr |
||||
#define faacDecFrameInfo NeAACDecFrameInfo |
||||
/* functions */ |
||||
#define faacDecGetErrorMessage NeAACDecGetErrorMessage |
||||
#define faacDecSetConfiguration NeAACDecSetConfiguration |
||||
#define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration |
||||
#define faacDecInit NeAACDecInit |
||||
#define faacDecInit2 NeAACDecInit2 |
||||
#define faacDecInitDRM NeAACDecInitDRM |
||||
#define faacDecPostSeekReset NeAACDecPostSeekReset |
||||
#define faacDecOpen NeAACDecOpen |
||||
#define faacDecClose NeAACDecClose |
||||
#define faacDecDecode NeAACDecDecode |
||||
#define AudioSpecificConfig NeAACDecAudioSpecificConfig |
||||
#endif |
||||
|
||||
|
||||
#ifdef _WIN32 |
||||
#pragma pack(push, 8) |
||||
#define NEAACDECAPI __declspec(dllexport) |
||||
#elif defined(__GNUC__) && __GNUC__ >= 4 |
||||
#define NEAACDECAPI __attribute__((visibility("default"))) |
||||
#else |
||||
#define NEAACDECAPI |
||||
#endif |
||||
|
||||
#ifndef FAAD2_VERSION |
||||
#define FAAD2_VERSION "unknown" |
||||
#endif |
||||
|
||||
/* object types for AAC */ |
||||
#define MAIN 1 |
||||
#define LC 2 |
||||
#define SSR 3 |
||||
#define LTP 4 |
||||
#define HE_AAC 5 |
||||
#define ER_LC 17 |
||||
#define ER_LTP 19 |
||||
#define LD 23 |
||||
#define DRM_ER_LC 27 /* special object type for DRM */ |
||||
|
||||
/* header types */ |
||||
#define RAW 0 |
||||
#define ADIF 1 |
||||
#define ADTS 2 |
||||
#define LATM 3 |
||||
|
||||
/* SBR signalling */ |
||||
#define NO_SBR 0 |
||||
#define SBR_UPSAMPLED 1 |
||||
#define SBR_DOWNSAMPLED 2 |
||||
#define NO_SBR_UPSAMPLED 3 |
||||
|
||||
/* library output formats */ |
||||
#define FAAD_FMT_16BIT 1 |
||||
#define FAAD_FMT_24BIT 2 |
||||
#define FAAD_FMT_32BIT 3 |
||||
#define FAAD_FMT_FLOAT 4 |
||||
#define FAAD_FMT_FIXED FAAD_FMT_FLOAT |
||||
#define FAAD_FMT_DOUBLE 5 |
||||
|
||||
/* Capabilities */ |
||||
#define LC_DEC_CAP (1<<0) /* Can decode LC */ |
||||
#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */ |
||||
#define LTP_DEC_CAP (1<<2) /* Can decode LTP */ |
||||
#define LD_DEC_CAP (1<<3) /* Can decode LD */ |
||||
#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */ |
||||
#define FIXED_POINT_CAP (1<<5) /* Fixed point */ |
||||
|
||||
/* Channel definitions */ |
||||
#define FRONT_CHANNEL_CENTER (1) |
||||
#define FRONT_CHANNEL_LEFT (2) |
||||
#define FRONT_CHANNEL_RIGHT (3) |
||||
#define SIDE_CHANNEL_LEFT (4) |
||||
#define SIDE_CHANNEL_RIGHT (5) |
||||
#define BACK_CHANNEL_LEFT (6) |
||||
#define BACK_CHANNEL_RIGHT (7) |
||||
#define BACK_CHANNEL_CENTER (8) |
||||
#define LFE_CHANNEL (9) |
||||
#define UNKNOWN_CHANNEL (0) |
||||
|
||||
/* DRM channel definitions */ |
||||
#define DRMCH_MONO 1 |
||||
#define DRMCH_STEREO 2 |
||||
#define DRMCH_SBR_MONO 3 |
||||
#define DRMCH_SBR_STEREO 4 |
||||
#define DRMCH_SBR_PS_STEREO 5 |
||||
|
||||
|
||||
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
|
||||
so at least so much bytes per channel should be available in this stream */ |
||||
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ |
||||
|
||||
|
||||
typedef void *NeAACDecHandle; |
||||
|
||||
typedef struct mp4AudioSpecificConfig |
||||
{ |
||||
/* Audio Specific Info */ |
||||
unsigned char objectTypeIndex; |
||||
unsigned char samplingFrequencyIndex; |
||||
unsigned long samplingFrequency; |
||||
unsigned char channelsConfiguration; |
||||
|
||||
/* GA Specific Info */ |
||||
unsigned char frameLengthFlag; |
||||
unsigned char dependsOnCoreCoder; |
||||
unsigned short coreCoderDelay; |
||||
unsigned char extensionFlag; |
||||
unsigned char aacSectionDataResilienceFlag; |
||||
unsigned char aacScalefactorDataResilienceFlag; |
||||
unsigned char aacSpectralDataResilienceFlag; |
||||
unsigned char epConfig; |
||||
|
||||
char sbr_present_flag; |
||||
char forceUpSampling; |
||||
char downSampledSBR; |
||||
} mp4AudioSpecificConfig; |
||||
|
||||
typedef struct NeAACDecConfiguration |
||||
{ |
||||
unsigned char defObjectType; |
||||
unsigned long defSampleRate; |
||||
unsigned char outputFormat; |
||||
unsigned char downMatrix; |
||||
unsigned char useOldADTSFormat; |
||||
unsigned char dontUpSampleImplicitSBR; |
||||
} NeAACDecConfiguration, *NeAACDecConfigurationPtr; |
||||
|
||||
typedef struct NeAACDecFrameInfo |
||||
{ |
||||
unsigned long bytesconsumed; |
||||
unsigned long samples; |
||||
unsigned char channels; |
||||
unsigned char error; |
||||
unsigned long samplerate; |
||||
|
||||
/* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */ |
||||
unsigned char sbr; |
||||
|
||||
/* MPEG-4 ObjectType */ |
||||
unsigned char object_type; |
||||
|
||||
/* AAC header type; MP4 will be signalled as RAW also */ |
||||
unsigned char header_type; |
||||
|
||||
/* multichannel configuration */ |
||||
unsigned char num_front_channels; |
||||
unsigned char num_side_channels; |
||||
unsigned char num_back_channels; |
||||
unsigned char num_lfe_channels; |
||||
unsigned char channel_position[64]; |
||||
|
||||
/* PS: 0: off, 1: on */ |
||||
unsigned char ps; |
||||
} NeAACDecFrameInfo; |
||||
|
||||
NEAACDECAPI char* NeAACDecGetErrorMessage(unsigned char errcode); |
||||
|
||||
NEAACDECAPI unsigned long NeAACDecGetCapabilities(void); |
||||
|
||||
NEAACDECAPI NeAACDecHandle NeAACDecOpen(void); |
||||
|
||||
NEAACDECAPI NeAACDecConfigurationPtr NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); |
||||
|
||||
NEAACDECAPI unsigned char NeAACDecSetConfiguration(NeAACDecHandle hDecoder, |
||||
NeAACDecConfigurationPtr config); |
||||
|
||||
/* Init the library based on info from the AAC file (ADTS/ADIF) */ |
||||
NEAACDECAPI long NeAACDecInit(NeAACDecHandle hDecoder, |
||||
unsigned char *buffer, |
||||
unsigned long buffer_size, |
||||
unsigned long *samplerate, |
||||
unsigned char *channels); |
||||
|
||||
/* Init the library using a DecoderSpecificInfo */ |
||||
NEAACDECAPI char NeAACDecInit2(NeAACDecHandle hDecoder, |
||||
unsigned char *pBuffer, |
||||
unsigned long SizeOfDecoderSpecificInfo, |
||||
unsigned long *samplerate, |
||||
unsigned char *channels); |
||||
|
||||
/* Init the library for DRM */ |
||||
NEAACDECAPI char NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate, |
||||
unsigned char channels); |
||||
|
||||
NEAACDECAPI void NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame); |
||||
|
||||
NEAACDECAPI void NeAACDecClose(NeAACDecHandle hDecoder); |
||||
|
||||
NEAACDECAPI void* NeAACDecDecode(NeAACDecHandle hDecoder, |
||||
NeAACDecFrameInfo *hInfo, |
||||
unsigned char *buffer, |
||||
unsigned long buffer_size); |
||||
|
||||
NEAACDECAPI void* NeAACDecDecode2(NeAACDecHandle hDecoder, |
||||
NeAACDecFrameInfo *hInfo, |
||||
unsigned char *buffer, |
||||
unsigned long buffer_size, |
||||
void **sample_buffer, |
||||
unsigned long sample_buffer_size); |
||||
|
||||
NEAACDECAPI char NeAACDecAudioSpecificConfig(unsigned char *pBuffer, |
||||
unsigned long buffer_size, |
||||
mp4AudioSpecificConfig *mp4ASC); |
||||
|
||||
/* Get version and copyright strings */ |
||||
NEAACDECAPI int NeAACDecGetVersion(char **faad_id_string, |
||||
char **faad_copyright_string); |
||||
|
||||
#ifdef _WIN32 |
||||
#pragma pack(pop) |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif /* __cplusplus */ |
||||
|
||||
#endif |
@ -0,0 +1,52 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __ANALYSIS_H__ |
||||
#define __ANALYSIS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
#ifdef ANALYSIS |
||||
#define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg |
||||
#define DEBUGVAR(A,B,C) ,A,B,C |
||||
extern uint16_t dbg_count; |
||||
#else |
||||
#define DEBUGDEC |
||||
#define DEBUGVAR(A,B,C) |
||||
#endif |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,292 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: bits.c,v 1.44 2007/11/01 12:33:29 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#include "bits.h" |
||||
|
||||
/* reads only n bytes from the stream instead of the standard 4 */ |
||||
static /*INLINE*/ uint32_t getdword_n(void *mem, int n) |
||||
{ |
||||
uint8_t* m8 = (uint8_t*)mem; |
||||
switch (n) |
||||
{ |
||||
case 3: |
||||
return ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24); |
||||
case 2: |
||||
return ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24); |
||||
case 1: |
||||
return (uint32_t)m8[0] << 24; |
||||
default: |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
/* initialize buffer, call once before first getbits or showbits */ |
||||
void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) |
||||
{ |
||||
uint32_t tmp; |
||||
|
||||
if (ld == NULL) |
||||
return; |
||||
|
||||
if (buffer_size == 0 || _buffer == NULL) |
||||
{ |
||||
ld->error = 1; |
||||
return; |
||||
} |
||||
|
||||
ld->buffer = _buffer; |
||||
|
||||
ld->buffer_size = buffer_size; |
||||
ld->bytes_left = buffer_size; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword((uint32_t*)ld->buffer); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufa = tmp; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword((uint32_t*)ld->buffer + 1); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufb = tmp; |
||||
|
||||
ld->start = (uint32_t*)ld->buffer; |
||||
ld->tail = ((uint32_t*)ld->buffer + 2); |
||||
|
||||
ld->bits_left = 32; |
||||
|
||||
ld->error = 0; |
||||
} |
||||
|
||||
void faad_endbits(bitfile *ld) |
||||
{ |
||||
(void)ld; |
||||
} |
||||
|
||||
uint32_t faad_get_processed_bits(bitfile *ld) |
||||
{ |
||||
return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left)); |
||||
} |
||||
|
||||
uint8_t faad_byte_align(bitfile *ld) |
||||
{ |
||||
int remainder = (32 - ld->bits_left) & 0x7; |
||||
|
||||
if (remainder) |
||||
{ |
||||
faad_flushbits(ld, 8 - remainder); |
||||
return (uint8_t)(8 - remainder); |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
void faad_flushbits_ex(bitfile *ld, uint32_t bits) |
||||
{ |
||||
uint32_t tmp; |
||||
|
||||
ld->bufa = ld->bufb; |
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword(ld->tail); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n(ld->tail, ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufb = tmp; |
||||
ld->tail++; |
||||
ld->bits_left += (32 - bits); |
||||
//ld->bytes_left -= 4;
|
||||
// if (ld->bytes_left == 0)
|
||||
// ld->no_more_reading = 1;
|
||||
// if (ld->bytes_left < 0)
|
||||
// ld->error = 1;
|
||||
} |
||||
|
||||
#ifdef DRM |
||||
/* rewind to beginning */ |
||||
void faad_rewindbits(bitfile *ld) |
||||
{ |
||||
uint32_t tmp; |
||||
|
||||
ld->bytes_left = ld->buffer_size; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword((uint32_t*)&ld->start[0]); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n((uint32_t*)&ld->start[0], ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufa = tmp; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword((uint32_t*)&ld->start[1]); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n((uint32_t*)&ld->start[1], ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufb = tmp; |
||||
|
||||
ld->bits_left = 32; |
||||
ld->tail = &ld->start[2]; |
||||
} |
||||
#endif |
||||
|
||||
/* reset to a certain point */ |
||||
void faad_resetbits(bitfile *ld, uint32_t bits) |
||||
{ |
||||
uint32_t tmp; |
||||
uint32_t words = bits >> 5; |
||||
uint32_t remainder = bits & 0x1F; |
||||
|
||||
if (ld->buffer_size < words * 4) |
||||
ld->bytes_left = 0; |
||||
else |
||||
ld->bytes_left = ld->buffer_size - words*4; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword(&ld->start[words]); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n(&ld->start[words], ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufa = tmp; |
||||
|
||||
if (ld->bytes_left >= 4) |
||||
{ |
||||
tmp = getdword(&ld->start[words+1]); |
||||
ld->bytes_left -= 4; |
||||
} else { |
||||
tmp = getdword_n(&ld->start[words+1], ld->bytes_left); |
||||
ld->bytes_left = 0; |
||||
} |
||||
ld->bufb = tmp; |
||||
|
||||
ld->bits_left = 32 - remainder; |
||||
ld->tail = &ld->start[words+2]; |
||||
|
||||
/* recheck for reading too many bytes */ |
||||
ld->error = 0; |
||||
// if (ld->bytes_left == 0)
|
||||
// ld->no_more_reading = 1;
|
||||
// if (ld->bytes_left < 0)
|
||||
// ld->error = 1;
|
||||
} |
||||
|
||||
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits |
||||
DEBUGDEC) |
||||
{ |
||||
int i; |
||||
unsigned int temp; |
||||
int bytes = bits >> 3; |
||||
int remainder = bits & 0x7; |
||||
|
||||
uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); |
||||
|
||||
for (i = 0; i < bytes; i++) |
||||
{ |
||||
buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg)); |
||||
} |
||||
|
||||
if (remainder) |
||||
{ |
||||
temp = faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); |
||||
|
||||
buffer[bytes] = (uint8_t)temp; |
||||
} |
||||
|
||||
return buffer; |
||||
} |
||||
|
||||
#ifdef DRM |
||||
/* return the original data buffer */ |
||||
void *faad_origbitbuffer(bitfile *ld) |
||||
{ |
||||
return (void*)ld->start; |
||||
} |
||||
|
||||
/* return the original data buffer size */ |
||||
uint32_t faad_origbitbuffer_size(bitfile *ld) |
||||
{ |
||||
return ld->buffer_size; |
||||
} |
||||
#endif |
||||
|
||||
#if 0 |
||||
/* reversed bit reading routines, used for RVLC and HCR */ |
||||
void faad_initbits_rev(bitfile *ld, void *buffer, |
||||
uint32_t bits_in_buffer) |
||||
{ |
||||
uint32_t tmp; |
||||
int32_t index; |
||||
|
||||
ld->buffer_size = bit2byte(bits_in_buffer); |
||||
|
||||
index = (bits_in_buffer+31)/32 - 1; |
||||
|
||||
ld->start = (uint32_t*)buffer + index - 2; |
||||
|
||||
tmp = getdword((uint32_t*)buffer + index); |
||||
ld->bufa = tmp; |
||||
|
||||
tmp = getdword((uint32_t*)buffer + index - 1); |
||||
ld->bufb = tmp; |
||||
|
||||
ld->tail = (uint32_t*)buffer + index; |
||||
|
||||
ld->bits_left = bits_in_buffer % 32; |
||||
if (ld->bits_left == 0) |
||||
ld->bits_left = 32; |
||||
|
||||
ld->bytes_left = ld->buffer_size; |
||||
ld->error = 0; |
||||
} |
||||
#endif |
||||
|
||||
/* EOF */ |
@ -0,0 +1,422 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: bits.h,v 1.45 2007/11/01 12:33:29 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __BITS_H__ |
||||
#define __BITS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "analysis.h" |
||||
#ifdef ANALYSIS |
||||
#include <stdio.h> |
||||
#endif |
||||
|
||||
#define BYTE_NUMBIT 8 |
||||
#define BYTE_NUMBIT_LD 3 |
||||
//#define bit2byte(a) ((a+7)/BYTE_NUMBIT)
|
||||
#define bit2byte(a) ((a+7)>>BYTE_NUMBIT_LD) |
||||
|
||||
typedef struct _bitfile |
||||
{ |
||||
const void *buffer; |
||||
uint32_t *tail; |
||||
uint32_t *start; |
||||
/* bit input */ |
||||
uint32_t bufa; |
||||
uint32_t bufb; |
||||
uint32_t bits_left; |
||||
uint32_t buffer_size; /* size of the buffer in bytes */ |
||||
uint32_t bytes_left; |
||||
uint8_t error; |
||||
} bitfile; |
||||
|
||||
|
||||
#if 0 |
||||
static uint32_t const bitmask[] = { |
||||
0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, |
||||
0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, |
||||
0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, |
||||
0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, |
||||
0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF |
||||
/* added bitmask 32, correct?!?!?! */ |
||||
, 0xFFFFFFFF |
||||
}; |
||||
#endif |
||||
|
||||
void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); |
||||
void faad_endbits(bitfile *ld); |
||||
#if 0 |
||||
void faad_initbits_rev(bitfile *ld, void *buffer, |
||||
uint32_t bits_in_buffer); |
||||
#endif |
||||
uint8_t faad_byte_align(bitfile *ld); |
||||
uint32_t faad_get_processed_bits(bitfile *ld); |
||||
void faad_flushbits_ex(bitfile *ld, uint32_t bits); |
||||
#ifdef DRM |
||||
void faad_rewindbits(bitfile *ld); |
||||
#endif |
||||
void faad_resetbits(bitfile *ld, uint32_t bits); |
||||
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits |
||||
DEBUGDEC); |
||||
#ifdef DRM |
||||
void *faad_origbitbuffer(bitfile *ld); |
||||
uint32_t faad_origbitbuffer_size(bitfile *ld); |
||||
#endif |
||||
|
||||
/* circumvent memory alignment errors on ARM */ |
||||
static INLINE uint32_t getdword(void *mem) |
||||
{ |
||||
uint8_t* m8 = (uint8_t*)mem; |
||||
return (uint32_t)m8[3] | ((uint32_t)m8[2] << 8) | ((uint32_t)m8[1] << 16) | ((uint32_t)m8[0] << 24); |
||||
} |
||||
|
||||
static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits) |
||||
{ |
||||
if (bits <= ld->bits_left) |
||||
{ |
||||
//return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
|
||||
return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits); |
||||
} |
||||
|
||||
bits -= ld->bits_left; |
||||
//return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
|
||||
return ((ld->bufa & ((1u<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits)); |
||||
} |
||||
|
||||
static INLINE void faad_flushbits(bitfile *ld, uint32_t bits) |
||||
{ |
||||
/* do nothing if error */ |
||||
if (ld->error != 0) |
||||
return; |
||||
|
||||
if (bits < ld->bits_left) |
||||
{ |
||||
ld->bits_left -= bits; |
||||
} else { |
||||
faad_flushbits_ex(ld, bits); |
||||
} |
||||
} |
||||
|
||||
/* return next n bits (right adjusted) */ |
||||
static /*INLINE*/ uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC) |
||||
{ |
||||
uint32_t ret; |
||||
|
||||
if (n == 0) |
||||
return 0; |
||||
|
||||
ret = faad_showbits(ld, n); |
||||
faad_flushbits(ld, n); |
||||
|
||||
#ifdef ANALYSIS |
||||
if (print) |
||||
fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); |
||||
#endif |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) |
||||
{ |
||||
uint8_t r; |
||||
|
||||
if (ld->bits_left > 0) |
||||
{ |
||||
ld->bits_left--; |
||||
r = (uint8_t)((ld->bufa >> ld->bits_left) & 1); |
||||
return r; |
||||
} |
||||
|
||||
/* bits_left == 0 */ |
||||
#if 0 |
||||
r = (uint8_t)(ld->bufb >> 31); |
||||
faad_flushbits_ex(ld, 1); |
||||
#else |
||||
r = (uint8_t)faad_getbits(ld, 1); |
||||
#endif |
||||
return r; |
||||
} |
||||
|
||||
#if 0 |
||||
/* reversed bitreading routines */ |
||||
static INLINE uint32_t faad_showbits_rev(bitfile *ld, uint32_t bits) |
||||
{ |
||||
uint8_t i; |
||||
uint32_t B = 0; |
||||
|
||||
if (bits <= ld->bits_left) |
||||
{ |
||||
for (i = 0; i < bits; i++) |
||||
{ |
||||
if (ld->bufa & (1u << (i + (32 - ld->bits_left)))) |
||||
B |= (1u << (bits - i - 1)); |
||||
} |
||||
return B; |
||||
} else { |
||||
for (i = 0; i < ld->bits_left; i++) |
||||
{ |
||||
if (ld->bufa & (1u << (i + (32 - ld->bits_left)))) |
||||
B |= (1u << (bits - i - 1)); |
||||
} |
||||
for (i = 0; i < bits - ld->bits_left; i++) |
||||
{ |
||||
if (ld->bufb & (1u << (i + (32-ld->bits_left)))) |
||||
B |= (1u << (bits - ld->bits_left - i - 1)); |
||||
} |
||||
return B; |
||||
} |
||||
} |
||||
|
||||
static INLINE void faad_flushbits_rev(bitfile *ld, uint32_t bits) |
||||
{ |
||||
/* do nothing if error */ |
||||
if (ld->error != 0) |
||||
return; |
||||
|
||||
if (bits < ld->bits_left) |
||||
{ |
||||
ld->bits_left -= bits; |
||||
} else { |
||||
uint32_t tmp; |
||||
|
||||
ld->bufa = ld->bufb; |
||||
tmp = getdword(ld->start); |
||||
ld->bufb = tmp; |
||||
ld->start--; |
||||
ld->bits_left += (32 - bits); |
||||
|
||||
if (ld->bytes_left < 4) |
||||
{ |
||||
ld->error = 1; |
||||
ld->bytes_left = 0; |
||||
} else { |
||||
ld->bytes_left -= 4; |
||||
} |
||||
// if (ld->bytes_left == 0)
|
||||
// ld->no_more_reading = 1;
|
||||
} |
||||
} |
||||
|
||||
static /*INLINE*/ uint32_t faad_getbits_rev(bitfile *ld, uint32_t n |
||||
DEBUGDEC) |
||||
{ |
||||
uint32_t ret; |
||||
|
||||
if (n == 0) |
||||
return 0; |
||||
|
||||
ret = faad_showbits_rev(ld, n); |
||||
faad_flushbits_rev(ld, n); |
||||
|
||||
#ifdef ANALYSIS |
||||
if (print) |
||||
fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); |
||||
#endif |
||||
|
||||
return ret; |
||||
} |
||||
#endif |
||||
|
||||
#ifdef DRM |
||||
/* CRC lookup table for G8 polynome in DRM standard */ |
||||
static const uint8_t crc_table_G8[256] = { |
||||
0x0, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53, |
||||
0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb, |
||||
0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e, |
||||
0x25, 0x38, 0x1f, 0x2, 0x51, 0x4c, 0x6b, 0x76, |
||||
0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4, |
||||
0x6f, 0x72, 0x55, 0x48, 0x1b, 0x6, 0x21, 0x3c, |
||||
0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x4, 0x19, |
||||
0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1, |
||||
0x13, 0xe, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40, |
||||
0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8, |
||||
0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d, |
||||
0x36, 0x2b, 0xc, 0x11, 0x42, 0x5f, 0x78, 0x65, |
||||
0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7, |
||||
0x7c, 0x61, 0x46, 0x5b, 0x8, 0x15, 0x32, 0x2f, |
||||
0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0xa, |
||||
0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2, |
||||
0x26, 0x3b, 0x1c, 0x1, 0x52, 0x4f, 0x68, 0x75, |
||||
0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d, |
||||
0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8, |
||||
0x3, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50, |
||||
0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2, |
||||
0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x7, 0x1a, |
||||
0x6c, 0x71, 0x56, 0x4b, 0x18, 0x5, 0x22, 0x3f, |
||||
0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7, |
||||
0x35, 0x28, 0xf, 0x12, 0x41, 0x5c, 0x7b, 0x66, |
||||
0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e, |
||||
0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab, |
||||
0x10, 0xd, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43, |
||||
0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1, |
||||
0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x9, |
||||
0x7f, 0x62, 0x45, 0x58, 0xb, 0x16, 0x31, 0x2c, |
||||
0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4, |
||||
}; |
||||
|
||||
static INLINE uint8_t faad_check_CRC(bitfile *ld, uint16_t len) |
||||
{ |
||||
int bytes, rem; |
||||
unsigned int CRC; |
||||
unsigned int r=255; /* Initialize to all ones */ |
||||
|
||||
/* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */ |
||||
#define GPOLY 0435 |
||||
|
||||
faad_rewindbits(ld); |
||||
|
||||
CRC = (unsigned int) ~faad_getbits(ld, 8 |
||||
DEBUGVAR(1,999,"faad_check_CRC(): CRC")) & 0xFF; /* CRC is stored inverted */ |
||||
|
||||
bytes = len >> 3; |
||||
rem = len & 0x7; |
||||
|
||||
for (; bytes > 0; bytes--) |
||||
{ |
||||
r = crc_table_G8[( r ^ faad_getbits(ld, 8 DEBUGVAR(1,998,"")) ) & 0xFF]; |
||||
} |
||||
for (; rem > 0; rem--) |
||||
{ |
||||
r = ( (r << 1) ^ (( ( faad_get1bit(ld |
||||
DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF; |
||||
} |
||||
|
||||
if (r != CRC) |
||||
// if (0)
|
||||
{ |
||||
return 28; |
||||
} else { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
#ifdef SBR_DEC |
||||
static uint8_t tabFlipbits[256] = { |
||||
0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240, |
||||
8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248, |
||||
4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244, |
||||
12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252, |
||||
2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242, |
||||
10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250, |
||||
6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246, |
||||
14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254, |
||||
1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241, |
||||
9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249, |
||||
5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245, |
||||
13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253, |
||||
3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243, |
||||
11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251, |
||||
7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247, |
||||
15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255 |
||||
}; |
||||
static INLINE uint8_t reverse_byte(uint8_t b) |
||||
{ |
||||
return tabFlipbits[b]; |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
#ifdef ERROR_RESILIENCE |
||||
|
||||
/* Modified bit reading functions for HCR */ |
||||
|
||||
typedef struct |
||||
{ |
||||
/* bit input */ |
||||
uint32_t bufa; |
||||
uint32_t bufb; |
||||
int8_t len; |
||||
} bits_t; |
||||
|
||||
/* PRECONDITION: bits <= 32 */ |
||||
static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits) |
||||
{ |
||||
uint32_t mask; |
||||
int8_t tail; |
||||
if (bits == 0) return 0; |
||||
if (ld->len == 0) return 0; |
||||
tail = ld->len - bits; |
||||
mask = 0xFFFFFFFF >> (32 - bits); |
||||
if (ld->len <= 32) |
||||
{ |
||||
/* huffman_spectral_data_2 might request more than available (tail < 0),
|
||||
pad with zeroes then. */ |
||||
if (tail >= 0) |
||||
return (ld->bufa >> tail) & mask; /* tail is 0..31 */ |
||||
else |
||||
return (ld->bufa << -tail) & mask; /* -tail is 1..31 */ |
||||
} else { |
||||
/* tail is 1..63 */ |
||||
if (tail < 32) |
||||
return ((ld->bufb << (32 - tail)) | (ld->bufa >> tail)) & mask; |
||||
else |
||||
return (ld->bufb >> (tail - 32)) & mask; |
||||
} |
||||
} |
||||
|
||||
/* return 1 if position is outside of buffer, 0 otherwise */ |
||||
static INLINE int8_t flushbits_hcr( bits_t *ld, uint8_t bits) |
||||
{ |
||||
ld->len -= bits; |
||||
|
||||
if (ld->len <0) |
||||
{ |
||||
ld->len = 0; |
||||
return 1; |
||||
} else { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
static INLINE int8_t getbits_hcr(bits_t *ld, uint8_t n, uint32_t *result) |
||||
{ |
||||
*result = showbits_hcr(ld, n); |
||||
return flushbits_hcr(ld, n); |
||||
} |
||||
|
||||
static INLINE int8_t get1bit_hcr(bits_t *ld, uint8_t *result) |
||||
{ |
||||
uint32_t res; |
||||
int8_t ret; |
||||
|
||||
ret = getbits_hcr(ld, 1, &res); |
||||
*result = (int8_t)(res & 1); |
||||
return ret; |
||||
} |
||||
|
||||
#endif |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __CFFT_H__ |
||||
#define __CFFT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
typedef struct |
||||
{ |
||||
uint16_t n; |
||||
uint16_t ifac[15]; |
||||
complex_t *work; |
||||
complex_t *tab; |
||||
} cfft_info; |
||||
|
||||
|
||||
void cfftf(cfft_info *cfft, complex_t *c); |
||||
void cfftb(cfft_info *cfft, complex_t *c); |
||||
cfft_info *cffti(uint16_t n); |
||||
void cfftu(cfft_info *cfft); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,145 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __HCB_H__ |
||||
#define __HCB_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/*
|
||||
* Optimal huffman decoding for AAC taken from: |
||||
* "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by |
||||
* VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO |
||||
* AES paper 5436 |
||||
* |
||||
* 2 methods are used for huffman decoding: |
||||
* - binary search |
||||
* - 2-step table lookup |
||||
* |
||||
* The choice of the "optimal" method is based on the fact that if the |
||||
* memory size for the Two-step is exorbitantly high then the decision |
||||
* is Binary search for that codebook. However, for marginally more memory |
||||
* size, if Twostep outperforms even the best case of Binary then the |
||||
* decision is Two-step for that codebook. |
||||
* |
||||
* The following methods are used for the different tables. |
||||
* codebook "optimal" method |
||||
* HCB_1 2-Step |
||||
* HCB_2 2-Step |
||||
* HCB_3 Binary |
||||
* HCB_4 2-Step |
||||
* HCB_5 Binary |
||||
* HCB_6 2-Step |
||||
* HCB_7 Binary |
||||
* HCB_8 2-Step |
||||
* HCB_9 Binary |
||||
* HCB_10 2-Step |
||||
* HCB_11 2-Step |
||||
* HCB_SF Binary |
||||
* |
||||
*/ |
||||
|
||||
|
||||
#define ZERO_HCB 0 |
||||
#define FIRST_PAIR_HCB 5 |
||||
#define ESC_HCB 11 |
||||
#define QUAD_LEN 4 |
||||
#define PAIR_LEN 2 |
||||
#define NOISE_HCB 13 |
||||
#define INTENSITY_HCB2 14 |
||||
#define INTENSITY_HCB 15 |
||||
|
||||
/* 1st step table */ |
||||
typedef struct |
||||
{ |
||||
uint8_t offset; |
||||
uint8_t extra_bits; |
||||
} hcb; |
||||
|
||||
/* 2nd step table with quadruple data */ |
||||
typedef struct |
||||
{ |
||||
uint8_t bits; |
||||
int8_t x; |
||||
int8_t y; |
||||
} hcb_2_pair; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint8_t bits; |
||||
int8_t x; |
||||
int8_t y; |
||||
int8_t v; |
||||
int8_t w; |
||||
} hcb_2_quad; |
||||
|
||||
/* binary search table */ |
||||
typedef struct |
||||
{ |
||||
uint8_t is_leaf; |
||||
int8_t data[4]; |
||||
} hcb_bin_quad; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint8_t is_leaf; |
||||
int8_t data[2]; |
||||
} hcb_bin_pair; |
||||
|
||||
hcb *hcb_table[]; |
||||
hcb_2_quad *hcb_2_quad_table[]; |
||||
hcb_2_pair *hcb_2_pair_table[]; |
||||
hcb_bin_pair *hcb_bin_table[]; |
||||
uint8_t hcbN[]; |
||||
uint8_t unsigned_cb[]; |
||||
int hcb_2_quad_table_size[]; |
||||
int hcb_2_pair_table_size[]; |
||||
int hcb_bin_table_size[]; |
||||
|
||||
#include "codebook/hcb_1.h" |
||||
#include "codebook/hcb_2.h" |
||||
#include "codebook/hcb_3.h" |
||||
#include "codebook/hcb_4.h" |
||||
#include "codebook/hcb_5.h" |
||||
#include "codebook/hcb_6.h" |
||||
#include "codebook/hcb_7.h" |
||||
#include "codebook/hcb_8.h" |
||||
#include "codebook/hcb_9.h" |
||||
#include "codebook/hcb_10.h" |
||||
#include "codebook/hcb_11.h" |
||||
#include "codebook/hcb_sf.h" |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,186 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_1.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_1 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb1_1[] = { |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 10000 */ 1, 0 }, |
||||
{ /* 10001 */ 2, 0 }, |
||||
{ /* 10010 */ 3, 0 }, |
||||
{ /* 10011 */ 4, 0 }, |
||||
{ /* 10100 */ 5, 0 }, |
||||
{ /* 10101 */ 6, 0 }, |
||||
{ /* 10110 */ 7, 0 }, |
||||
{ /* 10111 */ 8, 0 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ /* 11000 */ 9, 2 }, |
||||
{ /* 11001 */ 13, 2 }, |
||||
{ /* 11010 */ 17, 2 }, |
||||
{ /* 11011 */ 21, 2 }, |
||||
{ /* 11100 */ 25, 2 }, |
||||
{ /* 11101 */ 29, 2 }, |
||||
|
||||
/* 9 bit codewords */ |
||||
{ /* 11110 */ 33, 4 }, |
||||
|
||||
/* 9/10/11 bit codewords */ |
||||
{ /* 11111 */ 49, 6 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_quad hcb1_2[] = { |
||||
/* 1 bit codeword */ |
||||
{ 1, 0, 0, 0, 0 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ 5, 1, 0, 0, 0 }, |
||||
{ 5, -1, 0, 0, 0 }, |
||||
{ 5, 0, 0, 0, -1 }, |
||||
{ 5, 0, 1, 0, 0 }, |
||||
{ 5, 0, 0, 0, 1 }, |
||||
{ 5, 0, 0, -1, 0 }, |
||||
{ 5, 0, 0, 1, 0 }, |
||||
{ 5, 0, -1, 0, 0 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
/* first 5 bits: 11000 */ |
||||
{ 7, 1, -1, 0, 0 }, |
||||
{ 7, -1, 1, 0, 0 }, |
||||
{ 7, 0, 0, -1, 1 }, |
||||
{ 7, 0, 1, -1, 0 }, |
||||
/* first 5 bits: 11001 */ |
||||
{ 7, 0, -1, 1, 0 }, |
||||
{ 7, 0, 0, 1, -1 }, |
||||
{ 7, 1, 1, 0, 0 }, |
||||
{ 7, 0, 0, -1, -1 }, |
||||
/* first 5 bits: 11010 */ |
||||
{ 7, -1, -1, 0, 0 }, |
||||
{ 7, 0, -1, -1, 0 }, |
||||
{ 7, 1, 0, -1, 0 }, |
||||
{ 7, 0, 1, 0, -1 }, |
||||
/* first 5 bits: 11011 */ |
||||
{ 7, -1, 0, 1, 0 }, |
||||
{ 7, 0, 0, 1, 1 }, |
||||
{ 7, 1, 0, 1, 0 }, |
||||
{ 7, 0, -1, 0, 1 }, |
||||
/* first 5 bits: 11100 */ |
||||
{ 7, 0, 1, 1, 0 }, |
||||
{ 7, 0, 1, 0, 1 }, |
||||
{ 7, -1, 0, -1, 0 }, |
||||
{ 7, 1, 0, 0, 1 }, |
||||
/* first 5 bits: 11101 */ |
||||
{ 7, -1, 0, 0, -1 }, |
||||
{ 7, 1, 0, 0, -1 }, |
||||
{ 7, -1, 0, 0, 1 }, |
||||
{ 7, 0, -1, 0, -1 }, |
||||
|
||||
/* 9 bit codeword */ |
||||
/* first 5 bits: 11110 */ |
||||
{ 9, 1, 1, -1, 0 }, |
||||
{ 9, -1, 1, -1, 0 }, |
||||
{ 9, 1, -1, 1, 0 }, |
||||
{ 9, 0, 1, 1, -1 }, |
||||
{ 9, 0, 1, -1, 1 }, |
||||
{ 9, 0, -1, 1, 1 }, |
||||
{ 9, 0, -1, 1, -1 }, |
||||
{ 9, 1, -1, -1, 0 }, |
||||
{ 9, 1, 0, -1, 1 }, |
||||
{ 9, 0, 1, -1, -1 }, |
||||
{ 9, -1, 1, 1, 0 }, |
||||
{ 9, -1, 0, 1, -1 }, |
||||
{ 9, -1, -1, 1, 0 }, |
||||
{ 9, 0, -1, -1, 1 }, |
||||
{ 9, 1, -1, 0, 1 }, |
||||
{ 9, 1, -1, 0, -1 }, |
||||
|
||||
/* 9/10/11 bit codewords */ |
||||
/* first 5 bits: 11111 */ |
||||
/* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */ |
||||
{ 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, |
||||
{ 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, |
||||
{ 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, |
||||
{ 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, |
||||
{ 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, |
||||
{ 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, |
||||
{ 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, |
||||
{ 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, |
||||
/* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */ |
||||
{ 10, -1, -1, 0, 1 }, { 10, -1, -1, 0, 1 }, |
||||
{ 10, -1, 0, -1, -1 }, { 10, -1, 0, -1, -1 }, |
||||
{ 10, 1, 1, 0, -1 }, { 10, 1, 1, 0, -1 }, |
||||
{ 10, 1, 0, -1, -1 }, { 10, 1, 0, -1, -1 }, |
||||
{ 10, -1, 0, -1, 1 }, { 10, -1, 0, -1, 1 }, |
||||
{ 10, -1, -1, 0, -1 }, { 10, -1, -1, 0, -1 }, |
||||
{ 10, -1, 0, 1, 1 }, { 10, -1, 0, 1, 1 }, |
||||
{ 10, 1, 0, 1, 1 }, { 10, 1, 0, 1, 1 }, |
||||
/* 11 bit */ |
||||
{ 11, 1, -1, 1, -1 }, |
||||
{ 11, -1, 1, -1, 1 }, |
||||
{ 11, -1, 1, 1, -1 }, |
||||
{ 11, 1, -1, -1, 1 }, |
||||
{ 11, 1, 1, 1, 1 }, |
||||
{ 11, -1, -1, 1, 1 }, |
||||
{ 11, 1, 1, -1, -1 }, |
||||
{ 11, -1, -1, 1, -1 }, |
||||
{ 11, -1, -1, -1, -1 }, |
||||
{ 11, 1, 1, -1, 1 }, |
||||
{ 11, 1, -1, 1, 1 }, |
||||
{ 11, -1, 1, 1, 1 }, |
||||
{ 11, -1, 1, -1, -1 }, |
||||
{ 11, -1, -1, -1, 1 }, |
||||
{ 11, 1, -1, -1, -1 }, |
||||
{ 11, 1, 1, 1, -1 } |
||||
}; |
@ -0,0 +1,312 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_10.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_10 */ |
||||
|
||||
|
||||
/* 1st step: 6 bits
|
||||
* 2^6 = 64 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb10_1[] = { |
||||
/* 4 bit codewords */ |
||||
{ /* 000000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 000100 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* 001000 */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
/* 5 bit codewords */ |
||||
{ /* 001100 */ 3, 0 }, |
||||
{ /* */ 3, 0 }, |
||||
{ /* 001110 */ 4, 0 }, |
||||
{ /* */ 4, 0 }, |
||||
{ /* 010000 */ 5, 0 }, |
||||
{ /* */ 5, 0 }, |
||||
{ /* 010010 */ 6, 0 }, |
||||
{ /* */ 6, 0 }, |
||||
{ /* 010100 */ 7, 0 }, |
||||
{ /* */ 7, 0 }, |
||||
{ /* 010110 */ 8, 0 }, |
||||
{ /* */ 8, 0 }, |
||||
{ /* 011000 */ 9, 0 }, |
||||
{ /* */ 9, 0 }, |
||||
{ /* 011010 */ 10, 0 }, |
||||
{ /* */ 10, 0 }, |
||||
/* 6 bit codewords */ |
||||
{ /* 011100 */ 11, 0 }, |
||||
{ /* 011101 */ 12, 0 }, |
||||
{ /* 011110 */ 13, 0 }, |
||||
{ /* 011111 */ 14, 0 }, |
||||
{ /* 100000 */ 15, 0 }, |
||||
{ /* 100001 */ 16, 0 }, |
||||
{ /* 100010 */ 17, 0 }, |
||||
{ /* 100011 */ 18, 0 }, |
||||
{ /* 100100 */ 19, 0 }, |
||||
{ /* 100101 */ 20, 0 }, |
||||
{ /* 100110 */ 21, 0 }, |
||||
{ /* 100111 */ 22, 0 }, |
||||
{ /* 101000 */ 23, 0 }, |
||||
{ /* 101001 */ 24, 0 }, |
||||
/* 7 bit codewords */ |
||||
{ /* 101010 */ 25, 1 }, |
||||
{ /* 101011 */ 27, 1 }, |
||||
{ /* 101100 */ 29, 1 }, |
||||
{ /* 101101 */ 31, 1 }, |
||||
{ /* 101110 */ 33, 1 }, |
||||
{ /* 101111 */ 35, 1 }, |
||||
{ /* 110000 */ 37, 1 }, |
||||
{ /* 110001 */ 39, 1 }, |
||||
/* 7/8 bit codewords */ |
||||
{ /* 110010 */ 41, 2 }, |
||||
/* 8 bit codewords */ |
||||
{ /* 110011 */ 45, 2 }, |
||||
{ /* 110100 */ 49, 2 }, |
||||
{ /* 110101 */ 53, 2 }, |
||||
{ /* 110110 */ 57, 2 }, |
||||
{ /* 110111 */ 61, 2 }, |
||||
/* 8/9 bit codewords */ |
||||
{ /* 111000 */ 65, 3 }, |
||||
/* 9 bit codewords */ |
||||
{ /* 111001 */ 73, 3 }, |
||||
{ /* 111010 */ 81, 3 }, |
||||
{ /* 111011 */ 89, 3 }, |
||||
/* 9/10 bit codewords */ |
||||
{ /* 111100 */ 97, 4 }, |
||||
/* 10 bit codewords */ |
||||
{ /* 111101 */ 113, 4 }, |
||||
{ /* 111110 */ 129, 4 }, |
||||
/* 10/11/12 bit codewords */ |
||||
{ /* 111111 */ 145, 6 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_pair hcb10_2[] = { |
||||
/* 4 bit codewords */ |
||||
{ 4, 1, 1 }, |
||||
{ 4, 1, 2 }, |
||||
{ 4, 2, 1 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ 5, 2, 2 }, |
||||
{ 5, 1, 0 }, |
||||
{ 5, 0, 1 }, |
||||
{ 5, 1, 3 }, |
||||
{ 5, 3, 2 }, |
||||
{ 5, 3, 1 }, |
||||
{ 5, 2, 3 }, |
||||
{ 5, 3, 3 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ 6, 2, 0 }, |
||||
{ 6, 0, 2 }, |
||||
{ 6, 2, 4 }, |
||||
{ 6, 4, 2 }, |
||||
{ 6, 1, 4 }, |
||||
{ 6, 4, 1 }, |
||||
{ 6, 0, 0 }, |
||||
{ 6, 4, 3 }, |
||||
{ 6, 3, 4 }, |
||||
{ 6, 3, 0 }, |
||||
{ 6, 0, 3 }, |
||||
{ 6, 4, 4 }, |
||||
{ 6, 2, 5 }, |
||||
{ 6, 5, 2 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ 7, 1, 5 }, |
||||
{ 7, 5, 1 }, |
||||
{ 7, 5, 3 }, |
||||
{ 7, 3, 5 }, |
||||
{ 7, 5, 4 }, |
||||
{ 7, 4, 5 }, |
||||
{ 7, 6, 2 }, |
||||
{ 7, 2, 6 }, |
||||
{ 7, 6, 3 }, |
||||
{ 7, 4, 0 }, |
||||
{ 7, 6, 1 }, |
||||
{ 7, 0, 4 }, |
||||
{ 7, 1, 6 }, |
||||
{ 7, 3, 6 }, |
||||
{ 7, 5, 5 }, |
||||
{ 7, 6, 4 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ 7, 4, 6 }, { 7, 4, 6 }, |
||||
{ 8, 6, 5 }, |
||||
{ 8, 7, 2 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ 8, 3, 7 }, |
||||
{ 8, 2, 7 }, |
||||
{ 8, 5, 6 }, |
||||
{ 8, 8, 2 }, |
||||
{ 8, 7, 3 }, |
||||
{ 8, 5, 0 }, |
||||
{ 8, 7, 1 }, |
||||
{ 8, 0, 5 }, |
||||
{ 8, 8, 1 }, |
||||
{ 8, 1, 7 }, |
||||
{ 8, 8, 3 }, |
||||
{ 8, 7, 4 }, |
||||
{ 8, 4, 7 }, |
||||
{ 8, 2, 8 }, |
||||
{ 8, 6, 6 }, |
||||
{ 8, 7, 5 }, |
||||
{ 8, 1, 8 }, |
||||
{ 8, 3, 8 }, |
||||
{ 8, 8, 4 }, |
||||
{ 8, 4, 8 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ 8, 5, 7 }, { 8, 5, 7 }, |
||||
{ 8, 8, 5 }, { 8, 8, 5 }, |
||||
{ 8, 5, 8 }, { 8, 5, 8 }, |
||||
{ 9, 7, 6 }, |
||||
{ 9, 6, 7 }, |
||||
|
||||
/* 9 bit codewords */ |
||||
{ 9, 9, 2 }, |
||||
{ 9, 6, 0 }, |
||||
{ 9, 6, 8 }, |
||||
{ 9, 9, 3 }, |
||||
{ 9, 3, 9 }, |
||||
{ 9, 9, 1 }, |
||||
{ 9, 2, 9 }, |
||||
{ 9, 0, 6 }, |
||||
{ 9, 8, 6 }, |
||||
{ 9, 9, 4 }, |
||||
{ 9, 4, 9 }, |
||||
{ 9, 10, 2 }, |
||||
{ 9, 1, 9 }, |
||||
{ 9, 7, 7 }, |
||||
{ 9, 8, 7 }, |
||||
{ 9, 9, 5 }, |
||||
{ 9, 7, 8 }, |
||||
{ 9, 10, 3 }, |
||||
{ 9, 5, 9 }, |
||||
{ 9, 10, 4 }, |
||||
{ 9, 2, 10 }, |
||||
{ 9, 10, 1 }, |
||||
{ 9, 3, 10 }, |
||||
{ 9, 9, 6 }, |
||||
|
||||
/* 9/10 bit codewords */ |
||||
{ 9, 6, 9 }, { 9, 6, 9 }, |
||||
{ 9, 8, 0 }, { 9, 8, 0 }, |
||||
{ 9, 4, 10 }, { 9, 4, 10 }, |
||||
{ 9, 7, 0 }, { 9, 7, 0 }, |
||||
{ 9, 11, 2 }, { 9, 11, 2 }, |
||||
{ 10, 7, 9 }, |
||||
{ 10, 11, 3 }, |
||||
{ 10, 10, 6 }, |
||||
{ 10, 1, 10 }, |
||||
{ 10, 11, 1 }, |
||||
{ 10, 9, 7 }, |
||||
|
||||
/* 10 bit codewords */ |
||||
{ 10, 0, 7 }, |
||||
{ 10, 8, 8 }, |
||||
{ 10, 10, 5 }, |
||||
{ 10, 3, 11 }, |
||||
{ 10, 5, 10 }, |
||||
{ 10, 8, 9 }, |
||||
{ 10, 11, 5 }, |
||||
{ 10, 0, 8 }, |
||||
{ 10, 11, 4 }, |
||||
{ 10, 2, 11 }, |
||||
{ 10, 7, 10 }, |
||||
{ 10, 6, 10 }, |
||||
{ 10, 10, 7 }, |
||||
{ 10, 4, 11 }, |
||||
{ 10, 1, 11 }, |
||||
{ 10, 12, 2 }, |
||||
{ 10, 9, 8 }, |
||||
{ 10, 12, 3 }, |
||||
{ 10, 11, 6 }, |
||||
{ 10, 5, 11 }, |
||||
{ 10, 12, 4 }, |
||||
{ 10, 11, 7 }, |
||||
{ 10, 12, 5 }, |
||||
{ 10, 3, 12 }, |
||||
{ 10, 6, 11 }, |
||||
{ 10, 9, 0 }, |
||||
{ 10, 10, 8 }, |
||||
{ 10, 10, 0 }, |
||||
{ 10, 12, 1 }, |
||||
{ 10, 0, 9 }, |
||||
{ 10, 4, 12 }, |
||||
{ 10, 9, 9 }, |
||||
|
||||
/* 10/11/12 bit codewords */ |
||||
{ 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, |
||||
{ 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, |
||||
{ 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, |
||||
{ 11, 9, 10 }, { 11, 9, 10 }, |
||||
{ 11, 1, 12 }, { 11, 1, 12 }, |
||||
{ 11, 11, 8 }, { 11, 11, 8 }, |
||||
{ 11, 12, 7 }, { 11, 12, 7 }, |
||||
{ 11, 7, 11 }, { 11, 7, 11 }, |
||||
{ 11, 5, 12 }, { 11, 5, 12 }, |
||||
{ 11, 6, 12 }, { 11, 6, 12 }, |
||||
{ 11, 10, 9 }, { 11, 10, 9 }, |
||||
{ 11, 8, 11 }, { 11, 8, 11 }, |
||||
{ 11, 12, 8 }, { 11, 12, 8 }, |
||||
{ 11, 0, 10 }, { 11, 0, 10 }, |
||||
{ 11, 7, 12 }, { 11, 7, 12 }, |
||||
{ 11, 11, 0 }, { 11, 11, 0 }, |
||||
{ 11, 10, 10 }, { 11, 10, 10 }, |
||||
{ 11, 11, 9 }, { 11, 11, 9 }, |
||||
{ 11, 11, 10 }, { 11, 11, 10 }, |
||||
{ 11, 0, 11 }, { 11, 0, 11 }, |
||||
{ 11, 11, 11 }, { 11, 11, 11 }, |
||||
{ 11, 9, 11 }, { 11, 9, 11 }, |
||||
{ 11, 10, 11 }, { 11, 10, 11 }, |
||||
{ 11, 12, 0 }, { 11, 12, 0 }, |
||||
{ 11, 8, 12 }, { 11, 8, 12 }, |
||||
{ 12, 12, 9 }, |
||||
{ 12, 10, 12 }, |
||||
{ 12, 9, 12 }, |
||||
{ 12, 11, 12 }, |
||||
{ 12, 12, 11 }, |
||||
{ 12, 0, 12 }, |
||||
{ 12, 12, 10 }, |
||||
{ 12, 12, 12 } |
||||
}; |
@ -0,0 +1,415 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_11.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_11 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb11_1[] = { |
||||
/* 4 bits */ |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 00010 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
|
||||
/* 5 bits */ |
||||
{ /* 00100 */ 2, 0 }, |
||||
{ /* 00101 */ 3, 0 }, |
||||
{ /* 00110 */ 4, 0 }, |
||||
{ /* 00111 */ 5, 0 }, |
||||
{ /* 01000 */ 6, 0 }, |
||||
{ /* 01001 */ 7, 0 }, |
||||
|
||||
/* 6 bits */ |
||||
{ /* 01010 */ 8, 1 }, |
||||
{ /* 01011 */ 10, 1 }, |
||||
{ /* 01100 */ 12, 1 }, |
||||
|
||||
/* 6/7 bits */ |
||||
{ /* 01101 */ 14, 2 }, |
||||
|
||||
/* 7 bits */ |
||||
{ /* 01110 */ 18, 2 }, |
||||
{ /* 01111 */ 22, 2 }, |
||||
{ /* 10000 */ 26, 2 }, |
||||
|
||||
/* 7/8 bits */ |
||||
{ /* 10001 */ 30, 3 }, |
||||
|
||||
/* 8 bits */ |
||||
{ /* 10010 */ 38, 3 }, |
||||
{ /* 10011 */ 46, 3 }, |
||||
{ /* 10100 */ 54, 3 }, |
||||
{ /* 10101 */ 62, 3 }, |
||||
{ /* 10110 */ 70, 3 }, |
||||
{ /* 10111 */ 78, 3 }, |
||||
|
||||
/* 8/9 bits */ |
||||
{ /* 11000 */ 86, 4 }, |
||||
|
||||
/* 9 bits */ |
||||
{ /* 11001 */ 102, 4 }, |
||||
{ /* 11010 */ 118, 4 }, |
||||
{ /* 11011 */ 134, 4 }, |
||||
|
||||
/* 9/10 bits */ |
||||
{ /* 11100 */ 150, 5 }, |
||||
|
||||
/* 10 bits */ |
||||
{ /* 11101 */ 182, 5 }, |
||||
{ /* 11110 */ 214, 5 }, |
||||
|
||||
/* 10/11/12 bits */ |
||||
{ /* 11111 */ 246, 7 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_pair hcb11_2[] = { |
||||
/* 4 */ |
||||
{ 4, 0, 0 }, |
||||
{ 4, 1, 1 }, |
||||
|
||||
/* 5 */ |
||||
{ 5, 16, 16 }, |
||||
{ 5, 1, 0 }, |
||||
{ 5, 0, 1 }, |
||||
{ 5, 2, 1 }, |
||||
{ 5, 1, 2 }, |
||||
{ 5, 2, 2 }, |
||||
|
||||
/* 6 */ |
||||
{ 6, 1, 3 }, |
||||
{ 6, 3, 1 }, |
||||
{ 6, 3, 2 }, |
||||
{ 6, 2, 0 }, |
||||
{ 6, 2, 3 }, |
||||
{ 6, 0, 2 }, |
||||
|
||||
/* 6/7 */ |
||||
{ 6, 3, 3 }, { 6, 3, 3 }, |
||||
{ 7, 4, 1 }, |
||||
{ 7, 1, 4 }, |
||||
|
||||
/* 7 */ |
||||
{ 7, 4, 2 }, |
||||
{ 7, 2, 4 }, |
||||
{ 7, 4, 3 }, |
||||
{ 7, 3, 4 }, |
||||
{ 7, 3, 0 }, |
||||
{ 7, 0, 3 }, |
||||
{ 7, 5, 1 }, |
||||
{ 7, 5, 2 }, |
||||
{ 7, 2, 5 }, |
||||
{ 7, 4, 4 }, |
||||
{ 7, 1, 5 }, |
||||
{ 7, 5, 3 }, |
||||
|
||||
/* 7/8 */ |
||||
{ 7, 3, 5 }, { 7, 3, 5 }, |
||||
{ 7, 5, 4 }, { 7, 5, 4 }, |
||||
{ 8, 4, 5 }, |
||||
{ 8, 6, 2 }, |
||||
{ 8, 2, 6 }, |
||||
{ 8, 6, 1 }, |
||||
|
||||
/* 8 */ |
||||
{ 8, 6, 3 }, |
||||
{ 8, 3, 6 }, |
||||
{ 8, 1, 6 }, |
||||
{ 8, 4, 16 }, |
||||
{ 8, 3, 16 }, |
||||
{ 8, 16, 5 }, |
||||
{ 8, 16, 3 }, |
||||
{ 8, 16, 4 }, |
||||
{ 8, 6, 4 }, |
||||
{ 8, 16, 6 }, |
||||
{ 8, 4, 0 }, |
||||
{ 8, 4, 6 }, |
||||
{ 8, 0, 4 }, |
||||
{ 8, 2, 16 }, |
||||
{ 8, 5, 5 }, |
||||
{ 8, 5, 16 }, |
||||
{ 8, 16, 7 }, |
||||
{ 8, 16, 2 }, |
||||
{ 8, 16, 8 }, |
||||
{ 8, 2, 7 }, |
||||
{ 8, 7, 2 }, |
||||
{ 8, 3, 7 }, |
||||
{ 8, 6, 5 }, |
||||
{ 8, 5, 6 }, |
||||
{ 8, 6, 16 }, |
||||
{ 8, 16, 10 }, |
||||
{ 8, 7, 3 }, |
||||
{ 8, 7, 1 }, |
||||
{ 8, 16, 9 }, |
||||
{ 8, 7, 16 }, |
||||
{ 8, 1, 16 }, |
||||
{ 8, 1, 7 }, |
||||
{ 8, 4, 7 }, |
||||
{ 8, 16, 11 }, |
||||
{ 8, 7, 4 }, |
||||
{ 8, 16, 12 }, |
||||
{ 8, 8, 16 }, |
||||
{ 8, 16, 1 }, |
||||
{ 8, 6, 6 }, |
||||
{ 8, 9, 16 }, |
||||
{ 8, 2, 8 }, |
||||
{ 8, 5, 7 }, |
||||
{ 8, 10, 16 }, |
||||
{ 8, 16, 13 }, |
||||
{ 8, 8, 3 }, |
||||
{ 8, 8, 2 }, |
||||
{ 8, 3, 8 }, |
||||
{ 8, 5, 0 }, |
||||
|
||||
/* 8/9 */ |
||||
{ 8, 16, 14 }, { 8, 16, 14 }, |
||||
{ 8, 11, 16 }, { 8, 11, 16 }, |
||||
{ 8, 7, 5 }, { 8, 7, 5 }, |
||||
{ 8, 4, 8 }, { 8, 4, 8 }, |
||||
{ 8, 6, 7 }, { 8, 6, 7 }, |
||||
{ 8, 7, 6 }, { 8, 7, 6 }, |
||||
{ 8, 0, 5 }, { 8, 0, 5 }, |
||||
{ 9, 8, 4 }, |
||||
{ 9, 16, 15 }, |
||||
|
||||
/* 9 */ |
||||
{ 9, 12, 16 }, |
||||
{ 9, 1, 8 }, |
||||
{ 9, 8, 1 }, |
||||
{ 9, 14, 16 }, |
||||
{ 9, 5, 8 }, |
||||
{ 9, 13, 16 }, |
||||
{ 9, 3, 9 }, |
||||
{ 9, 8, 5 }, |
||||
{ 9, 7, 7 }, |
||||
{ 9, 2, 9 }, |
||||
{ 9, 8, 6 }, |
||||
{ 9, 9, 2 }, |
||||
{ 9, 9, 3 }, |
||||
{ 9, 15, 16 }, |
||||
{ 9, 4, 9 }, |
||||
{ 9, 6, 8 }, |
||||
{ 9, 6, 0 }, |
||||
{ 9, 9, 4 }, |
||||
{ 9, 5, 9 }, |
||||
{ 9, 8, 7 }, |
||||
{ 9, 7, 8 }, |
||||
{ 9, 1, 9 }, |
||||
{ 9, 10, 3 }, |
||||
{ 9, 0, 6 }, |
||||
{ 9, 10, 2 }, |
||||
{ 9, 9, 1 }, |
||||
{ 9, 9, 5 }, |
||||
{ 9, 4, 10 }, |
||||
{ 9, 2, 10 }, |
||||
{ 9, 9, 6 }, |
||||
{ 9, 3, 10 }, |
||||
{ 9, 6, 9 }, |
||||
{ 9, 10, 4 }, |
||||
{ 9, 8, 8 }, |
||||
{ 9, 10, 5 }, |
||||
{ 9, 9, 7 }, |
||||
{ 9, 11, 3 }, |
||||
{ 9, 1, 10 }, |
||||
{ 9, 7, 0 }, |
||||
{ 9, 10, 6 }, |
||||
{ 9, 7, 9 }, |
||||
{ 9, 3, 11 }, |
||||
{ 9, 5, 10 }, |
||||
{ 9, 10, 1 }, |
||||
{ 9, 4, 11 }, |
||||
{ 9, 11, 2 }, |
||||
{ 9, 13, 2 }, |
||||
{ 9, 6, 10 }, |
||||
|
||||
/* 9/10 */ |
||||
{ 9, 13, 3 }, { 9, 13, 3 }, |
||||
{ 9, 2, 11 }, { 9, 2, 11 }, |
||||
{ 9, 16, 0 }, { 9, 16, 0 }, |
||||
{ 9, 5, 11 }, { 9, 5, 11 }, |
||||
{ 9, 11, 5 }, { 9, 11, 5 }, |
||||
{ 10, 11, 4 }, |
||||
{ 10, 9, 8 }, |
||||
{ 10, 7, 10 }, |
||||
{ 10, 8, 9 }, |
||||
{ 10, 0, 16 }, |
||||
{ 10, 4, 13 }, |
||||
{ 10, 0, 7 }, |
||||
{ 10, 3, 13 }, |
||||
{ 10, 11, 6 }, |
||||
{ 10, 13, 1 }, |
||||
{ 10, 13, 4 }, |
||||
{ 10, 12, 3 }, |
||||
{ 10, 2, 13 }, |
||||
{ 10, 13, 5 }, |
||||
{ 10, 8, 10 }, |
||||
{ 10, 6, 11 }, |
||||
{ 10, 10, 8 }, |
||||
{ 10, 10, 7 }, |
||||
{ 10, 14, 2 }, |
||||
{ 10, 12, 4 }, |
||||
{ 10, 1, 11 }, |
||||
{ 10, 4, 12 }, |
||||
|
||||
/* 10 */ |
||||
{ 10, 11, 1 }, |
||||
{ 10, 3, 12 }, |
||||
{ 10, 1, 13 }, |
||||
{ 10, 12, 2 }, |
||||
{ 10, 7, 11 }, |
||||
{ 10, 3, 14 }, |
||||
{ 10, 5, 12 }, |
||||
{ 10, 5, 13 }, |
||||
{ 10, 14, 4 }, |
||||
{ 10, 4, 14 }, |
||||
{ 10, 11, 7 }, |
||||
{ 10, 14, 3 }, |
||||
{ 10, 12, 5 }, |
||||
{ 10, 13, 6 }, |
||||
{ 10, 12, 6 }, |
||||
{ 10, 8, 0 }, |
||||
{ 10, 11, 8 }, |
||||
{ 10, 2, 12 }, |
||||
{ 10, 9, 9 }, |
||||
{ 10, 14, 5 }, |
||||
{ 10, 6, 13 }, |
||||
{ 10, 10, 10 }, |
||||
{ 10, 15, 2 }, |
||||
{ 10, 8, 11 }, |
||||
{ 10, 9, 10 }, |
||||
{ 10, 14, 6 }, |
||||
{ 10, 10, 9 }, |
||||
{ 10, 5, 14 }, |
||||
{ 10, 11, 9 }, |
||||
{ 10, 14, 1 }, |
||||
{ 10, 2, 14 }, |
||||
{ 10, 6, 12 }, |
||||
{ 10, 1, 12 }, |
||||
{ 10, 13, 8 }, |
||||
{ 10, 0, 8 }, |
||||
{ 10, 13, 7 }, |
||||
{ 10, 7, 12 }, |
||||
{ 10, 12, 7 }, |
||||
{ 10, 7, 13 }, |
||||
{ 10, 15, 3 }, |
||||
{ 10, 12, 1 }, |
||||
{ 10, 6, 14 }, |
||||
{ 10, 2, 15 }, |
||||
{ 10, 15, 5 }, |
||||
{ 10, 15, 4 }, |
||||
{ 10, 1, 14 }, |
||||
{ 10, 9, 11 }, |
||||
{ 10, 4, 15 }, |
||||
{ 10, 14, 7 }, |
||||
{ 10, 8, 13 }, |
||||
{ 10, 13, 9 }, |
||||
{ 10, 8, 12 }, |
||||
{ 10, 5, 15 }, |
||||
{ 10, 3, 15 }, |
||||
{ 10, 10, 11 }, |
||||
{ 10, 11, 10 }, |
||||
{ 10, 12, 8 }, |
||||
{ 10, 15, 6 }, |
||||
{ 10, 15, 7 }, |
||||
{ 10, 8, 14 }, |
||||
{ 10, 15, 1 }, |
||||
{ 10, 7, 14 }, |
||||
{ 10, 9, 0 }, |
||||
{ 10, 0, 9 }, |
||||
|
||||
/* 10/11/12 */ |
||||
{ 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, |
||||
{ 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, |
||||
{ 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, |
||||
{ 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, |
||||
{ 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, |
||||
{ 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, |
||||
{ 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, |
||||
{ 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, |
||||
{ 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, |
||||
|
||||
{ 11, 9, 14 }, { 11, 9, 14 }, |
||||
{ 11, 15, 8 }, { 11, 15, 8 }, |
||||
{ 11, 11, 11 }, { 11, 11, 11 }, |
||||
{ 11, 11, 14 }, { 11, 11, 14 }, |
||||
{ 11, 1, 15 }, { 11, 1, 15 }, |
||||
{ 11, 10, 12 }, { 11, 10, 12 }, |
||||
{ 11, 10, 14 }, { 11, 10, 14 }, |
||||
{ 11, 13, 11 }, { 11, 13, 11 }, |
||||
{ 11, 13, 10 }, { 11, 13, 10 }, |
||||
{ 11, 11, 13 }, { 11, 11, 13 }, |
||||
{ 11, 11, 12 }, { 11, 11, 12 }, |
||||
{ 11, 8, 15 }, { 11, 8, 15 }, |
||||
{ 11, 14, 11 }, { 11, 14, 11 }, |
||||
{ 11, 13, 12 }, { 11, 13, 12 }, |
||||
{ 11, 12, 13 }, { 11, 12, 13 }, |
||||
{ 11, 15, 9 }, { 11, 15, 9 }, |
||||
{ 11, 14, 10 }, { 11, 14, 10 }, |
||||
{ 11, 10, 0 }, { 11, 10, 0 }, |
||||
{ 11, 12, 11 }, { 11, 12, 11 }, |
||||
{ 11, 9, 15 }, { 11, 9, 15 }, |
||||
{ 11, 0, 10 }, { 11, 0, 10 }, |
||||
{ 11, 12, 12 }, { 11, 12, 12 }, |
||||
{ 11, 11, 0 }, { 11, 11, 0 }, |
||||
{ 11, 12, 14 }, { 11, 12, 14 }, |
||||
{ 11, 10, 15 }, { 11, 10, 15 }, |
||||
{ 11, 13, 13 }, { 11, 13, 13 }, |
||||
{ 11, 0, 13 }, { 11, 0, 13 }, |
||||
{ 11, 14, 12 }, { 11, 14, 12 }, |
||||
{ 11, 15, 10 }, { 11, 15, 10 }, |
||||
{ 11, 15, 11 }, { 11, 15, 11 }, |
||||
{ 11, 11, 15 }, { 11, 11, 15 }, |
||||
{ 11, 14, 13 }, { 11, 14, 13 }, |
||||
{ 11, 13, 0 }, { 11, 13, 0 }, |
||||
{ 11, 0, 11 }, { 11, 0, 11 }, |
||||
{ 11, 13, 14 }, { 11, 13, 14 }, |
||||
{ 11, 15, 12 }, { 11, 15, 12 }, |
||||
{ 11, 15, 13 }, { 11, 15, 13 }, |
||||
{ 11, 12, 15 }, { 11, 12, 15 }, |
||||
{ 11, 14, 0 }, { 11, 14, 0 }, |
||||
{ 11, 14, 14 }, { 11, 14, 14 }, |
||||
{ 11, 13, 15 }, { 11, 13, 15 }, |
||||
{ 11, 12, 0 }, { 11, 12, 0 }, |
||||
{ 11, 14, 15 }, { 11, 14, 15 }, |
||||
{ 12, 0, 14 }, |
||||
{ 12, 0, 12 }, |
||||
{ 12, 15, 14 }, |
||||
{ 12, 15, 0 }, |
||||
{ 12, 0, 15 }, |
||||
{ 12, 15, 15 } |
||||
}; |
@ -0,0 +1,185 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_2.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_2 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb2_1[] = { |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 00100 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* 00110 */ 2, 0 }, |
||||
{ /* 00111 */ 3, 0 }, |
||||
{ /* 01000 */ 4, 0 }, |
||||
{ /* 01001 */ 5, 0 }, |
||||
{ /* 01010 */ 6, 0 }, |
||||
{ /* 01011 */ 7, 0 }, |
||||
{ /* 01100 */ 8, 0 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ /* 01101 */ 9, 1 }, |
||||
{ /* 01110 */ 11, 1 }, |
||||
{ /* 01111 */ 13, 1 }, |
||||
{ /* 10000 */ 15, 1 }, |
||||
{ /* 10001 */ 17, 1 }, |
||||
{ /* 10010 */ 19, 1 }, |
||||
{ /* 10011 */ 21, 1 }, |
||||
{ /* 10100 */ 23, 1 }, |
||||
{ /* 10101 */ 25, 1 }, |
||||
{ /* 10110 */ 27, 1 }, |
||||
{ /* 10111 */ 29, 1 }, |
||||
{ /* 11000 */ 31, 1 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ /* 11001 */ 33, 2 }, |
||||
{ /* 11010 */ 37, 2 }, |
||||
{ /* 11011 */ 41, 2 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ /* 11100 */ 45, 3 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ /* 11101 */ 53, 3 }, |
||||
{ /* 11110 */ 61, 3 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ /* 11111 */ 69, 4 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_quad hcb2_2[] = { |
||||
/* 3 bit codeword */ |
||||
{ 3, 0, 0, 0, 0 }, |
||||
|
||||
/* 4 bit codeword */ |
||||
{ 4, 1, 0, 0, 0 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ 5, -1, 0, 0, 0 }, |
||||
{ 5, 0, 0, 0, 1 }, |
||||
{ 5, 0, 0, -1, 0 }, |
||||
{ 5, 0, 0, 0, -1 }, |
||||
{ 5, 0, -1, 0, 0 }, |
||||
{ 5, 0, 0, 1, 0 }, |
||||
{ 5, 0, 1, 0, 0 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ 6, 0, -1, 1, 0 }, |
||||
{ 6, -1, 1, 0, 0 }, |
||||
{ 6, 0, 1, -1, 0 }, |
||||
{ 6, 0, 0, 1, -1 }, |
||||
{ 6, 0, 1, 0, -1 }, |
||||
{ 6, 0, 0, -1, 1 }, |
||||
{ 6, -1, 0, 0, -1 }, |
||||
{ 6, 1, -1, 0, 0 }, |
||||
{ 6, 1, 0, -1, 0 }, |
||||
{ 6, -1, -1, 0, 0 }, |
||||
{ 6, 0, 0, -1, -1 }, |
||||
{ 6, 1, 0, 1, 0 }, |
||||
{ 6, 1, 0, 0, 1 }, |
||||
{ 6, 0, -1, 0, 1 }, |
||||
{ 6, -1, 0, 1, 0 }, |
||||
{ 6, 0, 1, 0, 1 }, |
||||
{ 6, 0, -1, -1, 0 }, |
||||
{ 6, -1, 0, 0, 1 }, |
||||
{ 6, 0, -1, 0, -1 }, |
||||
{ 6, -1, 0, -1, 0 }, |
||||
{ 6, 1, 1, 0, 0 }, |
||||
{ 6, 0, 1, 1, 0 }, |
||||
{ 6, 0, 0, 1, 1 }, |
||||
{ 6, 1, 0, 0, -1 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ 7, 0, 1, -1, 1 }, |
||||
{ 7, 1, 0, -1, 1 }, |
||||
{ 7, -1, 1, -1, 0 }, |
||||
{ 7, 0, -1, 1, -1 }, |
||||
{ 7, 1, -1, 1, 0 }, |
||||
{ 7, 1, 1, 0, -1 }, |
||||
{ 7, 1, 0, 1, 1 }, |
||||
{ 7, -1, 1, 1, 0 }, |
||||
{ 7, 0, -1, -1, 1 }, |
||||
{ 7, 1, 1, 1, 0 }, |
||||
{ 7, -1, 0, 1, -1 }, |
||||
{ 7, -1, -1, -1, 0 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ 7, -1, 0, -1, 1 }, { 7, -1, 0, -1, 1 }, |
||||
{ 7, 1, -1, -1, 0 }, { 7, 1, -1, -1, 0 }, |
||||
{ 7, 1, 1, -1, 0 }, { 7, 1, 1, -1, 0 }, |
||||
{ 8, 1, -1, 0, 1 }, |
||||
{ 8, -1, 1, 0, -1 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ 8, -1, -1, 1, 0 }, |
||||
{ 8, -1, 0, 1, 1 }, |
||||
{ 8, -1, -1, 0, 1 }, |
||||
{ 8, -1, -1, 0, -1 }, |
||||
{ 8, 0, -1, -1, -1 }, |
||||
{ 8, 1, 0, 1, -1 }, |
||||
{ 8, 1, 0, -1, -1 }, |
||||
{ 8, 0, 1, -1, -1 }, |
||||
{ 8, 0, 1, 1, 1 }, |
||||
{ 8, -1, 1, 0, 1 }, |
||||
{ 8, -1, 0, -1, -1 }, |
||||
{ 8, 0, 1, 1, -1 }, |
||||
{ 8, 1, -1, 0, -1 }, |
||||
{ 8, 0, -1, 1, 1 }, |
||||
{ 8, 1, 1, 0, 1 }, |
||||
{ 8, 1, -1, 1, -1 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ 8, -1, 1, -1, 1 }, { 8, -1, 1, -1, 1 }, |
||||
{ 9, 1, -1, -1, 1 }, |
||||
{ 9, -1, -1, -1, -1 }, |
||||
{ 9, -1, 1, 1, -1 }, |
||||
{ 9, -1, 1, 1, 1 }, |
||||
{ 9, 1, 1, 1, 1 }, |
||||
{ 9, -1, -1, 1, -1 }, |
||||
{ 9, 1, -1, 1, 1 }, |
||||
{ 9, -1, 1, -1, -1 }, |
||||
{ 9, -1, -1, 1, 1 }, |
||||
{ 9, 1, 1, -1, -1 }, |
||||
{ 9, 1, -1, -1, -1 }, |
||||
{ 9, -1, -1, -1, 1 }, |
||||
{ 9, 1, 1, -1, 1 }, |
||||
{ 9, 1, 1, 1, -1 } |
||||
}; |
@ -0,0 +1,196 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_3.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* Binary search huffman table HCB_3 */ |
||||
|
||||
|
||||
static hcb_bin_quad hcb3[] = { |
||||
{ /* 0 */ 0, { 1, 2, 0, 0 } }, |
||||
{ /* 1 */ 1, { 0, 0, 0, 0 } }, /* 0 */ |
||||
{ /* 2 */ 0, { 1, 2, 0, 0 } }, |
||||
{ /* 3 */ 0, { 2, 3, 0, 0 } }, |
||||
{ /* 4 */ 0, { 3, 4, 0, 0 } }, |
||||
{ /* 5 */ 0, { 4, 5, 0, 0 } }, |
||||
{ /* 6 */ 0, { 5, 6, 0, 0 } }, |
||||
{ /* 7 */ 0, { 6, 7, 0, 0 } }, |
||||
{ /* 8 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 9 */ 1, { 1, 0, 0, 0 } }, /* 1000 */ |
||||
{ /* 10 */ 1, { 0, 0, 0, 1 } }, /* 1001 */ |
||||
{ /* 11 */ 1, { 0, 1, 0, 0 } }, /* 1010 */ |
||||
{ /* 12 */ 1, { 0, 0, 1, 0 } }, /* 1011 */ |
||||
{ /* 13 */ 0, { 4, 5, 0, 0 } }, |
||||
{ /* 14 */ 0, { 5, 6, 0, 0 } }, |
||||
{ /* 15 */ 0, { 6, 7, 0, 0 } }, |
||||
{ /* 16 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 17 */ 1, { 1, 1, 0, 0 } }, |
||||
{ /* 18 */ 1, { 0, 0, 1, 1 } }, |
||||
{ /* 19 */ 0, { 6, 7, 0, 0 } }, |
||||
{ /* 20 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 21 */ 0, { 8, 9, 0, 0 } }, |
||||
{ /* 22 */ 0, { 9, 10, 0, 0 } }, |
||||
{ /* 23 */ 0, { 10, 11, 0, 0 } }, |
||||
{ /* 24 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 25 */ 1, { 0, 1, 1, 0 } }, /* 110100 */ |
||||
{ /* 26 */ 1, { 0, 1, 0, 1 } }, /* 110101 */ |
||||
{ /* 27 */ 1, { 1, 0, 1, 0 } }, /* 110110 */ |
||||
{ /* 28 */ 1, { 0, 1, 1, 1 } }, /* 110111 */ |
||||
{ /* 29 */ 1, { 1, 0, 0, 1 } }, /* 111000 */ |
||||
{ /* 30 */ 1, { 1, 1, 1, 0 } }, /* 111001 */ |
||||
{ /* 31 */ 0, { 6, 7, 0, 0 } }, |
||||
{ /* 32 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 33 */ 0, { 8, 9, 0, 0 } }, |
||||
{ /* 34 */ 0, { 9, 10, 0, 0 } }, |
||||
{ /* 35 */ 0, { 10, 11, 0, 0 } }, |
||||
{ /* 36 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 37 */ 1, { 1, 1, 1, 1 } }, /* 1110100 */ |
||||
{ /* 38 */ 1, { 1, 0, 1, 1 } }, /* 1110101 */ |
||||
{ /* 39 */ 1, { 1, 1, 0, 1 } }, /* 1110110 */ |
||||
{ /* 40 */ 0, { 9, 10, 0, 0 } }, |
||||
{ /* 41 */ 0, { 10, 11, 0, 0 } }, |
||||
{ /* 42 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 43 */ 0, { 12, 13, 0, 0 } }, |
||||
{ /* 44 */ 0, { 13, 14, 0, 0 } }, |
||||
{ /* 45 */ 0, { 14, 15, 0, 0 } }, |
||||
{ /* 46 */ 0, { 15, 16, 0, 0 } }, |
||||
{ /* 47 */ 0, { 16, 17, 0, 0 } }, |
||||
{ /* 48 */ 0, { 17, 18, 0, 0 } }, |
||||
{ /* 49 */ 1, { 2, 0, 0, 0 } }, /* 11101110 */ |
||||
{ /* 50 */ 1, { 0, 0, 0, 2 } }, /* 11101111 */ |
||||
{ /* 51 */ 1, { 0, 0, 1, 2 } }, /* 11110000 */ |
||||
{ /* 52 */ 1, { 2, 1, 0, 0 } }, /* 11110001 */ |
||||
{ /* 53 */ 1, { 1, 2, 1, 0 } }, /* 11110010 */ |
||||
{ /* 54 */ 0, { 13, 14, 0, 0 } }, |
||||
{ /* 55 */ 0, { 14, 15, 0, 0 } }, |
||||
{ /* 56 */ 0, { 15, 16, 0, 0 } }, |
||||
{ /* 57 */ 0, { 16, 17, 0, 0 } }, |
||||
{ /* 58 */ 0, { 17, 18, 0, 0 } }, |
||||
{ /* 59 */ 0, { 18, 19, 0, 0 } }, |
||||
{ /* 60 */ 0, { 19, 20, 0, 0 } }, |
||||
{ /* 61 */ 0, { 20, 21, 0, 0 } }, |
||||
{ /* 62 */ 0, { 21, 22, 0, 0 } }, |
||||
{ /* 63 */ 0, { 22, 23, 0, 0 } }, |
||||
{ /* 64 */ 0, { 23, 24, 0, 0 } }, |
||||
{ /* 65 */ 0, { 24, 25, 0, 0 } }, |
||||
{ /* 66 */ 0, { 25, 26, 0, 0 } }, |
||||
{ /* 67 */ 1, { 0, 0, 2, 1 } }, |
||||
{ /* 68 */ 1, { 0, 1, 2, 1 } }, |
||||
{ /* 69 */ 1, { 1, 2, 0, 0 } }, |
||||
{ /* 70 */ 1, { 0, 1, 1, 2 } }, |
||||
{ /* 71 */ 1, { 2, 1, 1, 0 } }, |
||||
{ /* 72 */ 1, { 0, 0, 2, 0 } }, |
||||
{ /* 73 */ 1, { 0, 2, 1, 0 } }, |
||||
{ /* 74 */ 1, { 0, 1, 2, 0 } }, |
||||
{ /* 75 */ 1, { 0, 2, 0, 0 } }, |
||||
{ /* 76 */ 1, { 0, 1, 0, 2 } }, |
||||
{ /* 77 */ 1, { 2, 0, 1, 0 } }, |
||||
{ /* 78 */ 1, { 1, 2, 1, 1 } }, |
||||
{ /* 79 */ 1, { 0, 2, 1, 1 } }, |
||||
{ /* 80 */ 1, { 1, 1, 2, 0 } }, |
||||
{ /* 81 */ 1, { 1, 1, 2, 1 } }, |
||||
{ /* 82 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 83 */ 0, { 12, 13, 0, 0 } }, |
||||
{ /* 84 */ 0, { 13, 14, 0, 0 } }, |
||||
{ /* 85 */ 0, { 14, 15, 0, 0 } }, |
||||
{ /* 86 */ 0, { 15, 16, 0, 0 } }, |
||||
{ /* 87 */ 0, { 16, 17, 0, 0 } }, |
||||
{ /* 88 */ 0, { 17, 18, 0, 0 } }, |
||||
{ /* 89 */ 0, { 18, 19, 0, 0 } }, |
||||
{ /* 90 */ 0, { 19, 20, 0, 0 } }, |
||||
{ /* 91 */ 0, { 20, 21, 0, 0 } }, |
||||
{ /* 92 */ 0, { 21, 22, 0, 0 } }, |
||||
{ /* 93 */ 1, { 1, 2, 0, 1 } }, /* 1111101010 */ |
||||
{ /* 94 */ 1, { 1, 0, 2, 0 } }, /* 1111101011 */ |
||||
{ /* 95 */ 1, { 1, 0, 2, 1 } }, /* 1111101100 */ |
||||
{ /* 96 */ 1, { 0, 2, 0, 1 } }, /* 1111101101 */ |
||||
{ /* 97 */ 1, { 2, 1, 1, 1 } }, /* 1111101110 */ |
||||
{ /* 98 */ 1, { 1, 1, 1, 2 } }, /* 1111101111 */ |
||||
{ /* 99 */ 1, { 2, 1, 0, 1 } }, /* 1111110000 */ |
||||
{ /* 00 */ 1, { 1, 0, 1, 2 } }, /* 1111110001 */ |
||||
{ /* 01 */ 1, { 0, 0, 2, 2 } }, /* 1111110010 */ |
||||
{ /* 02 */ 1, { 0, 1, 2, 2 } }, /* 1111110011 */ |
||||
{ /* 03 */ 1, { 2, 2, 1, 0 } }, /* 1111110100 */ |
||||
{ /* 04 */ 1, { 1, 2, 2, 0 } }, /* 1111110101 */ |
||||
{ /* 05 */ 1, { 1, 0, 0, 2 } }, /* 1111110110 */ |
||||
{ /* 06 */ 1, { 2, 0, 0, 1 } }, /* 1111110111 */ |
||||
{ /* 07 */ 1, { 0, 2, 2, 1 } }, /* 1111111000 */ |
||||
{ /* 08 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 09 */ 0, { 8, 9, 0, 0 } }, |
||||
{ /* 10 */ 0, { 9, 10, 0, 0 } }, |
||||
{ /* 11 */ 0, { 10, 11, 0, 0 } }, |
||||
{ /* 12 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 13 */ 0, { 12, 13, 0, 0 } }, |
||||
{ /* 14 */ 0, { 13, 14, 0, 0 } }, |
||||
{ /* 15 */ 1, { 2, 2, 0, 0 } }, /* 11111110010 */ |
||||
{ /* 16 */ 1, { 1, 2, 2, 1 } }, /* 11111110011 */ |
||||
{ /* 17 */ 1, { 1, 1, 0, 2 } }, /* 11111110100 */ |
||||
{ /* 18 */ 1, { 2, 0, 1, 1 } }, /* 11111110101 */ |
||||
{ /* 19 */ 1, { 1, 1, 2, 2 } }, /* 11111110110 */ |
||||
{ /* 20 */ 1, { 2, 2, 1, 1 } }, /* 11111110111 */ |
||||
{ /* 21 */ 1, { 0, 2, 2, 0 } }, /* 11111111000 */ |
||||
{ /* 22 */ 1, { 0, 2, 1, 2 } }, /* 11111111001 */ |
||||
{ /* 23 */ 0, { 6, 7, 0, 0 } }, |
||||
{ /* 24 */ 0, { 7, 8, 0, 0 } }, |
||||
{ /* 25 */ 0, { 8, 9, 0, 0 } }, |
||||
{ /* 26 */ 0, { 9, 10, 0, 0 } }, |
||||
{ /* 27 */ 0, { 10, 11, 0, 0 } }, |
||||
{ /* 28 */ 0, { 11, 12, 0, 0 } }, |
||||
{ /* 29 */ 1, { 1, 0, 2, 2 } }, /* 111111110100 */ |
||||
{ /* 30 */ 1, { 2, 2, 0, 1 } }, /* 111111110101 */ |
||||
{ /* 31 */ 1, { 2, 1, 2, 0 } }, /* 111111110110 */ |
||||
{ /* 32 */ 1, { 2, 2, 2, 0 } }, /* 111111110111 */ |
||||
{ /* 33 */ 1, { 0, 2, 2, 2 } }, /* 111111111000 */ |
||||
{ /* 34 */ 1, { 2, 2, 2, 1 } }, /* 111111111001 */ |
||||
{ /* 35 */ 1, { 2, 1, 2, 1 } }, /* 111111111010 */ |
||||
{ /* 36 */ 1, { 1, 2, 1, 2 } }, /* 111111111011 */ |
||||
{ /* 37 */ 1, { 1, 2, 2, 2 } }, /* 111111111100 */ |
||||
{ /* 38 */ 0, { 3, 4, 0, 0 } }, |
||||
{ /* 39 */ 0, { 4, 5, 0, 0 } }, |
||||
{ /* 40 */ 0, { 5, 6, 0, 0 } }, |
||||
{ /* 41 */ 1, { 0, 2, 0, 2 } }, /* 1111111111010 */ |
||||
{ /* 42 */ 1, { 2, 0, 2, 0 } }, /* 1111111111011 */ |
||||
{ /* 43 */ 1, { 1, 2, 0, 2 } }, /* 1111111111100 */ |
||||
{ /* 44 */ 0, { 3, 4, 0, 0 } }, |
||||
{ /* 45 */ 0, { 4, 5, 0, 0 } }, |
||||
{ /* 46 */ 0, { 5, 6, 0, 0 } }, |
||||
{ /* 47 */ 1, { 2, 0, 2, 1 } }, /* 11111111111010 */ |
||||
{ /* 48 */ 1, { 2, 1, 1, 2 } }, /* 11111111111011 */ |
||||
{ /* 49 */ 1, { 2, 1, 0, 2 } }, /* 11111111111100 */ |
||||
{ /* 50 */ 0, { 3, 4, 0, 0 } }, |
||||
{ /* 51 */ 0, { 4, 5, 0, 0 } }, |
||||
{ /* 52 */ 0, { 5, 6, 0, 0 } }, |
||||
{ /* 53 */ 1, { 2, 2, 2, 2 } }, /* 111111111111010 */ |
||||
{ /* 54 */ 1, { 2, 2, 1, 2 } }, /* 111111111111011 */ |
||||
{ /* 55 */ 1, { 2, 1, 2, 2 } }, /* 111111111111100 */ |
||||
{ /* 56 */ 1, { 2, 0, 1, 2 } }, /* 111111111111101 */ |
||||
{ /* 57 */ 1, { 2, 0, 0, 2 } }, /* 111111111111110 */ |
||||
{ /* 58 */ 0, { 1, 2, 0, 0 } }, |
||||
{ /* 59 */ 1, { 2, 2, 0, 2 } }, /* 1111111111111110 */ |
||||
{ /* 60 */ 1, { 2, 0, 2, 2 } } /* 1111111111111111 */ |
||||
}; |
@ -0,0 +1,199 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_4.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_4 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb4_1[] = { |
||||
/* 4 bit codewords */ |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 00010 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* 00100 */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
{ /* 00110 */ 3, 0 }, |
||||
{ /* */ 3, 0 }, |
||||
{ /* 01000 */ 4, 0 }, |
||||
{ /* */ 4, 0 }, |
||||
{ /* 01010 */ 5, 0 }, |
||||
{ /* */ 5, 0 }, |
||||
{ /* 01100 */ 6, 0 }, |
||||
{ /* */ 6, 0 }, |
||||
{ /* 01110 */ 7, 0 }, |
||||
{ /* */ 7, 0 }, |
||||
{ /* 10000 */ 8, 0 }, |
||||
{ /* */ 8, 0 }, |
||||
{ /* 10010 */ 9, 0 }, |
||||
{ /* */ 9, 0 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ /* 10100 */ 10, 0 }, |
||||
{ /* 10101 */ 11, 0 }, |
||||
{ /* 10110 */ 12, 0 }, |
||||
{ /* 10111 */ 13, 0 }, |
||||
{ /* 11000 */ 14, 0 }, |
||||
{ /* 11001 */ 15, 0 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ /* 11010 */ 16, 2 }, |
||||
{ /* 11011 */ 20, 2 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ /* 11100 */ 24, 3 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ /* 11101 */ 32, 3 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ /* 11110 */ 40, 4 }, |
||||
|
||||
/* 9/10/11/12 bit codewords */ |
||||
{ /* 11111 */ 56, 7 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_quad hcb4_2[] = { |
||||
/* 4 bit codewords */ |
||||
{ 4, 1, 1, 1, 1 }, |
||||
{ 4, 0, 1, 1, 1 }, |
||||
{ 4, 1, 1, 0, 1 }, |
||||
{ 4, 1, 1, 1, 0 }, |
||||
{ 4, 1, 0, 1, 1 }, |
||||
{ 4, 1, 0, 0, 0 }, |
||||
{ 4, 1, 1, 0, 0 }, |
||||
{ 4, 0, 0, 0, 0 }, |
||||
{ 4, 0, 0, 1, 1 }, |
||||
{ 4, 1, 0, 1, 0 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ 5, 1, 0, 0, 1 }, |
||||
{ 5, 0, 1, 1, 0 }, |
||||
{ 5, 0, 0, 0, 1 }, |
||||
{ 5, 0, 1, 0, 1 }, |
||||
{ 5, 0, 0, 1, 0 }, |
||||
{ 5, 0, 1, 0, 0 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
/* first 5 bits: 11010 */ |
||||
{ 7, 2, 1, 1, 1 }, |
||||
{ 7, 1, 1, 2, 1 }, |
||||
{ 7, 1, 2, 1, 1 }, |
||||
{ 7, 1, 1, 1, 2 }, |
||||
/* first 5 bits: 11011 */ |
||||
{ 7, 2, 1, 1, 0 }, |
||||
{ 7, 2, 1, 0, 1 }, |
||||
{ 7, 1, 2, 1, 0 }, |
||||
{ 7, 2, 0, 1, 1 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
/* first 5 bits: 11100 */ |
||||
{ 7, 0, 1, 2, 1 }, { 7, 0, 1, 2, 1 }, |
||||
{ 8, 0, 1, 1, 2 }, |
||||
{ 8, 1, 1, 2, 0 }, |
||||
{ 8, 0, 2, 1, 1 }, |
||||
{ 8, 1, 0, 1, 2 }, |
||||
{ 8, 1, 2, 0, 1 }, |
||||
{ 8, 1, 1, 0, 2 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ 8, 1, 0, 2, 1 }, |
||||
{ 8, 2, 1, 0, 0 }, |
||||
{ 8, 2, 0, 1, 0 }, |
||||
{ 8, 1, 2, 0, 0 }, |
||||
{ 8, 2, 0, 0, 1 }, |
||||
{ 8, 0, 1, 0, 2 }, |
||||
{ 8, 0, 2, 1, 0 }, |
||||
{ 8, 0, 0, 1, 2 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ 8, 0, 1, 2, 0 }, { 8, 0, 1, 2, 0 }, |
||||
{ 8, 0, 2, 0, 1 }, { 8, 0, 2, 0, 1 }, |
||||
{ 8, 1, 0, 0, 2 }, { 8, 1, 0, 0, 2 }, |
||||
{ 8, 0, 0, 2, 1 }, { 8, 0, 0, 2, 1 }, |
||||
{ 8, 1, 0, 2, 0 }, { 8, 1, 0, 2, 0 }, |
||||
{ 8, 2, 0, 0, 0 }, { 8, 2, 0, 0, 0 }, |
||||
{ 8, 0, 0, 0, 2 }, { 8, 0, 0, 0, 2 }, |
||||
{ 9, 0, 2, 0, 0 }, |
||||
{ 9, 0, 0, 2, 0 }, |
||||
|
||||
/* 9/10/11 bit codewords */ |
||||
/* 9 bit codewords repeated 2^3 = 8 times */ |
||||
{ 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, |
||||
{ 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, |
||||
{ 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, |
||||
{ 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, |
||||
{ 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, |
||||
{ 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, |
||||
{ 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, |
||||
{ 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, |
||||
{ 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, |
||||
{ 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, |
||||
{ 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, |
||||
{ 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, |
||||
/* 10 bit codewords repeated 2^2 = 4 times */ |
||||
{ 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, |
||||
{ 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, |
||||
{ 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, |
||||
{ 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, |
||||
{ 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, |
||||
{ 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, |
||||
{ 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, |
||||
{ 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, |
||||
{ 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, |
||||
{ 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, |
||||
{ 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, |
||||
{ 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, |
||||
{ 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, |
||||
{ 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, |
||||
/* 11 bit codewords repeated 2^1 = 2 times */ |
||||
{ 11, 2, 1, 2, 2 }, { 11, 2, 1, 2, 2 }, |
||||
{ 11, 2, 2, 1, 2 }, { 11, 2, 2, 1, 2 }, |
||||
{ 11, 0, 2, 2, 0 }, { 11, 0, 2, 2, 0 }, |
||||
{ 11, 2, 2, 0, 0 }, { 11, 2, 2, 0, 0 }, |
||||
{ 11, 0, 0, 2, 2 }, { 11, 0, 0, 2, 2 }, |
||||
{ 11, 2, 0, 2, 0 }, { 11, 2, 0, 2, 0 }, |
||||
{ 11, 0, 2, 0, 2 }, { 11, 0, 2, 0, 2 }, |
||||
{ 11, 2, 0, 0, 2 }, { 11, 2, 0, 0, 2 }, |
||||
{ 11, 2, 2, 2, 2 }, { 11, 2, 2, 2, 2 }, |
||||
{ 11, 0, 2, 2, 2 }, { 11, 0, 2, 2, 2 }, |
||||
{ 11, 2, 2, 2, 0 }, { 11, 2, 2, 2, 0 }, |
||||
/* 12 bit codewords */ |
||||
{ 12, 2, 2, 0, 2 }, |
||||
{ 12, 2, 0, 2, 2 }, |
||||
}; |
@ -0,0 +1,196 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_5.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* Binary search huffman table HCB_5 */ |
||||
|
||||
|
||||
static hcb_bin_pair hcb5[] = { |
||||
{ /* 0 */ 0, { 1, 2 } }, |
||||
{ /* 1 */ 1, { 0, 0 } }, /* 0 */ |
||||
{ /* 2 */ 0, { 1, 2 } }, |
||||
{ /* 3 */ 0, { 2, 3 } }, |
||||
{ /* 4 */ 0, { 3, 4 } }, |
||||
{ /* 5 */ 0, { 4, 5 } }, |
||||
{ /* 6 */ 0, { 5, 6 } }, |
||||
{ /* 7 */ 0, { 6, 7 } }, |
||||
{ /* 8 */ 0, { 7, 8 } }, |
||||
{ /* 9 */ 1, { -1, 0 } }, /* 1000 */ |
||||
{ /* 10 */ 1, { 1, 0 } }, /* 1001 */ |
||||
{ /* 11 */ 1, { 0, 1 } }, /* 1010 */ |
||||
{ /* 12 */ 1, { 0, -1 } }, /* 1011 */ |
||||
{ /* 13 */ 0, { 4, 5 } }, |
||||
{ /* 14 */ 0, { 5, 6 } }, |
||||
{ /* 15 */ 0, { 6, 7 } }, |
||||
{ /* 16 */ 0, { 7, 8 } }, |
||||
{ /* 17 */ 1, { 1, -1 } }, |
||||
{ /* 18 */ 1, { -1, 1 } }, |
||||
{ /* 19 */ 1, { -1, -1 } }, |
||||
{ /* 20 */ 1, { 1, 1 } }, |
||||
{ /* 21 */ 0, { 4, 5 } }, |
||||
{ /* 22 */ 0, { 5, 6 } }, |
||||
{ /* 23 */ 0, { 6, 7 } }, |
||||
{ /* 24 */ 0, { 7, 8 } }, |
||||
{ /* 25 */ 0, { 8, 9 } }, |
||||
{ /* 26 */ 0, { 9, 10 } }, |
||||
{ /* 27 */ 0, { 10, 11 } }, |
||||
{ /* 28 */ 0, { 11, 12 } }, |
||||
{ /* 29 */ 0, { 12, 13 } }, |
||||
{ /* 30 */ 0, { 13, 14 } }, |
||||
{ /* 31 */ 0, { 14, 15 } }, |
||||
{ /* 32 */ 0, { 15, 16 } }, |
||||
{ /* 33 */ 1, { -2, 0 } }, |
||||
{ /* 34 */ 1, { 0, 2 } }, |
||||
{ /* 35 */ 1, { 2, 0 } }, |
||||
{ /* 36 */ 1, { 0, -2 } }, |
||||
{ /* 37 */ 0, { 12, 13 } }, |
||||
{ /* 38 */ 0, { 13, 14 } }, |
||||
{ /* 39 */ 0, { 14, 15 } }, |
||||
{ /* 40 */ 0, { 15, 16 } }, |
||||
{ /* 41 */ 0, { 16, 17 } }, |
||||
{ /* 42 */ 0, { 17, 18 } }, |
||||
{ /* 43 */ 0, { 18, 19 } }, |
||||
{ /* 44 */ 0, { 19, 20 } }, |
||||
{ /* 45 */ 0, { 20, 21 } }, |
||||
{ /* 46 */ 0, { 21, 22 } }, |
||||
{ /* 47 */ 0, { 22, 23 } }, |
||||
{ /* 48 */ 0, { 23, 24 } }, |
||||
{ /* 49 */ 1, { -2, -1 } }, |
||||
{ /* 50 */ 1, { 2, 1 } }, |
||||
{ /* 51 */ 1, { -1, -2 } }, |
||||
{ /* 52 */ 1, { 1, 2 } }, |
||||
{ /* 53 */ 1, { -2, 1 } }, |
||||
{ /* 54 */ 1, { 2, -1 } }, |
||||
{ /* 55 */ 1, { -1, 2 } }, |
||||
{ /* 56 */ 1, { 1, -2 } }, |
||||
{ /* 57 */ 1, { -3, 0 } }, |
||||
{ /* 58 */ 1, { 3, 0 } }, |
||||
{ /* 59 */ 1, { 0, -3 } }, |
||||
{ /* 60 */ 1, { 0, 3 } }, |
||||
{ /* 61 */ 0, { 12, 13 } }, |
||||
{ /* 62 */ 0, { 13, 14 } }, |
||||
{ /* 63 */ 0, { 14, 15 } }, |
||||
{ /* 64 */ 0, { 15, 16 } }, |
||||
{ /* 65 */ 0, { 16, 17 } }, |
||||
{ /* 66 */ 0, { 17, 18 } }, |
||||
{ /* 67 */ 0, { 18, 19 } }, |
||||
{ /* 68 */ 0, { 19, 20 } }, |
||||
{ /* 69 */ 0, { 20, 21 } }, |
||||
{ /* 70 */ 0, { 21, 22 } }, |
||||
{ /* 71 */ 0, { 22, 23 } }, |
||||
{ /* 72 */ 0, { 23, 24 } }, |
||||
{ /* 73 */ 1, { -3, -1 } }, |
||||
{ /* 74 */ 1, { 1, 3 } }, |
||||
{ /* 75 */ 1, { 3, 1 } }, |
||||
{ /* 76 */ 1, { -1, -3 } }, |
||||
{ /* 77 */ 1, { -3, 1 } }, |
||||
{ /* 78 */ 1, { 3, -1 } }, |
||||
{ /* 79 */ 1, { 1, -3 } }, |
||||
{ /* 80 */ 1, { -1, 3 } }, |
||||
{ /* 81 */ 1, { -2, 2 } }, |
||||
{ /* 82 */ 1, { 2, 2 } }, |
||||
{ /* 83 */ 1, { -2, -2 } }, |
||||
{ /* 84 */ 1, { 2, -2 } }, |
||||
{ /* 85 */ 0, { 12, 13 } }, |
||||
{ /* 86 */ 0, { 13, 14 } }, |
||||
{ /* 87 */ 0, { 14, 15 } }, |
||||
{ /* 88 */ 0, { 15, 16 } }, |
||||
{ /* 89 */ 0, { 16, 17 } }, |
||||
{ /* 90 */ 0, { 17, 18 } }, |
||||
{ /* 91 */ 0, { 18, 19 } }, |
||||
{ /* 92 */ 0, { 19, 20 } }, |
||||
{ /* 93 */ 0, { 20, 21 } }, |
||||
{ /* 94 */ 0, { 21, 22 } }, |
||||
{ /* 95 */ 0, { 22, 23 } }, |
||||
{ /* 96 */ 0, { 23, 24 } }, |
||||
{ /* 97 */ 1, { -3, -2 } }, |
||||
{ /* 98 */ 1, { 3, -2 } }, |
||||
{ /* 99 */ 1, { -2, 3 } }, |
||||
{ /* 00 */ 1, { 2, -3 } }, |
||||
{ /* 01 */ 1, { 3, 2 } }, |
||||
{ /* 02 */ 1, { 2, 3 } }, |
||||
{ /* 03 */ 1, { -3, 2 } }, |
||||
{ /* 04 */ 1, { -2, -3 } }, |
||||
{ /* 05 */ 1, { 0, -4 } }, |
||||
{ /* 06 */ 1, { -4, 0 } }, |
||||
{ /* 07 */ 1, { 4, 1 } }, |
||||
{ /* 08 */ 1, { 4, 0 } }, |
||||
{ /* 09 */ 0, { 12, 13 } }, |
||||
{ /* 10 */ 0, { 13, 14 } }, |
||||
{ /* 11 */ 0, { 14, 15 } }, |
||||
{ /* 12 */ 0, { 15, 16 } }, |
||||
{ /* 13 */ 0, { 16, 17 } }, |
||||
{ /* 14 */ 0, { 17, 18 } }, |
||||
{ /* 15 */ 0, { 18, 19 } }, |
||||
{ /* 16 */ 0, { 19, 20 } }, |
||||
{ /* 17 */ 0, { 20, 21 } }, |
||||
{ /* 18 */ 0, { 21, 22 } }, |
||||
{ /* 19 */ 0, { 22, 23 } }, |
||||
{ /* 20 */ 0, { 23, 24 } }, |
||||
{ /* 21 */ 1, { -4, -1 } }, |
||||
{ /* 22 */ 1, { 0, 4 } }, |
||||
{ /* 23 */ 1, { 4, -1 } }, |
||||
{ /* 24 */ 1, { -1, -4 } }, |
||||
{ /* 25 */ 1, { 1, 4 } }, |
||||
{ /* 26 */ 1, { -1, 4 } }, |
||||
{ /* 27 */ 1, { -4, 1 } }, |
||||
{ /* 28 */ 1, { 1, -4 } }, |
||||
{ /* 29 */ 1, { 3, -3 } }, |
||||
{ /* 30 */ 1, { -3, -3 } }, |
||||
{ /* 31 */ 1, { -3, 3 } }, |
||||
{ /* 32 */ 1, { -2, 4 } }, |
||||
{ /* 33 */ 1, { -4, -2 } }, |
||||
{ /* 34 */ 1, { 4, 2 } }, |
||||
{ /* 35 */ 1, { 2, -4 } }, |
||||
{ /* 36 */ 1, { 2, 4 } }, |
||||
{ /* 37 */ 1, { 3, 3 } }, |
||||
{ /* 38 */ 1, { -4, 2 } }, |
||||
{ /* 39 */ 0, { 6, 7 } }, |
||||
{ /* 40 */ 0, { 7, 8 } }, |
||||
{ /* 41 */ 0, { 8, 9 } }, |
||||
{ /* 42 */ 0, { 9, 10 } }, |
||||
{ /* 43 */ 0, { 10, 11 } }, |
||||
{ /* 44 */ 0, { 11, 12 } }, |
||||
{ /* 45 */ 1, { -2, -4 } }, |
||||
{ /* 46 */ 1, { 4, -2 } }, |
||||
{ /* 47 */ 1, { 3, -4 } }, |
||||
{ /* 48 */ 1, { -4, -3 } }, |
||||
{ /* 49 */ 1, { -4, 3 } }, |
||||
{ /* 50 */ 1, { 3, 4 } }, |
||||
{ /* 51 */ 1, { -3, 4 } }, |
||||
{ /* 52 */ 1, { 4, 3 } }, |
||||
{ /* 53 */ 1, { 4, -3 } }, |
||||
{ /* 54 */ 1, { -3, -4 } }, |
||||
{ /* 55 */ 0, { 2, 3 } }, |
||||
{ /* 56 */ 0, { 3, 4 } }, |
||||
{ /* 57 */ 1, { 4, -4 } }, |
||||
{ /* 58 */ 1, { -4, 4 } }, |
||||
{ /* 59 */ 1, { 4, 4 } }, |
||||
{ /* 60 */ 1, { -4, -4 } } |
||||
}; |
@ -0,0 +1,182 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_6.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_6 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb6_1[] = { |
||||
/* 4 bit codewords */ |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* 00010 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* 00100 */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
{ /* 00110 */ 3, 0 }, |
||||
{ /* */ 3, 0 }, |
||||
{ /* 01000 */ 4, 0 }, |
||||
{ /* */ 4, 0 }, |
||||
{ /* 01010 */ 5, 0 }, |
||||
{ /* */ 5, 0 }, |
||||
{ /* 01100 */ 6, 0 }, |
||||
{ /* */ 6, 0 }, |
||||
{ /* 01110 */ 7, 0 }, |
||||
{ /* */ 7, 0 }, |
||||
{ /* 10000 */ 8, 0 }, |
||||
{ /* */ 8, 0 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ /* 10010 */ 9, 1 }, |
||||
{ /* 10011 */ 11, 1 }, |
||||
{ /* 10100 */ 13, 1 }, |
||||
{ /* 10101 */ 15, 1 }, |
||||
{ /* 10110 */ 17, 1 }, |
||||
{ /* 10111 */ 19, 1 }, |
||||
{ /* 11000 */ 21, 1 }, |
||||
{ /* 11001 */ 23, 1 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ /* 11010 */ 25, 2 }, |
||||
{ /* 11011 */ 29, 2 }, |
||||
{ /* 11100 */ 33, 2 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ /* 11101 */ 37, 3 }, |
||||
|
||||
/* 8/9 bit codewords */ |
||||
{ /* 11110 */ 45, 4 }, |
||||
|
||||
/* 9/10/11 bit codewords */ |
||||
{ /* 11111 */ 61, 6 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_pair hcb6_2[] = { |
||||
/* 4 bit codewords */ |
||||
{ 4, 0, 0 }, |
||||
{ 4, 1, 0 }, |
||||
{ 4, 0, -1 }, |
||||
{ 4, 0, 1 }, |
||||
{ 4, -1, 0 }, |
||||
{ 4, 1, 1 }, |
||||
{ 4, -1, 1 }, |
||||
{ 4, 1, -1 }, |
||||
{ 4, -1, -1 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ 6, 2, -1 }, |
||||
{ 6, 2, 1 }, |
||||
{ 6, -2, 1 }, |
||||
{ 6, -2, -1 }, |
||||
{ 6, -2, 0 }, |
||||
{ 6, -1, 2 }, |
||||
{ 6, 2, 0 }, |
||||
{ 6, 1, -2 }, |
||||
{ 6, 1, 2 }, |
||||
{ 6, 0, -2 }, |
||||
{ 6, -1, -2 }, |
||||
{ 6, 0, 2 }, |
||||
{ 6, 2, -2 }, |
||||
{ 6, -2, 2 }, |
||||
{ 6, -2, -2 }, |
||||
{ 6, 2, 2 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ 7, -3, 1 }, |
||||
{ 7, 3, 1 }, |
||||
{ 7, 3, -1 }, |
||||
{ 7, -1, 3 }, |
||||
{ 7, -3, -1 }, |
||||
{ 7, 1, 3 }, |
||||
{ 7, 1, -3 }, |
||||
{ 7, -1, -3 }, |
||||
{ 7, 3, 0 }, |
||||
{ 7, -3, 0 }, |
||||
{ 7, 0, -3 }, |
||||
{ 7, 0, 3 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ 7, 3, 2 }, { 7, 3, 2 }, |
||||
{ 8, -3, -2 }, |
||||
{ 8, -2, 3 }, |
||||
{ 8, 2, 3 }, |
||||
{ 8, 3, -2 }, |
||||
{ 8, 2, -3 }, |
||||
{ 8, -2, -3 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ 8, -3, 2 }, { 8, -3, 2 }, |
||||
{ 8, 3, 3 }, { 8, 3, 3 }, |
||||
{ 9, 3, -3 }, |
||||
{ 9, -3, -3 }, |
||||
{ 9, -3, 3 }, |
||||
{ 9, 1, -4 }, |
||||
{ 9, -1, -4 }, |
||||
{ 9, 4, 1 }, |
||||
{ 9, -4, 1 }, |
||||
{ 9, -4, -1 }, |
||||
{ 9, 1, 4 }, |
||||
{ 9, 4, -1 }, |
||||
{ 9, -1, 4 }, |
||||
{ 9, 0, -4 }, |
||||
|
||||
/* 9/10/11 bit codewords */ |
||||
{ 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, |
||||
{ 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, |
||||
{ 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, |
||||
{ 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, |
||||
{ 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, |
||||
{ 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, |
||||
{ 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, |
||||
{ 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, |
||||
{ 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, |
||||
{ 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, |
||||
{ 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, |
||||
{ 10, -3, -4 }, { 10, -3, -4 }, |
||||
{ 10, -3, 4 }, { 10, -3, 4 }, |
||||
{ 10, 3, -4 }, { 10, 3, -4 }, |
||||
{ 10, 4, -3 }, { 10, 4, -3 }, |
||||
{ 10, 3, 4 }, { 10, 3, 4 }, |
||||
{ 10, 4, 3 }, { 10, 4, 3 }, |
||||
{ 10, -4, 3 }, { 10, -4, 3 }, |
||||
{ 10, -4, -3 }, { 10, -4, -3 }, |
||||
{ 11, 4, 4 }, |
||||
{ 11, -4, 4 }, |
||||
{ 11, -4, -4 }, |
||||
{ 11, 4, -4 } |
||||
}; |
@ -0,0 +1,162 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_7.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* Binary search huffman table HCB_7 */ |
||||
|
||||
|
||||
static hcb_bin_pair hcb7[] = { |
||||
{ /* 0 */ 0, { 1, 2 } }, |
||||
{ /* 1 */ 1, { 0, 0 } }, |
||||
{ /* 2 */ 0, { 1, 2 } }, |
||||
{ /* 3 */ 0, { 2, 3 } }, |
||||
{ /* 4 */ 0, { 3, 4 } }, |
||||
{ /* 5 */ 1, { 1, 0 } }, |
||||
{ /* 6 */ 1, { 0, 1 } }, |
||||
{ /* 7 */ 0, { 2, 3 } }, |
||||
{ /* 8 */ 0, { 3, 4 } }, |
||||
{ /* 9 */ 1, { 1, 1 } }, |
||||
{ /* 10 */ 0, { 3, 4 } }, |
||||
{ /* 11 */ 0, { 4, 5 } }, |
||||
{ /* 12 */ 0, { 5, 6 } }, |
||||
{ /* 13 */ 0, { 6, 7 } }, |
||||
{ /* 14 */ 0, { 7, 8 } }, |
||||
{ /* 15 */ 0, { 8, 9 } }, |
||||
{ /* 16 */ 0, { 9, 10 } }, |
||||
{ /* 17 */ 0, { 10, 11 } }, |
||||
{ /* 18 */ 0, { 11, 12 } }, |
||||
{ /* 19 */ 1, { 2, 1 } }, |
||||
{ /* 20 */ 1, { 1, 2 } }, |
||||
{ /* 21 */ 1, { 2, 0 } }, |
||||
{ /* 22 */ 1, { 0, 2 } }, |
||||
{ /* 23 */ 0, { 8, 9 } }, |
||||
{ /* 24 */ 0, { 9, 10 } }, |
||||
{ /* 25 */ 0, { 10, 11 } }, |
||||
{ /* 26 */ 0, { 11, 12 } }, |
||||
{ /* 27 */ 0, { 12, 13 } }, |
||||
{ /* 28 */ 0, { 13, 14 } }, |
||||
{ /* 29 */ 0, { 14, 15 } }, |
||||
{ /* 30 */ 0, { 15, 16 } }, |
||||
{ /* 31 */ 1, { 3, 1 } }, |
||||
{ /* 32 */ 1, { 1, 3 } }, |
||||
{ /* 33 */ 1, { 2, 2 } }, |
||||
{ /* 34 */ 1, { 3, 0 } }, |
||||
{ /* 35 */ 1, { 0, 3 } }, |
||||
{ /* 36 */ 0, { 11, 12 } }, |
||||
{ /* 37 */ 0, { 12, 13 } }, |
||||
{ /* 38 */ 0, { 13, 14 } }, |
||||
{ /* 39 */ 0, { 14, 15 } }, |
||||
{ /* 40 */ 0, { 15, 16 } }, |
||||
{ /* 41 */ 0, { 16, 17 } }, |
||||
{ /* 42 */ 0, { 17, 18 } }, |
||||
{ /* 43 */ 0, { 18, 19 } }, |
||||
{ /* 44 */ 0, { 19, 20 } }, |
||||
{ /* 45 */ 0, { 20, 21 } }, |
||||
{ /* 46 */ 0, { 21, 22 } }, |
||||
{ /* 47 */ 1, { 2, 3 } }, |
||||
{ /* 48 */ 1, { 3, 2 } }, |
||||
{ /* 49 */ 1, { 1, 4 } }, |
||||
{ /* 50 */ 1, { 4, 1 } }, |
||||
{ /* 51 */ 1, { 1, 5 } }, |
||||
{ /* 52 */ 1, { 5, 1 } }, |
||||
{ /* 53 */ 1, { 3, 3 } }, |
||||
{ /* 54 */ 1, { 2, 4 } }, |
||||
{ /* 55 */ 1, { 0, 4 } }, |
||||
{ /* 56 */ 1, { 4, 0 } }, |
||||
{ /* 57 */ 0, { 12, 13 } }, |
||||
{ /* 58 */ 0, { 13, 14 } }, |
||||
{ /* 59 */ 0, { 14, 15 } }, |
||||
{ /* 60 */ 0, { 15, 16 } }, |
||||
{ /* 61 */ 0, { 16, 17 } }, |
||||
{ /* 62 */ 0, { 17, 18 } }, |
||||
{ /* 63 */ 0, { 18, 19 } }, |
||||
{ /* 64 */ 0, { 19, 20 } }, |
||||
{ /* 65 */ 0, { 20, 21 } }, |
||||
{ /* 66 */ 0, { 21, 22 } }, |
||||
{ /* 67 */ 0, { 22, 23 } }, |
||||
{ /* 68 */ 0, { 23, 24 } }, |
||||
{ /* 69 */ 1, { 4, 2 } }, |
||||
{ /* 70 */ 1, { 2, 5 } }, |
||||
{ /* 71 */ 1, { 5, 2 } }, |
||||
{ /* 72 */ 1, { 0, 5 } }, |
||||
{ /* 73 */ 1, { 6, 1 } }, |
||||
{ /* 74 */ 1, { 5, 0 } }, |
||||
{ /* 75 */ 1, { 1, 6 } }, |
||||
{ /* 76 */ 1, { 4, 3 } }, |
||||
{ /* 77 */ 1, { 3, 5 } }, |
||||
{ /* 78 */ 1, { 3, 4 } }, |
||||
{ /* 79 */ 1, { 5, 3 } }, |
||||
{ /* 80 */ 1, { 2, 6 } }, |
||||
{ /* 81 */ 1, { 6, 2 } }, |
||||
{ /* 82 */ 1, { 1, 7 } }, |
||||
{ /* 83 */ 0, { 10, 11 } }, |
||||
{ /* 84 */ 0, { 11, 12 } }, |
||||
{ /* 85 */ 0, { 12, 13 } }, |
||||
{ /* 86 */ 0, { 13, 14 } }, |
||||
{ /* 87 */ 0, { 14, 15 } }, |
||||
{ /* 88 */ 0, { 15, 16 } }, |
||||
{ /* 89 */ 0, { 16, 17 } }, |
||||
{ /* 90 */ 0, { 17, 18 } }, |
||||
{ /* 91 */ 0, { 18, 19 } }, |
||||
{ /* 92 */ 0, { 19, 20 } }, |
||||
{ /* 93 */ 1, { 3, 6 } }, |
||||
{ /* 94 */ 1, { 0, 6 } }, |
||||
{ /* 95 */ 1, { 6, 0 } }, |
||||
{ /* 96 */ 1, { 4, 4 } }, |
||||
{ /* 97 */ 1, { 7, 1 } }, |
||||
{ /* 98 */ 1, { 4, 5 } }, |
||||
{ /* 99 */ 1, { 7, 2 } }, |
||||
{ /* 00 */ 1, { 5, 4 } }, |
||||
{ /* 01 */ 1, { 6, 3 } }, |
||||
{ /* 02 */ 1, { 2, 7 } }, |
||||
{ /* 03 */ 1, { 7, 3 } }, |
||||
{ /* 04 */ 1, { 6, 4 } }, |
||||
{ /* 05 */ 1, { 5, 5 } }, |
||||
{ /* 06 */ 1, { 4, 6 } }, |
||||
{ /* 07 */ 1, { 3, 7 } }, |
||||
{ /* 08 */ 0, { 5, 6 } }, |
||||
{ /* 09 */ 0, { 6, 7 } }, |
||||
{ /* 10 */ 0, { 7, 8 } }, |
||||
{ /* 11 */ 0, { 8, 9 } }, |
||||
{ /* 12 */ 0, { 9, 10 } }, |
||||
{ /* 13 */ 1, { 7, 0 } }, |
||||
{ /* 14 */ 1, { 0, 7 } }, |
||||
{ /* 15 */ 1, { 6, 5 } }, |
||||
{ /* 16 */ 1, { 5, 6 } }, |
||||
{ /* 17 */ 1, { 7, 4 } }, |
||||
{ /* 18 */ 1, { 4, 7 } }, |
||||
{ /* 19 */ 1, { 5, 7 } }, |
||||
{ /* 20 */ 1, { 7, 5 } }, |
||||
{ /* 21 */ 0, { 2, 3 } }, |
||||
{ /* 22 */ 0, { 3, 4 } }, |
||||
{ /* 23 */ 1, { 7, 6 } }, |
||||
{ /* 24 */ 1, { 6, 6 } }, |
||||
{ /* 25 */ 1, { 6, 7 } }, |
||||
{ /* 26 */ 1, { 7, 7 } } |
||||
}; |
@ -0,0 +1,173 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_8.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* 2-step huffman table HCB_8 */ |
||||
|
||||
|
||||
/* 1st step: 5 bits
|
||||
* 2^5 = 32 entries |
||||
* |
||||
* Used to find offset into 2nd step table and number of extra bits to get |
||||
*/ |
||||
static hcb hcb8_1[] = { |
||||
/* 3 bit codeword */ |
||||
{ /* 00000 */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
{ /* */ 0, 0 }, |
||||
|
||||
/* 4 bit codewords */ |
||||
{ /* 00100 */ 1, 0 }, |
||||
{ /* */ 1, 0 }, |
||||
{ /* 00110 */ 2, 0 }, |
||||
{ /* */ 2, 0 }, |
||||
{ /* 01000 */ 3, 0 }, |
||||
{ /* */ 3, 0 }, |
||||
{ /* 01010 */ 4, 0 }, |
||||
{ /* */ 4, 0 }, |
||||
{ /* 01100 */ 5, 0 }, |
||||
{ /* */ 5, 0 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ /* 01110 */ 6, 0 }, |
||||
{ /* 01111 */ 7, 0 }, |
||||
{ /* 10000 */ 8, 0 }, |
||||
{ /* 10001 */ 9, 0 }, |
||||
{ /* 10010 */ 10, 0 }, |
||||
{ /* 10011 */ 11, 0 }, |
||||
{ /* 10100 */ 12, 0 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ /* 10101 */ 13, 1 }, |
||||
{ /* 10110 */ 15, 1 }, |
||||
{ /* 10111 */ 17, 1 }, |
||||
{ /* 11000 */ 19, 1 }, |
||||
{ /* 11001 */ 21, 1 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ /* 11010 */ 23, 2 }, |
||||
{ /* 11011 */ 27, 2 }, |
||||
{ /* 11100 */ 31, 2 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ /* 11101 */ 35, 3 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ /* 11110 */ 43, 3 }, |
||||
|
||||
/* 8/9/10 bit codewords */ |
||||
{ /* 11111 */ 51, 5 } |
||||
}; |
||||
|
||||
/* 2nd step table
|
||||
* |
||||
* Gives size of codeword and actual data (x,y,v,w) |
||||
*/ |
||||
static hcb_2_pair hcb8_2[] = { |
||||
/* 3 bit codeword */ |
||||
{ 3, 1, 1 }, |
||||
|
||||
/* 4 bit codewords */ |
||||
{ 4, 2, 1 }, |
||||
{ 4, 1, 0 }, |
||||
{ 4, 1, 2 }, |
||||
{ 4, 0, 1 }, |
||||
{ 4, 2, 2 }, |
||||
|
||||
/* 5 bit codewords */ |
||||
{ 5, 0, 0 }, |
||||
{ 5, 2, 0 }, |
||||
{ 5, 0, 2 }, |
||||
{ 5, 3, 1 }, |
||||
{ 5, 1, 3 }, |
||||
{ 5, 3, 2 }, |
||||
{ 5, 2, 3 }, |
||||
|
||||
/* 6 bit codewords */ |
||||
{ 6, 3, 3 }, |
||||
{ 6, 4, 1 }, |
||||
{ 6, 1, 4 }, |
||||
{ 6, 4, 2 }, |
||||
{ 6, 2, 4 }, |
||||
{ 6, 3, 0 }, |
||||
{ 6, 0, 3 }, |
||||
{ 6, 4, 3 }, |
||||
{ 6, 3, 4 }, |
||||
{ 6, 5, 2 }, |
||||
|
||||
/* 7 bit codewords */ |
||||
{ 7, 5, 1 }, |
||||
{ 7, 2, 5 }, |
||||
{ 7, 1, 5 }, |
||||
{ 7, 5, 3 }, |
||||
{ 7, 3, 5 }, |
||||
{ 7, 4, 4 }, |
||||
{ 7, 5, 4 }, |
||||
{ 7, 0, 4 }, |
||||
{ 7, 4, 5 }, |
||||
{ 7, 4, 0 }, |
||||
{ 7, 2, 6 }, |
||||
{ 7, 6, 2 }, |
||||
|
||||
/* 7/8 bit codewords */ |
||||
{ 7, 6, 1 }, { 7, 6, 1 }, |
||||
{ 7, 1, 6 }, { 7, 1, 6 }, |
||||
{ 8, 3, 6 }, |
||||
{ 8, 6, 3 }, |
||||
{ 8, 5, 5 }, |
||||
{ 8, 5, 0 }, |
||||
|
||||
/* 8 bit codewords */ |
||||
{ 8, 6, 4 }, |
||||
{ 8, 0, 5 }, |
||||
{ 8, 4, 6 }, |
||||
{ 8, 7, 1 }, |
||||
{ 8, 7, 2 }, |
||||
{ 8, 2, 7 }, |
||||
{ 8, 6, 5 }, |
||||
{ 8, 7, 3 }, |
||||
|
||||
/* 8/9/10 bit codewords */ |
||||
{ 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, |
||||
{ 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, |
||||
{ 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, |
||||
{ 9, 6, 6 }, { 9, 6, 6 }, |
||||
{ 9, 7, 4 }, { 9, 7, 4 }, |
||||
{ 9, 6, 0 }, { 9, 6, 0 }, |
||||
{ 9, 4, 7 }, { 9, 4, 7 }, |
||||
{ 9, 0, 6 }, { 9, 0, 6 }, |
||||
{ 9, 7, 5 }, { 9, 7, 5 }, |
||||
{ 9, 7, 6 }, { 9, 7, 6 }, |
||||
{ 9, 6, 7 }, { 9, 6, 7 }, |
||||
{ 10, 5, 7 }, |
||||
{ 10, 7, 0 }, |
||||
{ 10, 0, 7 }, |
||||
{ 10, 7, 7 } |
||||
}; |
@ -0,0 +1,372 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_9.h,v 1.5 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* Binary search huffman table HCB_9 */ |
||||
|
||||
|
||||
static hcb_bin_pair hcb9[] = { |
||||
{ /* 0 */ 0, { 1, 2 } }, |
||||
{ /* 1 */ 1, { 0, 0 } }, |
||||
{ /* 2 */ 0, { 1, 2 } }, |
||||
{ /* 3 */ 0, { 2, 3 } }, |
||||
{ /* 4 */ 0, { 3, 4 } }, |
||||
{ /* 5 */ 1, { 1, 0 } }, |
||||
{ /* 6 */ 1, { 0, 1 } }, |
||||
{ /* 7 */ 0, { 2, 3 } }, |
||||
{ /* 8 */ 0, { 3, 4 } }, |
||||
{ /* 9 */ 1, { 1, 1 } }, |
||||
{ /* 10 */ 0, { 3, 4 } }, |
||||
{ /* 11 */ 0, { 4, 5 } }, |
||||
{ /* 12 */ 0, { 5, 6 } }, |
||||
{ /* 13 */ 0, { 6, 7 } }, |
||||
{ /* 14 */ 0, { 7, 8 } }, |
||||
{ /* 15 */ 0, { 8, 9 } }, |
||||
{ /* 16 */ 0, { 9, 10 } }, |
||||
{ /* 17 */ 0, { 10, 11 } }, |
||||
{ /* 18 */ 0, { 11, 12 } }, |
||||
{ /* 19 */ 1, { 2, 1 } }, |
||||
{ /* 20 */ 1, { 1, 2 } }, |
||||
{ /* 21 */ 1, { 2, 0 } }, |
||||
{ /* 22 */ 1, { 0, 2 } }, |
||||
{ /* 23 */ 0, { 8, 9 } }, |
||||
{ /* 24 */ 0, { 9, 10 } }, |
||||
{ /* 25 */ 0, { 10, 11 } }, |
||||
{ /* 26 */ 0, { 11, 12 } }, |
||||
{ /* 27 */ 0, { 12, 13 } }, |
||||
{ /* 28 */ 0, { 13, 14 } }, |
||||
{ /* 29 */ 0, { 14, 15 } }, |
||||
{ /* 30 */ 0, { 15, 16 } }, |
||||
{ /* 31 */ 1, { 3, 1 } }, |
||||
{ /* 32 */ 1, { 2, 2 } }, |
||||
{ /* 33 */ 1, { 1, 3 } }, |
||||
{ /* 34 */ 0, { 13, 14 } }, |
||||
{ /* 35 */ 0, { 14, 15 } }, |
||||
{ /* 36 */ 0, { 15, 16 } }, |
||||
{ /* 37 */ 0, { 16, 17 } }, |
||||
{ /* 38 */ 0, { 17, 18 } }, |
||||
{ /* 39 */ 0, { 18, 19 } }, |
||||
{ /* 40 */ 0, { 19, 20 } }, |
||||
{ /* 41 */ 0, { 20, 21 } }, |
||||
{ /* 42 */ 0, { 21, 22 } }, |
||||
{ /* 43 */ 0, { 22, 23 } }, |
||||
{ /* 44 */ 0, { 23, 24 } }, |
||||
{ /* 45 */ 0, { 24, 25 } }, |
||||
{ /* 46 */ 0, { 25, 26 } }, |
||||
{ /* 47 */ 1, { 3, 0 } }, |
||||
{ /* 48 */ 1, { 0, 3 } }, |
||||
{ /* 49 */ 1, { 2, 3 } }, |
||||
{ /* 50 */ 1, { 3, 2 } }, |
||||
{ /* 51 */ 1, { 1, 4 } }, |
||||
{ /* 52 */ 1, { 4, 1 } }, |
||||
{ /* 53 */ 1, { 2, 4 } }, |
||||
{ /* 54 */ 1, { 1, 5 } }, |
||||
{ /* 55 */ 0, { 18, 19 } }, |
||||
{ /* 56 */ 0, { 19, 20 } }, |
||||
{ /* 57 */ 0, { 20, 21 } }, |
||||
{ /* 58 */ 0, { 21, 22 } }, |
||||
{ /* 59 */ 0, { 22, 23 } }, |
||||
{ /* 60 */ 0, { 23, 24 } }, |
||||
{ /* 61 */ 0, { 24, 25 } }, |
||||
{ /* 62 */ 0, { 25, 26 } }, |
||||
{ /* 63 */ 0, { 26, 27 } }, |
||||
{ /* 64 */ 0, { 27, 28 } }, |
||||
{ /* 65 */ 0, { 28, 29 } }, |
||||
{ /* 66 */ 0, { 29, 30 } }, |
||||
{ /* 67 */ 0, { 30, 31 } }, |
||||
{ /* 68 */ 0, { 31, 32 } }, |
||||
{ /* 69 */ 0, { 32, 33 } }, |
||||
{ /* 70 */ 0, { 33, 34 } }, |
||||
{ /* 71 */ 0, { 34, 35 } }, |
||||
{ /* 72 */ 0, { 35, 36 } }, |
||||
{ /* 73 */ 1, { 4, 2 } }, |
||||
{ /* 74 */ 1, { 3, 3 } }, |
||||
{ /* 75 */ 1, { 0, 4 } }, |
||||
{ /* 76 */ 1, { 4, 0 } }, |
||||
{ /* 77 */ 1, { 5, 1 } }, |
||||
{ /* 78 */ 1, { 2, 5 } }, |
||||
{ /* 79 */ 1, { 1, 6 } }, |
||||
{ /* 80 */ 1, { 3, 4 } }, |
||||
{ /* 81 */ 1, { 5, 2 } }, |
||||
{ /* 82 */ 1, { 6, 1 } }, |
||||
{ /* 83 */ 1, { 4, 3 } }, |
||||
{ /* 84 */ 0, { 25, 26 } }, |
||||
{ /* 85 */ 0, { 26, 27 } }, |
||||
{ /* 86 */ 0, { 27, 28 } }, |
||||
{ /* 87 */ 0, { 28, 29 } }, |
||||
{ /* 88 */ 0, { 29, 30 } }, |
||||
{ /* 89 */ 0, { 30, 31 } }, |
||||
{ /* 90 */ 0, { 31, 32 } }, |
||||
{ /* 91 */ 0, { 32, 33 } }, |
||||
{ /* 92 */ 0, { 33, 34 } }, |
||||
{ /* 93 */ 0, { 34, 35 } }, |
||||
{ /* 94 */ 0, { 35, 36 } }, |
||||
{ /* 95 */ 0, { 36, 37 } }, |
||||
{ /* 96 */ 0, { 37, 38 } }, |
||||
{ /* 97 */ 0, { 38, 39 } }, |
||||
{ /* 98 */ 0, { 39, 40 } }, |
||||
{ /* 99 */ 0, { 40, 41 } }, |
||||
{ /* 00 */ 0, { 41, 42 } }, |
||||
{ /* 01 */ 0, { 42, 43 } }, |
||||
{ /* 02 */ 0, { 43, 44 } }, |
||||
{ /* 03 */ 0, { 44, 45 } }, |
||||
{ /* 04 */ 0, { 45, 46 } }, |
||||
{ /* 05 */ 0, { 46, 47 } }, |
||||
{ /* 06 */ 0, { 47, 48 } }, |
||||
{ /* 07 */ 0, { 48, 49 } }, |
||||
{ /* 08 */ 0, { 49, 50 } }, |
||||
{ /* 09 */ 1, { 0, 5 } }, |
||||
{ /* 10 */ 1, { 2, 6 } }, |
||||
{ /* 11 */ 1, { 5, 0 } }, |
||||
{ /* 12 */ 1, { 1, 7 } }, |
||||
{ /* 13 */ 1, { 3, 5 } }, |
||||
{ /* 14 */ 1, { 1, 8 } }, |
||||
{ /* 15 */ 1, { 8, 1 } }, |
||||
{ /* 16 */ 1, { 4, 4 } }, |
||||
{ /* 17 */ 1, { 5, 3 } }, |
||||
{ /* 18 */ 1, { 6, 2 } }, |
||||
{ /* 19 */ 1, { 7, 1 } }, |
||||
{ /* 20 */ 1, { 0, 6 } }, |
||||
{ /* 21 */ 1, { 8, 2 } }, |
||||
{ /* 22 */ 1, { 2, 8 } }, |
||||
{ /* 23 */ 1, { 3, 6 } }, |
||||
{ /* 24 */ 1, { 2, 7 } }, |
||||
{ /* 25 */ 1, { 4, 5 } }, |
||||
{ /* 26 */ 1, { 9, 1 } }, |
||||
{ /* 27 */ 1, { 1, 9 } }, |
||||
{ /* 28 */ 1, { 7, 2 } }, |
||||
{ /* 29 */ 0, { 30, 31 } }, |
||||
{ /* 30 */ 0, { 31, 32 } }, |
||||
{ /* 31 */ 0, { 32, 33 } }, |
||||
{ /* 32 */ 0, { 33, 34 } }, |
||||
{ /* 33 */ 0, { 34, 35 } }, |
||||
{ /* 34 */ 0, { 35, 36 } }, |
||||
{ /* 35 */ 0, { 36, 37 } }, |
||||
{ /* 36 */ 0, { 37, 38 } }, |
||||
{ /* 37 */ 0, { 38, 39 } }, |
||||
{ /* 38 */ 0, { 39, 40 } }, |
||||
{ /* 39 */ 0, { 40, 41 } }, |
||||
{ /* 40 */ 0, { 41, 42 } }, |
||||
{ /* 41 */ 0, { 42, 43 } }, |
||||
{ /* 42 */ 0, { 43, 44 } }, |
||||
{ /* 43 */ 0, { 44, 45 } }, |
||||
{ /* 44 */ 0, { 45, 46 } }, |
||||
{ /* 45 */ 0, { 46, 47 } }, |
||||
{ /* 46 */ 0, { 47, 48 } }, |
||||
{ /* 47 */ 0, { 48, 49 } }, |
||||
{ /* 48 */ 0, { 49, 50 } }, |
||||
{ /* 49 */ 0, { 50, 51 } }, |
||||
{ /* 50 */ 0, { 51, 52 } }, |
||||
{ /* 51 */ 0, { 52, 53 } }, |
||||
{ /* 52 */ 0, { 53, 54 } }, |
||||
{ /* 53 */ 0, { 54, 55 } }, |
||||
{ /* 54 */ 0, { 55, 56 } }, |
||||
{ /* 55 */ 0, { 56, 57 } }, |
||||
{ /* 56 */ 0, { 57, 58 } }, |
||||
{ /* 57 */ 0, { 58, 59 } }, |
||||
{ /* 58 */ 0, { 59, 60 } }, |
||||
{ /* 59 */ 1, { 6, 0 } }, |
||||
{ /* 60 */ 1, { 5, 4 } }, |
||||
{ /* 61 */ 1, { 6, 3 } }, |
||||
{ /* 62 */ 1, { 8, 3 } }, |
||||
{ /* 63 */ 1, { 0, 7 } }, |
||||
{ /* 64 */ 1, { 9, 2 } }, |
||||
{ /* 65 */ 1, { 3, 8 } }, |
||||
{ /* 66 */ 1, { 4, 6 } }, |
||||
{ /* 67 */ 1, { 3, 7 } }, |
||||
{ /* 68 */ 1, { 0, 8 } }, |
||||
{ /* 69 */ 1, { 10, 1 } }, |
||||
{ /* 70 */ 1, { 6, 4 } }, |
||||
{ /* 71 */ 1, { 2, 9 } }, |
||||
{ /* 72 */ 1, { 5, 5 } }, |
||||
{ /* 73 */ 1, { 8, 0 } }, |
||||
{ /* 74 */ 1, { 7, 0 } }, |
||||
{ /* 75 */ 1, { 7, 3 } }, |
||||
{ /* 76 */ 1, { 10, 2 } }, |
||||
{ /* 77 */ 1, { 9, 3 } }, |
||||
{ /* 78 */ 1, { 8, 4 } }, |
||||
{ /* 79 */ 1, { 1, 10 } }, |
||||
{ /* 80 */ 1, { 7, 4 } }, |
||||
{ /* 81 */ 1, { 6, 5 } }, |
||||
{ /* 82 */ 1, { 5, 6 } }, |
||||
{ /* 83 */ 1, { 4, 8 } }, |
||||
{ /* 84 */ 1, { 4, 7 } }, |
||||
{ /* 85 */ 1, { 3, 9 } }, |
||||
{ /* 86 */ 1, { 11, 1 } }, |
||||
{ /* 87 */ 1, { 5, 8 } }, |
||||
{ /* 88 */ 1, { 9, 0 } }, |
||||
{ /* 89 */ 1, { 8, 5 } }, |
||||
{ /* 90 */ 0, { 29, 30 } }, |
||||
{ /* 91 */ 0, { 30, 31 } }, |
||||
{ /* 92 */ 0, { 31, 32 } }, |
||||
{ /* 93 */ 0, { 32, 33 } }, |
||||
{ /* 94 */ 0, { 33, 34 } }, |
||||
{ /* 95 */ 0, { 34, 35 } }, |
||||
{ /* 96 */ 0, { 35, 36 } }, |
||||
{ /* 97 */ 0, { 36, 37 } }, |
||||
{ /* 98 */ 0, { 37, 38 } }, |
||||
{ /* 99 */ 0, { 38, 39 } }, |
||||
{ /* 00 */ 0, { 39, 40 } }, |
||||
{ /* 01 */ 0, { 40, 41 } }, |
||||
{ /* 02 */ 0, { 41, 42 } }, |
||||
{ /* 03 */ 0, { 42, 43 } }, |
||||
{ /* 04 */ 0, { 43, 44 } }, |
||||
{ /* 05 */ 0, { 44, 45 } }, |
||||
{ /* 06 */ 0, { 45, 46 } }, |
||||
{ /* 07 */ 0, { 46, 47 } }, |
||||
{ /* 08 */ 0, { 47, 48 } }, |
||||
{ /* 09 */ 0, { 48, 49 } }, |
||||
{ /* 10 */ 0, { 49, 50 } }, |
||||
{ /* 11 */ 0, { 50, 51 } }, |
||||
{ /* 12 */ 0, { 51, 52 } }, |
||||
{ /* 13 */ 0, { 52, 53 } }, |
||||
{ /* 14 */ 0, { 53, 54 } }, |
||||
{ /* 15 */ 0, { 54, 55 } }, |
||||
{ /* 16 */ 0, { 55, 56 } }, |
||||
{ /* 17 */ 0, { 56, 57 } }, |
||||
{ /* 18 */ 0, { 57, 58 } }, |
||||
{ /* 19 */ 1, { 10, 3 } }, |
||||
{ /* 20 */ 1, { 2, 10 } }, |
||||
{ /* 21 */ 1, { 0, 9 } }, |
||||
{ /* 22 */ 1, { 11, 2 } }, |
||||
{ /* 23 */ 1, { 9, 4 } }, |
||||
{ /* 24 */ 1, { 6, 6 } }, |
||||
{ /* 25 */ 1, { 12, 1 } }, |
||||
{ /* 26 */ 1, { 4, 9 } }, |
||||
{ /* 27 */ 1, { 8, 6 } }, |
||||
{ /* 28 */ 1, { 1, 11 } }, |
||||
{ /* 29 */ 1, { 9, 5 } }, |
||||
{ /* 30 */ 1, { 10, 4 } }, |
||||
{ /* 31 */ 1, { 5, 7 } }, |
||||
{ /* 32 */ 1, { 7, 5 } }, |
||||
{ /* 33 */ 1, { 2, 11 } }, |
||||
{ /* 34 */ 1, { 1, 12 } }, |
||||
{ /* 35 */ 1, { 12, 2 } }, |
||||
{ /* 36 */ 1, { 11, 3 } }, |
||||
{ /* 37 */ 1, { 3, 10 } }, |
||||
{ /* 38 */ 1, { 5, 9 } }, |
||||
{ /* 39 */ 1, { 6, 7 } }, |
||||
{ /* 40 */ 1, { 8, 7 } }, |
||||
{ /* 41 */ 1, { 11, 4 } }, |
||||
{ /* 42 */ 1, { 0, 10 } }, |
||||
{ /* 43 */ 1, { 7, 6 } }, |
||||
{ /* 44 */ 1, { 12, 3 } }, |
||||
{ /* 45 */ 1, { 10, 0 } }, |
||||
{ /* 46 */ 1, { 10, 5 } }, |
||||
{ /* 47 */ 1, { 4, 10 } }, |
||||
{ /* 48 */ 1, { 6, 8 } }, |
||||
{ /* 49 */ 1, { 2, 12 } }, |
||||
{ /* 50 */ 1, { 9, 6 } }, |
||||
{ /* 51 */ 1, { 9, 7 } }, |
||||
{ /* 52 */ 1, { 4, 11 } }, |
||||
{ /* 53 */ 1, { 11, 0 } }, |
||||
{ /* 54 */ 1, { 6, 9 } }, |
||||
{ /* 55 */ 1, { 3, 11 } }, |
||||
{ /* 56 */ 1, { 5, 10 } }, |
||||
{ /* 57 */ 0, { 20, 21 } }, |
||||
{ /* 58 */ 0, { 21, 22 } }, |
||||
{ /* 59 */ 0, { 22, 23 } }, |
||||
{ /* 60 */ 0, { 23, 24 } }, |
||||
{ /* 61 */ 0, { 24, 25 } }, |
||||
{ /* 62 */ 0, { 25, 26 } }, |
||||
{ /* 63 */ 0, { 26, 27 } }, |
||||
{ /* 64 */ 0, { 27, 28 } }, |
||||
{ /* 65 */ 0, { 28, 29 } }, |
||||
{ /* 66 */ 0, { 29, 30 } }, |
||||
{ /* 67 */ 0, { 30, 31 } }, |
||||
{ /* 68 */ 0, { 31, 32 } }, |
||||
{ /* 69 */ 0, { 32, 33 } }, |
||||
{ /* 70 */ 0, { 33, 34 } }, |
||||
{ /* 71 */ 0, { 34, 35 } }, |
||||
{ /* 72 */ 0, { 35, 36 } }, |
||||
{ /* 73 */ 0, { 36, 37 } }, |
||||
{ /* 74 */ 0, { 37, 38 } }, |
||||
{ /* 75 */ 0, { 38, 39 } }, |
||||
{ /* 76 */ 0, { 39, 40 } }, |
||||
{ /* 77 */ 1, { 8, 8 } }, |
||||
{ /* 78 */ 1, { 7, 8 } }, |
||||
{ /* 79 */ 1, { 12, 5 } }, |
||||
{ /* 80 */ 1, { 3, 12 } }, |
||||
{ /* 81 */ 1, { 11, 5 } }, |
||||
{ /* 82 */ 1, { 7, 7 } }, |
||||
{ /* 83 */ 1, { 12, 4 } }, |
||||
{ /* 84 */ 1, { 11, 6 } }, |
||||
{ /* 85 */ 1, { 10, 6 } }, |
||||
{ /* 86 */ 1, { 4, 12 } }, |
||||
{ /* 87 */ 1, { 7, 9 } }, |
||||
{ /* 88 */ 1, { 5, 11 } }, |
||||
{ /* 89 */ 1, { 0, 11 } }, |
||||
{ /* 90 */ 1, { 12, 6 } }, |
||||
{ /* 91 */ 1, { 6, 10 } }, |
||||
{ /* 92 */ 1, { 12, 0 } }, |
||||
{ /* 93 */ 1, { 10, 7 } }, |
||||
{ /* 94 */ 1, { 5, 12 } }, |
||||
{ /* 95 */ 1, { 7, 10 } }, |
||||
{ /* 96 */ 1, { 9, 8 } }, |
||||
{ /* 97 */ 1, { 0, 12 } }, |
||||
{ /* 98 */ 1, { 11, 7 } }, |
||||
{ /* 99 */ 1, { 8, 9 } }, |
||||
{ /* 00 */ 1, { 9, 9 } }, |
||||
{ /* 01 */ 1, { 10, 8 } }, |
||||
{ /* 02 */ 1, { 7, 11 } }, |
||||
{ /* 03 */ 1, { 12, 7 } }, |
||||
{ /* 04 */ 1, { 6, 11 } }, |
||||
{ /* 05 */ 1, { 8, 11 } }, |
||||
{ /* 06 */ 1, { 11, 8 } }, |
||||
{ /* 07 */ 1, { 7, 12 } }, |
||||
{ /* 08 */ 1, { 6, 12 } }, |
||||
{ /* 09 */ 0, { 8, 9 } }, |
||||
{ /* 10 */ 0, { 9, 10 } }, |
||||
{ /* 11 */ 0, { 10, 11 } }, |
||||
{ /* 12 */ 0, { 11, 12 } }, |
||||
{ /* 13 */ 0, { 12, 13 } }, |
||||
{ /* 14 */ 0, { 13, 14 } }, |
||||
{ /* 15 */ 0, { 14, 15 } }, |
||||
{ /* 16 */ 0, { 15, 16 } }, |
||||
{ /* 17 */ 1, { 8, 10 } }, |
||||
{ /* 18 */ 1, { 10, 9 } }, |
||||
{ /* 19 */ 1, { 8, 12 } }, |
||||
{ /* 20 */ 1, { 9, 10 } }, |
||||
{ /* 21 */ 1, { 9, 11 } }, |
||||
{ /* 22 */ 1, { 9, 12 } }, |
||||
{ /* 23 */ 1, { 10, 11 } }, |
||||
{ /* 24 */ 1, { 12, 9 } }, |
||||
{ /* 25 */ 1, { 10, 10 } }, |
||||
{ /* 26 */ 1, { 11, 9 } }, |
||||
{ /* 27 */ 1, { 12, 8 } }, |
||||
{ /* 28 */ 1, { 11, 10 } }, |
||||
{ /* 29 */ 1, { 12, 10 } }, |
||||
{ /* 30 */ 1, { 12, 11 } }, |
||||
{ /* 31 */ 0, { 2, 3 } }, |
||||
{ /* 32 */ 0, { 3, 4 } }, |
||||
{ /* 33 */ 1, { 10, 12 } }, |
||||
{ /* 34 */ 1, { 11, 11 } }, |
||||
{ /* 35 */ 1, { 11, 12 } }, |
||||
{ /* 36 */ 1, { 12, 12 } } |
||||
}; |
@ -0,0 +1,276 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcb_sf.h,v 1.7 2007/11/01 12:34:11 menno Exp $ |
||||
**/ |
||||
|
||||
/* Binary search huffman table HCB_SF */ |
||||
|
||||
|
||||
static uint8_t hcb_sf[][2] = { |
||||
{ /* 0 */ 1, 2 }, |
||||
{ /* 1 */ 60, 0 }, |
||||
{ /* 2 */ 1, 2 }, |
||||
{ /* 3 */ 2, 3 }, |
||||
{ /* 4 */ 3, 4 }, |
||||
{ /* 5 */ 59, 0 }, |
||||
{ /* 6 */ 3, 4 }, |
||||
{ /* 7 */ 4, 5 }, |
||||
{ /* 8 */ 5, 6 }, |
||||
{ /* 9 */ 61, 0 }, |
||||
{ /* 10 */ 58, 0 }, |
||||
{ /* 11 */ 62, 0 }, |
||||
{ /* 12 */ 3, 4 }, |
||||
{ /* 13 */ 4, 5 }, |
||||
{ /* 14 */ 5, 6 }, |
||||
{ /* 15 */ 57, 0 }, |
||||
{ /* 16 */ 63, 0 }, |
||||
{ /* 17 */ 4, 5 }, |
||||
{ /* 18 */ 5, 6 }, |
||||
{ /* 19 */ 6, 7 }, |
||||
{ /* 20 */ 7, 8 }, |
||||
{ /* 21 */ 56, 0 }, |
||||
{ /* 22 */ 64, 0 }, |
||||
{ /* 23 */ 55, 0 }, |
||||
{ /* 24 */ 65, 0 }, |
||||
{ /* 25 */ 4, 5 }, |
||||
{ /* 26 */ 5, 6 }, |
||||
{ /* 27 */ 6, 7 }, |
||||
{ /* 28 */ 7, 8 }, |
||||
{ /* 29 */ 66, 0 }, |
||||
{ /* 30 */ 54, 0 }, |
||||
{ /* 31 */ 67, 0 }, |
||||
{ /* 32 */ 5, 6 }, |
||||
{ /* 33 */ 6, 7 }, |
||||
{ /* 34 */ 7, 8 }, |
||||
{ /* 35 */ 8, 9 }, |
||||
{ /* 36 */ 9, 10 }, |
||||
{ /* 37 */ 53, 0 }, |
||||
{ /* 38 */ 68, 0 }, |
||||
{ /* 39 */ 52, 0 }, |
||||
{ /* 40 */ 69, 0 }, |
||||
{ /* 41 */ 51, 0 }, |
||||
{ /* 42 */ 5, 6 }, |
||||
{ /* 43 */ 6, 7 }, |
||||
{ /* 44 */ 7, 8 }, |
||||
{ /* 45 */ 8, 9 }, |
||||
{ /* 46 */ 9, 10 }, |
||||
{ /* 47 */ 70, 0 }, |
||||
{ /* 48 */ 50, 0 }, |
||||
{ /* 49 */ 49, 0 }, |
||||
{ /* 50 */ 71, 0 }, |
||||
{ /* 51 */ 6, 7 }, |
||||
{ /* 52 */ 7, 8 }, |
||||
{ /* 53 */ 8, 9 }, |
||||
{ /* 54 */ 9, 10 }, |
||||
{ /* 55 */ 10, 11 }, |
||||
{ /* 56 */ 11, 12 }, |
||||
{ /* 57 */ 72, 0 }, |
||||
{ /* 58 */ 48, 0 }, |
||||
{ /* 59 */ 73, 0 }, |
||||
{ /* 60 */ 47, 0 }, |
||||
{ /* 61 */ 74, 0 }, |
||||
{ /* 62 */ 46, 0 }, |
||||
{ /* 63 */ 6, 7 }, |
||||
{ /* 64 */ 7, 8 }, |
||||
{ /* 65 */ 8, 9 }, |
||||
{ /* 66 */ 9, 10 }, |
||||
{ /* 67 */ 10, 11 }, |
||||
{ /* 68 */ 11, 12 }, |
||||
{ /* 69 */ 76, 0 }, |
||||
{ /* 70 */ 75, 0 }, |
||||
{ /* 71 */ 77, 0 }, |
||||
{ /* 72 */ 78, 0 }, |
||||
{ /* 73 */ 45, 0 }, |
||||
{ /* 74 */ 43, 0 }, |
||||
{ /* 75 */ 6, 7 }, |
||||
{ /* 76 */ 7, 8 }, |
||||
{ /* 77 */ 8, 9 }, |
||||
{ /* 78 */ 9, 10 }, |
||||
{ /* 79 */ 10, 11 }, |
||||
{ /* 80 */ 11, 12 }, |
||||
{ /* 81 */ 44, 0 }, |
||||
{ /* 82 */ 79, 0 }, |
||||
{ /* 83 */ 42, 0 }, |
||||
{ /* 84 */ 41, 0 }, |
||||
{ /* 85 */ 80, 0 }, |
||||
{ /* 86 */ 40, 0 }, |
||||
{ /* 87 */ 6, 7 }, |
||||
{ /* 88 */ 7, 8 }, |
||||
{ /* 89 */ 8, 9 }, |
||||
{ /* 90 */ 9, 10 }, |
||||
{ /* 91 */ 10, 11 }, |
||||
{ /* 92 */ 11, 12 }, |
||||
{ /* 93 */ 81, 0 }, |
||||
{ /* 94 */ 39, 0 }, |
||||
{ /* 95 */ 82, 0 }, |
||||
{ /* 96 */ 38, 0 }, |
||||
{ /* 97 */ 83, 0 }, |
||||
{ /* 98 */ 7, 8 }, |
||||
{ /* 99 */ 8, 9 }, |
||||
{ /* 00 */ 9, 10 }, |
||||
{ /* 01 */ 10, 11 }, |
||||
{ /* 02 */ 11, 12 }, |
||||
{ /* 03 */ 12, 13 }, |
||||
{ /* 04 */ 13, 14 }, |
||||
{ /* 05 */ 37, 0 }, |
||||
{ /* 06 */ 35, 0 }, |
||||
{ /* 07 */ 85, 0 }, |
||||
{ /* 08 */ 33, 0 }, |
||||
{ /* 09 */ 36, 0 }, |
||||
{ /* 10 */ 34, 0 }, |
||||
{ /* 11 */ 84, 0 }, |
||||
{ /* 12 */ 32, 0 }, |
||||
{ /* 13 */ 6, 7 }, |
||||
{ /* 14 */ 7, 8 }, |
||||
{ /* 15 */ 8, 9 }, |
||||
{ /* 16 */ 9, 10 }, |
||||
{ /* 17 */ 10, 11 }, |
||||
{ /* 18 */ 11, 12 }, |
||||
{ /* 19 */ 87, 0 }, |
||||
{ /* 20 */ 89, 0 }, |
||||
{ /* 21 */ 30, 0 }, |
||||
{ /* 22 */ 31, 0 }, |
||||
{ /* 23 */ 8, 9 }, |
||||
{ /* 24 */ 9, 10 }, |
||||
{ /* 25 */ 10, 11 }, |
||||
{ /* 26 */ 11, 12 }, |
||||
{ /* 27 */ 12, 13 }, |
||||
{ /* 28 */ 13, 14 }, |
||||
{ /* 29 */ 14, 15 }, |
||||
{ /* 30 */ 15, 16 }, |
||||
{ /* 31 */ 86, 0 }, |
||||
{ /* 32 */ 29, 0 }, |
||||
{ /* 33 */ 26, 0 }, |
||||
{ /* 34 */ 27, 0 }, |
||||
{ /* 35 */ 28, 0 }, |
||||
{ /* 36 */ 24, 0 }, |
||||
{ /* 37 */ 88, 0 }, |
||||
{ /* 38 */ 9, 10 }, |
||||
{ /* 39 */ 10, 11 }, |
||||
{ /* 40 */ 11, 12 }, |
||||
{ /* 41 */ 12, 13 }, |
||||
{ /* 42 */ 13, 14 }, |
||||
{ /* 43 */ 14, 15 }, |
||||
{ /* 44 */ 15, 16 }, |
||||
{ /* 45 */ 16, 17 }, |
||||
{ /* 46 */ 17, 18 }, |
||||
{ /* 47 */ 25, 0 }, |
||||
{ /* 48 */ 22, 0 }, |
||||
{ /* 49 */ 23, 0 }, |
||||
{ /* 50 */ 15, 16 }, |
||||
{ /* 51 */ 16, 17 }, |
||||
{ /* 52 */ 17, 18 }, |
||||
{ /* 53 */ 18, 19 }, |
||||
{ /* 54 */ 19, 20 }, |
||||
{ /* 55 */ 20, 21 }, |
||||
{ /* 56 */ 21, 22 }, |
||||
{ /* 57 */ 22, 23 }, |
||||
{ /* 58 */ 23, 24 }, |
||||
{ /* 59 */ 24, 25 }, |
||||
{ /* 60 */ 25, 26 }, |
||||
{ /* 61 */ 26, 27 }, |
||||
{ /* 62 */ 27, 28 }, |
||||
{ /* 63 */ 28, 29 }, |
||||
{ /* 64 */ 29, 30 }, |
||||
{ /* 65 */ 90, 0 }, |
||||
{ /* 66 */ 21, 0 }, |
||||
{ /* 67 */ 19, 0 }, |
||||
{ /* 68 */ 3, 0 }, |
||||
{ /* 69 */ 1, 0 }, |
||||
{ /* 70 */ 2, 0 }, |
||||
{ /* 71 */ 0, 0 }, |
||||
{ /* 72 */ 23, 24 }, |
||||
{ /* 73 */ 24, 25 }, |
||||
{ /* 74 */ 25, 26 }, |
||||
{ /* 75 */ 26, 27 }, |
||||
{ /* 76 */ 27, 28 }, |
||||
{ /* 77 */ 28, 29 }, |
||||
{ /* 78 */ 29, 30 }, |
||||
{ /* 79 */ 30, 31 }, |
||||
{ /* 80 */ 31, 32 }, |
||||
{ /* 81 */ 32, 33 }, |
||||
{ /* 82 */ 33, 34 }, |
||||
{ /* 83 */ 34, 35 }, |
||||
{ /* 84 */ 35, 36 }, |
||||
{ /* 85 */ 36, 37 }, |
||||
{ /* 86 */ 37, 38 }, |
||||
{ /* 87 */ 38, 39 }, |
||||
{ /* 88 */ 39, 40 }, |
||||
{ /* 89 */ 40, 41 }, |
||||
{ /* 90 */ 41, 42 }, |
||||
{ /* 91 */ 42, 43 }, |
||||
{ /* 92 */ 43, 44 }, |
||||
{ /* 93 */ 44, 45 }, |
||||
{ /* 94 */ 45, 46 }, |
||||
{ /* 95 */ 98, 0 }, |
||||
{ /* 96 */ 99, 0 }, |
||||
{ /* 97 */ 100, 0 }, |
||||
{ /* 98 */ 101, 0 }, |
||||
{ /* 99 */ 102, 0 }, |
||||
{ /* 00 */ 117, 0 }, |
||||
{ /* 01 */ 97, 0 }, |
||||
{ /* 02 */ 91, 0 }, |
||||
{ /* 03 */ 92, 0 }, |
||||
{ /* 04 */ 93, 0 }, |
||||
{ /* 05 */ 94, 0 }, |
||||
{ /* 06 */ 95, 0 }, |
||||
{ /* 07 */ 96, 0 }, |
||||
{ /* 08 */ 104, 0 }, |
||||
{ /* 09 */ 111, 0 }, |
||||
{ /* 10 */ 112, 0 }, |
||||
{ /* 11 */ 113, 0 }, |
||||
{ /* 12 */ 114, 0 }, |
||||
{ /* 13 */ 115, 0 }, |
||||
{ /* 14 */ 116, 0 }, |
||||
{ /* 15 */ 110, 0 }, |
||||
{ /* 16 */ 105, 0 }, |
||||
{ /* 17 */ 106, 0 }, |
||||
{ /* 18 */ 107, 0 }, |
||||
{ /* 19 */ 108, 0 }, |
||||
{ /* 20 */ 109, 0 }, |
||||
{ /* 21 */ 118, 0 }, |
||||
{ /* 22 */ 6, 0 }, |
||||
{ /* 23 */ 8, 0 }, |
||||
{ /* 24 */ 9, 0 }, |
||||
{ /* 25 */ 10, 0 }, |
||||
{ /* 26 */ 5, 0 }, |
||||
{ /* 27 */ 103, 0 }, |
||||
{ /* 28 */ 120, 0 }, |
||||
{ /* 29 */ 119, 0 }, |
||||
{ /* 30 */ 4, 0 }, |
||||
{ /* 31 */ 7, 0 }, |
||||
{ /* 32 */ 15, 0 }, |
||||
{ /* 33 */ 16, 0 }, |
||||
{ /* 34 */ 18, 0 }, |
||||
{ /* 35 */ 20, 0 }, |
||||
{ /* 36 */ 17, 0 }, |
||||
{ /* 37 */ 11, 0 }, |
||||
{ /* 38 */ 12, 0 }, |
||||
{ /* 39 */ 14, 0 }, |
||||
{ /* 40 */ 13, 0 } |
||||
}; |
@ -0,0 +1,492 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: common.c,v 1.27 2008/03/23 23:03:28 menno Exp $ |
||||
**/ |
||||
|
||||
/* just some common functions that could be used anywhere */ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#include "syntax.h" |
||||
|
||||
|
||||
/* Returns the sample rate index based on the samplerate */ |
||||
uint8_t get_sr_index(const uint32_t samplerate) |
||||
{ |
||||
if (92017 <= samplerate) return 0; |
||||
if (75132 <= samplerate) return 1; |
||||
if (55426 <= samplerate) return 2; |
||||
if (46009 <= samplerate) return 3; |
||||
if (37566 <= samplerate) return 4; |
||||
if (27713 <= samplerate) return 5; |
||||
if (23004 <= samplerate) return 6; |
||||
if (18783 <= samplerate) return 7; |
||||
if (13856 <= samplerate) return 8; |
||||
if (11502 <= samplerate) return 9; |
||||
if (9391 <= samplerate) return 10; |
||||
|
||||
return 11; |
||||
} |
||||
|
||||
/* Returns the sample rate based on the sample rate index */ |
||||
uint32_t get_sample_rate(const uint8_t sr_index) |
||||
{ |
||||
static const uint32_t sample_rates[] = |
||||
{ |
||||
96000, 88200, 64000, 48000, 44100, 32000, |
||||
24000, 22050, 16000, 12000, 11025, 8000 |
||||
}; |
||||
|
||||
if (sr_index < 12) |
||||
return sample_rates[sr_index]; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
uint8_t max_pred_sfb(const uint8_t sr_index) |
||||
{ |
||||
static const uint8_t pred_sfb_max[] = |
||||
{ |
||||
33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34 |
||||
}; |
||||
|
||||
|
||||
if (sr_index < 12) |
||||
return pred_sfb_max[sr_index]; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, |
||||
const uint8_t is_short) |
||||
{ |
||||
/* entry for each sampling rate
|
||||
* 1 Main/LC long window |
||||
* 2 Main/LC short window |
||||
* 3 SSR long window |
||||
* 4 SSR short window |
||||
*/ |
||||
static const uint8_t tns_sbf_max[][4] = |
||||
{ |
||||
{31, 9, 28, 7}, /* 96000 */ |
||||
{31, 9, 28, 7}, /* 88200 */ |
||||
{34, 10, 27, 7}, /* 64000 */ |
||||
{40, 14, 26, 6}, /* 48000 */ |
||||
{42, 14, 26, 6}, /* 44100 */ |
||||
{51, 14, 26, 6}, /* 32000 */ |
||||
{46, 14, 29, 7}, /* 24000 */ |
||||
{46, 14, 29, 7}, /* 22050 */ |
||||
{42, 14, 23, 8}, /* 16000 */ |
||||
{42, 14, 23, 8}, /* 12000 */ |
||||
{42, 14, 23, 8}, /* 11025 */ |
||||
{39, 14, 19, 7}, /* 8000 */ |
||||
{39, 14, 19, 7}, /* 7350 */ |
||||
{0,0,0,0}, |
||||
{0,0,0,0}, |
||||
{0,0,0,0} |
||||
}; |
||||
uint8_t i = 0; |
||||
|
||||
if (is_short) i++; |
||||
if (object_type == SSR) i += 2; |
||||
|
||||
return tns_sbf_max[sr_index][i]; |
||||
} |
||||
|
||||
/* Returns 0 if an object type is decodable, otherwise returns -1 */ |
||||
int8_t can_decode_ot(const uint8_t object_type) |
||||
{ |
||||
switch (object_type) |
||||
{ |
||||
case LC: |
||||
return 0; |
||||
case MAIN: |
||||
#ifdef MAIN_DEC |
||||
return 0; |
||||
#else |
||||
return -1; |
||||
#endif |
||||
case SSR: |
||||
#ifdef SSR_DEC |
||||
return 0; |
||||
#else |
||||
return -1; |
||||
#endif |
||||
case LTP: |
||||
#ifdef LTP_DEC |
||||
return 0; |
||||
#else |
||||
return -1; |
||||
#endif |
||||
|
||||
/* ER object types */ |
||||
#ifdef ERROR_RESILIENCE |
||||
case ER_LC: |
||||
#ifdef DRM |
||||
case DRM_ER_LC: |
||||
#endif |
||||
return 0; |
||||
case ER_LTP: |
||||
#ifdef LTP_DEC |
||||
return 0; |
||||
#else |
||||
return -1; |
||||
#endif |
||||
case LD: |
||||
#ifdef LD_DEC |
||||
return 0; |
||||
#else |
||||
return -1; |
||||
#endif |
||||
#endif |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
void *faad_malloc(size_t size) |
||||
{ |
||||
#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
return _aligned_malloc(size, 16); |
||||
#else // #ifdef 0
|
||||
return malloc(size); |
||||
#endif // #ifdef 0
|
||||
} |
||||
|
||||
/* common free function */ |
||||
void faad_free(void *b) |
||||
{ |
||||
#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
_aligned_free(b); |
||||
#else |
||||
free(b); |
||||
} |
||||
#endif |
||||
|
||||
static const uint8_t Parity [256] = { // parity
|
||||
0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, |
||||
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, |
||||
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, |
||||
0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, |
||||
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, |
||||
0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, |
||||
0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, |
||||
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 |
||||
}; |
||||
|
||||
|
||||
/*
|
||||
* This is a simple random number generator with good quality for audio purposes. |
||||
* It consists of two polycounters with opposite rotation direction and different |
||||
* periods. The periods are coprime, so the total period is the product of both. |
||||
* |
||||
* ------------------------------------------------------------------------------------------------- |
||||
* +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| |
||||
* | ------------------------------------------------------------------------------------------------- |
||||
* | | | | | | | |
||||
* | +--+--+--+-XOR-+--------+ |
||||
* | | |
||||
* +--------------------------------------------------------------------------------------+ |
||||
* |
||||
* ------------------------------------------------------------------------------------------------- |
||||
* |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ |
||||
* ------------------------------------------------------------------------------------------------- | |
||||
* | | | | | |
||||
* +--+----XOR----+--+ | |
||||
* | | |
||||
* +----------------------------------------------------------------------------------------+ |
||||
* |
||||
* |
||||
* The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, |
||||
* which gives a period of 18.410.713.077.675.721.215. The result is the |
||||
* XORed values of both generators. |
||||
*/ |
||||
uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2) |
||||
{ |
||||
uint32_t t1, t2, t3, t4; |
||||
|
||||
t3 = t1 = *__r1; t4 = t2 = *__r2; // Parity calculation is done via table lookup, this is also available
|
||||
t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable
|
||||
t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations.
|
||||
t1 <<= 31; t2 = Parity [t2]; |
||||
|
||||
return (*__r1 = (t3 >> 1) | t1 ) ^ (*__r2 = (t4 + t4) | t2 ); |
||||
} |
||||
|
||||
#ifdef FIXED_POINT |
||||
|
||||
static uint32_t ones32(uint32_t x) |
||||
{ |
||||
x -= ((x >> 1) & 0x55555555); |
||||
x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); |
||||
x = (((x >> 4) + x) & 0x0f0f0f0f); |
||||
x += (x >> 8); |
||||
x += (x >> 16); |
||||
|
||||
return (x & 0x0000003f); |
||||
} |
||||
|
||||
static uint32_t ones64(uint64_t x) |
||||
{ |
||||
return ones32((uint32_t)x) + ones32(x >> 32); |
||||
} |
||||
|
||||
static uint32_t floor_log2(uint64_t x) |
||||
{ |
||||
#if 1 |
||||
x |= (x >> 1); |
||||
x |= (x >> 2); |
||||
x |= (x >> 4); |
||||
x |= (x >> 8); |
||||
x |= (x >> 16); |
||||
x |= (x >> 32); |
||||
|
||||
return (ones64(x) - 1); |
||||
#else |
||||
uint32_t count = 0; |
||||
|
||||
while (x >>= 1) |
||||
count++; |
||||
|
||||
return count; |
||||
#endif |
||||
} |
||||
|
||||
/* returns position of first bit that is not 0 from msb,
|
||||
* starting count at lsb */ |
||||
uint32_t wl_min_lzc(uint32_t x) |
||||
{ |
||||
#if 1 |
||||
x |= (x >> 1); |
||||
x |= (x >> 2); |
||||
x |= (x >> 4); |
||||
x |= (x >> 8); |
||||
x |= (x >> 16); |
||||
|
||||
return (ones32(x)); |
||||
#else |
||||
uint32_t count = 0; |
||||
|
||||
while (x >>= 1) |
||||
count++; |
||||
|
||||
return (count + 1); |
||||
#endif |
||||
} |
||||
|
||||
#define TABLE_BITS 6 |
||||
/* just take the maximum number of bits for interpolation */ |
||||
#define INTERP_BITS (REAL_BITS-TABLE_BITS) |
||||
|
||||
static const real_t pow2_tab[] = { |
||||
REAL_CONST(1.000000000000000), REAL_CONST(1.010889286051701), REAL_CONST(1.021897148654117), |
||||
REAL_CONST(1.033024879021228), REAL_CONST(1.044273782427414), REAL_CONST(1.055645178360557), |
||||
REAL_CONST(1.067140400676824), REAL_CONST(1.078760797757120), REAL_CONST(1.090507732665258), |
||||
REAL_CONST(1.102382583307841), REAL_CONST(1.114386742595892), REAL_CONST(1.126521618608242), |
||||
REAL_CONST(1.138788634756692), REAL_CONST(1.151189229952983), REAL_CONST(1.163724858777578), |
||||
REAL_CONST(1.176396991650281), REAL_CONST(1.189207115002721), REAL_CONST(1.202156731452703), |
||||
REAL_CONST(1.215247359980469), REAL_CONST(1.228480536106870), REAL_CONST(1.241857812073484), |
||||
REAL_CONST(1.255380757024691), REAL_CONST(1.269050957191733), REAL_CONST(1.282870016078778), |
||||
REAL_CONST(1.296839554651010), REAL_CONST(1.310961211524764), REAL_CONST(1.325236643159741), |
||||
REAL_CONST(1.339667524053303), REAL_CONST(1.354255546936893), REAL_CONST(1.369002422974591), |
||||
REAL_CONST(1.383909881963832), REAL_CONST(1.398979672538311), REAL_CONST(1.414213562373095), |
||||
REAL_CONST(1.429613338391970), REAL_CONST(1.445180806977047), REAL_CONST(1.460917794180647), |
||||
REAL_CONST(1.476826145939499), REAL_CONST(1.492907728291265), REAL_CONST(1.509164427593423), |
||||
REAL_CONST(1.525598150744538), REAL_CONST(1.542210825407941), REAL_CONST(1.559004400237837), |
||||
REAL_CONST(1.575980845107887), REAL_CONST(1.593142151342267), REAL_CONST(1.610490331949254), |
||||
REAL_CONST(1.628027421857348), REAL_CONST(1.645755478153965), REAL_CONST(1.663676580326736), |
||||
REAL_CONST(1.681792830507429), REAL_CONST(1.700106353718524), REAL_CONST(1.718619298122478), |
||||
REAL_CONST(1.737333835273706), REAL_CONST(1.756252160373300), REAL_CONST(1.775376492526521), |
||||
REAL_CONST(1.794709075003107), REAL_CONST(1.814252175500399), REAL_CONST(1.834008086409342), |
||||
REAL_CONST(1.853979125083386), REAL_CONST(1.874167634110300), REAL_CONST(1.894575981586966), |
||||
REAL_CONST(1.915206561397147), REAL_CONST(1.936061793492294), REAL_CONST(1.957144124175400), |
||||
REAL_CONST(1.978456026387951), REAL_CONST(2.000000000000000) |
||||
}; |
||||
|
||||
static const real_t log2_tab[] = { |
||||
REAL_CONST(0.000000000000000), REAL_CONST(0.022367813028455), REAL_CONST(0.044394119358453), |
||||
REAL_CONST(0.066089190457772), REAL_CONST(0.087462841250339), REAL_CONST(0.108524456778169), |
||||
REAL_CONST(0.129283016944966), REAL_CONST(0.149747119504682), REAL_CONST(0.169925001442312), |
||||
REAL_CONST(0.189824558880017), REAL_CONST(0.209453365628950), REAL_CONST(0.228818690495881), |
||||
REAL_CONST(0.247927513443585), REAL_CONST(0.266786540694901), REAL_CONST(0.285402218862248), |
||||
REAL_CONST(0.303780748177103), REAL_CONST(0.321928094887362), REAL_CONST(0.339850002884625), |
||||
REAL_CONST(0.357552004618084), REAL_CONST(0.375039431346925), REAL_CONST(0.392317422778760), |
||||
REAL_CONST(0.409390936137702), REAL_CONST(0.426264754702098), REAL_CONST(0.442943495848728), |
||||
REAL_CONST(0.459431618637297), REAL_CONST(0.475733430966398), REAL_CONST(0.491853096329675), |
||||
REAL_CONST(0.507794640198696), REAL_CONST(0.523561956057013), REAL_CONST(0.539158811108031), |
||||
REAL_CONST(0.554588851677637), REAL_CONST(0.569855608330948), REAL_CONST(0.584962500721156), |
||||
REAL_CONST(0.599912842187128), REAL_CONST(0.614709844115208), REAL_CONST(0.629356620079610), |
||||
REAL_CONST(0.643856189774725), REAL_CONST(0.658211482751795), REAL_CONST(0.672425341971496), |
||||
REAL_CONST(0.686500527183218), REAL_CONST(0.700439718141092), REAL_CONST(0.714245517666123), |
||||
REAL_CONST(0.727920454563199), REAL_CONST(0.741466986401147), REAL_CONST(0.754887502163469), |
||||
REAL_CONST(0.768184324776926), REAL_CONST(0.781359713524660), REAL_CONST(0.794415866350106), |
||||
REAL_CONST(0.807354922057604), REAL_CONST(0.820178962415188), REAL_CONST(0.832890014164742), |
||||
REAL_CONST(0.845490050944375), REAL_CONST(0.857980995127572), REAL_CONST(0.870364719583405), |
||||
REAL_CONST(0.882643049361841), REAL_CONST(0.894817763307943), REAL_CONST(0.906890595608519), |
||||
REAL_CONST(0.918863237274595), REAL_CONST(0.930737337562886), REAL_CONST(0.942514505339240), |
||||
REAL_CONST(0.954196310386875), REAL_CONST(0.965784284662087), REAL_CONST(0.977279923499917), |
||||
REAL_CONST(0.988684686772166), REAL_CONST(1.000000000000000) |
||||
}; |
||||
|
||||
real_t pow2_fix(real_t val) |
||||
{ |
||||
uint32_t x1, x2; |
||||
uint32_t errcorr; |
||||
uint32_t index_frac; |
||||
real_t retval; |
||||
int32_t whole = (val >> REAL_BITS); |
||||
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
||||
if (whole >= 17) __builtin_trap(); |
||||
#endif |
||||
|
||||
/* rest = [0..1] */ |
||||
int32_t rest = val & ((1 << REAL_BITS) - 1); |
||||
|
||||
/* index into pow2_tab */ |
||||
int32_t index = rest >> (REAL_BITS-TABLE_BITS); |
||||
|
||||
|
||||
if (val == 0) |
||||
return (1<<REAL_BITS); |
||||
if (REAL_BITS + whole < 0) |
||||
return 0; |
||||
|
||||
/* leave INTERP_BITS bits */ |
||||
index_frac = rest >> (REAL_BITS-TABLE_BITS-INTERP_BITS); |
||||
index_frac = index_frac & ((1<<INTERP_BITS)-1); |
||||
|
||||
if (whole > 0) |
||||
{ |
||||
retval = 1 << whole; |
||||
} else { |
||||
retval = REAL_CONST(1) >> -whole; |
||||
} |
||||
|
||||
x1 = pow2_tab[index & ((1<<TABLE_BITS)-1)]; |
||||
x2 = pow2_tab[(index & ((1<<TABLE_BITS)-1)) + 1]; |
||||
errcorr = ( (index_frac*(x2-x1))) >> INTERP_BITS; |
||||
|
||||
if (whole > 0) |
||||
{ |
||||
retval = retval * (errcorr + x1); |
||||
} else { |
||||
retval = MUL_R(retval, (errcorr + x1)); |
||||
} |
||||
|
||||
return retval; |
||||
} |
||||
|
||||
uint64_t pow2_int(real_t val) |
||||
{ |
||||
uint32_t x1, x2; |
||||
uint32_t errcorr; |
||||
uint32_t index_frac; |
||||
uint64_t retval; |
||||
int32_t whole = (val >> REAL_BITS); |
||||
int32_t exp = 0; |
||||
|
||||
/* rest = [0..1] */ |
||||
int32_t rest = val & ((1 << REAL_BITS) - 1); |
||||
|
||||
/* index into pow2_tab */ |
||||
int32_t index = rest >> (REAL_BITS-TABLE_BITS); |
||||
|
||||
if (val < 0) |
||||
return 0; |
||||
if (val == 0) |
||||
return 1; |
||||
if (whole > COEF_BITS) { |
||||
exp = whole - COEF_BITS; |
||||
whole = COEF_BITS; |
||||
} |
||||
|
||||
/* leave INTERP_BITS bits */ |
||||
index_frac = rest >> (REAL_BITS-TABLE_BITS-INTERP_BITS); |
||||
index_frac = index_frac & ((1<<INTERP_BITS)-1); |
||||
|
||||
if (whole >= 0) |
||||
retval = (uint32_t)(1 << whole); |
||||
else |
||||
retval = 0; |
||||
|
||||
x1 = pow2_tab[index & ((1<<TABLE_BITS)-1)]; |
||||
x2 = pow2_tab[(index & ((1<<TABLE_BITS)-1)) + 1]; |
||||
errcorr = ((index_frac*(x2-x1))) >> INTERP_BITS; |
||||
|
||||
retval = MUL_R(retval, (errcorr + x1)); |
||||
|
||||
return retval << exp; |
||||
} |
||||
|
||||
/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ |
||||
int32_t log2_int(uint64_t val) |
||||
{ |
||||
uint32_t frac; |
||||
int32_t exp = 0; |
||||
uint32_t index; |
||||
uint32_t index_frac; |
||||
uint32_t x1, x2; |
||||
uint32_t errcorr; |
||||
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
||||
if (val == 0) __builtin_trap(); |
||||
#endif |
||||
|
||||
exp = floor_log2(val); |
||||
exp -= REAL_BITS; |
||||
|
||||
/* frac = [1..2] */ |
||||
if (exp >= 0) |
||||
frac = (uint32_t)(val >> exp); |
||||
else |
||||
frac = (uint32_t)(val << -exp); |
||||
|
||||
/* index in the log2 table */ |
||||
index = frac >> (REAL_BITS-TABLE_BITS); |
||||
|
||||
/* leftover part for linear interpolation */ |
||||
index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); |
||||
|
||||
/* leave INTERP_BITS bits */ |
||||
index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); |
||||
|
||||
x1 = log2_tab[index & ((1<<TABLE_BITS)-1)]; |
||||
x2 = log2_tab[(index & ((1<<TABLE_BITS)-1)) + 1]; |
||||
|
||||
/* linear interpolation */ |
||||
/* retval = exp + ((index_frac)*x2 + (1-index_frac)*x1) */ |
||||
|
||||
errcorr = (index_frac * (x2-x1)) >> INTERP_BITS; |
||||
|
||||
return ((exp+REAL_BITS) << REAL_BITS) + errcorr + x1; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,458 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: common.h,v 1.79 2015/01/26 17:48:53 knik Exp $ |
||||
**/ |
||||
|
||||
#ifndef __COMMON_H__ |
||||
#define __COMMON_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
# include "../config.h" |
||||
#endif |
||||
|
||||
#include "neaacdec.h" |
||||
|
||||
#if 1 |
||||
#define INLINE __inline |
||||
#else |
||||
#define INLINE inline |
||||
#endif |
||||
|
||||
#if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
#define ALIGN __declspec(align(16)) |
||||
#else |
||||
#define ALIGN |
||||
#endif |
||||
|
||||
#ifndef max |
||||
#define max(a, b) (((a) > (b)) ? (a) : (b)) |
||||
#endif |
||||
#ifndef min |
||||
#define min(a, b) (((a) < (b)) ? (a) : (b)) |
||||
#endif |
||||
|
||||
/* COMPILE TIME DEFINITIONS */ |
||||
|
||||
/* use double precision */ |
||||
/* #define USE_DOUBLE_PRECISION */ |
||||
/* use fixed point reals */ |
||||
//#define FIXED_POINT
|
||||
//#define BIG_IQ_TABLE
|
||||
|
||||
/* Use if target platform has address generators with autoincrement */ |
||||
//#define PREFER_POINTERS
|
||||
|
||||
#ifdef _WIN32_WCE |
||||
#define FIXED_POINT |
||||
#endif |
||||
|
||||
#ifdef __BFIN__ |
||||
#define FIXED_POINT |
||||
#endif |
||||
|
||||
#define ERROR_RESILIENCE |
||||
|
||||
|
||||
/* Allow decoding of MAIN profile AAC */ |
||||
#define MAIN_DEC |
||||
/* Allow decoding of SSR profile AAC */ |
||||
//#define SSR_DEC
|
||||
/* Allow decoding of LTP profile AAC */ |
||||
#define LTP_DEC |
||||
/* Allow decoding of LD profile AAC */ |
||||
#define LD_DEC |
||||
/* Allow decoding of Digital Radio Mondiale (DRM) */ |
||||
#ifdef DRM_SUPPORT |
||||
#define DRM |
||||
#define DRM_PS |
||||
#endif |
||||
|
||||
/* LD can't do without LTP */ |
||||
#ifdef LD_DEC |
||||
#ifndef ERROR_RESILIENCE |
||||
#define ERROR_RESILIENCE |
||||
#endif |
||||
#ifndef LTP_DEC |
||||
#define LTP_DEC |
||||
#endif |
||||
#endif |
||||
|
||||
#define ALLOW_SMALL_FRAMELENGTH |
||||
|
||||
|
||||
// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC)
|
||||
//#define LC_ONLY_DECODER
|
||||
#ifdef LC_ONLY_DECODER |
||||
#undef LD_DEC |
||||
#undef LTP_DEC |
||||
#undef MAIN_DEC |
||||
#undef SSR_DEC |
||||
#undef DRM |
||||
#undef DRM_PS |
||||
#undef ALLOW_SMALL_FRAMELENGTH |
||||
#undef ERROR_RESILIENCE |
||||
#endif |
||||
|
||||
// Define DISABLE_SBR if you want to disable SBR decoding.
|
||||
//#define DISABLE_SBR
|
||||
|
||||
// Define SBR_LOW_POWER if you want only low power SBR decoding without PS.
|
||||
//#define SBR_LOW_POWER
|
||||
|
||||
#ifndef DISABLE_SBR |
||||
# define SBR_DEC |
||||
# ifndef SBR_LOW_POWER |
||||
# define PS_DEC |
||||
# endif // SBR_LOW_POWER
|
||||
#endif // DISABLE_SBR
|
||||
|
||||
/* FIXED POINT: No MAIN decoding */ |
||||
#ifdef FIXED_POINT |
||||
# ifdef MAIN_DEC |
||||
# undef MAIN_DEC |
||||
# endif |
||||
#endif // FIXED_POINT
|
||||
|
||||
#ifdef DRM |
||||
# ifndef ALLOW_SMALL_FRAMELENGTH |
||||
# define ALLOW_SMALL_FRAMELENGTH |
||||
# endif |
||||
# undef LD_DEC |
||||
# undef LTP_DEC |
||||
# undef MAIN_DEC |
||||
# undef SSR_DEC |
||||
#endif |
||||
|
||||
|
||||
#ifdef FIXED_POINT |
||||
#define DIV_R(A, B) (((int64_t)A * REAL_PRECISION)/B) |
||||
#define DIV_C(A, B) (((int64_t)A * COEF_PRECISION)/B) |
||||
#define DIV_F(A, B) (((int64_t)A * FRAC_PRECISION)/B) |
||||
#else |
||||
#define DIV_R(A, B) ((A)/(B)) |
||||
#define DIV_C(A, B) ((A)/(B)) |
||||
#define DIV_F(A, B) ((A)/(B)) |
||||
#endif |
||||
|
||||
#ifndef SBR_LOW_POWER |
||||
#define qmf_t complex_t |
||||
#define QMF_RE(A) RE(A) |
||||
#define QMF_IM(A) IM(A) |
||||
#else |
||||
#define qmf_t real_t |
||||
#define QMF_RE(A) (A) |
||||
#define QMF_IM(A) |
||||
#endif |
||||
|
||||
|
||||
/* END COMPILE TIME DEFINITIONS */ |
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) |
||||
|
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
typedef unsigned __int64 uint64_t; |
||||
typedef unsigned __int32 uint32_t; |
||||
typedef unsigned __int16 uint16_t; |
||||
typedef unsigned __int8 uint8_t; |
||||
typedef signed __int64 int64_t; |
||||
typedef signed __int32 int32_t; |
||||
typedef signed __int16 int16_t; |
||||
typedef signed __int8 int8_t; |
||||
typedef float float32_t; |
||||
|
||||
|
||||
#else /* WIN */ |
||||
|
||||
#include <stdio.h> |
||||
#if HAVE_SYS_TYPES_H |
||||
# include <sys/types.h> |
||||
#endif |
||||
#if HAVE_SYS_STAT_H |
||||
# include <sys/stat.h> |
||||
#endif |
||||
#if STDC_HEADERS |
||||
# include <stdlib.h> |
||||
# include <stddef.h> |
||||
#else |
||||
# if HAVE_STDLIB_H |
||||
# include <stdlib.h> |
||||
# endif |
||||
#endif |
||||
#if HAVE_STRING_H |
||||
# if !STDC_HEADERS && HAVE_MEMORY_H |
||||
# include <memory.h> |
||||
# endif |
||||
# include <string.h> |
||||
#endif |
||||
#if HAVE_STRINGS_H |
||||
# include <strings.h> |
||||
#endif |
||||
#if HAVE_INTTYPES_H |
||||
# include <inttypes.h> |
||||
#else |
||||
# if HAVE_STDINT_H |
||||
# include <stdint.h> |
||||
# else |
||||
/* we need these... */ |
||||
#ifndef __TCS__ |
||||
typedef unsigned long long uint64_t; |
||||
typedef signed long long int64_t; |
||||
#else |
||||
typedef unsigned long uint64_t; |
||||
typedef signed long int64_t; |
||||
#endif |
||||
typedef unsigned long uint32_t; |
||||
typedef unsigned short uint16_t; |
||||
typedef unsigned char uint8_t; |
||||
typedef signed long int32_t; |
||||
typedef signed short int16_t; |
||||
typedef signed char int8_t; |
||||
# endif |
||||
#endif |
||||
#if HAVE_UNISTD_H |
||||
//# include <unistd.h>
|
||||
#endif |
||||
|
||||
#ifndef HAVE_FLOAT32_T |
||||
typedef float float32_t; |
||||
#endif |
||||
|
||||
#if STDC_HEADERS |
||||
# include <string.h> |
||||
#else |
||||
# if !HAVE_STRCHR |
||||
# define strchr index |
||||
# define strrchr rindex |
||||
# endif |
||||
char *strchr(), *strrchr(); |
||||
# if !HAVE_MEMCPY |
||||
# define memcpy(d, s, n) bcopy((s), (d), (n)) |
||||
# define memmove(d, s, n) bcopy((s), (d), (n)) |
||||
# endif |
||||
#endif |
||||
|
||||
#endif /* WIN */ |
||||
|
||||
/* FIXED_POINT doesn't work with MAIN and SSR yet */ |
||||
#ifdef FIXED_POINT |
||||
#undef MAIN_DEC |
||||
#undef SSR_DEC |
||||
#endif |
||||
|
||||
|
||||
#if defined(FIXED_POINT) |
||||
|
||||
#include "fixed.h" |
||||
|
||||
#elif defined(USE_DOUBLE_PRECISION) |
||||
|
||||
typedef double real_t; |
||||
|
||||
#include <math.h> |
||||
|
||||
#define MUL_R(A,B) ((A)*(B)) |
||||
#define MUL_C(A,B) ((A)*(B)) |
||||
#define MUL_F(A,B) ((A)*(B)) |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2); |
||||
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2); |
||||
} |
||||
|
||||
#define REAL_CONST(A) ((real_t)(A)) |
||||
#define COEF_CONST(A) ((real_t)(A)) |
||||
#define Q2_CONST(A) ((real_t)(A)) |
||||
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
||||
|
||||
#else /* Normal floating point operation */ |
||||
|
||||
typedef float real_t; |
||||
|
||||
#define MUL_R(A,B) ((A)*(B)) |
||||
#define MUL_C(A,B) ((A)*(B)) |
||||
#define MUL_F(A,B) ((A)*(B)) |
||||
|
||||
#define REAL_CONST(A) ((real_t)(A)) |
||||
#define COEF_CONST(A) ((real_t)(A)) |
||||
#define Q2_CONST(A) ((real_t)(A)) |
||||
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2); |
||||
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2); |
||||
} |
||||
|
||||
|
||||
#if defined(_WIN32) && defined(_M_IX86) && !defined(__MINGW32__) |
||||
#ifndef HAVE_LRINTF |
||||
#define HAS_LRINTF |
||||
static INLINE long lrintf(float f) |
||||
{ |
||||
int i; |
||||
__asm |
||||
{ |
||||
fld f |
||||
fistp i |
||||
} |
||||
return i; |
||||
} |
||||
#endif /* HAVE_LRINTF */ |
||||
#elif (defined(__i386__) && defined(__GNUC__) && \ |
||||
!defined(__CYGWIN__) && !defined(__MINGW32__)) |
||||
#ifndef HAVE_LRINTF |
||||
#define HAS_LRINTF |
||||
// from http://www.stereopsis.com/FPU.html
|
||||
static INLINE long lrintf(float f) |
||||
{ |
||||
int i; |
||||
__asm__ __volatile__ ( |
||||
"flds %1 \n\t" |
||||
"fistpl %0 \n\t" |
||||
: "=m" (i) |
||||
: "m" (f)); |
||||
return i; |
||||
} |
||||
#endif /* HAVE_LRINTF */ |
||||
#endif |
||||
|
||||
|
||||
#ifdef __ICL /* only Intel C compiler has fmath ??? */ |
||||
|
||||
#include <mathf.h> |
||||
|
||||
#define sin sinf |
||||
#define cos cosf |
||||
#define log logf |
||||
#define floor floorf |
||||
#define ceil ceilf |
||||
#define sqrt sqrtf |
||||
|
||||
#else |
||||
|
||||
#ifdef HAVE_LRINTF |
||||
# define HAS_LRINTF |
||||
# define _ISOC9X_SOURCE 1 |
||||
# define _ISOC99_SOURCE 1 |
||||
# define __USE_ISOC9X 1 |
||||
# define __USE_ISOC99 1 |
||||
#endif |
||||
|
||||
#include <math.h> |
||||
|
||||
#ifdef HAVE_SINF |
||||
# define sin sinf |
||||
#error |
||||
#endif |
||||
#ifdef HAVE_COSF |
||||
# define cos cosf |
||||
#endif |
||||
#ifdef HAVE_LOGF |
||||
# define log logf |
||||
#endif |
||||
#ifdef HAVE_EXPF |
||||
# define exp expf |
||||
#endif |
||||
#ifdef HAVE_FLOORF |
||||
# define floor floorf |
||||
#endif |
||||
#ifdef HAVE_CEILF |
||||
# define ceil ceilf |
||||
#endif |
||||
#ifdef HAVE_SQRTF |
||||
# define sqrt sqrtf |
||||
#endif |
||||
|
||||
#endif |
||||
|
||||
#endif |
||||
|
||||
#ifndef HAS_LRINTF |
||||
/* standard cast */ |
||||
#define lrintf(f) ((long)(f)) |
||||
#endif |
||||
|
||||
typedef real_t complex_t[2]; |
||||
#define RE(A) (A)[0] |
||||
#define IM(A) (A)[1] |
||||
|
||||
|
||||
/* common functions */ |
||||
uint8_t cpu_has_sse(void); |
||||
uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2); |
||||
#ifdef FIXED_POINT |
||||
uint32_t wl_min_lzc(uint32_t x); |
||||
#define LOG2_MIN_INF REAL_CONST(-10000) |
||||
int32_t log2_int(uint64_t val); |
||||
uint64_t pow2_int(real_t val); |
||||
real_t pow2_fix(real_t val); |
||||
#endif |
||||
uint8_t get_sr_index(const uint32_t samplerate); |
||||
uint8_t max_pred_sfb(const uint8_t sr_index); |
||||
uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, |
||||
const uint8_t is_short); |
||||
uint32_t get_sample_rate(const uint8_t sr_index); |
||||
int8_t can_decode_ot(const uint8_t object_type); |
||||
|
||||
void *faad_malloc(size_t size); |
||||
void faad_free(void *b); |
||||
|
||||
//#define PROFILE
|
||||
#ifdef PROFILE |
||||
static int64_t faad_get_ts() |
||||
{ |
||||
__asm |
||||
{ |
||||
rdtsc |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
#ifndef M_PI |
||||
#define M_PI 3.14159265358979323846 |
||||
#endif |
||||
#ifndef M_PI_2 /* PI/2 */ |
||||
#define M_PI_2 1.57079632679489661923 |
||||
#endif |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,172 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: drc.c,v 1.29 2015/02/22 10:09:29 knik Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#include "syntax.h" |
||||
#include "drc.h" |
||||
|
||||
drc_info *drc_init(real_t cut, real_t boost) |
||||
{ |
||||
drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info)); |
||||
memset(drc, 0, sizeof(drc_info)); |
||||
|
||||
drc->ctrl1 = cut; |
||||
drc->ctrl2 = boost; |
||||
|
||||
drc->num_bands = 1; |
||||
drc->band_top[0] = 1024/4 - 1; |
||||
drc->dyn_rng_sgn[0] = 1; |
||||
drc->dyn_rng_ctl[0] = 0; |
||||
|
||||
return drc; |
||||
} |
||||
|
||||
void drc_end(drc_info *drc) |
||||
{ |
||||
if (drc) faad_free(drc); |
||||
} |
||||
|
||||
#ifdef FIXED_POINT |
||||
static real_t drc_pow2_table[] = |
||||
{ |
||||
COEF_CONST(0.5146511183), |
||||
COEF_CONST(0.5297315472), |
||||
COEF_CONST(0.5452538663), |
||||
COEF_CONST(0.5612310242), |
||||
COEF_CONST(0.5776763484), |
||||
COEF_CONST(0.5946035575), |
||||
COEF_CONST(0.6120267717), |
||||
COEF_CONST(0.6299605249), |
||||
COEF_CONST(0.6484197773), |
||||
COEF_CONST(0.6674199271), |
||||
COEF_CONST(0.6869768237), |
||||
COEF_CONST(0.7071067812), |
||||
COEF_CONST(0.7278265914), |
||||
COEF_CONST(0.7491535384), |
||||
COEF_CONST(0.7711054127), |
||||
COEF_CONST(0.7937005260), |
||||
COEF_CONST(0.8169577266), |
||||
COEF_CONST(0.8408964153), |
||||
COEF_CONST(0.8655365610), |
||||
COEF_CONST(0.8908987181), |
||||
COEF_CONST(0.9170040432), |
||||
COEF_CONST(0.9438743127), |
||||
COEF_CONST(0.9715319412), |
||||
COEF_CONST(1.0000000000), |
||||
COEF_CONST(1.0293022366), |
||||
COEF_CONST(1.0594630944), |
||||
COEF_CONST(1.0905077327), |
||||
COEF_CONST(1.1224620483), |
||||
COEF_CONST(1.1553526969), |
||||
COEF_CONST(1.1892071150), |
||||
COEF_CONST(1.2240535433), |
||||
COEF_CONST(1.2599210499), |
||||
COEF_CONST(1.2968395547), |
||||
COEF_CONST(1.3348398542), |
||||
COEF_CONST(1.3739536475), |
||||
COEF_CONST(1.4142135624), |
||||
COEF_CONST(1.4556531828), |
||||
COEF_CONST(1.4983070769), |
||||
COEF_CONST(1.5422108254), |
||||
COEF_CONST(1.5874010520), |
||||
COEF_CONST(1.6339154532), |
||||
COEF_CONST(1.6817928305), |
||||
COEF_CONST(1.7310731220), |
||||
COEF_CONST(1.7817974363), |
||||
COEF_CONST(1.8340080864), |
||||
COEF_CONST(1.8877486254), |
||||
COEF_CONST(1.9430638823) |
||||
}; |
||||
#endif |
||||
|
||||
void drc_decode(drc_info *drc, real_t *spec) |
||||
{ |
||||
uint16_t i, bd, top; |
||||
#ifdef FIXED_POINT |
||||
int32_t exp, frac; |
||||
#else |
||||
real_t factor, exp; |
||||
#endif |
||||
uint16_t bottom = 0; |
||||
|
||||
if (drc->num_bands == 1) |
||||
drc->band_top[0] = 1024/4 - 1; |
||||
|
||||
for (bd = 0; bd < drc->num_bands; bd++) |
||||
{ |
||||
top = 4 * (drc->band_top[bd] + 1); |
||||
|
||||
#ifndef FIXED_POINT |
||||
/* Decode DRC gain factor */ |
||||
if (drc->dyn_rng_sgn[bd]) /* compress */ |
||||
exp = ((-drc->ctrl1 * drc->dyn_rng_ctl[bd]) - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); |
||||
else /* boost */ |
||||
exp = ((drc->ctrl2 * drc->dyn_rng_ctl[bd]) - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); |
||||
factor = (real_t)pow(2.0, exp); |
||||
|
||||
/* Apply gain factor */ |
||||
for (i = bottom; i < top; i++) |
||||
spec[i] *= factor; |
||||
#else |
||||
/* Decode DRC gain factor */ |
||||
if (drc->dyn_rng_sgn[bd]) /* compress */ |
||||
{ |
||||
exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; |
||||
frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; |
||||
} else { /* boost */ |
||||
exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; |
||||
frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; |
||||
} |
||||
|
||||
/* Apply gain factor */ |
||||
if (exp < 0) |
||||
{ |
||||
for (i = bottom; i < top; i++) |
||||
{ |
||||
spec[i] >>= -exp; |
||||
if (frac) |
||||
spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); |
||||
} |
||||
} else { |
||||
for (i = bottom; i < top; i++) |
||||
{ |
||||
spec[i] = (int32_t)(((uint32_t)spec[i]) << exp); |
||||
if (frac) |
||||
spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
bottom = top; |
||||
} |
||||
} |
@ -0,0 +1,49 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: drc.h,v 1.22 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __DRC_H__ |
||||
#define __DRC_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define DRC_REF_LEVEL 20*4 /* -20 dB */ |
||||
|
||||
|
||||
drc_info *drc_init(real_t cut, real_t boost); |
||||
void drc_end(drc_info *drc); |
||||
void drc_decode(drc_info *drc, real_t *spec); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,965 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: drm_dec.c,v 1.9 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <math.h> |
||||
#include "common.h" |
||||
|
||||
#ifdef DRM |
||||
|
||||
#include "sbr_dec.h" |
||||
#include "drm_dec.h" |
||||
#include "bits.h" |
||||
|
||||
/* constants */ |
||||
#define DECAY_CUTOFF 3 |
||||
#define DECAY_SLOPE 0.05f |
||||
|
||||
/* type definitaions */ |
||||
typedef const int8_t (*drm_ps_huff_tab)[2]; |
||||
|
||||
|
||||
/* binary search huffman tables */ |
||||
static const int8_t f_huffman_sa[][2] = |
||||
{ |
||||
{ /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 1x */ |
||||
{ /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ |
||||
{ 5, 6 }, /* index 3: 3 bits: 11x */ |
||||
{ /*1*/ -14, /*-1*/ -16 }, /* index 4: 4 bits: 101x */ |
||||
{ /*-2*/ -17, 7 }, /* index 5: 4 bits: 110x */ |
||||
{ 8, 9 }, /* index 6: 4 bits: 111x */ |
||||
{ /*2*/ -13, /*-3*/ -18 }, /* index 7: 5 bits: 1101x */ |
||||
{ /*3*/ -12, 10 }, /* index 8: 5 bits: 1110x */ |
||||
{ 11, 12 }, /* index 9: 5 bits: 1111x */ |
||||
{ /*4*/ -11, /*5*/ -10 }, /* index 10: 6 bits: 11101x */ |
||||
{ /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ |
||||
{ /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ |
||||
{ /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ |
||||
}; |
||||
|
||||
static const int8_t t_huffman_sa[][2] = |
||||
{ |
||||
{ /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 1x */ |
||||
{ /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ |
||||
{ 4, 5 }, /* index 3: 3 bits: 11x */ |
||||
{ /*-2*/ -17, /*2*/ -13 }, /* index 4: 4 bits: 110x */ |
||||
{ 6, 7 }, /* index 5: 4 bits: 111x */ |
||||
{ /*-3*/ -18, /*3*/ -12 }, /* index 6: 5 bits: 1110x */ |
||||
{ 8, 9 }, /* index 7: 5 bits: 1111x */ |
||||
{ /*-4*/ -19, /*4*/ -11 }, /* index 8: 6 bits: 11110x */ |
||||
{ 10, 11 }, /* index 9: 6 bits: 11111x */ |
||||
{ /*-5*/ -20, /*5*/ -10 }, /* index 10: 7 bits: 111110x */ |
||||
{ /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ |
||||
{ /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ |
||||
{ /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ |
||||
}; |
||||
|
||||
static const int8_t f_huffman_pan[][2] = |
||||
{ |
||||
{ /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
||||
{ /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
||||
{ /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ |
||||
{ 4, 5 }, /* index 3: 4 bits: 111x */ |
||||
{ /*-2*/ -17, /*2*/ -13 }, /* index 4: 5 bits: 1110x */ |
||||
{ 6, 7 }, /* index 5: 5 bits: 1111x */ |
||||
{ /*-3*/ -18, /*3*/ -12 }, /* index 6: 6 bits: 11110x */ |
||||
{ 8, 9 }, /* index 7: 6 bits: 11111x */ |
||||
{ /*-4*/ -19, /*4*/ -11 }, /* index 8: 7 bits: 111110x */ |
||||
{ 10, 11 }, /* index 9: 7 bits: 111111x */ |
||||
{ /*-5*/ -20, /*5*/ -10 }, /* index 10: 8 bits: 1111110x */ |
||||
{ 12, 13 }, /* index 11: 8 bits: 1111111x */ |
||||
{ /*-6*/ -21, /*6*/ -9 }, /* index 12: 9 bits: 11111110x */ |
||||
{ /*-7*/ -22, 14 }, /* index 13: 9 bits: 11111111x */ |
||||
{ /*7*/ -8, 15 }, /* index 14: 10 bits: 111111111x */ |
||||
{ 16, 17 }, /* index 15: 11 bits: 1111111111x */ |
||||
{ /*-8*/ -23, /*8*/ -7 }, /* index 16: 12 bits: 11111111110x */ |
||||
{ 18, 19 }, /* index 17: 12 bits: 11111111111x */ |
||||
{ /*-10*/ -25, 20 }, /* index 18: 13 bits: 111111111110x */ |
||||
{ 21, 22 }, /* index 19: 13 bits: 111111111111x */ |
||||
{ /*-9*/ -24, /*9*/ -6 }, /* index 20: 14 bits: 1111111111101x */ |
||||
{ /*10*/ -5, 23 }, /* index 21: 14 bits: 1111111111110x */ |
||||
{ 24, 25 }, /* index 22: 14 bits: 1111111111111x */ |
||||
{ /*-13*/ -28, /*-11*/ -26 }, /* index 23: 15 bits: 11111111111101x */ |
||||
{ /*11*/ -4, /*13*/ -2 }, /* index 24: 15 bits: 11111111111110x */ |
||||
{ 26, 27 }, /* index 25: 15 bits: 11111111111111x */ |
||||
{ /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ |
||||
{ /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ |
||||
}; |
||||
|
||||
static const int8_t t_huffman_pan[][2] = |
||||
{ |
||||
{ /*0*/ -15, 1 }, /* index 0: 1 bits: x */ |
||||
{ /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ |
||||
{ /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ |
||||
{ /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ |
||||
{ /*2*/ -13, 5 }, /* index 4: 5 bits: 1111x */ |
||||
{ /*-3*/ -18, 6 }, /* index 5: 6 bits: 11111x */ |
||||
{ /*3*/ -12, 7 }, /* index 6: 7 bits: 111111x */ |
||||
{ /*-4*/ -19, 8 }, /* index 7: 8 bits: 1111111x */ |
||||
{ /*4*/ -11, 9 }, /* index 8: 9 bits: 11111111x */ |
||||
{ 10, 11 }, /* index 9: 10 bits: 111111111x */ |
||||
{ /*-5*/ -20, /*5*/ -10 }, /* index 10: 11 bits: 1111111110x */ |
||||
{ 12, 13 }, /* index 11: 11 bits: 1111111111x */ |
||||
{ /*-6*/ -21, /*6*/ -9 }, /* index 12: 12 bits: 11111111110x */ |
||||
{ 14, 15 }, /* index 13: 12 bits: 11111111111x */ |
||||
{ /*-7*/ -22, /*7*/ -8 }, /* index 14: 13 bits: 111111111110x */ |
||||
{ 16, 17 }, /* index 15: 13 bits: 111111111111x */ |
||||
{ /*-8*/ -23, /*8*/ -7 }, /* index 16: 14 bits: 1111111111110x */ |
||||
{ 18, 19 }, /* index 17: 14 bits: 1111111111111x */ |
||||
{ /*-10*/ -25, /*10*/ -5 }, /* index 18: 15 bits: 11111111111110x */ |
||||
{ 20, 21 }, /* index 19: 15 bits: 11111111111111x */ |
||||
{ /*-9*/ -24, /*9*/ -6 }, /* index 20: 16 bits: 111111111111110x */ |
||||
{ 22, 23 }, /* index 21: 16 bits: 111111111111111x */ |
||||
{ 24, 25 }, /* index 22: 17 bits: 1111111111111110x */ |
||||
{ 26, 27 }, /* index 23: 17 bits: 1111111111111111x */ |
||||
{ /*-14*/ -29, /*-13*/ -28 }, /* index 24: 18 bits: 11111111111111100x */ |
||||
{ /*-12*/ -27, /*-11*/ -26 }, /* index 25: 18 bits: 11111111111111101x */ |
||||
{ /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ |
||||
{ /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ |
||||
}; |
||||
|
||||
/* There are 3 classes in the standard but the last 2 are identical */ |
||||
static const real_t sa_quant[8][2] = |
||||
{ |
||||
{ FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, |
||||
{ FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, |
||||
{ FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, |
||||
{ FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, |
||||
{ FRAC_CONST(0.1399), FRAC_CONST(0.5623) }, |
||||
{ FRAC_CONST(0.1957), FRAC_CONST(0.7079) }, |
||||
{ FRAC_CONST(0.2713), FRAC_CONST(0.8913) }, |
||||
{ FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, |
||||
}; |
||||
|
||||
/* We don't need the actual quantizer values */ |
||||
#if 0 |
||||
static const real_t pan_quant[8][5] = |
||||
{ |
||||
{ COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, |
||||
{ COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, |
||||
{ COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, |
||||
{ COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, |
||||
{ COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(2.1593), COEF_CONST(2.4914) }, |
||||
{ COEF_CONST(0.8305), COEF_CONST(1.3288), COEF_CONST(2.1593), COEF_CONST(2.9897), COEF_CONST(3.4880) }, |
||||
{ COEF_CONST(0.9966), COEF_CONST(1.8271), COEF_CONST(2.8236), COEF_CONST(3.8202), COEF_CONST(4.6507) }, |
||||
{ COEF_CONST(1.3288), COEF_CONST(2.3253), COEF_CONST(3.4880), COEF_CONST(4.6507), COEF_CONST(5.8134) }, |
||||
}; |
||||
#endif |
||||
|
||||
/* 2^(pan_quant[x][y] */ |
||||
static const real_t pan_pow_2_pos[8][5] = { |
||||
{ REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000) }, |
||||
{ REAL_CONST(1.1220021), REAL_CONST(1.1220021), REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.2589312) }, |
||||
{ REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.5849090), REAL_CONST(1.7783016), REAL_CONST(1.7783016) }, |
||||
{ REAL_CONST(1.4125481), REAL_CONST(1.5849090), REAL_CONST(1.9952921), REAL_CONST(2.8184461), REAL_CONST(3.1623565) }, |
||||
{ REAL_CONST(1.5849090), REAL_CONST(1.9952922), REAL_CONST(2.8184461), REAL_CONST(4.4669806), REAL_CONST(5.6232337) }, |
||||
{ REAL_CONST(1.7783016), REAL_CONST(2.5119365), REAL_CONST(4.4669806), REAL_CONST(7.9430881), REAL_CONST(11.219994) }, |
||||
{ REAL_CONST(1.9952921), REAL_CONST(3.5482312), REAL_CONST(7.0792671), REAL_CONST(14.125206), REAL_CONST(25.118876) }, |
||||
{ REAL_CONST(2.5119365), REAL_CONST(5.0116998), REAL_CONST(11.219994), REAL_CONST(25.118876), REAL_CONST(56.235140) } |
||||
}; |
||||
|
||||
/* 2^(-pan_quant[x][y] */ |
||||
static const real_t pan_pow_2_neg[8][5] = { |
||||
{ REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1) }, |
||||
{ REAL_CONST(0.8912487), REAL_CONST(0.8912487), REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.7943242) }, |
||||
{ REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.6309511), REAL_CONST(0.5623344), REAL_CONST(0.5623344) }, |
||||
{ REAL_CONST(0.7079405), REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.3162199) }, |
||||
{ REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.2238649), REAL_CONST(0.1778336) }, |
||||
{ REAL_CONST(0.5623343), REAL_CONST(0.3980992), REAL_CONST(0.2238649), REAL_CONST(0.1258956), REAL_CONST(0.0891266) }, |
||||
{ REAL_CONST(0.5011797), REAL_CONST(0.2818306), REAL_CONST(0.1412576), REAL_CONST(0.0707954), REAL_CONST(0.0398107) }, |
||||
{ REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } |
||||
}; |
||||
|
||||
/* 2^(pan_quant[x][y]/30) */ |
||||
static const real_t pan_pow_2_30_pos[8][5] = { |
||||
{ COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, |
||||
{ COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, |
||||
{ COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, |
||||
{ COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, |
||||
{ COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, |
||||
{ COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, |
||||
{ COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, |
||||
{ COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } |
||||
}; |
||||
|
||||
/* 2^(-pan_quant[x][y]/30) */ |
||||
static const real_t pan_pow_2_30_neg[8][5] = { |
||||
{ COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, |
||||
{ COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, |
||||
{ COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, |
||||
{ COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, |
||||
{ COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, |
||||
{ COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, |
||||
{ COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, |
||||
{ COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } |
||||
}; |
||||
|
||||
static const real_t g_decayslope[MAX_SA_BAND] = { |
||||
FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), |
||||
FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), |
||||
FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), |
||||
FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
||||
FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
||||
FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), |
||||
FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) |
||||
}; |
||||
|
||||
static const real_t sa_sqrt_1_minus[8][2] = { |
||||
{ FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.998744206), FRAC_CONST(0.984066644) }, |
||||
{ FRAC_CONST(0.997504707), FRAC_CONST(0.959473168) }, |
||||
{ FRAC_CONST(0.995037562), FRAC_CONST(0.894683804) }, |
||||
{ FRAC_CONST(0.990165638), FRAC_CONST(0.826933317) }, |
||||
{ FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, |
||||
{ FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, |
||||
{ FRAC_CONST(0.929071574), FRAC_CONST(0) } |
||||
}; |
||||
|
||||
static const uint8_t sa_freq_scale[9] = |
||||
{ |
||||
0, 1, 2, 3, 5, 7, 10, 13, 23 |
||||
}; |
||||
|
||||
//static const uint8_t pan_freq_scale[21] =
|
||||
//{
|
||||
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
// 11, 12, 13, 14, 15, 18, 22, 26, 32, 64
|
||||
//};
|
||||
|
||||
static const uint8_t pan_quant_class[20] = |
||||
{ |
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
||||
2, 2, 2, 2, 3, 3, 3, 4, 4, 4 |
||||
}; |
||||
|
||||
/* Inverse mapping lookup */ |
||||
static const uint8_t pan_inv_freq[64] = { |
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
||||
15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, |
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 |
||||
}; |
||||
|
||||
static const uint8_t sa_inv_freq[MAX_SA_BAND] = { |
||||
0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, |
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
||||
7, 7, 7, 7, 7, 7, 7 |
||||
}; |
||||
|
||||
static const real_t filter_coeff[] = |
||||
{ |
||||
FRAC_CONST(0.65143905754106), |
||||
FRAC_CONST(0.56471812200776), |
||||
FRAC_CONST(0.48954165955695) |
||||
}; |
||||
|
||||
static const uint8_t delay_length[3] = |
||||
{ |
||||
3, 4, 5 |
||||
}; |
||||
|
||||
//static const real_t delay_fraction[] =
|
||||
//{
|
||||
// FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347)
|
||||
//};
|
||||
|
||||
static const real_t peak_decay = FRAC_CONST(0.76592833836465); |
||||
|
||||
static const real_t smooth_coeff = FRAC_CONST(0.25); |
||||
|
||||
/* Please note that these are the same tables as in plain PS */ |
||||
static const complex_t Q_Fract_allpass_Qmf[][3] = { |
||||
{ { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, |
||||
{ { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, |
||||
{ { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, |
||||
{ { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, |
||||
{ { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, |
||||
{ { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, |
||||
{ { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, |
||||
{ { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, |
||||
{ { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, |
||||
{ { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, |
||||
{ { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, |
||||
{ { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, |
||||
{ { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, |
||||
{ { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, |
||||
{ { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, |
||||
{ { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, |
||||
{ { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, |
||||
{ { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, |
||||
{ { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, |
||||
{ { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, |
||||
{ { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, |
||||
{ { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, |
||||
{ { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, |
||||
{ { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, |
||||
{ { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, |
||||
{ { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, |
||||
{ { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, |
||||
{ { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, |
||||
{ { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, |
||||
{ { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, |
||||
{ { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, |
||||
{ { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, |
||||
{ { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, |
||||
{ { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, |
||||
{ { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, |
||||
{ { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, |
||||
{ { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, |
||||
{ { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, |
||||
{ { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, |
||||
{ { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, |
||||
{ { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, |
||||
{ { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, |
||||
{ { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, |
||||
{ { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, |
||||
{ { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, |
||||
{ { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, |
||||
{ { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, |
||||
{ { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, |
||||
{ { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, |
||||
{ { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, |
||||
{ { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, |
||||
{ { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, |
||||
{ { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, |
||||
{ { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, |
||||
{ { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, |
||||
{ { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, |
||||
{ { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, |
||||
{ { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, |
||||
{ { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, |
||||
{ { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, |
||||
{ { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, |
||||
{ { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, |
||||
{ { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, |
||||
{ { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } |
||||
}; |
||||
|
||||
static const complex_t Phi_Fract_Qmf[] = { |
||||
{ FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, |
||||
{ FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, |
||||
{ FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, |
||||
{ FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, |
||||
{ FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, |
||||
{ FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, |
||||
{ FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, |
||||
{ FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, |
||||
{ FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, |
||||
{ FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, |
||||
{ FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, |
||||
{ FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, |
||||
{ FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, |
||||
{ FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, |
||||
{ FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, |
||||
{ FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, |
||||
{ FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, |
||||
{ FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, |
||||
{ FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, |
||||
{ FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, |
||||
{ FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, |
||||
{ FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, |
||||
{ FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, |
||||
{ FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, |
||||
{ FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, |
||||
{ FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, |
||||
{ FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, |
||||
{ FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, |
||||
{ FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, |
||||
{ FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, |
||||
{ FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, |
||||
{ FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, |
||||
{ FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, |
||||
{ FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, |
||||
{ FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, |
||||
{ FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, |
||||
{ FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, |
||||
{ FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, |
||||
{ FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, |
||||
{ FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, |
||||
{ FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, |
||||
{ FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, |
||||
{ FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, |
||||
{ FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, |
||||
{ FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, |
||||
{ FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, |
||||
{ FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, |
||||
{ FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, |
||||
{ FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, |
||||
{ FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, |
||||
{ FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, |
||||
{ FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, |
||||
{ FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, |
||||
{ FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, |
||||
{ FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, |
||||
{ FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, |
||||
{ FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, |
||||
{ FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, |
||||
{ FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, |
||||
{ FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, |
||||
{ FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, |
||||
{ FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, |
||||
{ FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, |
||||
{ FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } |
||||
}; |
||||
|
||||
|
||||
/* static function declarations */ |
||||
static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld); |
||||
static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld); |
||||
static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff); |
||||
|
||||
|
||||
uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld) |
||||
{ |
||||
uint16_t bits = (uint16_t)faad_get_processed_bits(ld); |
||||
|
||||
ps->drm_ps_data_available = 1; |
||||
|
||||
ps->bs_enable_sa = faad_get1bit(ld); |
||||
ps->bs_enable_pan = faad_get1bit(ld); |
||||
|
||||
if (ps->bs_enable_sa) |
||||
{ |
||||
drm_ps_sa_element(ps, ld); |
||||
} |
||||
|
||||
if (ps->bs_enable_pan) |
||||
{ |
||||
drm_ps_pan_element(ps, ld); |
||||
} |
||||
|
||||
bits = (uint16_t)faad_get_processed_bits(ld) - bits; |
||||
|
||||
return bits; |
||||
} |
||||
|
||||
static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld) |
||||
{ |
||||
drm_ps_huff_tab huff; |
||||
uint8_t band; |
||||
|
||||
ps->bs_sa_dt_flag = faad_get1bit(ld); |
||||
if (ps->bs_sa_dt_flag) |
||||
{ |
||||
huff = t_huffman_sa; |
||||
} else { |
||||
huff = f_huffman_sa; |
||||
} |
||||
|
||||
for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
||||
{ |
||||
ps->bs_sa_data[band] = huff_dec(ld, huff); |
||||
} |
||||
} |
||||
|
||||
static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld) |
||||
{ |
||||
drm_ps_huff_tab huff; |
||||
uint8_t band; |
||||
|
||||
ps->bs_pan_dt_flag = faad_get1bit(ld); |
||||
if (ps->bs_pan_dt_flag) |
||||
{ |
||||
huff = t_huffman_pan; |
||||
} else { |
||||
huff = f_huffman_pan; |
||||
} |
||||
|
||||
for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
||||
{ |
||||
ps->bs_pan_data[band] = huff_dec(ld, huff); |
||||
} |
||||
} |
||||
|
||||
/* binary search huffman decoding */ |
||||
static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff) |
||||
{ |
||||
uint8_t bit; |
||||
int8_t index = 0; |
||||
|
||||
while (index >= 0) |
||||
{ |
||||
bit = (uint8_t)faad_get1bit(ld); |
||||
index = huff[index][bit]; |
||||
} |
||||
|
||||
return index + 15; |
||||
} |
||||
|
||||
|
||||
static int8_t sa_delta_clip(drm_ps_info *ps, int8_t i) |
||||
{ |
||||
if (i < 0) { |
||||
/* printf(" SAminclip %d", i); */ |
||||
ps->sa_decode_error = 1; |
||||
return 0; |
||||
} else if (i > 7) { |
||||
/* printf(" SAmaxclip %d", i); */ |
||||
ps->sa_decode_error = 1; |
||||
return 7; |
||||
} else |
||||
return i; |
||||
} |
||||
|
||||
static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) |
||||
{ |
||||
if (i < -7) { |
||||
/* printf(" PANminclip %d", i); */ |
||||
ps->pan_decode_error = 1; |
||||
return -7; |
||||
} else if (i > 7) { |
||||
/* printf(" PANmaxclip %d", i); */ |
||||
ps->pan_decode_error = 1; |
||||
return 7; |
||||
} else |
||||
return i; |
||||
} |
||||
|
||||
static void drm_ps_delta_decode(drm_ps_info *ps) |
||||
{ |
||||
uint8_t band; |
||||
|
||||
if (ps->bs_enable_sa) |
||||
{ |
||||
if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) |
||||
{ |
||||
/* wait until we get a DT frame */ |
||||
ps->bs_enable_sa = 0; |
||||
} else if (ps->bs_sa_dt_flag) { |
||||
/* DT frame, we have a last frame, so we can decode */ |
||||
ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); |
||||
} else { |
||||
/* DF always decodable */ |
||||
ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); |
||||
} |
||||
|
||||
for (band = 1; band < DRM_NUM_SA_BANDS; band++) |
||||
{ |
||||
if (ps->bs_sa_dt_flag && ps->g_last_had_sa) |
||||
{ |
||||
ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); |
||||
} else if (!ps->bs_sa_dt_flag) { |
||||
ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* An error during SA decoding implies PAN data will be undecodable, too */ |
||||
/* Also, we don't like on/off switching in PS, so we force to last settings */ |
||||
if (ps->sa_decode_error) { |
||||
ps->pan_decode_error = 1; |
||||
ps->bs_enable_pan = ps->g_last_had_pan; |
||||
ps->bs_enable_sa = ps->g_last_had_sa; |
||||
} |
||||
|
||||
|
||||
if (ps->bs_enable_sa) |
||||
{ |
||||
if (ps->sa_decode_error) { |
||||
for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
||||
{ |
||||
ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; |
||||
} |
||||
} else { |
||||
for (band = 0; band < DRM_NUM_SA_BANDS; band++) |
||||
{ |
||||
ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (ps->bs_enable_pan) |
||||
{ |
||||
if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) |
||||
{ |
||||
ps->bs_enable_pan = 0; |
||||
} else if (ps->bs_pan_dt_flag) { |
||||
ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); |
||||
} else { |
||||
ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); |
||||
} |
||||
|
||||
for (band = 1; band < DRM_NUM_PAN_BANDS; band++) |
||||
{ |
||||
if (ps->bs_pan_dt_flag && ps->g_last_had_pan) |
||||
{ |
||||
ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); |
||||
} else if (!ps->bs_pan_dt_flag) { |
||||
ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); |
||||
} |
||||
} |
||||
|
||||
if (ps->pan_decode_error) { |
||||
for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
||||
{ |
||||
ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; |
||||
} |
||||
} else { |
||||
for (band = 0; band < DRM_NUM_PAN_BANDS; band++) |
||||
{ |
||||
ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64]) |
||||
{ |
||||
uint8_t s, b, k; |
||||
complex_t qfrac, tmp0, tmp, in, R0; |
||||
real_t peakdiff; |
||||
real_t nrg; |
||||
real_t power; |
||||
real_t transratio; |
||||
real_t new_delay_slopes[NUM_OF_LINKS]; |
||||
uint8_t temp_delay_ser[NUM_OF_LINKS]; |
||||
complex_t Phi_Fract; |
||||
#ifdef FIXED_POINT |
||||
uint32_t in_re, in_im; |
||||
#endif |
||||
|
||||
for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) |
||||
{ |
||||
/* set delay indices */ |
||||
for (k = 0; k < NUM_OF_LINKS; k++) |
||||
temp_delay_ser[k] = ps->delay_buf_index_ser[k]; |
||||
|
||||
RE(Phi_Fract) = RE(Phi_Fract_Qmf[b]); |
||||
IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); |
||||
|
||||
for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
||||
{ |
||||
const real_t gamma = REAL_CONST(1.5); |
||||
const real_t sigma = REAL_CONST(1.5625); |
||||
|
||||
RE(in) = QMF_RE(X[s][b]); |
||||
IM(in) = QMF_IM(X[s][b]); |
||||
|
||||
#ifdef FIXED_POINT |
||||
/* NOTE: all input is scaled by 2^(-5) because of fixed point QMF
|
||||
* meaning that P will be scaled by 2^(-10) compared to floating point version |
||||
*/ |
||||
in_re = ((abs(RE(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); |
||||
in_im = ((abs(IM(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); |
||||
power = in_re*in_re + in_im*in_im; |
||||
#else |
||||
power = MUL_R(RE(in),RE(in)) + MUL_R(IM(in),IM(in)); |
||||
#endif |
||||
|
||||
ps->peakdecay_fast[b] = MUL_F(ps->peakdecay_fast[b], peak_decay); |
||||
if (ps->peakdecay_fast[b] < power) |
||||
ps->peakdecay_fast[b] = power; |
||||
|
||||
peakdiff = ps->prev_peakdiff[b]; |
||||
peakdiff += MUL_F((ps->peakdecay_fast[b] - power - ps->prev_peakdiff[b]), smooth_coeff); |
||||
ps->prev_peakdiff[b] = peakdiff; |
||||
|
||||
nrg = ps->prev_nrg[b]; |
||||
nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff); |
||||
ps->prev_nrg[b] = nrg; |
||||
|
||||
if (MUL_R(peakdiff, gamma) <= nrg) { |
||||
transratio = sigma; |
||||
} else { |
||||
transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); |
||||
} |
||||
|
||||
for (k = 0; k < NUM_OF_LINKS; k++) |
||||
{ |
||||
new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); |
||||
} |
||||
|
||||
RE(tmp0) = RE(ps->d_buff[0][b]); |
||||
IM(tmp0) = IM(ps->d_buff[0][b]); |
||||
|
||||
RE(ps->d_buff[0][b]) = RE(ps->d_buff[1][b]); |
||||
IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); |
||||
|
||||
RE(ps->d_buff[1][b]) = RE(in); |
||||
IM(ps->d_buff[1][b]) = IM(in); |
||||
|
||||
ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); |
||||
|
||||
RE(R0) = RE(tmp); |
||||
IM(R0) = IM(tmp); |
||||
|
||||
for (k = 0; k < NUM_OF_LINKS; k++) |
||||
{ |
||||
RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); |
||||
IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); |
||||
|
||||
RE(tmp0) = RE(ps->d2_buff[k][temp_delay_ser[k]][b]); |
||||
IM(tmp0) = IM(ps->d2_buff[k][temp_delay_ser[k]][b]); |
||||
|
||||
ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(qfrac), IM(qfrac)); |
||||
|
||||
RE(tmp) += -MUL_F(new_delay_slopes[k], RE(R0)); |
||||
IM(tmp) += -MUL_F(new_delay_slopes[k], IM(R0)); |
||||
|
||||
RE(ps->d2_buff[k][temp_delay_ser[k]][b]) = RE(R0) + MUL_F(new_delay_slopes[k], RE(tmp)); |
||||
IM(ps->d2_buff[k][temp_delay_ser[k]][b]) = IM(R0) + MUL_F(new_delay_slopes[k], IM(tmp)); |
||||
|
||||
RE(R0) = RE(tmp); |
||||
IM(R0) = IM(tmp); |
||||
} |
||||
|
||||
QMF_RE(ps->SA[s][b]) = MUL_R(RE(R0), transratio); |
||||
QMF_IM(ps->SA[s][b]) = MUL_R(IM(R0), transratio); |
||||
|
||||
for (k = 0; k < NUM_OF_LINKS; k++) |
||||
{ |
||||
if (++temp_delay_ser[k] >= delay_length[k]) |
||||
temp_delay_ser[k] = 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (k = 0; k < NUM_OF_LINKS; k++) |
||||
ps->delay_buf_index_ser[k] = temp_delay_ser[k]; |
||||
} |
||||
|
||||
static void drm_add_ambiance(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
||||
{ |
||||
uint8_t s, b, ifreq, qclass; |
||||
real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; |
||||
real_t new_dir_map, new_sa_map; |
||||
|
||||
if (ps->bs_enable_sa) |
||||
{ |
||||
/* Instead of dequantization and mapping, we use an inverse mapping
|
||||
to look up all the values we need */ |
||||
for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) |
||||
{ |
||||
const real_t inv_f_num_of_subsamples = FRAC_CONST(0.03333333333); |
||||
|
||||
ifreq = sa_inv_freq[b]; |
||||
qclass = (b != 0); |
||||
|
||||
sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; |
||||
new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; |
||||
|
||||
k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b])); |
||||
|
||||
sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass]; |
||||
new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; |
||||
|
||||
k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); |
||||
|
||||
} |
||||
|
||||
for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
||||
{ |
||||
for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) |
||||
{ |
||||
QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); |
||||
QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); |
||||
QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); |
||||
QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); |
||||
|
||||
sa_map[b] += k_sa_map[b]; |
||||
sa_dir_map[b] += k_sa_dir_map[b]; |
||||
} |
||||
for (b = sa_freq_scale[DRM_NUM_SA_BANDS]; b < NUM_OF_QMF_CHANNELS; b++) |
||||
{ |
||||
QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); |
||||
QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); |
||||
} |
||||
} |
||||
} |
||||
else { |
||||
for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
||||
{ |
||||
for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
||||
{ |
||||
QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); |
||||
QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void drm_add_pan(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
||||
{ |
||||
uint8_t s, b, qclass, ifreq; |
||||
real_t tmp, coeff1, coeff2; |
||||
real_t pan_base[MAX_PAN_BAND]; |
||||
real_t pan_delta[MAX_PAN_BAND]; |
||||
qmf_t temp_l, temp_r; |
||||
|
||||
if (ps->bs_enable_pan) |
||||
{ |
||||
for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
||||
{ |
||||
/* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an
|
||||
inverse mapping 64->20 and look up the 2^G(x,y) values directly */ |
||||
ifreq = pan_inv_freq[b]; |
||||
qclass = pan_quant_class[ifreq]; |
||||
|
||||
if (ps->g_prev_pan_index[ifreq] >= 0) |
||||
{ |
||||
pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass]; |
||||
} else { |
||||
pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; |
||||
} |
||||
|
||||
/* 2^((a-b)/30) = 2^(a/30) * 1/(2^(b/30)) */ |
||||
/* a en b can be negative so we may need to inverse parts */ |
||||
if (ps->g_pan_index[ifreq] >= 0) |
||||
{ |
||||
if (ps->g_prev_pan_index[ifreq] >= 0) |
||||
{ |
||||
pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], |
||||
pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
||||
} else { |
||||
pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], |
||||
pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); |
||||
} |
||||
} else { |
||||
if (ps->g_prev_pan_index[ifreq] >= 0) |
||||
{ |
||||
pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], |
||||
pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); |
||||
} else { |
||||
pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], |
||||
pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (s = 0; s < NUM_OF_SUBSAMPLES; s++) |
||||
{ |
||||
/* PAN always uses all 64 channels */ |
||||
for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) |
||||
{ |
||||
tmp = pan_base[b]; |
||||
|
||||
coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); |
||||
coeff1 = MUL_R(coeff2, tmp); |
||||
|
||||
QMF_RE(temp_l) = QMF_RE(X_left[s][b]); |
||||
QMF_IM(temp_l) = QMF_IM(X_left[s][b]); |
||||
QMF_RE(temp_r) = QMF_RE(X_right[s][b]); |
||||
QMF_IM(temp_r) = QMF_IM(X_right[s][b]); |
||||
|
||||
QMF_RE(X_left[s][b]) = MUL_R(QMF_RE(temp_l), coeff1); |
||||
QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); |
||||
QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); |
||||
QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); |
||||
|
||||
/* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ |
||||
/* ^^^^^^^^^^^^^^^ k times */ |
||||
pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
drm_ps_info *drm_ps_init(void) |
||||
{ |
||||
drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info)); |
||||
|
||||
memset(ps, 0, sizeof(drm_ps_info)); |
||||
|
||||
return ps; |
||||
} |
||||
|
||||
void drm_ps_free(drm_ps_info *ps) |
||||
{ |
||||
faad_free(ps); |
||||
} |
||||
|
||||
/* main DRM PS decoding function */ |
||||
uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]) |
||||
{ |
||||
if (ps == NULL) |
||||
{ |
||||
memcpy(X_right, X_left, sizeof(qmf_t)*30*64); |
||||
return 0; |
||||
} |
||||
|
||||
if (!ps->drm_ps_data_available && !guess) |
||||
{ |
||||
memcpy(X_right, X_left, sizeof(qmf_t)*30*64); |
||||
memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); |
||||
memset(ps->g_prev_pan_index, 0, sizeof(ps->g_prev_pan_index)); |
||||
return 0; |
||||
} |
||||
|
||||
/* if SBR CRC doesn't match out, we can assume decode errors to start with,
|
||||
and we'll guess what the parameters should be */ |
||||
if (!guess) |
||||
{ |
||||
ps->sa_decode_error = 0; |
||||
ps->pan_decode_error = 0; |
||||
drm_ps_delta_decode(ps); |
||||
} else |
||||
{ |
||||
ps->sa_decode_error = 1; |
||||
ps->pan_decode_error = 1; |
||||
/* don't even bother decoding */ |
||||
} |
||||
|
||||
ps->drm_ps_data_available = 0; |
||||
|
||||
drm_calc_sa_side_signal(ps, X_left); |
||||
drm_add_ambiance(ps, X_left, X_right); |
||||
|
||||
if (ps->bs_enable_sa) |
||||
{ |
||||
ps->g_last_had_sa = 1; |
||||
|
||||
memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS); |
||||
|
||||
} else { |
||||
ps->g_last_had_sa = 0; |
||||
} |
||||
|
||||
if (ps->bs_enable_pan) |
||||
{ |
||||
drm_add_pan(ps, X_left, X_right); |
||||
|
||||
ps->g_last_had_pan = 1; |
||||
|
||||
memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); |
||||
|
||||
} else { |
||||
ps->g_last_had_pan = 0; |
||||
} |
||||
|
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,100 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: drm_dec.h,v 1.8 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __DRM_DEC_H__ |
||||
#define __DRM_DEC_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "bits.h" |
||||
|
||||
#define DRM_PARAMETRIC_STEREO 0 |
||||
#define DRM_NUM_SA_BANDS 8 |
||||
#define DRM_NUM_PAN_BANDS 20 |
||||
#define NUM_OF_LINKS 3 |
||||
#define NUM_OF_QMF_CHANNELS 64 |
||||
#define NUM_OF_SUBSAMPLES 30 |
||||
#define MAX_SA_BAND 46 |
||||
#define MAX_PAN_BAND 64 |
||||
#define MAX_DELAY 5 |
||||
|
||||
typedef struct |
||||
{ |
||||
uint8_t drm_ps_data_available; |
||||
uint8_t bs_enable_sa; |
||||
uint8_t bs_enable_pan; |
||||
|
||||
uint8_t bs_sa_dt_flag; |
||||
uint8_t bs_pan_dt_flag; |
||||
|
||||
uint8_t g_last_had_sa; |
||||
uint8_t g_last_had_pan; |
||||
|
||||
int8_t bs_sa_data[DRM_NUM_SA_BANDS]; |
||||
int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; |
||||
|
||||
int8_t g_sa_index[DRM_NUM_SA_BANDS]; |
||||
int8_t g_pan_index[DRM_NUM_PAN_BANDS]; |
||||
int8_t g_prev_sa_index[DRM_NUM_SA_BANDS]; |
||||
int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS]; |
||||
|
||||
int8_t sa_decode_error; |
||||
int8_t pan_decode_error; |
||||
|
||||
int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; |
||||
int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS]; |
||||
|
||||
uint8_t delay_buf_index_ser[NUM_OF_LINKS]; |
||||
|
||||
qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND]; |
||||
|
||||
complex_t d_buff[2][MAX_SA_BAND]; |
||||
complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; |
||||
|
||||
real_t prev_nrg[MAX_SA_BAND]; |
||||
real_t prev_peakdiff[MAX_SA_BAND]; |
||||
real_t peakdecay_fast[MAX_SA_BAND]; |
||||
} drm_ps_info; |
||||
|
||||
|
||||
uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); |
||||
|
||||
drm_ps_info *drm_ps_init(void); |
||||
void drm_ps_free(drm_ps_info *ps); |
||||
|
||||
uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,70 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: error.c,v 1.33 2008/09/19 23:31:39 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "error.h" |
||||
|
||||
char *err_msg[] = { |
||||
"No error", |
||||
"Gain control not yet implemented", |
||||
"Pulse coding not allowed in short blocks", |
||||
"Invalid huffman codebook", |
||||
"Scalefactor out of range", |
||||
"Unable to find ADTS syncword", |
||||
"Channel coupling not yet implemented", |
||||
"Channel configuration not allowed in error resilient frame", |
||||
"Bit error in error resilient scalefactor decoding", |
||||
"Error decoding huffman scalefactor (bitstream error)", |
||||
"Error decoding huffman codeword (bitstream error)", |
||||
"Non existent huffman codebook number found", |
||||
"Invalid number of channels", |
||||
"Maximum number of bitstream elements exceeded", |
||||
"Input data buffer too small", |
||||
"Array index out of range", |
||||
"Maximum number of scalefactor bands exceeded", |
||||
"Quantised value out of range", |
||||
"LTP lag out of range", |
||||
"Invalid SBR parameter decoded", |
||||
"SBR called without being initialised", |
||||
"Unexpected channel configuration change", |
||||
"Error in program_config_element", |
||||
"First SBR frame is not the same as first AAC frame", |
||||
"Unexpected fill element with SBR data", |
||||
"Not all elements were provided with SBR data", |
||||
"LTP decoding not available", |
||||
"Output data buffer too small", |
||||
"CRC error in DRM data", |
||||
"PNS not allowed in DRM data stream", |
||||
"No standard extension payload allowed in DRM", |
||||
"PCE shall be the first element in a frame", |
||||
"Bitstream value not allowed by specification", |
||||
"MAIN prediction not initialised" |
||||
}; |
||||
|
@ -0,0 +1,44 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: error.h,v 1.27 2008/09/19 23:31:40 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __ERROR_H__ |
||||
#define __ERROR_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define NUM_ERROR_MESSAGES 34 |
||||
extern char *err_msg[]; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,11 @@ |
||||
prefix=@prefix@ |
||||
exec_prefix=@exec_prefix@ |
||||
libdir=@libdir@ |
||||
includedir=@includedir@ |
||||
|
||||
Name: FAAD2 |
||||
Description: Freeware Advanced Audio (AAC) Decoder |
||||
Version: @VERSION@ |
||||
Libs: -L${libdir} -lfaad |
||||
Libs.private: -lm |
||||
Cflags: -I${includedir} |
@ -0,0 +1,408 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: filtbank.c,v 1.46 2009/01/26 23:51:15 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#ifdef _WIN32_WCE |
||||
#define assert(x) |
||||
#else |
||||
#include <assert.h> |
||||
#endif |
||||
|
||||
#include "filtbank.h" |
||||
#include "syntax.h" |
||||
#include "kbd_win.h" |
||||
#include "sine_win.h" |
||||
#include "mdct.h" |
||||
|
||||
|
||||
fb_info *filter_bank_init(uint16_t frame_len) |
||||
{ |
||||
uint16_t nshort = frame_len/8; |
||||
#ifdef LD_DEC |
||||
uint16_t frame_len_ld = frame_len/2; |
||||
#endif |
||||
|
||||
fb_info *fb = (fb_info*)faad_malloc(sizeof(fb_info)); |
||||
memset(fb, 0, sizeof(fb_info)); |
||||
|
||||
/* normal */ |
||||
fb->mdct256 = faad_mdct_init(2*nshort); |
||||
fb->mdct2048 = faad_mdct_init(2*frame_len); |
||||
#ifdef LD_DEC |
||||
/* LD */ |
||||
fb->mdct1024 = faad_mdct_init(2*frame_len_ld); |
||||
#endif |
||||
|
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
if (frame_len == 1024) |
||||
{ |
||||
#endif |
||||
fb->long_window[0] = sine_long_1024; |
||||
fb->short_window[0] = sine_short_128; |
||||
fb->long_window[1] = kbd_long_1024; |
||||
fb->short_window[1] = kbd_short_128; |
||||
#ifdef LD_DEC |
||||
fb->ld_window[0] = sine_mid_512; |
||||
fb->ld_window[1] = ld_mid_512; |
||||
#endif |
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
} else /* (frame_len == 960) */ { |
||||
fb->long_window[0] = sine_long_960; |
||||
fb->short_window[0] = sine_short_120; |
||||
fb->long_window[1] = kbd_long_960; |
||||
fb->short_window[1] = kbd_short_120; |
||||
#ifdef LD_DEC |
||||
fb->ld_window[0] = sine_mid_480; |
||||
fb->ld_window[1] = ld_mid_480; |
||||
#endif |
||||
} |
||||
#endif |
||||
|
||||
return fb; |
||||
} |
||||
|
||||
void filter_bank_end(fb_info *fb) |
||||
{ |
||||
if (fb != NULL) |
||||
{ |
||||
#ifdef PROFILE |
||||
printf("FB: %I64d cycles\n", fb->cycles); |
||||
#endif |
||||
|
||||
faad_mdct_end(fb->mdct256); |
||||
faad_mdct_end(fb->mdct2048); |
||||
#ifdef LD_DEC |
||||
faad_mdct_end(fb->mdct1024); |
||||
#endif |
||||
|
||||
faad_free(fb); |
||||
} |
||||
} |
||||
|
||||
static INLINE void imdct_long(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len) |
||||
{ |
||||
#ifdef LD_DEC |
||||
mdct_info *mdct = NULL; |
||||
|
||||
switch (len) |
||||
{ |
||||
case 2048: |
||||
case 1920: |
||||
mdct = fb->mdct2048; |
||||
break; |
||||
case 1024: |
||||
case 960: |
||||
mdct = fb->mdct1024; |
||||
break; |
||||
} |
||||
|
||||
faad_imdct(mdct, in_data, out_data); |
||||
#else |
||||
(void)len; |
||||
faad_imdct(fb->mdct2048, in_data, out_data); |
||||
#endif |
||||
} |
||||
|
||||
|
||||
#ifdef LTP_DEC |
||||
static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len) |
||||
{ |
||||
mdct_info *mdct = NULL; |
||||
|
||||
switch (len) |
||||
{ |
||||
case 2048: |
||||
case 1920: |
||||
mdct = fb->mdct2048; |
||||
break; |
||||
case 256: |
||||
case 240: |
||||
mdct = fb->mdct256; |
||||
break; |
||||
#ifdef LD_DEC |
||||
case 1024: |
||||
case 960: |
||||
mdct = fb->mdct1024; |
||||
break; |
||||
#endif |
||||
} |
||||
|
||||
faad_mdct(mdct, in_data, out_data); |
||||
} |
||||
#endif |
||||
|
||||
void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, |
||||
uint8_t window_shape_prev, real_t *freq_in, |
||||
real_t *time_out, real_t *overlap, |
||||
uint8_t object_type, uint16_t frame_len) |
||||
{ |
||||
int16_t i; |
||||
ALIGN real_t transf_buf[2*1024] = {0}; |
||||
|
||||
const real_t *window_long = NULL; |
||||
const real_t *window_long_prev = NULL; |
||||
const real_t *window_short = NULL; |
||||
const real_t *window_short_prev = NULL; |
||||
|
||||
uint16_t nlong = frame_len; |
||||
uint16_t nshort = frame_len/8; |
||||
uint16_t trans = nshort/2; |
||||
|
||||
uint16_t nflat_ls = (nlong-nshort)/2; |
||||
|
||||
#ifdef PROFILE |
||||
int64_t count = faad_get_ts(); |
||||
#endif |
||||
|
||||
/* select windows of current frame and previous frame (Sine or KBD) */ |
||||
#ifdef LD_DEC |
||||
if (object_type == LD) |
||||
{ |
||||
window_long = fb->ld_window[window_shape]; |
||||
window_long_prev = fb->ld_window[window_shape_prev]; |
||||
} else { |
||||
#else |
||||
(void)object_type; |
||||
#endif |
||||
window_long = fb->long_window[window_shape]; |
||||
window_long_prev = fb->long_window[window_shape_prev]; |
||||
window_short = fb->short_window[window_shape]; |
||||
window_short_prev = fb->short_window[window_shape_prev]; |
||||
#ifdef LD_DEC |
||||
} |
||||
#endif |
||||
|
||||
#if 0 |
||||
for (i = 0; i < 1024; i++) |
||||
{ |
||||
printf("%d\n", freq_in[i]); |
||||
} |
||||
#endif |
||||
|
||||
#if 0 |
||||
printf("%d %d\n", window_sequence, window_shape); |
||||
#endif |
||||
|
||||
switch (window_sequence) |
||||
{ |
||||
case ONLY_LONG_SEQUENCE: |
||||
/* perform iMDCT */ |
||||
imdct_long(fb, freq_in, transf_buf, 2*nlong); |
||||
|
||||
/* add second half output of previous frame to windowed output of current frame */ |
||||
for (i = 0; i < nlong; i+=4) |
||||
{ |
||||
time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); |
||||
time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); |
||||
time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); |
||||
time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); |
||||
} |
||||
|
||||
/* window the second half and save as overlap for next frame */ |
||||
for (i = 0; i < nlong; i+=4) |
||||
{ |
||||
overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); |
||||
overlap[i+1] = MUL_F(transf_buf[nlong+i+1],window_long[nlong-2-i]); |
||||
overlap[i+2] = MUL_F(transf_buf[nlong+i+2],window_long[nlong-3-i]); |
||||
overlap[i+3] = MUL_F(transf_buf[nlong+i+3],window_long[nlong-4-i]); |
||||
} |
||||
break; |
||||
|
||||
case LONG_START_SEQUENCE: |
||||
/* perform iMDCT */ |
||||
imdct_long(fb, freq_in, transf_buf, 2*nlong); |
||||
|
||||
/* add second half output of previous frame to windowed output of current frame */ |
||||
for (i = 0; i < nlong; i+=4) |
||||
{ |
||||
time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); |
||||
time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); |
||||
time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); |
||||
time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); |
||||
} |
||||
|
||||
/* window the second half and save as overlap for next frame */ |
||||
/* construct second half window using padding with 1's and 0's */ |
||||
for (i = 0; i < nflat_ls; i++) |
||||
overlap[i] = transf_buf[nlong+i]; |
||||
for (i = 0; i < nshort; i++) |
||||
overlap[nflat_ls+i] = MUL_F(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); |
||||
for (i = 0; i < nflat_ls; i++) |
||||
overlap[nflat_ls+nshort+i] = 0; |
||||
break; |
||||
|
||||
case EIGHT_SHORT_SEQUENCE: |
||||
/* perform iMDCT for each short block */ |
||||
faad_imdct(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0); |
||||
faad_imdct(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1); |
||||
faad_imdct(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2); |
||||
faad_imdct(fb->mdct256, freq_in+3*nshort, transf_buf+2*nshort*3); |
||||
faad_imdct(fb->mdct256, freq_in+4*nshort, transf_buf+2*nshort*4); |
||||
faad_imdct(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5); |
||||
faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6); |
||||
faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7); |
||||
|
||||
/* add second half output of previous frame to windowed output of current frame */ |
||||
for (i = 0; i < nflat_ls; i++) |
||||
time_out[i] = overlap[i]; |
||||
for(i = 0; i < nshort; i++) |
||||
{ |
||||
time_out[nflat_ls+ i] = overlap[nflat_ls+ i] + MUL_F(transf_buf[nshort*0+i],window_short_prev[i]); |
||||
time_out[nflat_ls+1*nshort+i] = overlap[nflat_ls+nshort*1+i] + MUL_F(transf_buf[nshort*1+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*2+i],window_short[i]); |
||||
time_out[nflat_ls+2*nshort+i] = overlap[nflat_ls+nshort*2+i] + MUL_F(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*4+i],window_short[i]); |
||||
time_out[nflat_ls+3*nshort+i] = overlap[nflat_ls+nshort*3+i] + MUL_F(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*6+i],window_short[i]); |
||||
if (i < trans) |
||||
time_out[nflat_ls+4*nshort+i] = overlap[nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); |
||||
} |
||||
|
||||
/* window the second half and save as overlap for next frame */ |
||||
for(i = 0; i < nshort; i++) |
||||
{ |
||||
if (i >= trans) |
||||
overlap[nflat_ls+4*nshort+i-nlong] = MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); |
||||
overlap[nflat_ls+5*nshort+i-nlong] = MUL_F(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*10+i],window_short[i]); |
||||
overlap[nflat_ls+6*nshort+i-nlong] = MUL_F(transf_buf[nshort*11+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*12+i],window_short[i]); |
||||
overlap[nflat_ls+7*nshort+i-nlong] = MUL_F(transf_buf[nshort*13+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*14+i],window_short[i]); |
||||
overlap[nflat_ls+8*nshort+i-nlong] = MUL_F(transf_buf[nshort*15+i],window_short[nshort-1-i]); |
||||
} |
||||
for (i = 0; i < nflat_ls; i++) |
||||
overlap[nflat_ls+nshort+i] = 0; |
||||
break; |
||||
|
||||
case LONG_STOP_SEQUENCE: |
||||
/* perform iMDCT */ |
||||
imdct_long(fb, freq_in, transf_buf, 2*nlong); |
||||
|
||||
/* add second half output of previous frame to windowed output of current frame */ |
||||
/* construct first half window using padding with 1's and 0's */ |
||||
for (i = 0; i < nflat_ls; i++) |
||||
time_out[i] = overlap[i]; |
||||
for (i = 0; i < nshort; i++) |
||||
time_out[nflat_ls+i] = overlap[nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]); |
||||
for (i = 0; i < nflat_ls; i++) |
||||
time_out[nflat_ls+nshort+i] = overlap[nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i]; |
||||
|
||||
/* window the second half and save as overlap for next frame */ |
||||
for (i = 0; i < nlong; i++) |
||||
overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); |
||||
break; |
||||
} |
||||
|
||||
#if 0 |
||||
for (i = 0; i < 1024; i++) |
||||
{ |
||||
printf("%d\n", time_out[i]); |
||||
//printf("0x%.8X\n", time_out[i]);
|
||||
} |
||||
#endif |
||||
|
||||
|
||||
#ifdef PROFILE |
||||
count = faad_get_ts() - count; |
||||
fb->cycles += count; |
||||
#endif |
||||
} |
||||
|
||||
|
||||
#ifdef LTP_DEC |
||||
/* only works for LTP -> no overlapping, no short blocks */ |
||||
void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, |
||||
uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct, |
||||
uint8_t object_type, uint16_t frame_len) |
||||
{ |
||||
int16_t i; |
||||
ALIGN real_t windowed_buf[2*1024] = {0}; |
||||
|
||||
const real_t *window_long = NULL; |
||||
const real_t *window_long_prev = NULL; |
||||
const real_t *window_short = NULL; |
||||
const real_t *window_short_prev = NULL; |
||||
|
||||
uint16_t nlong = frame_len; |
||||
uint16_t nshort = frame_len/8; |
||||
uint16_t nflat_ls = (nlong-nshort)/2; |
||||
|
||||
assert(window_sequence != EIGHT_SHORT_SEQUENCE); |
||||
|
||||
#ifdef LD_DEC |
||||
if (object_type == LD) |
||||
{ |
||||
window_long = fb->ld_window[window_shape]; |
||||
window_long_prev = fb->ld_window[window_shape_prev]; |
||||
} else { |
||||
#endif |
||||
window_long = fb->long_window[window_shape]; |
||||
window_long_prev = fb->long_window[window_shape_prev]; |
||||
window_short = fb->short_window[window_shape]; |
||||
window_short_prev = fb->short_window[window_shape_prev]; |
||||
#ifdef LD_DEC |
||||
} |
||||
#endif |
||||
|
||||
switch(window_sequence) |
||||
{ |
||||
case ONLY_LONG_SEQUENCE: |
||||
for (i = nlong-1; i >= 0; i--) |
||||
{ |
||||
windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); |
||||
windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); |
||||
} |
||||
mdct(fb, windowed_buf, out_mdct, 2*nlong); |
||||
break; |
||||
|
||||
case LONG_START_SEQUENCE: |
||||
for (i = 0; i < nlong; i++) |
||||
windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); |
||||
for (i = 0; i < nflat_ls; i++) |
||||
windowed_buf[i+nlong] = in_data[i+nlong]; |
||||
for (i = 0; i < nshort; i++) |
||||
windowed_buf[i+nlong+nflat_ls] = MUL_F(in_data[i+nlong+nflat_ls], window_short[nshort-1-i]); |
||||
for (i = 0; i < nflat_ls; i++) |
||||
windowed_buf[i+nlong+nflat_ls+nshort] = 0; |
||||
mdct(fb, windowed_buf, out_mdct, 2*nlong); |
||||
break; |
||||
|
||||
case LONG_STOP_SEQUENCE: |
||||
for (i = 0; i < nflat_ls; i++) |
||||
windowed_buf[i] = 0; |
||||
for (i = 0; i < nshort; i++) |
||||
windowed_buf[i+nflat_ls] = MUL_F(in_data[i+nflat_ls], window_short_prev[i]); |
||||
for (i = 0; i < nflat_ls; i++) |
||||
windowed_buf[i+nflat_ls+nshort] = in_data[i+nflat_ls+nshort]; |
||||
for (i = 0; i < nlong; i++) |
||||
windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); |
||||
mdct(fb, windowed_buf, out_mdct, 2*nlong); |
||||
break; |
||||
} |
||||
} |
||||
#endif |
@ -0,0 +1,61 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: filtbank.h,v 1.27 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __FILTBANK_H__ |
||||
#define __FILTBANK_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
fb_info *filter_bank_init(uint16_t frame_len); |
||||
void filter_bank_end(fb_info *fb); |
||||
|
||||
#ifdef LTP_DEC |
||||
void filter_bank_ltp(fb_info *fb, |
||||
uint8_t window_sequence, |
||||
uint8_t window_shape, |
||||
uint8_t window_shape_prev, |
||||
real_t *in_data, |
||||
real_t *out_mdct, |
||||
uint8_t object_type, |
||||
uint16_t frame_len); |
||||
#endif |
||||
|
||||
void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, |
||||
uint8_t window_shape_prev, real_t *freq_in, |
||||
real_t *time_out, real_t *overlap, |
||||
uint8_t object_type, uint16_t frame_len); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,293 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: fixed.h,v 1.32 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __FIXED_H__ |
||||
#define __FIXED_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#if defined(_WIN32_WCE) && defined(_ARM_) |
||||
#include <cmnintrin.h> |
||||
#endif |
||||
|
||||
|
||||
#define COEF_BITS 28 |
||||
#define COEF_PRECISION (1 << COEF_BITS) |
||||
#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
|
||||
#define REAL_PRECISION (1 << REAL_BITS) |
||||
|
||||
/* FRAC is the fractional only part of the fixed point number [0.0..1.0) */ |
||||
#define FRAC_SIZE 32 /* frac is a 32 bit integer */ |
||||
#define FRAC_BITS 31 |
||||
/* Multiplication by power of 2 will be compiled to left-shift */ |
||||
#define FRAC_MUL (1u << (FRAC_SIZE - FRAC_BITS)) |
||||
#define FRAC_PRECISION ((uint32_t)(1u << FRAC_BITS)) |
||||
#define FRAC_MAX 0x7FFFFFFF |
||||
|
||||
typedef int32_t real_t; |
||||
|
||||
|
||||
#define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5))) |
||||
#define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5))) |
||||
#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))) |
||||
//#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))
|
||||
|
||||
#define Q2_BITS 22 |
||||
#define Q2_PRECISION (1 << Q2_BITS) |
||||
#define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A)*(Q2_PRECISION)+0.5)) : ((real_t)((A)*(Q2_PRECISION)-0.5))) |
||||
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && !defined(_WIN64) |
||||
|
||||
/* multiply with real shift */ |
||||
static INLINE real_t MUL_R(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,REAL_BITS |
||||
} |
||||
} |
||||
|
||||
/* multiply with coef shift */ |
||||
static INLINE real_t MUL_C(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,COEF_BITS |
||||
} |
||||
} |
||||
|
||||
static INLINE real_t MUL_Q2(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,Q2_BITS |
||||
} |
||||
} |
||||
|
||||
static INLINE real_t MUL_SHIFT6(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,6 |
||||
} |
||||
} |
||||
|
||||
static INLINE real_t MUL_SHIFT23(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,23 |
||||
} |
||||
} |
||||
|
||||
#if 1 |
||||
static INLINE real_t _MulHigh(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
mov eax,edx |
||||
} |
||||
} |
||||
|
||||
/* multiply with fractional shift */ |
||||
static INLINE real_t MUL_F(real_t A, real_t B) |
||||
{ |
||||
return _MulHigh(A,B) << (FRAC_SIZE-FRAC_BITS); |
||||
} |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
*y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS); |
||||
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS); |
||||
} |
||||
#else |
||||
static INLINE real_t MUL_F(real_t A, real_t B) |
||||
{ |
||||
_asm { |
||||
mov eax,A |
||||
imul B |
||||
shrd eax,edx,FRAC_BITS |
||||
} |
||||
} |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2); |
||||
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2); |
||||
} |
||||
#endif |
||||
|
||||
#elif defined(__GNUC__) && defined (__arm__) |
||||
|
||||
/* taken from MAD */ |
||||
#define arm_mul(x, y, SCALEBITS) \ |
||||
({ \
|
||||
uint32_t __hi; \
|
||||
uint32_t __lo; \
|
||||
uint32_t __result; \
|
||||
asm("smull %0, %1, %3, %4\n\t" \
|
||||
"movs %0, %0, lsr %5\n\t" \
|
||||
"adc %2, %0, %1, lsl %6" \
|
||||
: "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
|
||||
: "%r" (x), "r" (y), \
|
||||
"M" (SCALEBITS), "M" (32 - (SCALEBITS)) \
|
||||
: "cc"); \
|
||||
__result; \
|
||||
}) |
||||
|
||||
static INLINE real_t MUL_R(real_t A, real_t B) |
||||
{ |
||||
return arm_mul(A, B, REAL_BITS); |
||||
} |
||||
|
||||
static INLINE real_t MUL_C(real_t A, real_t B) |
||||
{ |
||||
return arm_mul(A, B, COEF_BITS); |
||||
} |
||||
|
||||
static INLINE real_t MUL_Q2(real_t A, real_t B) |
||||
{ |
||||
return arm_mul(A, B, Q2_BITS); |
||||
} |
||||
|
||||
static INLINE real_t MUL_SHIFT6(real_t A, real_t B) |
||||
{ |
||||
return arm_mul(A, B, 6); |
||||
} |
||||
|
||||
static INLINE real_t MUL_SHIFT23(real_t A, real_t B) |
||||
{ |
||||
return arm_mul(A, B, 23); |
||||
} |
||||
|
||||
static INLINE real_t _MulHigh(real_t x, real_t y) |
||||
{ |
||||
uint32_t __lo; |
||||
uint32_t __hi; |
||||
asm("smull\t%0, %1, %2, %3" |
||||
: "=&r"(__lo),"=&r"(__hi) |
||||
: "%r"(x),"r"(y) |
||||
: "cc"); |
||||
return __hi; |
||||
} |
||||
|
||||
static INLINE real_t MUL_F(real_t A, real_t B) |
||||
{ |
||||
return _MulHigh(A, B) << (FRAC_SIZE-FRAC_BITS); |
||||
} |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
int32_t tmp, yt1, yt2; |
||||
asm("smull %0, %1, %4, %6\n\t" |
||||
"smlal %0, %1, %5, %7\n\t" |
||||
"rsb %3, %4, #0\n\t" |
||||
"smull %0, %2, %5, %6\n\t" |
||||
"smlal %0, %2, %3, %7" |
||||
: "=&r" (tmp), "=&r" (yt1), "=&r" (yt2), "=r" (x1) |
||||
: "3" (x1), "r" (x2), "r" (c1), "r" (c2) |
||||
: "cc" ); |
||||
*y1 = yt1 << (FRAC_SIZE-FRAC_BITS); |
||||
*y2 = yt2 << (FRAC_SIZE-FRAC_BITS); |
||||
} |
||||
|
||||
#else |
||||
|
||||
/* multiply with real shift */ |
||||
#define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS) |
||||
/* multiply with coef shift */ |
||||
#define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS) |
||||
/* multiply with fractional shift */ |
||||
#if defined(_WIN32_WCE) && defined(_ARM_) |
||||
/* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */ |
||||
static INLINE real_t MUL_F(real_t A, real_t B) |
||||
{ |
||||
return _MulHigh(A,B) << (32-FRAC_BITS); |
||||
} |
||||
#else |
||||
#ifdef __BFIN__ |
||||
#define _MulHigh(X,Y) ({ int __xxo; \ |
||||
asm ( \
|
||||
"a1 = %2.H * %1.L (IS,M);\n\t" \
|
||||
"a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\
|
||||
"a1 = a1 >>> 16;\n\t" \
|
||||
"%0 = (a0 += a1);\n\t" \
|
||||
: "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; }) |
||||
|
||||
#define MUL_F(X,Y) ({ int __xxo; \ |
||||
asm ( \
|
||||
"a1 = %2.H * %1.L (M);\n\t" \
|
||||
"a0 = %1.H * %2.H, a1+= %1.H * %2.L (M);\n\t" \
|
||||
"a1 = a1 >>> 16;\n\t" \
|
||||
"%0 = (a0 += a1);\n\t" \
|
||||
: "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; }) |
||||
#else |
||||
#define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1u << (FRAC_SIZE-1))) >> FRAC_SIZE) |
||||
#define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1u << (FRAC_BITS-1))) >> FRAC_BITS) |
||||
#endif |
||||
#endif |
||||
#define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) |
||||
#define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6) |
||||
#define MUL_SHIFT23(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (23-1))) >> 23) |
||||
|
||||
/* Complex multiplication */ |
||||
static INLINE void ComplexMult(real_t *y1, real_t *y2, |
||||
real_t x1, real_t x2, real_t c1, real_t c2) |
||||
{ |
||||
*y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2)) * FRAC_MUL; |
||||
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2)) * FRAC_MUL; |
||||
} |
||||
|
||||
#endif |
||||
|
||||
/* Saturated left shift */ |
||||
#define SAT_SHIFT_MASK(E) (~0u << (31u - (E))) |
||||
#define SAT_SHIFT(V,E,M) (((((V) >> ((E) + 1)) ^ (V)) & (M)) \ |
||||
? (((V) < 0) ? (int32_t)0x80000000 : 0x7FFFFFFF) \
|
||||
: ((int32_t)((uint32_t)(V) << (E)))) |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,433 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: hcr.c,v 1.26 2009/01/26 23:51:15 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "specrec.h" |
||||
#include "huffman.h" |
||||
|
||||
/* ISO/IEC 14496-3/Amd.1
|
||||
* 8.5.3.3: Huffman Codeword Reordering for AAC spectral data (HCR) |
||||
* |
||||
* HCR devides the spectral data in known fixed size segments, and |
||||
* sorts it by the importance of the data. The importance is firstly |
||||
* the (lower) position in the spectrum, and secondly the largest |
||||
* value in the used codebook. |
||||
* The most important data is written at the start of each segment |
||||
* (at known positions), the remaining data is interleaved inbetween, |
||||
* with the writing direction alternating. |
||||
* Data length is not increased. |
||||
*/ |
||||
|
||||
#ifdef ERROR_RESILIENCE |
||||
|
||||
/* 8.5.3.3.1 Pre-sorting */ |
||||
|
||||
#define NUM_CB 6 |
||||
#define NUM_CB_ER 22 |
||||
#define MAX_CB 32 |
||||
#define VCB11_FIRST 16 |
||||
#define VCB11_LAST 31 |
||||
|
||||
static const uint8_t PreSortCB_STD[NUM_CB] = |
||||
{ 11, 9, 7, 5, 3, 1}; |
||||
|
||||
static const uint8_t PreSortCB_ER[NUM_CB_ER] = |
||||
{ 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1}; |
||||
|
||||
/* 8.5.3.3.2 Derivation of segment width */ |
||||
|
||||
static const uint8_t maxCwLen[MAX_CB] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49, |
||||
0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41}; |
||||
|
||||
#define segmentWidth(cb) min(maxCwLen[cb], ics->length_of_longest_codeword) |
||||
|
||||
/* bit-twiddling helpers */ |
||||
static const uint8_t S[] = {1, 2, 4, 8, 16}; |
||||
static const uint32_t B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint8_t cb; |
||||
uint8_t decoded; |
||||
uint16_t sp_offset; |
||||
bits_t bits; |
||||
} codeword_t; |
||||
|
||||
static uint32_t reverse_word(uint32_t v) |
||||
{ |
||||
v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]); |
||||
v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]); |
||||
v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]); |
||||
v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); |
||||
v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); |
||||
return v; |
||||
} |
||||
|
||||
/* bits_t version */ |
||||
static void rewrev_bits(bits_t *bits) |
||||
{ |
||||
if (bits->len == 0) return; |
||||
if (bits->len <= 32) { |
||||
bits->bufb = 0; |
||||
bits->bufa = reverse_word(bits->bufa) >> (32 - bits->len); |
||||
} else { |
||||
/* last 32<>32 bit swap via rename */ |
||||
uint32_t lo = reverse_word(bits->bufb); |
||||
uint32_t hi = reverse_word(bits->bufa); |
||||
|
||||
if (bits->len == 64) { |
||||
bits->bufb = hi; |
||||
bits->bufa = lo; |
||||
} else { |
||||
/* shift off low bits (this is really only one 64 bit shift) */ |
||||
bits->bufb = hi >> (64 - bits->len); |
||||
bits->bufa = (lo >> (64 - bits->len)) | (hi << (bits->len - 32)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/* merge bits of a to b */ |
||||
/* precondition: a->len + b->len <= 64 */ |
||||
static void concat_bits(bits_t *b, bits_t *a) |
||||
{ |
||||
uint32_t bl, bh, al, ah; |
||||
|
||||
/* empty addend */ |
||||
if (a->len == 0) return; |
||||
|
||||
/* addend becomes result */ |
||||
if (b->len == 0) |
||||
{ |
||||
*b = *a; |
||||
return; |
||||
} |
||||
|
||||
al = a->bufa; |
||||
ah = a->bufb; |
||||
|
||||
if (b->len > 32) |
||||
{ |
||||
/* (b->len - 32) is 1..31 */ |
||||
/* maskoff superfluous high b bits */ |
||||
bl = b->bufa; |
||||
bh = b->bufb & ((1u << (b->len-32)) - 1); |
||||
/* left shift a b->len bits */ |
||||
ah = al << (b->len - 32); |
||||
al = 0; |
||||
} else if (b->len == 32) { |
||||
bl = b->bufa; |
||||
bh = 0; |
||||
ah = al; |
||||
al = 0; |
||||
} else { |
||||
/* b->len is 1..31, (32 - b->len) is 1..31 */ |
||||
bl = b->bufa & ((1u << (b->len)) - 1); |
||||
bh = 0; |
||||
ah = (ah << (b->len)) | (al >> (32 - b->len)); |
||||
al = al << b->len; |
||||
} |
||||
|
||||
/* merge */ |
||||
b->bufa = bl | al; |
||||
b->bufb = bh | ah; |
||||
|
||||
b->len += a->len; |
||||
} |
||||
|
||||
static uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB) |
||||
{ |
||||
/* only want spectral data CB's */ |
||||
if ((this_sec_CB > ZERO_HCB && this_sec_CB <= ESC_HCB) || (this_sec_CB >= VCB11_FIRST && this_sec_CB <= VCB11_LAST)) |
||||
{ |
||||
if (this_CB < ESC_HCB) |
||||
{ |
||||
/* normal codebook pairs */ |
||||
return ((this_sec_CB == this_CB) || (this_sec_CB == this_CB + 1)); |
||||
} else |
||||
{ |
||||
/* escape codebook */ |
||||
return (this_sec_CB == this_CB); |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
static void read_segment(bits_t *segment, uint8_t segwidth, bitfile *ld) |
||||
{ |
||||
segment->len = segwidth; |
||||
|
||||
if (segwidth > 32) |
||||
{ |
||||
segment->bufb = faad_getbits(ld, segwidth - 32); |
||||
segment->bufa = faad_getbits(ld, 32); |
||||
|
||||
} else { |
||||
segment->bufb = 0; |
||||
segment->bufa = faad_getbits(ld, segwidth); |
||||
} |
||||
} |
||||
|
||||
static void fill_in_codeword(codeword_t *codeword, uint16_t index, uint16_t sp, uint8_t cb) |
||||
{ |
||||
codeword[index].sp_offset = sp; |
||||
codeword[index].cb = cb; |
||||
codeword[index].decoded = 0; |
||||
codeword[index].bits.len = 0; |
||||
} |
||||
|
||||
uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, |
||||
bitfile *ld, int16_t *spectral_data) |
||||
{ |
||||
uint16_t PCWs_done; |
||||
uint16_t numberOfSegments, numberOfSets, numberOfCodewords; |
||||
|
||||
codeword_t codeword[512]; |
||||
bits_t segment[512]; |
||||
|
||||
uint16_t sp_offset[8]; |
||||
uint16_t g, i, sortloop, set, bitsread; |
||||
/*uint16_t bitsleft, codewordsleft*/; |
||||
uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB; |
||||
|
||||
const uint16_t nshort = hDecoder->frameLength/8; |
||||
const uint16_t sp_data_len = ics->length_of_reordered_spectral_data; |
||||
|
||||
const uint8_t *PreSortCb; |
||||
|
||||
/* no data (e.g. silence) */ |
||||
if (sp_data_len == 0) |
||||
return 0; |
||||
|
||||
/* since there is spectral data, at least one codeword has nonzero length */ |
||||
if (ics->length_of_longest_codeword == 0) |
||||
return 10; |
||||
|
||||
if (sp_data_len < ics->length_of_longest_codeword) |
||||
return 10; |
||||
|
||||
sp_offset[0] = 0; |
||||
for (g = 1; g < ics->num_window_groups; g++) |
||||
{ |
||||
sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1]; |
||||
} |
||||
|
||||
PCWs_done = 0; |
||||
numberOfSegments = 0; |
||||
numberOfCodewords = 0; |
||||
bitsread = 0; |
||||
|
||||
/* VCB11 code books in use */ |
||||
if (hDecoder->aacSectionDataResilienceFlag) |
||||
{ |
||||
PreSortCb = PreSortCB_ER; |
||||
last_CB = NUM_CB_ER; |
||||
} else |
||||
{ |
||||
PreSortCb = PreSortCB_STD; |
||||
last_CB = NUM_CB; |
||||
} |
||||
|
||||
/* step 1: decode PCW's (set 0), and stuff data in easier-to-use format */ |
||||
for (sortloop = 0; sortloop < last_CB; sortloop++) |
||||
{ |
||||
/* select codebook to process this pass */ |
||||
this_CB = PreSortCb[sortloop]; |
||||
|
||||
/* loop over sfbs */ |
||||
for (sfb = 0; sfb < ics->max_sfb; sfb++) |
||||
{ |
||||
/* loop over all in this sfb, 4 lines per loop */ |
||||
for (w_idx = 0; 4*w_idx < (min(ics->swb_offset[sfb+1], ics->swb_offset_max) - ics->swb_offset[sfb]); w_idx++) |
||||
{ |
||||
for(g = 0; g < ics->num_window_groups; g++) |
||||
{ |
||||
for (i = 0; i < ics->num_sec[g]; i++) |
||||
{ |
||||
/* check whether sfb used here is the one we want to process */ |
||||
if ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb)) |
||||
{ |
||||
/* check whether codebook used here is the one we want to process */ |
||||
this_sec_CB = ics->sect_cb[g][i]; |
||||
|
||||
if (is_good_cb(this_CB, this_sec_CB)) |
||||
{ |
||||
/* precalculate some stuff */ |
||||
uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb]; |
||||
uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN; |
||||
uint16_t group_cws_count = (4*ics->window_group_length[g])/inc; |
||||
uint8_t segwidth = segmentWidth(this_sec_CB); |
||||
uint16_t cws; |
||||
|
||||
/* read codewords until end of sfb or end of window group (shouldn't only 1 trigger?) */ |
||||
for (cws = 0; (cws < group_cws_count) && ((cws + w_idx*group_cws_count) < sect_sfb_size); cws++) |
||||
{ |
||||
uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc * (cws + w_idx*group_cws_count); |
||||
|
||||
/* read and decode PCW */ |
||||
if (!PCWs_done) |
||||
{ |
||||
/* read in normal segments */ |
||||
if (bitsread + segwidth <= sp_data_len) |
||||
{ |
||||
read_segment(&segment[numberOfSegments], segwidth, ld); |
||||
bitsread += segwidth; |
||||
|
||||
huffman_spectral_data_2(this_sec_CB, &segment[numberOfSegments], &spectral_data[sp]); |
||||
|
||||
/* keep leftover bits */ |
||||
rewrev_bits(&segment[numberOfSegments]); |
||||
|
||||
numberOfSegments++; |
||||
} else { // sp_data_len - bitsread < segwidth
|
||||
/* remaining stuff after last segment, we unfortunately couldn't read
|
||||
this in earlier because it might not fit in 64 bits. since we already |
||||
decoded (and removed) the PCW it is now should fit */ |
||||
if (bitsread < sp_data_len) |
||||
{ |
||||
const uint8_t additional_bits = (uint8_t)(sp_data_len - bitsread); |
||||
|
||||
read_segment(&segment[numberOfSegments], additional_bits, ld); |
||||
segment[numberOfSegments].len += segment[numberOfSegments-1].len; |
||||
if (segment[numberOfSegments].len > 64) |
||||
return 10; |
||||
rewrev_bits(&segment[numberOfSegments]); |
||||
|
||||
if (segment[numberOfSegments-1].len > 32) |
||||
{ |
||||
segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb + |
||||
showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len - 32); |
||||
segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + |
||||
showbits_hcr(&segment[numberOfSegments-1], 32); |
||||
} else { |
||||
segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + |
||||
showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len); |
||||
segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb; |
||||
} |
||||
segment[numberOfSegments-1].len += additional_bits; |
||||
} |
||||
bitsread = sp_data_len; |
||||
PCWs_done = 1; |
||||
|
||||
fill_in_codeword(codeword, 0, sp, this_sec_CB); |
||||
} |
||||
} else { |
||||
fill_in_codeword(codeword, numberOfCodewords - numberOfSegments, sp, this_sec_CB); |
||||
} |
||||
numberOfCodewords++; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (numberOfSegments == 0) |
||||
return 10; |
||||
|
||||
numberOfSets = numberOfCodewords / numberOfSegments; |
||||
|
||||
/* step 2: decode nonPCWs */ |
||||
for (set = 1; set <= numberOfSets; set++) |
||||
{ |
||||
uint16_t trial; |
||||
|
||||
for (trial = 0; trial < numberOfSegments; trial++) |
||||
{ |
||||
uint16_t codewordBase; |
||||
|
||||
for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++) |
||||
{ |
||||
const uint16_t segment_idx = (trial + codewordBase) % numberOfSegments; |
||||
const uint16_t codeword_idx = codewordBase + set*numberOfSegments - numberOfSegments; |
||||
|
||||
/* data up */ |
||||
if (codeword_idx >= numberOfCodewords - numberOfSegments) break; |
||||
|
||||
if (!codeword[codeword_idx].decoded && segment[segment_idx].len > 0) |
||||
{ |
||||
uint8_t tmplen = segment[segment_idx].len + codeword[codeword_idx].bits.len; |
||||
|
||||
if (tmplen > 64) |
||||
{ |
||||
// Drop bits that do not fit concatenation result.
|
||||
flushbits_hcr(&codeword[codeword_idx].bits, tmplen - 64); |
||||
} |
||||
|
||||
if (codeword[codeword_idx].bits.len != 0) |
||||
concat_bits(&segment[segment_idx], &codeword[codeword_idx].bits); |
||||
|
||||
tmplen = segment[segment_idx].len; |
||||
|
||||
if (huffman_spectral_data_2(codeword[codeword_idx].cb, &segment[segment_idx], |
||||
&spectral_data[codeword[codeword_idx].sp_offset]) >= 0) |
||||
{ |
||||
codeword[codeword_idx].decoded = 1; |
||||
} else |
||||
{ |
||||
codeword[codeword_idx].bits = segment[segment_idx]; |
||||
codeword[codeword_idx].bits.len = tmplen; |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
for (i = 0; i < numberOfSegments; i++) |
||||
rewrev_bits(&segment[i]); |
||||
} |
||||
|
||||
#if 0 // Seems to give false errors
|
||||
bitsleft = 0; |
||||
|
||||
for (i = 0; i < numberOfSegments && !bitsleft; i++) |
||||
bitsleft += segment[i].len; |
||||
|
||||
if (bitsleft) return 10; |
||||
|
||||
codewordsleft = 0; |
||||
|
||||
for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++) |
||||
if (!codeword[i].decoded) |
||||
codewordsleft++; |
||||
|
||||
if (codewordsleft) return 10; |
||||
#endif |
||||
|
||||
|
||||
return 0; |
||||
|
||||
} |
||||
#endif |
@ -0,0 +1,578 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: huffman.c,v 1.26 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#ifdef ANALYSIS |
||||
#include <stdio.h> |
||||
#endif |
||||
|
||||
#include "bits.h" |
||||
#include "huffman.h" |
||||
#include "codebook/hcb.h" |
||||
|
||||
|
||||
/* static function declarations */ |
||||
static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len); |
||||
static INLINE uint8_t huffman_getescape(bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
#if 0 |
||||
static int16_t huffman_codebook(uint8_t i); |
||||
#endif |
||||
static void vcb11_check_LAV(uint8_t cb, int16_t *sp); |
||||
|
||||
int8_t huffman_scale_factor(bitfile *ld) |
||||
{ |
||||
uint16_t offset = 0; |
||||
|
||||
while (hcb_sf[offset][1]) |
||||
{ |
||||
uint8_t b = faad_get1bit(ld |
||||
DEBUGVAR(1,255,"huffman_scale_factor()")); |
||||
offset += hcb_sf[offset][b]; |
||||
|
||||
if (offset > 240) |
||||
{ |
||||
/* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */ |
||||
return -1; |
||||
} |
||||
} |
||||
|
||||
return hcb_sf[offset][0]; |
||||
} |
||||
|
||||
|
||||
hcb *hcb_table[] = { |
||||
0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1 |
||||
}; |
||||
|
||||
hcb_2_quad *hcb_2_quad_table[] = { |
||||
0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0 |
||||
}; |
||||
|
||||
hcb_2_pair *hcb_2_pair_table[] = { |
||||
0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2 |
||||
}; |
||||
|
||||
hcb_bin_pair *hcb_bin_table[] = { |
||||
0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0 |
||||
}; |
||||
|
||||
uint8_t hcbN[] = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 }; |
||||
|
||||
/* defines whether a huffman codebook is unsigned or not */ |
||||
/* Table 4.6.2 */ |
||||
uint8_t unsigned_cb[] = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, |
||||
/* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 |
||||
}; |
||||
|
||||
int hcb_2_quad_table_size[] = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 }; |
||||
int hcb_2_pair_table_size[] = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 }; |
||||
int hcb_bin_table_size[] = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 }; |
||||
|
||||
static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len) |
||||
{ |
||||
uint8_t i; |
||||
|
||||
for (i = 0; i < len; i++) |
||||
{ |
||||
if(sp[i]) |
||||
{ |
||||
if(faad_get1bit(ld |
||||
DEBUGVAR(1,5,"huffman_sign_bits(): sign bit")) & 1) |
||||
{ |
||||
sp[i] = -sp[i]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static INLINE uint8_t huffman_getescape(bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint8_t neg, i; |
||||
int16_t j; |
||||
int16_t off; |
||||
int16_t x = *sp; |
||||
|
||||
if (x < 0) |
||||
{ |
||||
if (x != -16) |
||||
return 0; |
||||
neg = 1; |
||||
} else { |
||||
if (x != 16) |
||||
return 0; |
||||
neg = 0; |
||||
} |
||||
|
||||
for (i = 4; i < 16; i++) |
||||
{ |
||||
if (faad_get1bit(ld |
||||
DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0) |
||||
{ |
||||
break; |
||||
} |
||||
} |
||||
if (i >= 16) |
||||
return 10; |
||||
|
||||
off = (int16_t)faad_getbits(ld, i |
||||
DEBUGVAR(1,9,"huffman_getescape(): escape")); |
||||
|
||||
j = off | (1<<i); |
||||
if (neg) |
||||
j = -j; |
||||
|
||||
*sp = j; |
||||
return 0; |
||||
} |
||||
|
||||
static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint32_t cw; |
||||
uint16_t offset = 0; |
||||
uint8_t extra_bits; |
||||
|
||||
cw = faad_showbits(ld, hcbN[cb]); |
||||
offset = hcb_table[cb][cw].offset; |
||||
extra_bits = hcb_table[cb][cw].extra_bits; |
||||
|
||||
if (extra_bits) |
||||
{ |
||||
/* we know for sure it's more than hcbN[cb] bits long */ |
||||
faad_flushbits(ld, hcbN[cb]); |
||||
offset += (uint16_t)faad_showbits(ld, extra_bits); |
||||
faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]); |
||||
} else { |
||||
faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits); |
||||
} |
||||
|
||||
if (offset > hcb_2_quad_table_size[cb]) |
||||
{ |
||||
/* printf("ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset,
|
||||
hcb_2_quad_table_size[cb]); */ |
||||
return 10; |
||||
} |
||||
|
||||
sp[0] = hcb_2_quad_table[cb][offset].x; |
||||
sp[1] = hcb_2_quad_table[cb][offset].y; |
||||
sp[2] = hcb_2_quad_table[cb][offset].v; |
||||
sp[3] = hcb_2_quad_table[cb][offset].w; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint8_t err = huffman_2step_quad(cb, ld, sp); |
||||
huffman_sign_bits(ld, sp, QUAD_LEN); |
||||
|
||||
return err; |
||||
} |
||||
|
||||
static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint32_t cw; |
||||
uint16_t offset = 0; |
||||
uint8_t extra_bits; |
||||
|
||||
cw = faad_showbits(ld, hcbN[cb]); |
||||
offset = hcb_table[cb][cw].offset; |
||||
extra_bits = hcb_table[cb][cw].extra_bits; |
||||
|
||||
if (extra_bits) |
||||
{ |
||||
/* we know for sure it's more than hcbN[cb] bits long */ |
||||
faad_flushbits(ld, hcbN[cb]); |
||||
offset += (uint16_t)faad_showbits(ld, extra_bits); |
||||
faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]); |
||||
} else { |
||||
faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits); |
||||
} |
||||
|
||||
if (offset > hcb_2_pair_table_size[cb]) |
||||
{ |
||||
/* printf("ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset,
|
||||
hcb_2_pair_table_size[cb]); */ |
||||
return 10; |
||||
} |
||||
|
||||
sp[0] = hcb_2_pair_table[cb][offset].x; |
||||
sp[1] = hcb_2_pair_table[cb][offset].y; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint8_t err = huffman_2step_pair(cb, ld, sp); |
||||
huffman_sign_bits(ld, sp, PAIR_LEN); |
||||
|
||||
return err; |
||||
} |
||||
|
||||
static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint16_t offset = 0; |
||||
|
||||
while (!hcb3[offset].is_leaf) |
||||
{ |
||||
uint8_t b = faad_get1bit(ld |
||||
DEBUGVAR(1,255,"huffman_spectral_data():3")); |
||||
offset += hcb3[offset].data[b]; |
||||
} |
||||
|
||||
if (offset > hcb_bin_table_size[cb]) |
||||
{ |
||||
/* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
|
||||
hcb_bin_table_size[cb]); */ |
||||
return 10; |
||||
} |
||||
|
||||
sp[0] = hcb3[offset].data[0]; |
||||
sp[1] = hcb3[offset].data[1]; |
||||
sp[2] = hcb3[offset].data[2]; |
||||
sp[3] = hcb3[offset].data[3]; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint8_t err = huffman_binary_quad(cb, ld, sp); |
||||
huffman_sign_bits(ld, sp, QUAD_LEN); |
||||
|
||||
return err; |
||||
} |
||||
|
||||
static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint16_t offset = 0; |
||||
|
||||
while (!hcb_bin_table[cb][offset].is_leaf) |
||||
{ |
||||
uint8_t b = faad_get1bit(ld |
||||
DEBUGVAR(1,255,"huffman_spectral_data():9")); |
||||
offset += hcb_bin_table[cb][offset].data[b]; |
||||
} |
||||
|
||||
if (offset > hcb_bin_table_size[cb]) |
||||
{ |
||||
/* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
|
||||
hcb_bin_table_size[cb]); */ |
||||
return 10; |
||||
} |
||||
|
||||
sp[0] = hcb_bin_table[cb][offset].data[0]; |
||||
sp[1] = hcb_bin_table[cb][offset].data[1]; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
uint8_t err = huffman_binary_pair(cb, ld, sp); |
||||
huffman_sign_bits(ld, sp, PAIR_LEN); |
||||
|
||||
return err; |
||||
} |
||||
|
||||
#if 0 |
||||
static int16_t huffman_codebook(uint8_t i) |
||||
{ |
||||
static const uint32_t data = 16428320; |
||||
if (i == 0) return (int16_t)(data >> 16) & 0xFFFF; |
||||
else return (int16_t)data & 0xFFFF; |
||||
} |
||||
#endif |
||||
|
||||
static void vcb11_check_LAV(uint8_t cb, int16_t *sp) |
||||
{ |
||||
static const uint16_t vcb11_LAV_tab[] = { |
||||
16, 31, 47, 63, 95, 127, 159, 191, 223, |
||||
255, 319, 383, 511, 767, 1023, 2047 |
||||
}; |
||||
uint16_t max = 0; |
||||
|
||||
if (cb < 16 || cb > 31) |
||||
return; |
||||
|
||||
max = vcb11_LAV_tab[cb - 16]; |
||||
|
||||
if ((abs(sp[0]) > max) || (abs(sp[1]) > max)) |
||||
{ |
||||
sp[0] = 0; |
||||
sp[1] = 0; |
||||
} |
||||
} |
||||
|
||||
uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) |
||||
{ |
||||
switch (cb) |
||||
{ |
||||
case 1: /* 2-step method for data quadruples */ |
||||
case 2: |
||||
return huffman_2step_quad(cb, ld, sp); |
||||
case 3: /* binary search for data quadruples */ |
||||
return huffman_binary_quad_sign(cb, ld, sp); |
||||
case 4: /* 2-step method for data quadruples */ |
||||
return huffman_2step_quad_sign(cb, ld, sp); |
||||
case 5: /* binary search for data pairs */ |
||||
return huffman_binary_pair(cb, ld, sp); |
||||
case 6: /* 2-step method for data pairs */ |
||||
return huffman_2step_pair(cb, ld, sp); |
||||
case 7: /* binary search for data pairs */ |
||||
case 9: |
||||
return huffman_binary_pair_sign(cb, ld, sp); |
||||
case 8: /* 2-step method for data pairs */ |
||||
case 10: |
||||
return huffman_2step_pair_sign(cb, ld, sp); |
||||
/* Codebook 12 is disallowed, see `section_data` */ |
||||
#if 0 |
||||
case 12: { |
||||
uint8_t err = huffman_2step_pair(11, ld, sp); |
||||
sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1); |
||||
return err; } |
||||
#endif |
||||
case 11: |
||||
{ |
||||
uint8_t err = huffman_2step_pair_sign(11, ld, sp); |
||||
if (!err) |
||||
err = huffman_getescape(ld, &sp[0]); |
||||
if (!err) |
||||
err = huffman_getescape(ld, &sp[1]); |
||||
return err; |
||||
} |
||||
#ifdef ERROR_RESILIENCE |
||||
/* VCB11 uses codebook 11 */ |
||||
case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: |
||||
case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: |
||||
{ |
||||
uint8_t err = huffman_2step_pair_sign(11, ld, sp); |
||||
if (!err) |
||||
err = huffman_getescape(ld, &sp[0]); |
||||
if (!err) |
||||
err = huffman_getescape(ld, &sp[1]); |
||||
|
||||
/* check LAV (Largest Absolute Value) */ |
||||
/* this finds errors in the ESCAPE signal */ |
||||
vcb11_check_LAV(cb, sp); |
||||
|
||||
return err; |
||||
} |
||||
#endif |
||||
default: |
||||
/* Non existent codebook number, something went wrong */ |
||||
return 11; |
||||
} |
||||
|
||||
/* return 0; */ |
||||
} |
||||
|
||||
|
||||
#ifdef ERROR_RESILIENCE |
||||
|
||||
/* Special version of huffman_spectral_data
|
||||
Will not read from a bitfile but a bits_t structure. |
||||
Will keep track of the bits decoded and return the number of bits remaining. |
||||
Do not read more than ld->len, return -1 if codeword would be longer */ |
||||
|
||||
int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp) |
||||
{ |
||||
uint32_t cw; |
||||
uint16_t offset = 0; |
||||
uint8_t extra_bits; |
||||
uint8_t vcb11 = 0; |
||||
|
||||
|
||||
switch (cb) |
||||
{ |
||||
case 1: /* 2-step method for data quadruples */ |
||||
case 2: |
||||
case 4: |
||||
|
||||
cw = showbits_hcr(ld, hcbN[cb]); |
||||
offset = hcb_table[cb][cw].offset; |
||||
extra_bits = hcb_table[cb][cw].extra_bits; |
||||
|
||||
if (extra_bits) |
||||
{ |
||||
/* we know for sure it's more than hcbN[cb] bits long */ |
||||
if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; |
||||
offset += (uint16_t)showbits_hcr(ld, extra_bits); |
||||
if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1; |
||||
} else { |
||||
if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits) ) return -1; |
||||
} |
||||
|
||||
sp[0] = hcb_2_quad_table[cb][offset].x; |
||||
sp[1] = hcb_2_quad_table[cb][offset].y; |
||||
sp[2] = hcb_2_quad_table[cb][offset].v; |
||||
sp[3] = hcb_2_quad_table[cb][offset].w; |
||||
break; |
||||
|
||||
case 6: /* 2-step method for data pairs */ |
||||
case 8: |
||||
case 10: |
||||
case 11: |
||||
/* VCB11 uses codebook 11 */ |
||||
case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: |
||||
case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: |
||||
|
||||
if (cb >= 16) |
||||
{ |
||||
/* store the virtual codebook */ |
||||
vcb11 = cb; |
||||
cb = 11; |
||||
} |
||||
|
||||
cw = showbits_hcr(ld, hcbN[cb]); |
||||
offset = hcb_table[cb][cw].offset; |
||||
extra_bits = hcb_table[cb][cw].extra_bits; |
||||
|
||||
if (extra_bits) |
||||
{ |
||||
/* we know for sure it's more than hcbN[cb] bits long */ |
||||
if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; |
||||
offset += (uint16_t)showbits_hcr(ld, extra_bits); |
||||
if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1; |
||||
} else { |
||||
if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits) ) return -1; |
||||
} |
||||
sp[0] = hcb_2_pair_table[cb][offset].x; |
||||
sp[1] = hcb_2_pair_table[cb][offset].y; |
||||
break; |
||||
|
||||
case 3: /* binary search for data quadruples */ |
||||
|
||||
while (!hcb3[offset].is_leaf) |
||||
{ |
||||
uint8_t b; |
||||
|
||||
if ( get1bit_hcr(ld, &b) ) return -1; |
||||
offset += hcb3[offset].data[b]; |
||||
} |
||||
|
||||
sp[0] = hcb3[offset].data[0]; |
||||
sp[1] = hcb3[offset].data[1]; |
||||
sp[2] = hcb3[offset].data[2]; |
||||
sp[3] = hcb3[offset].data[3]; |
||||
|
||||
break; |
||||
|
||||
case 5: /* binary search for data pairs */ |
||||
case 7: |
||||
case 9: |
||||
|
||||
while (!hcb_bin_table[cb][offset].is_leaf) |
||||
{ |
||||
uint8_t b; |
||||
|
||||
if (get1bit_hcr(ld, &b) ) return -1; |
||||
offset += hcb_bin_table[cb][offset].data[b]; |
||||
} |
||||
|
||||
sp[0] = hcb_bin_table[cb][offset].data[0]; |
||||
sp[1] = hcb_bin_table[cb][offset].data[1]; |
||||
|
||||
break; |
||||
} |
||||
|
||||
/* decode sign bits */ |
||||
if (unsigned_cb[cb]) |
||||
{ |
||||
uint8_t i; |
||||
for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++) |
||||
{ |
||||
if(sp[i]) |
||||
{ |
||||
uint8_t b; |
||||
if ( get1bit_hcr(ld, &b) ) return -1; |
||||
if (b != 0) { |
||||
sp[i] = -sp[i]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* decode huffman escape bits */ |
||||
if ((cb == ESC_HCB) || (cb >= 16)) |
||||
{ |
||||
uint8_t k; |
||||
for (k = 0; k < 2; k++) |
||||
{ |
||||
if ((sp[k] == 16) || (sp[k] == -16)) |
||||
{ |
||||
uint8_t neg, i; |
||||
int32_t j; |
||||
uint32_t off; |
||||
|
||||
neg = (sp[k] < 0) ? 1 : 0; |
||||
|
||||
for (i = 4; ; i++) |
||||
{ |
||||
uint8_t b; |
||||
if (get1bit_hcr(ld, &b)) |
||||
return -1; |
||||
if (b == 0) |
||||
break; |
||||
} |
||||
|
||||
if (i > 32) |
||||
return -1; |
||||
|
||||
if (getbits_hcr(ld, i, &off)) |
||||
return -1; |
||||
j = off + (1<<i); |
||||
sp[k] = (int16_t)((neg) ? -j : j); |
||||
} |
||||
} |
||||
|
||||
if (vcb11 != 0) |
||||
{ |
||||
/* check LAV (Largest Absolute Value) */ |
||||
/* this finds errors in the ESCAPE signal */ |
||||
vcb11_check_LAV(vcb11, sp); |
||||
} |
||||
} |
||||
return ld->len; |
||||
} |
||||
|
||||
#endif |
||||
|
@ -0,0 +1,47 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: huffman.h,v 1.28 2007/11/01 12:33:30 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __HUFFMAN_H__ |
||||
#define __HUFFMAN_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
int8_t huffman_scale_factor(bitfile *ld); |
||||
uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp); |
||||
#ifdef ERROR_RESILIENCE |
||||
int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp); |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,281 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ic_predict.c,v 1.28 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#ifdef MAIN_DEC |
||||
|
||||
#include "syntax.h" |
||||
#include "ic_predict.h" |
||||
#include "pns.h" |
||||
|
||||
|
||||
static uint32_t float_to_bits(float32_t f32) { |
||||
uint32_t u32; |
||||
memcpy(&u32, &f32, 4); |
||||
return u32; |
||||
} |
||||
|
||||
static float32_t bits_to_float(uint32_t u32) { |
||||
float32_t f32; |
||||
memcpy(&f32, &u32, 4); |
||||
return f32; |
||||
} |
||||
|
||||
static float32_t flt_round(float32_t pf) |
||||
{ |
||||
int32_t flg; |
||||
uint32_t tmp, tmp1, tmp2; |
||||
|
||||
tmp = float_to_bits(pf); |
||||
flg = tmp & (uint32_t)0x00008000; |
||||
tmp &= (uint32_t)0xffff0000; |
||||
tmp1 = tmp; |
||||
/* round 1/2 lsb toward infinity */ |
||||
if (flg) |
||||
{ |
||||
tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ |
||||
tmp |= (uint32_t)0x00010000; /* insert 1 lsb */ |
||||
tmp2 = tmp; /* add 1 lsb and elided one */ |
||||
tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ |
||||
|
||||
return bits_to_float(tmp1) + bits_to_float(tmp2) - bits_to_float(tmp); |
||||
} else { |
||||
return bits_to_float(tmp); |
||||
} |
||||
} |
||||
|
||||
static int16_t quant_pred(float32_t x) |
||||
{ |
||||
return (int16_t)(float_to_bits(x) >> 16); |
||||
} |
||||
|
||||
static float32_t inv_quant_pred(int16_t q) |
||||
{ |
||||
uint16_t u16 = (uint16_t)q; |
||||
return bits_to_float((uint32_t)u16 << 16); |
||||
} |
||||
|
||||
static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t pred) |
||||
{ |
||||
#ifdef FIXED_POINT |
||||
// main codepath is simply not ready for FIXED_POINT, better not to run it at all.
|
||||
if (pred) |
||||
*output = input; |
||||
#else |
||||
uint16_t tmp; |
||||
int16_t i, j; |
||||
real_t dr1; |
||||
float32_t predictedvalue; |
||||
real_t e0, e1; |
||||
real_t k1, k2; |
||||
|
||||
real_t r[2]; |
||||
real_t COR[2]; |
||||
real_t VAR[2]; |
||||
|
||||
r[0] = inv_quant_pred(state->r[0]); |
||||
r[1] = inv_quant_pred(state->r[1]); |
||||
COR[0] = inv_quant_pred(state->COR[0]); |
||||
COR[1] = inv_quant_pred(state->COR[1]); |
||||
VAR[0] = inv_quant_pred(state->VAR[0]); |
||||
VAR[1] = inv_quant_pred(state->VAR[1]); |
||||
|
||||
|
||||
#if 1 |
||||
tmp = state->VAR[0]; |
||||
j = (tmp >> 7); |
||||
i = tmp & 0x7f; |
||||
if (j >= 128) |
||||
{ |
||||
j -= 128; |
||||
k1 = COR[0] * exp_table[j] * mnt_table[i]; |
||||
} else { |
||||
k1 = REAL_CONST(0); |
||||
} |
||||
#else |
||||
|
||||
{ |
||||
#define B 0.953125 |
||||
real_t c = COR[0]; |
||||
real_t v = VAR[0]; |
||||
float32_t tmp; |
||||
if (c == 0 || v <= 1) |
||||
{ |
||||
k1 = 0; |
||||
} else { |
||||
tmp = B / v; |
||||
flt_round(&tmp); |
||||
k1 = c * tmp; |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
if (pred) |
||||
{ |
||||
#if 1 |
||||
tmp = state->VAR[1]; |
||||
j = (tmp >> 7); |
||||
i = tmp & 0x7f; |
||||
if (j >= 128) |
||||
{ |
||||
j -= 128; |
||||
k2 = COR[1] * exp_table[j] * mnt_table[i]; |
||||
} else { |
||||
k2 = REAL_CONST(0); |
||||
} |
||||
#else |
||||
|
||||
#define B 0.953125 |
||||
real_t c = COR[1]; |
||||
real_t v = VAR[1]; |
||||
float32_t tmp; |
||||
if (c == 0 || v <= 1) |
||||
{ |
||||
k2 = 0; |
||||
} else { |
||||
tmp = B / v; |
||||
flt_round(&tmp); |
||||
k2 = c * tmp; |
||||
} |
||||
#endif |
||||
|
||||
predictedvalue = k1*r[0] + k2*r[1]; |
||||
predictedvalue = flt_round(predictedvalue); |
||||
*output = input + predictedvalue; |
||||
} |
||||
|
||||
/* calculate new state data */ |
||||
e0 = *output; |
||||
e1 = e0 - k1*r[0]; |
||||
dr1 = k1*e0; |
||||
|
||||
VAR[0] = ALPHA*VAR[0] + 0.5f * (r[0]*r[0] + e0*e0); |
||||
COR[0] = ALPHA*COR[0] + r[0]*e0; |
||||
VAR[1] = ALPHA*VAR[1] + 0.5f * (r[1]*r[1] + e1*e1); |
||||
COR[1] = ALPHA*COR[1] + r[1]*e1; |
||||
|
||||
r[1] = A * (r[0]-dr1); |
||||
r[0] = A * e0; |
||||
|
||||
state->r[0] = quant_pred(r[0]); |
||||
state->r[1] = quant_pred(r[1]); |
||||
state->COR[0] = quant_pred(COR[0]); |
||||
state->COR[1] = quant_pred(COR[1]); |
||||
state->VAR[0] = quant_pred(VAR[0]); |
||||
state->VAR[1] = quant_pred(VAR[1]); |
||||
#endif |
||||
} |
||||
|
||||
static void reset_pred_state(pred_state *state) |
||||
{ |
||||
state->r[0] = 0; |
||||
state->r[1] = 0; |
||||
state->COR[0] = 0; |
||||
state->COR[1] = 0; |
||||
state->VAR[0] = 0x3F80; |
||||
state->VAR[1] = 0x3F80; |
||||
} |
||||
|
||||
void pns_reset_pred_state(ic_stream *ics, pred_state *state) |
||||
{ |
||||
uint8_t sfb, g, b; |
||||
uint16_t i, offs, offs2; |
||||
|
||||
/* prediction only for long blocks */ |
||||
if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) |
||||
return; |
||||
|
||||
for (g = 0; g < ics->num_window_groups; g++) |
||||
{ |
||||
for (b = 0; b < ics->window_group_length[g]; b++) |
||||
{ |
||||
for (sfb = 0; sfb < ics->max_sfb; sfb++) |
||||
{ |
||||
if (is_noise(ics, g, sfb)) |
||||
{ |
||||
offs = ics->swb_offset[sfb]; |
||||
offs2 = min(ics->swb_offset[sfb+1], ics->swb_offset_max); |
||||
|
||||
for (i = offs; i < offs2; i++) |
||||
reset_pred_state(&state[i]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void reset_all_predictors(pred_state *state, uint16_t frame_len) |
||||
{ |
||||
uint16_t i; |
||||
|
||||
for (i = 0; i < frame_len; i++) |
||||
reset_pred_state(&state[i]); |
||||
} |
||||
|
||||
/* intra channel prediction */ |
||||
void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, |
||||
uint16_t frame_len, uint8_t sf_index) |
||||
{ |
||||
uint8_t sfb; |
||||
uint16_t bin; |
||||
|
||||
if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) |
||||
{ |
||||
reset_all_predictors(state, frame_len); |
||||
} else { |
||||
for (sfb = 0; sfb < max_pred_sfb(sf_index); sfb++) |
||||
{ |
||||
uint16_t low = ics->swb_offset[sfb]; |
||||
uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); |
||||
|
||||
for (bin = low; bin < high; bin++) |
||||
{ |
||||
ic_predict(&state[bin], spec[bin], &spec[bin], |
||||
(ics->predictor_data_present && ics->pred.prediction_used[sfb])); |
||||
} |
||||
} |
||||
|
||||
if (ics->predictor_data_present) |
||||
{ |
||||
if (ics->pred.predictor_reset) |
||||
{ |
||||
for (bin = ics->pred.predictor_reset_group_number - 1; |
||||
bin < frame_len; bin += 30) |
||||
{ |
||||
reset_pred_state(&state[bin]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,252 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ic_predict.h,v 1.23 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#ifdef MAIN_DEC |
||||
|
||||
#ifndef __IC_PREDICT_H__ |
||||
#define __IC_PREDICT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define ALPHA REAL_CONST(0.90625) |
||||
#define A REAL_CONST(0.953125) |
||||
|
||||
|
||||
void pns_reset_pred_state(ic_stream *ics, pred_state *state); |
||||
void reset_all_predictors(pred_state *state, uint16_t frame_len); |
||||
void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, |
||||
uint16_t frame_len, uint8_t sf_index); |
||||
|
||||
ALIGN static const real_t mnt_table[128] = { |
||||
COEF_CONST(0.9531250000), COEF_CONST(0.9453125000), |
||||
COEF_CONST(0.9375000000), COEF_CONST(0.9296875000), |
||||
COEF_CONST(0.9257812500), COEF_CONST(0.9179687500), |
||||
COEF_CONST(0.9101562500), COEF_CONST(0.9023437500), |
||||
COEF_CONST(0.8984375000), COEF_CONST(0.8906250000), |
||||
COEF_CONST(0.8828125000), COEF_CONST(0.8789062500), |
||||
COEF_CONST(0.8710937500), COEF_CONST(0.8671875000), |
||||
COEF_CONST(0.8593750000), COEF_CONST(0.8515625000), |
||||
COEF_CONST(0.8476562500), COEF_CONST(0.8398437500), |
||||
COEF_CONST(0.8359375000), COEF_CONST(0.8281250000), |
||||
COEF_CONST(0.8242187500), COEF_CONST(0.8203125000), |
||||
COEF_CONST(0.8125000000), COEF_CONST(0.8085937500), |
||||
COEF_CONST(0.8007812500), COEF_CONST(0.7968750000), |
||||
COEF_CONST(0.7929687500), COEF_CONST(0.7851562500), |
||||
COEF_CONST(0.7812500000), COEF_CONST(0.7773437500), |
||||
COEF_CONST(0.7734375000), COEF_CONST(0.7656250000), |
||||
COEF_CONST(0.7617187500), COEF_CONST(0.7578125000), |
||||
COEF_CONST(0.7539062500), COEF_CONST(0.7500000000), |
||||
COEF_CONST(0.7421875000), COEF_CONST(0.7382812500), |
||||
COEF_CONST(0.7343750000), COEF_CONST(0.7304687500), |
||||
COEF_CONST(0.7265625000), COEF_CONST(0.7226562500), |
||||
COEF_CONST(0.7187500000), COEF_CONST(0.7148437500), |
||||
COEF_CONST(0.7109375000), COEF_CONST(0.7070312500), |
||||
COEF_CONST(0.6992187500), COEF_CONST(0.6953125000), |
||||
COEF_CONST(0.6914062500), COEF_CONST(0.6875000000), |
||||
COEF_CONST(0.6835937500), COEF_CONST(0.6796875000), |
||||
COEF_CONST(0.6796875000), COEF_CONST(0.6757812500), |
||||
COEF_CONST(0.6718750000), COEF_CONST(0.6679687500), |
||||
COEF_CONST(0.6640625000), COEF_CONST(0.6601562500), |
||||
COEF_CONST(0.6562500000), COEF_CONST(0.6523437500), |
||||
COEF_CONST(0.6484375000), COEF_CONST(0.6445312500), |
||||
COEF_CONST(0.6406250000), COEF_CONST(0.6406250000), |
||||
COEF_CONST(0.6367187500), COEF_CONST(0.6328125000), |
||||
COEF_CONST(0.6289062500), COEF_CONST(0.6250000000), |
||||
COEF_CONST(0.6210937500), COEF_CONST(0.6210937500), |
||||
COEF_CONST(0.6171875000), COEF_CONST(0.6132812500), |
||||
COEF_CONST(0.6093750000), COEF_CONST(0.6054687500), |
||||
COEF_CONST(0.6054687500), COEF_CONST(0.6015625000), |
||||
COEF_CONST(0.5976562500), COEF_CONST(0.5937500000), |
||||
COEF_CONST(0.5937500000), COEF_CONST(0.5898437500), |
||||
COEF_CONST(0.5859375000), COEF_CONST(0.5820312500), |
||||
COEF_CONST(0.5820312500), COEF_CONST(0.5781250000), |
||||
COEF_CONST(0.5742187500), COEF_CONST(0.5742187500), |
||||
COEF_CONST(0.5703125000), COEF_CONST(0.5664062500), |
||||
COEF_CONST(0.5664062500), COEF_CONST(0.5625000000), |
||||
COEF_CONST(0.5585937500), COEF_CONST(0.5585937500), |
||||
COEF_CONST(0.5546875000), COEF_CONST(0.5507812500), |
||||
COEF_CONST(0.5507812500), COEF_CONST(0.5468750000), |
||||
COEF_CONST(0.5429687500), COEF_CONST(0.5429687500), |
||||
COEF_CONST(0.5390625000), COEF_CONST(0.5390625000), |
||||
COEF_CONST(0.5351562500), COEF_CONST(0.5312500000), |
||||
COEF_CONST(0.5312500000), COEF_CONST(0.5273437500), |
||||
COEF_CONST(0.5273437500), COEF_CONST(0.5234375000), |
||||
COEF_CONST(0.5195312500), COEF_CONST(0.5195312500), |
||||
COEF_CONST(0.5156250000), COEF_CONST(0.5156250000), |
||||
COEF_CONST(0.5117187500), COEF_CONST(0.5117187500), |
||||
COEF_CONST(0.5078125000), COEF_CONST(0.5078125000), |
||||
COEF_CONST(0.5039062500), COEF_CONST(0.5039062500), |
||||
COEF_CONST(0.5000000000), COEF_CONST(0.4980468750), |
||||
COEF_CONST(0.4960937500), COEF_CONST(0.4941406250), |
||||
COEF_CONST(0.4921875000), COEF_CONST(0.4902343750), |
||||
COEF_CONST(0.4882812500), COEF_CONST(0.4863281250), |
||||
COEF_CONST(0.4843750000), COEF_CONST(0.4824218750), |
||||
COEF_CONST(0.4804687500), COEF_CONST(0.4785156250) |
||||
}; |
||||
|
||||
ALIGN static const real_t exp_table[128] = { |
||||
COEF_CONST(0.50000000000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.25000000000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.12500000000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.06250000000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.03125000000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.01562500000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00781250000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00390625000000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00195312500000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00097656250000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00048828125000000000000000000000000000000000000000), |
||||
COEF_CONST(0.00024414062500000000000000000000000000000000000000), |
||||
COEF_CONST(0.00012207031250000000000000000000000000000000000000), |
||||
COEF_CONST(0.00006103515625000000000000000000000000000000000000), |
||||
COEF_CONST(0.00003051757812500000000000000000000000000000000000), |
||||
COEF_CONST(0.00001525878906250000000000000000000000000000000000), |
||||
COEF_CONST(0.00000762939453125000000000000000000000000000000000), |
||||
COEF_CONST(0.00000381469726562500000000000000000000000000000000), |
||||
COEF_CONST(0.00000190734863281250000000000000000000000000000000), |
||||
COEF_CONST(0.00000095367431640625000000000000000000000000000000), |
||||
COEF_CONST(0.00000047683715820312500000000000000000000000000000), |
||||
COEF_CONST(0.00000023841857910156250000000000000000000000000000), |
||||
COEF_CONST(0.00000011920928955078125000000000000000000000000000), |
||||
COEF_CONST(0.00000005960464477539062500000000000000000000000000), |
||||
COEF_CONST(0.00000002980232238769531300000000000000000000000000), |
||||
COEF_CONST(0.00000001490116119384765600000000000000000000000000), |
||||
COEF_CONST(0.00000000745058059692382810000000000000000000000000), |
||||
COEF_CONST(0.00000000372529029846191410000000000000000000000000), |
||||
COEF_CONST(0.00000000186264514923095700000000000000000000000000), |
||||
COEF_CONST(0.00000000093132257461547852000000000000000000000000), |
||||
COEF_CONST(0.00000000046566128730773926000000000000000000000000), |
||||
COEF_CONST(0.00000000023283064365386963000000000000000000000000), |
||||
COEF_CONST(0.00000000011641532182693481000000000000000000000000), |
||||
COEF_CONST(0.00000000005820766091346740700000000000000000000000), |
||||
COEF_CONST(0.00000000002910383045673370400000000000000000000000), |
||||
COEF_CONST(0.00000000001455191522836685200000000000000000000000), |
||||
COEF_CONST(0.00000000000727595761418342590000000000000000000000), |
||||
COEF_CONST(0.00000000000363797880709171300000000000000000000000), |
||||
COEF_CONST(0.00000000000181898940354585650000000000000000000000), |
||||
COEF_CONST(0.00000000000090949470177292824000000000000000000000), |
||||
COEF_CONST(0.00000000000045474735088646412000000000000000000000), |
||||
COEF_CONST(0.00000000000022737367544323206000000000000000000000), |
||||
COEF_CONST(0.00000000000011368683772161603000000000000000000000), |
||||
COEF_CONST(0.00000000000005684341886080801500000000000000000000), |
||||
COEF_CONST(0.00000000000002842170943040400700000000000000000000), |
||||
COEF_CONST(0.00000000000001421085471520200400000000000000000000), |
||||
COEF_CONST(0.00000000000000710542735760100190000000000000000000), |
||||
COEF_CONST(0.00000000000000355271367880050090000000000000000000), |
||||
COEF_CONST(0.00000000000000177635683940025050000000000000000000), |
||||
COEF_CONST(0.00000000000000088817841970012523000000000000000000), |
||||
COEF_CONST(0.00000000000000044408920985006262000000000000000000), |
||||
COEF_CONST(0.00000000000000022204460492503131000000000000000000), |
||||
COEF_CONST(0.00000000000000011102230246251565000000000000000000), |
||||
COEF_CONST(0.00000000000000005551115123125782700000000000000000), |
||||
COEF_CONST(0.00000000000000002775557561562891400000000000000000), |
||||
COEF_CONST(0.00000000000000001387778780781445700000000000000000), |
||||
COEF_CONST(0.00000000000000000693889390390722840000000000000000), |
||||
COEF_CONST(0.00000000000000000346944695195361420000000000000000), |
||||
COEF_CONST(0.00000000000000000173472347597680710000000000000000), |
||||
COEF_CONST(0.00000000000000000086736173798840355000000000000000), |
||||
COEF_CONST(0.00000000000000000043368086899420177000000000000000), |
||||
COEF_CONST(0.00000000000000000021684043449710089000000000000000), |
||||
COEF_CONST(0.00000000000000000010842021724855044000000000000000), |
||||
COEF_CONST(0.00000000000000000005421010862427522200000000000000), |
||||
COEF_CONST(0.00000000000000000002710505431213761100000000000000), |
||||
COEF_CONST(0.00000000000000000001355252715606880500000000000000), |
||||
COEF_CONST(0.00000000000000000000677626357803440270000000000000), |
||||
COEF_CONST(0.00000000000000000000338813178901720140000000000000), |
||||
COEF_CONST(0.00000000000000000000169406589450860070000000000000), |
||||
COEF_CONST(0.00000000000000000000084703294725430034000000000000), |
||||
COEF_CONST(0.00000000000000000000042351647362715017000000000000), |
||||
COEF_CONST(0.00000000000000000000021175823681357508000000000000), |
||||
COEF_CONST(0.00000000000000000000010587911840678754000000000000), |
||||
COEF_CONST(0.00000000000000000000005293955920339377100000000000), |
||||
COEF_CONST(0.00000000000000000000002646977960169688600000000000), |
||||
COEF_CONST(0.00000000000000000000001323488980084844300000000000), |
||||
COEF_CONST(0.00000000000000000000000661744490042422140000000000), |
||||
COEF_CONST(0.00000000000000000000000330872245021211070000000000), |
||||
COEF_CONST(0.00000000000000000000000165436122510605530000000000), |
||||
COEF_CONST(0.00000000000000000000000082718061255302767000000000), |
||||
COEF_CONST(0.00000000000000000000000041359030627651384000000000), |
||||
COEF_CONST(0.00000000000000000000000020679515313825692000000000), |
||||
COEF_CONST(0.00000000000000000000000010339757656912846000000000), |
||||
COEF_CONST(0.00000000000000000000000005169878828456423000000000), |
||||
COEF_CONST(0.00000000000000000000000002584939414228211500000000), |
||||
COEF_CONST(0.00000000000000000000000001292469707114105700000000), |
||||
COEF_CONST(0.00000000000000000000000000646234853557052870000000), |
||||
COEF_CONST(0.00000000000000000000000000323117426778526440000000), |
||||
COEF_CONST(0.00000000000000000000000000161558713389263220000000), |
||||
COEF_CONST(0.00000000000000000000000000080779356694631609000000), |
||||
COEF_CONST(0.00000000000000000000000000040389678347315804000000), |
||||
COEF_CONST(0.00000000000000000000000000020194839173657902000000), |
||||
COEF_CONST(0.00000000000000000000000000010097419586828951000000), |
||||
COEF_CONST(0.00000000000000000000000000005048709793414475600000), |
||||
COEF_CONST(0.00000000000000000000000000002524354896707237800000), |
||||
COEF_CONST(0.00000000000000000000000000001262177448353618900000), |
||||
COEF_CONST(0.00000000000000000000000000000631088724176809440000), |
||||
COEF_CONST(0.00000000000000000000000000000315544362088404720000), |
||||
COEF_CONST(0.00000000000000000000000000000157772181044202360000), |
||||
COEF_CONST(0.00000000000000000000000000000078886090522101181000), |
||||
COEF_CONST(0.00000000000000000000000000000039443045261050590000), |
||||
COEF_CONST(0.00000000000000000000000000000019721522630525295000), |
||||
COEF_CONST(0.00000000000000000000000000000009860761315262647600), |
||||
COEF_CONST(0.00000000000000000000000000000004930380657631323800), |
||||
COEF_CONST(0.00000000000000000000000000000002465190328815661900), |
||||
COEF_CONST(0.00000000000000000000000000000001232595164407830900), |
||||
COEF_CONST(0.00000000000000000000000000000000616297582203915470), |
||||
COEF_CONST(0.00000000000000000000000000000000308148791101957740), |
||||
COEF_CONST(0.00000000000000000000000000000000154074395550978870), |
||||
COEF_CONST(0.00000000000000000000000000000000077037197775489434), |
||||
COEF_CONST(0.00000000000000000000000000000000038518598887744717), |
||||
COEF_CONST(0.00000000000000000000000000000000019259299443872359), |
||||
COEF_CONST(0.00000000000000000000000000000000009629649721936179), |
||||
COEF_CONST(0.00000000000000000000000000000000004814824860968090), |
||||
COEF_CONST(0.00000000000000000000000000000000002407412430484045), |
||||
COEF_CONST(0.00000000000000000000000000000000001203706215242022), |
||||
COEF_CONST(0.00000000000000000000000000000000000601853107621011), |
||||
COEF_CONST(0.00000000000000000000000000000000000300926553810506), |
||||
COEF_CONST(0.00000000000000000000000000000000000150463276905253), |
||||
COEF_CONST(0.00000000000000000000000000000000000075231638452626), |
||||
COEF_CONST(0.00000000000000000000000000000000000037615819226313), |
||||
COEF_CONST(0.00000000000000000000000000000000000018807909613157), |
||||
COEF_CONST(0.00000000000000000000000000000000000009403954806578), |
||||
COEF_CONST(0.00000000000000000000000000000000000004701977403289), |
||||
COEF_CONST(0.00000000000000000000000000000000000002350988701645), |
||||
COEF_CONST(0.00000000000000000000000000000000000001175494350822), |
||||
COEF_CONST(0.0 /* 0000000000000000000000000000000000000587747175411 "floating point underflow" */), |
||||
COEF_CONST(0.0) |
||||
}; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,106 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: is.c,v 1.28 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include "syntax.h" |
||||
#include "is.h" |
||||
|
||||
#ifdef FIXED_POINT |
||||
static real_t pow05_table[] = { |
||||
COEF_CONST(1.0), /* 0.5^( 0/4) */ |
||||
COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */ |
||||
COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */ |
||||
COEF_CONST(0.59460355750136) /* 0.5^(+3/4) */ |
||||
}; |
||||
#endif |
||||
|
||||
void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, |
||||
uint16_t frame_len) |
||||
{ |
||||
uint8_t g, sfb, b; |
||||
uint16_t i; |
||||
real_t scale; |
||||
#ifdef FIXED_POINT |
||||
int32_t exp, frac; |
||||
#endif |
||||
|
||||
uint16_t nshort = frame_len/8; |
||||
uint8_t group = 0; |
||||
|
||||
for (g = 0; g < icsr->num_window_groups; g++) |
||||
{ |
||||
/* Do intensity stereo decoding */ |
||||
for (b = 0; b < icsr->window_group_length[g]; b++) |
||||
{ |
||||
for (sfb = 0; sfb < icsr->max_sfb; sfb++) |
||||
{ |
||||
if (is_intensity(icsr, g, sfb)) |
||||
{ |
||||
int16_t scale_factor = icsr->scale_factors[g][sfb]; |
||||
#ifdef MAIN_DEC |
||||
/* For scalefactor bands coded in intensity stereo the
|
||||
corresponding predictors in the right channel are |
||||
switched to "off". |
||||
*/ |
||||
ics->pred.prediction_used[sfb] = 0; |
||||
icsr->pred.prediction_used[sfb] = 0; |
||||
#endif |
||||
|
||||
#ifndef FIXED_POINT |
||||
scale_factor = min(max(scale_factor, -120), 120); |
||||
scale = (real_t)pow(0.5, (0.25*scale_factor)); |
||||
#else |
||||
scale_factor = min(max(scale_factor, -60), 60); |
||||
exp = scale_factor >> 2; /* exp is -15..15 */ |
||||
frac = scale_factor & 3; |
||||
scale = pow05_table[frac]; |
||||
exp += COEF_BITS - REAL_BITS; /* exp is -1..29 */ |
||||
if (exp < 0) |
||||
scale <<= -exp; |
||||
else |
||||
scale >>= exp; |
||||
#endif |
||||
|
||||
/* Scale from left to right channel,
|
||||
do not touch left channel */ |
||||
for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb+1], ics->swb_offset_max); i++) |
||||
{ |
||||
r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale); |
||||
if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) |
||||
r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i]; |
||||
} |
||||
} |
||||
} |
||||
group++; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: is.h,v 1.20 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __IS_H__ |
||||
#define __IS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "syntax.h" |
||||
|
||||
void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, |
||||
uint16_t frame_len); |
||||
|
||||
static INLINE int8_t is_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) |
||||
{ |
||||
switch (ics->sfb_cb[group][sfb]) |
||||
{ |
||||
case INTENSITY_HCB: |
||||
return 1; |
||||
case INTENSITY_HCB2: |
||||
return -1; |
||||
default: |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
static INLINE int8_t invert_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) |
||||
{ |
||||
if (ics->ms_mask_present == 1) |
||||
return (1-2*ics->ms_used[group][sfb]); |
||||
return 1; |
||||
} |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,215 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: lt_predict.c,v 1.27 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#ifdef LTP_DEC |
||||
|
||||
#include <stdlib.h> |
||||
#include "syntax.h" |
||||
#include "lt_predict.h" |
||||
#include "filtbank.h" |
||||
#include "tns.h" |
||||
|
||||
|
||||
/* static function declarations */ |
||||
static int16_t real_to_int16(real_t sig_in); |
||||
|
||||
|
||||
/* check if the object type is an object type that can have LTP */ |
||||
uint8_t is_ltp_ot(uint8_t object_type) |
||||
{ |
||||
#ifdef LTP_DEC |
||||
if ((object_type == LTP) |
||||
#ifdef ERROR_RESILIENCE |
||||
|| (object_type == ER_LTP) |
||||
#endif |
||||
#ifdef LD_DEC |
||||
|| (object_type == LD) |
||||
#endif |
||||
) |
||||
{ |
||||
return 1; |
||||
} |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
ALIGN static const real_t codebook[8] = |
||||
{ |
||||
REAL_CONST(0.570829), |
||||
REAL_CONST(0.696616), |
||||
REAL_CONST(0.813004), |
||||
REAL_CONST(0.911304), |
||||
REAL_CONST(0.984900), |
||||
REAL_CONST(1.067894), |
||||
REAL_CONST(1.194601), |
||||
REAL_CONST(1.369533) |
||||
}; |
||||
|
||||
void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, |
||||
int16_t *lt_pred_stat, fb_info *fb, uint8_t win_shape, |
||||
uint8_t win_shape_prev, uint8_t sr_index, |
||||
uint8_t object_type, uint16_t frame_len) |
||||
{ |
||||
uint8_t sfb; |
||||
uint16_t bin, i, num_samples; |
||||
ALIGN real_t x_est[2048]; |
||||
ALIGN real_t X_est[2048]; |
||||
|
||||
if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) |
||||
{ |
||||
if (ltp->data_present) |
||||
{ |
||||
num_samples = frame_len << 1; |
||||
|
||||
for(i = 0; i < num_samples; i++) |
||||
{ |
||||
/* The extra lookback M (N/2 for LD, 0 for LTP) is handled
|
||||
in the buffer updating */ |
||||
|
||||
#if 0 |
||||
x_est[i] = MUL_R_C(lt_pred_stat[num_samples + i - ltp->lag], |
||||
codebook[ltp->coef]); |
||||
#else |
||||
/* lt_pred_stat is a 16 bit int, multiplied with the fixed point real
|
||||
this gives a real for x_est |
||||
*/ |
||||
x_est[i] = (real_t)lt_pred_stat[num_samples + i - ltp->lag] * codebook[ltp->coef]; |
||||
#endif |
||||
} |
||||
|
||||
filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev, |
||||
x_est, X_est, object_type, frame_len); |
||||
|
||||
tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est, |
||||
frame_len); |
||||
|
||||
for (sfb = 0; sfb < ltp->last_band; sfb++) |
||||
{ |
||||
if (ltp->long_used[sfb]) |
||||
{ |
||||
uint16_t low = ics->swb_offset[sfb]; |
||||
uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); |
||||
|
||||
for (bin = low; bin < high; bin++) |
||||
{ |
||||
spec[bin] += X_est[bin]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#ifdef FIXED_POINT |
||||
static INLINE int16_t real_to_int16(real_t sig_in) |
||||
{ |
||||
if (sig_in >= 0) |
||||
{ |
||||
sig_in += (1 << (REAL_BITS-1)); |
||||
if (sig_in >= REAL_CONST(32768)) |
||||
return 32767; |
||||
} else { |
||||
sig_in += -(1 << (REAL_BITS-1)); |
||||
if (sig_in <= REAL_CONST(-32768)) |
||||
return -32768; |
||||
} |
||||
|
||||
return (int16_t)(sig_in >> REAL_BITS); |
||||
} |
||||
#else |
||||
static INLINE int16_t real_to_int16(real_t sig_in) |
||||
{ |
||||
if (sig_in >= 0) |
||||
{ |
||||
#ifndef HAS_LRINTF |
||||
sig_in += 0.5f; |
||||
#endif |
||||
if (sig_in >= 32768.0f) |
||||
return 32767; |
||||
} else { |
||||
#ifndef HAS_LRINTF |
||||
sig_in += -0.5f; |
||||
#endif |
||||
if (sig_in <= -32768.0f) |
||||
return -32768; |
||||
} |
||||
|
||||
return (int16_t)lrintf(sig_in); |
||||
} |
||||
#endif |
||||
|
||||
void lt_update_state(int16_t *lt_pred_stat, real_t *time, real_t *overlap, |
||||
uint16_t frame_len, uint8_t object_type) |
||||
{ |
||||
uint16_t i; |
||||
|
||||
/*
|
||||
* The reference point for index i and the content of the buffer |
||||
* lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the |
||||
* last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1) |
||||
* is always all zeros. The rest of lt_pred_stat (i<0) contains the previous |
||||
* fully reconstructed time domain samples, i.e., output of the decoder. |
||||
* |
||||
* These values are shifted up by N*2 to avoid (i<0) |
||||
* |
||||
* For the LD object type an extra 512 samples lookback is accomodated here. |
||||
*/ |
||||
#ifdef LD_DEC |
||||
if (object_type == LD) |
||||
{ |
||||
for (i = 0; i < frame_len; i++) |
||||
{ |
||||
lt_pred_stat[i] /* extra 512 */ = lt_pred_stat[i + frame_len]; |
||||
lt_pred_stat[frame_len + i] = lt_pred_stat[i + (frame_len * 2)]; |
||||
lt_pred_stat[(frame_len * 2) + i] = real_to_int16(time[i]); |
||||
lt_pred_stat[(frame_len * 3) + i] = real_to_int16(overlap[i]); |
||||
} |
||||
} else { |
||||
#endif |
||||
for (i = 0; i < frame_len; i++) |
||||
{ |
||||
lt_pred_stat[i] = lt_pred_stat[i + frame_len]; |
||||
lt_pred_stat[frame_len + i] = real_to_int16(time[i]); |
||||
lt_pred_stat[(frame_len * 2) + i] = real_to_int16(overlap[i]); |
||||
#if 0 /* set to zero once upon initialisation */
|
||||
lt_pred_stat[(frame_len * 3) + i] = 0; |
||||
#endif |
||||
} |
||||
#ifdef LD_DEC |
||||
} |
||||
#endif |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,66 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: lt_predict.h,v 1.20 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#ifdef LTP_DEC |
||||
|
||||
#ifndef __LT_PREDICT_H__ |
||||
#define __LT_PREDICT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "filtbank.h" |
||||
|
||||
uint8_t is_ltp_ot(uint8_t object_type); |
||||
|
||||
void lt_prediction(ic_stream *ics, |
||||
ltp_info *ltp, |
||||
real_t *spec, |
||||
int16_t *lt_pred_stat, |
||||
fb_info *fb, |
||||
uint8_t win_shape, |
||||
uint8_t win_shape_prev, |
||||
uint8_t sr_index, |
||||
uint8_t object_type, |
||||
uint16_t frame_len); |
||||
|
||||
void lt_update_state(int16_t *lt_pred_stat, |
||||
real_t *time, |
||||
real_t *overlap, |
||||
uint16_t frame_len, |
||||
uint8_t object_type); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,301 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: mdct.c,v 1.47 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
/*
|
||||
* Fast (I)MDCT Implementation using (I)FFT ((Inverse) Fast Fourier Transform) |
||||
* and consists of three steps: pre-(I)FFT complex multiplication, complex |
||||
* (I)FFT, post-(I)FFT complex multiplication, |
||||
* |
||||
* As described in: |
||||
* P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the |
||||
* Implementation of Filter Banks Based on 'Time Domain Aliasing |
||||
* Cancellation'," IEEE Proc. on ICASSP'91, 1991, pp. 2209-2212. |
||||
* |
||||
* |
||||
* As of April 6th 2002 completely rewritten. |
||||
* This (I)MDCT can now be used for any data size n, where n is divisible by 8. |
||||
* |
||||
*/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
#ifdef _WIN32_WCE |
||||
#define assert(x) |
||||
#else |
||||
#include <assert.h> |
||||
#endif |
||||
|
||||
#include "cfft.h" |
||||
#include "mdct.h" |
||||
#include "mdct_tab.h" |
||||
|
||||
|
||||
mdct_info *faad_mdct_init(uint16_t N) |
||||
{ |
||||
mdct_info *mdct = (mdct_info*)faad_malloc(sizeof(mdct_info)); |
||||
|
||||
assert(N % 8 == 0); |
||||
|
||||
mdct->N = N; |
||||
|
||||
/* NOTE: For "small framelengths" in FIXED_POINT the coefficients need to be
|
||||
* scaled by sqrt("(nearest power of 2) > N" / N) */ |
||||
|
||||
/* RE(mdct->sincos[k]) = scale*(real_t)(cos(2.0*M_PI*(k+1./8.) / (real_t)N));
|
||||
* IM(mdct->sincos[k]) = scale*(real_t)(sin(2.0*M_PI*(k+1./8.) / (real_t)N)); */ |
||||
/* scale is 1 for fixed point, sqrt(N) for floating point */ |
||||
switch (N) |
||||
{ |
||||
case 2048: mdct->sincos = (complex_t*)mdct_tab_2048; break; |
||||
case 256: mdct->sincos = (complex_t*)mdct_tab_256; break; |
||||
#ifdef LD_DEC |
||||
case 1024: mdct->sincos = (complex_t*)mdct_tab_1024; break; |
||||
#endif |
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
case 1920: mdct->sincos = (complex_t*)mdct_tab_1920; break; |
||||
case 240: mdct->sincos = (complex_t*)mdct_tab_240; break; |
||||
#ifdef LD_DEC |
||||
case 960: mdct->sincos = (complex_t*)mdct_tab_960; break; |
||||
#endif |
||||
#endif |
||||
#ifdef SSR_DEC |
||||
case 512: mdct->sincos = (complex_t*)mdct_tab_512; break; |
||||
case 64: mdct->sincos = (complex_t*)mdct_tab_64; break; |
||||
#endif |
||||
} |
||||
|
||||
/* initialise fft */ |
||||
mdct->cfft = cffti(N/4); |
||||
|
||||
#ifdef PROFILE |
||||
mdct->cycles = 0; |
||||
mdct->fft_cycles = 0; |
||||
#endif |
||||
|
||||
return mdct; |
||||
} |
||||
|
||||
void faad_mdct_end(mdct_info *mdct) |
||||
{ |
||||
if (mdct != NULL) |
||||
{ |
||||
#ifdef PROFILE |
||||
printf("MDCT[%.4d]: %I64d cycles\n", mdct->N, mdct->cycles); |
||||
printf("CFFT[%.4d]: %I64d cycles\n", mdct->N/4, mdct->fft_cycles); |
||||
#endif |
||||
|
||||
cfftu(mdct->cfft); |
||||
|
||||
faad_free(mdct); |
||||
} |
||||
} |
||||
|
||||
void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out) |
||||
{ |
||||
uint16_t k; |
||||
|
||||
complex_t x; |
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
#ifdef FIXED_POINT |
||||
real_t scale = 0, b_scale = 0; |
||||
#endif |
||||
#endif |
||||
ALIGN complex_t Z1[512]; |
||||
complex_t *sincos = mdct->sincos; |
||||
|
||||
uint16_t N = mdct->N; |
||||
uint16_t N2 = N >> 1; |
||||
uint16_t N4 = N >> 2; |
||||
uint16_t N8 = N >> 3; |
||||
|
||||
#ifdef PROFILE |
||||
int64_t count1, count2 = faad_get_ts(); |
||||
#endif |
||||
|
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
#ifdef FIXED_POINT |
||||
/* detect non-power of 2 */ |
||||
if (N & (N-1)) |
||||
{ |
||||
/* adjust scale for non-power of 2 MDCT */ |
||||
/* 2048/1920 */ |
||||
b_scale = 1; |
||||
scale = COEF_CONST(1.0666666666666667); |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
/* pre-IFFT complex multiplication */ |
||||
for (k = 0; k < N4; k++) |
||||
{ |
||||
ComplexMult(&IM(Z1[k]), &RE(Z1[k]), |
||||
X_in[2*k], X_in[N2 - 1 - 2*k], RE(sincos[k]), IM(sincos[k])); |
||||
} |
||||
|
||||
#ifdef PROFILE |
||||
count1 = faad_get_ts(); |
||||
#endif |
||||
|
||||
/* complex IFFT, any non-scaling FFT can be used here */ |
||||
cfftb(mdct->cfft, Z1); |
||||
|
||||
#ifdef PROFILE |
||||
count1 = faad_get_ts() - count1; |
||||
#endif |
||||
|
||||
/* post-IFFT complex multiplication */ |
||||
for (k = 0; k < N4; k++) |
||||
{ |
||||
RE(x) = RE(Z1[k]); |
||||
IM(x) = IM(Z1[k]); |
||||
ComplexMult(&IM(Z1[k]), &RE(Z1[k]), |
||||
IM(x), RE(x), RE(sincos[k]), IM(sincos[k])); |
||||
|
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
#ifdef FIXED_POINT |
||||
/* non-power of 2 MDCT scaling */ |
||||
if (b_scale) |
||||
{ |
||||
RE(Z1[k]) = MUL_C(RE(Z1[k]), scale); |
||||
IM(Z1[k]) = MUL_C(IM(Z1[k]), scale); |
||||
} |
||||
#endif |
||||
#endif |
||||
} |
||||
|
||||
/* reordering */ |
||||
for (k = 0; k < N8; k+=2) |
||||
{ |
||||
X_out[ 2*k] = IM(Z1[N8 + k]); |
||||
X_out[ 2 + 2*k] = IM(Z1[N8 + 1 + k]); |
||||
|
||||
X_out[ 1 + 2*k] = -RE(Z1[N8 - 1 - k]); |
||||
X_out[ 3 + 2*k] = -RE(Z1[N8 - 2 - k]); |
||||
|
||||
X_out[N4 + 2*k] = RE(Z1[ k]); |
||||
X_out[N4 + + 2 + 2*k] = RE(Z1[ 1 + k]); |
||||
|
||||
X_out[N4 + 1 + 2*k] = -IM(Z1[N4 - 1 - k]); |
||||
X_out[N4 + 3 + 2*k] = -IM(Z1[N4 - 2 - k]); |
||||
|
||||
X_out[N2 + 2*k] = RE(Z1[N8 + k]); |
||||
X_out[N2 + + 2 + 2*k] = RE(Z1[N8 + 1 + k]); |
||||
|
||||
X_out[N2 + 1 + 2*k] = -IM(Z1[N8 - 1 - k]); |
||||
X_out[N2 + 3 + 2*k] = -IM(Z1[N8 - 2 - k]); |
||||
|
||||
X_out[N2 + N4 + 2*k] = -IM(Z1[ k]); |
||||
X_out[N2 + N4 + 2 + 2*k] = -IM(Z1[ 1 + k]); |
||||
|
||||
X_out[N2 + N4 + 1 + 2*k] = RE(Z1[N4 - 1 - k]); |
||||
X_out[N2 + N4 + 3 + 2*k] = RE(Z1[N4 - 2 - k]); |
||||
} |
||||
|
||||
#ifdef PROFILE |
||||
count2 = faad_get_ts() - count2; |
||||
mdct->fft_cycles += count1; |
||||
mdct->cycles += (count2 - count1); |
||||
#endif |
||||
} |
||||
|
||||
#ifdef LTP_DEC |
||||
void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out) |
||||
{ |
||||
uint16_t k; |
||||
|
||||
complex_t x; |
||||
ALIGN complex_t Z1[512]; |
||||
complex_t *sincos = mdct->sincos; |
||||
|
||||
uint16_t N = mdct->N; |
||||
uint16_t N2 = N >> 1; |
||||
uint16_t N4 = N >> 2; |
||||
uint16_t N8 = N >> 3; |
||||
|
||||
#ifndef FIXED_POINT |
||||
real_t scale = REAL_CONST(N); |
||||
#else |
||||
real_t scale = REAL_CONST(4.0/N); |
||||
#endif |
||||
|
||||
#ifdef ALLOW_SMALL_FRAMELENGTH |
||||
#ifdef FIXED_POINT |
||||
/* detect non-power of 2 */ |
||||
if (N & (N-1)) |
||||
{ |
||||
/* adjust scale for non-power of 2 MDCT */ |
||||
/* *= sqrt(2048/1920) */ |
||||
scale = MUL_C(scale, COEF_CONST(1.0327955589886444)); |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
/* pre-FFT complex multiplication */ |
||||
for (k = 0; k < N8; k++) |
||||
{ |
||||
uint16_t n = k << 1; |
||||
RE(x) = X_in[N - N4 - 1 - n] + X_in[N - N4 + n]; |
||||
IM(x) = X_in[ N4 + n] - X_in[ N4 - 1 - n]; |
||||
|
||||
ComplexMult(&RE(Z1[k]), &IM(Z1[k]), |
||||
RE(x), IM(x), RE(sincos[k]), IM(sincos[k])); |
||||
|
||||
RE(Z1[k]) = MUL_R(RE(Z1[k]), scale); |
||||
IM(Z1[k]) = MUL_R(IM(Z1[k]), scale); |
||||
|
||||
RE(x) = X_in[N2 - 1 - n] - X_in[ n]; |
||||
IM(x) = X_in[N2 + n] + X_in[N - 1 - n]; |
||||
|
||||
ComplexMult(&RE(Z1[k + N8]), &IM(Z1[k + N8]), |
||||
RE(x), IM(x), RE(sincos[k + N8]), IM(sincos[k + N8])); |
||||
|
||||
RE(Z1[k + N8]) = MUL_R(RE(Z1[k + N8]), scale); |
||||
IM(Z1[k + N8]) = MUL_R(IM(Z1[k + N8]), scale); |
||||
} |
||||
|
||||
/* complex FFT, any non-scaling FFT can be used here */ |
||||
cfftf(mdct->cfft, Z1); |
||||
|
||||
/* post-FFT complex multiplication */ |
||||
for (k = 0; k < N4; k++) |
||||
{ |
||||
uint16_t n = k << 1; |
||||
ComplexMult(&RE(x), &IM(x), |
||||
RE(Z1[k]), IM(Z1[k]), RE(sincos[k]), IM(sincos[k])); |
||||
|
||||
X_out[ n] = -RE(x); |
||||
X_out[N2 - 1 - n] = IM(x); |
||||
X_out[N2 + n] = -IM(x); |
||||
X_out[N - 1 - n] = RE(x); |
||||
} |
||||
} |
||||
#endif |
@ -0,0 +1,48 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: mdct.h,v 1.30 2007/11/01 12:33:31 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __MDCT_H__ |
||||
#define __MDCT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
mdct_info *faad_mdct_init(uint16_t N); |
||||
void faad_mdct_end(mdct_info *mdct); |
||||
void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out); |
||||
void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,313 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: mp4.c,v 1.41 2016/11/11 11:25:58 knik Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "mp4.h" |
||||
#include "syntax.h" |
||||
|
||||
/* defines if an object type can be decoded by this library or not */ |
||||
static uint8_t ObjectTypesTable[32] = { |
||||
0, /* 0 NULL */ |
||||
#ifdef MAIN_DEC |
||||
1, /* 1 AAC Main */ |
||||
#else |
||||
0, /* 1 AAC Main */ |
||||
#endif |
||||
1, /* 2 AAC LC */ |
||||
#ifdef SSR_DEC |
||||
1, /* 3 AAC SSR */ |
||||
#else |
||||
0, /* 3 AAC SSR */ |
||||
#endif |
||||
#ifdef LTP_DEC |
||||
1, /* 4 AAC LTP */ |
||||
#else |
||||
0, /* 4 AAC LTP */ |
||||
#endif |
||||
#ifdef SBR_DEC |
||||
1, /* 5 SBR */ |
||||
#else |
||||
0, /* 5 SBR */ |
||||
#endif |
||||
0, /* 6 AAC Scalable */ |
||||
0, /* 7 TwinVQ */ |
||||
0, /* 8 CELP */ |
||||
0, /* 9 HVXC */ |
||||
0, /* 10 Reserved */ |
||||
0, /* 11 Reserved */ |
||||
0, /* 12 TTSI */ |
||||
0, /* 13 Main synthetic */ |
||||
0, /* 14 Wavetable synthesis */ |
||||
0, /* 15 General MIDI */ |
||||
0, /* 16 Algorithmic Synthesis and Audio FX */ |
||||
|
||||
/* MPEG-4 Version 2 */ |
||||
#ifdef ERROR_RESILIENCE |
||||
1, /* 17 ER AAC LC */ |
||||
0, /* 18 (Reserved) */ |
||||
#ifdef LTP_DEC |
||||
1, /* 19 ER AAC LTP */ |
||||
#else |
||||
0, /* 19 ER AAC LTP */ |
||||
#endif |
||||
0, /* 20 ER AAC scalable */ |
||||
0, /* 21 ER TwinVQ */ |
||||
0, /* 22 ER BSAC */ |
||||
#ifdef LD_DEC |
||||
1, /* 23 ER AAC LD */ |
||||
#else |
||||
0, /* 23 ER AAC LD */ |
||||
#endif |
||||
0, /* 24 ER CELP */ |
||||
0, /* 25 ER HVXC */ |
||||
0, /* 26 ER HILN */ |
||||
0, /* 27 ER Parametric */ |
||||
#else /* No ER defined */ |
||||
0, /* 17 ER AAC LC */ |
||||
0, /* 18 (Reserved) */ |
||||
0, /* 19 ER AAC LTP */ |
||||
0, /* 20 ER AAC scalable */ |
||||
0, /* 21 ER TwinVQ */ |
||||
0, /* 22 ER BSAC */ |
||||
0, /* 23 ER AAC LD */ |
||||
0, /* 24 ER CELP */ |
||||
0, /* 25 ER HVXC */ |
||||
0, /* 26 ER HILN */ |
||||
0, /* 27 ER Parametric */ |
||||
#endif |
||||
0, /* 28 (Reserved) */ |
||||
#ifdef PS_DEC |
||||
1, /* 29 AAC LC + SBR + PS */ |
||||
#else |
||||
0, /* 29 AAC LC + SBR + PS */ |
||||
#endif |
||||
0, /* 30 (Reserved) */ |
||||
0 /* 31 (Reserved) */ |
||||
}; |
||||
|
||||
/* Table 1.6.1 */ |
||||
char NeAACDecAudioSpecificConfig(unsigned char *pBuffer, |
||||
unsigned long buffer_size, |
||||
mp4AudioSpecificConfig *mp4ASC) |
||||
{ |
||||
return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL, 0); |
||||
} |
||||
|
||||
int8_t AudioSpecificConfigFromBitfile(bitfile *ld, |
||||
mp4AudioSpecificConfig *mp4ASC, |
||||
program_config *pce, uint32_t buffer_size, uint8_t short_form) |
||||
{ |
||||
int8_t result = 0; |
||||
uint32_t startpos = faad_get_processed_bits(ld); |
||||
#ifdef SBR_DEC |
||||
int8_t bits_to_decode = 0; |
||||
#endif |
||||
|
||||
if (mp4ASC == NULL) |
||||
return -8; |
||||
|
||||
memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig)); |
||||
|
||||
mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5 |
||||
DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); |
||||
|
||||
mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(ld, 4 |
||||
DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex")); |
||||
if(mp4ASC->samplingFrequencyIndex==0x0f) |
||||
faad_getbits(ld, 24); |
||||
|
||||
mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(ld, 4 |
||||
DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration")); |
||||
|
||||
mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); |
||||
|
||||
if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1) |
||||
{ |
||||
return -1; |
||||
} |
||||
|
||||
if (mp4ASC->samplingFrequency == 0) |
||||
{ |
||||
return -2; |
||||
} |
||||
|
||||
if (mp4ASC->channelsConfiguration > 7) |
||||
{ |
||||
return -3; |
||||
} |
||||
|
||||
#if (defined(PS_DEC) || defined(DRM_PS)) |
||||
/* check if we have a mono file */ |
||||
if (mp4ASC->channelsConfiguration == 1) |
||||
{ |
||||
/* upMatrix to 2 channels for implicit signalling of PS */ |
||||
mp4ASC->channelsConfiguration = 2; |
||||
} |
||||
#endif |
||||
|
||||
#ifdef SBR_DEC |
||||
mp4ASC->sbr_present_flag = -1; |
||||
if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29) |
||||
{ |
||||
uint8_t tmp; |
||||
|
||||
mp4ASC->sbr_present_flag = 1; |
||||
tmp = (uint8_t)faad_getbits(ld, 4 |
||||
DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); |
||||
/* check for downsampled SBR */ |
||||
if (tmp == mp4ASC->samplingFrequencyIndex) |
||||
mp4ASC->downSampledSBR = 1; |
||||
mp4ASC->samplingFrequencyIndex = tmp; |
||||
if (mp4ASC->samplingFrequencyIndex == 15) |
||||
{ |
||||
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24 |
||||
DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); |
||||
} else { |
||||
mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); |
||||
} |
||||
mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5 |
||||
DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); |
||||
} |
||||
#endif |
||||
|
||||
/* get GASpecificConfig */ |
||||
if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 || |
||||
mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 || |
||||
mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7) |
||||
{ |
||||
result = GASpecificConfig(ld, mp4ASC, pce); |
||||
|
||||
#ifdef ERROR_RESILIENCE |
||||
} else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */ |
||||
result = GASpecificConfig(ld, mp4ASC, pce); |
||||
mp4ASC->epConfig = (uint8_t)faad_getbits(ld, 2 |
||||
DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig")); |
||||
|
||||
if (mp4ASC->epConfig != 0) |
||||
result = -5; |
||||
#endif |
||||
|
||||
} else { |
||||
result = -4; |
||||
} |
||||
|
||||
#ifdef SSR_DEC |
||||
/* shorter frames not allowed for SSR */ |
||||
if ((mp4ASC->objectTypeIndex == 4) && mp4ASC->frameLengthFlag) |
||||
return -6; |
||||
#endif |
||||
|
||||
|
||||
#ifdef SBR_DEC |
||||
if(short_form) |
||||
bits_to_decode = 0; |
||||
else |
||||
bits_to_decode = (int8_t)(buffer_size*8 + faad_get_processed_bits(ld) - startpos); |
||||
|
||||
if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16)) |
||||
{ |
||||
int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11 |
||||
DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType")); |
||||
|
||||
if (syncExtensionType == 0x2b7) |
||||
{ |
||||
uint8_t tmp_OTi = (uint8_t)faad_getbits(ld, 5 |
||||
DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType")); |
||||
|
||||
if (tmp_OTi == 5) |
||||
{ |
||||
mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag")); |
||||
|
||||
if (mp4ASC->sbr_present_flag) |
||||
{ |
||||
uint8_t tmp; |
||||
|
||||
/* Don't set OT to SBR until checked that it is actually there */ |
||||
mp4ASC->objectTypeIndex = tmp_OTi; |
||||
|
||||
tmp = (uint8_t)faad_getbits(ld, 4 |
||||
DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); |
||||
|
||||
/* check for downsampled SBR */ |
||||
if (tmp == mp4ASC->samplingFrequencyIndex) |
||||
mp4ASC->downSampledSBR = 1; |
||||
mp4ASC->samplingFrequencyIndex = tmp; |
||||
|
||||
if (mp4ASC->samplingFrequencyIndex == 15) |
||||
{ |
||||
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(ld, 24 |
||||
DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); |
||||
} else { |
||||
mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* no SBR signalled, this could mean either implicit signalling or no SBR in this file */ |
||||
/* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */ |
||||
if (mp4ASC->sbr_present_flag == (char)-1) /* cannot be -1 on systems with unsigned char */ |
||||
{ |
||||
if (mp4ASC->samplingFrequency <= 24000) |
||||
{ |
||||
mp4ASC->samplingFrequency *= 2; |
||||
mp4ASC->forceUpSampling = 1; |
||||
} else /* > 24000*/ { |
||||
mp4ASC->downSampledSBR = 1; |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
faad_endbits(ld); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
int8_t AudioSpecificConfig2(uint8_t *pBuffer, |
||||
uint32_t buffer_size, |
||||
mp4AudioSpecificConfig *mp4ASC, |
||||
program_config *pce, |
||||
uint8_t short_form) |
||||
{ |
||||
uint8_t ret = 0; |
||||
bitfile ld; |
||||
faad_initbits(&ld, pBuffer, buffer_size); |
||||
if (ld.error != 0) |
||||
return -7; |
||||
ret = AudioSpecificConfigFromBitfile(&ld, mp4ASC, pce, buffer_size, short_form); |
||||
faad_endbits(&ld); |
||||
return ret; |
||||
} |
@ -0,0 +1,53 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: mp4.h,v 1.28 2009/02/05 00:51:03 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __MP4_H__ |
||||
#define __MP4_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "bits.h" |
||||
#include "neaacdec.h" |
||||
|
||||
int8_t AudioSpecificConfig2(uint8_t *pBuffer, |
||||
uint32_t buffer_size, |
||||
mp4AudioSpecificConfig *mp4ASC, |
||||
program_config *pce, uint8_t short_form); |
||||
|
||||
int8_t AudioSpecificConfigFromBitfile(bitfile *ld, |
||||
mp4AudioSpecificConfig *mp4ASC, |
||||
program_config *pce, uint32_t bsize, uint8_t short_form); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,77 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ms.c,v 1.21 2007/11/01 12:33:32 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include "syntax.h" |
||||
#include "ms.h" |
||||
#include "is.h" |
||||
#include "pns.h" |
||||
|
||||
void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, |
||||
uint16_t frame_len) |
||||
{ |
||||
uint8_t g, b, sfb; |
||||
uint8_t group = 0; |
||||
uint16_t nshort = frame_len/8; |
||||
|
||||
uint16_t i, k; |
||||
real_t tmp; |
||||
|
||||
if (ics->ms_mask_present >= 1) |
||||
{ |
||||
for (g = 0; g < ics->num_window_groups; g++) |
||||
{ |
||||
for (b = 0; b < ics->window_group_length[g]; b++) |
||||
{ |
||||
for (sfb = 0; sfb < ics->max_sfb; sfb++) |
||||
{ |
||||
/* If intensity stereo coding or noise substitution is on
|
||||
for a particular scalefactor band, no M/S stereo decoding |
||||
is carried out. |
||||
*/ |
||||
if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && |
||||
!is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) |
||||
{ |
||||
for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb+1], ics->swb_offset_max); i++) |
||||
{ |
||||
k = (group*nshort) + i; |
||||
tmp = l_spec[k] - r_spec[k]; |
||||
l_spec[k] = l_spec[k] + r_spec[k]; |
||||
r_spec[k] = tmp; |
||||
} |
||||
} |
||||
} |
||||
group++; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ms.h,v 1.19 2007/11/01 12:33:32 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __MS_H__ |
||||
#define __MS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, |
||||
uint16_t frame_len); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,563 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: output.c,v 1.47 2009/01/26 23:51:15 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include "output.h" |
||||
|
||||
#ifndef FIXED_POINT |
||||
|
||||
|
||||
#define FLOAT_SCALE (1.0f/(1<<15)) |
||||
|
||||
#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
|
||||
#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)
|
||||
|
||||
|
||||
static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, |
||||
uint8_t down_matrix, uint8_t *internal_channel) |
||||
{ |
||||
if (!down_matrix) |
||||
return input[internal_channel[channel]][sample]; |
||||
|
||||
if (channel == 0) |
||||
{ |
||||
return DM_MUL * (input[internal_channel[1]][sample] + |
||||
input[internal_channel[0]][sample] * RSQRT2 + |
||||
input[internal_channel[3]][sample] * RSQRT2); |
||||
} else { |
||||
return DM_MUL * (input[internal_channel[2]][sample] + |
||||
input[internal_channel[0]][sample] * RSQRT2 + |
||||
input[internal_channel[4]][sample] * RSQRT2); |
||||
} |
||||
} |
||||
|
||||
#ifndef HAS_LRINTF |
||||
#define CLIP(sample, max, min) \ |
||||
if (sample >= 0.0f) \
|
||||
{ \
|
||||
sample += 0.5f; \
|
||||
if (sample >= max) \
|
||||
sample = max; \
|
||||
} else { \
|
||||
sample += -0.5f; \
|
||||
if (sample <= min) \
|
||||
sample = min; \
|
||||
} |
||||
#else |
||||
#define CLIP(sample, max, min) \ |
||||
if (sample >= 0.0f) \
|
||||
{ \
|
||||
if (sample >= max) \
|
||||
sample = max; \
|
||||
} else { \
|
||||
if (sample <= min) \
|
||||
sample = min; \
|
||||
} |
||||
#endif |
||||
|
||||
#define CONV(a,b) ((a<<1)|(b&0x1)) |
||||
|
||||
static void to_PCM_16bit(NeAACDecStruct *hDecoder, real_t **input, |
||||
uint8_t channels, uint16_t frame_len, |
||||
int16_t **sample_buffer) |
||||
{ |
||||
uint8_t ch, ch1; |
||||
uint16_t i; |
||||
|
||||
switch (CONV(channels,hDecoder->downMatrix)) |
||||
{ |
||||
case CONV(1,0): |
||||
case CONV(1,1): |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = input[hDecoder->internal_channel[0]][i]; |
||||
|
||||
CLIP(inp, 32767.0f, -32768.0f); |
||||
|
||||
(*sample_buffer)[i] = (int16_t)lrintf(inp); |
||||
} |
||||
break; |
||||
case CONV(2,0): |
||||
if (hDecoder->upMatrix) |
||||
{ |
||||
ch = hDecoder->internal_channel[0]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch][i]; |
||||
|
||||
CLIP(inp0, 32767.0f, -32768.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp0); |
||||
} |
||||
} else { |
||||
ch = hDecoder->internal_channel[0]; |
||||
ch1 = hDecoder->internal_channel[1]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch ][i]; |
||||
real_t inp1 = input[ch1][i]; |
||||
|
||||
CLIP(inp0, 32767.0f, -32768.0f); |
||||
CLIP(inp1, 32767.0f, -32768.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); |
||||
|
||||
CLIP(inp, 32767.0f, -32768.0f); |
||||
|
||||
(*sample_buffer)[(i*channels)+ch] = (int16_t)lrintf(inp); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
static void to_PCM_24bit(NeAACDecStruct *hDecoder, real_t **input, |
||||
uint8_t channels, uint16_t frame_len, |
||||
int32_t **sample_buffer) |
||||
{ |
||||
uint8_t ch, ch1; |
||||
uint16_t i; |
||||
|
||||
switch (CONV(channels,hDecoder->downMatrix)) |
||||
{ |
||||
case CONV(1,0): |
||||
case CONV(1,1): |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = input[hDecoder->internal_channel[0]][i]; |
||||
|
||||
inp *= 256.0f; |
||||
CLIP(inp, 8388607.0f, -8388608.0f); |
||||
|
||||
(*sample_buffer)[i] = (int32_t)lrintf(inp); |
||||
} |
||||
break; |
||||
case CONV(2,0): |
||||
if (hDecoder->upMatrix) |
||||
{ |
||||
ch = hDecoder->internal_channel[0]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch][i]; |
||||
|
||||
inp0 *= 256.0f; |
||||
CLIP(inp0, 8388607.0f, -8388608.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); |
||||
} |
||||
} else { |
||||
ch = hDecoder->internal_channel[0]; |
||||
ch1 = hDecoder->internal_channel[1]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch ][i]; |
||||
real_t inp1 = input[ch1][i]; |
||||
|
||||
inp0 *= 256.0f; |
||||
inp1 *= 256.0f; |
||||
CLIP(inp0, 8388607.0f, -8388608.0f); |
||||
CLIP(inp1, 8388607.0f, -8388608.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); |
||||
|
||||
inp *= 256.0f; |
||||
CLIP(inp, 8388607.0f, -8388608.0f); |
||||
|
||||
(*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
static void to_PCM_32bit(NeAACDecStruct *hDecoder, real_t **input, |
||||
uint8_t channels, uint16_t frame_len, |
||||
int32_t **sample_buffer) |
||||
{ |
||||
uint8_t ch, ch1; |
||||
uint16_t i; |
||||
|
||||
switch (CONV(channels,hDecoder->downMatrix)) |
||||
{ |
||||
case CONV(1,0): |
||||
case CONV(1,1): |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = input[hDecoder->internal_channel[0]][i]; |
||||
|
||||
inp *= 65536.0f; |
||||
CLIP(inp, 2147483647.0f, -2147483648.0f); |
||||
|
||||
(*sample_buffer)[i] = (int32_t)lrintf(inp); |
||||
} |
||||
break; |
||||
case CONV(2,0): |
||||
if (hDecoder->upMatrix) |
||||
{ |
||||
ch = hDecoder->internal_channel[0]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch][i]; |
||||
|
||||
inp0 *= 65536.0f; |
||||
CLIP(inp0, 2147483647.0f, -2147483648.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); |
||||
} |
||||
} else { |
||||
ch = hDecoder->internal_channel[0]; |
||||
ch1 = hDecoder->internal_channel[1]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch ][i]; |
||||
real_t inp1 = input[ch1][i]; |
||||
|
||||
inp0 *= 65536.0f; |
||||
inp1 *= 65536.0f; |
||||
CLIP(inp0, 2147483647.0f, -2147483648.0f); |
||||
CLIP(inp1, 2147483647.0f, -2147483648.0f); |
||||
|
||||
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); |
||||
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); |
||||
|
||||
inp *= 65536.0f; |
||||
CLIP(inp, 2147483647.0f, -2147483648.0f); |
||||
|
||||
(*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
static void to_PCM_float(NeAACDecStruct *hDecoder, real_t **input, |
||||
uint8_t channels, uint16_t frame_len, |
||||
float32_t **sample_buffer) |
||||
{ |
||||
uint8_t ch, ch1; |
||||
uint16_t i; |
||||
|
||||
switch (CONV(channels,hDecoder->downMatrix)) |
||||
{ |
||||
case CONV(1,0): |
||||
case CONV(1,1): |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = input[hDecoder->internal_channel[0]][i]; |
||||
(*sample_buffer)[i] = inp*FLOAT_SCALE; |
||||
} |
||||
break; |
||||
case CONV(2,0): |
||||
if (hDecoder->upMatrix) |
||||
{ |
||||
ch = hDecoder->internal_channel[0]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch][i]; |
||||
(*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; |
||||
(*sample_buffer)[(i*2)+1] = inp0*FLOAT_SCALE; |
||||
} |
||||
} else { |
||||
ch = hDecoder->internal_channel[0]; |
||||
ch1 = hDecoder->internal_channel[1]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch ][i]; |
||||
real_t inp1 = input[ch1][i]; |
||||
(*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; |
||||
(*sample_buffer)[(i*2)+1] = inp1*FLOAT_SCALE; |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); |
||||
(*sample_buffer)[(i*channels)+ch] = inp*FLOAT_SCALE; |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
static void to_PCM_double(NeAACDecStruct *hDecoder, real_t **input, |
||||
uint8_t channels, uint16_t frame_len, |
||||
double **sample_buffer) |
||||
{ |
||||
uint8_t ch, ch1; |
||||
uint16_t i; |
||||
|
||||
switch (CONV(channels,hDecoder->downMatrix)) |
||||
{ |
||||
case CONV(1,0): |
||||
case CONV(1,1): |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = input[hDecoder->internal_channel[0]][i]; |
||||
(*sample_buffer)[i] = (double)inp*FLOAT_SCALE; |
||||
} |
||||
break; |
||||
case CONV(2,0): |
||||
if (hDecoder->upMatrix) |
||||
{ |
||||
ch = hDecoder->internal_channel[0]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch][i]; |
||||
(*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; |
||||
(*sample_buffer)[(i*2)+1] = (double)inp0*FLOAT_SCALE; |
||||
} |
||||
} else { |
||||
ch = hDecoder->internal_channel[0]; |
||||
ch1 = hDecoder->internal_channel[1]; |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp0 = input[ch ][i]; |
||||
real_t inp1 = input[ch1][i]; |
||||
(*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; |
||||
(*sample_buffer)[(i*2)+1] = (double)inp1*FLOAT_SCALE; |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); |
||||
(*sample_buffer)[(i*channels)+ch] = (double)inp*FLOAT_SCALE; |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
void *output_to_PCM(NeAACDecStruct *hDecoder, |
||||
real_t **input, void *sample_buffer, uint8_t channels, |
||||
uint16_t frame_len, uint8_t format) |
||||
{ |
||||
int16_t *short_sample_buffer = (int16_t*)sample_buffer; |
||||
int32_t *int_sample_buffer = (int32_t*)sample_buffer; |
||||
float32_t *float_sample_buffer = (float32_t*)sample_buffer; |
||||
double *double_sample_buffer = (double*)sample_buffer; |
||||
|
||||
#ifdef PROFILE |
||||
int64_t count = faad_get_ts(); |
||||
#endif |
||||
|
||||
/* Copy output to a standard PCM buffer */ |
||||
switch (format) |
||||
{ |
||||
case FAAD_FMT_16BIT: |
||||
to_PCM_16bit(hDecoder, input, channels, frame_len, &short_sample_buffer); |
||||
break; |
||||
case FAAD_FMT_24BIT: |
||||
to_PCM_24bit(hDecoder, input, channels, frame_len, &int_sample_buffer); |
||||
break; |
||||
case FAAD_FMT_32BIT: |
||||
to_PCM_32bit(hDecoder, input, channels, frame_len, &int_sample_buffer); |
||||
break; |
||||
case FAAD_FMT_FLOAT: |
||||
to_PCM_float(hDecoder, input, channels, frame_len, &float_sample_buffer); |
||||
break; |
||||
case FAAD_FMT_DOUBLE: |
||||
to_PCM_double(hDecoder, input, channels, frame_len, &double_sample_buffer); |
||||
break; |
||||
} |
||||
|
||||
#ifdef PROFILE |
||||
count = faad_get_ts() - count; |
||||
hDecoder->output_cycles += count; |
||||
#endif |
||||
|
||||
return sample_buffer; |
||||
} |
||||
|
||||
#else |
||||
|
||||
#define DM_MUL FRAC_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
|
||||
#define RSQRT2 FRAC_CONST(0.7071067811865475244) // 1/sqrt(2)
|
||||
#define BOTH FRAC_CONST(0.2265409196609864215998) // 1/(sqrt(2) + 2 + 1)
|
||||
|
||||
static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, |
||||
uint8_t down_matrix, uint8_t up_matrix, |
||||
uint8_t *internal_channel) |
||||
{ |
||||
real_t C; |
||||
if (up_matrix == 1) |
||||
return input[internal_channel[0]][sample]; |
||||
|
||||
if (!down_matrix) |
||||
return input[internal_channel[channel]][sample]; |
||||
|
||||
C = MUL_F(input[internal_channel[0]][sample], BOTH); |
||||
if (channel == 0) |
||||
{ |
||||
real_t L_S = MUL_F(input[internal_channel[3]][sample], BOTH); |
||||
real_t core = MUL_F(input[internal_channel[1]][sample], DM_MUL); |
||||
return core + C + L_S; |
||||
} else { |
||||
real_t R_S = MUL_F(input[internal_channel[4]][sample], BOTH); |
||||
real_t core = MUL_F(input[internal_channel[2]][sample], DM_MUL); |
||||
return core + C + R_S; |
||||
} |
||||
} |
||||
|
||||
void* output_to_PCM(NeAACDecStruct *hDecoder, |
||||
real_t **input, void *sample_buffer, uint8_t channels, |
||||
uint16_t frame_len, uint8_t format) |
||||
{ |
||||
uint8_t ch; |
||||
uint16_t i; |
||||
int16_t *short_sample_buffer = (int16_t*)sample_buffer; |
||||
int32_t *int_sample_buffer = (int32_t*)sample_buffer; |
||||
int32_t exp, half, sat_shift_mask; |
||||
|
||||
/* Copy output to a standard PCM buffer */ |
||||
for (ch = 0; ch < channels; ch++) |
||||
{ |
||||
switch (format) |
||||
{ |
||||
case FAAD_FMT_16BIT: |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, |
||||
hDecoder->internal_channel); |
||||
if (tmp >= 0) |
||||
{ |
||||
tmp += (1 << (REAL_BITS-1)); |
||||
if (tmp >= REAL_CONST(32767)) |
||||
{ |
||||
tmp = REAL_CONST(32767); |
||||
} |
||||
} else { |
||||
tmp += -(1 << (REAL_BITS-1)); |
||||
if (tmp <= REAL_CONST(-32768)) |
||||
{ |
||||
tmp = REAL_CONST(-32768); |
||||
} |
||||
} |
||||
tmp >>= REAL_BITS; |
||||
short_sample_buffer[(i*channels)+ch] = (int16_t)tmp; |
||||
} |
||||
break; |
||||
case FAAD_FMT_24BIT: |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, |
||||
hDecoder->internal_channel); |
||||
if (tmp >= 0) |
||||
{ |
||||
tmp += (1 << (REAL_BITS-9)); |
||||
tmp >>= (REAL_BITS-8); |
||||
if (tmp >= 8388607) |
||||
{ |
||||
tmp = 8388607; |
||||
} |
||||
} else { |
||||
tmp += -(1 << (REAL_BITS-9)); |
||||
tmp >>= (REAL_BITS-8); |
||||
if (tmp <= -8388608) |
||||
{ |
||||
tmp = -8388608; |
||||
} |
||||
} |
||||
int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; |
||||
} |
||||
break; |
||||
case FAAD_FMT_32BIT: |
||||
exp = 16 - REAL_BITS; |
||||
half = 1 << (exp - 1); |
||||
sat_shift_mask = SAT_SHIFT_MASK(exp); |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, |
||||
hDecoder->internal_channel); |
||||
if (tmp >= 0) |
||||
{ |
||||
tmp += half; |
||||
} else { |
||||
tmp += -half; |
||||
} |
||||
tmp = SAT_SHIFT(tmp, exp, sat_shift_mask); |
||||
int_sample_buffer[(i*channels)+ch] = tmp; |
||||
} |
||||
break; |
||||
case FAAD_FMT_FIXED: |
||||
for(i = 0; i < frame_len; i++) |
||||
{ |
||||
real_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, |
||||
hDecoder->internal_channel); |
||||
int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return sample_buffer; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,48 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: output.h,v 1.26 2009/01/26 23:51:15 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __OUTPUT_H__ |
||||
#define __OUTPUT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
void* output_to_PCM(NeAACDecStruct *hDecoder, |
||||
real_t **input, |
||||
void *samplebuffer, |
||||
uint8_t channels, |
||||
uint16_t frame_len, |
||||
uint8_t format); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,270 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: pns.c,v 1.39 2010/06/04 20:47:56 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include "pns.h" |
||||
|
||||
|
||||
/* static function declarations */ |
||||
static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, |
||||
uint8_t sub, |
||||
/* RNG states */ uint32_t *__r1, uint32_t *__r2); |
||||
|
||||
|
||||
#ifdef FIXED_POINT |
||||
|
||||
static real_t const pow2_table[] = |
||||
{ |
||||
COEF_CONST(1.0), |
||||
COEF_CONST(1.18920711500272), |
||||
COEF_CONST(1.41421356237310), |
||||
COEF_CONST(1.68179283050743) |
||||
}; |
||||
|
||||
// mean_energy_table[x] == sqrt(3 / x)
|
||||
static real_t const mean_energy_table[] = |
||||
{ |
||||
COEF_CONST(0.0), // should not happen
|
||||
COEF_CONST(1.7320508075688772), |
||||
COEF_CONST(1.224744871391589), |
||||
COEF_CONST(1.0), // sqrt(3/3)
|
||||
COEF_CONST(0.8660254037844386), |
||||
COEF_CONST(0.7745966692414834), |
||||
COEF_CONST(0.7071067811865476), |
||||
COEF_CONST(0.6546536707079771), |
||||
COEF_CONST(0.6123724356957945), |
||||
COEF_CONST(0.5773502691896257), |
||||
COEF_CONST(0.5477225575051661), |
||||
COEF_CONST(0.5222329678670935), |
||||
COEF_CONST(0.5), // sqrt(3/12)
|
||||
COEF_CONST(0.4803844614152614), |
||||
COEF_CONST(0.4629100498862757), |
||||
COEF_CONST(0.4472135954999579), |
||||
}; |
||||
#endif |
||||
|
||||
/* The function gen_rand_vector(addr, size) generates a vector of length
|
||||
<size> with signed random values of average energy MEAN_NRG per random |
||||
value. A suitable random number generator can be realized using one |
||||
multiplication/accumulation per random value. |
||||
*/ |
||||
static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, |
||||
uint8_t sub, |
||||
/* RNG states */ uint32_t *__r1, uint32_t *__r2) |
||||
{ |
||||
#ifndef FIXED_POINT |
||||
uint16_t i; |
||||
real_t energy = 0.0; |
||||
(void)sub; |
||||
|
||||
scale_factor = min(max(scale_factor, -120), 120); |
||||
|
||||
for (i = 0; i < size; i++) |
||||
{ |
||||
real_t tmp = (real_t)(int32_t)ne_rng(__r1, __r2); |
||||
spec[i] = tmp; |
||||
energy += tmp*tmp; |
||||
} |
||||
|
||||
if (energy > 0) |
||||
{ |
||||
real_t scale = (real_t)1.0/(real_t)sqrt(energy); |
||||
scale *= (real_t)pow(2.0, 0.25 * scale_factor); |
||||
for (i = 0; i < size; i++) |
||||
{ |
||||
spec[i] *= scale; |
||||
} |
||||
} |
||||
#else |
||||
uint16_t i; |
||||
real_t scale; |
||||
int32_t exp, frac; |
||||
int32_t idx, mask; |
||||
|
||||
/* IMDCT pre-scaling */ |
||||
scale_factor -= 4 * sub; |
||||
|
||||
// 52 stands for 2**13 == 8192 factor; larger factor causes overflows later (in cfft).
|
||||
scale_factor = min(max(scale_factor, -(REAL_BITS * 4)), 52); |
||||
|
||||
exp = scale_factor >> 2; |
||||
frac = scale_factor & 3; |
||||
|
||||
/* 29 <= REAL_BITS + exp <= 0 */ |
||||
mask = (1 << (REAL_BITS + exp)) - 1; |
||||
|
||||
idx = size; |
||||
scale = COEF_CONST(1); |
||||
// At most 2 iterations.
|
||||
while (idx >= 16) |
||||
{ |
||||
idx >>= 2; |
||||
scale >>= 1; |
||||
} |
||||
scale = MUL_C(scale, mean_energy_table[idx]); |
||||
if (frac) |
||||
scale = MUL_C(scale, pow2_table[frac]); |
||||
// scale is less than 4.0 now.
|
||||
|
||||
for (i = 0; i < size; i++) |
||||
{ |
||||
real_t tmp = (int32_t)ne_rng(__r1, __r2); |
||||
if (tmp < 0) |
||||
tmp = -(tmp & mask); |
||||
else |
||||
tmp = (tmp & mask); |
||||
spec[i] = MUL_C(tmp, scale); |
||||
} |
||||
#endif |
||||
} |
||||
|
||||
void pns_decode(ic_stream *ics_left, ic_stream *ics_right, |
||||
real_t *spec_left, real_t *spec_right, uint16_t frame_len, |
||||
uint8_t channel_pair, uint8_t object_type, |
||||
/* RNG states */ uint32_t *__r1, uint32_t *__r2) |
||||
{ |
||||
uint8_t g, sfb, b; |
||||
uint16_t begin, end; |
||||
|
||||
uint8_t group = 0; |
||||
uint16_t nshort = frame_len >> 3; |
||||
|
||||
uint8_t sub = 0; |
||||
|
||||
#ifdef FIXED_POINT |
||||
/* IMDCT scaling */ |
||||
if (object_type == LD) |
||||
{ |
||||
sub = 9 /*9*/; |
||||
} else { |
||||
if (ics_left->window_sequence == EIGHT_SHORT_SEQUENCE) |
||||
sub = 7 /*7*/; |
||||
else |
||||
sub = 10 /*10*/; |
||||
} |
||||
#else |
||||
(void)object_type; |
||||
#endif |
||||
|
||||
for (g = 0; g < ics_left->num_window_groups; g++) |
||||
{ |
||||
/* Do perceptual noise substitution decoding */ |
||||
for (b = 0; b < ics_left->window_group_length[g]; b++) |
||||
{ |
||||
uint16_t base = group * nshort; |
||||
for (sfb = 0; sfb < ics_left->max_sfb; sfb++) |
||||
{ |
||||
uint32_t r1_dep = 0, r2_dep = 0; |
||||
|
||||
if (is_noise(ics_left, g, sfb)) |
||||
{ |
||||
#ifdef LTP_DEC |
||||
/* Simultaneous use of LTP and PNS is not prevented in the
|
||||
syntax. If both LTP, and PNS are enabled on the same |
||||
scalefactor band, PNS takes precedence, and no prediction |
||||
is applied to this band. |
||||
*/ |
||||
ics_left->ltp.long_used[sfb] = 0; |
||||
ics_left->ltp2.long_used[sfb] = 0; |
||||
#endif |
||||
|
||||
#ifdef MAIN_DEC |
||||
/* For scalefactor bands coded using PNS the corresponding
|
||||
predictors are switched to "off". |
||||
*/ |
||||
ics_left->pred.prediction_used[sfb] = 0; |
||||
#endif |
||||
begin = min(base + ics_left->swb_offset[sfb], ics_left->swb_offset_max); |
||||
end = min(base + ics_left->swb_offset[sfb+1], ics_left->swb_offset_max); |
||||
|
||||
r1_dep = *__r1; |
||||
r2_dep = *__r2; |
||||
|
||||
/* Generate random vector */ |
||||
gen_rand_vector(&spec_left[begin], |
||||
ics_left->scale_factors[g][sfb], end - begin, sub, __r1, __r2); |
||||
} |
||||
|
||||
/* From the spec:
|
||||
If the same scalefactor band and group is coded by perceptual noise |
||||
substitution in both channels of a channel pair, the correlation of |
||||
the noise signal can be controlled by means of the ms_used field: While |
||||
the default noise generation process works independently for each channel |
||||
(separate generation of random vectors), the same random vector is used |
||||
for both channels if ms_used[] is set for a particular scalefactor band |
||||
and group. In this case, no M/S stereo coding is carried out (because M/S |
||||
stereo coding and noise substitution coding are mutually exclusive). |
||||
If the same scalefactor band and group is coded by perceptual noise |
||||
substitution in only one channel of a channel pair the setting of ms_used[] |
||||
is not evaluated. |
||||
*/ |
||||
if ((ics_right != NULL) |
||||
&& is_noise(ics_right, g, sfb)) |
||||
{ |
||||
#ifdef LTP_DEC |
||||
/* See comment above. */ |
||||
ics_right->ltp.long_used[sfb] = 0; |
||||
ics_right->ltp2.long_used[sfb] = 0; |
||||
#endif |
||||
#ifdef MAIN_DEC |
||||
/* See comment above. */ |
||||
ics_right->pred.prediction_used[sfb] = 0; |
||||
#endif |
||||
|
||||
if (channel_pair && is_noise(ics_left, g, sfb) && |
||||
(((ics_left->ms_mask_present == 1) && |
||||
(ics_left->ms_used[g][sfb])) || |
||||
(ics_left->ms_mask_present == 2))) |
||||
{ |
||||
/*uint16_t c;*/ |
||||
|
||||
begin = min(base + ics_right->swb_offset[sfb], ics_right->swb_offset_max); |
||||
end = min(base + ics_right->swb_offset[sfb+1], ics_right->swb_offset_max); |
||||
|
||||
/* Generate random vector dependent on left channel*/ |
||||
gen_rand_vector(&spec_right[begin], |
||||
ics_right->scale_factors[g][sfb], end - begin, sub, &r1_dep, &r2_dep); |
||||
|
||||
} else /*if (ics_left->ms_mask_present == 0)*/ { |
||||
begin = min(base + ics_right->swb_offset[sfb], ics_right->swb_offset_max); |
||||
end = min(base + ics_right->swb_offset[sfb+1], ics_right->swb_offset_max); |
||||
|
||||
/* Generate random vector */ |
||||
gen_rand_vector(&spec_right[begin], |
||||
ics_right->scale_factors[g][sfb], end - begin, sub, __r1, __r2); |
||||
} |
||||
} |
||||
} /* sfb */ |
||||
group++; |
||||
} /* b */ |
||||
} /* g */ |
||||
} |
@ -0,0 +1,57 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: pns.h,v 1.27 2007/11/01 12:33:33 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __PNS_H__ |
||||
#define __PNS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "syntax.h" |
||||
|
||||
#define NOISE_OFFSET 90 |
||||
|
||||
void pns_decode(ic_stream *ics_left, ic_stream *ics_right, |
||||
real_t *spec_left, real_t *spec_right, uint16_t frame_len, |
||||
uint8_t channel_pair, uint8_t object_type, |
||||
/* RNG states */ uint32_t *__r1, uint32_t *__r2); |
||||
|
||||
static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) |
||||
{ |
||||
if (ics->sfb_cb[group][sfb] == NOISE_HCB) |
||||
return 1; |
||||
return 0; |
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,155 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ps_dec.h,v 1.13 2009/01/26 22:32:31 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __PS_DEC_H__ |
||||
#define __PS_DEC_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "bits.h" |
||||
|
||||
#define EXTENSION_ID_PS 2 |
||||
|
||||
#define MAX_PS_ENVELOPES 5 |
||||
#define NO_ALLPASS_LINKS 3 |
||||
|
||||
typedef struct |
||||
{ |
||||
/* bitstream parameters */ |
||||
uint8_t enable_iid; |
||||
uint8_t enable_icc; |
||||
uint8_t enable_ext; |
||||
|
||||
uint8_t iid_mode; |
||||
uint8_t icc_mode; |
||||
uint8_t nr_iid_par; |
||||
uint8_t nr_ipdopd_par; |
||||
uint8_t nr_icc_par; |
||||
|
||||
uint8_t frame_class; |
||||
uint8_t num_env; |
||||
|
||||
uint8_t border_position[MAX_PS_ENVELOPES+1]; |
||||
|
||||
uint8_t iid_dt[MAX_PS_ENVELOPES]; |
||||
uint8_t icc_dt[MAX_PS_ENVELOPES]; |
||||
|
||||
uint8_t enable_ipdopd; |
||||
uint8_t ipd_mode; |
||||
uint8_t ipd_dt[MAX_PS_ENVELOPES]; |
||||
uint8_t opd_dt[MAX_PS_ENVELOPES]; |
||||
|
||||
/* indices */ |
||||
int8_t iid_index_prev[34]; |
||||
int8_t icc_index_prev[34]; |
||||
int8_t ipd_index_prev[17]; |
||||
int8_t opd_index_prev[17]; |
||||
int8_t iid_index[MAX_PS_ENVELOPES][34]; |
||||
int8_t icc_index[MAX_PS_ENVELOPES][34]; |
||||
int8_t ipd_index[MAX_PS_ENVELOPES][17]; |
||||
int8_t opd_index[MAX_PS_ENVELOPES][17]; |
||||
|
||||
int8_t ipd_index_1[17]; |
||||
int8_t opd_index_1[17]; |
||||
int8_t ipd_index_2[17]; |
||||
int8_t opd_index_2[17]; |
||||
|
||||
/* ps data was correctly read */ |
||||
uint8_t ps_data_available; |
||||
|
||||
/* a header has been read */ |
||||
uint8_t header_read; |
||||
|
||||
/**/ |
||||
uint8_t num_groups; |
||||
uint8_t num_hybrid_groups; |
||||
uint8_t nr_par_bands; |
||||
uint8_t nr_allpass_bands; |
||||
uint8_t decay_cutoff; |
||||
|
||||
/* filter delay handling */ |
||||
uint8_t saved_delay; |
||||
uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS]; |
||||
uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS]; |
||||
uint8_t delay_D[64]; |
||||
uint8_t delay_buf_index_delay[64]; |
||||
|
||||
/* mixing and phase */ |
||||
uint8_t phase_hist; |
||||
|
||||
/* hybrid filterbank parameters */ |
||||
uint8_t use34hybrid_bands; |
||||
uint8_t numTimeSlotsRate; |
||||
|
||||
uint8_t *group_border; |
||||
uint16_t *map_group2bk; |
||||
|
||||
complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */ |
||||
complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */ |
||||
complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */ |
||||
complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */ |
||||
|
||||
/* transients */ |
||||
real_t alpha_decay; |
||||
real_t alpha_smooth; |
||||
|
||||
real_t P_PeakDecayNrg[34]; |
||||
real_t P_prev[34]; |
||||
real_t P_SmoothPeakDecayDiffNrg_prev[34]; |
||||
|
||||
/* mixing and phase */ |
||||
complex_t h11_prev[50]; |
||||
complex_t h12_prev[50]; |
||||
complex_t h21_prev[50]; |
||||
complex_t h22_prev[50]; |
||||
complex_t ipd_prev[20][2]; |
||||
complex_t opd_prev[20][2]; |
||||
|
||||
/* hybrid filterbank parameters */ |
||||
void *hyb; |
||||
} ps_info; |
||||
|
||||
/* ps_syntax.c */ |
||||
uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); |
||||
|
||||
/* ps_dec.c */ |
||||
ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate); |
||||
void ps_free(ps_info *ps); |
||||
|
||||
uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,552 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ps_syntax.c,v 1.11 2007/11/01 12:33:33 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
|
||||
#ifdef PS_DEC |
||||
|
||||
#include "bits.h" |
||||
#include "ps_dec.h" |
||||
|
||||
/* type definitaions */ |
||||
typedef const int8_t (*ps_huff_tab)[2]; |
||||
|
||||
/* static data tables */ |
||||
static const uint8_t nr_iid_par_tab[] = { |
||||
10, 20, 34, 10, 20, 34, 0, 0 |
||||
}; |
||||
static const uint8_t nr_ipdopd_par_tab[] = { |
||||
5, 11, 17, 5, 11, 17, 0, 0 |
||||
}; |
||||
static const uint8_t nr_icc_par_tab[] = { |
||||
10, 20, 34, 10, 20, 34, 0, 0 |
||||
}; |
||||
static const uint8_t num_env_tab[][4] = { |
||||
{ 0, 1, 2, 4 }, |
||||
{ 1, 2, 3, 4 } |
||||
}; |
||||
|
||||
/* binary lookup huffman tables */ |
||||
static const int8_t f_huff_iid_def[][2] = { |
||||
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 1x */ |
||||
{ /*1*/ -30, /*-1*/ -32 }, /* index 2: 3 bits: 10x */ |
||||
{ 4, 5 }, /* index 3: 3 bits: 11x */ |
||||
{ /*2*/ -29, /*-2*/ -33 }, /* index 4: 4 bits: 110x */ |
||||
{ 6, 7 }, /* index 5: 4 bits: 111x */ |
||||
{ /*3*/ -28, /*-3*/ -34 }, /* index 6: 5 bits: 1110x */ |
||||
{ 8, 9 }, /* index 7: 5 bits: 1111x */ |
||||
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 11110x */ |
||||
{ /*5*/ -26, 10 }, /* index 9: 6 bits: 11111x */ |
||||
{ /*-5*/ -36, 11 }, /* index 10: 7 bits: 111111x */ |
||||
{ /*6*/ -25, 12 }, /* index 11: 8 bits: 1111111x */ |
||||
{ /*-6*/ -37, 13 }, /* index 12: 9 bits: 11111111x */ |
||||
{ /*-7*/ -38, 14 }, /* index 13: 10 bits: 111111111x */ |
||||
{ /*7*/ -24, 15 }, /* index 14: 11 bits: 1111111111x */ |
||||
{ 16, 17 }, /* index 15: 12 bits: 11111111111x */ |
||||
{ /*8*/ -23, /*-8*/ -39 }, /* index 16: 13 bits: 111111111110x */ |
||||
{ 18, 19 }, /* index 17: 13 bits: 111111111111x */ |
||||
{ /*9*/ -22, /*10*/ -21 }, /* index 18: 14 bits: 1111111111110x */ |
||||
{ 20, 21 }, /* index 19: 14 bits: 1111111111111x */ |
||||
{ /*-9*/ -40, /*11*/ -20 }, /* index 20: 15 bits: 11111111111110x */ |
||||
{ 22, 23 }, /* index 21: 15 bits: 11111111111111x */ |
||||
{ /*-10*/ -41, 24 }, /* index 22: 16 bits: 111111111111110x */ |
||||
{ 25, 26 }, /* index 23: 16 bits: 111111111111111x */ |
||||
{ /*-11*/ -42, /*-14*/ -45 }, /* index 24: 17 bits: 1111111111111101x */ |
||||
{ /*-13*/ -44, /*-12*/ -43 }, /* index 25: 17 bits: 1111111111111110x */ |
||||
{ /*12*/ -19, 27 }, /* index 26: 17 bits: 1111111111111111x */ |
||||
{ /*13*/ -18, /*14*/ -17 } /* index 27: 18 bits: 11111111111111111x */ |
||||
}; |
||||
|
||||
static const int8_t t_huff_iid_def[][2] = { |
||||
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */ |
||||
{ /*-1*/ -32, 2 }, /* index 1: 2 bits: 1x */ |
||||
{ /*1*/ -30, 3 }, /* index 2: 3 bits: 11x */ |
||||
{ /*-2*/ -33, 4 }, /* index 3: 4 bits: 111x */ |
||||
{ /*2*/ -29, 5 }, /* index 4: 5 bits: 1111x */ |
||||
{ /*-3*/ -34, 6 }, /* index 5: 6 bits: 11111x */ |
||||
{ /*3*/ -28, 7 }, /* index 6: 7 bits: 111111x */ |
||||
{ /*-4*/ -35, 8 }, /* index 7: 8 bits: 1111111x */ |
||||
{ /*4*/ -27, 9 }, /* index 8: 9 bits: 11111111x */ |
||||
{ /*-5*/ -36, 10 }, /* index 9: 10 bits: 111111111x */ |
||||
{ /*5*/ -26, 11 }, /* index 10: 11 bits: 1111111111x */ |
||||
{ /*-6*/ -37, 12 }, /* index 11: 12 bits: 11111111111x */ |
||||
{ /*6*/ -25, 13 }, /* index 12: 13 bits: 111111111111x */ |
||||
{ /*7*/ -24, 14 }, /* index 13: 14 bits: 1111111111111x */ |
||||
{ /*-7*/ -38, 15 }, /* index 14: 15 bits: 11111111111111x */ |
||||
{ 16, 17 }, /* index 15: 16 bits: 111111111111111x */ |
||||
{ /*8*/ -23, /*-8*/ -39 }, /* index 16: 17 bits: 1111111111111110x */ |
||||
{ 18, 19 }, /* index 17: 17 bits: 1111111111111111x */ |
||||
{ 20, 21 }, /* index 18: 18 bits: 11111111111111110x */ |
||||
{ 22, 23 }, /* index 19: 18 bits: 11111111111111111x */ |
||||
{ /*9*/ -22, /*-14*/ -45 }, /* index 20: 19 bits: 111111111111111100x */ |
||||
{ /*-13*/ -44, /*-12*/ -43 }, /* index 21: 19 bits: 111111111111111101x */ |
||||
{ 24, 25 }, /* index 22: 19 bits: 111111111111111110x */ |
||||
{ 26, 27 }, /* index 23: 19 bits: 111111111111111111x */ |
||||
{ /*-11*/ -42, /*-10*/ -41 }, /* index 24: 20 bits: 1111111111111111100x */ |
||||
{ /*-9*/ -40, /*10*/ -21 }, /* index 25: 20 bits: 1111111111111111101x */ |
||||
{ /*11*/ -20, /*12*/ -19 }, /* index 26: 20 bits: 1111111111111111110x */ |
||||
{ /*13*/ -18, /*14*/ -17 } /* index 27: 20 bits: 1111111111111111111x */ |
||||
}; |
||||
|
||||
static const int8_t f_huff_iid_fine[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 0x */ |
||||
{ 4, /*-1*/ -32 }, /* index 2: 3 bits: 00x */ |
||||
{ /*1*/ -30, 5 }, /* index 3: 3 bits: 01x */ |
||||
{ /*-2*/ -33, /*2*/ -29 }, /* index 4: 4 bits: 000x */ |
||||
{ 6, 7 }, /* index 5: 4 bits: 011x */ |
||||
{ /*-3*/ -34, /*3*/ -28 }, /* index 6: 5 bits: 0110x */ |
||||
{ 8, 9 }, /* index 7: 5 bits: 0111x */ |
||||
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 01110x */ |
||||
{ 10, 11 }, /* index 9: 6 bits: 01111x */ |
||||
{ /*-5*/ -36, /*5*/ -26 }, /* index 10: 7 bits: 011110x */ |
||||
{ 12, 13 }, /* index 11: 7 bits: 011111x */ |
||||
{ /*-6*/ -37, /*6*/ -25 }, /* index 12: 8 bits: 0111110x */ |
||||
{ 14, 15 }, /* index 13: 8 bits: 0111111x */ |
||||
{ /*7*/ -24, 16 }, /* index 14: 9 bits: 01111110x */ |
||||
{ 17, 18 }, /* index 15: 9 bits: 01111111x */ |
||||
{ 19, /*-8*/ -39 }, /* index 16: 10 bits: 011111101x */ |
||||
{ /*8*/ -23, 20 }, /* index 17: 10 bits: 011111110x */ |
||||
{ 21, /*-7*/ -38 }, /* index 18: 10 bits: 011111111x */ |
||||
{ /*10*/ -21, 22 }, /* index 19: 11 bits: 0111111010x */ |
||||
{ 23, /*-9*/ -40 }, /* index 20: 11 bits: 0111111101x */ |
||||
{ /*9*/ -22, 24 }, /* index 21: 11 bits: 0111111110x */ |
||||
{ /*-11*/ -42, /*11*/ -20 }, /* index 22: 12 bits: 01111110101x */ |
||||
{ 25, 26 }, /* index 23: 12 bits: 01111111010x */ |
||||
{ 27, /*-10*/ -41 }, /* index 24: 12 bits: 01111111101x */ |
||||
{ 28, /*-12*/ -43 }, /* index 25: 13 bits: 011111110100x */ |
||||
{ /*12*/ -19, 29 }, /* index 26: 13 bits: 011111110101x */ |
||||
{ 30, 31 }, /* index 27: 13 bits: 011111111010x */ |
||||
{ 32, /*-14*/ -45 }, /* index 28: 14 bits: 0111111101000x */ |
||||
{ /*14*/ -17, 33 }, /* index 29: 14 bits: 0111111101011x */ |
||||
{ 34, /*-13*/ -44 }, /* index 30: 14 bits: 0111111110100x */ |
||||
{ /*13*/ -18, 35 }, /* index 31: 14 bits: 0111111110101x */ |
||||
{ 36, 37 }, /* index 32: 15 bits: 01111111010000x */ |
||||
{ 38, /*-15*/ -46 }, /* index 33: 15 bits: 01111111010111x */ |
||||
{ /*15*/ -16, 39 }, /* index 34: 15 bits: 01111111101000x */ |
||||
{ 40, 41 }, /* index 35: 15 bits: 01111111101011x */ |
||||
{ 42, 43 }, /* index 36: 16 bits: 011111110100000x */ |
||||
{ /*-17*/ -48, /*17*/ -14 }, /* index 37: 16 bits: 011111110100001x */ |
||||
{ 44, 45 }, /* index 38: 16 bits: 011111110101110x */ |
||||
{ 46, 47 }, /* index 39: 16 bits: 011111111010001x */ |
||||
{ 48, 49 }, /* index 40: 16 bits: 011111111010110x */ |
||||
{ /*-16*/ -47, /*16*/ -15 }, /* index 41: 16 bits: 011111111010111x */ |
||||
{ /*-21*/ -52, /*21*/ -10 }, /* index 42: 17 bits: 0111111101000000x */ |
||||
{ /*-19*/ -50, /*19*/ -12 }, /* index 43: 17 bits: 0111111101000001x */ |
||||
{ /*-18*/ -49, /*18*/ -13 }, /* index 44: 17 bits: 0111111101011100x */ |
||||
{ 50, 51 }, /* index 45: 17 bits: 0111111101011101x */ |
||||
{ 52, 53 }, /* index 46: 17 bits: 0111111110100010x */ |
||||
{ 54, 55 }, /* index 47: 17 bits: 0111111110100011x */ |
||||
{ 56, 57 }, /* index 48: 17 bits: 0111111110101100x */ |
||||
{ 58, 59 }, /* index 49: 17 bits: 0111111110101101x */ |
||||
{ /*-26*/ -57, /*-25*/ -56 }, /* index 50: 18 bits: 01111111010111010x */ |
||||
{ /*-28*/ -59, /*-27*/ -58 }, /* index 51: 18 bits: 01111111010111011x */ |
||||
{ /*-22*/ -53, /*22*/ -9 }, /* index 52: 18 bits: 01111111101000100x */ |
||||
{ /*-24*/ -55, /*-23*/ -54 }, /* index 53: 18 bits: 01111111101000101x */ |
||||
{ /*25*/ -6, /*26*/ -5 }, /* index 54: 18 bits: 01111111101000110x */ |
||||
{ /*23*/ -8, /*24*/ -7 }, /* index 55: 18 bits: 01111111101000111x */ |
||||
{ /*29*/ -2, /*30*/ -1 }, /* index 56: 18 bits: 01111111101011000x */ |
||||
{ /*27*/ -4, /*28*/ -3 }, /* index 57: 18 bits: 01111111101011001x */ |
||||
{ /*-30*/ -61, /*-29*/ -60 }, /* index 58: 18 bits: 01111111101011010x */ |
||||
{ /*-20*/ -51, /*20*/ -11 } /* index 59: 18 bits: 01111111101011011x */ |
||||
}; |
||||
|
||||
static const int8_t t_huff_iid_fine[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 0x */ |
||||
{ 3, /*-1*/ -32 }, /* index 2: 3 bits: 01x */ |
||||
{ 4, 5 }, /* index 3: 4 bits: 010x */ |
||||
{ 6, 7 }, /* index 4: 5 bits: 0100x */ |
||||
{ /*-2*/ -33, /*2*/ -29 }, /* index 5: 5 bits: 0101x */ |
||||
{ 8, /*-3*/ -34 }, /* index 6: 6 bits: 01000x */ |
||||
{ /*3*/ -28, 9 }, /* index 7: 6 bits: 01001x */ |
||||
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 7 bits: 010000x */ |
||||
{ 10, 11 }, /* index 9: 7 bits: 010011x */ |
||||
{ /*5*/ -26, 12 }, /* index 10: 8 bits: 0100110x */ |
||||
{ 13, 14 }, /* index 11: 8 bits: 0100111x */ |
||||
{ /*-6*/ -37, /*6*/ -25 }, /* index 12: 9 bits: 01001101x */ |
||||
{ 15, 16 }, /* index 13: 9 bits: 01001110x */ |
||||
{ 17, /*-5*/ -36 }, /* index 14: 9 bits: 01001111x */ |
||||
{ 18, /*-7*/ -38 }, /* index 15: 10 bits: 010011100x */ |
||||
{ /*7*/ -24, 19 }, /* index 16: 10 bits: 010011101x */ |
||||
{ 20, 21 }, /* index 17: 10 bits: 010011110x */ |
||||
{ /*9*/ -22, 22 }, /* index 18: 11 bits: 0100111000x */ |
||||
{ 23, 24 }, /* index 19: 11 bits: 0100111011x */ |
||||
{ /*-8*/ -39, /*8*/ -23 }, /* index 20: 11 bits: 0100111100x */ |
||||
{ 25, 26 }, /* index 21: 11 bits: 0100111101x */ |
||||
{ /*11*/ -20, 27 }, /* index 22: 12 bits: 01001110001x */ |
||||
{ 28, 29 }, /* index 23: 12 bits: 01001110110x */ |
||||
{ /*-10*/ -41, /*10*/ -21 }, /* index 24: 12 bits: 01001110111x */ |
||||
{ 30, 31 }, /* index 25: 12 bits: 01001111010x */ |
||||
{ 32, /*-9*/ -40 }, /* index 26: 12 bits: 01001111011x */ |
||||
{ 33, /*-13*/ -44 }, /* index 27: 13 bits: 010011100011x */ |
||||
{ /*13*/ -18, 34 }, /* index 28: 13 bits: 010011101100x */ |
||||
{ 35, 36 }, /* index 29: 13 bits: 010011101101x */ |
||||
{ 37, /*-12*/ -43 }, /* index 30: 13 bits: 010011110100x */ |
||||
{ /*12*/ -19, 38 }, /* index 31: 13 bits: 010011110101x */ |
||||
{ 39, /*-11*/ -42 }, /* index 32: 13 bits: 010011110110x */ |
||||
{ 40, 41 }, /* index 33: 14 bits: 0100111000110x */ |
||||
{ 42, 43 }, /* index 34: 14 bits: 0100111011001x */ |
||||
{ 44, 45 }, /* index 35: 14 bits: 0100111011010x */ |
||||
{ 46, /*-15*/ -46 }, /* index 36: 14 bits: 0100111011011x */ |
||||
{ /*15*/ -16, 47 }, /* index 37: 14 bits: 0100111101000x */ |
||||
{ /*-14*/ -45, /*14*/ -17 }, /* index 38: 14 bits: 0100111101011x */ |
||||
{ 48, 49 }, /* index 39: 14 bits: 0100111101100x */ |
||||
{ /*-21*/ -52, /*-20*/ -51 }, /* index 40: 15 bits: 01001110001100x */ |
||||
{ /*18*/ -13, /*19*/ -12 }, /* index 41: 15 bits: 01001110001101x */ |
||||
{ /*-19*/ -50, /*-18*/ -49 }, /* index 42: 15 bits: 01001110110010x */ |
||||
{ 50, 51 }, /* index 43: 15 bits: 01001110110011x */ |
||||
{ 52, 53 }, /* index 44: 15 bits: 01001110110100x */ |
||||
{ 54, 55 }, /* index 45: 15 bits: 01001110110101x */ |
||||
{ 56, /*-17*/ -48 }, /* index 46: 15 bits: 01001110110110x */ |
||||
{ /*17*/ -14, 57 }, /* index 47: 15 bits: 01001111010001x */ |
||||
{ 58, /*-16*/ -47 }, /* index 48: 15 bits: 01001111011000x */ |
||||
{ /*16*/ -15, 59 }, /* index 49: 15 bits: 01001111011001x */ |
||||
{ /*-26*/ -57, /*26*/ -5 }, /* index 50: 16 bits: 010011101100110x */ |
||||
{ /*-28*/ -59, /*-27*/ -58 }, /* index 51: 16 bits: 010011101100111x */ |
||||
{ /*29*/ -2, /*30*/ -1 }, /* index 52: 16 bits: 010011101101000x */ |
||||
{ /*27*/ -4, /*28*/ -3 }, /* index 53: 16 bits: 010011101101001x */ |
||||
{ /*-30*/ -61, /*-29*/ -60 }, /* index 54: 16 bits: 010011101101010x */ |
||||
{ /*-25*/ -56, /*25*/ -6 }, /* index 55: 16 bits: 010011101101011x */ |
||||
{ /*-24*/ -55, /*24*/ -7 }, /* index 56: 16 bits: 010011101101100x */ |
||||
{ /*-23*/ -54, /*23*/ -8 }, /* index 57: 16 bits: 010011110100011x */ |
||||
{ /*-22*/ -53, /*22*/ -9 }, /* index 58: 16 bits: 010011110110000x */ |
||||
{ /*20*/ -11, /*21*/ -10 } /* index 59: 16 bits: 010011110110011x */ |
||||
}; |
||||
|
||||
static const int8_t f_huff_icc[][2] = { |
||||
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */ |
||||
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ |
||||
{ /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ |
||||
{ /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ |
||||
{ /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ |
||||
{ /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ |
||||
{ /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ |
||||
{ /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ |
||||
{ /*5*/ -26, 9 }, /* index 8: 9 bits: 11111111x */ |
||||
{ /*-4*/ -35, 10 }, /* index 9: 10 bits: 111111111x */ |
||||
{ /*6*/ -25, 11 }, /* index 10: 11 bits: 1111111111x */ |
||||
{ /*-5*/ -36, 12 }, /* index 11: 12 bits: 11111111111x */ |
||||
{ /*7*/ -24, 13 }, /* index 12: 13 bits: 111111111111x */ |
||||
{ /*-6*/ -37, /*-7*/ -38 } /* index 13: 14 bits: 1111111111111x */ |
||||
}; |
||||
|
||||
static const int8_t t_huff_icc[][2] = { |
||||
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */ |
||||
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ |
||||
{ /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ |
||||
{ /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ |
||||
{ /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ |
||||
{ /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ |
||||
{ /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ |
||||
{ /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ |
||||
{ /*-4*/ -35, 9 }, /* index 8: 9 bits: 11111111x */ |
||||
{ /*5*/ -26, 10 }, /* index 9: 10 bits: 111111111x */ |
||||
{ /*-5*/ -36, 11 }, /* index 10: 11 bits: 1111111111x */ |
||||
{ /*6*/ -25, 12 }, /* index 11: 12 bits: 11111111111x */ |
||||
{ /*-6*/ -37, 13 }, /* index 12: 13 bits: 111111111111x */ |
||||
{ /*-7*/ -38, /*7*/ -24 } /* index 13: 14 bits: 1111111111111x */ |
||||
}; |
||||
|
||||
static const int8_t f_huff_ipd[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 0x */ |
||||
{ /*1*/ -30, 4 }, /* index 2: 3 bits: 00x */ |
||||
{ 5, 6 }, /* index 3: 3 bits: 01x */ |
||||
{ /*4*/ -27, /*5*/ -26 }, /* index 4: 4 bits: 001x */ |
||||
{ /*3*/ -28, /*6*/ -25 }, /* index 5: 4 bits: 010x */ |
||||
{ /*2*/ -29, /*7*/ -24 } /* index 6: 4 bits: 011x */ |
||||
}; |
||||
|
||||
static const int8_t t_huff_ipd[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 0x */ |
||||
{ 4, 5 }, /* index 2: 3 bits: 00x */ |
||||
{ /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ |
||||
{ /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ |
||||
{ /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ |
||||
{ /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ |
||||
}; |
||||
|
||||
static const int8_t f_huff_opd[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 0x */ |
||||
{ /*7*/ -24, /*1*/ -30 }, /* index 2: 3 bits: 00x */ |
||||
{ 4, 5 }, /* index 3: 3 bits: 01x */ |
||||
{ /*3*/ -28, /*6*/ -25 }, /* index 4: 4 bits: 010x */ |
||||
{ /*2*/ -29, 6 }, /* index 5: 4 bits: 011x */ |
||||
{ /*5*/ -26, /*4*/ -27 } /* index 6: 5 bits: 0111x */ |
||||
}; |
||||
|
||||
static const int8_t t_huff_opd[][2] = { |
||||
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */ |
||||
{ 2, 3 }, /* index 1: 2 bits: 0x */ |
||||
{ 4, 5 }, /* index 2: 3 bits: 00x */ |
||||
{ /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ |
||||
{ /*5*/ -26, /*2*/ -29 }, /* index 4: 4 bits: 000x */ |
||||
{ /*6*/ -25, 6 }, /* index 5: 4 bits: 001x */ |
||||
{ /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0011x */ |
||||
}; |
||||
|
||||
/* static function declarations */ |
||||
static uint16_t ps_extension(ps_info *ps, bitfile *ld, |
||||
const uint8_t ps_extension_id, |
||||
const uint16_t num_bits_left); |
||||
static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, |
||||
ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par); |
||||
static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff); |
||||
|
||||
|
||||
uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header) |
||||
{ |
||||
uint8_t tmp, n; |
||||
uint16_t bits = (uint16_t)faad_get_processed_bits(ld); |
||||
|
||||
*header = 0; |
||||
|
||||
/* check for new PS header */ |
||||
if (faad_get1bit(ld |
||||
DEBUGVAR(1,1000,"ps_data(): enable_ps_header"))) |
||||
{ |
||||
*header = 1; |
||||
|
||||
ps->header_read = 1; |
||||
|
||||
ps->use34hybrid_bands = 0; |
||||
|
||||
/* Inter-channel Intensity Difference (IID) parameters enabled */ |
||||
ps->enable_iid = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1001,"ps_data(): enable_iid")); |
||||
|
||||
if (ps->enable_iid) |
||||
{ |
||||
ps->iid_mode = (uint8_t)faad_getbits(ld, 3 |
||||
DEBUGVAR(1,1002,"ps_data(): iid_mode")); |
||||
|
||||
ps->nr_iid_par = nr_iid_par_tab[ps->iid_mode]; |
||||
ps->nr_ipdopd_par = nr_ipdopd_par_tab[ps->iid_mode]; |
||||
|
||||
if (ps->iid_mode == 2 || ps->iid_mode == 5) |
||||
ps->use34hybrid_bands = 1; |
||||
|
||||
/* IPD freq res equal to IID freq res */ |
||||
ps->ipd_mode = ps->iid_mode; |
||||
} |
||||
|
||||
/* Inter-channel Coherence (ICC) parameters enabled */ |
||||
ps->enable_icc = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1003,"ps_data(): enable_icc")); |
||||
|
||||
if (ps->enable_icc) |
||||
{ |
||||
ps->icc_mode = (uint8_t)faad_getbits(ld, 3 |
||||
DEBUGVAR(1,1004,"ps_data(): icc_mode")); |
||||
|
||||
ps->nr_icc_par = nr_icc_par_tab[ps->icc_mode]; |
||||
|
||||
if (ps->icc_mode == 2 || ps->icc_mode == 5) |
||||
ps->use34hybrid_bands = 1; |
||||
} |
||||
|
||||
/* PS extension layer enabled */ |
||||
ps->enable_ext = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1005,"ps_data(): enable_ext")); |
||||
} |
||||
|
||||
/* we are here, but no header has been read yet */ |
||||
if (ps->header_read == 0) |
||||
{ |
||||
ps->ps_data_available = 0; |
||||
return 1; |
||||
} |
||||
|
||||
ps->frame_class = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1006,"ps_data(): frame_class")); |
||||
tmp = (uint8_t)faad_getbits(ld, 2 |
||||
DEBUGVAR(1,1007,"ps_data(): num_env_idx")); |
||||
|
||||
ps->num_env = num_env_tab[ps->frame_class][tmp]; |
||||
|
||||
if (ps->frame_class) |
||||
{ |
||||
for (n = 1; n < ps->num_env+1; n++) |
||||
{ |
||||
ps->border_position[n] = (uint8_t)faad_getbits(ld, 5 |
||||
DEBUGVAR(1,1008,"ps_data(): border_position")) + 1; |
||||
} |
||||
} |
||||
|
||||
if (ps->enable_iid) |
||||
{ |
||||
for (n = 0; n < ps->num_env; n++) |
||||
{ |
||||
ps->iid_dt[n] = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1009,"ps_data(): iid_dt")); |
||||
|
||||
/* iid_data */ |
||||
if (ps->iid_mode < 3) |
||||
{ |
||||
huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_def, |
||||
f_huff_iid_def, ps->iid_index[n]); |
||||
} else { |
||||
huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_fine, |
||||
f_huff_iid_fine, ps->iid_index[n]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (ps->enable_icc) |
||||
{ |
||||
for (n = 0; n < ps->num_env; n++) |
||||
{ |
||||
ps->icc_dt[n] = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1010,"ps_data(): icc_dt")); |
||||
|
||||
/* icc_data */ |
||||
huff_data(ld, ps->icc_dt[n], ps->nr_icc_par, t_huff_icc, |
||||
f_huff_icc, ps->icc_index[n]); |
||||
} |
||||
} |
||||
|
||||
if (ps->enable_ext) |
||||
{ |
||||
uint16_t num_bits_left; |
||||
uint16_t cnt = (uint16_t)faad_getbits(ld, 4 |
||||
DEBUGVAR(1,1011,"ps_data(): ps_extension_size")); |
||||
if (cnt == 15) |
||||
{ |
||||
cnt += (uint16_t)faad_getbits(ld, 8 |
||||
DEBUGVAR(1,1012,"ps_data(): esc_count")); |
||||
} |
||||
|
||||
num_bits_left = 8 * cnt; |
||||
while (num_bits_left > 7) |
||||
{ |
||||
uint8_t ps_extension_id = (uint8_t)faad_getbits(ld, 2 |
||||
DEBUGVAR(1,1013,"ps_data(): ps_extension_size")); |
||||
|
||||
num_bits_left -= 2; |
||||
num_bits_left -= ps_extension(ps, ld, ps_extension_id, num_bits_left); |
||||
} |
||||
|
||||
faad_getbits(ld, num_bits_left |
||||
DEBUGVAR(1,1014,"ps_data(): fill_bits")); |
||||
} |
||||
|
||||
bits = (uint16_t)faad_get_processed_bits(ld) - bits; |
||||
|
||||
ps->ps_data_available = 1; |
||||
|
||||
return bits; |
||||
} |
||||
|
||||
static uint16_t ps_extension(ps_info *ps, bitfile *ld, |
||||
const uint8_t ps_extension_id, |
||||
const uint16_t num_bits_left) |
||||
{ |
||||
uint8_t n; |
||||
uint16_t bits = (uint16_t)faad_get_processed_bits(ld); |
||||
(void)num_bits_left; /* TODO: remove parameter, or actually use it. */ |
||||
|
||||
if (ps_extension_id == 0) |
||||
{ |
||||
ps->enable_ipdopd = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1015,"ps_extension(): enable_ipdopd")); |
||||
|
||||
if (ps->enable_ipdopd) |
||||
{ |
||||
for (n = 0; n < ps->num_env; n++) |
||||
{ |
||||
ps->ipd_dt[n] = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1016,"ps_extension(): ipd_dt")); |
||||
|
||||
/* ipd_data */ |
||||
huff_data(ld, ps->ipd_dt[n], ps->nr_ipdopd_par, t_huff_ipd, |
||||
f_huff_ipd, ps->ipd_index[n]); |
||||
|
||||
ps->opd_dt[n] = (uint8_t)faad_get1bit(ld |
||||
DEBUGVAR(1,1017,"ps_extension(): opd_dt")); |
||||
|
||||
/* opd_data */ |
||||
huff_data(ld, ps->opd_dt[n], ps->nr_ipdopd_par, t_huff_opd, |
||||
f_huff_opd, ps->opd_index[n]); |
||||
} |
||||
} |
||||
faad_get1bit(ld |
||||
DEBUGVAR(1,1018,"ps_extension(): reserved_ps")); |
||||
} |
||||
|
||||
/* return number of bits read */ |
||||
bits = (uint16_t)faad_get_processed_bits(ld) - bits; |
||||
|
||||
return bits; |
||||
} |
||||
|
||||
/* read huffman data coded in either the frequency or the time direction */ |
||||
static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, |
||||
ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par) |
||||
{ |
||||
uint8_t n; |
||||
|
||||
if (dt) |
||||
{ |
||||
/* coded in time direction */ |
||||
for (n = 0; n < nr_par; n++) |
||||
{ |
||||
par[n] = ps_huff_dec(ld, t_huff); |
||||
} |
||||
} else { |
||||
/* coded in frequency direction */ |
||||
par[0] = ps_huff_dec(ld, f_huff); |
||||
|
||||
for (n = 1; n < nr_par; n++) |
||||
{ |
||||
par[n] = ps_huff_dec(ld, f_huff); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* binary search huffman decoding */ |
||||
static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff) |
||||
{ |
||||
uint8_t bit; |
||||
int8_t index = 0; |
||||
|
||||
while (index >= 0) |
||||
{ |
||||
bit = (uint8_t)faad_get1bit(ld); |
||||
index = t_huff[index][bit]; |
||||
} |
||||
|
||||
return index + 31; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,550 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: ps_tables.h,v 1.8 2007/11/01 12:33:33 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __PS_TABLES_H__ |
||||
#define __PS_TABLES_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#ifdef _MSC_VER |
||||
#pragma warning(disable:4305) |
||||
#pragma warning(disable:4244) |
||||
#endif |
||||
|
||||
#if 0 |
||||
#if 0 |
||||
float f_center_20[12] = { |
||||
0.5/4, 1.5/4, 2.5/4, 3.5/4, |
||||
4.5/4*0, 5.5/4*0, -1.5/4, -0.5/4, |
||||
3.5/2, 2.5/2, 4.5/2, 5.5/2 |
||||
}; |
||||
#else |
||||
float f_center_20[12] = { |
||||
0.5/8, 1.5/8, 2.5/8, 3.5/8, |
||||
4.5/8*0, 5.5/8*0, -1.5/8, -0.5/8, |
||||
3.5/4, 2.5/4, 4.5/4, 5.5/4 |
||||
}; |
||||
#endif |
||||
|
||||
float f_center_34[32] = { |
||||
1/12, 3/12, 5/12, 7/12, |
||||
9/12, 11/12, 13/12, 15/12, |
||||
17/12, -5/12, -3/12, -1/12, |
||||
17/8, 19/8, 5/8, 7/8, |
||||
9/8, 11/8, 13/8, 15/8, |
||||
9/4, 11/4, 13/4, 7/4, |
||||
17/4, 11/4, 13/4, 15/4, |
||||
17/4, 19/4, 21/4, 15/4 |
||||
}; |
||||
|
||||
static const real_t frac_delay_q[] = { |
||||
FRAC_CONST(0.43), |
||||
FRAC_CONST(0.75), |
||||
FRAC_CONST(0.347) |
||||
}; |
||||
#endif |
||||
|
||||
/* RE(ps->Phi_Fract_Qmf[j]) = (float)cos(M_PI*(j+0.5)*(0.39)); */ |
||||
/* IM(ps->Phi_Fract_Qmf[j]) = (float)sin(M_PI*(j+0.5)*(0.39)); */ |
||||
static const complex_t Phi_Fract_Qmf[] = { |
||||
{ FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, |
||||
{ FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, |
||||
{ FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, |
||||
{ FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, |
||||
{ FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, |
||||
{ FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, |
||||
{ FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, |
||||
{ FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, |
||||
{ FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, |
||||
{ FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, |
||||
{ FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, |
||||
{ FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, |
||||
{ FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, |
||||
{ FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, |
||||
{ FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, |
||||
{ FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, |
||||
{ FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, |
||||
{ FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, |
||||
{ FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, |
||||
{ FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, |
||||
{ FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, |
||||
{ FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, |
||||
{ FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, |
||||
{ FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, |
||||
{ FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, |
||||
{ FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, |
||||
{ FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, |
||||
{ FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, |
||||
{ FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, |
||||
{ FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, |
||||
{ FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, |
||||
{ FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, |
||||
{ FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, |
||||
{ FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, |
||||
{ FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, |
||||
{ FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, |
||||
{ FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, |
||||
{ FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, |
||||
{ FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, |
||||
{ FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, |
||||
{ FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, |
||||
{ FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, |
||||
{ FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, |
||||
{ FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, |
||||
{ FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, |
||||
{ FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, |
||||
{ FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, |
||||
{ FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, |
||||
{ FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, |
||||
{ FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, |
||||
{ FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, |
||||
{ FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, |
||||
{ FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, |
||||
{ FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, |
||||
{ FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, |
||||
{ FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, |
||||
{ FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, |
||||
{ FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, |
||||
{ FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, |
||||
{ FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, |
||||
{ FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, |
||||
{ FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, |
||||
{ FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, |
||||
{ FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } |
||||
}; |
||||
|
||||
/* RE(Phi_Fract_SubQmf20[j]) = (float)cos(M_PI*f_center_20[j]*0.39); */ |
||||
/* IM(Phi_Fract_SubQmf20[j]) = (float)sin(M_PI*f_center_20[j]*0.39); */ |
||||
static const complex_t Phi_Fract_SubQmf20[] = { |
||||
{ FRAC_CONST(0.9882950187), FRAC_CONST(0.1525546312) }, |
||||
{ FRAC_CONST(0.8962930441), FRAC_CONST(0.4434623122) }, |
||||
{ FRAC_CONST(0.7208535671), FRAC_CONST(0.6930873394) }, |
||||
{ FRAC_CONST(0.4783087075), FRAC_CONST(0.8781917691) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(0.8962930441), FRAC_CONST(-0.4434623122) }, |
||||
{ FRAC_CONST(0.9882950187), FRAC_CONST(-0.1525546312) }, |
||||
{ FRAC_CONST(-0.5424415469), FRAC_CONST(0.8400935531) }, |
||||
{ FRAC_CONST(0.0392598175), FRAC_CONST(0.9992290139) }, |
||||
{ FRAC_CONST(-0.9268565774), FRAC_CONST(0.3754155636) }, |
||||
{ FRAC_CONST(-0.9741733670), FRAC_CONST(-0.2258012742) } |
||||
}; |
||||
|
||||
/* RE(Phi_Fract_SubQmf34[j]) = (float)cos(M_PI*f_center_34[j]*0.39); */ |
||||
/* IM(Phi_Fract_SubQmf34[j]) = (float)sin(M_PI*f_center_34[j]*0.39); */ |
||||
static const complex_t Phi_Fract_SubQmf34[] = { |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, |
||||
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, |
||||
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, |
||||
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, |
||||
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, |
||||
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, |
||||
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, |
||||
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, |
||||
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, |
||||
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, |
||||
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, |
||||
{ FRAC_CONST(0.9876883626), FRAC_CONST(-0.1564344615) }, |
||||
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) } |
||||
}; |
||||
|
||||
/* RE(Q_Fract_allpass_Qmf[j][i]) = (float)cos(M_PI*(j+0.5)*(frac_delay_q[i])); */ |
||||
/* IM(Q_Fract_allpass_Qmf[j][i]) = (float)sin(M_PI*(j+0.5)*(frac_delay_q[i])); */ |
||||
static const complex_t Q_Fract_allpass_Qmf[][3] = { |
||||
{ { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, |
||||
{ { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, |
||||
{ { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, |
||||
{ { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, |
||||
{ { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, |
||||
{ { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, |
||||
{ { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, |
||||
{ { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, |
||||
{ { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, |
||||
{ { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, |
||||
{ { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, |
||||
{ { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, |
||||
{ { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, |
||||
{ { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, |
||||
{ { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, |
||||
{ { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, |
||||
{ { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, |
||||
{ { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, |
||||
{ { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, |
||||
{ { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, |
||||
{ { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, |
||||
{ { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, |
||||
{ { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, |
||||
{ { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, |
||||
{ { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, |
||||
{ { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, |
||||
{ { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, |
||||
{ { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, |
||||
{ { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, |
||||
{ { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, |
||||
{ { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, |
||||
{ { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, |
||||
{ { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, |
||||
{ { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, |
||||
{ { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, |
||||
{ { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, |
||||
{ { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, |
||||
{ { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, |
||||
{ { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, |
||||
{ { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, |
||||
{ { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, |
||||
{ { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, |
||||
{ { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, |
||||
{ { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, |
||||
{ { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, |
||||
{ { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, |
||||
{ { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, |
||||
{ { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, |
||||
{ { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, |
||||
{ { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, |
||||
{ { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, |
||||
{ { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, |
||||
{ { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, |
||||
{ { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, |
||||
{ { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, |
||||
{ { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, |
||||
{ { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, |
||||
{ { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, |
||||
{ { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, |
||||
{ { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, |
||||
{ { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, |
||||
{ { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, |
||||
{ { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, |
||||
{ { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } |
||||
}; |
||||
|
||||
/* RE(Q_Fract_allpass_SubQmf20[j][i]) = (float)cos(M_PI*f_center_20[j]*frac_delay_q[i]); */ |
||||
/* IM(Q_Fract_allpass_SubQmf20[j][i]) = (float)sin(M_PI*f_center_20[j]*frac_delay_q[i]); */ |
||||
static const complex_t Q_Fract_allpass_SubQmf20[][3] = { |
||||
{ { FRAC_CONST(0.9857769012), FRAC_CONST(0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(0.1358452588) } }, |
||||
{ { FRAC_CONST(0.8744080663), FRAC_CONST(0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(0.3975082636) } }, |
||||
{ { FRAC_CONST(0.6642524004), FRAC_CONST(0.7475083470) }, { FRAC_CONST(0.0980171412), FRAC_CONST(0.9951847196) }, { FRAC_CONST(0.7767338753), FRAC_CONST(0.6298289299) } }, |
||||
{ { FRAC_CONST(0.3790524006), FRAC_CONST(0.9253752232) }, { FRAC_CONST(-0.4713967443), FRAC_CONST(0.8819212914) }, { FRAC_CONST(0.5785340071), FRAC_CONST(0.8156582713) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(0.8744080663), FRAC_CONST(-0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(-0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(-0.3975082636) } }, |
||||
{ { FRAC_CONST(0.9857769012), FRAC_CONST(-0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(-0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(-0.1358452588) } }, |
||||
{ { FRAC_CONST(-0.7126385570), FRAC_CONST(0.7015314102) }, { FRAC_CONST(-0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.3305967748), FRAC_CONST(0.9437720776) } }, |
||||
{ { FRAC_CONST(-0.1175374240), FRAC_CONST(0.9930684566) }, { FRAC_CONST(-0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(0.2066311091), FRAC_CONST(0.9784189463) } }, |
||||
{ { FRAC_CONST(-0.9947921634), FRAC_CONST(0.1019244045) }, { FRAC_CONST(0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.7720130086), FRAC_CONST(0.6356067061) } }, |
||||
{ { FRAC_CONST(-0.8400934935), FRAC_CONST(-0.5424416065) }, { FRAC_CONST(0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(-0.9896889329), FRAC_CONST(0.1432335079) } } |
||||
}; |
||||
|
||||
/* RE(Q_Fract_allpass_SubQmf34[j][i]) = (float)cos(M_PI*f_center_34[j]*frac_delay_q[i]); */ |
||||
/* IM(Q_Fract_allpass_SubQmf34[j][i]) = (float)sin(M_PI*f_center_34[j]*frac_delay_q[i]); */ |
||||
static const complex_t Q_Fract_allpass_SubQmf34[][3] = { |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, |
||||
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, |
||||
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, |
||||
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, |
||||
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, |
||||
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, |
||||
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, |
||||
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, |
||||
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, |
||||
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, |
||||
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, |
||||
{ { FRAC_CONST(0.8910064697), FRAC_CONST(0.4539906085) }, { FRAC_CONST(0.7071067691), FRAC_CONST(-0.7071067691) }, { FRAC_CONST(0.6730125546), FRAC_CONST(-0.7396310568) } }, |
||||
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } } |
||||
}; |
||||
|
||||
#if 0 |
||||
static float quant_rho[8] = |
||||
{ |
||||
FRAC_CONST(1.0), FRAC_CONST(0.937), FRAC_CONST(0.84118), FRAC_CONST(0.60092), |
||||
FRAC_CONST(0.36764), FRAC_CONST(0.0), FRAC_CONST(-0.589), FRAC_CONST(-1.0) |
||||
}; |
||||
|
||||
static const uint8_t quant_iid_normal[7] = |
||||
{ |
||||
2, 4, 7, 10, 14, 18, 25 |
||||
}; |
||||
|
||||
static const uint8_t quant_iid_fine[15] = |
||||
{ |
||||
2, 4, 6, 8, 10, 13, 16, 19, 22, 25, 30, 35, 40, 45, 50 |
||||
}; |
||||
#endif |
||||
|
||||
static const real_t cos_alphas[] = { |
||||
COEF_CONST(1.0000000000), COEF_CONST(0.9841239700), COEF_CONST(0.9594738210), |
||||
COEF_CONST(0.8946843079), COEF_CONST(0.8269340931), COEF_CONST(0.7071067812), |
||||
COEF_CONST(0.4533210856), COEF_CONST(0.0000000000) |
||||
}; |
||||
|
||||
static const real_t sin_alphas[] = { |
||||
COEF_CONST(0.0000000000), COEF_CONST(0.1774824264), COEF_CONST(0.2817977763), |
||||
COEF_CONST(0.4466989918), COEF_CONST(0.5622988580), COEF_CONST(0.7071067812), |
||||
COEF_CONST(0.8913472911), COEF_CONST(1.0000000000) |
||||
}; |
||||
|
||||
static const real_t cos_betas_normal[][8] = { |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9959398908), COEF_CONST(0.9896038018), COEF_CONST(0.9727589768), COEF_CONST(0.9548355329), COEF_CONST(0.9223070404), COEF_CONST(0.8494349490), COEF_CONST(0.7013005535) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9902068095), COEF_CONST(0.9749613872), COEF_CONST(0.9346538534), COEF_CONST(0.8921231300), COEF_CONST(0.8158851259), COEF_CONST(0.6495964302), COEF_CONST(0.3313370772) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9880510933), COEF_CONST(0.9694670261), COEF_CONST(0.9204347876), COEF_CONST(0.8688622825), COEF_CONST(0.7768516704), COEF_CONST(0.5782161800), COEF_CONST(0.2069970356) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) } |
||||
}; |
||||
|
||||
static const real_t sin_betas_normal[][8] = { |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0900207420), COEF_CONST(-0.1438204281), COEF_CONST(-0.2318188366), COEF_CONST(-0.2971348264), COEF_CONST(-0.3864579191), COEF_CONST(-0.5276933461), COEF_CONST(-0.7128657193) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1396082894), COEF_CONST(-0.2223742196), COEF_CONST(-0.3555589603), COEF_CONST(-0.4517923427), COEF_CONST(-0.5782140273), COEF_CONST(-0.7602792104), COEF_CONST(-0.9435124489) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1541266914), COEF_CONST(-0.2452217065), COEF_CONST(-0.3908961522), COEF_CONST(-0.4950538699), COEF_CONST(-0.6296836366), COEF_CONST(-0.8158836002), COEF_CONST(-0.9783415698) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) } |
||||
}; |
||||
|
||||
static const real_t cos_betas_fine[][8] = { |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9968361371), COEF_CONST(0.9918968104), COEF_CONST(0.9787540479), COEF_CONST(0.9647515190), COEF_CONST(0.9392903010), COEF_CONST(0.8820167114), COEF_CONST(0.7645325390) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9950262915), COEF_CONST(0.9872675041), COEF_CONST(0.9666584578), COEF_CONST(0.9447588606), COEF_CONST(0.9050918405), COEF_CONST(0.8165997379), COEF_CONST(0.6383824796) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9908827998), COEF_CONST(0.9766855904), COEF_CONST(0.9391249214), COEF_CONST(0.8994531782), COEF_CONST(0.8282352693), COEF_CONST(0.6723983174), COEF_CONST(0.3719473225) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9890240165), COEF_CONST(0.9719459866), COEF_CONST(0.9268448110), COEF_CONST(0.8793388536), COEF_CONST(0.7944023271), COEF_CONST(0.6101812098), COEF_CONST(0.2621501145) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9876350461), COEF_CONST(0.9684073447), COEF_CONST(0.9176973944), COEF_CONST(0.8643930070), COEF_CONST(0.7693796058), COEF_CONST(0.5646720713), COEF_CONST(0.1838899556) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9866247085), COEF_CONST(0.9658349704), COEF_CONST(0.9110590761), COEF_CONST(0.8535668048), COEF_CONST(0.7513165426), COEF_CONST(0.5320914819), COEF_CONST(0.1289530943) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9851245614), COEF_CONST(0.9620180268), COEF_CONST(0.9012265590), COEF_CONST(0.8375623272), COEF_CONST(0.7247108045), COEF_CONST(0.4845204297), COEF_CONST(0.0504115003) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9846869856), COEF_CONST(0.9609052357), COEF_CONST(0.8983639533), COEF_CONST(0.8329098386), COEF_CONST(0.7169983441), COEF_CONST(0.4708245354), COEF_CONST(0.0281732509) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9844406325), COEF_CONST(0.9602788522), COEF_CONST(0.8967533934), COEF_CONST(0.8302936455), COEF_CONST(0.7126658102), COEF_CONST(0.4631492839), COEF_CONST(0.0157851140) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9843020502), COEF_CONST(0.9599265269), COEF_CONST(0.8958477331), COEF_CONST(0.8288229094), COEF_CONST(0.7102315840), COEF_CONST(0.4588429315), COEF_CONST(0.0088578059) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9842241136), COEF_CONST(0.9597283916), COEF_CONST(0.8953385094), COEF_CONST(0.8279961409), COEF_CONST(0.7088635748), COEF_CONST(0.4564246834), COEF_CONST(0.0049751355) } |
||||
}; |
||||
|
||||
static const real_t sin_betas_fine[][8] = { |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0794840594), COEF_CONST(-0.1270461238), COEF_CONST(-0.2050378347), COEF_CONST(-0.2631625097), COEF_CONST(-0.3431234916), COEF_CONST(-0.4712181245), COEF_CONST(-0.6445851354) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0996126459), COEF_CONST(-0.1590687758), COEF_CONST(-0.2560691819), COEF_CONST(-0.3277662204), COEF_CONST(-0.4252161335), COEF_CONST(-0.5772043556), COEF_CONST(-0.7697193058) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1347266752), COEF_CONST(-0.2146747714), COEF_CONST(-0.3435758752), COEF_CONST(-0.4370171396), COEF_CONST(-0.5603805303), COEF_CONST(-0.7401895046), COEF_CONST(-0.9282538388) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1477548470), COEF_CONST(-0.2352041647), COEF_CONST(-0.3754446647), COEF_CONST(-0.4761965776), COEF_CONST(-0.6073919186), COEF_CONST(-0.7922618830), COEF_CONST(-0.9650271071) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1567705832), COEF_CONST(-0.2493736450), COEF_CONST(-0.3972801182), COEF_CONST(-0.5028167951), COEF_CONST(-0.6387918458), COEF_CONST(-0.8253153651), COEF_CONST(-0.9829468369) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1630082348), COEF_CONST(-0.2591578860), COEF_CONST(-0.4122758299), COEF_CONST(-0.5209834064), COEF_CONST(-0.6599420072), COEF_CONST(-0.8466868694), COEF_CONST(-0.9916506943) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1718417832), COEF_CONST(-0.2729859267), COEF_CONST(-0.4333482310), COEF_CONST(-0.5463417868), COEF_CONST(-0.6890531546), COEF_CONST(-0.8747799456), COEF_CONST(-0.9987285320) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1743316967), COEF_CONST(-0.2768774604), COEF_CONST(-0.4392518725), COEF_CONST(-0.5534087104), COEF_CONST(-0.6970748701), COEF_CONST(-0.8822268738), COEF_CONST(-0.9996030552) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1757175038), COEF_CONST(-0.2790421580), COEF_CONST(-0.4425306221), COEF_CONST(-0.5573261722), COEF_CONST(-0.7015037013), COEF_CONST(-0.8862802834), COEF_CONST(-0.9998754073) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1764921355), COEF_CONST(-0.2802517850), COEF_CONST(-0.4443611583), COEF_CONST(-0.5595110229), COEF_CONST(-0.7039681080), COEF_CONST(-0.8885173967), COEF_CONST(-0.9999607689) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1769262394), COEF_CONST(-0.2809295540), COEF_CONST(-0.4453862969), COEF_CONST(-0.5607337966), COEF_CONST(-0.7053456119), COEF_CONST(-0.8897620516), COEF_CONST(-0.9999876239) } |
||||
}; |
||||
|
||||
static const real_t sincos_alphas_B_normal[][8] = { |
||||
{ COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, |
||||
{ COEF_CONST(0.1249065138), COEF_CONST(0.1173697697), COEF_CONST(0.1057888284), COEF_CONST(0.0761985131), COEF_CONST(0.0468732723), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103) }, |
||||
{ COEF_CONST(0.1956693050), COEF_CONST(0.1846090179), COEF_CONST(0.1673645109), COEF_CONST(0.1220621836), COEF_CONST(0.0757362479), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630) }, |
||||
{ COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, |
||||
{ COEF_CONST(0.4078449476), COEF_CONST(0.3929852420), COEF_CONST(0.3680589270), COEF_CONST(0.2911029124), COEF_CONST(0.1934512363), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716) }, |
||||
{ COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, |
||||
{ COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, |
||||
{ COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, |
||||
{ COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, |
||||
{ COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, |
||||
{ COEF_CONST(0.9130511848), COEF_CONST(0.9195447612), COEF_CONST(0.9298024282), COEF_CONST(0.9566917233), COEF_CONST(0.9811098801), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928) }, |
||||
{ COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, |
||||
{ COEF_CONST(0.9806699215), COEF_CONST(0.9828120260), COEF_CONST(0.9858950861), COEF_CONST(0.9925224431), COEF_CONST(0.9971278825), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406) }, |
||||
{ COEF_CONST(0.9921685024), COEF_CONST(0.9930882705), COEF_CONST(0.9943886135), COEF_CONST(0.9970926648), COEF_CONST(0.9989008403), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479) }, |
||||
{ COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) } |
||||
}; |
||||
|
||||
static const real_t sincos_alphas_B_fine[][8] = { |
||||
{ COEF_CONST(0.0031622158), COEF_CONST(0.0029630181), COEF_CONST(0.0026599892), COEF_CONST(0.0019002704), COEF_CONST(0.0011626042), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278) }, |
||||
{ COEF_CONST(0.0056232673), COEF_CONST(0.0052689825), COEF_CONST(0.0047302825), COEF_CONST(0.0033791756), COEF_CONST(0.0020674015), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710) }, |
||||
{ COEF_CONST(0.0099994225), COEF_CONST(0.0093696693), COEF_CONST(0.0084117414), COEF_CONST(0.0060093796), COEF_CONST(0.0036766009), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392) }, |
||||
{ COEF_CONST(0.0177799194), COEF_CONST(0.0166607102), COEF_CONST(0.0149581377), COEF_CONST(0.0106875809), COEF_CONST(0.0065392545), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767) }, |
||||
{ COEF_CONST(0.0316069684), COEF_CONST(0.0296211579), COEF_CONST(0.0265987295), COEF_CONST(0.0190113813), COEF_CONST(0.0116349973), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974) }, |
||||
{ COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, |
||||
{ COEF_CONST(0.0791834041), COEF_CONST(0.0742798103), COEF_CONST(0.0667907269), COEF_CONST(0.0478705292), COEF_CONST(0.0293500747), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755) }, |
||||
{ COEF_CONST(0.1115021177), COEF_CONST(0.1047141985), COEF_CONST(0.0943053154), COEF_CONST(0.0678120561), COEF_CONST(0.0416669150), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213) }, |
||||
{ COEF_CONST(0.1565355066), COEF_CONST(0.1473258371), COEF_CONST(0.1330924027), COEF_CONST(0.0963282233), COEF_CONST(0.0594509113), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946) }, |
||||
{ COEF_CONST(0.2184643682), COEF_CONST(0.2064579524), COEF_CONST(0.1876265439), COEF_CONST(0.1375744167), COEF_CONST(0.0856896681), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338) }, |
||||
{ COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, |
||||
{ COEF_CONST(0.3698741335), COEF_CONST(0.3547727297), COEF_CONST(0.3298252076), COEF_CONST(0.2556265829), COEF_CONST(0.1665990017), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541) }, |
||||
{ COEF_CONST(0.4480623975), COEF_CONST(0.4339410024), COEF_CONST(0.4098613774), COEF_CONST(0.3322709108), COEF_CONST(0.2266784729), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131) }, |
||||
{ COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, |
||||
{ COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, |
||||
{ COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, |
||||
{ COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, |
||||
{ COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, |
||||
{ COEF_CONST(0.8940022267), COEF_CONST(0.9009412572), COEF_CONST(0.9121477564), COEF_CONST(0.9431839770), COEF_CONST(0.9739696219), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480) }, |
||||
{ COEF_CONST(0.9290818561), COEF_CONST(0.9349525662), COEF_CONST(0.9440420138), COEF_CONST(0.9667755833), COEF_CONST(0.9860247275), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664) }, |
||||
{ COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, |
||||
{ COEF_CONST(0.9758449068), COEF_CONST(0.9784554646), COEF_CONST(0.9822404252), COEF_CONST(0.9904914275), COEF_CONST(0.9963218730), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926) }, |
||||
{ COEF_CONST(0.9876723320), COEF_CONST(0.9890880155), COEF_CONST(0.9911036356), COEF_CONST(0.9953496173), COEF_CONST(0.9982312259), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685) }, |
||||
{ COEF_CONST(0.9937641889), COEF_CONST(0.9945023501), COEF_CONST(0.9955433130), COEF_CONST(0.9976981117), COEF_CONST(0.9991315558), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610) }, |
||||
{ COEF_CONST(0.9968600642), COEF_CONST(0.9972374385), COEF_CONST(0.9977670024), COEF_CONST(0.9988535464), COEF_CONST(0.9995691924), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129) }, |
||||
{ COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) }, |
||||
{ COEF_CONST(0.9995003746), COEF_CONST(0.9995611974), COEF_CONST(0.9996461891), COEF_CONST(0.9998192657), COEF_CONST(0.9999323103), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475) }, |
||||
{ COEF_CONST(0.9998419236), COEF_CONST(0.9998611991), COEF_CONST(0.9998881193), COEF_CONST(0.9999428861), COEF_CONST(0.9999786185), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045) }, |
||||
{ COEF_CONST(0.9999500038), COEF_CONST(0.9999561034), COEF_CONST(0.9999646206), COEF_CONST(0.9999819429), COEF_CONST(0.9999932409), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750) }, |
||||
{ COEF_CONST(0.9999841890), COEF_CONST(0.9999861183), COEF_CONST(0.9999888121), COEF_CONST(0.9999942902), COEF_CONST(0.9999978628), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605) }, |
||||
{ COEF_CONST(0.9999950000), COEF_CONST(0.9999956102), COEF_CONST(0.9999964621), COEF_CONST(0.9999981945), COEF_CONST(0.9999993242), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875) } |
||||
}; |
||||
|
||||
static const real_t cos_gammas_normal[][8] = { |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9913533967), COEF_CONST(0.9786000177), COEF_CONST(0.9496063381), COEF_CONST(0.9277157252), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9977406278), COEF_CONST(0.9945423840), COEF_CONST(0.9878736667), COEF_CONST(0.9833980494), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9990607067), COEF_CONST(0.9977417734), COEF_CONST(0.9950323970), COEF_CONST(0.9932453273), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) } |
||||
}; |
||||
|
||||
static const real_t cos_gammas_fine[][8] = { |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9899597309), COEF_CONST(0.9750098690), COEF_CONST(0.9402333855), COEF_CONST(0.9129698759), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9926607607), COEF_CONST(0.9819295710), COEF_CONST(0.9580160104), COEF_CONST(0.9404993670), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9972074644), COEF_CONST(0.9932414270), COEF_CONST(0.9849197629), COEF_CONST(0.9792926592), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9985361982), COEF_CONST(0.9964742028), COEF_CONST(0.9922136306), COEF_CONST(0.9893845420), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9992494366), COEF_CONST(0.9981967170), COEF_CONST(0.9960386625), COEF_CONST(0.9946185834), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9996194722), COEF_CONST(0.9990869422), COEF_CONST(0.9979996269), COEF_CONST(0.9972873651), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999390971), COEF_CONST(0.9998540271), COEF_CONST(0.9996809352), COEF_CONST(0.9995679735), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999807170), COEF_CONST(0.9999537862), COEF_CONST(0.9998990191), COEF_CONST(0.9998632947), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999938979), COEF_CONST(0.9999853814), COEF_CONST(0.9999680568), COEF_CONST(0.9999567596), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999980703), COEF_CONST(0.9999953731), COEF_CONST(0.9999898968), COEF_CONST(0.9999863277), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265) }, |
||||
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999993891), COEF_CONST(0.9999985397), COEF_CONST(0.9999968037), COEF_CONST(0.9999956786), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155) } |
||||
}; |
||||
|
||||
static const real_t sin_gammas_normal[][8] = { |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1312190642), COEF_CONST(0.2057717310), COEF_CONST(0.3134450552), COEF_CONST(0.3732874674), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0671836269), COEF_CONST(0.1043333428), COEF_CONST(0.1552598422), COEF_CONST(0.1814615013), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0433324862), COEF_CONST(0.0671666110), COEF_CONST(0.0995516398), COEF_CONST(0.1160332699), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) } |
||||
}; |
||||
|
||||
static const real_t sin_gammas_fine[][8] = { |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1413496768), COEF_CONST(0.2221615526), COEF_CONST(0.3405307340), COEF_CONST(0.4080269669), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1209322714), COEF_CONST(0.1892467110), COEF_CONST(0.2867147079), COEF_CONST(0.3397954394), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0746811420), COEF_CONST(0.1160666523), COEF_CONST(0.1730117353), COEF_CONST(0.2024497161), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0540875291), COEF_CONST(0.0838997203), COEF_CONST(0.1245476266), COEF_CONST(0.1453211203), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0387371058), COEF_CONST(0.0600276114), COEF_CONST(0.0889212171), COEF_CONST(0.1036044086), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0275846110), COEF_CONST(0.0427233177), COEF_CONST(0.0632198125), COEF_CONST(0.0736064637), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0110363955), COEF_CONST(0.0170857974), COEF_CONST(0.0252592108), COEF_CONST(0.0293916021), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0062101284), COEF_CONST(0.0096138203), COEF_CONST(0.0142109649), COEF_CONST(0.0165345659), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0034934509), COEF_CONST(0.0054071189), COEF_CONST(0.0079928316), COEF_CONST(0.0092994041), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0019645397), COEF_CONST(0.0030419905), COEF_CONST(0.0044951511), COEF_CONST(0.0052291853), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498) }, |
||||
{ COEF_CONST(0.0000000000), COEF_CONST(0.0011053943), COEF_CONST(0.0017089869), COEF_CONST(0.0025283670), COEF_CONST(0.0029398552), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685) } |
||||
}; |
||||
|
||||
static const real_t sf_iid_normal[] = { |
||||
COEF_CONST(1.4119827747), COEF_CONST(1.4031381607), COEF_CONST(1.3868767023), |
||||
COEF_CONST(1.3483997583), COEF_CONST(1.2912493944), COEF_CONST(1.1960374117), |
||||
COEF_CONST(1.1073724031), COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), |
||||
COEF_CONST(0.7546485662), COEF_CONST(0.5767799020), COEF_CONST(0.4264014363), |
||||
COEF_CONST(0.2767182887), COEF_CONST(0.1766446233), COEF_CONST(0.0794016272) |
||||
}; |
||||
|
||||
static const real_t sf_iid_fine[] = { |
||||
COEF_CONST(1.4142065048), COEF_CONST(1.4141912460), COEF_CONST(1.4141428471), |
||||
COEF_CONST(1.4139900208), COEF_CONST(1.4135069847), COEF_CONST(1.4119827747), |
||||
COEF_CONST(1.4097729921), COEF_CONST(1.4053947926), COEF_CONST(1.3967796564), |
||||
COEF_CONST(1.3800530434), COEF_CONST(1.3483997583), COEF_CONST(1.3139201403), |
||||
COEF_CONST(1.2643101215), COEF_CONST(1.1960374117), COEF_CONST(1.1073724031), |
||||
COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), COEF_CONST(0.7546485662), |
||||
COEF_CONST(0.6336560845), COEF_CONST(0.5230810642), COEF_CONST(0.4264014363), |
||||
COEF_CONST(0.3089554012), COEF_CONST(0.2213746458), COEF_CONST(0.1576878875), |
||||
COEF_CONST(0.1119822487), COEF_CONST(0.0794016272), COEF_CONST(0.0446990170), |
||||
COEF_CONST(0.0251446925), COEF_CONST(0.0141414283), COEF_CONST(0.0079525812), |
||||
COEF_CONST(0.0044721137) |
||||
}; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,58 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: pulse.c,v 1.21 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include "syntax.h" |
||||
#include "pulse.h" |
||||
|
||||
uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) |
||||
{ |
||||
uint8_t i; |
||||
uint16_t k; |
||||
pulse_info *pul = &(ics->pul); |
||||
|
||||
k = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max); |
||||
|
||||
for (i = 0; i <= pul->number_pulse; i++) |
||||
{ |
||||
k += pul->pulse_offset[i]; |
||||
|
||||
if (k >= framelen) |
||||
return 15; /* should not be possible */ |
||||
|
||||
if (spec_data[k] > 0) |
||||
spec_data[k] += pul->pulse_amp[i]; |
||||
else |
||||
spec_data[k] -= pul->pulse_amp[i]; |
||||
} |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,43 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: pulse.h,v 1.20 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __PULSE_H__ |
||||
#define __PULSE_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,551 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: rvlc.c,v 1.21 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
|
||||
/* RVLC scalefactor decoding
|
||||
* |
||||
* RVLC works like this: |
||||
* 1. Only symmetric huffman codewords are used |
||||
* 2. Total length of the scalefactor data is stored in the bitsream |
||||
* 3. Scalefactors are DPCM coded |
||||
* 4. Next to the starting value for DPCM the ending value is also stored |
||||
* |
||||
* With all this it is possible to read the scalefactor data from 2 sides. |
||||
* If there is a bit error in the scalefactor data it is possible to start |
||||
* decoding from the other end of the data, to find all but 1 scalefactor. |
||||
*/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "syntax.h" |
||||
#include "bits.h" |
||||
#include "rvlc.h" |
||||
|
||||
|
||||
#ifdef ERROR_RESILIENCE |
||||
|
||||
//#define PRINT_RVLC
|
||||
|
||||
/* static function declarations */ |
||||
static uint8_t rvlc_decode_sf_forward(ic_stream *ics, |
||||
bitfile *ld_sf, |
||||
bitfile *ld_esc, |
||||
uint8_t *is_used); |
||||
#if 0 |
||||
static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, |
||||
bitfile *ld_sf, |
||||
bitfile *ld_esc, |
||||
uint8_t is_used); |
||||
#endif |
||||
static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc /*,
|
||||
int8_t direction*/); |
||||
static int8_t rvlc_huffman_esc(bitfile *ld_esc /*, int8_t direction*/); |
||||
|
||||
|
||||
uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld) |
||||
{ |
||||
uint8_t bits = 9; |
||||
|
||||
ics->sf_concealment = faad_get1bit(ld |
||||
DEBUGVAR(1,149,"rvlc_scale_factor_data(): sf_concealment")); |
||||
ics->rev_global_gain = (uint8_t)faad_getbits(ld, 8 |
||||
DEBUGVAR(1,150,"rvlc_scale_factor_data(): rev_global_gain")); |
||||
|
||||
if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) |
||||
bits = 11; |
||||
|
||||
/* the number of bits used for the huffman codewords */ |
||||
ics->length_of_rvlc_sf = (uint16_t)faad_getbits(ld, bits |
||||
DEBUGVAR(1,151,"rvlc_scale_factor_data(): length_of_rvlc_sf")); |
||||
|
||||
if (ics->noise_used) |
||||
{ |
||||
ics->dpcm_noise_nrg = (uint16_t)faad_getbits(ld, 9 |
||||
DEBUGVAR(1,152,"rvlc_scale_factor_data(): dpcm_noise_nrg")); |
||||
|
||||
ics->length_of_rvlc_sf -= 9; |
||||
} |
||||
|
||||
ics->sf_escapes_present = faad_get1bit(ld |
||||
DEBUGVAR(1,153,"rvlc_scale_factor_data(): sf_escapes_present")); |
||||
|
||||
if (ics->sf_escapes_present) |
||||
{ |
||||
ics->length_of_rvlc_escapes = (uint8_t)faad_getbits(ld, 8 |
||||
DEBUGVAR(1,154,"rvlc_scale_factor_data(): length_of_rvlc_escapes")); |
||||
} |
||||
|
||||
if (ics->noise_used) |
||||
{ |
||||
ics->dpcm_noise_last_position = (uint16_t)faad_getbits(ld, 9 |
||||
DEBUGVAR(1,155,"rvlc_scale_factor_data(): dpcm_noise_last_position")); |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld) |
||||
{ |
||||
uint8_t result; |
||||
uint8_t intensity_used = 0; |
||||
uint8_t *rvlc_sf_buffer = NULL; |
||||
uint8_t *rvlc_esc_buffer = NULL; |
||||
bitfile ld_rvlc_sf = {0}, ld_rvlc_esc = {0}; |
||||
// bitfile ld_rvlc_sf_rev, ld_rvlc_esc_rev;
|
||||
|
||||
if (ics->length_of_rvlc_sf > 0) |
||||
{ |
||||
/* We read length_of_rvlc_sf bits here to put it in a
|
||||
seperate bitfile. |
||||
*/ |
||||
rvlc_sf_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_sf |
||||
DEBUGVAR(1,156,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_sf")); |
||||
|
||||
faad_initbits(&ld_rvlc_sf, (void*)rvlc_sf_buffer, bit2byte(ics->length_of_rvlc_sf)); |
||||
// faad_initbits_rev(&ld_rvlc_sf_rev, (void*)rvlc_sf_buffer,
|
||||
// ics->length_of_rvlc_sf);
|
||||
} |
||||
if ((ics->length_of_rvlc_sf == 0) || (ld_rvlc_sf.error != 0)) { |
||||
memset(&ld_rvlc_sf, 0, sizeof(ld_rvlc_sf)); |
||||
ld_rvlc_sf.error = 1; |
||||
} |
||||
|
||||
if (ics->sf_escapes_present) |
||||
{ |
||||
/* We read length_of_rvlc_escapes bits here to put it in a
|
||||
seperate bitfile. |
||||
*/ |
||||
rvlc_esc_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_escapes |
||||
DEBUGVAR(1,157,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_escapes")); |
||||
|
||||
faad_initbits(&ld_rvlc_esc, (void*)rvlc_esc_buffer, bit2byte(ics->length_of_rvlc_escapes)); |
||||
// faad_initbits_rev(&ld_rvlc_esc_rev, (void*)rvlc_esc_buffer,
|
||||
// ics->length_of_rvlc_escapes);
|
||||
} |
||||
if (!ics->sf_escapes_present || (ld_rvlc_esc.error != 0)) { |
||||
memset(&ld_rvlc_esc, 0, sizeof(ld_rvlc_esc)); |
||||
ld_rvlc_esc.error = 1; |
||||
} |
||||
|
||||
/* decode the rvlc scale factors and escapes */ |
||||
result = rvlc_decode_sf_forward(ics, &ld_rvlc_sf, |
||||
&ld_rvlc_esc, &intensity_used); |
||||
// result = rvlc_decode_sf_reverse(ics, &ld_rvlc_sf_rev,
|
||||
// &ld_rvlc_esc_rev, intensity_used);
|
||||
|
||||
|
||||
if (rvlc_esc_buffer) faad_free(rvlc_esc_buffer); |
||||
if (rvlc_sf_buffer) faad_free(rvlc_sf_buffer); |
||||
|
||||
if (ics->length_of_rvlc_sf > 0) |
||||
faad_endbits(&ld_rvlc_sf); |
||||
if (ics->sf_escapes_present) |
||||
faad_endbits(&ld_rvlc_esc); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, |
||||
uint8_t *intensity_used) |
||||
{ |
||||
int8_t g, sfb; |
||||
int8_t t = 0; |
||||
int8_t error = ld_sf->error | ld_esc->error; |
||||
int8_t noise_pcm_flag = 1; |
||||
|
||||
int16_t scale_factor = ics->global_gain; |
||||
int16_t is_position = 0; |
||||
int16_t noise_energy = ics->global_gain - 90 - 256; |
||||
int16_t scale_factor_max = 255; |
||||
#ifdef FIXED_POINT |
||||
/* TODO: consider rolling out to regular build. */ |
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
||||
/* The value is inexact, adjusted to current fuzzer findings. */ |
||||
scale_factor_max = 165; |
||||
#endif // FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
#endif // FIXED_POINT
|
||||
|
||||
#ifdef PRINT_RVLC |
||||
printf("\nglobal_gain: %d\n", ics->global_gain); |
||||
#endif |
||||
|
||||
for (g = 0; g < ics->num_window_groups; g++) |
||||
{ |
||||
for (sfb = 0; sfb < ics->max_sfb; sfb++) |
||||
{ |
||||
if (error) |
||||
{ |
||||
ics->scale_factors[g][sfb] = 0; |
||||
} else { |
||||
switch (ics->sfb_cb[g][sfb]) |
||||
{ |
||||
case ZERO_HCB: /* zero book */ |
||||
ics->scale_factors[g][sfb] = 0; |
||||
break; |
||||
case INTENSITY_HCB: /* intensity books */ |
||||
case INTENSITY_HCB2: |
||||
|
||||
*intensity_used = 1; |
||||
|
||||
/* decode intensity position */ |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc /*, +1*/); |
||||
|
||||
is_position += t; |
||||
ics->scale_factors[g][sfb] = is_position; |
||||
|
||||
break; |
||||
case NOISE_HCB: /* noise books */ |
||||
|
||||
/* decode noise energy */ |
||||
if (noise_pcm_flag) |
||||
{ |
||||
int16_t n = ics->dpcm_noise_nrg; |
||||
noise_pcm_flag = 0; |
||||
noise_energy += n; |
||||
} else { |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc /*, +1*/); |
||||
noise_energy += t; |
||||
} |
||||
|
||||
ics->scale_factors[g][sfb] = noise_energy; |
||||
|
||||
break; |
||||
default: /* spectral books */ |
||||
|
||||
/* decode scale factor */ |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc /*, +1*/); |
||||
|
||||
scale_factor += t; |
||||
if (scale_factor < 0 || scale_factor > 255) |
||||
return 4; |
||||
|
||||
ics->scale_factors[g][sfb] = min(scale_factor, scale_factor_max); |
||||
|
||||
break; |
||||
} |
||||
#ifdef PRINT_RVLC |
||||
printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], |
||||
ics->scale_factors[g][sfb]); |
||||
#endif |
||||
if (t == 99) |
||||
{ |
||||
error = 1; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
#ifdef PRINT_RVLC |
||||
printf("\n\n"); |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#if 0 // not used right now, doesn't work correctly yet
|
||||
static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, |
||||
uint8_t intensity_used) |
||||
{ |
||||
int8_t g, sfb; |
||||
int8_t t = 0; |
||||
int8_t error = 0; |
||||
int8_t noise_pcm_flag = 1, is_pcm_flag = 1, sf_pcm_flag = 1; |
||||
|
||||
int16_t scale_factor = ics->rev_global_gain; |
||||
int16_t is_position = 0; |
||||
int16_t noise_energy = ics->rev_global_gain; |
||||
|
||||
#ifdef PRINT_RVLC |
||||
printf("\nrev_global_gain: %d\n", ics->rev_global_gain); |
||||
#endif |
||||
|
||||
if (intensity_used) |
||||
{ |
||||
is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1); |
||||
#ifdef PRINT_RVLC |
||||
printf("is_position: %d\n", is_position); |
||||
#endif |
||||
} |
||||
|
||||
for (g = ics->num_window_groups-1; g >= 0; g--) |
||||
{ |
||||
for (sfb = ics->max_sfb-1; sfb >= 0; sfb--) |
||||
{ |
||||
if (error) |
||||
{ |
||||
ics->scale_factors[g][sfb] = 0; |
||||
} else { |
||||
switch (ics->sfb_cb[g][sfb]) |
||||
{ |
||||
case ZERO_HCB: /* zero book */ |
||||
ics->scale_factors[g][sfb] = 0; |
||||
break; |
||||
case INTENSITY_HCB: /* intensity books */ |
||||
case INTENSITY_HCB2: |
||||
|
||||
if (is_pcm_flag) |
||||
{ |
||||
is_pcm_flag = 0; |
||||
ics->scale_factors[g][sfb] = is_position; |
||||
} else { |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc, -1); |
||||
is_position -= t; |
||||
|
||||
ics->scale_factors[g][sfb] = (uint8_t)is_position; |
||||
} |
||||
break; |
||||
case NOISE_HCB: /* noise books */ |
||||
|
||||
/* decode noise energy */ |
||||
if (noise_pcm_flag) |
||||
{ |
||||
noise_pcm_flag = 0; |
||||
noise_energy = ics->dpcm_noise_last_position; |
||||
} else { |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc, -1); |
||||
noise_energy -= t; |
||||
} |
||||
|
||||
ics->scale_factors[g][sfb] = (uint8_t)noise_energy; |
||||
break; |
||||
default: /* spectral books */ |
||||
|
||||
if (sf_pcm_flag || (sfb == 0)) |
||||
{ |
||||
sf_pcm_flag = 0; |
||||
if (sfb == 0) |
||||
scale_factor = ics->global_gain; |
||||
} else { |
||||
/* decode scale factor */ |
||||
t = rvlc_huffman_sf(ld_sf, ld_esc, -1); |
||||
scale_factor -= t; |
||||
} |
||||
|
||||
if (scale_factor < 0) |
||||
return 4; |
||||
|
||||
ics->scale_factors[g][sfb] = (uint8_t)scale_factor; |
||||
break; |
||||
} |
||||
#ifdef PRINT_RVLC |
||||
printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], |
||||
ics->scale_factors[g][sfb]); |
||||
#endif |
||||
if (t == 99) |
||||
{ |
||||
error = 1; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#ifdef PRINT_RVLC |
||||
printf("\n\n"); |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
#endif |
||||
|
||||
/* index == 99 means not allowed codeword */ |
||||
static rvlc_huff_table book_rvlc[] = { |
||||
/*index length codeword */ |
||||
{ 0, 1, 0 }, /* 0 */ |
||||
{ -1, 3, 5 }, /* 101 */ |
||||
{ 1, 3, 7 }, /* 111 */ |
||||
{ -2, 4, 9 }, /* 1001 */ |
||||
{ -3, 5, 17 }, /* 10001 */ |
||||
{ 2, 5, 27 }, /* 11011 */ |
||||
{ -4, 6, 33 }, /* 100001 */ |
||||
{ 99, 6, 50 }, /* 110010 */ |
||||
{ 3, 6, 51 }, /* 110011 */ |
||||
{ 99, 6, 52 }, /* 110100 */ |
||||
{ -7, 7, 65 }, /* 1000001 */ |
||||
{ 99, 7, 96 }, /* 1100000 */ |
||||
{ 99, 7, 98 }, /* 1100010 */ |
||||
{ 7, 7, 99 }, /* 1100011 */ |
||||
{ 4, 7, 107 }, /* 1101011 */ |
||||
{ -5, 8, 129 }, /* 10000001 */ |
||||
{ 99, 8, 194 }, /* 11000010 */ |
||||
{ 5, 8, 195 }, /* 11000011 */ |
||||
{ 99, 8, 212 }, /* 11010100 */ |
||||
{ 99, 9, 256 }, /* 100000000 */ |
||||
{ -6, 9, 257 }, /* 100000001 */ |
||||
{ 99, 9, 426 }, /* 110101010 */ |
||||
{ 6, 9, 427 }, /* 110101011 */ |
||||
{ 99, 10, 0 } /* Shouldn't come this far */ |
||||
}; |
||||
|
||||
static rvlc_huff_table book_escape[] = { |
||||
/*index length codeword */ |
||||
{ 1, 2, 0 }, |
||||
{ 0, 2, 2 }, |
||||
{ 3, 3, 2 }, |
||||
{ 2, 3, 6 }, |
||||
{ 4, 4, 14 }, |
||||
{ 7, 5, 13 }, |
||||
{ 6, 5, 15 }, |
||||
{ 5, 5, 31 }, |
||||
{ 11, 6, 24 }, |
||||
{ 10, 6, 25 }, |
||||
{ 9, 6, 29 }, |
||||
{ 8, 6, 61 }, |
||||
{ 13, 7, 56 }, |
||||
{ 12, 7, 120 }, |
||||
{ 15, 8, 114 }, |
||||
{ 14, 8, 242 }, |
||||
{ 17, 9, 230 }, |
||||
{ 16, 9, 486 }, |
||||
{ 19, 10, 463 }, |
||||
{ 18, 10, 974 }, |
||||
{ 22, 11, 925 }, |
||||
{ 20, 11, 1950 }, |
||||
{ 21, 11, 1951 }, |
||||
{ 23, 12, 1848 }, |
||||
{ 25, 13, 3698 }, |
||||
{ 24, 14, 7399 }, |
||||
{ 26, 15, 14797 }, |
||||
{ 49, 19, 236736 }, |
||||
{ 50, 19, 236737 }, |
||||
{ 51, 19, 236738 }, |
||||
{ 52, 19, 236739 }, |
||||
{ 53, 19, 236740 }, |
||||
{ 27, 20, 473482 }, |
||||
{ 28, 20, 473483 }, |
||||
{ 29, 20, 473484 }, |
||||
{ 30, 20, 473485 }, |
||||
{ 31, 20, 473486 }, |
||||
{ 32, 20, 473487 }, |
||||
{ 33, 20, 473488 }, |
||||
{ 34, 20, 473489 }, |
||||
{ 35, 20, 473490 }, |
||||
{ 36, 20, 473491 }, |
||||
{ 37, 20, 473492 }, |
||||
{ 38, 20, 473493 }, |
||||
{ 39, 20, 473494 }, |
||||
{ 40, 20, 473495 }, |
||||
{ 41, 20, 473496 }, |
||||
{ 42, 20, 473497 }, |
||||
{ 43, 20, 473498 }, |
||||
{ 44, 20, 473499 }, |
||||
{ 45, 20, 473500 }, |
||||
{ 46, 20, 473501 }, |
||||
{ 47, 20, 473502 }, |
||||
{ 48, 20, 473503 }, |
||||
{ 99, 21, 0 } /* Shouldn't come this far */ |
||||
}; |
||||
|
||||
static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc /*,
|
||||
int8_t direction*/) |
||||
{ |
||||
uint16_t i, j; |
||||
int16_t index; |
||||
uint32_t cw; |
||||
rvlc_huff_table *h = book_rvlc; |
||||
int8_t direction = +1; |
||||
|
||||
i = h->len; |
||||
if (direction > 0) |
||||
cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,"")); |
||||
else |
||||
cw = 0 /* faad_getbits_rev(ld_sf, i DEBUGVAR(1,0,"")) */; |
||||
|
||||
while ((cw != h->cw) |
||||
&& (i < 10)) |
||||
{ |
||||
h++; |
||||
j = h->len-i; |
||||
i += j; |
||||
cw <<= j; |
||||
if (direction > 0) |
||||
cw |= faad_getbits(ld_sf, j DEBUGVAR(1,0,"")); |
||||
else |
||||
cw |= 0 /* faad_getbits_rev(ld_sf, j DEBUGVAR(1,0,"")) */; |
||||
} |
||||
|
||||
index = h->index; |
||||
|
||||
if (index == +ESC_VAL) |
||||
{ |
||||
int8_t esc = rvlc_huffman_esc(ld_esc /*, direction*/); |
||||
if (esc == 99) |
||||
return 99; |
||||
index += esc; |
||||
#ifdef PRINT_RVLC |
||||
printf("esc: %d - ", esc); |
||||
#endif |
||||
} |
||||
if (index == -ESC_VAL) |
||||
{ |
||||
int8_t esc = rvlc_huffman_esc(ld_esc /*, direction*/); |
||||
if (esc == 99) |
||||
return 99; |
||||
index -= esc; |
||||
#ifdef PRINT_RVLC |
||||
printf("esc: %d - ", esc); |
||||
#endif |
||||
} |
||||
|
||||
return (int8_t)index; |
||||
} |
||||
|
||||
static int8_t rvlc_huffman_esc(bitfile *ld /*,
|
||||
int8_t direction*/) |
||||
{ |
||||
uint16_t i, j; |
||||
uint32_t cw; |
||||
rvlc_huff_table *h = book_escape; |
||||
int8_t direction = +1; |
||||
|
||||
i = h->len; |
||||
if (direction > 0) |
||||
cw = faad_getbits(ld, i DEBUGVAR(1,0,"")); |
||||
else |
||||
cw = 0 /* faad_getbits_rev(ld, i DEBUGVAR(1,0,"")) */; |
||||
|
||||
while ((cw != h->cw) |
||||
&& (i < 21)) |
||||
{ |
||||
h++; |
||||
j = h->len-i; |
||||
i += j; |
||||
cw <<= j; |
||||
if (direction > 0) |
||||
cw |= faad_getbits(ld, j DEBUGVAR(1,0,"")); |
||||
else |
||||
cw |= 0 /* faad_getbits_rev(ld, j DEBUGVAR(1,0,"")) */; |
||||
} |
||||
|
||||
return (int8_t)h->index; |
||||
} |
||||
|
||||
#endif |
||||
|
@ -0,0 +1,56 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: rvlc.h,v 1.17 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __RVLC_SCF_H__ |
||||
#define __RVLC_SCF_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
typedef struct |
||||
{ |
||||
int16_t index; |
||||
uint16_t len; |
||||
uint32_t cw; |
||||
} rvlc_huff_table; |
||||
|
||||
|
||||
#define ESC_VAL 7 |
||||
|
||||
|
||||
uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld); |
||||
uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,52 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_dct.h,v 1.19 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __SBR_DCT_H__ |
||||
#define __SBR_DCT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag); |
||||
|
||||
void DCT3_32_unscaled(real_t *y, real_t *x); |
||||
void DCT4_32(real_t *y, real_t *x); |
||||
void DST4_32(real_t *y, real_t *x); |
||||
void DCT2_32_unscaled(real_t *y, real_t *x); |
||||
void DCT4_16(real_t *y, real_t *x); |
||||
void DCT2_16_unscaled(real_t *y, real_t *x); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,698 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_dec.c,v 1.44 2009/01/26 22:32:31 menno Exp $ |
||||
**/ |
||||
|
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#ifdef SBR_DEC |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "syntax.h" |
||||
#include "bits.h" |
||||
#include "sbr_syntax.h" |
||||
#include "sbr_qmf.h" |
||||
#include "sbr_hfgen.h" |
||||
#include "sbr_hfadj.h" |
||||
|
||||
|
||||
/* static function declarations */ |
||||
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); |
||||
static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); |
||||
|
||||
#define INVALID ((uint8_t)-1) |
||||
|
||||
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, |
||||
uint32_t sample_rate, uint8_t downSampledSBR |
||||
#ifdef DRM |
||||
, uint8_t IsDRM |
||||
#endif |
||||
) |
||||
{ |
||||
sbr_info *sbr = faad_malloc(sizeof(sbr_info)); |
||||
memset(sbr, 0, sizeof(sbr_info)); |
||||
|
||||
/* save id of the parent element */ |
||||
sbr->id_aac = id_aac; |
||||
sbr->sample_rate = sample_rate; |
||||
|
||||
sbr->bs_freq_scale = 2; |
||||
sbr->bs_alter_scale = 1; |
||||
sbr->bs_noise_bands = 2; |
||||
sbr->bs_limiter_bands = 2; |
||||
sbr->bs_limiter_gains = 2; |
||||
sbr->bs_interpol_freq = 1; |
||||
sbr->bs_smoothing_mode = 1; |
||||
sbr->bs_start_freq = 5; |
||||
sbr->bs_amp_res = 1; |
||||
sbr->bs_samplerate_mode = 1; |
||||
sbr->prevEnvIsShort[0] = -1; |
||||
sbr->prevEnvIsShort[1] = -1; |
||||
sbr->header_count = 0; |
||||
sbr->Reset = 1; |
||||
|
||||
#ifdef DRM |
||||
sbr->Is_DRM_SBR = IsDRM; |
||||
#endif |
||||
sbr->tHFGen = T_HFGEN; |
||||
sbr->tHFAdj = T_HFADJ; |
||||
|
||||
sbr->bsco = 0; |
||||
sbr->bsco_prev = 0; |
||||
sbr->M_prev = 0; |
||||
sbr->frame_len = framelength; |
||||
|
||||
/* force sbr reset */ |
||||
sbr->bs_start_freq_prev = INVALID; |
||||
|
||||
if (framelength == 960) |
||||
{ |
||||
sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; |
||||
sbr->numTimeSlots = NO_TIME_SLOTS_960; |
||||
} |
||||
else if (framelength == 1024) |
||||
{ |
||||
sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; |
||||
sbr->numTimeSlots = NO_TIME_SLOTS; |
||||
} |
||||
else |
||||
{ |
||||
faad_free(sbr); |
||||
return NULL; |
||||
} |
||||
|
||||
sbr->GQ_ringbuf_index[0] = 0; |
||||
sbr->GQ_ringbuf_index[1] = 0; |
||||
|
||||
if (id_aac == ID_CPE) |
||||
{ |
||||
/* stereo */ |
||||
uint8_t j; |
||||
sbr->qmfa[0] = qmfa_init(32); |
||||
sbr->qmfa[1] = qmfa_init(32); |
||||
sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); |
||||
sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); |
||||
|
||||
for (j = 0; j < 5; j++) |
||||
{ |
||||
sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
||||
sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); |
||||
sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
||||
sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); |
||||
} |
||||
|
||||
memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
||||
memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
||||
} else { |
||||
/* mono */ |
||||
uint8_t j; |
||||
sbr->qmfa[0] = qmfa_init(32); |
||||
sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); |
||||
sbr->qmfs[1] = NULL; |
||||
|
||||
for (j = 0; j < 5; j++) |
||||
{ |
||||
sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
||||
sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
||||
} |
||||
|
||||
memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
||||
} |
||||
|
||||
return sbr; |
||||
} |
||||
|
||||
void sbrDecodeEnd(sbr_info *sbr) |
||||
{ |
||||
uint8_t j; |
||||
|
||||
if (sbr) |
||||
{ |
||||
qmfa_end(sbr->qmfa[0]); |
||||
qmfs_end(sbr->qmfs[0]); |
||||
if (sbr->qmfs[1] != NULL) |
||||
{ |
||||
qmfa_end(sbr->qmfa[1]); |
||||
qmfs_end(sbr->qmfs[1]); |
||||
} |
||||
|
||||
for (j = 0; j < 5; j++) |
||||
{ |
||||
if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]); |
||||
if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]); |
||||
if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]); |
||||
if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]); |
||||
} |
||||
|
||||
#ifdef PS_DEC |
||||
if (sbr->ps != NULL) |
||||
ps_free(sbr->ps); |
||||
#endif |
||||
|
||||
#ifdef DRM_PS |
||||
if (sbr->drm_ps != NULL) |
||||
drm_ps_free(sbr->drm_ps); |
||||
#endif |
||||
|
||||
faad_free(sbr); |
||||
} |
||||
} |
||||
|
||||
void sbrReset(sbr_info *sbr) |
||||
{ |
||||
uint8_t j; |
||||
if (sbr->qmfa[0] != NULL) |
||||
memset(sbr->qmfa[0]->x, 0, 2 * sbr->qmfa[0]->channels * 10 * sizeof(real_t)); |
||||
if (sbr->qmfa[1] != NULL) |
||||
memset(sbr->qmfa[1]->x, 0, 2 * sbr->qmfa[1]->channels * 10 * sizeof(real_t)); |
||||
if (sbr->qmfs[0] != NULL) |
||||
memset(sbr->qmfs[0]->v, 0, 2 * sbr->qmfs[0]->channels * 20 * sizeof(real_t)); |
||||
if (sbr->qmfs[1] != NULL) |
||||
memset(sbr->qmfs[1]->v, 0, 2 * sbr->qmfs[1]->channels * 20 * sizeof(real_t)); |
||||
|
||||
for (j = 0; j < 5; j++) |
||||
{ |
||||
if (sbr->G_temp_prev[0][j] != NULL) |
||||
memset(sbr->G_temp_prev[0][j], 0, 64*sizeof(real_t)); |
||||
if (sbr->G_temp_prev[1][j] != NULL) |
||||
memset(sbr->G_temp_prev[1][j], 0, 64*sizeof(real_t)); |
||||
if (sbr->Q_temp_prev[0][j] != NULL) |
||||
memset(sbr->Q_temp_prev[0][j], 0, 64*sizeof(real_t)); |
||||
if (sbr->Q_temp_prev[1][j] != NULL) |
||||
memset(sbr->Q_temp_prev[1][j], 0, 64*sizeof(real_t)); |
||||
} |
||||
|
||||
memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
||||
memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
||||
|
||||
sbr->GQ_ringbuf_index[0] = 0; |
||||
sbr->GQ_ringbuf_index[1] = 0; |
||||
sbr->header_count = 0; |
||||
sbr->Reset = 1; |
||||
|
||||
sbr->L_E_prev[0] = 0; |
||||
sbr->L_E_prev[1] = 0; |
||||
sbr->bs_freq_scale = 2; |
||||
sbr->bs_alter_scale = 1; |
||||
sbr->bs_noise_bands = 2; |
||||
sbr->bs_limiter_bands = 2; |
||||
sbr->bs_limiter_gains = 2; |
||||
sbr->bs_interpol_freq = 1; |
||||
sbr->bs_smoothing_mode = 1; |
||||
sbr->bs_start_freq = 5; |
||||
sbr->bs_amp_res = 1; |
||||
sbr->bs_samplerate_mode = 1; |
||||
sbr->prevEnvIsShort[0] = -1; |
||||
sbr->prevEnvIsShort[1] = -1; |
||||
sbr->bsco = 0; |
||||
sbr->bsco_prev = 0; |
||||
sbr->M_prev = 0; |
||||
sbr->bs_start_freq_prev = INVALID; |
||||
|
||||
sbr->f_prev[0] = 0; |
||||
sbr->f_prev[1] = 0; |
||||
for (j = 0; j < MAX_M; j++) |
||||
{ |
||||
sbr->E_prev[0][j] = 0; |
||||
sbr->Q_prev[0][j] = 0; |
||||
sbr->E_prev[1][j] = 0; |
||||
sbr->Q_prev[1][j] = 0; |
||||
sbr->bs_add_harmonic_prev[0][j] = 0; |
||||
sbr->bs_add_harmonic_prev[1][j] = 0; |
||||
} |
||||
sbr->bs_add_harmonic_flag_prev[0] = 0; |
||||
sbr->bs_add_harmonic_flag_prev[1] = 0; |
||||
} |
||||
|
||||
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) |
||||
{ |
||||
uint8_t i; |
||||
|
||||
/* save data for next frame */ |
||||
sbr->kx_prev = sbr->kx; |
||||
sbr->M_prev = sbr->M; |
||||
sbr->bsco_prev = sbr->bsco; |
||||
|
||||
sbr->L_E_prev[ch] = sbr->L_E[ch]; |
||||
|
||||
/* sbr->L_E[ch] can become 0 on files with bit errors */ |
||||
if (sbr->L_E[ch] <= 0) |
||||
return 19; |
||||
|
||||
sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; |
||||
for (i = 0; i < MAX_M; i++) |
||||
{ |
||||
sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; |
||||
sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; |
||||
} |
||||
|
||||
for (i = 0; i < MAX_M; i++) |
||||
{ |
||||
sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i]; |
||||
} |
||||
sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch]; |
||||
|
||||
if (sbr->l_A[ch] == sbr->L_E[ch]) |
||||
sbr->prevEnvIsShort[ch] = 0; |
||||
else |
||||
sbr->prevEnvIsShort[ch] = -1; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) |
||||
{ |
||||
uint8_t i; |
||||
|
||||
for (i = 0; i < sbr->tHFGen; i++) |
||||
{ |
||||
memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); |
||||
} |
||||
for (i = sbr->tHFGen; i < MAX_NTSRHFG; i++) |
||||
{ |
||||
memset(sbr->Xsbr[ch][i], 0, 64 * sizeof(qmf_t)); |
||||
} |
||||
} |
||||
|
||||
static uint8_t sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], |
||||
uint8_t ch, uint8_t dont_process, |
||||
const uint8_t downSampledSBR) |
||||
{ |
||||
int16_t k, l; |
||||
uint8_t ret = 0; |
||||
(void)downSampledSBR; /* TODO: remove parameter? */ |
||||
|
||||
#ifdef SBR_LOW_POWER |
||||
ALIGN real_t deg[64]; |
||||
#endif |
||||
|
||||
#ifdef DRM |
||||
if (sbr->Is_DRM_SBR) |
||||
{ |
||||
sbr->bsco = (uint8_t)max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0); |
||||
} else { |
||||
#endif |
||||
sbr->bsco = 0; |
||||
#ifdef DRM |
||||
} |
||||
#endif |
||||
|
||||
|
||||
//#define PRE_QMF_PRINT
|
||||
#ifdef PRE_QMF_PRINT |
||||
{ |
||||
int i; |
||||
for (i = 0; i < 1024; i++) |
||||
{ |
||||
printf("%d\n", channel_buf[i]); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
|
||||
/* subband analysis */ |
||||
if (dont_process) |
||||
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); |
||||
else |
||||
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); |
||||
|
||||
if (!dont_process) |
||||
{ |
||||
#if 1 |
||||
/* insert high frequencies here */ |
||||
/* hf generation using patching */ |
||||
hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch] |
||||
#ifdef SBR_LOW_POWER |
||||
,deg |
||||
#endif |
||||
,ch); |
||||
#endif |
||||
|
||||
#if 0 //def SBR_LOW_POWER
|
||||
for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) |
||||
{ |
||||
for (k = 0; k < sbr->kx; k++) |
||||
{ |
||||
QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
#if 1 |
||||
/* hf adjustment */ |
||||
ret = hf_adjustment(sbr, sbr->Xsbr[ch] |
||||
#ifdef SBR_LOW_POWER |
||||
,deg |
||||
#endif |
||||
,ch); |
||||
#endif |
||||
if (ret > 0) |
||||
{ |
||||
dont_process = 1; |
||||
} |
||||
} |
||||
|
||||
if ((sbr->just_seeked != 0) || dont_process) |
||||
{ |
||||
for (l = 0; l < sbr->numTimeSlotsRate; l++) |
||||
{ |
||||
for (k = 0; k < 32; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
#ifndef SBR_LOW_POWER |
||||
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
#endif |
||||
} |
||||
for (k = 32; k < 64; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = 0; |
||||
#ifndef SBR_LOW_POWER |
||||
QMF_IM(X[l][k]) = 0; |
||||
#endif |
||||
} |
||||
} |
||||
} else { |
||||
for (l = 0; l < sbr->numTimeSlotsRate; l++) |
||||
{ |
||||
uint8_t kx_band, M_band, bsco_band; |
||||
|
||||
if (l < sbr->t_E[ch][0]) |
||||
{ |
||||
kx_band = sbr->kx_prev; |
||||
M_band = sbr->M_prev; |
||||
bsco_band = sbr->bsco_prev; |
||||
} else { |
||||
kx_band = sbr->kx; |
||||
M_band = sbr->M; |
||||
bsco_band = sbr->bsco; |
||||
} |
||||
|
||||
#ifndef SBR_LOW_POWER |
||||
for (k = 0; k < kx_band + bsco_band; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
} |
||||
for (k = kx_band + bsco_band; k < kx_band + M_band; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
} |
||||
for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = 0; |
||||
QMF_IM(X[l][k]) = 0; |
||||
} |
||||
#else |
||||
for (k = 0; k < kx_band + bsco_band; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
} |
||||
for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
||||
} |
||||
for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) |
||||
{ |
||||
QMF_RE(X[l][k]) = 0; |
||||
} |
||||
QMF_RE(X[l][kx_band - 1 + bsco_band]) += |
||||
QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]); |
||||
#endif |
||||
} |
||||
} |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR) |
||||
{ |
||||
uint8_t dont_process = 0; |
||||
uint8_t ret = 0; |
||||
ALIGN qmf_t X[MAX_NTSRHFG][64]; |
||||
|
||||
if (sbr == NULL) |
||||
return 20; |
||||
|
||||
/* case can occur due to bit errors */ |
||||
if (sbr->id_aac != ID_CPE) |
||||
return 21; |
||||
|
||||
if (sbr->ret || (sbr->header_count == 0)) |
||||
{ |
||||
/* don't process just upsample */ |
||||
dont_process = 1; |
||||
|
||||
/* Re-activate reset for next frame */ |
||||
if (sbr->ret && sbr->Reset) |
||||
sbr->bs_start_freq_prev = INVALID; |
||||
} |
||||
|
||||
if (just_seeked) |
||||
{ |
||||
sbr->just_seeked = 1; |
||||
} else { |
||||
sbr->just_seeked = 0; |
||||
} |
||||
|
||||
sbr->ret += sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR); |
||||
/* subband synthesis */ |
||||
if (downSampledSBR) |
||||
{ |
||||
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, left_chan); |
||||
} else { |
||||
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan); |
||||
} |
||||
|
||||
sbr->ret += sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR); |
||||
/* subband synthesis */ |
||||
if (downSampledSBR) |
||||
{ |
||||
sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X, right_chan); |
||||
} else { |
||||
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, right_chan); |
||||
} |
||||
|
||||
if (sbr->bs_header_flag) |
||||
sbr->just_seeked = 0; |
||||
|
||||
if (sbr->header_count != 0 && sbr->ret == 0) |
||||
{ |
||||
ret = sbr_save_prev_data(sbr, 0); |
||||
if (ret) return ret; |
||||
ret = sbr_save_prev_data(sbr, 1); |
||||
if (ret) return ret; |
||||
} |
||||
|
||||
sbr_save_matrix(sbr, 0); |
||||
sbr_save_matrix(sbr, 1); |
||||
|
||||
sbr->frame++; |
||||
|
||||
//#define POST_QMF_PRINT
|
||||
#ifdef POST_QMF_PRINT |
||||
{ |
||||
int i; |
||||
for (i = 0; i < 2048; i++) |
||||
{ |
||||
printf("%d\n", left_chan[i]); |
||||
} |
||||
for (i = 0; i < 2048; i++) |
||||
{ |
||||
printf("%d\n", right_chan[i]); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR) |
||||
{ |
||||
uint8_t dont_process = 0; |
||||
uint8_t ret = 0; |
||||
ALIGN qmf_t X[MAX_NTSRHFG][64]; |
||||
|
||||
if (sbr == NULL) |
||||
return 20; |
||||
|
||||
/* case can occur due to bit errors */ |
||||
if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) |
||||
return 21; |
||||
|
||||
if (sbr->ret || (sbr->header_count == 0)) |
||||
{ |
||||
/* don't process just upsample */ |
||||
dont_process = 1; |
||||
|
||||
/* Re-activate reset for next frame */ |
||||
if (sbr->ret && sbr->Reset) |
||||
sbr->bs_start_freq_prev = INVALID; |
||||
} |
||||
|
||||
if (just_seeked) |
||||
{ |
||||
sbr->just_seeked = 1; |
||||
} else { |
||||
sbr->just_seeked = 0; |
||||
} |
||||
|
||||
sbr->ret += sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR); |
||||
/* subband synthesis */ |
||||
if (downSampledSBR) |
||||
{ |
||||
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, channel); |
||||
} else { |
||||
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, channel); |
||||
} |
||||
|
||||
if (sbr->bs_header_flag) |
||||
sbr->just_seeked = 0; |
||||
|
||||
if (sbr->header_count != 0 && sbr->ret == 0) |
||||
{ |
||||
ret = sbr_save_prev_data(sbr, 0); |
||||
if (ret) return ret; |
||||
} |
||||
|
||||
sbr_save_matrix(sbr, 0); |
||||
|
||||
sbr->frame++; |
||||
|
||||
//#define POST_QMF_PRINT
|
||||
#ifdef POST_QMF_PRINT |
||||
{ |
||||
int i; |
||||
for (i = 0; i < 2048; i++) |
||||
{ |
||||
printf("%d\n", channel[i]); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#if (defined(PS_DEC) || defined(DRM_PS)) |
||||
uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR) |
||||
{ |
||||
uint8_t l, k; |
||||
uint8_t dont_process = 0; |
||||
uint8_t ret = 0; |
||||
ALIGN qmf_t X_left[MAX_NTSRHFG][64] = {{{0}}}; |
||||
ALIGN qmf_t X_right[MAX_NTSRHFG][64] = {{{0}}}; /* must set this to 0 */ |
||||
|
||||
if (sbr == NULL) |
||||
return 20; |
||||
|
||||
/* case can occur due to bit errors */ |
||||
if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) |
||||
return 21; |
||||
|
||||
if (sbr->ret || (sbr->header_count == 0)) |
||||
{ |
||||
/* don't process just upsample */ |
||||
dont_process = 1; |
||||
|
||||
/* Re-activate reset for next frame */ |
||||
if (sbr->ret && sbr->Reset) |
||||
sbr->bs_start_freq_prev = INVALID; |
||||
} |
||||
|
||||
if (just_seeked) |
||||
{ |
||||
sbr->just_seeked = 1; |
||||
} else { |
||||
sbr->just_seeked = 0; |
||||
} |
||||
|
||||
if (sbr->qmfs[1] == NULL) |
||||
{ |
||||
sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); |
||||
} |
||||
|
||||
sbr->ret += sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); |
||||
|
||||
/* copy some extra data for PS */ |
||||
for (l = sbr->numTimeSlotsRate; l < sbr->numTimeSlotsRate + 6; l++) |
||||
{ |
||||
for (k = 0; k < 5; k++) |
||||
{ |
||||
QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
||||
QMF_IM(X_left[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
||||
} |
||||
} |
||||
|
||||
/* perform parametric stereo */ |
||||
#ifdef DRM_PS |
||||
if (sbr->Is_DRM_SBR) |
||||
{ |
||||
drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), X_left, X_right); |
||||
} else { |
||||
#endif |
||||
#ifdef PS_DEC |
||||
ps_decode(sbr->ps, X_left, X_right); |
||||
#endif |
||||
#ifdef DRM_PS |
||||
} |
||||
#endif |
||||
|
||||
/* subband synthesis */ |
||||
if (downSampledSBR) |
||||
{ |
||||
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel); |
||||
sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel); |
||||
} else { |
||||
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel); |
||||
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel); |
||||
} |
||||
|
||||
if (sbr->bs_header_flag) |
||||
sbr->just_seeked = 0; |
||||
|
||||
if (sbr->header_count != 0 && sbr->ret == 0) |
||||
{ |
||||
ret = sbr_save_prev_data(sbr, 0); |
||||
if (ret) return ret; |
||||
} |
||||
|
||||
sbr_save_matrix(sbr, 0); |
||||
|
||||
sbr->frame++; |
||||
|
||||
return 0; |
||||
} |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,258 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __SBR_DEC_H__ |
||||
#define __SBR_DEC_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#ifdef PS_DEC |
||||
#include "ps_dec.h" |
||||
#endif |
||||
#ifdef DRM_PS |
||||
#include "drm_dec.h" |
||||
#endif |
||||
|
||||
/* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */ |
||||
#define MAX_NTSRHFG 40 |
||||
#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */ |
||||
|
||||
/* MAX_M: maximum value for M */ |
||||
#define MAX_M 49 |
||||
/* MAX_L_E: maximum value for L_E */ |
||||
#define MAX_L_E 5 |
||||
|
||||
typedef struct { |
||||
real_t *x; |
||||
int16_t x_index; |
||||
uint8_t channels; |
||||
} qmfa_info; |
||||
|
||||
typedef struct { |
||||
real_t *v; |
||||
int16_t v_index; |
||||
uint8_t channels; |
||||
} qmfs_info; |
||||
|
||||
typedef struct |
||||
{ |
||||
uint32_t sample_rate; |
||||
uint32_t maxAACLine; |
||||
|
||||
uint8_t rate; |
||||
uint8_t just_seeked; |
||||
uint8_t ret; |
||||
|
||||
uint8_t amp_res[2]; |
||||
|
||||
uint8_t k0; |
||||
uint8_t kx; |
||||
uint8_t M; |
||||
uint8_t N_master; |
||||
uint8_t N_high; |
||||
uint8_t N_low; |
||||
uint8_t N_Q; |
||||
uint8_t N_L[4]; |
||||
uint8_t n[2]; |
||||
|
||||
uint8_t f_master[64]; |
||||
uint8_t f_table_res[2][64]; |
||||
uint8_t f_table_noise[64]; |
||||
uint8_t f_table_lim[4][64]; |
||||
#ifdef SBR_LOW_POWER |
||||
uint8_t f_group[5][64]; |
||||
uint8_t N_G[5]; |
||||
#endif |
||||
|
||||
uint8_t table_map_k_to_g[64]; |
||||
|
||||
uint8_t abs_bord_lead[2]; |
||||
uint8_t abs_bord_trail[2]; |
||||
uint8_t n_rel_lead[2]; |
||||
uint8_t n_rel_trail[2]; |
||||
|
||||
uint8_t L_E[2]; |
||||
uint8_t L_E_prev[2]; |
||||
uint8_t L_Q[2]; |
||||
|
||||
uint8_t t_E[2][MAX_L_E+1]; |
||||
uint8_t t_Q[2][3]; |
||||
uint8_t f[2][MAX_L_E+1]; |
||||
uint8_t f_prev[2]; |
||||
|
||||
real_t *G_temp_prev[2][5]; |
||||
real_t *Q_temp_prev[2][5]; |
||||
|
||||
int16_t E[2][64][MAX_L_E]; |
||||
int16_t E_prev[2][64]; |
||||
#ifndef FIXED_POINT |
||||
real_t E_orig[2][64][MAX_L_E]; |
||||
#endif |
||||
real_t E_curr[2][64][MAX_L_E]; |
||||
int32_t Q[2][64][2]; |
||||
#ifndef FIXED_POINT |
||||
real_t Q_div[2][64][2]; |
||||
real_t Q_div2[2][64][2]; |
||||
#endif |
||||
int32_t Q_prev[2][64]; |
||||
|
||||
int8_t l_A[2]; |
||||
int8_t l_A_prev[2]; |
||||
|
||||
uint8_t bs_invf_mode[2][MAX_L_E]; |
||||
uint8_t bs_invf_mode_prev[2][MAX_L_E]; |
||||
real_t bwArray[2][64]; |
||||
real_t bwArray_prev[2][64]; |
||||
|
||||
uint8_t noPatches; |
||||
uint8_t patchNoSubbands[64]; |
||||
uint8_t patchStartSubband[64]; |
||||
|
||||
uint8_t bs_add_harmonic[2][64]; |
||||
uint8_t bs_add_harmonic_prev[2][64]; |
||||
|
||||
int8_t GQ_ringbuf_index[2]; |
||||
|
||||
uint16_t index_noise_prev[2]; |
||||
uint8_t psi_is_prev[2]; |
||||
|
||||
uint8_t bs_start_freq_prev; |
||||
uint8_t bs_stop_freq_prev; |
||||
uint8_t bs_xover_band_prev; |
||||
uint8_t bs_freq_scale_prev; |
||||
uint8_t bs_alter_scale_prev; |
||||
uint8_t bs_noise_bands_prev; |
||||
|
||||
int8_t prevEnvIsShort[2]; |
||||
|
||||
int8_t kx_prev; |
||||
uint8_t bsco; |
||||
uint8_t bsco_prev; |
||||
uint8_t M_prev; |
||||
uint16_t frame_len; |
||||
|
||||
uint32_t frame; |
||||
uint32_t header_count; |
||||
|
||||
qmfa_info *qmfa[2]; |
||||
qmfs_info *qmfs[2]; |
||||
|
||||
qmf_t Xsbr[2][MAX_NTSRHFG][64]; |
||||
|
||||
#if defined(DRM) && defined(DRM_PS) |
||||
drm_ps_info *drm_ps; |
||||
#endif |
||||
|
||||
#ifdef PS_DEC |
||||
ps_info *ps; |
||||
#endif |
||||
|
||||
uint8_t numTimeSlotsRate; |
||||
uint8_t numTimeSlots; |
||||
uint8_t tHFGen; |
||||
uint8_t tHFAdj; |
||||
|
||||
#if (defined(PS_DEC) || defined(DRM_PS)) |
||||
uint8_t ps_used; |
||||
uint8_t psResetFlag; |
||||
#endif |
||||
|
||||
/* to get it compiling */ |
||||
/* we'll see during the coding of all the tools, whether
|
||||
these are all used or not. |
||||
*/ |
||||
uint8_t bs_header_flag; |
||||
uint8_t bs_crc_flag; |
||||
uint16_t bs_sbr_crc_bits; |
||||
uint8_t bs_protocol_version; |
||||
uint8_t bs_amp_res; |
||||
uint8_t bs_start_freq; |
||||
uint8_t bs_stop_freq; |
||||
uint8_t bs_xover_band; |
||||
uint8_t bs_freq_scale; |
||||
uint8_t bs_alter_scale; |
||||
uint8_t bs_noise_bands; |
||||
uint8_t bs_limiter_bands; |
||||
uint8_t bs_limiter_gains; |
||||
uint8_t bs_interpol_freq; |
||||
uint8_t bs_smoothing_mode; |
||||
uint8_t bs_samplerate_mode; |
||||
uint8_t bs_add_harmonic_flag[2]; |
||||
uint8_t bs_add_harmonic_flag_prev[2]; |
||||
uint8_t bs_extended_data; |
||||
uint8_t bs_extension_id; |
||||
uint8_t bs_extension_data; |
||||
uint8_t bs_coupling; |
||||
uint8_t bs_frame_class[2]; |
||||
uint8_t bs_rel_bord[2][9]; |
||||
uint8_t bs_rel_bord_0[2][9]; |
||||
uint8_t bs_rel_bord_1[2][9]; |
||||
uint8_t bs_pointer[2]; |
||||
uint8_t bs_abs_bord_0[2]; |
||||
uint8_t bs_abs_bord_1[2]; |
||||
uint8_t bs_num_rel_0[2]; |
||||
uint8_t bs_num_rel_1[2]; |
||||
uint8_t bs_df_env[2][9]; |
||||
uint8_t bs_df_noise[2][3]; |
||||
|
||||
uint8_t Reset; |
||||
uint8_t id_aac; |
||||
|
||||
#ifdef DRM |
||||
uint8_t Is_DRM_SBR; |
||||
#endif |
||||
} sbr_info; |
||||
|
||||
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, |
||||
uint32_t sample_rate, uint8_t downSampledSBR |
||||
#ifdef DRM |
||||
, uint8_t IsDRM |
||||
#endif |
||||
); |
||||
void sbrDecodeEnd(sbr_info *sbr); |
||||
void sbrReset(sbr_info *sbr); |
||||
|
||||
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR); |
||||
uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR); |
||||
#if (defined(PS_DEC) || defined(DRM_PS)) |
||||
uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, |
||||
const uint8_t just_seeked, const uint8_t downSampledSBR); |
||||
#endif |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,510 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_e_nf.c,v 1.22 2008/03/23 23:03:29 menno Exp $ |
||||
**/ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#ifdef SBR_DEC |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "sbr_syntax.h" |
||||
#include "sbr_e_nf.h" |
||||
|
||||
void extract_envelope_data(sbr_info *sbr, uint8_t ch) |
||||
{ |
||||
uint8_t l, k; |
||||
|
||||
for (l = 0; l < sbr->L_E[ch]; l++) |
||||
{ |
||||
if (sbr->bs_df_env[ch][l] == 0) |
||||
{ |
||||
for (k = 1; k < sbr->n[sbr->f[ch][l]]; k++) |
||||
{ |
||||
sbr->E[ch][k][l] = sbr->E[ch][k - 1][l] + sbr->E[ch][k][l]; |
||||
if (sbr->E[ch][k][l] < 0) |
||||
sbr->E[ch][k][l] = 0; |
||||
} |
||||
|
||||
} else { /* bs_df_env == 1 */ |
||||
|
||||
uint8_t g = (l == 0) ? sbr->f_prev[ch] : sbr->f[ch][l-1]; |
||||
int16_t E_prev; |
||||
|
||||
if (sbr->f[ch][l] == g) |
||||
{ |
||||
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) |
||||
{ |
||||
if (l == 0) |
||||
E_prev = sbr->E_prev[ch][k]; |
||||
else |
||||
E_prev = sbr->E[ch][k][l - 1]; |
||||
|
||||
sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; |
||||
} |
||||
|
||||
} else if ((g == 1) && (sbr->f[ch][l] == 0)) { |
||||
uint8_t i; |
||||
|
||||
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) |
||||
{ |
||||
for (i = 0; i < sbr->N_high; i++) |
||||
{ |
||||
if (sbr->f_table_res[HI_RES][i] == sbr->f_table_res[LO_RES][k]) |
||||
{ |
||||
if (l == 0) |
||||
E_prev = sbr->E_prev[ch][i]; |
||||
else |
||||
E_prev = sbr->E[ch][i][l - 1]; |
||||
|
||||
sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} else if ((g == 0) && (sbr->f[ch][l] == 1)) { |
||||
uint8_t i; |
||||
|
||||
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) |
||||
{ |
||||
for (i = 0; i < sbr->N_low; i++) |
||||
{ |
||||
if ((sbr->f_table_res[LO_RES][i] <= sbr->f_table_res[HI_RES][k]) && |
||||
(sbr->f_table_res[HI_RES][k] < sbr->f_table_res[LO_RES][i + 1])) |
||||
{ |
||||
if (l == 0) |
||||
E_prev = sbr->E_prev[ch][i]; |
||||
else |
||||
E_prev = sbr->E[ch][i][l - 1]; |
||||
|
||||
sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch) |
||||
{ |
||||
uint8_t l, k; |
||||
|
||||
for (l = 0; l < sbr->L_Q[ch]; l++) |
||||
{ |
||||
if (sbr->bs_df_noise[ch][l] == 0) |
||||
{ |
||||
for (k = 1; k < sbr->N_Q; k++) |
||||
{ |
||||
sbr->Q[ch][k][l] = sbr->Q[ch][k][l] + sbr->Q[ch][k-1][l]; |
||||
} |
||||
} else { |
||||
if (l == 0) |
||||
{ |
||||
for (k = 0; k < sbr->N_Q; k++) |
||||
{ |
||||
sbr->Q[ch][k][l] = sbr->Q_prev[ch][k] + sbr->Q[ch][k][0]; |
||||
} |
||||
} else { |
||||
for (k = 0; k < sbr->N_Q; k++) |
||||
{ |
||||
sbr->Q[ch][k][l] = sbr->Q[ch][k][l - 1] + sbr->Q[ch][k][l]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
#ifndef FIXED_POINT |
||||
|
||||
/* table for Q_div values when no coupling */ |
||||
static const real_t Q_div_tab[31] = { |
||||
FRAC_CONST(0.0153846), FRAC_CONST(0.030303), |
||||
FRAC_CONST(0.0588235), FRAC_CONST(0.111111), |
||||
FRAC_CONST(0.2), FRAC_CONST(0.333333), |
||||
FRAC_CONST(0.5), FRAC_CONST(0.666667), |
||||
FRAC_CONST(0.8), FRAC_CONST(0.888889), |
||||
FRAC_CONST(0.941176), FRAC_CONST(0.969697), |
||||
FRAC_CONST(0.984615), FRAC_CONST(0.992248), |
||||
FRAC_CONST(0.996109), FRAC_CONST(0.998051), |
||||
FRAC_CONST(0.999024), FRAC_CONST(0.999512), |
||||
FRAC_CONST(0.999756), FRAC_CONST(0.999878), |
||||
FRAC_CONST(0.999939), FRAC_CONST(0.999969), |
||||
FRAC_CONST(0.999985), FRAC_CONST(0.999992), |
||||
FRAC_CONST(0.999996), FRAC_CONST(0.999998), |
||||
FRAC_CONST(0.999999), FRAC_CONST(1), |
||||
FRAC_CONST(1), FRAC_CONST(1), |
||||
FRAC_CONST(1) |
||||
}; |
||||
|
||||
static const real_t Q_div_tab_left[31][13] = { |
||||
{ FRAC_CONST(0.969704), FRAC_CONST(0.888985), FRAC_CONST(0.667532), FRAC_CONST(0.336788), FRAC_CONST(0.117241), FRAC_CONST(0.037594), FRAC_CONST(0.0153846), FRAC_CONST(0.00967118), FRAC_CONST(0.00823245), FRAC_CONST(0.00787211), FRAC_CONST(0.00778198), FRAC_CONST(0.00775945), FRAC_CONST(0.00775382) }, |
||||
{ FRAC_CONST(0.984619), FRAC_CONST(0.94123), FRAC_CONST(0.800623), FRAC_CONST(0.503876), FRAC_CONST(0.209877), FRAC_CONST(0.0724638), FRAC_CONST(0.030303), FRAC_CONST(0.0191571), FRAC_CONST(0.0163305), FRAC_CONST(0.0156212), FRAC_CONST(0.0154438), FRAC_CONST(0.0153994), FRAC_CONST(0.0153883) }, |
||||
{ FRAC_CONST(0.99225), FRAC_CONST(0.969726), FRAC_CONST(0.889273), FRAC_CONST(0.670103), FRAC_CONST(0.346939), FRAC_CONST(0.135135), FRAC_CONST(0.0588235), FRAC_CONST(0.037594), FRAC_CONST(0.0321361), FRAC_CONST(0.0307619), FRAC_CONST(0.0304178), FRAC_CONST(0.0303317), FRAC_CONST(0.0303102) }, |
||||
{ FRAC_CONST(0.99611), FRAC_CONST(0.98463), FRAC_CONST(0.941392), FRAC_CONST(0.802469), FRAC_CONST(0.515152), FRAC_CONST(0.238095), FRAC_CONST(0.111111), FRAC_CONST(0.0724638), FRAC_CONST(0.0622711), FRAC_CONST(0.0596878), FRAC_CONST(0.0590397), FRAC_CONST(0.0588776), FRAC_CONST(0.058837) }, |
||||
{ FRAC_CONST(0.998051), FRAC_CONST(0.992256), FRAC_CONST(0.969811), FRAC_CONST(0.890411), FRAC_CONST(0.68), FRAC_CONST(0.384615), FRAC_CONST(0.2), FRAC_CONST(0.135135), FRAC_CONST(0.117241), FRAC_CONST(0.112652), FRAC_CONST(0.111497), FRAC_CONST(0.111208), FRAC_CONST(0.111135) }, |
||||
{ FRAC_CONST(0.999025), FRAC_CONST(0.996113), FRAC_CONST(0.984674), FRAC_CONST(0.942029), FRAC_CONST(0.809524), FRAC_CONST(0.555556), FRAC_CONST(0.333333), FRAC_CONST(0.238095), FRAC_CONST(0.209877), FRAC_CONST(0.202492), FRAC_CONST(0.200625), FRAC_CONST(0.200156), FRAC_CONST(0.200039) }, |
||||
{ FRAC_CONST(0.999512), FRAC_CONST(0.998053), FRAC_CONST(0.992278), FRAC_CONST(0.970149), FRAC_CONST(0.894737), FRAC_CONST(0.714286), FRAC_CONST(0.5), FRAC_CONST(0.384615), FRAC_CONST(0.346939), FRAC_CONST(0.336788), FRAC_CONST(0.3342), FRAC_CONST(0.33355), FRAC_CONST(0.333388) }, |
||||
{ FRAC_CONST(0.999756), FRAC_CONST(0.999025), FRAC_CONST(0.996124), FRAC_CONST(0.984848), FRAC_CONST(0.944444), FRAC_CONST(0.833333), FRAC_CONST(0.666667), FRAC_CONST(0.555556), FRAC_CONST(0.515152), FRAC_CONST(0.503876), FRAC_CONST(0.500975), FRAC_CONST(0.500244), FRAC_CONST(0.500061) }, |
||||
{ FRAC_CONST(0.999878), FRAC_CONST(0.999512), FRAC_CONST(0.998058), FRAC_CONST(0.992366), FRAC_CONST(0.971429), FRAC_CONST(0.909091), FRAC_CONST(0.8), FRAC_CONST(0.714286), FRAC_CONST(0.68), FRAC_CONST(0.670103), FRAC_CONST(0.667532), FRAC_CONST(0.666884), FRAC_CONST(0.666721) }, |
||||
{ FRAC_CONST(0.999939), FRAC_CONST(0.999756), FRAC_CONST(0.999028), FRAC_CONST(0.996169), FRAC_CONST(0.985507), FRAC_CONST(0.952381), FRAC_CONST(0.888889), FRAC_CONST(0.833333), FRAC_CONST(0.809524), FRAC_CONST(0.802469), FRAC_CONST(0.800623), FRAC_CONST(0.800156), FRAC_CONST(0.800039) }, |
||||
{ FRAC_CONST(0.999969), FRAC_CONST(0.999878), FRAC_CONST(0.999514), FRAC_CONST(0.998081), FRAC_CONST(0.992701), FRAC_CONST(0.97561), FRAC_CONST(0.941176), FRAC_CONST(0.909091), FRAC_CONST(0.894737), FRAC_CONST(0.890411), FRAC_CONST(0.889273), FRAC_CONST(0.888985), FRAC_CONST(0.888913) }, |
||||
{ FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.999757), FRAC_CONST(0.999039), FRAC_CONST(0.996337), FRAC_CONST(0.987654), FRAC_CONST(0.969697), FRAC_CONST(0.952381), FRAC_CONST(0.944444), FRAC_CONST(0.942029), FRAC_CONST(0.941392), FRAC_CONST(0.94123), FRAC_CONST(0.94119) }, |
||||
{ FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999878), FRAC_CONST(0.999519), FRAC_CONST(0.998165), FRAC_CONST(0.993789), FRAC_CONST(0.984615), FRAC_CONST(0.97561), FRAC_CONST(0.971429), FRAC_CONST(0.970149), FRAC_CONST(0.969811), FRAC_CONST(0.969726), FRAC_CONST(0.969704) }, |
||||
{ FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.99976), FRAC_CONST(0.999082), FRAC_CONST(0.996885), FRAC_CONST(0.992248), FRAC_CONST(0.987654), FRAC_CONST(0.985507), FRAC_CONST(0.984848), FRAC_CONST(0.984674), FRAC_CONST(0.98463), FRAC_CONST(0.984619) }, |
||||
{ FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.99988), FRAC_CONST(0.999541), FRAC_CONST(0.99844), FRAC_CONST(0.996109), FRAC_CONST(0.993789), FRAC_CONST(0.992701), FRAC_CONST(0.992366), FRAC_CONST(0.992278), FRAC_CONST(0.992256), FRAC_CONST(0.99225) }, |
||||
{ FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.99994), FRAC_CONST(0.99977), FRAC_CONST(0.999219), FRAC_CONST(0.998051), FRAC_CONST(0.996885), FRAC_CONST(0.996337), FRAC_CONST(0.996169), FRAC_CONST(0.996124), FRAC_CONST(0.996113), FRAC_CONST(0.99611) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999885), FRAC_CONST(0.99961), FRAC_CONST(0.999024), FRAC_CONST(0.99844), FRAC_CONST(0.998165), FRAC_CONST(0.998081), FRAC_CONST(0.998058), FRAC_CONST(0.998053), FRAC_CONST(0.998051) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999943), FRAC_CONST(0.999805), FRAC_CONST(0.999512), FRAC_CONST(0.999219), FRAC_CONST(0.999082), FRAC_CONST(0.999039), FRAC_CONST(0.999028), FRAC_CONST(0.999025), FRAC_CONST(0.999025) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.999971), FRAC_CONST(0.999902), FRAC_CONST(0.999756), FRAC_CONST(0.99961), FRAC_CONST(0.999541), FRAC_CONST(0.999519), FRAC_CONST(0.999514), FRAC_CONST(0.999512), FRAC_CONST(0.999512) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999986), FRAC_CONST(0.999951), FRAC_CONST(0.999878), FRAC_CONST(0.999805), FRAC_CONST(0.99977), FRAC_CONST(0.99976), FRAC_CONST(0.999757), FRAC_CONST(0.999756), FRAC_CONST(0.999756) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999993), FRAC_CONST(0.999976), FRAC_CONST(0.999939), FRAC_CONST(0.999902), FRAC_CONST(0.999885), FRAC_CONST(0.99988), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999988), FRAC_CONST(0.999969), FRAC_CONST(0.999951), FRAC_CONST(0.999943), FRAC_CONST(0.99994), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999994), FRAC_CONST(0.999985), FRAC_CONST(0.999976), FRAC_CONST(0.999971), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999969) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999997), FRAC_CONST(0.999992), FRAC_CONST(0.999988), FRAC_CONST(0.999986), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999996), FRAC_CONST(0.999994), FRAC_CONST(0.999993), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999997), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } |
||||
}; |
||||
|
||||
static const real_t Q_div_tab_right[31][13] = { |
||||
{ FRAC_CONST(0.00775382), FRAC_CONST(0.00775945), FRAC_CONST(0.00778198), FRAC_CONST(0.00787211), FRAC_CONST(0.00823245), FRAC_CONST(0.00967118), FRAC_CONST(0.0153846), FRAC_CONST(0.037594), FRAC_CONST(0.117241), FRAC_CONST(0.336788), FRAC_CONST(0.667532), FRAC_CONST(0.888985), FRAC_CONST(0.969704) }, |
||||
{ FRAC_CONST(0.0153883), FRAC_CONST(0.0153994), FRAC_CONST(0.0154438), FRAC_CONST(0.0156212), FRAC_CONST(0.0163305), FRAC_CONST(0.0191571), FRAC_CONST(0.030303), FRAC_CONST(0.0724638), FRAC_CONST(0.209877), FRAC_CONST(0.503876), FRAC_CONST(0.800623), FRAC_CONST(0.94123), FRAC_CONST(0.984619) }, |
||||
{ FRAC_CONST(0.0303102), FRAC_CONST(0.0303317), FRAC_CONST(0.0304178), FRAC_CONST(0.0307619), FRAC_CONST(0.0321361), FRAC_CONST(0.037594), FRAC_CONST(0.0588235), FRAC_CONST(0.135135), FRAC_CONST(0.346939), FRAC_CONST(0.670103), FRAC_CONST(0.889273), FRAC_CONST(0.969726), FRAC_CONST(0.99225) }, |
||||
{ FRAC_CONST(0.058837), FRAC_CONST(0.0588776), FRAC_CONST(0.0590397), FRAC_CONST(0.0596878), FRAC_CONST(0.0622711), FRAC_CONST(0.0724638), FRAC_CONST(0.111111), FRAC_CONST(0.238095), FRAC_CONST(0.515152), FRAC_CONST(0.802469), FRAC_CONST(0.941392), FRAC_CONST(0.98463), FRAC_CONST(0.99611) }, |
||||
{ FRAC_CONST(0.111135), FRAC_CONST(0.111208), FRAC_CONST(0.111497), FRAC_CONST(0.112652), FRAC_CONST(0.117241), FRAC_CONST(0.135135), FRAC_CONST(0.2), FRAC_CONST(0.384615), FRAC_CONST(0.68), FRAC_CONST(0.890411), FRAC_CONST(0.969811), FRAC_CONST(0.992256), FRAC_CONST(0.998051) }, |
||||
{ FRAC_CONST(0.200039), FRAC_CONST(0.200156), FRAC_CONST(0.200625), FRAC_CONST(0.202492), FRAC_CONST(0.209877), FRAC_CONST(0.238095), FRAC_CONST(0.333333), FRAC_CONST(0.555556), FRAC_CONST(0.809524), FRAC_CONST(0.942029), FRAC_CONST(0.984674), FRAC_CONST(0.996113), FRAC_CONST(0.999025) }, |
||||
{ FRAC_CONST(0.333388), FRAC_CONST(0.33355), FRAC_CONST(0.3342), FRAC_CONST(0.336788), FRAC_CONST(0.346939), FRAC_CONST(0.384615), FRAC_CONST(0.5), FRAC_CONST(0.714286), FRAC_CONST(0.894737), FRAC_CONST(0.970149), FRAC_CONST(0.992278), FRAC_CONST(0.998053), FRAC_CONST(0.999512) }, |
||||
{ FRAC_CONST(0.500061), FRAC_CONST(0.500244), FRAC_CONST(0.500975), FRAC_CONST(0.503876), FRAC_CONST(0.515152), FRAC_CONST(0.555556), FRAC_CONST(0.666667), FRAC_CONST(0.833333), FRAC_CONST(0.944444), FRAC_CONST(0.984848), FRAC_CONST(0.996124), FRAC_CONST(0.999025), FRAC_CONST(0.999756) }, |
||||
{ FRAC_CONST(0.666721), FRAC_CONST(0.666884), FRAC_CONST(0.667532), FRAC_CONST(0.670103), FRAC_CONST(0.68), FRAC_CONST(0.714286), FRAC_CONST(0.8), FRAC_CONST(0.909091), FRAC_CONST(0.971429), FRAC_CONST(0.992366), FRAC_CONST(0.998058), FRAC_CONST(0.999512), FRAC_CONST(0.999878) }, |
||||
{ FRAC_CONST(0.800039), FRAC_CONST(0.800156), FRAC_CONST(0.800623), FRAC_CONST(0.802469), FRAC_CONST(0.809524), FRAC_CONST(0.833333), FRAC_CONST(0.888889), FRAC_CONST(0.952381), FRAC_CONST(0.985507), FRAC_CONST(0.996169), FRAC_CONST(0.999028), FRAC_CONST(0.999756), FRAC_CONST(0.999939) }, |
||||
{ FRAC_CONST(0.888913), FRAC_CONST(0.888985), FRAC_CONST(0.889273), FRAC_CONST(0.890411), FRAC_CONST(0.894737), FRAC_CONST(0.909091), FRAC_CONST(0.941176), FRAC_CONST(0.97561), FRAC_CONST(0.992701), FRAC_CONST(0.998081), FRAC_CONST(0.999514), FRAC_CONST(0.999878), FRAC_CONST(0.999969) }, |
||||
{ FRAC_CONST(0.94119), FRAC_CONST(0.94123), FRAC_CONST(0.941392), FRAC_CONST(0.942029), FRAC_CONST(0.944444), FRAC_CONST(0.952381), FRAC_CONST(0.969697), FRAC_CONST(0.987654), FRAC_CONST(0.996337), FRAC_CONST(0.999039), FRAC_CONST(0.999757), FRAC_CONST(0.999939), FRAC_CONST(0.999985) }, |
||||
{ FRAC_CONST(0.969704), FRAC_CONST(0.969726), FRAC_CONST(0.969811), FRAC_CONST(0.970149), FRAC_CONST(0.971429), FRAC_CONST(0.97561), FRAC_CONST(0.984615), FRAC_CONST(0.993789), FRAC_CONST(0.998165), FRAC_CONST(0.999519), FRAC_CONST(0.999878), FRAC_CONST(0.99997), FRAC_CONST(0.999992) }, |
||||
{ FRAC_CONST(0.984619), FRAC_CONST(0.98463), FRAC_CONST(0.984674), FRAC_CONST(0.984848), FRAC_CONST(0.985507), FRAC_CONST(0.987654), FRAC_CONST(0.992248), FRAC_CONST(0.996885), FRAC_CONST(0.999082), FRAC_CONST(0.99976), FRAC_CONST(0.999939), FRAC_CONST(0.999985), FRAC_CONST(0.999996) }, |
||||
{ FRAC_CONST(0.99225), FRAC_CONST(0.992256), FRAC_CONST(0.992278), FRAC_CONST(0.992366), FRAC_CONST(0.992701), FRAC_CONST(0.993789), FRAC_CONST(0.996109), FRAC_CONST(0.99844), FRAC_CONST(0.999541), FRAC_CONST(0.99988), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998) }, |
||||
{ FRAC_CONST(0.99611), FRAC_CONST(0.996113), FRAC_CONST(0.996124), FRAC_CONST(0.996169), FRAC_CONST(0.996337), FRAC_CONST(0.996885), FRAC_CONST(0.998051), FRAC_CONST(0.999219), FRAC_CONST(0.99977), FRAC_CONST(0.99994), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999) }, |
||||
{ FRAC_CONST(0.998051), FRAC_CONST(0.998053), FRAC_CONST(0.998058), FRAC_CONST(0.998081), FRAC_CONST(0.998165), FRAC_CONST(0.99844), FRAC_CONST(0.999024), FRAC_CONST(0.99961), FRAC_CONST(0.999885), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999025), FRAC_CONST(0.999025), FRAC_CONST(0.999028), FRAC_CONST(0.999039), FRAC_CONST(0.999082), FRAC_CONST(0.999219), FRAC_CONST(0.999512), FRAC_CONST(0.999805), FRAC_CONST(0.999943), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999512), FRAC_CONST(0.999512), FRAC_CONST(0.999514), FRAC_CONST(0.999519), FRAC_CONST(0.999541), FRAC_CONST(0.99961), FRAC_CONST(0.999756), FRAC_CONST(0.999902), FRAC_CONST(0.999971), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999756), FRAC_CONST(0.999756), FRAC_CONST(0.999757), FRAC_CONST(0.99976), FRAC_CONST(0.99977), FRAC_CONST(0.999805), FRAC_CONST(0.999878), FRAC_CONST(0.999951), FRAC_CONST(0.999986), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.99988), FRAC_CONST(0.999885), FRAC_CONST(0.999902), FRAC_CONST(0.999939), FRAC_CONST(0.999976), FRAC_CONST(0.999993), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.99994), FRAC_CONST(0.999943), FRAC_CONST(0.999951), FRAC_CONST(0.999969), FRAC_CONST(0.999988), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999969), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999971), FRAC_CONST(0.999976), FRAC_CONST(0.999985), FRAC_CONST(0.999994), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999986), FRAC_CONST(0.999988), FRAC_CONST(0.999992), FRAC_CONST(0.999997), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999993), FRAC_CONST(0.999994), FRAC_CONST(0.999996), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999997), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, |
||||
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } |
||||
}; |
||||
|
||||
/* calculates 1/(1+Q) */ |
||||
/* [0..1] */ |
||||
static real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) |
||||
{ |
||||
if (sbr->bs_coupling) |
||||
{ |
||||
/* left channel */ |
||||
if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || |
||||
(sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) |
||||
{ |
||||
return 0; |
||||
} else { |
||||
/* the pan parameter is always even */ |
||||
if (ch == 0) |
||||
{ |
||||
return Q_div_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; |
||||
} else { |
||||
return Q_div_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; |
||||
} |
||||
} |
||||
} else { |
||||
/* no coupling */ |
||||
if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) |
||||
{ |
||||
return 0; |
||||
} else { |
||||
return Q_div_tab[sbr->Q[ch][m][l]]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* table for Q_div2 values when no coupling */ |
||||
static const real_t Q_div2_tab[31] = { |
||||
FRAC_CONST(0.984615), FRAC_CONST(0.969697), |
||||
FRAC_CONST(0.941176), FRAC_CONST(0.888889), |
||||
FRAC_CONST(0.8), FRAC_CONST(0.666667), |
||||
FRAC_CONST(0.5), FRAC_CONST(0.333333), |
||||
FRAC_CONST(0.2), FRAC_CONST(0.111111), |
||||
FRAC_CONST(0.0588235), FRAC_CONST(0.030303), |
||||
FRAC_CONST(0.0153846), FRAC_CONST(0.00775194), |
||||
FRAC_CONST(0.00389105), FRAC_CONST(0.00194932), |
||||
FRAC_CONST(0.00097561), FRAC_CONST(0.000488043), |
||||
FRAC_CONST(0.000244081), FRAC_CONST(0.000122055), |
||||
FRAC_CONST(6.10314E-005), FRAC_CONST(3.05166E-005), |
||||
FRAC_CONST(1.52586E-005), FRAC_CONST(7.62934E-006), |
||||
FRAC_CONST(3.81468E-006), FRAC_CONST(1.90734E-006), |
||||
FRAC_CONST(9.53673E-007), FRAC_CONST(4.76837E-007), |
||||
FRAC_CONST(2.38419E-007), FRAC_CONST(1.19209E-007), |
||||
FRAC_CONST(5.96046E-008) |
||||
}; |
||||
|
||||
static const real_t Q_div2_tab_left[31][13] = { |
||||
{ FRAC_CONST(0.0302959), FRAC_CONST(0.111015), FRAC_CONST(0.332468), FRAC_CONST(0.663212), FRAC_CONST(0.882759), FRAC_CONST(0.962406), FRAC_CONST(0.984615), FRAC_CONST(0.990329), FRAC_CONST(0.991768), FRAC_CONST(0.992128), FRAC_CONST(0.992218), FRAC_CONST(0.992241), FRAC_CONST(0.992246) }, |
||||
{ FRAC_CONST(0.0153809), FRAC_CONST(0.0587695), FRAC_CONST(0.199377), FRAC_CONST(0.496124), FRAC_CONST(0.790123), FRAC_CONST(0.927536), FRAC_CONST(0.969697), FRAC_CONST(0.980843), FRAC_CONST(0.98367), FRAC_CONST(0.984379), FRAC_CONST(0.984556), FRAC_CONST(0.984601), FRAC_CONST(0.984612) }, |
||||
{ FRAC_CONST(0.00775006), FRAC_CONST(0.0302744), FRAC_CONST(0.110727), FRAC_CONST(0.329897), FRAC_CONST(0.653061), FRAC_CONST(0.864865), FRAC_CONST(0.941176), FRAC_CONST(0.962406), FRAC_CONST(0.967864), FRAC_CONST(0.969238), FRAC_CONST(0.969582), FRAC_CONST(0.969668), FRAC_CONST(0.96969) }, |
||||
{ FRAC_CONST(0.0038901), FRAC_CONST(0.0153698), FRAC_CONST(0.0586081), FRAC_CONST(0.197531), FRAC_CONST(0.484848), FRAC_CONST(0.761905), FRAC_CONST(0.888889), FRAC_CONST(0.927536), FRAC_CONST(0.937729), FRAC_CONST(0.940312), FRAC_CONST(0.94096), FRAC_CONST(0.941122), FRAC_CONST(0.941163) }, |
||||
{ FRAC_CONST(0.00194884), FRAC_CONST(0.00774443), FRAC_CONST(0.0301887), FRAC_CONST(0.109589), FRAC_CONST(0.32), FRAC_CONST(0.615385), FRAC_CONST(0.8), FRAC_CONST(0.864865), FRAC_CONST(0.882759), FRAC_CONST(0.887348), FRAC_CONST(0.888503), FRAC_CONST(0.888792), FRAC_CONST(0.888865) }, |
||||
{ FRAC_CONST(0.000975372), FRAC_CONST(0.00388727), FRAC_CONST(0.0153257), FRAC_CONST(0.057971), FRAC_CONST(0.190476), FRAC_CONST(0.444444), FRAC_CONST(0.666667), FRAC_CONST(0.761905), FRAC_CONST(0.790123), FRAC_CONST(0.797508), FRAC_CONST(0.799375), FRAC_CONST(0.799844), FRAC_CONST(0.799961) }, |
||||
{ FRAC_CONST(0.000487924), FRAC_CONST(0.00194742), FRAC_CONST(0.00772201), FRAC_CONST(0.0298507), FRAC_CONST(0.105263), FRAC_CONST(0.285714), FRAC_CONST(0.5), FRAC_CONST(0.615385), FRAC_CONST(0.653061), FRAC_CONST(0.663212), FRAC_CONST(0.6658), FRAC_CONST(0.66645), FRAC_CONST(0.666612) }, |
||||
{ FRAC_CONST(0.000244021), FRAC_CONST(0.000974659), FRAC_CONST(0.00387597), FRAC_CONST(0.0151515), FRAC_CONST(0.0555556), FRAC_CONST(0.166667), FRAC_CONST(0.333333), FRAC_CONST(0.444444), FRAC_CONST(0.484848), FRAC_CONST(0.496124), FRAC_CONST(0.499025), FRAC_CONST(0.499756), FRAC_CONST(0.499939) }, |
||||
{ FRAC_CONST(0.000122026), FRAC_CONST(0.000487567), FRAC_CONST(0.00194175), FRAC_CONST(0.00763359), FRAC_CONST(0.0285714), FRAC_CONST(0.0909091), FRAC_CONST(0.2), FRAC_CONST(0.285714), FRAC_CONST(0.32), FRAC_CONST(0.329897), FRAC_CONST(0.332468), FRAC_CONST(0.333116), FRAC_CONST(0.333279) }, |
||||
{ FRAC_CONST(6.10165E-005), FRAC_CONST(0.000243843), FRAC_CONST(0.000971817), FRAC_CONST(0.00383142), FRAC_CONST(0.0144928), FRAC_CONST(0.047619), FRAC_CONST(0.111111), FRAC_CONST(0.166667), FRAC_CONST(0.190476), FRAC_CONST(0.197531), FRAC_CONST(0.199377), FRAC_CONST(0.199844), FRAC_CONST(0.199961) }, |
||||
{ FRAC_CONST(3.05092E-005), FRAC_CONST(0.000121936), FRAC_CONST(0.000486145), FRAC_CONST(0.00191939), FRAC_CONST(0.00729927), FRAC_CONST(0.0243902), FRAC_CONST(0.0588235), FRAC_CONST(0.0909091), FRAC_CONST(0.105263), FRAC_CONST(0.109589), FRAC_CONST(0.110727), FRAC_CONST(0.111015), FRAC_CONST(0.111087) }, |
||||
{ FRAC_CONST(1.52548E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(0.000243132), FRAC_CONST(0.000960615), FRAC_CONST(0.003663), FRAC_CONST(0.0123457), FRAC_CONST(0.030303), FRAC_CONST(0.047619), FRAC_CONST(0.0555556), FRAC_CONST(0.057971), FRAC_CONST(0.0586081), FRAC_CONST(0.0587695), FRAC_CONST(0.05881) }, |
||||
{ FRAC_CONST(7.62747E-006), FRAC_CONST(3.04869E-005), FRAC_CONST(0.000121581), FRAC_CONST(0.000480538), FRAC_CONST(0.00183486), FRAC_CONST(0.00621118), FRAC_CONST(0.0153846), FRAC_CONST(0.0243902), FRAC_CONST(0.0285714), FRAC_CONST(0.0298507), FRAC_CONST(0.0301887), FRAC_CONST(0.0302744), FRAC_CONST(0.0302959) }, |
||||
{ FRAC_CONST(3.81375E-006), FRAC_CONST(1.52437E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(0.000240327), FRAC_CONST(0.000918274), FRAC_CONST(0.00311526), FRAC_CONST(0.00775194), FRAC_CONST(0.0123457), FRAC_CONST(0.0144928), FRAC_CONST(0.0151515), FRAC_CONST(0.0153257), FRAC_CONST(0.0153698), FRAC_CONST(0.0153809) }, |
||||
{ FRAC_CONST(1.90688E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(3.03979E-005), FRAC_CONST(0.000120178), FRAC_CONST(0.000459348), FRAC_CONST(0.00156006), FRAC_CONST(0.00389105), FRAC_CONST(0.00621118), FRAC_CONST(0.00729927), FRAC_CONST(0.00763359), FRAC_CONST(0.00772201), FRAC_CONST(0.00774443), FRAC_CONST(0.00775006) }, |
||||
{ FRAC_CONST(9.53441E-007), FRAC_CONST(3.81096E-006), FRAC_CONST(1.51992E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(0.000229727), FRAC_CONST(0.00078064), FRAC_CONST(0.00194932), FRAC_CONST(0.00311526), FRAC_CONST(0.003663), FRAC_CONST(0.00383142), FRAC_CONST(0.00387597), FRAC_CONST(0.00388727), FRAC_CONST(0.0038901) }, |
||||
{ FRAC_CONST(4.76721E-007), FRAC_CONST(1.90548E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(3.00472E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000390472), FRAC_CONST(0.00097561), FRAC_CONST(0.00156006), FRAC_CONST(0.00183486), FRAC_CONST(0.00191939), FRAC_CONST(0.00194175), FRAC_CONST(0.00194742), FRAC_CONST(0.00194884) }, |
||||
{ FRAC_CONST(2.3836E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(3.79984E-006), FRAC_CONST(1.50238E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(0.000195274), FRAC_CONST(0.000488043), FRAC_CONST(0.00078064), FRAC_CONST(0.000918274), FRAC_CONST(0.000960615), FRAC_CONST(0.000971817), FRAC_CONST(0.000974659), FRAC_CONST(0.000975372) }, |
||||
{ FRAC_CONST(1.1918E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(1.89992E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(2.87216E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000244081), FRAC_CONST(0.000390472), FRAC_CONST(0.000459348), FRAC_CONST(0.000480538), FRAC_CONST(0.000486145), FRAC_CONST(0.000487567), FRAC_CONST(0.000487924) }, |
||||
{ FRAC_CONST(5.95901E-008), FRAC_CONST(2.38186E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(3.756E-006), FRAC_CONST(1.4361E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(0.000122055), FRAC_CONST(0.000195274), FRAC_CONST(0.000229727), FRAC_CONST(0.000240327), FRAC_CONST(0.000243132), FRAC_CONST(0.000243843), FRAC_CONST(0.000244021) }, |
||||
{ FRAC_CONST(2.9795E-008), FRAC_CONST(1.19093E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(1.878E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(2.44135E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000120178), FRAC_CONST(0.000121581), FRAC_CONST(0.000121936), FRAC_CONST(0.000122026) }, |
||||
{ FRAC_CONST(1.48975E-008), FRAC_CONST(5.95465E-008), FRAC_CONST(2.37491E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(3.59029E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.10165E-005) }, |
||||
{ FRAC_CONST(7.44876E-009), FRAC_CONST(2.97732E-008), FRAC_CONST(1.18745E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(1.79515E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(1.52586E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.05092E-005) }, |
||||
{ FRAC_CONST(3.72438E-009), FRAC_CONST(1.48866E-008), FRAC_CONST(5.93727E-008), FRAC_CONST(2.34751E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(3.05175E-006), FRAC_CONST(7.62934E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.52548E-005) }, |
||||
{ FRAC_CONST(1.86219E-009), FRAC_CONST(7.44331E-009), FRAC_CONST(2.96864E-008), FRAC_CONST(1.17375E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.62747E-006) }, |
||||
{ FRAC_CONST(9.31095E-010), FRAC_CONST(3.72166E-009), FRAC_CONST(1.48432E-008), FRAC_CONST(5.86876E-008), FRAC_CONST(2.24394E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(1.90734E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.81375E-006) }, |
||||
{ FRAC_CONST(4.65548E-010), FRAC_CONST(1.86083E-009), FRAC_CONST(7.42159E-009), FRAC_CONST(2.93438E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(9.53673E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.90688E-006) }, |
||||
{ FRAC_CONST(2.32774E-010), FRAC_CONST(9.30414E-010), FRAC_CONST(3.71079E-009), FRAC_CONST(1.46719E-008), FRAC_CONST(5.60985E-008), FRAC_CONST(1.90735E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.53441E-007) }, |
||||
{ FRAC_CONST(1.16387E-010), FRAC_CONST(4.65207E-010), FRAC_CONST(1.8554E-009), FRAC_CONST(7.33596E-009), FRAC_CONST(2.80492E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(2.38419E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.76721E-007) }, |
||||
{ FRAC_CONST(5.81935E-011), FRAC_CONST(2.32603E-010), FRAC_CONST(9.27699E-010), FRAC_CONST(3.66798E-009), FRAC_CONST(1.40246E-008), FRAC_CONST(4.76837E-008), FRAC_CONST(1.19209E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.3836E-007) }, |
||||
{ FRAC_CONST(2.90967E-011), FRAC_CONST(1.16302E-010), FRAC_CONST(4.63849E-010), FRAC_CONST(1.83399E-009), FRAC_CONST(7.01231E-009), FRAC_CONST(2.38419E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.1918E-007) } |
||||
}; |
||||
|
||||
static const real_t Q_div2_tab_right[31][13] = { |
||||
{ FRAC_CONST(0.992246), FRAC_CONST(0.992241), FRAC_CONST(0.992218), FRAC_CONST(0.992128), FRAC_CONST(0.991768), FRAC_CONST(0.990329), FRAC_CONST(0.984615), FRAC_CONST(0.962406), FRAC_CONST(0.882759), FRAC_CONST(0.663212), FRAC_CONST(0.332468), FRAC_CONST(0.111015), FRAC_CONST(0.0302959) }, |
||||
{ FRAC_CONST(0.984612), FRAC_CONST(0.984601), FRAC_CONST(0.984556), FRAC_CONST(0.984379), FRAC_CONST(0.98367), FRAC_CONST(0.980843), FRAC_CONST(0.969697), FRAC_CONST(0.927536), FRAC_CONST(0.790123), FRAC_CONST(0.496124), FRAC_CONST(0.199377), FRAC_CONST(0.0587695), FRAC_CONST(0.0153809) }, |
||||
{ FRAC_CONST(0.96969), FRAC_CONST(0.969668), FRAC_CONST(0.969582), FRAC_CONST(0.969238), FRAC_CONST(0.967864), FRAC_CONST(0.962406), FRAC_CONST(0.941176), FRAC_CONST(0.864865), FRAC_CONST(0.653061), FRAC_CONST(0.329897), FRAC_CONST(0.110727), FRAC_CONST(0.0302744), FRAC_CONST(0.00775006) }, |
||||
{ FRAC_CONST(0.941163), FRAC_CONST(0.941122), FRAC_CONST(0.94096), FRAC_CONST(0.940312), FRAC_CONST(0.937729), FRAC_CONST(0.927536), FRAC_CONST(0.888889), FRAC_CONST(0.761905), FRAC_CONST(0.484848), FRAC_CONST(0.197531), FRAC_CONST(0.0586081), FRAC_CONST(0.0153698), FRAC_CONST(0.0038901) }, |
||||
{ FRAC_CONST(0.888865), FRAC_CONST(0.888792), FRAC_CONST(0.888503), FRAC_CONST(0.887348), FRAC_CONST(0.882759), FRAC_CONST(0.864865), FRAC_CONST(0.8), FRAC_CONST(0.615385), FRAC_CONST(0.32), FRAC_CONST(0.109589), FRAC_CONST(0.0301887), FRAC_CONST(0.00774443), FRAC_CONST(0.00194884) }, |
||||
{ FRAC_CONST(0.799961), FRAC_CONST(0.799844), FRAC_CONST(0.799375), FRAC_CONST(0.797508), FRAC_CONST(0.790123), FRAC_CONST(0.761905), FRAC_CONST(0.666667), FRAC_CONST(0.444444), FRAC_CONST(0.190476), FRAC_CONST(0.057971), FRAC_CONST(0.0153257), FRAC_CONST(0.00388727), FRAC_CONST(0.000975372) }, |
||||
{ FRAC_CONST(0.666612), FRAC_CONST(0.66645), FRAC_CONST(0.6658), FRAC_CONST(0.663212), FRAC_CONST(0.653061), FRAC_CONST(0.615385), FRAC_CONST(0.5), FRAC_CONST(0.285714), FRAC_CONST(0.105263), FRAC_CONST(0.0298507), FRAC_CONST(0.00772201), FRAC_CONST(0.00194742), FRAC_CONST(0.000487924) }, |
||||
{ FRAC_CONST(0.499939), FRAC_CONST(0.499756), FRAC_CONST(0.499025), FRAC_CONST(0.496124), FRAC_CONST(0.484848), FRAC_CONST(0.444444), FRAC_CONST(0.333333), FRAC_CONST(0.166667), FRAC_CONST(0.0555556), FRAC_CONST(0.0151515), FRAC_CONST(0.00387597), FRAC_CONST(0.000974659), FRAC_CONST(0.000244021) }, |
||||
{ FRAC_CONST(0.333279), FRAC_CONST(0.333116), FRAC_CONST(0.332468), FRAC_CONST(0.329897), FRAC_CONST(0.32), FRAC_CONST(0.285714), FRAC_CONST(0.2), FRAC_CONST(0.0909091), FRAC_CONST(0.0285714), FRAC_CONST(0.00763359), FRAC_CONST(0.00194175), FRAC_CONST(0.000487567), FRAC_CONST(0.000122026) }, |
||||
{ FRAC_CONST(0.199961), FRAC_CONST(0.199844), FRAC_CONST(0.199377), FRAC_CONST(0.197531), FRAC_CONST(0.190476), FRAC_CONST(0.166667), FRAC_CONST(0.111111), FRAC_CONST(0.047619), FRAC_CONST(0.0144928), FRAC_CONST(0.00383142), FRAC_CONST(0.000971817), FRAC_CONST(0.000243843), FRAC_CONST(6.10165E-005) }, |
||||
{ FRAC_CONST(0.111087), FRAC_CONST(0.111015), FRAC_CONST(0.110727), FRAC_CONST(0.109589), FRAC_CONST(0.105263), FRAC_CONST(0.0909091), FRAC_CONST(0.0588235), FRAC_CONST(0.0243902), FRAC_CONST(0.00729927), FRAC_CONST(0.00191939), FRAC_CONST(0.000486145), FRAC_CONST(0.000121936), FRAC_CONST(3.05092E-005) }, |
||||
{ FRAC_CONST(0.05881), FRAC_CONST(0.0587695), FRAC_CONST(0.0586081), FRAC_CONST(0.057971), FRAC_CONST(0.0555556), FRAC_CONST(0.047619), FRAC_CONST(0.030303), FRAC_CONST(0.0123457), FRAC_CONST(0.003663), FRAC_CONST(0.000960615), FRAC_CONST(0.000243132), FRAC_CONST(6.09719E-005), FRAC_CONST(1.52548E-005) }, |
||||
{ FRAC_CONST(0.0302959), FRAC_CONST(0.0302744), FRAC_CONST(0.0301887), FRAC_CONST(0.0298507), FRAC_CONST(0.0285714), FRAC_CONST(0.0243902), FRAC_CONST(0.0153846), FRAC_CONST(0.00621118), FRAC_CONST(0.00183486), FRAC_CONST(0.000480538), FRAC_CONST(0.000121581), FRAC_CONST(3.04869E-005), FRAC_CONST(7.62747E-006) }, |
||||
{ FRAC_CONST(0.0153809), FRAC_CONST(0.0153698), FRAC_CONST(0.0153257), FRAC_CONST(0.0151515), FRAC_CONST(0.0144928), FRAC_CONST(0.0123457), FRAC_CONST(0.00775194), FRAC_CONST(0.00311526), FRAC_CONST(0.000918274), FRAC_CONST(0.000240327), FRAC_CONST(6.0794E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(3.81375E-006) }, |
||||
{ FRAC_CONST(0.00775006), FRAC_CONST(0.00774443), FRAC_CONST(0.00772201), FRAC_CONST(0.00763359), FRAC_CONST(0.00729927), FRAC_CONST(0.00621118), FRAC_CONST(0.00389105), FRAC_CONST(0.00156006), FRAC_CONST(0.000459348), FRAC_CONST(0.000120178), FRAC_CONST(3.03979E-005), FRAC_CONST(7.62189E-006), FRAC_CONST(1.90688E-006) }, |
||||
{ FRAC_CONST(0.0038901), FRAC_CONST(0.00388727), FRAC_CONST(0.00387597), FRAC_CONST(0.00383142), FRAC_CONST(0.003663), FRAC_CONST(0.00311526), FRAC_CONST(0.00194932), FRAC_CONST(0.00078064), FRAC_CONST(0.000229727), FRAC_CONST(6.00925E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(3.81096E-006), FRAC_CONST(9.53441E-007) }, |
||||
{ FRAC_CONST(0.00194884), FRAC_CONST(0.00194742), FRAC_CONST(0.00194175), FRAC_CONST(0.00191939), FRAC_CONST(0.00183486), FRAC_CONST(0.00156006), FRAC_CONST(0.00097561), FRAC_CONST(0.000390472), FRAC_CONST(0.000114877), FRAC_CONST(3.00472E-005), FRAC_CONST(7.59965E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(4.76721E-007) }, |
||||
{ FRAC_CONST(0.000975372), FRAC_CONST(0.000974659), FRAC_CONST(0.000971817), FRAC_CONST(0.000960615), FRAC_CONST(0.000918274), FRAC_CONST(0.00078064), FRAC_CONST(0.000488043), FRAC_CONST(0.000195274), FRAC_CONST(5.74416E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(3.79984E-006), FRAC_CONST(9.52743E-007), FRAC_CONST(2.3836E-007) }, |
||||
{ FRAC_CONST(0.000487924), FRAC_CONST(0.000487567), FRAC_CONST(0.000486145), FRAC_CONST(0.000480538), FRAC_CONST(0.000459348), FRAC_CONST(0.000390472), FRAC_CONST(0.000244081), FRAC_CONST(9.76467E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(7.51196E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(4.76372E-007), FRAC_CONST(1.1918E-007) }, |
||||
{ FRAC_CONST(0.000244021), FRAC_CONST(0.000243843), FRAC_CONST(0.000243132), FRAC_CONST(0.000240327), FRAC_CONST(0.000229727), FRAC_CONST(0.000195274), FRAC_CONST(0.000122055), FRAC_CONST(4.88257E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(3.756E-006), FRAC_CONST(9.49963E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(5.95901E-008) }, |
||||
{ FRAC_CONST(0.000122026), FRAC_CONST(0.000121936), FRAC_CONST(0.000121581), FRAC_CONST(0.000120178), FRAC_CONST(0.000114877), FRAC_CONST(9.76467E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(7.18056E-006), FRAC_CONST(1.878E-006), FRAC_CONST(4.74982E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(2.9795E-008) }, |
||||
{ FRAC_CONST(6.10165E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(3.59029E-006), FRAC_CONST(9.39002E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(5.95465E-008), FRAC_CONST(1.48975E-008) }, |
||||
{ FRAC_CONST(3.05092E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(1.52586E-005), FRAC_CONST(6.10348E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(4.69501E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(2.97732E-008), FRAC_CONST(7.44876E-009) }, |
||||
{ FRAC_CONST(1.52548E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(7.62934E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(8.97575E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(5.93727E-008), FRAC_CONST(1.48866E-008), FRAC_CONST(3.72438E-009) }, |
||||
{ FRAC_CONST(7.62747E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(4.48788E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(2.96864E-008), FRAC_CONST(7.44331E-009), FRAC_CONST(1.86219E-009) }, |
||||
{ FRAC_CONST(3.81375E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(1.90734E-006), FRAC_CONST(7.62939E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(5.86876E-008), FRAC_CONST(1.48432E-008), FRAC_CONST(3.72166E-009), FRAC_CONST(9.31095E-010) }, |
||||
{ FRAC_CONST(1.90688E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(9.53673E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(2.93438E-008), FRAC_CONST(7.42159E-009), FRAC_CONST(1.86083E-009), FRAC_CONST(4.65548E-010) }, |
||||
{ FRAC_CONST(9.53441E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(5.60985E-008), FRAC_CONST(1.46719E-008), FRAC_CONST(3.71079E-009), FRAC_CONST(9.30414E-010), FRAC_CONST(2.32774E-010) }, |
||||
{ FRAC_CONST(4.76721E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(2.38419E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(2.80492E-008), FRAC_CONST(7.33596E-009), FRAC_CONST(1.8554E-009), FRAC_CONST(4.65207E-010), FRAC_CONST(1.16387E-010) }, |
||||
{ FRAC_CONST(2.3836E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(1.19209E-007), FRAC_CONST(4.76837E-008), FRAC_CONST(1.40246E-008), FRAC_CONST(3.66798E-009), FRAC_CONST(9.27699E-010), FRAC_CONST(2.32603E-010), FRAC_CONST(5.81935E-011) }, |
||||
{ FRAC_CONST(1.1918E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(2.38419E-008), FRAC_CONST(7.01231E-009), FRAC_CONST(1.83399E-009), FRAC_CONST(4.63849E-010), FRAC_CONST(1.16302E-010), FRAC_CONST(2.90967E-011) } |
||||
}; |
||||
|
||||
/* calculates Q/(1+Q) */ |
||||
/* [0..1] */ |
||||
static real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) |
||||
{ |
||||
if (sbr->bs_coupling) |
||||
{ |
||||
if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || |
||||
(sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) |
||||
{ |
||||
return 0; |
||||
} else { |
||||
/* the pan parameter is always even */ |
||||
if (ch == 0) |
||||
{ |
||||
return Q_div2_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; |
||||
} else { |
||||
return Q_div2_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; |
||||
} |
||||
} |
||||
} else { |
||||
/* no coupling */ |
||||
if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) |
||||
{ |
||||
return 0; |
||||
} else { |
||||
return Q_div2_tab[sbr->Q[ch][m][l]]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
static const real_t E_deq_tab[64] = { |
||||
64.0f, 128.0f, 256.0f, 512.0f, 1024.0f, 2048.0f, 4096.0f, 8192.0f, |
||||
16384.0f, 32768.0f, 65536.0f, 131072.0f, 262144.0f, 524288.0f, 1.04858E+006f, 2.09715E+006f, |
||||
4.1943E+006f, 8.38861E+006f, 1.67772E+007f, 3.35544E+007f, 6.71089E+007f, 1.34218E+008f, 2.68435E+008f, 5.36871E+008f, |
||||
1.07374E+009f, 2.14748E+009f, 4.29497E+009f, 8.58993E+009f, 1.71799E+010f, 3.43597E+010f, 6.87195E+010f, 1.37439E+011f, |
||||
2.74878E+011f, 5.49756E+011f, 1.09951E+012f, 2.19902E+012f, 4.39805E+012f, 8.79609E+012f, 1.75922E+013f, 3.51844E+013f, |
||||
7.03687E+013f, 1.40737E+014f, 2.81475E+014f, 5.6295E+014f, 1.1259E+015f, 2.2518E+015f, 4.5036E+015f, 9.0072E+015f, |
||||
1.80144E+016f, 3.60288E+016f, 7.20576E+016f, 1.44115E+017f, 2.8823E+017f, 5.76461E+017f, 1.15292E+018f, 2.30584E+018f, |
||||
4.61169E+018f, 9.22337E+018f, 1.84467E+019f, 3.68935E+019f, 7.3787E+019f, 1.47574E+020f, 2.95148E+020f, 5.90296E+020f |
||||
}; |
||||
|
||||
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch) |
||||
{ |
||||
if (sbr->bs_coupling == 0) |
||||
{ |
||||
int16_t exp; |
||||
uint8_t l, k; |
||||
uint8_t amp = (sbr->amp_res[ch]) ? 0 : 1; |
||||
|
||||
for (l = 0; l < sbr->L_E[ch]; l++) |
||||
{ |
||||
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) |
||||
{ |
||||
/* +6 for the *64 and -10 for the /32 in the synthesis QMF (fixed)
|
||||
* since this is a energy value: (x/32)^2 = (x^2)/1024 |
||||
*/ |
||||
/* exp = (sbr->E[ch][k][l] >> amp) + 6; */ |
||||
exp = (sbr->E[ch][k][l] >> amp); |
||||
|
||||
if ((exp < 0) || (exp >= 64)) |
||||
{ |
||||
sbr->E_orig[ch][k][l] = 0; |
||||
} else { |
||||
sbr->E_orig[ch][k][l] = E_deq_tab[exp]; |
||||
|
||||
/* save half the table size at the cost of 1 multiply */ |
||||
if (amp && (sbr->E[ch][k][l] & 1)) |
||||
{ |
||||
sbr->E_orig[ch][k][l] = MUL_C(sbr->E_orig[ch][k][l], COEF_CONST(1.414213562)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (l = 0; l < sbr->L_Q[ch]; l++) |
||||
{ |
||||
for (k = 0; k < sbr->N_Q; k++) |
||||
{ |
||||
sbr->Q_div[ch][k][l] = calc_Q_div(sbr, ch, k, l); |
||||
sbr->Q_div2[ch][k][l] = calc_Q_div2(sbr, ch, k, l); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static const real_t E_pan_tab[25] = { |
||||
FRAC_CONST(0.000244081), FRAC_CONST(0.000488043), |
||||
FRAC_CONST(0.00097561), FRAC_CONST(0.00194932), |
||||
FRAC_CONST(0.00389105), FRAC_CONST(0.00775194), |
||||
FRAC_CONST(0.0153846), FRAC_CONST(0.030303), |
||||
FRAC_CONST(0.0588235), FRAC_CONST(0.111111), |
||||
FRAC_CONST(0.2), FRAC_CONST(0.333333), |
||||
FRAC_CONST(0.5), FRAC_CONST(0.666667), |
||||
FRAC_CONST(0.8), FRAC_CONST(0.888889), |
||||
FRAC_CONST(0.941176), FRAC_CONST(0.969697), |
||||
FRAC_CONST(0.984615), FRAC_CONST(0.992248), |
||||
FRAC_CONST(0.996109), FRAC_CONST(0.998051), |
||||
FRAC_CONST(0.999024), FRAC_CONST(0.999512), |
||||
FRAC_CONST(0.999756) |
||||
}; |
||||
|
||||
void unmap_envelope_noise(sbr_info *sbr) |
||||
{ |
||||
real_t tmp; |
||||
int16_t exp0, exp1; |
||||
uint8_t l, k; |
||||
uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1; |
||||
uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1; |
||||
|
||||
for (l = 0; l < sbr->L_E[0]; l++) |
||||
{ |
||||
for (k = 0; k < sbr->n[sbr->f[0][l]]; k++) |
||||
{ |
||||
/* +6: * 64 ; +1: * 2 ; */ |
||||
exp0 = (sbr->E[0][k][l] >> amp0) + 1; |
||||
|
||||
/* UN_MAP removed: (x / 4096) same as (x >> 12) */ |
||||
/* E[1] is always even so no need for compensating the divide by 2 with
|
||||
* an extra multiplication |
||||
*/ |
||||
/* exp1 = (sbr->E[1][k][l] >> amp1) - 12; */ |
||||
exp1 = (sbr->E[1][k][l] >> amp1); |
||||
|
||||
if ((exp0 < 0) || (exp0 >= 64) || |
||||
(exp1 < 0) || (exp1 > 24)) |
||||
{ |
||||
sbr->E_orig[1][k][l] = 0; |
||||
sbr->E_orig[0][k][l] = 0; |
||||
} else { |
||||
tmp = E_deq_tab[exp0]; |
||||
if (amp0 && (sbr->E[0][k][l] & 1)) |
||||
{ |
||||
tmp = MUL_C(tmp, COEF_CONST(1.414213562)); |
||||
} |
||||
|
||||
/* panning */ |
||||
sbr->E_orig[0][k][l] = MUL_F(tmp, E_pan_tab[exp1]); |
||||
sbr->E_orig[1][k][l] = MUL_F(tmp, E_pan_tab[24 - exp1]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (l = 0; l < sbr->L_Q[0]; l++) |
||||
{ |
||||
for (k = 0; k < sbr->N_Q; k++) |
||||
{ |
||||
sbr->Q_div[0][k][l] = calc_Q_div(sbr, 0, k, l); |
||||
sbr->Q_div[1][k][l] = calc_Q_div(sbr, 1, k, l); |
||||
sbr->Q_div2[0][k][l] = calc_Q_div2(sbr, 0, k, l); |
||||
sbr->Q_div2[1][k][l] = calc_Q_div2(sbr, 1, k, l); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,50 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __SBR_E_NF_H__ |
||||
#define __SBR_E_NF_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
void extract_envelope_data(sbr_info *sbr, uint8_t ch); |
||||
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch); |
||||
#ifndef FIXED_POINT |
||||
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch); |
||||
void unmap_envelope_noise(sbr_info *sbr); |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
@ -0,0 +1,767 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_fbt.c,v 1.21 2007/11/01 12:33:35 menno Exp $ |
||||
**/ |
||||
|
||||
/* Calculate frequency band tables */ |
||||
|
||||
#include "common.h" |
||||
#include "structs.h" |
||||
|
||||
#ifdef SBR_DEC |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#include "sbr_syntax.h" |
||||
#include "sbr_fbt.h" |
||||
|
||||
/* static function declarations */ |
||||
static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1); |
||||
|
||||
|
||||
/* calculate the start QMF channel for the master frequency band table */ |
||||
/* parameter is also called k0 */ |
||||
uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, |
||||
uint32_t sample_rate) |
||||
{ |
||||
static const uint8_t startMinTable[12] = { 7, 7, 10, 11, 12, 16, 16, |
||||
17, 24, 32, 35, 48 }; |
||||
static const uint8_t offsetIndexTable[12] = { 5, 5, 4, 4, 4, 3, 2, 1, 0, |
||||
6, 6, 6 }; |
||||
static const int8_t offset[7][16] = { |
||||
{ -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 }, |
||||
{ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 }, |
||||
{ -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, |
||||
{ -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, |
||||
{ -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20 }, |
||||
{ -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 }, |
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 } |
||||
}; |
||||
uint8_t startMin = startMinTable[get_sr_index(sample_rate)]; |
||||
uint8_t offsetIndex = offsetIndexTable[get_sr_index(sample_rate)]; |
||||
|
||||
#if 0 /* replaced with table (startMinTable) */
|
||||
if (sample_rate >= 64000) |
||||
{ |
||||
startMin = (uint8_t)((5000.*128.)/(float)sample_rate + 0.5); |
||||
} else if (sample_rate < 32000) { |
||||
startMin = (uint8_t)((3000.*128.)/(float)sample_rate + 0.5); |
||||
} else { |
||||
startMin = (uint8_t)((4000.*128.)/(float)sample_rate + 0.5); |
||||
} |
||||
#endif |
||||
|
||||
if (bs_samplerate_mode) |
||||
{ |
||||
return startMin + offset[offsetIndex][bs_start_freq]; |
||||
|
||||
#if 0 /* replaced by offsetIndexTable */
|
||||
switch (sample_rate) |
||||
{ |
||||
case 16000: |
||||
return startMin + offset[0][bs_start_freq]; |
||||
case 22050: |
||||
return startMin + offset[1][bs_start_freq]; |
||||
case 24000: |
||||
return startMin + offset[2][bs_start_freq]; |
||||
case 32000: |
||||
return startMin + offset[3][bs_start_freq]; |
||||
default: |
||||
if (sample_rate > 64000) |
||||
{ |
||||
return startMin + offset[5][bs_start_freq]; |
||||
} else { /* 44100 <= sample_rate <= 64000 */ |
||||
return startMin + offset[4][bs_start_freq]; |
||||
} |
||||
} |
||||
#endif |
||||
} else { |
||||
return startMin + offset[6][bs_start_freq]; |
||||
} |
||||
} |
||||
|
||||
static int int32cmp(const void *a, const void *b) |
||||
{ |
||||
return ((int)(*(int32_t*)a - *(int32_t*)b)); |
||||
} |
||||
|
||||
static int uint8cmp(const void *a, const void *b) |
||||
{ |
||||
return ((int)(*(uint8_t*)a - *(uint8_t*)b)); |
||||
} |
||||
|
||||
/* calculate the stop QMF channel for the master frequency band table */ |
||||
/* parameter is also called k2 */ |
||||
uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, |
||||
uint8_t k0) |
||||
{ |
||||
if (bs_stop_freq == 15) |
||||
{ |
||||
return min(64, k0 * 3); |
||||
} else if (bs_stop_freq == 14) { |
||||
return min(64, k0 * 2); |
||||
} else { |
||||
static const uint8_t stopMinTable[12] = { 13, 15, 20, 21, 23, |
||||
32, 32, 35, 48, 64, 70, 96 }; |
||||
static const int8_t offset[12][14] = { |
||||
{ 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 }, |
||||
{ 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 }, |
||||
{ 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 }, |
||||
{ 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 }, |
||||
{ 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 }, |
||||
{ 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, |
||||
{ 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, |
||||
{ 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 }, |
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 }, |
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
||||
{ 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6 }, |
||||
{ 0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32 } |
||||
}; |
||||
#if 0 |
||||
uint8_t i; |
||||
int32_t stopDk[13], stopDk_t[14], k2; |
||||
#endif |
||||
uint8_t stopMin = stopMinTable[get_sr_index(sample_rate)]; |
||||
|
||||
#if 0 /* replaced by table lookup */
|
||||
if (sample_rate >= 64000) |
||||
{ |
||||
stopMin = (uint8_t)((10000.*128.)/(float)sample_rate + 0.5); |
||||
} else if (sample_rate < 32000) { |
||||
stopMin = (uint8_t)((6000.*128.)/(float)sample_rate + 0.5); |
||||
} else { |
||||
stopMin = (uint8_t)((8000.*128.)/(float)sample_rate + 0.5); |
||||
} |
||||
#endif |
||||
|
||||
#if 0 /* replaced by table lookup */
|
||||
/* diverging power series */ |
||||
for (i = 0; i <= 13; i++) |
||||
{ |
||||
stopDk_t[i] = (int32_t)(stopMin*pow(64.0/stopMin, i/13.0) + 0.5); |
||||
} |
||||
for (i = 0; i < 13; i++) |
||||
{ |
||||
stopDk[i] = stopDk_t[i+1] - stopDk_t[i]; |
||||
} |
||||
|
||||
/* needed? */ |
||||
qsort(stopDk, 13, sizeof(stopDk[0]), int32cmp); |
||||
|
||||
k2 = stopMin; |
||||
for (i = 0; i < bs_stop_freq; i++) |
||||
{ |
||||
k2 += stopDk[i]; |
||||
} |
||||
return min(64, k2); |
||||
#endif |
||||
/* bs_stop_freq <= 13 */ |
||||
return min(64, stopMin + offset[get_sr_index(sample_rate)][min(bs_stop_freq, 13)]); |
||||
} |
||||
|
||||
// return 0;
|
||||
} |
||||
|
||||
/* calculate the master frequency table from k0, k2, bs_freq_scale
|
||||
and bs_alter_scale |
||||
|
||||
version for bs_freq_scale = 0 |
||||
*/ |
||||
uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, |
||||
uint8_t bs_alter_scale) |
||||
{ |
||||
int8_t incr; |
||||
uint8_t k; |
||||
uint8_t dk; |
||||
int32_t nrBands, k2Achieved; |
||||
int32_t k2Diff, vDk[64] = {0}; |
||||
|
||||
/* mft only defined for k2 > k0 */ |
||||
if (k2 <= k0) |
||||
{ |
||||
sbr->N_master = 0; |
||||
return 1; |
||||
} |
||||
|
||||
dk = bs_alter_scale ? 2 : 1; |
||||
|
||||
#if 0 /* replaced by float-less design */
|
||||
nrBands = 2 * (int32_t)((float)(k2-k0)/(dk*2) + (-1+dk)/2.0f); |
||||
#else |
||||
if (bs_alter_scale) |
||||
{ |
||||
nrBands = (((k2-k0+2)>>2)<<1); |
||||
} else { |
||||
nrBands = (((k2-k0)>>1)<<1); |
||||
} |
||||
#endif |
||||
nrBands = min(nrBands, 63); |
||||
if (nrBands <= 0) |
||||
return 1; |
||||
|
||||
k2Achieved = k0 + nrBands * dk; |
||||
k2Diff = k2 - k2Achieved; |
||||
for (k = 0; k < nrBands; k++) |
||||
vDk[k] = dk; |
||||
|
||||
if (k2Diff) |
||||
{ |
||||
incr = (k2Diff > 0) ? -1 : 1; |
||||
k = (uint8_t) ((k2Diff > 0) ? (nrBands-1) : 0); |
||||
|
||||
while (k2Diff != 0) |
||||
{ |
||||
vDk[k] -= incr; |
||||
k += incr; |
||||
k2Diff += incr; |
||||
} |
||||
} |
||||
|
||||
sbr->f_master[0] = k0; |
||||
for (k = 1; k <= nrBands; k++) |
||||
sbr->f_master[k] = (uint8_t)(sbr->f_master[k-1] + vDk[k-1]); |
||||
|
||||
sbr->N_master = (uint8_t)nrBands; |
||||
sbr->N_master = (min(sbr->N_master, 64)); |
||||
|
||||
#if 0 |
||||
printf("f_master[%d]: ", nrBands); |
||||
for (k = 0; k <= nrBands; k++) |
||||
{ |
||||
printf("%d ", sbr->f_master[k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/*
|
||||
This function finds the number of bands using this formula: |
||||
bands * log(a1/a0)/log(2.0) + 0.5 |
||||
*/ |
||||
static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) |
||||
{ |
||||
#ifdef FIXED_POINT |
||||
/* table with log2() values */ |
||||
static const real_t log2Table[65] = { |
||||
COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007), |
||||
COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221), |
||||
COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186), |
||||
COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956), |
||||
COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134), |
||||
COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561), |
||||
COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022), |
||||
COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104), |
||||
COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169), |
||||
COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189), |
||||
COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547), |
||||
COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517), |
||||
COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420), |
||||
COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135), |
||||
COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494), |
||||
COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235), |
||||
COEF_CONST(6.0) |
||||
}; |
||||
real_t r0 = log2Table[a0]; /* coef */ |
||||
real_t r1 = log2Table[a1]; /* coef */ |
||||
real_t r2 = (r1 - r0); /* coef */ |
||||
|
||||
if (warp) |
||||
r2 = MUL_C(r2, COEF_CONST(1.0/1.3)); |
||||
|
||||
/* convert r2 to real and then multiply and round */ |
||||
r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1)); |
||||
|
||||
return (r2 >> REAL_BITS); |
||||
#else |
||||
real_t div = (real_t)log(2.0); |
||||
if (warp) div *= (real_t)1.3; |
||||
|
||||
return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); |
||||
#endif |
||||
} |
||||
|
||||
static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) |
||||
{ |
||||
#ifdef FIXED_POINT |
||||
/* table with log() values */ |
||||
static const real_t logTable[65] = { |
||||
COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887), |
||||
COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491), |
||||
COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728), |
||||
COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011), |
||||
COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792), |
||||
COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159), |
||||
COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660), |
||||
COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045), |
||||
COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615), |
||||
COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461), |
||||
COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157), |
||||
COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017), |
||||
COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327), |
||||
COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852), |
||||
COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439), |
||||
COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264), |
||||
COEF_CONST(4.158883083) |
||||
}; |
||||
/* standard Taylor polynomial coefficients for exp(x) around 0 */ |
||||
/* a polynomial around x=1 is more precise, as most values are around 1.07,
|
||||
but this is just fine already */ |
||||
static const real_t c1 = COEF_CONST(1.0); |
||||
static const real_t c2 = COEF_CONST(1.0/2.0); |
||||
static const real_t c3 = COEF_CONST(1.0/6.0); |
||||
static const real_t c4 = COEF_CONST(1.0/24.0); |
||||
|
||||
real_t r0 = logTable[a0]; /* coef */ |
||||
real_t r1 = logTable[a1]; /* coef */ |
||||
real_t r2 = (r1 - r0) / bands; /* coef */ |
||||
real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2); |
||||
|
||||
return (rexp >> (COEF_BITS-REAL_BITS)); /* real */ |
||||
#else |
||||
return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); |
||||
#endif |
||||
} |
||||
|
||||
/*
|
||||
version for bs_freq_scale > 0 |
||||
*/ |
||||
uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, |
||||
uint8_t bs_freq_scale, uint8_t bs_alter_scale) |
||||
{ |
||||
uint8_t k, bands, twoRegions; |
||||
uint8_t k1; |
||||
uint8_t nrBand0, nrBand1; |
||||
int32_t vDk0[64] = {0}, vDk1[64] = {0}; |
||||
int32_t vk0[64] = {0}, vk1[64] = {0}; |
||||
uint8_t temp1[] = { 6, 5, 4 }; |
||||
real_t q, qk; |
||||
int32_t A_1; |
||||
#ifdef FIXED_POINT |
||||
real_t rk2, rk0; |
||||
#endif |
||||
(void)bs_alter_scale; /* TODO: remove parameter? */ |
||||
|
||||
/* mft only defined for k2 > k0 */ |
||||
if (k2 <= k0) |
||||
{ |
||||
sbr->N_master = 0; |
||||
return 1; |
||||
} |
||||
|
||||
bands = temp1[bs_freq_scale-1]; |
||||
|
||||
#ifdef FIXED_POINT |
||||
rk0 = (real_t)k0 << REAL_BITS; |
||||
rk2 = (real_t)k2 << REAL_BITS; |
||||
if (rk2 > MUL_C(rk0, COEF_CONST(2.2449))) |
||||
#else |
||||
if ((float)k2/(float)k0 > 2.2449) |
||||
#endif |
||||
{ |
||||
twoRegions = 1; |
||||
k1 = k0 << 1; |
||||
} else { |
||||
twoRegions = 0; |
||||
k1 = k2; |
||||
} |
||||
|
||||
nrBand0 = (uint8_t)(2 * find_bands(0, bands, k0, k1)); |
||||
nrBand0 = min(nrBand0, 63); |
||||
if (nrBand0 <= 0) |
||||
return 1; |
||||
|
||||
q = find_initial_power(nrBand0, k0, k1); |
||||
#ifdef FIXED_POINT |
||||
qk = (real_t)k0 << REAL_BITS; |
||||
//A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
|
||||
A_1 = k0; |
||||
#else |
||||
qk = REAL_CONST(k0); |
||||
A_1 = (int32_t)(qk + .5); |
||||
#endif |
||||
for (k = 0; k <= nrBand0; k++) |
||||
{ |
||||
int32_t A_0 = A_1; |
||||
#ifdef FIXED_POINT |
||||
qk = MUL_R(qk,q); |
||||
A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); |
||||
#else |
||||
qk *= q; |
||||
A_1 = (int32_t)(qk + 0.5); |
||||
#endif |
||||
vDk0[k] = A_1 - A_0; |
||||
} |
||||
|
||||
/* needed? */ |
||||
qsort(vDk0, nrBand0, sizeof(vDk0[0]), int32cmp); |
||||
|
||||
vk0[0] = k0; |
||||
for (k = 1; k <= nrBand0; k++) |
||||
{ |
||||
vk0[k] = vk0[k-1] + vDk0[k-1]; |
||||
if (vDk0[k-1] == 0) |
||||
return 1; |
||||
} |
||||
|
||||
if (!twoRegions) |
||||
{ |
||||
for (k = 0; k <= nrBand0; k++) |
||||
sbr->f_master[k] = (uint8_t) vk0[k]; |
||||
|
||||
sbr->N_master = nrBand0; |
||||
sbr->N_master = min(sbr->N_master, 64); |
||||
return 0; |
||||
} |
||||
|
||||
nrBand1 = (uint8_t)(2 * find_bands(1 /* warped */, bands, k1, k2)); |
||||
nrBand1 = min(nrBand1, 63); |
||||
|
||||
q = find_initial_power(nrBand1, k1, k2); |
||||
#ifdef FIXED_POINT |
||||
qk = (real_t)k1 << REAL_BITS; |
||||
//A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
|
||||
A_1 = k1; |
||||
#else |
||||
qk = REAL_CONST(k1); |
||||
A_1 = (int32_t)(qk + .5); |
||||
#endif |
||||
for (k = 0; k <= nrBand1 - 1; k++) |
||||
{ |
||||
int32_t A_0 = A_1; |
||||
#ifdef FIXED_POINT |
||||
qk = MUL_R(qk,q); |
||||
A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); |
||||
#else |
||||
qk *= q; |
||||
A_1 = (int32_t)(qk + 0.5); |
||||
#endif |
||||
vDk1[k] = A_1 - A_0; |
||||
} |
||||
|
||||
if (vDk1[0] < vDk0[nrBand0 - 1]) |
||||
{ |
||||
int32_t change; |
||||
|
||||
/* needed? */ |
||||
qsort(vDk1, nrBand1 + 1, sizeof(vDk1[0]), int32cmp); |
||||
change = vDk0[nrBand0 - 1] - vDk1[0]; |
||||
vDk1[0] = vDk0[nrBand0 - 1]; |
||||
vDk1[nrBand1 - 1] = vDk1[nrBand1 - 1] - change; |
||||
} |
||||
|
||||
/* needed? */ |
||||
qsort(vDk1, nrBand1, sizeof(vDk1[0]), int32cmp); |
||||
vk1[0] = k1; |
||||
for (k = 1; k <= nrBand1; k++) |
||||
{ |
||||
vk1[k] = vk1[k-1] + vDk1[k-1]; |
||||
if (vDk1[k-1] == 0) |
||||
return 1; |
||||
} |
||||
|
||||
sbr->N_master = nrBand0 + nrBand1; |
||||
sbr->N_master = min(sbr->N_master, 64); |
||||
for (k = 0; k <= nrBand0; k++) |
||||
{ |
||||
sbr->f_master[k] = (uint8_t) vk0[k]; |
||||
} |
||||
for (k = nrBand0 + 1; k <= sbr->N_master; k++) |
||||
{ |
||||
sbr->f_master[k] = (uint8_t) vk1[k - nrBand0]; |
||||
} |
||||
|
||||
#if 0 |
||||
printf("f_master[%d]: ", sbr->N_master); |
||||
for (k = 0; k <= sbr->N_master; k++) |
||||
{ |
||||
printf("%d ", sbr->f_master[k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/* calculate the derived frequency border tables from f_master */ |
||||
uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, |
||||
uint8_t k2) |
||||
{ |
||||
uint8_t k, i; |
||||
uint32_t minus; |
||||
|
||||
/* The following relation shall be satisfied: bs_xover_band < N_Master */ |
||||
if (sbr->N_master <= bs_xover_band) |
||||
return 1; |
||||
|
||||
sbr->N_high = sbr->N_master - bs_xover_band; |
||||
sbr->N_low = (sbr->N_high>>1) + (sbr->N_high - ((sbr->N_high>>1)<<1)); |
||||
|
||||
sbr->n[0] = sbr->N_low; |
||||
sbr->n[1] = sbr->N_high; |
||||
|
||||
for (k = 0; k <= sbr->N_high; k++) |
||||
{ |
||||
sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band]; |
||||
} |
||||
|
||||
sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; |
||||
if (sbr->M > MAX_M) |
||||
return 1; |
||||
sbr->kx = sbr->f_table_res[HI_RES][0]; |
||||
if (sbr->kx > 32) |
||||
return 1; |
||||
if (sbr->kx + sbr->M > 64) |
||||
return 1; |
||||
|
||||
minus = (sbr->N_high & 1) ? 1 : 0; |
||||
|
||||
i = 0; |
||||
for (k = 0; k <= sbr->N_low; k++) |
||||
{ |
||||
if (k != 0) |
||||
i = (uint8_t)(2*k - minus); |
||||
sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i]; |
||||
} |
||||
|
||||
#if 0 |
||||
printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); |
||||
printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); |
||||
printf("f_table_res[HI_RES][%d]: ", sbr->N_high); |
||||
for (k = 0; k <= sbr->N_high; k++) |
||||
{ |
||||
printf("%d ", sbr->f_table_res[HI_RES][k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
#if 0 |
||||
printf("f_table_res[LO_RES][%d]: ", sbr->N_low); |
||||
for (k = 0; k <= sbr->N_low; k++) |
||||
{ |
||||
printf("%d ", sbr->f_table_res[LO_RES][k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
|
||||
sbr->N_Q = 0; |
||||
if (sbr->bs_noise_bands == 0) |
||||
{ |
||||
sbr->N_Q = 1; |
||||
} else { |
||||
#if 0 |
||||
sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5)); |
||||
#else |
||||
sbr->N_Q = (uint8_t)(max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2))); |
||||
#endif |
||||
sbr->N_Q = min(5, sbr->N_Q); |
||||
} |
||||
|
||||
i = 0; |
||||
for (k = 0; k <= sbr->N_Q; k++) |
||||
{ |
||||
if (k != 0) |
||||
i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); |
||||
sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; |
||||
} |
||||
|
||||
/* build table for mapping k to g in hf patching */ |
||||
for (k = 0; k < 64; k++) |
||||
{ |
||||
uint8_t g; |
||||
for (g = 0; g < sbr->N_Q; g++) |
||||
{ |
||||
if ((sbr->f_table_noise[g] <= k) && |
||||
(k < sbr->f_table_noise[g+1])) |
||||
{ |
||||
sbr->table_map_k_to_g[k] = g; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
#if 0 |
||||
printf("f_table_noise[%d]: ", sbr->N_Q); |
||||
for (k = 0; k <= sbr->N_Q; k++) |
||||
{ |
||||
printf("%d ", sbr->f_table_noise[k] - sbr->kx); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/* TODO: blegh, ugly */ |
||||
/* Modified to calculate for all possible bs_limiter_bands always
|
||||
* This reduces the number calls to this functions needed (now only on |
||||
* header reset) |
||||
*/ |
||||
void limiter_frequency_table(sbr_info *sbr) |
||||
{ |
||||
#if 0 |
||||
static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2), |
||||
REAL_CONST(2), REAL_CONST(3) }; |
||||
#else |
||||
static const real_t limiterBandsCompare[] = { REAL_CONST(1.327152), |
||||
REAL_CONST(1.185093), REAL_CONST(1.119872) }; |
||||
#endif |
||||
uint8_t k, s; |
||||
int8_t nrLim; |
||||
#if 0 |
||||
real_t limBands; |
||||
#endif |
||||
|
||||
sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx; |
||||
sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx; |
||||
sbr->N_L[0] = 1; |
||||
|
||||
#if 0 |
||||
printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]); |
||||
for (k = 0; k <= sbr->N_L[0]; k++) |
||||
{ |
||||
printf("%d ", sbr->f_table_lim[0][k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
|
||||
for (s = 1; s < 4; s++) |
||||
{ |
||||
uint8_t limTable[100 /*TODO*/] = {0}; |
||||
uint8_t patchBorders[64/*??*/] = {0}; |
||||
|
||||
#if 0 |
||||
limBands = limiterBandsPerOctave[s - 1]; |
||||
#endif |
||||
|
||||
patchBorders[0] = sbr->kx; |
||||
for (k = 1; k <= sbr->noPatches; k++) |
||||
{ |
||||
patchBorders[k] = patchBorders[k-1] + sbr->patchNoSubbands[k-1]; |
||||
} |
||||
|
||||
for (k = 0; k <= sbr->N_low; k++) |
||||
{ |
||||
limTable[k] = sbr->f_table_res[LO_RES][k]; |
||||
} |
||||
for (k = 1; k < sbr->noPatches; k++) |
||||
{ |
||||
limTable[k+sbr->N_low] = patchBorders[k]; |
||||
} |
||||
|
||||
/* needed */ |
||||
qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), uint8cmp); |
||||
k = 1; |
||||
nrLim = sbr->noPatches + sbr->N_low - 1; |
||||
|
||||
if (nrLim < 0) // TODO: BIG FAT PROBLEM
|
||||
return; |
||||
|
||||
restart: |
||||
if (k <= nrLim) |
||||
{ |
||||
real_t nOctaves; |
||||
|
||||
if (limTable[k-1] != 0) |
||||
#if 0 |
||||
nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); |
||||
#else |
||||
#ifdef FIXED_POINT |
||||
nOctaves = DIV_R((limTable[k]<<REAL_BITS),REAL_CONST(limTable[k-1])); |
||||
#else |
||||
nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; |
||||
#endif |
||||
#endif |
||||
else |
||||
nOctaves = 0; |
||||
|
||||
#if 0 |
||||
if ((MUL_R(nOctaves,limBands)) < REAL_CONST(0.49)) |
||||
#else |
||||
if (nOctaves < limiterBandsCompare[s - 1]) |
||||
#endif |
||||
{ |
||||
uint8_t i; |
||||
if (limTable[k] != limTable[k-1]) |
||||
{ |
||||
uint8_t found = 0, found2 = 0; |
||||
for (i = 0; i <= sbr->noPatches; i++) |
||||
{ |
||||
if (limTable[k] == patchBorders[i]) |
||||
found = 1; |
||||
} |
||||
if (found) |
||||
{ |
||||
found2 = 0; |
||||
for (i = 0; i <= sbr->noPatches; i++) |
||||
{ |
||||
if (limTable[k-1] == patchBorders[i]) |
||||
found2 = 1; |
||||
} |
||||
if (found2) |
||||
{ |
||||
k++; |
||||
goto restart; |
||||
} else { |
||||
/* remove (k-1)th element */ |
||||
limTable[k-1] = sbr->f_table_res[LO_RES][sbr->N_low]; |
||||
qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), uint8cmp); |
||||
nrLim--; |
||||
goto restart; |
||||
} |
||||
} |
||||
} |
||||
/* remove kth element */ |
||||
limTable[k] = sbr->f_table_res[LO_RES][sbr->N_low]; |
||||
qsort(limTable, nrLim, sizeof(limTable[0]), uint8cmp); |
||||
nrLim--; |
||||
goto restart; |
||||
} else { |
||||
k++; |
||||
goto restart; |
||||
} |
||||
} |
||||
|
||||
sbr->N_L[s] = nrLim; |
||||
for (k = 0; k <= nrLim; k++) |
||||
{ |
||||
sbr->f_table_lim[s][k] = limTable[k] - sbr->kx; |
||||
} |
||||
|
||||
#if 0 |
||||
printf("f_table_lim[%d][%d]: ", s, sbr->N_L[s]); |
||||
for (k = 0; k <= sbr->N_L[s]; k++) |
||||
{ |
||||
printf("%d ", sbr->f_table_lim[s][k]); |
||||
} |
||||
printf("\n"); |
||||
#endif |
||||
} |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,55 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __SBR_FBT_H__ |
||||
#define __SBR_FBT_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, |
||||
uint32_t sample_rate); |
||||
uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, |
||||
uint8_t k0); |
||||
uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, |
||||
uint8_t bs_alter_scale); |
||||
uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, |
||||
uint8_t bs_freq_scale, uint8_t bs_alter_scale); |
||||
uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, |
||||
uint8_t k2); |
||||
void limiter_frequency_table(sbr_info *sbr); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@ |
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
** |
||||
** This program is free software; you can redistribute it and/or modify |
||||
** it under the terms of the GNU General Public License as published by |
||||
** the Free Software Foundation; either version 2 of the License, or |
||||
** (at your option) any later version. |
||||
** |
||||
** This program is distributed in the hope that it will be useful, |
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
** GNU General Public License for more details. |
||||
** |
||||
** You should have received a copy of the GNU General Public License |
||||
** along with this program; if not, write to the Free Software |
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
** |
||||
** Any non-GPL usage of this software or parts of this software is strictly |
||||
** forbidden. |
||||
** |
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
||||
** |
||||
** Commercial non-GPL licensing of this software is possible. |
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
||||
** |
||||
** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $ |
||||
**/ |
||||
|
||||
#ifndef __SBR_HFADJ_H__ |
||||
#define __SBR_HFADJ_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
typedef struct |
||||
{ |
||||
real_t G_lim_boost[MAX_L_E][MAX_M]; |
||||
real_t Q_M_lim_boost[MAX_L_E][MAX_M]; |
||||
real_t S_M_boost[MAX_L_E][MAX_M]; |
||||
} sbr_hfadj_info; |
||||
|
||||
|
||||
uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] |
||||
#ifdef SBR_LOW_POWER |
||||
,real_t *deg |
||||
#endif |
||||
,uint8_t ch); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue