mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 04:08:57 +08:00
播放器新增支持音频:#945
This commit is contained in:
parent
66f28f52b4
commit
1b674a6ac2
@ -71,9 +71,9 @@ if(ENABLE_HLS)
|
|||||||
aux_source_directory(${MediaServer_Root}/libmpeg/source src_mpeg)
|
aux_source_directory(${MediaServer_Root}/libmpeg/source src_mpeg)
|
||||||
include_directories(${MediaServer_Root}/libmpeg/include)
|
include_directories(${MediaServer_Root}/libmpeg/include)
|
||||||
add_library(mpeg STATIC ${src_mpeg})
|
add_library(mpeg STATIC ${src_mpeg})
|
||||||
if(WIN32)
|
if(MSVC)
|
||||||
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||||
endif(WIN32)
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_MP4)
|
if(ENABLE_MP4)
|
||||||
@ -85,9 +85,9 @@ if(ENABLE_MP4)
|
|||||||
include_directories(${MediaServer_Root}/libflv/include)
|
include_directories(${MediaServer_Root}/libflv/include)
|
||||||
add_library(mov STATIC ${src_mov})
|
add_library(mov STATIC ${src_mov})
|
||||||
add_library(flv STATIC ${src_flv})
|
add_library(flv STATIC ${src_flv})
|
||||||
if(WIN32)
|
if(MSVC)
|
||||||
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||||
endif(WIN32)
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ option(ENABLE_SERVER "Enable Server" true)
|
|||||||
option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
|
option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
|
||||||
option(ENABLE_ASAN "Enable Address Sanitize" false)
|
option(ENABLE_ASAN "Enable Address Sanitize" false)
|
||||||
option(ENABLE_WEBRTC "Enable WebRTC" false)
|
option(ENABLE_WEBRTC "Enable WebRTC" false)
|
||||||
|
option(ENABLE_PLAYER "Enable Player" true)
|
||||||
|
|
||||||
# 添加git版本信息
|
# 添加git版本信息
|
||||||
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
||||||
@ -174,9 +175,9 @@ if (ENABLE_HLS)
|
|||||||
list(APPEND LINK_LIB_LIST mpeg)
|
list(APPEND LINK_LIB_LIST mpeg)
|
||||||
list(APPEND CXX_API_TARGETS mpeg)
|
list(APPEND CXX_API_TARGETS mpeg)
|
||||||
|
|
||||||
if (WIN32)
|
if (MSVC)
|
||||||
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||||
endif (WIN32)
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#添加mov、flv库用于MP4录制
|
#添加mov、flv库用于MP4录制
|
||||||
@ -198,9 +199,9 @@ if (ENABLE_MP4)
|
|||||||
list(APPEND LINK_LIB_LIST mov flv)
|
list(APPEND LINK_LIB_LIST mov flv)
|
||||||
list(APPEND CXX_API_TARGETS mov flv)
|
list(APPEND CXX_API_TARGETS mov flv)
|
||||||
|
|
||||||
if (WIN32)
|
if (MSVC)
|
||||||
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||||
endif (WIN32)
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#添加rtp库用于rtp转ps/ts
|
#添加rtp库用于rtp转ps/ts
|
||||||
@ -249,8 +250,10 @@ endif ()
|
|||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
||||||
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
if (MSVC)
|
||||||
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||||
|
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||||
|
endif ()
|
||||||
elseif (NOT ANDROID OR IOS)
|
elseif (NOT ANDROID OR IOS)
|
||||||
list(APPEND LINK_LIB_LIST pthread)
|
list(APPEND LINK_LIB_LIST pthread)
|
||||||
endif ()
|
endif ()
|
||||||
@ -291,4 +294,9 @@ if (NOT IOS)
|
|||||||
if (ENABLE_SERVER)
|
if (ENABLE_SERVER)
|
||||||
add_subdirectory(server)
|
add_subdirectory(server)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
#播放器
|
||||||
|
if (ENABLE_PLAYER)
|
||||||
|
add_subdirectory(player)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -5,9 +5,9 @@ foreach(TEST_SRC ${TEST_SRC_LIST})
|
|||||||
set(exe_name api_tester_${TEST_EXE_NAME})
|
set(exe_name api_tester_${TEST_EXE_NAME})
|
||||||
add_executable(${exe_name} ${TEST_SRC})
|
add_executable(${exe_name} ${TEST_SRC})
|
||||||
|
|
||||||
if(WIN32)
|
if(MSVC)
|
||||||
set_target_properties(${exe_name} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
set_target_properties(${exe_name} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||||
endif(WIN32)
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${exe_name} mk_api)
|
target_link_libraries(${exe_name} mk_api)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
12
cmake/FindSWRESAMPLE.cmake
Normal file
12
cmake/FindSWRESAMPLE.cmake
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
find_path(SWRESAMPLE_INCLUDE_DIR
|
||||||
|
NAMES libswresample/swresample.h)
|
||||||
|
|
||||||
|
find_library(SWRESAMPLE_LIBRARY
|
||||||
|
NAMES swresample)
|
||||||
|
|
||||||
|
set(SWRESAMPLE_LIBRARIES ${SWRESAMPLE_LIBRARY})
|
||||||
|
set(SWRESAMPLE_INCLUDE_DIRS ${SWRESAMPLE_INCLUDE_DIR})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(SWRESAMPLE DEFAULT_MSG SWRESAMPLE_LIBRARY SWRESAMPLE_INCLUDE_DIR)
|
126
player/AudioSRC.cpp
Normal file
126
player/AudioSRC.cpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Util/logger.h"
|
||||||
|
#include "AudioSRC.h"
|
||||||
|
#include "SDLAudioDevice.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace toolkit;
|
||||||
|
|
||||||
|
AudioSRC::AudioSRC(AudioSRCDelegate *del) {
|
||||||
|
_delegate = del;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioSRC::~AudioSRC() {}
|
||||||
|
|
||||||
|
void AudioSRC::setOutputAudioConfig(const SDL_AudioSpec &cfg) {
|
||||||
|
int freq = _delegate->getPCMSampleRate();
|
||||||
|
int format = _delegate->getPCMFormat();
|
||||||
|
int channels = _delegate->getPCMChannel();
|
||||||
|
if (-1 == SDL_BuildAudioCVT(&_audio_cvt, format, channels, freq, cfg.format, cfg.channels, cfg.freq)) {
|
||||||
|
throw std::runtime_error("the format conversion is not supported");
|
||||||
|
}
|
||||||
|
InfoL << "audio cvt origin format, freq:" << freq << ", format:" << hex << format << dec << ", channels:" << channels;
|
||||||
|
InfoL << "audio cvt info, "
|
||||||
|
<< "needed:" << _audio_cvt.needed
|
||||||
|
<< ", src_format:" << hex << _audio_cvt.src_format
|
||||||
|
<< ", dst_format:" << _audio_cvt.dst_format << dec
|
||||||
|
<< ", rate_incr:" << _audio_cvt.rate_incr
|
||||||
|
<< ", len_mult:" << _audio_cvt.len_mult
|
||||||
|
<< ", len_ratio:" << _audio_cvt.len_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioSRC::setEnableMix(bool flag) {
|
||||||
|
_enabled = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioSRC::getPCMData(char *buf, int size) {
|
||||||
|
if (!_enabled) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!_audio_cvt.needed) {
|
||||||
|
//获取原始数据,不需要频率转换
|
||||||
|
return _delegate->getPCMData(buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int)(size / _audio_cvt.len_ratio) != _origin_size) {
|
||||||
|
_origin_size = size / _audio_cvt.len_ratio;
|
||||||
|
_origin_buf.reset(new char[std::max(_origin_size, size)], [](char *ptr) {
|
||||||
|
delete[] ptr;
|
||||||
|
});
|
||||||
|
InfoL << "origin pcm buffer size is:" << _origin_size << ", target pcm buffer size is:" << size;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto origin_size = _delegate->getPCMData(_origin_buf.get(), _origin_size);
|
||||||
|
if (!origin_size) {
|
||||||
|
//获取数据失败
|
||||||
|
TraceL << "get empty pcm data";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_audio_cvt.buf = (Uint8 *) _origin_buf.get();
|
||||||
|
_audio_cvt.len = origin_size;
|
||||||
|
if (0 != SDL_ConvertAudio(&_audio_cvt)) {
|
||||||
|
WarnL << "SDL_ConvertAudio failed!";
|
||||||
|
_audio_cvt.len_cvt = 0;
|
||||||
|
}
|
||||||
|
if (_audio_cvt.len_cvt) {
|
||||||
|
_target_buf.append(_origin_buf.get(), _audio_cvt.len_cvt);
|
||||||
|
}
|
||||||
|
if (_target_buf.size() < size) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(buf, _target_buf.data(), size);
|
||||||
|
_target_buf.erase(0, size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
AudioPlayer::AudioPlayer() : AudioSRC(this) {
|
||||||
|
_device = SDLAudioDevice::Instance().shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioPlayer::~AudioPlayer() {
|
||||||
|
_device->delChannel(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioPlayer::setup(int sample_rate, int channel, SDL_AudioFormat format) {
|
||||||
|
_sample_rate = sample_rate;
|
||||||
|
_channel = channel;
|
||||||
|
_format = format;
|
||||||
|
_device->addChannel(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_AudioFormat AudioPlayer::getPCMFormat() {
|
||||||
|
return _format;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioPlayer::getPCMSampleRate() {
|
||||||
|
return _sample_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioPlayer::getPCMChannel() {
|
||||||
|
return _channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioPlayer::getPCMData(char *buf, int size) {
|
||||||
|
if (_buffer.size() < size) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(buf, _buffer.data(), size);
|
||||||
|
_buffer.erase(0, size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioPlayer::inputFrame(const char *data, size_t size){
|
||||||
|
_buffer.append(data, size);
|
||||||
|
}
|
86
player/AudioSRC.h
Normal file
86
player/AudioSRC.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AUDIOSRC_H_
|
||||||
|
#define AUDIOSRC_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "SDL2/SDL.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#pragma comment(lib,"SDL2.lib")
|
||||||
|
#endif //defined(_WIN32)
|
||||||
|
|
||||||
|
#include "Network/Buffer.h"
|
||||||
|
#include "SDLAudioDevice.h"
|
||||||
|
#include "FFMpegDecoder.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace toolkit;
|
||||||
|
|
||||||
|
class AudioSRCDelegate {
|
||||||
|
public:
|
||||||
|
virtual ~AudioSRCDelegate() {};
|
||||||
|
virtual SDL_AudioFormat getPCMFormat() = 0;
|
||||||
|
virtual int getPCMSampleRate() = 0;
|
||||||
|
virtual int getPCMChannel() = 0;
|
||||||
|
virtual int getPCMData(char *buf, int size) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//该类实现pcm的重采样
|
||||||
|
class AudioSRC {
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<AudioSRC> Ptr;
|
||||||
|
AudioSRC(AudioSRCDelegate *);
|
||||||
|
virtual ~AudioSRC();
|
||||||
|
|
||||||
|
void setEnableMix(bool flag);
|
||||||
|
void setOutputAudioConfig(const SDL_AudioSpec &cfg);
|
||||||
|
int getPCMData(char *buf, int size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _enabled = true;
|
||||||
|
int _origin_size = 0;
|
||||||
|
std::shared_ptr<char> _origin_buf;
|
||||||
|
AudioSRCDelegate *_delegate = nullptr;
|
||||||
|
BufferLikeString _target_buf;
|
||||||
|
SDL_AudioCVT _audio_cvt;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AudioPlayer : public AudioSRC, private AudioSRCDelegate{
|
||||||
|
public:
|
||||||
|
AudioPlayer();
|
||||||
|
~AudioPlayer() override;
|
||||||
|
|
||||||
|
void setup(int sample_rate, int channel, SDL_AudioFormat format);
|
||||||
|
void inputFrame(const char *data, size_t size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SDL_AudioFormat getPCMFormat() override;
|
||||||
|
int getPCMSampleRate() override;
|
||||||
|
int getPCMChannel() override;
|
||||||
|
int getPCMData(char *buf, int size) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _sample_rate, _channel;
|
||||||
|
SDL_AudioFormat _format;
|
||||||
|
BufferLikeString _buffer;
|
||||||
|
SDLAudioDevice::Ptr _device;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* AUDIOSRC_H_ */
|
110
player/CMakeLists.txt
Normal file
110
player/CMakeLists.txt
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
|
||||||
|
#查找SDL2是否安装
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(SDL2 QUIET IMPORTED_TARGET sdl2)
|
||||||
|
if (SDL2_FOUND)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
link_directories(${SDL2_LIBRARY_DIRS})
|
||||||
|
list(APPEND LINK_LIB_LIST ${SDL2_LIBRARIES})
|
||||||
|
message(STATUS "found library:${SDL2_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
find_package(SDL2 QUIET)
|
||||||
|
if (SDL2_FOUND)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIR})
|
||||||
|
list(APPEND LINK_LIB_LIST ${SDL2_LIBRARY})
|
||||||
|
message(STATUS "found library:${SDL2_LIBRARY}")
|
||||||
|
endif (SDL2_FOUND)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#查找ffmpeg/libutil是否安装
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil)
|
||||||
|
if (AVUTIL_FOUND)
|
||||||
|
include_directories(${AVUTIL_INCLUDE_DIRS})
|
||||||
|
link_directories(${AVUTIL_LIBRARY_DIRS})
|
||||||
|
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
|
||||||
|
message(STATUS "found library:${AVUTIL_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
find_package(AVUTIL QUIET)
|
||||||
|
if (AVUTIL_FOUND)
|
||||||
|
include_directories(${AVUTIL_INCLUDE_DIR})
|
||||||
|
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
|
||||||
|
message(STATUS "found library:${AVUTIL_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#查找ffmpeg/libswresample是否安装
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(SWRESAMPLE QUIET IMPORTED_TARGET libswresample)
|
||||||
|
if (SWRESAMPLE_FOUND)
|
||||||
|
include_directories(${SWRESAMPLE_INCLUDE_DIRS})
|
||||||
|
link_directories(${SWRESAMPLE_LIBRARY_DIRS})
|
||||||
|
list(APPEND LINK_LIB_LIST ${SWRESAMPLE_LIBRARIES})
|
||||||
|
message(STATUS "found library:${SWRESAMPLE_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
find_package(SWRESAMPLE QUIET)
|
||||||
|
if (SWRESAMPLE_FOUND)
|
||||||
|
include_directories(${SWRESAMPLE_INCLUDE_DIR})
|
||||||
|
list(APPEND LINK_LIB_LIST ${SWRESAMPLE_LIBRARIES})
|
||||||
|
message(STATUS "found library:${SWRESAMPLE_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#查找ffmpeg/libavcodec是否安装
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec)
|
||||||
|
if (AVCODEC_FOUND)
|
||||||
|
include_directories(${AVCODEC_INCLUDE_DIRS})
|
||||||
|
link_directories(${AVCODEC_LIBRARY_DIRS})
|
||||||
|
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
|
||||||
|
message(STATUS "found library:${AVCODEC_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
find_package(AVCODEC QUIET)
|
||||||
|
if (AVCODEC_FOUND)
|
||||||
|
include_directories(${AVCODEC_INCLUDE_DIR})
|
||||||
|
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
|
||||||
|
message(STATUS "found library:${AVCODEC_LIBRARIES}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PLAYER_NAME "player")
|
||||||
|
|
||||||
|
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
|
||||||
|
if (SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND AND SWRESAMPLE_FOUND)
|
||||||
|
message(STATUS "${PLAYER_NAME} enabled")
|
||||||
|
else ()
|
||||||
|
message(STATUS "${PLAYER_NAME} disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
aux_source_directory(. SRC_LIST)
|
||||||
|
add_executable(${PLAYER_NAME} ${SRC_LIST})
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set_target_properties(${PLAYER_NAME} PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||||
|
set_target_properties(${PLAYER_NAME} PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
target_link_libraries(${PLAYER_NAME} -Wl,--start-group ${LINK_LIB_LIST} -Wl,--end-group)
|
||||||
|
else ()
|
||||||
|
target_link_libraries(${PLAYER_NAME} ${LINK_LIB_LIST})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
312
player/FFMpegDecoder.cpp
Normal file
312
player/FFMpegDecoder.cpp
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FFMpegDecoder.h"
|
||||||
|
#define MAX_DELAY_SECOND 60
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace mediakit;
|
||||||
|
|
||||||
|
static string ffmpeg_err(int errnum){
|
||||||
|
char errbuf[AV_ERROR_MAX_STRING_SIZE];
|
||||||
|
av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
|
||||||
|
return errbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<bool decoder = true, typename ...ARGS>
|
||||||
|
AVCodec *getCodecByName(ARGS ...names);
|
||||||
|
|
||||||
|
template<bool decoder = true, typename ...ARGS>
|
||||||
|
AVCodec *getCodecByName(const char *name) {
|
||||||
|
auto codec = decoder ? avcodec_find_decoder_by_name(name) : avcodec_find_encoder_by_name(name);
|
||||||
|
if (codec) {
|
||||||
|
InfoL << (decoder ? "got decoder:" : "got encoder:") << name;
|
||||||
|
}
|
||||||
|
return codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool decoder = true, typename ...ARGS>
|
||||||
|
AVCodec *getCodecByName(const char *name, ARGS ...names) {
|
||||||
|
auto codec = getCodecByName<decoder>(names...);
|
||||||
|
if (codec) {
|
||||||
|
return codec;
|
||||||
|
}
|
||||||
|
return getCodecByName<decoder>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool decoder = true>
|
||||||
|
AVCodec *getCodec(enum AVCodecID id) {
|
||||||
|
auto codec = decoder ? avcodec_find_decoder(id) : avcodec_find_encoder(id);
|
||||||
|
if (codec) {
|
||||||
|
InfoL << (decoder ? "got decoder:" : "got encoder:") << avcodec_get_name(id);
|
||||||
|
}
|
||||||
|
return codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool decoder = true, typename ...ARGS>
|
||||||
|
AVCodec *getCodec(enum AVCodecID id, ARGS ...names) {
|
||||||
|
auto codec = getCodecByName<decoder>(names...);
|
||||||
|
if (codec) {
|
||||||
|
return codec;
|
||||||
|
}
|
||||||
|
return getCodec<decoder>(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FFmpegFrame::FFmpegFrame(std::shared_ptr<AVFrame> frame) {
|
||||||
|
if (frame) {
|
||||||
|
_frame = std::move(frame);
|
||||||
|
} else {
|
||||||
|
_frame.reset(av_frame_alloc(), [](AVFrame *ptr) {
|
||||||
|
av_frame_unref(ptr);
|
||||||
|
av_frame_free(&ptr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FFmpegFrame::~FFmpegFrame(){
|
||||||
|
if (_data) {
|
||||||
|
delete[] _data;
|
||||||
|
_data = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AVFrame *FFmpegFrame::get() const{
|
||||||
|
return _frame.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FFmpegSwr::FFmpegSwr(AVSampleFormat output, int channel, int channel_layout, int samplerate){
|
||||||
|
_target_format = output;
|
||||||
|
_target_channels = channel;
|
||||||
|
_target_channel_layout = channel_layout;
|
||||||
|
_target_samplerate = samplerate;
|
||||||
|
_frame_pool.setSize(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
FFmpegSwr::~FFmpegSwr(){
|
||||||
|
if (_ctx) {
|
||||||
|
swr_free(&_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FFmpegFrame::Ptr FFmpegSwr::inputFrame(const FFmpegFrame::Ptr &frame){
|
||||||
|
if (frame->get()->format == _target_format &&
|
||||||
|
frame->get()->channels == _target_channels &&
|
||||||
|
frame->get()->channel_layout == _target_channel_layout &&
|
||||||
|
frame->get()->sample_rate == _target_samplerate) {
|
||||||
|
//不转格式
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
if (!_ctx) {
|
||||||
|
_ctx = swr_alloc_set_opts(nullptr, _target_channel_layout, _target_format, _target_samplerate,
|
||||||
|
frame->get()->channel_layout, (AVSampleFormat) frame->get()->format,
|
||||||
|
frame->get()->sample_rate, 0, nullptr);
|
||||||
|
InfoL << "swr_alloc_set_opts:" << av_get_sample_fmt_name((enum AVSampleFormat) frame->get()->format) << " -> "
|
||||||
|
<< av_get_sample_fmt_name(_target_format);
|
||||||
|
}
|
||||||
|
if (_ctx) {
|
||||||
|
FFmpegFrame::Ptr out = _frame_pool.obtain();
|
||||||
|
out->get()->format = _target_format;
|
||||||
|
out->get()->channel_layout = _target_channel_layout;
|
||||||
|
out->get()->channels = _target_channels;
|
||||||
|
out->get()->sample_rate = _target_samplerate;
|
||||||
|
out->get()->pkt_dts = frame->get()->pkt_dts;
|
||||||
|
out->get()->pkt_pts = frame->get()->pkt_pts;
|
||||||
|
out->get()->pts = frame->get()->pts;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
if(0 != (ret = swr_convert_frame(_ctx, out->get(), frame->get()))){
|
||||||
|
WarnL << "swr_convert_frame failed:" << ffmpeg_err(ret);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
//修正大小
|
||||||
|
out->get()->linesize[0] = out->get()->nb_samples * out->get()->channels * av_get_bytes_per_sample((enum AVSampleFormat)out->get()->format);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
void FFmpegFrame::fillPicture(AVPixelFormat target_format, int target_width, int target_height){
|
||||||
|
assert(_data == nullptr);
|
||||||
|
_data = new char[avpicture_get_size(target_format, target_width, target_height)];
|
||||||
|
avpicture_fill((AVPicture *) _frame.get(), (uint8_t *) _data, target_format, target_width, target_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track) {
|
||||||
|
_frame_pool.setSize(8);
|
||||||
|
avcodec_register_all();
|
||||||
|
AVCodec *codec = nullptr;
|
||||||
|
AVCodec *codec_default = nullptr;
|
||||||
|
switch (track->getCodecId()) {
|
||||||
|
case CodecH264:
|
||||||
|
codec_default = getCodec(AV_CODEC_ID_H264);
|
||||||
|
codec = getCodec(AV_CODEC_ID_H264, "h264_cuvid","h264_videotoolbox");
|
||||||
|
break;
|
||||||
|
case CodecH265:
|
||||||
|
codec_default = getCodec(AV_CODEC_ID_HEVC);
|
||||||
|
codec = getCodec(AV_CODEC_ID_HEVC, "hevc_cuvid","hevc_videotoolbox");
|
||||||
|
break;
|
||||||
|
case CodecAAC:
|
||||||
|
codec = getCodec(AV_CODEC_ID_AAC);
|
||||||
|
break;
|
||||||
|
case CodecG711A:
|
||||||
|
codec = getCodec(AV_CODEC_ID_PCM_ALAW);
|
||||||
|
break;
|
||||||
|
case CodecG711U:
|
||||||
|
codec = getCodec(AV_CODEC_ID_PCM_MULAW);
|
||||||
|
break;
|
||||||
|
case CodecOpus:
|
||||||
|
codec = getCodec(AV_CODEC_ID_OPUS);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!codec) {
|
||||||
|
throw std::runtime_error("未找到解码器");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
_context.reset(avcodec_alloc_context3(codec), [](AVCodecContext *ctx) {
|
||||||
|
avcodec_close(ctx);
|
||||||
|
avcodec_free_context(&ctx);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!_context) {
|
||||||
|
throw std::runtime_error("创建解码器失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存AVFrame的引用
|
||||||
|
_context->refcounted_frames = 1;
|
||||||
|
_context->flags |= AV_CODEC_FLAG_LOW_DELAY;
|
||||||
|
_context->flags2 |= AV_CODEC_FLAG2_FAST;
|
||||||
|
|
||||||
|
switch (track->getCodecId()) {
|
||||||
|
case CodecG711A:
|
||||||
|
case CodecG711U: {
|
||||||
|
AudioTrack::Ptr audio = static_pointer_cast<AudioTrack>(track);
|
||||||
|
_context->channels = audio->getAudioChannel();
|
||||||
|
_context->sample_rate = audio->getAudioSampleRate();
|
||||||
|
_context->channel_layout = _context->channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
AVDictionary *dict = nullptr;
|
||||||
|
av_dict_set(&dict, "threads", to_string(thread::hardware_concurrency()).data(), 0);
|
||||||
|
av_dict_set(&dict, "zerolatency", "1", 0);
|
||||||
|
av_dict_set(&dict, "strict", "-2", 0);
|
||||||
|
|
||||||
|
if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
|
||||||
|
/* we do not send complete frames */
|
||||||
|
_context->flags |= AV_CODEC_FLAG_TRUNCATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = avcodec_open2(_context.get(), codec, &dict);
|
||||||
|
if (ret >= 0) {
|
||||||
|
//成功
|
||||||
|
InfoL << "打开解码器成功:" << codec->name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codec_default && codec_default != codec) {
|
||||||
|
//硬件编解码器打开失败,尝试软件的
|
||||||
|
WarnL << "打开解码器" << codec->name << "失败,原因是:" << ffmpeg_err(ret) << ", 再尝试打开解码器" << codec_default->name;
|
||||||
|
codec = codec_default;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw std::runtime_error(StrPrinter << "打开解码器" << codec->name << "失败:" << ffmpeg_err(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::flush(){
|
||||||
|
while (true) {
|
||||||
|
FFmpegFrame::Ptr out_frame = _frame_pool.obtain();
|
||||||
|
auto ret = avcodec_receive_frame(_context.get(), out_frame->get());
|
||||||
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ret < 0) {
|
||||||
|
WarnL << "avcodec_receive_frame failed:" << ffmpeg_err(ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
onDecode(out_frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const AVCodecContext *FFmpegDecoder::getContext() const{
|
||||||
|
return _context.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::inputFrame(const Frame::Ptr &frame) {
|
||||||
|
inputFrame(frame->data(), frame->size(), frame->dts(), frame->pts());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::inputFrame(const char *data, size_t size, uint32_t dts, uint32_t pts) {
|
||||||
|
AVPacket pkt;
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
|
||||||
|
pkt.data = (uint8_t *) data;
|
||||||
|
pkt.size = size;
|
||||||
|
pkt.dts = dts;
|
||||||
|
pkt.pts = pts;
|
||||||
|
|
||||||
|
auto ret = avcodec_send_packet(_context.get(), &pkt);
|
||||||
|
if (ret < 0) {
|
||||||
|
if (ret != AVERROR_INVALIDDATA) {
|
||||||
|
WarnL << "avcodec_send_packet failed:" << ffmpeg_err(ret);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
FFmpegFrame::Ptr out_frame = _frame_pool.obtain();
|
||||||
|
ret = avcodec_receive_frame(_context.get(), out_frame->get());
|
||||||
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ret < 0) {
|
||||||
|
WarnL << "avcodec_receive_frame failed:" << ffmpeg_err(ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pts - out_frame->get()->pkt_pts > MAX_DELAY_SECOND * 1000 && _ticker.createdTime() > 10 * 1000) {
|
||||||
|
//后面的帧才忽略,防止Track无法ready
|
||||||
|
WarnL << "解码时,忽略" << MAX_DELAY_SECOND << "秒前的数据:" << pts << " " << out_frame->get()->pkt_pts;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
onDecode(out_frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::setOnDecode(FFmpegDecoder::onDec cb) {
|
||||||
|
_cb = std::move(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::onDecode(const FFmpegFrame::Ptr &frame){
|
||||||
|
if (_context->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
|
if (!_swr) {
|
||||||
|
//固定输出16位整型的pcm
|
||||||
|
_swr = std::make_shared<FFmpegSwr>(AV_SAMPLE_FMT_S16, frame->get()->channels, frame->get()->channel_layout, frame->get()->sample_rate);
|
||||||
|
}
|
||||||
|
//音频情况下,转换音频format类型,比如说浮点型转换为int型
|
||||||
|
const_cast<FFmpegFrame::Ptr &>(frame) = _swr->inputFrame(frame);
|
||||||
|
}
|
||||||
|
if (_cb && frame) {
|
||||||
|
_cb(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
92
player/FFMpegDecoder.h
Normal file
92
player/FFMpegDecoder.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FFMpegDecoder_H_
|
||||||
|
#define FFMpegDecoder_H_
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include "Extension/Frame.h"
|
||||||
|
#include "Extension/Track.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "libavcodec/avcodec.h"
|
||||||
|
#include "libswresample/swresample.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace mediakit;
|
||||||
|
|
||||||
|
class FFmpegFrame {
|
||||||
|
public:
|
||||||
|
using Ptr = std::shared_ptr<FFmpegFrame>;
|
||||||
|
|
||||||
|
FFmpegFrame(std::shared_ptr<AVFrame> frame = nullptr);
|
||||||
|
~FFmpegFrame();
|
||||||
|
|
||||||
|
AVFrame *get() const;
|
||||||
|
void fillPicture(AVPixelFormat target_format, int target_width, int target_height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
char *_data = nullptr;
|
||||||
|
std::shared_ptr<AVFrame> _frame;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FFmpegSwr{
|
||||||
|
public:
|
||||||
|
using Ptr = std::shared_ptr<FFmpegSwr>;
|
||||||
|
|
||||||
|
FFmpegSwr(AVSampleFormat output, int channel, int channel_layout, int samplerate);
|
||||||
|
~FFmpegSwr();
|
||||||
|
|
||||||
|
FFmpegFrame::Ptr inputFrame(const FFmpegFrame::Ptr &frame);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _target_channels;
|
||||||
|
int _target_channel_layout;
|
||||||
|
int _target_samplerate;
|
||||||
|
AVSampleFormat _target_format;
|
||||||
|
SwrContext *_ctx = nullptr;
|
||||||
|
ResourcePool<FFmpegFrame> _frame_pool;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FFmpegDecoder : public FrameWriterInterface {
|
||||||
|
public:
|
||||||
|
using Ptr = std::shared_ptr<FFmpegDecoder>;
|
||||||
|
using onDec = function<void(const FFmpegFrame::Ptr &)>;
|
||||||
|
|
||||||
|
FFmpegDecoder(const Track::Ptr &track);
|
||||||
|
~FFmpegDecoder() {}
|
||||||
|
|
||||||
|
void inputFrame(const Frame::Ptr &frame) override;
|
||||||
|
void inputFrame(const char *data, size_t size, uint32_t dts, uint32_t pts);
|
||||||
|
|
||||||
|
void setOnDecode(onDec cb);
|
||||||
|
void flush();
|
||||||
|
const AVCodecContext *getContext() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onDecode(const FFmpegFrame::Ptr &frame);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ticker _ticker;
|
||||||
|
onDec _cb;
|
||||||
|
FFmpegSwr::Ptr _swr;
|
||||||
|
ResourcePool<FFmpegFrame> _frame_pool;
|
||||||
|
std::shared_ptr<AVCodecContext> _context;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FFMpegDecoder_H_ */
|
||||||
|
|
||||||
|
|
93
player/SDLAudioDevice.cpp
Normal file
93
player/SDLAudioDevice.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Util/logger.h"
|
||||||
|
#include "AudioSRC.h"
|
||||||
|
#include "SDLAudioDevice.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace toolkit;
|
||||||
|
|
||||||
|
INSTANCE_IMP(SDLAudioDevice);
|
||||||
|
|
||||||
|
SDLAudioDevice::~SDLAudioDevice() {
|
||||||
|
SDL_CloseAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDLAudioDevice::SDLAudioDevice() {
|
||||||
|
SDL_AudioSpec wanted_spec;
|
||||||
|
wanted_spec.freq = DEFAULT_SAMPLERATE;
|
||||||
|
wanted_spec.format = DEFAULT_FORMAT;
|
||||||
|
wanted_spec.channels = DEFAULT_CHANNEL;
|
||||||
|
wanted_spec.silence = 0;
|
||||||
|
wanted_spec.samples = DEFAULT_SAMPLES;
|
||||||
|
wanted_spec.userdata = this;
|
||||||
|
wanted_spec.callback = [](void *userdata, Uint8 *stream, int len) {
|
||||||
|
SDLAudioDevice *_this = (SDLAudioDevice *) userdata;
|
||||||
|
_this->onReqPCM((char *) stream, len);
|
||||||
|
};
|
||||||
|
if (SDL_OpenAudio(&wanted_spec, &_audio_config) < 0) {
|
||||||
|
throw std::runtime_error("SDL_OpenAudio failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoL << "actual audioSpec, " << "freq:" << _audio_config.freq
|
||||||
|
<< ", format:" << hex << _audio_config.format << dec
|
||||||
|
<< ", channels:" << (int) _audio_config.channels
|
||||||
|
<< ", samples:" << _audio_config.samples
|
||||||
|
<< ", pcm size:" << _audio_config.size;
|
||||||
|
|
||||||
|
_play_buf.reset(new char[_audio_config.size], [](char *ptr) {
|
||||||
|
delete[] ptr;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLAudioDevice::addChannel(AudioSRC *chn) {
|
||||||
|
lock_guard<recursive_mutex> lck(_channel_mtx);
|
||||||
|
if (_channels.empty()) {
|
||||||
|
SDL_PauseAudio(0);
|
||||||
|
}
|
||||||
|
chn->setOutputAudioConfig(_audio_config);
|
||||||
|
_channels.emplace(chn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLAudioDevice::delChannel(AudioSRC *chn) {
|
||||||
|
lock_guard<recursive_mutex> lck(_channel_mtx);
|
||||||
|
_channels.erase(chn);
|
||||||
|
if (_channels.empty()) {
|
||||||
|
SDL_PauseAudio(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLAudioDevice::onReqPCM(char *stream, int len) {
|
||||||
|
lock_guard<recursive_mutex> lck(_channel_mtx);
|
||||||
|
int size;
|
||||||
|
int channel = 0;
|
||||||
|
for (auto &chn : _channels) {
|
||||||
|
if (channel == 0) {
|
||||||
|
size = chn->getPCMData(_play_buf.get(), len);
|
||||||
|
if (size) {
|
||||||
|
memcpy(stream, _play_buf.get(), size);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
size = chn->getPCMData(_play_buf.get(), len);
|
||||||
|
if (size) {
|
||||||
|
SDL_MixAudio((Uint8 *) stream, (Uint8 *) _play_buf.get(), size, SDL_MIX_MAXVOLUME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size) {
|
||||||
|
channel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!channel) {
|
||||||
|
memset(stream, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
50
player/SDLAudioDevice.h
Normal file
50
player/SDLAudioDevice.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SDLAUDIOMIXER_SDLAUDIODEVICE_H_
|
||||||
|
#define SDLAUDIOMIXER_SDLAUDIODEVICE_H_
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#define DEFAULT_SAMPLERATE 48000
|
||||||
|
#define DEFAULT_FORMAT AUDIO_S16
|
||||||
|
#define DEFAULT_CHANNEL 2
|
||||||
|
#define DEFAULT_SAMPLES 1024
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class AudioSRC;
|
||||||
|
|
||||||
|
//该对象主要实现sdl混音与播放
|
||||||
|
class SDLAudioDevice : public std::enable_shared_from_this<SDLAudioDevice>{
|
||||||
|
public:
|
||||||
|
using Ptr = std::shared_ptr<SDLAudioDevice>;
|
||||||
|
|
||||||
|
~SDLAudioDevice();
|
||||||
|
static SDLAudioDevice &Instance();
|
||||||
|
|
||||||
|
void addChannel(AudioSRC *chn);
|
||||||
|
void delChannel(AudioSRC *chn);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SDLAudioDevice();
|
||||||
|
void onReqPCM(char *stream, int len);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<char> _play_buf;
|
||||||
|
SDL_AudioSpec _audio_config;
|
||||||
|
recursive_mutex _channel_mtx;
|
||||||
|
unordered_set<AudioSRC *> _channels;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SDLAUDIOMIXER_SDLAUDIODEVICE_H_ */
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by MIT license that can be found in the
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
* LICENSE file in the root of the source tree. All contributing project authors
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
@ -99,8 +99,9 @@ private:
|
|||||||
|
|
||||||
class YuvDisplayer {
|
class YuvDisplayer {
|
||||||
public:
|
public:
|
||||||
YuvDisplayer(void *hwnd = nullptr,const char *title = "untitled"){
|
using Ptr = std::shared_ptr<YuvDisplayer>;
|
||||||
|
|
||||||
|
YuvDisplayer(void *hwnd = nullptr,const char *title = "untitled"){
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) == -1) {
|
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) == -1) {
|
||||||
string err = "初始化SDL失败:";
|
string err = "初始化SDL失败:";
|
115
player/test_player.cpp
Normal file
115
player/test_player.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by MIT license that can be found in the
|
||||||
|
* LICENSE file in the root of the source tree. All contributing project authors
|
||||||
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include "Util/logger.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include "Rtsp/UDPServer.h"
|
||||||
|
#include "Player/MediaPlayer.h"
|
||||||
|
#include "Util/onceToken.h"
|
||||||
|
#include "FFMpegDecoder.h"
|
||||||
|
#include "YuvDisplayer.h"
|
||||||
|
#include "AudioSRC.h"
|
||||||
|
using namespace std;
|
||||||
|
using namespace toolkit;
|
||||||
|
using namespace mediakit;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <TCHAR.h>
|
||||||
|
|
||||||
|
extern int __argc;
|
||||||
|
extern TCHAR** __targv;
|
||||||
|
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstanc, LPSTR lpCmdLine, int nShowCmd) {
|
||||||
|
int argc = __argc;
|
||||||
|
char **argv = __targv;
|
||||||
|
|
||||||
|
//1. 首先调用AllocConsole创建一个控制台窗口
|
||||||
|
AllocConsole();
|
||||||
|
|
||||||
|
//2. 但此时调用cout或者printf都不能正常输出文字到窗口(包括输入流cin和scanf), 所以需要如下重定向输入输出流:
|
||||||
|
FILE* stream;
|
||||||
|
freopen_s(&stream, "CON", "r", stdin);//重定向输入流
|
||||||
|
freopen_s(&stream, "CON", "w", stdout);//重定向输入流
|
||||||
|
|
||||||
|
//3. 如果我们需要用到控制台窗口句柄,可以调用FindWindow取得:
|
||||||
|
HWND _consoleHwnd;
|
||||||
|
SetConsoleTitleA("test_player");//设置窗口名
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
#endif
|
||||||
|
static char *url = argv[1];
|
||||||
|
//设置退出信号处理函数
|
||||||
|
signal(SIGINT, [](int) { SDLDisplayerHelper::Instance().shutdown(); });
|
||||||
|
//设置日志
|
||||||
|
Logger::Instance().add(std::make_shared<ConsoleChannel>());
|
||||||
|
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||||
|
|
||||||
|
if (argc != 3) {
|
||||||
|
ErrorL << "\r\n测试方法:./test_player rtxp_url rtp_type\r\n"
|
||||||
|
<< "例如:./test_player rtsp://admin:123456@127.0.0.1/live/0 0\r\n"
|
||||||
|
<< endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto player = std::make_shared<MediaPlayer>();
|
||||||
|
//sdl要求在main线程初始化
|
||||||
|
auto displayer = std::make_shared<YuvDisplayer>(nullptr, url);
|
||||||
|
weak_ptr<MediaPlayer> weakPlayer = player;
|
||||||
|
player->setOnPlayResult([weakPlayer, displayer](const SockException &ex) {
|
||||||
|
InfoL << "OnPlayResult:" << ex.what();
|
||||||
|
auto strongPlayer = weakPlayer.lock();
|
||||||
|
if (ex || !strongPlayer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto videoTrack = dynamic_pointer_cast<VideoTrack>(strongPlayer->getTrack(TrackVideo, false));
|
||||||
|
auto audioTrack = dynamic_pointer_cast<AudioTrack>(strongPlayer->getTrack(TrackAudio,false));
|
||||||
|
|
||||||
|
if (videoTrack) {
|
||||||
|
auto decoder = std::make_shared<FFmpegDecoder>(videoTrack);
|
||||||
|
decoder->setOnDecode([displayer](const FFmpegFrame::Ptr &yuv) {
|
||||||
|
SDLDisplayerHelper::Instance().doTask([yuv, displayer]() {
|
||||||
|
//sdl要求在main线程渲染
|
||||||
|
displayer->displayYUV(yuv->get());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
auto merger = std::make_shared<FrameMerger>(FrameMerger::h264_prefix);
|
||||||
|
auto delegate = std::make_shared<FrameWriterInterfaceHelper>([decoder, merger](const Frame::Ptr &frame) {
|
||||||
|
merger->inputFrame(frame, [&](uint32_t dts, uint32_t pts, const Buffer::Ptr &buffer, bool have_idr) {
|
||||||
|
decoder->inputFrame(buffer->data(), buffer->size(), dts, pts);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
videoTrack->addDelegate(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioTrack) {
|
||||||
|
auto decoder = std::make_shared<FFmpegDecoder>(audioTrack);
|
||||||
|
auto audio_player = std::make_shared<AudioPlayer>();
|
||||||
|
//FFmpeg解码时已经统一转换为16位整型pcm
|
||||||
|
audio_player->setup(audioTrack->getAudioSampleRate(), audioTrack->getAudioChannel(), AUDIO_S16);
|
||||||
|
decoder->setOnDecode([audio_player](const FFmpegFrame::Ptr &pcm) {
|
||||||
|
audio_player->inputFrame((const char *) (pcm->get()->data[0]), pcm->get()->linesize[0]);
|
||||||
|
});
|
||||||
|
auto audio_delegate = std::make_shared<FrameWriterInterfaceHelper>( [decoder](const Frame::Ptr &frame) {
|
||||||
|
decoder->inputFrame(frame);
|
||||||
|
});
|
||||||
|
audioTrack->addDelegate(audio_delegate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
(*player)[kRtpType] = atoi(argv[2]);
|
||||||
|
player->play(argv[1]);
|
||||||
|
SDLDisplayerHelper::Instance().runLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ file(GLOB MediaServer_src_list ./*.cpp ./*.h)
|
|||||||
|
|
||||||
add_executable(MediaServer ${MediaServer_src_list})
|
add_executable(MediaServer ${MediaServer_src_list})
|
||||||
|
|
||||||
if(WIN32)
|
if(MSVC)
|
||||||
set_target_properties(MediaServer PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
set_target_properties(MediaServer PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||||
else()
|
else()
|
||||||
install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE})
|
install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE})
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
#include "AudioDecoder.h"
|
|
||||||
|
|
||||||
|
|
||||||
AudioDecoder::AudioDecoder():handle_(nullptr)
|
|
||||||
, samplerate_(0)
|
|
||||||
, channels_(2)
|
|
||||||
, samplebit_(16)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioDecoder::~AudioDecoder(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AudioDecoder::init(unsigned char * ADTSHead ,int headLen ){
|
|
||||||
if( handle_ == nullptr ){
|
|
||||||
handle_ = NeAACDecOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( handle_ == nullptr ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long err = NeAACDecInit( handle_ , ( unsigned char *)ADTSHead , headLen , &samplerate_, &channels_ );
|
|
||||||
|
|
||||||
if( err != 0 ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AudioDecoder::inputData( unsigned char * data,int len , unsigned char ** outBuffer ){
|
|
||||||
|
|
||||||
NeAACDecFrameInfo frameInfo;
|
|
||||||
*outBuffer = static_cast<unsigned char *>(NeAACDecDecode(handle_, &frameInfo, (unsigned char *) data, len));
|
|
||||||
|
|
||||||
if( frameInfo.error != 0){
|
|
||||||
//ErroL << NeAACDecGetErrorMessage(frameInfo.error) << endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return frameInfo.samples*frameInfo.channels;
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AUDIO_AUDIODECODER_H
|
|
||||||
#define AUDIO_AUDIODECODER_H
|
|
||||||
|
|
||||||
#include "libFaad/faad.h"
|
|
||||||
|
|
||||||
class AudioDecoder {
|
|
||||||
public:
|
|
||||||
AudioDecoder();
|
|
||||||
|
|
||||||
virtual ~AudioDecoder();
|
|
||||||
|
|
||||||
|
|
||||||
bool init(unsigned char * ADTSHead ,int headLen =7);
|
|
||||||
|
|
||||||
int inputData( unsigned char * data,int len , unsigned char ** outBuffer );
|
|
||||||
|
|
||||||
unsigned long getChannels() const { return channels_ ;}
|
|
||||||
unsigned long getSampleRate() const { return samplerate_ ; }
|
|
||||||
unsigned long getSampleBit() const { return samplebit_ ;}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
NeAACDecHandle handle_;
|
|
||||||
unsigned long samplerate_;
|
|
||||||
unsigned char channels_;
|
|
||||||
unsigned char samplebit_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //AUDIO_AUDIODECODER_H
|
|
@ -1,79 +0,0 @@
|
|||||||
|
|
||||||
#include "AudioPlayer.h"
|
|
||||||
|
|
||||||
#include "Util/util.h"
|
|
||||||
#include "Util/logger.h"
|
|
||||||
|
|
||||||
using namespace toolkit;
|
|
||||||
|
|
||||||
AudioPlayer::AudioPlayer( int sampleRate ,int channels ,int sampleBit):
|
|
||||||
sampleRate_(sampleRate)
|
|
||||||
,channels_(channels)
|
|
||||||
,sampleBit_(sampleBit)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioPlayer::~AudioPlayer(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int AudioPlayer::getPCMData(char *buf, int bufsize) {
|
|
||||||
|
|
||||||
if( buffer_->IsEmpty() ){
|
|
||||||
WarnL << "Audio Data Not Ready!";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PcmPacket pcm;
|
|
||||||
buffer_->Pop(pcm);
|
|
||||||
|
|
||||||
if( bufsize > pcm.data.size() ){
|
|
||||||
bufsize = pcm.data.size() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy( buf , pcm.data.data() , bufsize );
|
|
||||||
return pcm.data.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AudioPlayer::inputFrame( Frame::Ptr frame ){
|
|
||||||
unsigned char *pSampleBuffer = nullptr ;
|
|
||||||
|
|
||||||
if( decoder_ == nullptr ){
|
|
||||||
decoder_ = new AudioDecoder;
|
|
||||||
bool ret = decoder_->init( (unsigned char *)frame->data() );
|
|
||||||
buffer_ = new xRingBuffer<PcmPacket> ( 16 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( audioSrc_ == nullptr ){
|
|
||||||
audioSrc_ = new AudioSRC(this) ;
|
|
||||||
SDLAudioDevice::Instance().addChannel( audioSrc_ );
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = decoder_->inputData( (unsigned char *)frame->data() ,frame->size(), &pSampleBuffer );
|
|
||||||
|
|
||||||
if( size < 0 ){
|
|
||||||
ErrorL << "Audio Decode Error!!" << endl;
|
|
||||||
}else{
|
|
||||||
buf_.append((char*)pSampleBuffer , size);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t offset = 0 ;
|
|
||||||
int i = 0;
|
|
||||||
int ms = 1000 * reqSize_ / ( decoder_->getChannels()*decoder_->getSampleRate()*decoder_->getSampleBit() / 8);
|
|
||||||
|
|
||||||
while( buf_.size() - offset > reqSize_ ){
|
|
||||||
PcmPacket pcm;
|
|
||||||
pcm.data.assign( buf_.data() + offset , reqSize_ );
|
|
||||||
pcm.timeStmp = i*ms + frame->dts();
|
|
||||||
buffer_->Push(std::move(pcm));
|
|
||||||
++i;
|
|
||||||
offset += reqSize_;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(offset){
|
|
||||||
buf_.erase(0,offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/* MIT License
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AUDIO_AUDIOPLAYER_H
|
|
||||||
#define AUDIO_AUDIOPLAYER_H
|
|
||||||
|
|
||||||
#include "SDLAudioMixer/AudioSRC.h"
|
|
||||||
#include "SDLAudioMixer/SDLAudioDevice.h"
|
|
||||||
#include "AudioDecoder.h"
|
|
||||||
#include "xRingBuffer.h"
|
|
||||||
|
|
||||||
#include "Extension/Frame.h"
|
|
||||||
|
|
||||||
using mediakit::Frame;
|
|
||||||
|
|
||||||
class PcmPacket{
|
|
||||||
public:
|
|
||||||
string data;
|
|
||||||
uint32_t timeStmp;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AudioPlayer:public AudioSRCDelegate{
|
|
||||||
public:
|
|
||||||
AudioPlayer( int sampleRate ,int channels ,int sampleBit);
|
|
||||||
~AudioPlayer() override;
|
|
||||||
|
|
||||||
//audio
|
|
||||||
void setPCMBufferSize(int size) override{
|
|
||||||
InfoL << "setPCMBufferSize = " << size ;
|
|
||||||
reqSize_ = size;
|
|
||||||
}
|
|
||||||
int getPCMSampleBit() override{
|
|
||||||
return decoder_->getSampleBit();
|
|
||||||
}
|
|
||||||
int getPCMSampleRate() override{
|
|
||||||
return decoder_->getSampleRate();
|
|
||||||
}
|
|
||||||
int getPCMChannel() override{
|
|
||||||
return decoder_->getChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getPCMData(char *buf, int bufsize) override;
|
|
||||||
|
|
||||||
bool inputFrame( Frame::Ptr frame );
|
|
||||||
|
|
||||||
private:
|
|
||||||
int sampleRate_;
|
|
||||||
int channels_;
|
|
||||||
int sampleBit_;
|
|
||||||
|
|
||||||
string buf_;
|
|
||||||
|
|
||||||
int reqSize_ = 4096;
|
|
||||||
AudioDecoder* decoder_=nullptr;
|
|
||||||
xRingBuffer<PcmPacket>* buffer_ = nullptr;
|
|
||||||
AudioSRC * audioSrc_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //AUDIO_AUDIOPLAYER_H
|
|
@ -1,12 +0,0 @@
|
|||||||
INCLUDE_DIRECTORIES(./libFaad)
|
|
||||||
|
|
||||||
|
|
||||||
aux_source_directory(./libFaad AUDIO_SRC_LIST)
|
|
||||||
aux_source_directory(./SDLAudioMixer AUDIO_SRC_LIST)
|
|
||||||
aux_source_directory(. AUDIO_SRC_LIST)
|
|
||||||
|
|
||||||
add_definitions(-DHAVE_CONFIG_H)
|
|
||||||
|
|
||||||
add_library(audioPlayer ${AUDIO_SRC_LIST} )
|
|
||||||
|
|
||||||
message(STATUS "ADD AudioPlayer")
|
|
@ -1,72 +0,0 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "SDL2/SDL.h"
|
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Util/logger.h"
|
|
||||||
#include "AudioSRC.h"
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace toolkit;
|
|
||||||
|
|
||||||
AudioSRC::AudioSRC(AudioSRCDelegate *del) {
|
|
||||||
_delegate = del;
|
|
||||||
}
|
|
||||||
AudioSRC::~AudioSRC() {
|
|
||||||
}
|
|
||||||
void AudioSRC::setOutputAudioConfig(const SDL_AudioSpec& cfg) {
|
|
||||||
int freq = _delegate->getPCMSampleRate();
|
|
||||||
int format = _delegate->getPCMSampleBit() == 16 ? AUDIO_S16 : AUDIO_S8;
|
|
||||||
int channels = _delegate->getPCMChannel();
|
|
||||||
if(-1 == SDL_BuildAudioCVT(&_audioCvt,format,channels,freq,cfg.format,cfg.channels,cfg.freq)){
|
|
||||||
throw std::runtime_error("the format conversion is not supported");
|
|
||||||
}
|
|
||||||
InfoL << freq << " " << format << " " << channels ;
|
|
||||||
InfoL << _audioCvt.needed << " "
|
|
||||||
<< _audioCvt.src_format << " "
|
|
||||||
<< _audioCvt.dst_format << " "
|
|
||||||
<< _audioCvt.rate_incr << " "
|
|
||||||
<< _audioCvt.len_mult << " "
|
|
||||||
<< _audioCvt.len_ratio << " ";
|
|
||||||
}
|
|
||||||
void AudioSRC::setEnableMix(bool flag){
|
|
||||||
_enableMix = flag;
|
|
||||||
}
|
|
||||||
int AudioSRC::getPCMData(char* buf, int bufsize) {
|
|
||||||
if(!_enableMix){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(!_pcmSize){
|
|
||||||
_pcmSize = bufsize / _audioCvt.len_ratio;
|
|
||||||
_delegate->setPCMBufferSize(_pcmSize);
|
|
||||||
}
|
|
||||||
if(!_delegate->getPCMData(buf,_pcmSize)){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_audioCvt.buf = (Uint8 *)buf;
|
|
||||||
_audioCvt.len = _pcmSize;
|
|
||||||
if(0 != SDL_ConvertAudio(&_audioCvt)){
|
|
||||||
_audioCvt.len_cvt = 0;
|
|
||||||
TraceL << "SDL_ConvertAudio falied";
|
|
||||||
}
|
|
||||||
//return _audioCvt.len_cvt;
|
|
||||||
if(_audioCvt.len_cvt == bufsize)
|
|
||||||
{
|
|
||||||
return bufsize;
|
|
||||||
}
|
|
||||||
if(_audioCvt.len_cvt){
|
|
||||||
_pcmBuf.append(buf,_audioCvt.len_cvt);
|
|
||||||
}
|
|
||||||
if(_pcmBuf.size() < bufsize){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy(buf,_pcmBuf.data(),bufsize);
|
|
||||||
_pcmBuf.erase(0,bufsize);
|
|
||||||
return bufsize;
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 xiongziliang <771730766@qq.com>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDLAUDIOMIXER_AUDIOSRC_H_
|
|
||||||
#define SDLAUDIOMIXER_AUDIOSRC_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "SDL2/SDL.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#pragma comment(lib,"SDL2.lib")
|
|
||||||
#endif //defined(_WIN32)
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
class AudioSRCDelegate{
|
|
||||||
public:
|
|
||||||
virtual ~AudioSRCDelegate(){};
|
|
||||||
virtual void setPCMBufferSize(int bufsize) = 0;
|
|
||||||
virtual int getPCMSampleBit() = 0;
|
|
||||||
virtual int getPCMSampleRate() = 0;
|
|
||||||
virtual int getPCMChannel() = 0;
|
|
||||||
virtual int getPCMData(char *buf, int bufsize) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AudioSRC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::shared_ptr<AudioSRC> Ptr;
|
|
||||||
AudioSRC(AudioSRCDelegate *);
|
|
||||||
virtual ~AudioSRC();
|
|
||||||
void setEnableMix(bool flag);
|
|
||||||
void setOutputAudioConfig(const SDL_AudioSpec &cfg);
|
|
||||||
//此处buf大小务必要比bufsize大的多
|
|
||||||
int getPCMData(char *buf, int bufsize);
|
|
||||||
private:
|
|
||||||
AudioSRCDelegate *_delegate;
|
|
||||||
SDL_AudioCVT _audioCvt;
|
|
||||||
bool _enableMix = true;
|
|
||||||
int _pcmSize = 0;
|
|
||||||
string _pcmBuf;
|
|
||||||
};
|
|
||||||
#endif /* SDLAUDIOMIXER_AUDIOSRC_H_ */
|
|
@ -1,106 +0,0 @@
|
|||||||
|
|
||||||
#include "SDLAudioDevice.h"
|
|
||||||
|
|
||||||
#include "Util/logger.h"
|
|
||||||
using namespace std;
|
|
||||||
using namespace toolkit;
|
|
||||||
|
|
||||||
SDLAudioDevice& SDLAudioDevice::Instance() {
|
|
||||||
static SDLAudioDevice *instance(new SDLAudioDevice);
|
|
||||||
return *instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDLAudioDevice::SDLAudioDevice() {
|
|
||||||
SDL_AudioSpec wanted_spec;
|
|
||||||
wanted_spec.freq = DEFAULT_SAMPLERATE;
|
|
||||||
wanted_spec.format = DEFAULT_SAMPLEBIT == 16 ? AUDIO_S16 : AUDIO_S8;
|
|
||||||
wanted_spec.channels = DEFAULT_CHANNEL;
|
|
||||||
wanted_spec.silence = 0;
|
|
||||||
wanted_spec.samples = DEFAULT_PCMSIZE / (DEFAULT_CHANNEL * DEFAULT_SAMPLEBIT / 8) ;
|
|
||||||
wanted_spec.size = DEFAULT_PCMSIZE;
|
|
||||||
wanted_spec.callback = SDLAudioDevice::onReqPCM;
|
|
||||||
wanted_spec.userdata = this;
|
|
||||||
if (SDL_OpenAudio(&wanted_spec, &_audioConfig)<0) {
|
|
||||||
// throw std::runtime_error("SDL_OpenAudio failed");
|
|
||||||
InfoL << "SDL_OpenAudio failed";
|
|
||||||
}else{
|
|
||||||
InfoL << "actual audioSpec: " << "freq=" << _audioConfig.freq
|
|
||||||
<< ",format=" << hex<<_audioConfig.format<<dec
|
|
||||||
<< ",channels=" << _audioConfig.channels
|
|
||||||
<< ",samples=" << _audioConfig.samples
|
|
||||||
<< ",size=" << _audioConfig.size;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_pcmBuf.reset(new char[_audioConfig.size * 10],[](char *ptr){
|
|
||||||
delete [] ptr;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
SDLAudioDevice::~SDLAudioDevice() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioDevice::addChannel(AudioSRC* chn) {
|
|
||||||
lock_guard<recursive_mutex> lck(_mutexChannel);
|
|
||||||
if(_channelSet.empty()){
|
|
||||||
SDL_PauseAudio(0);
|
|
||||||
}
|
|
||||||
chn->setOutputAudioConfig(_audioConfig);
|
|
||||||
_channelSet.emplace(chn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioDevice::delChannel(AudioSRC* chn) {
|
|
||||||
lock_guard<recursive_mutex> lck(_mutexChannel);
|
|
||||||
_channelSet.erase(chn);
|
|
||||||
if(_channelSet.empty()){
|
|
||||||
SDL_PauseAudio(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioDevice::onReqPCM(void* userdata, Uint8* stream, int len) {
|
|
||||||
SDLAudioDevice *_this = (SDLAudioDevice *)userdata;
|
|
||||||
_this->onReqPCM((char *)stream,len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioDevice::onReqPCM(char* stream, int len) {
|
|
||||||
lock_guard<recursive_mutex> lck(_mutexChannel);
|
|
||||||
int size;
|
|
||||||
int channel = 0;
|
|
||||||
for(auto &chn : _channelSet){
|
|
||||||
if(channel ==0 ){
|
|
||||||
size = chn->getPCMData(_pcmBuf.get(),len);
|
|
||||||
if(size){
|
|
||||||
//InfoL << len << " " << size;
|
|
||||||
memcpy(stream,_pcmBuf.get(),size);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
size = chn->getPCMData(_pcmBuf.get(),len);
|
|
||||||
if(size){
|
|
||||||
//InfoL << len << " " << size;
|
|
||||||
SDL_MixAudio((Uint8*)stream,(Uint8*)_pcmBuf.get(),size,SDL_MIX_MAXVOLUME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(size){
|
|
||||||
channel++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!channel){
|
|
||||||
memset(stream,0,len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 xiongziliang <771730766@qq.com>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SDLAUDIOMIXER_SDLAUDIODEVICE_H_
|
|
||||||
#define SDLAUDIOMIXER_SDLAUDIODEVICE_H_
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#include <memory>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "AudioSRC.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_SAMPLERATE 48000
|
|
||||||
#define DEFAULT_SAMPLEBIT 16
|
|
||||||
#define DEFAULT_CHANNEL 2
|
|
||||||
#define DEFAULT_PCMSIZE 4096
|
|
||||||
|
|
||||||
class SDLAudioDevice{
|
|
||||||
public:
|
|
||||||
void addChannel(AudioSRC *chn);
|
|
||||||
void delChannel(AudioSRC *chn);
|
|
||||||
static SDLAudioDevice &Instance();
|
|
||||||
virtual ~SDLAudioDevice();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
private:
|
|
||||||
SDLAudioDevice();
|
|
||||||
static void onReqPCM (void *userdata, Uint8 * stream,int len);
|
|
||||||
void onReqPCM (char * stream,int len);
|
|
||||||
|
|
||||||
unordered_set<AudioSRC *> _channelSet;
|
|
||||||
recursive_mutex _mutexChannel;
|
|
||||||
SDL_AudioSpec _audioConfig;
|
|
||||||
std::shared_ptr<char> _pcmBuf;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SDLAUDIOMIXER_SDLAUDIODEVICE_H_ */
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,271 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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"
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
// useless
|
|
||||||
//memset(ld, 0, sizeof(bitfile));
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reset to a certain point */
|
|
||||||
void faad_resetbits(bitfile *ld, int bits)
|
|
||||||
{
|
|
||||||
uint32_t tmp;
|
|
||||||
int words = bits >> 5;
|
|
||||||
int remainder = bits & 0x1F;
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
|
@ -1,452 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
{
|
|
||||||
/* 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;
|
|
||||||
uint32_t *tail;
|
|
||||||
uint32_t *start;
|
|
||||||
const void *buffer;
|
|
||||||
} 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);
|
|
||||||
void faad_initbits_rev(bitfile *ld, void *buffer,
|
|
||||||
uint32_t bits_in_buffer);
|
|
||||||
uint8_t faad_byte_align(bitfile *ld);
|
|
||||||
uint32_t faad_get_processed_bits(bitfile *ld);
|
|
||||||
void faad_flushbits_ex(bitfile *ld, uint32_t bits);
|
|
||||||
void faad_rewindbits(bitfile *ld);
|
|
||||||
void faad_resetbits(bitfile *ld, int 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)
|
|
||||||
{
|
|
||||||
uint32_t tmp;
|
|
||||||
#ifndef ARCH_IS_BIG_ENDIAN
|
|
||||||
((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[3];
|
|
||||||
((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
|
|
||||||
((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
|
|
||||||
((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
|
|
||||||
#else
|
|
||||||
((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
|
|
||||||
((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
|
|
||||||
((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
|
|
||||||
((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[3];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reads only n bytes from the stream instead of the standard 4 */
|
|
||||||
static /*INLINE*/ uint32_t getdword_n(void *mem, int n)
|
|
||||||
{
|
|
||||||
uint32_t tmp = 0;
|
|
||||||
#ifndef ARCH_IS_BIG_ENDIAN
|
|
||||||
switch (n)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
|
|
||||||
case 2:
|
|
||||||
((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
|
|
||||||
case 1:
|
|
||||||
((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
switch (n)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
|
|
||||||
case 2:
|
|
||||||
((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
|
|
||||||
case 1:
|
|
||||||
((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 & ((1<<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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 & (1 << (i + (32 - ld->bits_left))))
|
|
||||||
B |= (1 << (bits - i - 1));
|
|
||||||
}
|
|
||||||
return B;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < ld->bits_left; i++)
|
|
||||||
{
|
|
||||||
if (ld->bufa & (1 << (i + (32 - ld->bits_left))))
|
|
||||||
B |= (1 << (bits - i - 1));
|
|
||||||
}
|
|
||||||
for (i = 0; i < bits - ld->bits_left; i++)
|
|
||||||
{
|
|
||||||
if (ld->bufb & (1 << (i + (32-ld->bits_left))))
|
|
||||||
B |= (1 << (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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#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 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
#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;
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits)
|
|
||||||
{
|
|
||||||
if (bits == 0) return 0;
|
|
||||||
if (ld->len <= 32)
|
|
||||||
{
|
|
||||||
/* huffman_spectral_data_2 needs to read more than may be available, bits maybe
|
|
||||||
> ld->len, deliver 0 than */
|
|
||||||
if (ld->len >= bits)
|
|
||||||
return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
|
|
||||||
else
|
|
||||||
return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
|
|
||||||
} else {
|
|
||||||
if ((ld->len - bits) < 32)
|
|
||||||
{
|
|
||||||
return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
|
|
||||||
(ld->bufa >> (ld->len - bits));
|
|
||||||
} else {
|
|
||||||
return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,312 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,415 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,185 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 */
|
|
||||||
};
|
|
@ -1,199 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 },
|
|
||||||
};
|
|
@ -1,196 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 } }
|
|
||||||
};
|
|
@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 } }
|
|
||||||
};
|
|
@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,372 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 } }
|
|
||||||
};
|
|
@ -1,276 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 }
|
|
||||||
};
|
|
@ -1,522 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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;
|
|
||||||
if (16428320 <= samplerate) return 11;
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint32_t __r1 = 1;
|
|
||||||
static uint32_t __r2 = 1;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
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 floor_log2(uint32_t x)
|
|
||||||
{
|
|
||||||
#if 1
|
|
||||||
x |= (x >> 1);
|
|
||||||
x |= (x >> 2);
|
|
||||||
x |= (x >> 4);
|
|
||||||
x |= (x >> 8);
|
|
||||||
x |= (x >> 16);
|
|
||||||
|
|
||||||
return (ones32(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
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
|
|
||||||
#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);
|
|
||||||
|
|
||||||
/* rest = [0..1] */
|
|
||||||
int32_t rest = val - (whole << REAL_BITS);
|
|
||||||
|
|
||||||
/* index into pow2_tab */
|
|
||||||
int32_t index = rest >> (REAL_BITS-TABLE_BITS);
|
|
||||||
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
return (1<<REAL_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 = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t pow2_int(real_t val)
|
|
||||||
{
|
|
||||||
uint32_t x1, x2;
|
|
||||||
uint32_t errcorr;
|
|
||||||
uint32_t index_frac;
|
|
||||||
real_t retval;
|
|
||||||
int32_t whole = (val >> REAL_BITS);
|
|
||||||
|
|
||||||
/* rest = [0..1] */
|
|
||||||
int32_t rest = val - (whole << REAL_BITS);
|
|
||||||
|
|
||||||
/* index into pow2_tab */
|
|
||||||
int32_t index = rest >> (REAL_BITS-TABLE_BITS);
|
|
||||||
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* 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 = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */
|
|
||||||
int32_t log2_int(uint32_t val)
|
|
||||||
{
|
|
||||||
uint32_t frac;
|
|
||||||
uint32_t whole = (val);
|
|
||||||
int32_t exp = 0;
|
|
||||||
uint32_t index;
|
|
||||||
uint32_t index_frac;
|
|
||||||
uint32_t x1, x2;
|
|
||||||
uint32_t errcorr;
|
|
||||||
|
|
||||||
/* error */
|
|
||||||
if (val == 0)
|
|
||||||
return -10000;
|
|
||||||
|
|
||||||
exp = floor_log2(val);
|
|
||||||
exp -= REAL_BITS;
|
|
||||||
|
|
||||||
/* frac = [1..2] */
|
|
||||||
if (exp >= 0)
|
|
||||||
frac = val >> exp;
|
|
||||||
else
|
|
||||||
frac = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */
|
|
||||||
real_t log2_fix(uint32_t val)
|
|
||||||
{
|
|
||||||
uint32_t frac;
|
|
||||||
uint32_t whole = (val >> REAL_BITS);
|
|
||||||
int8_t exp = 0;
|
|
||||||
uint32_t index;
|
|
||||||
uint32_t index_frac;
|
|
||||||
uint32_t x1, x2;
|
|
||||||
uint32_t errcorr;
|
|
||||||
|
|
||||||
/* error */
|
|
||||||
if (val == 0)
|
|
||||||
return -100000;
|
|
||||||
|
|
||||||
exp = floor_log2(val);
|
|
||||||
exp -= REAL_BITS;
|
|
||||||
|
|
||||||
/* frac = [1..2] */
|
|
||||||
if (exp >= 0)
|
|
||||||
frac = val >> exp;
|
|
||||||
else
|
|
||||||
frac = 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) + errcorr + x1;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,450 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.77 2009/02/05 00:51:03 menno 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) */
|
|
||||||
//#define DRM
|
|
||||||
//#define DRM_PS
|
|
||||||
|
|
||||||
/* 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 ALLOW_SMALL_FRAMELENGTH
|
|
||||||
#undef ERROR_RESILIENCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SBR_DEC
|
|
||||||
//#define SBR_LOW_POWER
|
|
||||||
#define PS_DEC
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
#undef PS_DEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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_BITS)/B)
|
|
||||||
#define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B)
|
|
||||||
#else
|
|
||||||
#define DIV_R(A, B) ((A)/(B))
|
|
||||||
#define DIV_C(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>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
#define ARCH_IS_BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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(__MINGW32__)
|
|
||||||
#define HAS_LRINTF
|
|
||||||
static INLINE int lrintf(float f)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
fld f
|
|
||||||
fistp i
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
#elif (defined(__i386__) && defined(__GNUC__) && \
|
|
||||||
!defined(__CYGWIN__) && !defined(__MINGW32__))
|
|
||||||
#ifndef HAVE_LRINTF
|
|
||||||
#define HAS_LRINTF
|
|
||||||
// from http://www.stereopsis.com/FPU.html
|
|
||||||
static INLINE int 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) ((int32_t)(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);
|
|
||||||
uint32_t wl_min_lzc(uint32_t x);
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
#define LOG2_MIN_INF REAL_CONST(-10000)
|
|
||||||
int32_t log2_int(uint32_t val);
|
|
||||||
int32_t log2_fix(uint32_t val);
|
|
||||||
int32_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
|
|
@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
* config.h
|
|
||||||
*
|
|
||||||
* Created on: 2014-7-1
|
|
||||||
* Author: root
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONFIG_H_
|
|
||||||
#define CONFIG_H_
|
|
||||||
|
|
||||||
/* config.h. Generated from config.h.in by configure. */
|
|
||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
|
||||||
|
|
||||||
/* Define if you want to use libfaad together with Digital Radio Mondiale
|
|
||||||
(DRM) */
|
|
||||||
/* #undef DRM */
|
|
||||||
|
|
||||||
/* Define if you want support for Digital Radio Mondiale (DRM) parametric
|
|
||||||
stereo */
|
|
||||||
/* #undef DRM_PS */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
|
||||||
#define HAVE_DLFCN_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <errno.h> header file. */
|
|
||||||
#define HAVE_ERRNO_H 1
|
|
||||||
|
|
||||||
/* Define if needed */
|
|
||||||
/* #undef HAVE_FLOAT32_T */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <float.h> header file. */
|
|
||||||
#define HAVE_FLOAT_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `getpwuid' function. */
|
|
||||||
#define HAVE_GETPWUID 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
|
|
||||||
/* Define if you have the IOKit API */
|
|
||||||
/* #undef HAVE_IOKIT_IOKITLIB_H */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <limits.h> header file. */
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
|
|
||||||
/* Define if you have C99's lrintf function. */
|
|
||||||
#define HAVE_LRINTF 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <mathf.h> header file. */
|
|
||||||
/* #undef HAVE_MATHF_H */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `memcpy' function. */
|
|
||||||
#define HAVE_MEMCPY 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
|
||||||
#define HAVE_MEMORY_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdint.h> header file. */
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
|
||||||
#define HAVE_STDLIB_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `strchr' function. */
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <strings.h> header file. */
|
|
||||||
#define HAVE_STRINGS_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <string.h> header file. */
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `strsep' function. */
|
|
||||||
#define HAVE_STRSEP 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sysfs/libsysfs.h> header file. */
|
|
||||||
/* #undef HAVE_SYSFS_LIBSYSFS_H */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
|
||||||
#define HAVE_SYS_STAT_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
|
||||||
#define HAVE_SYS_TIME_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
|
||||||
#define HAVE_UNISTD_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
|
||||||
/* #undef NO_MINUS_C_MINUS_O */
|
|
||||||
|
|
||||||
/* Name of package */
|
|
||||||
#define PACKAGE "faad2"
|
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
|
||||||
#define PACKAGE_BUGREPORT ""
|
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
|
||||||
#define PACKAGE_NAME ""
|
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
|
||||||
#define PACKAGE_STRING ""
|
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
|
||||||
#define PACKAGE_TARNAME ""
|
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
|
||||||
#define PACKAGE_VERSION ""
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
|
|
||||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
|
||||||
#define TIME_WITH_SYS_TIME 1
|
|
||||||
|
|
||||||
/* Version number of package */
|
|
||||||
#define VERSION "2.7.0"
|
|
||||||
|
|
||||||
/* Define to 1 if your processor stores words with the most significant byte
|
|
||||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
|
||||||
/* #undef WORDS_BIGENDIAN */
|
|
||||||
|
|
||||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
|
||||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
|
||||||
#ifndef __cplusplus
|
|
||||||
/* #undef inline */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to `long int' if <sys/types.h> does not define. */
|
|
||||||
/* #undef off_t */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* CONFIG_H_ */
|
|
File diff suppressed because it is too large
Load Diff
@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.28 2007/11/01 12:33:30 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "structs.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.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] <<= exp;
|
|
||||||
if (frac)
|
|
||||||
spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bottom = top;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,965 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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;
|
|
||||||
int16_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
|
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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];
|
|
||||||
|
|
||||||
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];
|
|
||||||
|
|
||||||
uint8_t delay_buf_index_ser[NUM_OF_LINKS];
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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"
|
|
||||||
};
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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: faad.h,v 1.51 2007/11/01 12:33:29 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* warn people for update */
|
|
||||||
//#pragma message("please update faad2 include filename and function names!")
|
|
||||||
|
|
||||||
/* Backwards compatible link */
|
|
||||||
#include "neaacdec.h"
|
|
@ -1,406 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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>
|
|
||||||
#include <string.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
|
|
||||||
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 {
|
|
||||||
#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
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,287 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
#define FRAC_PRECISION ((uint32_t)(1 << 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)
|
|
||||||
|
|
||||||
/* 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)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE)
|
|
||||||
#define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (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_SIZE-FRAC_BITS);
|
|
||||||
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
@ -1,432 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 <string.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;
|
|
||||||
|
|
||||||
/* rewind and reverse */
|
|
||||||
/* 32 bit version */
|
|
||||||
static uint32_t rewrev_word(uint32_t v, const uint8_t len)
|
|
||||||
{
|
|
||||||
/* 32 bit reverse */
|
|
||||||
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]);
|
|
||||||
|
|
||||||
/* shift off low bits */
|
|
||||||
v >>= (32 - len);
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 64 bit version */
|
|
||||||
static void rewrev_lword(uint32_t *hi, uint32_t *lo, const uint8_t len)
|
|
||||||
{
|
|
||||||
if (len <= 32) {
|
|
||||||
*hi = 0;
|
|
||||||
*lo = rewrev_word(*lo, len);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
uint32_t t = *hi, v = *lo;
|
|
||||||
|
|
||||||
/* double 32 bit reverse */
|
|
||||||
v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]);
|
|
||||||
t = ((t >> S[0]) & B[0]) | ((t << S[0]) & ~B[0]);
|
|
||||||
v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]);
|
|
||||||
t = ((t >> S[1]) & B[1]) | ((t << S[1]) & ~B[1]);
|
|
||||||
v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]);
|
|
||||||
t = ((t >> S[2]) & B[2]) | ((t << S[2]) & ~B[2]);
|
|
||||||
v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]);
|
|
||||||
t = ((t >> S[3]) & B[3]) | ((t << S[3]) & ~B[3]);
|
|
||||||
v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]);
|
|
||||||
t = ((t >> S[4]) & B[4]) | ((t << S[4]) & ~B[4]);
|
|
||||||
|
|
||||||
/* last 32<>32 bit swap is implicit below */
|
|
||||||
|
|
||||||
/* shift off low bits (this is really only one 64 bit shift) */
|
|
||||||
*lo = (t >> (64 - len)) | (v << (len - 32));
|
|
||||||
*hi = v >> (64 - len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* bits_t version */
|
|
||||||
static void rewrev_bits(bits_t *bits)
|
|
||||||
{
|
|
||||||
if (bits->len == 0) return;
|
|
||||||
rewrev_lword(&bits->bufb, &bits->bufa, bits->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* merge bits of a to b */
|
|
||||||
static void concat_bits(bits_t *b, bits_t *a)
|
|
||||||
{
|
|
||||||
uint32_t bl, bh, al, ah;
|
|
||||||
|
|
||||||
if (a->len == 0) return;
|
|
||||||
|
|
||||||
al = a->bufa;
|
|
||||||
ah = a->bufb;
|
|
||||||
|
|
||||||
if (b->len > 32)
|
|
||||||
{
|
|
||||||
/* maskoff superfluous high b bits */
|
|
||||||
bl = b->bufa;
|
|
||||||
bh = b->bufb & ((1 << (b->len-32)) - 1);
|
|
||||||
/* left shift a b->len bits */
|
|
||||||
ah = al << (b->len - 32);
|
|
||||||
al = 0;
|
|
||||||
} else {
|
|
||||||
bl = b->bufa & ((1 << (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->bufa = faad_getbits(ld, segwidth);
|
|
||||||
segment->bufb = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
/* 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 guaranteed to fit */
|
|
||||||
if (bitsread < sp_data_len)
|
|
||||||
{
|
|
||||||
const uint8_t additional_bits = sp_data_len - bitsread;
|
|
||||||
|
|
||||||
read_segment(&segment[numberOfSegments], additional_bits, ld);
|
|
||||||
segment[numberOfSegments].len += segment[numberOfSegments-1].len;
|
|
||||||
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;
|
|
||||||
|
|
||||||
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
|
|
@ -1,559 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 int16_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);
|
|
||||||
static int16_t huffman_codebook(uint8_t i);
|
|
||||||
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 int16_t huffman_getescape(bitfile *ld, int16_t sp)
|
|
||||||
{
|
|
||||||
uint8_t neg, i;
|
|
||||||
int16_t j;
|
|
||||||
int16_t off;
|
|
||||||
|
|
||||||
if (sp < 0)
|
|
||||||
{
|
|
||||||
if (sp != -16)
|
|
||||||
return sp;
|
|
||||||
neg = 1;
|
|
||||||
} else {
|
|
||||||
if (sp != 16)
|
|
||||||
return sp;
|
|
||||||
neg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 4; ; i++)
|
|
||||||
{
|
|
||||||
if (faad_get1bit(ld
|
|
||||||
DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
off = (int16_t)faad_getbits(ld, i
|
|
||||||
DEBUGVAR(1,9,"huffman_getescape(): escape"));
|
|
||||||
|
|
||||||
j = off | (1<<i);
|
|
||||||
if (neg)
|
|
||||||
j = -j;
|
|
||||||
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
case 12: {
|
|
||||||
uint8_t err = huffman_2step_pair(11, ld, sp);
|
|
||||||
sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1);
|
|
||||||
return err; }
|
|
||||||
case 11:
|
|
||||||
{
|
|
||||||
uint8_t err = huffman_2step_pair_sign(11, ld, sp);
|
|
||||||
sp[0] = huffman_getescape(ld, sp[0]);
|
|
||||||
sp[1] = 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);
|
|
||||||
sp[0] = huffman_getescape(ld, sp[0]);
|
|
||||||
sp[1] = 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 i, 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])
|
|
||||||
{
|
|
||||||
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 (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
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,271 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 void flt_round(float32_t *pf)
|
|
||||||
{
|
|
||||||
int32_t flg;
|
|
||||||
uint32_t tmp, tmp1, tmp2;
|
|
||||||
|
|
||||||
tmp = *(uint32_t*)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 */
|
|
||||||
|
|
||||||
*pf = *(float32_t*)&tmp1 + *(float32_t*)&tmp2 - *(float32_t*)&tmp;
|
|
||||||
} else {
|
|
||||||
*pf = *(float32_t*)&tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int16_t quant_pred(float32_t x)
|
|
||||||
{
|
|
||||||
int16_t q;
|
|
||||||
uint32_t *tmp = (uint32_t*)&x;
|
|
||||||
|
|
||||||
q = (int16_t)(*tmp>>16);
|
|
||||||
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
|
|
||||||
static float32_t inv_quant_pred(int16_t q)
|
|
||||||
{
|
|
||||||
float32_t x;
|
|
||||||
uint32_t *tmp = (uint32_t*)&x;
|
|
||||||
*tmp = ((uint32_t)q)<<16;
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t pred)
|
|
||||||
{
|
|
||||||
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];
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
@ -1,252 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.68179283050743), /* 0.5^(-3/4) */
|
|
||||||
COEF_CONST(1.41421356237310), /* 0.5^(-2/4) */
|
|
||||||
COEF_CONST(1.18920711500272), /* 0.5^(-1/4) */
|
|
||||||
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;
|
|
||||||
#ifndef FIXED_POINT
|
|
||||||
real_t scale;
|
|
||||||
#else
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
#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 = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb]));
|
|
||||||
#else
|
|
||||||
exp = icsr->scale_factors[g][sfb] >> 2;
|
|
||||||
frac = icsr->scale_factors[g][sfb] & 3;
|
|
||||||
#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++)
|
|
||||||
{
|
|
||||||
#ifndef FIXED_POINT
|
|
||||||
r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale);
|
|
||||||
#else
|
|
||||||
if (exp < 0)
|
|
||||||
r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] << -exp;
|
|
||||||
else
|
|
||||||
r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] >> exp;
|
|
||||||
r_spec[(group*nshort)+i] = MUL_C(r_spec[(group*nshort)+i], pow05_table[frac + 3]);
|
|
||||||
#endif
|
|
||||||
if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb))
|
|
||||||
r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
group++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,215 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 (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 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
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,301 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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, 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
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,309 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.40 2009/02/06 03:39:58 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "structs.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "bits.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) */
|
|
||||||
0, /* 29 (Reserved) */
|
|
||||||
0, /* 30 (Reserved) */
|
|
||||||
0 /* 31 (Reserved) */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Table 1.6.1 */
|
|
||||||
char NEAACDECAPI 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)
|
|
||||||
{
|
|
||||||
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 - (startpos-faad_get_processed_bits(ld)));
|
|
||||||
|
|
||||||
if ((mp4ASC->objectTypeIndex != 5) && (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 == -1)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
faad_byte_align(&ld);
|
|
||||||
ret = AudioSpecificConfigFromBitfile(&ld, mp4ASC, pce, buffer_size, short_form);
|
|
||||||
faad_endbits(&ld);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 "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
|
|
@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,258 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.13 2009/01/26 23:51:15 menno 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)
|
|
||||||
#ifndef NEAACDECAPI
|
|
||||||
#define NEAACDECAPI __cdecl
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifndef NEAACDECAPI
|
|
||||||
#define NEAACDECAPI
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FAAD2_VERSION "2.7"
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
|
|
||||||
|
|
||||||
unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
|
|
||||||
|
|
||||||
NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
|
|
||||||
|
|
||||||
NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
|
|
||||||
|
|
||||||
unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
|
|
||||||
NeAACDecConfigurationPtr config);
|
|
||||||
|
|
||||||
/* Init the library based on info from the AAC file (ADTS/ADIF) */
|
|
||||||
long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
|
|
||||||
unsigned char *buffer,
|
|
||||||
unsigned long buffer_size,
|
|
||||||
unsigned long *samplerate,
|
|
||||||
unsigned char *channels);
|
|
||||||
|
|
||||||
/* Init the library using a DecoderSpecificInfo */
|
|
||||||
char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder,
|
|
||||||
unsigned char *pBuffer,
|
|
||||||
unsigned long SizeOfDecoderSpecificInfo,
|
|
||||||
unsigned long *samplerate,
|
|
||||||
unsigned char *channels);
|
|
||||||
|
|
||||||
/* Init the library for DRM */
|
|
||||||
char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
|
|
||||||
unsigned char channels);
|
|
||||||
|
|
||||||
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
|
|
||||||
|
|
||||||
void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
|
|
||||||
|
|
||||||
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
|
|
||||||
NeAACDecFrameInfo *hInfo,
|
|
||||||
unsigned char *buffer,
|
|
||||||
unsigned long buffer_size);
|
|
||||||
|
|
||||||
void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
|
|
||||||
NeAACDecFrameInfo *hInfo,
|
|
||||||
unsigned char *buffer,
|
|
||||||
unsigned long buffer_size,
|
|
||||||
void **sample_buffer,
|
|
||||||
unsigned long sample_buffer_size);
|
|
||||||
|
|
||||||
char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
|
|
||||||
unsigned long buffer_size,
|
|
||||||
mp4AudioSpecificConfig *mp4ASC);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#pragma pack(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,559 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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)
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (up_matrix == 1)
|
|
||||||
return input[internal_channel[0]][sample];
|
|
||||||
|
|
||||||
if (!down_matrix)
|
|
||||||
return input[internal_channel[channel]][sample];
|
|
||||||
|
|
||||||
if (channel == 0)
|
|
||||||
{
|
|
||||||
real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2);
|
|
||||||
real_t L_S = MUL_F(input[internal_channel[3]][sample], RSQRT2);
|
|
||||||
real_t cum = input[internal_channel[1]][sample] + C + L_S;
|
|
||||||
return MUL_F(cum, DM_MUL);
|
|
||||||
} else {
|
|
||||||
real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2);
|
|
||||||
real_t R_S = MUL_F(input[internal_channel[4]][sample], RSQRT2);
|
|
||||||
real_t cum = input[internal_channel[2]][sample] + C + R_S;
|
|
||||||
return MUL_F(cum, DM_MUL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* 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:
|
|
||||||
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 << (16-REAL_BITS-1));
|
|
||||||
tmp <<= (16-REAL_BITS);
|
|
||||||
} else {
|
|
||||||
tmp += -(1 << (16-REAL_BITS-1));
|
|
||||||
tmp <<= (16-REAL_BITS);
|
|
||||||
}
|
|
||||||
int_sample_buffer[(i*channels)+ch] = (int32_t)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
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,271 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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.38 2007/11/01 12:33:32 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
|
|
||||||
|
|
||||||
#define DIV(A, B) (((int64_t)A << REAL_BITS)/B)
|
|
||||||
|
|
||||||
#define step(shift) \
|
|
||||||
if ((0x40000000l >> shift) + root <= value) \
|
|
||||||
{ \
|
|
||||||
value -= (0x40000000l >> shift) + root; \
|
|
||||||
root = (root >> 1) | (0x40000000l >> shift); \
|
|
||||||
} else { \
|
|
||||||
root = root >> 1; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fixed point square root approximation */
|
|
||||||
/* !!!! ONLY WORKS FOR EVEN %REAL_BITS% !!!! */
|
|
||||||
real_t fp_sqrt(real_t value)
|
|
||||||
{
|
|
||||||
real_t root = 0;
|
|
||||||
|
|
||||||
step( 0); step( 2); step( 4); step( 6);
|
|
||||||
step( 8); step(10); step(12); step(14);
|
|
||||||
step(16); step(18); step(20); step(22);
|
|
||||||
step(24); step(26); step(28); step(30);
|
|
||||||
|
|
||||||
if (root < value)
|
|
||||||
++root;
|
|
||||||
|
|
||||||
root <<= (REAL_BITS/2);
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
static real_t const pow2_table[] =
|
|
||||||
{
|
|
||||||
COEF_CONST(1.0),
|
|
||||||
COEF_CONST(1.18920711500272),
|
|
||||||
COEF_CONST(1.41421356237310),
|
|
||||||
COEF_CONST(1.68179283050743)
|
|
||||||
};
|
|
||||||
#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;
|
|
||||||
|
|
||||||
real_t scale = (real_t)1.0/(real_t)size;
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
real_t tmp = scale*(real_t)(int32_t)ne_rng(__r1, __r2);
|
|
||||||
spec[i] = tmp;
|
|
||||||
energy += tmp*tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 energy = 0, scale;
|
|
||||||
int32_t exp, frac;
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
/* this can be replaced by a 16 bit random generator!!!! */
|
|
||||||
real_t tmp = (int32_t)ne_rng(__r1, __r2);
|
|
||||||
if (tmp < 0)
|
|
||||||
tmp = -(tmp & ((1<<(REAL_BITS-1))-1));
|
|
||||||
else
|
|
||||||
tmp = (tmp & ((1<<(REAL_BITS-1))-1));
|
|
||||||
|
|
||||||
energy += MUL_R(tmp,tmp);
|
|
||||||
|
|
||||||
spec[i] = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
energy = fp_sqrt(energy);
|
|
||||||
if (energy > 0)
|
|
||||||
{
|
|
||||||
scale = DIV(REAL_CONST(1),energy);
|
|
||||||
|
|
||||||
exp = scale_factor >> 2;
|
|
||||||
frac = scale_factor & 3;
|
|
||||||
|
|
||||||
/* IMDCT pre-scaling */
|
|
||||||
exp -= sub;
|
|
||||||
|
|
||||||
if (exp < 0)
|
|
||||||
scale >>= -exp;
|
|
||||||
else
|
|
||||||
scale <<= exp;
|
|
||||||
|
|
||||||
if (frac)
|
|
||||||
scale = MUL_C(scale, pow2_table[frac]);
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
spec[i] = MUL_R(spec[i], 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 size, offs;
|
|
||||||
|
|
||||||
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*/;
|
|
||||||
}
|
|
||||||
#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++)
|
|
||||||
{
|
|
||||||
for (sfb = 0; sfb < ics_left->max_sfb; sfb++)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
|
|
||||||
offs = ics_left->swb_offset[sfb];
|
|
||||||
size = min(ics_left->swb_offset[sfb+1], ics_left->swb_offset_max) - offs;
|
|
||||||
|
|
||||||
/* Generate random vector */
|
|
||||||
gen_rand_vector(&spec_left[(group*nshort)+offs],
|
|
||||||
ics_left->scale_factors[g][sfb], size, 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 (channel_pair)
|
|
||||||
{
|
|
||||||
if (is_noise(ics_right, g, sfb))
|
|
||||||
{
|
|
||||||
if (((ics_left->ms_mask_present == 1) &&
|
|
||||||
(ics_left->ms_used[g][sfb])) ||
|
|
||||||
(ics_left->ms_mask_present == 2))
|
|
||||||
{
|
|
||||||
uint16_t c;
|
|
||||||
|
|
||||||
offs = ics_right->swb_offset[sfb];
|
|
||||||
size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
|
|
||||||
|
|
||||||
for (c = 0; c < size; c++)
|
|
||||||
{
|
|
||||||
spec_right[(group*nshort) + offs + c] =
|
|
||||||
spec_left[(group*nshort) + offs + c];
|
|
||||||
}
|
|
||||||
} else /*if (ics_left->ms_mask_present == 0)*/ {
|
|
||||||
#ifdef LTP_DEC
|
|
||||||
ics_right->ltp.long_used[sfb] = 0;
|
|
||||||
ics_right->ltp2.long_used[sfb] = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef MAIN_DEC
|
|
||||||
ics_right->pred.prediction_used[sfb] = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
offs = ics_right->swb_offset[sfb];
|
|
||||||
size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
|
|
||||||
|
|
||||||
/* Generate random vector */
|
|
||||||
gen_rand_vector(&spec_right[(group*nshort)+offs],
|
|
||||||
ics_right->scale_factors[g][sfb], size, sub, __r1, __r2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} /* sfb */
|
|
||||||
group++;
|
|
||||||
} /* b */
|
|
||||||
} /* g */
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,152 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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;
|
|
||||||
|
|
||||||
/* hybrid filterbank parameters */
|
|
||||||
void *hyb;
|
|
||||||
uint8_t use34hybrid_bands;
|
|
||||||
uint8_t numTimeSlotsRate;
|
|
||||||
|
|
||||||
/**/
|
|
||||||
uint8_t num_groups;
|
|
||||||
uint8_t num_hybrid_groups;
|
|
||||||
uint8_t nr_par_bands;
|
|
||||||
uint8_t nr_allpass_bands;
|
|
||||||
uint8_t decay_cutoff;
|
|
||||||
|
|
||||||
uint8_t *group_border;
|
|
||||||
uint16_t *map_group2bk;
|
|
||||||
|
|
||||||
/* 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];
|
|
||||||
|
|
||||||
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];
|
|
||||||
uint8_t phase_hist;
|
|
||||||
complex_t ipd_prev[20][2];
|
|
||||||
complex_t opd_prev[20][2];
|
|
||||||
|
|
||||||
} 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
|
|
||||||
|
|
@ -1,551 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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);
|
|
||||||
|
|
||||||
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;
|
|
||||||
int16_t index = 0;
|
|
||||||
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
|
||||||
bit = (uint8_t)faad_get1bit(ld);
|
|
||||||
index = t_huff[index][bit];
|
|
||||||
}
|
|
||||||
|
|
||||||
return index + 31;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,550 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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;
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,533 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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, ld_rvlc_esc;
|
|
||||||
// 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->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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 = 0;
|
|
||||||
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;
|
|
||||||
|
|
||||||
#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)
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
ics->scale_factors[g][sfb] = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#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)
|
|
||||||
{
|
|
||||||
uint8_t i, j;
|
|
||||||
int8_t index;
|
|
||||||
uint32_t cw;
|
|
||||||
rvlc_huff_table *h = book_rvlc;
|
|
||||||
|
|
||||||
i = h->len;
|
|
||||||
if (direction > 0)
|
|
||||||
cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,""));
|
|
||||||
else
|
|
||||||
cw = 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 |= 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 index;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int8_t rvlc_huffman_esc(bitfile *ld,
|
|
||||||
int8_t direction)
|
|
||||||
{
|
|
||||||
uint8_t i, j;
|
|
||||||
uint32_t cw;
|
|
||||||
rvlc_huff_table *h = book_escape;
|
|
||||||
|
|
||||||
i = h->len;
|
|
||||||
if (direction > 0)
|
|
||||||
cw = faad_getbits(ld, i DEBUGVAR(1,0,""));
|
|
||||||
else
|
|
||||||
cw = 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 |= faad_getbits_rev(ld, j DEBUGVAR(1,0,""));
|
|
||||||
}
|
|
||||||
|
|
||||||
return h->index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
{
|
|
||||||
int8_t index;
|
|
||||||
uint8_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
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
|
|
@ -1,690 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 <string.h>
|
|
||||||
#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);
|
|
||||||
|
|
||||||
|
|
||||||
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 = -1;
|
|
||||||
|
|
||||||
if (framelength == 960)
|
|
||||||
{
|
|
||||||
sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
|
|
||||||
sbr->numTimeSlots = NO_TIME_SLOTS_960;
|
|
||||||
} else {
|
|
||||||
sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
|
|
||||||
sbr->numTimeSlots = NO_TIME_SLOTS;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = -1;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
ALIGN real_t deg[64];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DRM
|
|
||||||
if (sbr->Is_DRM_SBR)
|
|
||||||
{
|
|
||||||
sbr->bsco = 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_NTSR][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 = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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_NTSR][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 = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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[38][64] = {{0}};
|
|
||||||
ALIGN qmf_t X_right[38][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 = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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];
|
|
||||||
int8_t GQ_ringbuf_index[2];
|
|
||||||
|
|
||||||
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];
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
uint8_t Reset;
|
|
||||||
uint32_t frame;
|
|
||||||
uint32_t header_count;
|
|
||||||
|
|
||||||
uint8_t id_aac;
|
|
||||||
qmfa_info *qmfa[2];
|
|
||||||
qmfs_info *qmfs[2];
|
|
||||||
|
|
||||||
qmf_t Xsbr[2][MAX_NTSRHFG][64];
|
|
||||||
|
|
||||||
#ifdef DRM
|
|
||||||
uint8_t Is_DRM_SBR;
|
|
||||||
#ifdef DRM_PS
|
|
||||||
drm_ps_info *drm_ps;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t numTimeSlotsRate;
|
|
||||||
uint8_t numTimeSlots;
|
|
||||||
uint8_t tHFGen;
|
|
||||||
uint8_t tHFAdj;
|
|
||||||
|
|
||||||
#ifdef PS_DEC
|
|
||||||
ps_info *ps;
|
|
||||||
#endif
|
|
||||||
#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];
|
|
||||||
} 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
|
|
||||||
|
|
@ -1,510 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
|
|
@ -1,764 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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 longcmp(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
return ((int)(*(int32_t*)a - *(int32_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]), longcmp);
|
|
||||||
|
|
||||||
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;
|
|
||||||
uint32_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
|
|
||||||
|
|
||||||
/* 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]), longcmp);
|
|
||||||
|
|
||||||
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]), longcmp);
|
|
||||||
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]), longcmp);
|
|
||||||
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];
|
|
||||||
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;
|
|
||||||
|
|
||||||
for (k = 0; k <= sbr->N_low; k++)
|
|
||||||
{
|
|
||||||
if (k == 0)
|
|
||||||
i = 0;
|
|
||||||
else
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (k = 0; k <= sbr->N_Q; k++)
|
|
||||||
{
|
|
||||||
if (k == 0)
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
} else {
|
|
||||||
/* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
int32_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]), longcmp);
|
|
||||||
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]), longcmp);
|
|
||||||
nrLim--;
|
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* remove kth element */
|
|
||||||
limTable[k] = sbr->f_table_res[LO_RES][sbr->N_low];
|
|
||||||
qsort(limTable, nrLim, sizeof(limTable[0]), longcmp);
|
|
||||||
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
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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
|
|
||||||
|
|
@ -1,668 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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_hfgen.c,v 1.26 2007/11/01 12:33:35 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* High Frequency generation */
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "structs.h"
|
|
||||||
|
|
||||||
#ifdef SBR_DEC
|
|
||||||
|
|
||||||
#include "sbr_syntax.h"
|
|
||||||
#include "sbr_hfgen.h"
|
|
||||||
#include "sbr_fbt.h"
|
|
||||||
|
|
||||||
/* static function declarations */
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
complex_t *alpha_0, complex_t *alpha_1, real_t *rxx);
|
|
||||||
static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
|
|
||||||
#else
|
|
||||||
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
complex_t *alpha_0, complex_t *alpha_1, uint8_t k);
|
|
||||||
#endif
|
|
||||||
static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
|
|
||||||
static void patch_construction(sbr_info *sbr);
|
|
||||||
|
|
||||||
|
|
||||||
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
qmf_t Xhigh[MAX_NTSRHFG][64]
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
,real_t *deg
|
|
||||||
#endif
|
|
||||||
,uint8_t ch)
|
|
||||||
{
|
|
||||||
uint8_t l, i, x;
|
|
||||||
ALIGN complex_t alpha_0[64], alpha_1[64];
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
ALIGN real_t rxx[64];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t offset = sbr->tHFAdj;
|
|
||||||
uint8_t first = sbr->t_E[ch][0];
|
|
||||||
uint8_t last = sbr->t_E[ch][sbr->L_E[ch]];
|
|
||||||
|
|
||||||
calc_chirp_factors(sbr, ch);
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
memset(deg, 0, 64*sizeof(real_t));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((ch == 0) && (sbr->Reset))
|
|
||||||
patch_construction(sbr);
|
|
||||||
|
|
||||||
/* calculate the prediction coefficients */
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx);
|
|
||||||
calc_aliasing_degree(sbr, rxx, deg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* actual HF generation */
|
|
||||||
for (i = 0; i < sbr->noPatches; i++)
|
|
||||||
{
|
|
||||||
for (x = 0; x < sbr->patchNoSubbands[i]; x++)
|
|
||||||
{
|
|
||||||
real_t a0_r, a0_i, a1_r, a1_i;
|
|
||||||
real_t bw, bw2;
|
|
||||||
uint8_t q, p, k, g;
|
|
||||||
|
|
||||||
/* find the low and high band for patching */
|
|
||||||
k = sbr->kx + x;
|
|
||||||
for (q = 0; q < i; q++)
|
|
||||||
{
|
|
||||||
k += sbr->patchNoSubbands[q];
|
|
||||||
}
|
|
||||||
p = sbr->patchStartSubband[i] + x;
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
if (x != 0 /*x < sbr->patchNoSubbands[i]-1*/)
|
|
||||||
deg[k] = deg[p];
|
|
||||||
else
|
|
||||||
deg[k] = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g = sbr->table_map_k_to_g[k];
|
|
||||||
|
|
||||||
bw = sbr->bwArray[ch][g];
|
|
||||||
bw2 = MUL_C(bw, bw);
|
|
||||||
|
|
||||||
/* do the patching */
|
|
||||||
/* with or without filtering */
|
|
||||||
if (bw2 > 0)
|
|
||||||
{
|
|
||||||
real_t temp1_r, temp2_r, temp3_r;
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
real_t temp1_i, temp2_i, temp3_i;
|
|
||||||
calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
a0_r = MUL_C(RE(alpha_0[p]), bw);
|
|
||||||
a1_r = MUL_C(RE(alpha_1[p]), bw2);
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
a0_i = MUL_C(IM(alpha_0[p]), bw);
|
|
||||||
a1_i = MUL_C(IM(alpha_1[p]), bw2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
temp2_r = QMF_RE(Xlow[first - 2 + offset][p]);
|
|
||||||
temp3_r = QMF_RE(Xlow[first - 1 + offset][p]);
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
temp2_i = QMF_IM(Xlow[first - 2 + offset][p]);
|
|
||||||
temp3_i = QMF_IM(Xlow[first - 1 + offset][p]);
|
|
||||||
#endif
|
|
||||||
for (l = first; l < last; l++)
|
|
||||||
{
|
|
||||||
temp1_r = temp2_r;
|
|
||||||
temp2_r = temp3_r;
|
|
||||||
temp3_r = QMF_RE(Xlow[l + offset][p]);
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
temp1_i = temp2_i;
|
|
||||||
temp2_i = temp3_i;
|
|
||||||
temp3_i = QMF_IM(Xlow[l + offset][p]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
QMF_RE(Xhigh[l + offset][k]) =
|
|
||||||
temp3_r
|
|
||||||
+(MUL_R(a0_r, temp2_r) +
|
|
||||||
MUL_R(a1_r, temp1_r));
|
|
||||||
#else
|
|
||||||
QMF_RE(Xhigh[l + offset][k]) =
|
|
||||||
temp3_r
|
|
||||||
+(MUL_R(a0_r, temp2_r) -
|
|
||||||
MUL_R(a0_i, temp2_i) +
|
|
||||||
MUL_R(a1_r, temp1_r) -
|
|
||||||
MUL_R(a1_i, temp1_i));
|
|
||||||
QMF_IM(Xhigh[l + offset][k]) =
|
|
||||||
temp3_i
|
|
||||||
+(MUL_R(a0_i, temp2_r) +
|
|
||||||
MUL_R(a0_r, temp2_i) +
|
|
||||||
MUL_R(a1_i, temp1_r) +
|
|
||||||
MUL_R(a1_r, temp1_i));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (l = first; l < last; l++)
|
|
||||||
{
|
|
||||||
QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sbr->Reset)
|
|
||||||
{
|
|
||||||
limiter_frequency_table(sbr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
complex_t r01;
|
|
||||||
complex_t r02;
|
|
||||||
complex_t r11;
|
|
||||||
complex_t r12;
|
|
||||||
complex_t r22;
|
|
||||||
real_t det;
|
|
||||||
} acorr_coef;
|
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
|
|
||||||
qmf_t buffer[MAX_NTSRHFG][64],
|
|
||||||
uint8_t bd, uint8_t len)
|
|
||||||
{
|
|
||||||
real_t r01 = 0, r02 = 0, r11 = 0;
|
|
||||||
int8_t j;
|
|
||||||
uint8_t offset = sbr->tHFAdj;
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
|
||||||
uint32_t maxi = 0;
|
|
||||||
uint32_t pow2, exp;
|
|
||||||
#else
|
|
||||||
const real_t rel = 1 / (1 + 1e-6f);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
for (j = (offset-2); j < (len + offset); j++)
|
|
||||||
{
|
|
||||||
real_t x;
|
|
||||||
x = QMF_RE(buffer[j][bd])>>REAL_BITS;
|
|
||||||
mask |= x ^ (x >> 31);
|
|
||||||
}
|
|
||||||
|
|
||||||
exp = wl_min_lzc(mask);
|
|
||||||
|
|
||||||
/* improves accuracy */
|
|
||||||
if (exp > 0)
|
|
||||||
exp -= 1;
|
|
||||||
|
|
||||||
for (j = offset; j < len + offset; j++)
|
|
||||||
{
|
|
||||||
real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp);
|
|
||||||
real_t buf_j_1 = ((QMF_RE(buffer[j-1][bd])+(1<<(exp-1)))>>exp);
|
|
||||||
real_t buf_j_2 = ((QMF_RE(buffer[j-2][bd])+(1<<(exp-1)))>>exp);
|
|
||||||
|
|
||||||
/* normalisation with rounding */
|
|
||||||
r01 += MUL_R(buf_j, buf_j_1);
|
|
||||||
r02 += MUL_R(buf_j, buf_j_2);
|
|
||||||
r11 += MUL_R(buf_j_1, buf_j_1);
|
|
||||||
}
|
|
||||||
RE(ac->r12) = r01 -
|
|
||||||
MUL_R(((QMF_RE(buffer[len+offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
|
|
||||||
MUL_R(((QMF_RE(buffer[offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
|
|
||||||
RE(ac->r22) = r11 -
|
|
||||||
MUL_R(((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
|
|
||||||
MUL_R(((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
|
|
||||||
#else
|
|
||||||
for (j = offset; j < len + offset; j++)
|
|
||||||
{
|
|
||||||
r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
|
|
||||||
r02 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]);
|
|
||||||
r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
|
|
||||||
}
|
|
||||||
RE(ac->r12) = r01 -
|
|
||||||
QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
|
|
||||||
QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
|
|
||||||
RE(ac->r22) = r11 -
|
|
||||||
QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
|
|
||||||
QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
|
|
||||||
#endif
|
|
||||||
RE(ac->r01) = r01;
|
|
||||||
RE(ac->r02) = r02;
|
|
||||||
RE(ac->r11) = r11;
|
|
||||||
|
|
||||||
ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
|
|
||||||
uint8_t bd, uint8_t len)
|
|
||||||
{
|
|
||||||
real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
|
|
||||||
real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i, temp4_r, temp4_i, temp5_r, temp5_i;
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
|
||||||
uint32_t mask, exp;
|
|
||||||
real_t pow2_to_exp;
|
|
||||||
#else
|
|
||||||
const real_t rel = 1 / (1 + 1e-6f);
|
|
||||||
#endif
|
|
||||||
int8_t j;
|
|
||||||
uint8_t offset = sbr->tHFAdj;
|
|
||||||
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
for (j = (offset-2); j < (len + offset); j++)
|
|
||||||
{
|
|
||||||
real_t x;
|
|
||||||
x = QMF_RE(buffer[j][bd])>>REAL_BITS;
|
|
||||||
mask |= x ^ (x >> 31);
|
|
||||||
x = QMF_IM(buffer[j][bd])>>REAL_BITS;
|
|
||||||
mask |= x ^ (x >> 31);
|
|
||||||
}
|
|
||||||
|
|
||||||
exp = wl_min_lzc(mask);
|
|
||||||
|
|
||||||
/* improves accuracy */
|
|
||||||
if (exp > 0)
|
|
||||||
exp -= 1;
|
|
||||||
|
|
||||||
pow2_to_exp = 1<<(exp-1);
|
|
||||||
|
|
||||||
temp2_r = (QMF_RE(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
|
|
||||||
temp2_i = (QMF_IM(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
|
|
||||||
temp3_r = (QMF_RE(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
|
|
||||||
temp3_i = (QMF_IM(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
|
|
||||||
// Save these because they are needed after loop
|
|
||||||
temp4_r = temp2_r;
|
|
||||||
temp4_i = temp2_i;
|
|
||||||
temp5_r = temp3_r;
|
|
||||||
temp5_i = temp3_i;
|
|
||||||
|
|
||||||
for (j = offset; j < len + offset; j++)
|
|
||||||
{
|
|
||||||
temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
|
|
||||||
temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
|
|
||||||
r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
|
|
||||||
r01i += MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i);
|
|
||||||
r02r += MUL_R(temp3_r, temp1_r) + MUL_R(temp3_i, temp1_i);
|
|
||||||
r02i += MUL_R(temp3_i, temp1_r) - MUL_R(temp3_r, temp1_i);
|
|
||||||
r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are actual values in temporary variable at this point
|
|
||||||
// temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
// temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
// temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
// temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
|
|
||||||
// temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
// temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
// temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
// temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
// temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
// temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
|
|
||||||
|
|
||||||
RE(ac->r12) = r01r -
|
|
||||||
(MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
|
|
||||||
(MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
|
|
||||||
IM(ac->r12) = r01i -
|
|
||||||
(MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
|
|
||||||
(MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
|
|
||||||
RE(ac->r22) = r11r -
|
|
||||||
(MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
|
|
||||||
(MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
temp2_r = QMF_RE(buffer[offset-2][bd]);
|
|
||||||
temp2_i = QMF_IM(buffer[offset-2][bd]);
|
|
||||||
temp3_r = QMF_RE(buffer[offset-1][bd]);
|
|
||||||
temp3_i = QMF_IM(buffer[offset-1][bd]);
|
|
||||||
// Save these because they are needed after loop
|
|
||||||
temp4_r = temp2_r;
|
|
||||||
temp4_i = temp2_i;
|
|
||||||
temp5_r = temp3_r;
|
|
||||||
temp5_i = temp3_i;
|
|
||||||
|
|
||||||
for (j = offset; j < len + offset; j++)
|
|
||||||
{
|
|
||||||
temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
|
|
||||||
temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
|
|
||||||
temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
|
|
||||||
temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
|
|
||||||
temp3_r = QMF_RE(buffer[j][bd]);
|
|
||||||
temp3_i = QMF_IM(buffer[j][bd]);
|
|
||||||
r01r += temp3_r * temp2_r + temp3_i * temp2_i;
|
|
||||||
r01i += temp3_i * temp2_r - temp3_r * temp2_i;
|
|
||||||
r02r += temp3_r * temp1_r + temp3_i * temp1_i;
|
|
||||||
r02i += temp3_i * temp1_r - temp3_r * temp1_i;
|
|
||||||
r11r += temp2_r * temp2_r + temp2_i * temp2_i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are actual values in temporary variable at this point
|
|
||||||
// temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
|
|
||||||
// temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
|
|
||||||
// temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
|
|
||||||
// temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
|
|
||||||
// temp3_r = QMF_RE(buffer[len+offset-1][bd]);
|
|
||||||
// temp3_i = QMF_IM(buffer[len+offset-1][bd]);
|
|
||||||
// temp4_r = QMF_RE(buffer[offset-2][bd]);
|
|
||||||
// temp4_i = QMF_IM(buffer[offset-2][bd]);
|
|
||||||
// temp5_r = QMF_RE(buffer[offset-1][bd]);
|
|
||||||
// temp5_i = QMF_IM(buffer[offset-1][bd]);
|
|
||||||
|
|
||||||
RE(ac->r12) = r01r -
|
|
||||||
(temp3_r * temp2_r + temp3_i * temp2_i) +
|
|
||||||
(temp5_r * temp4_r + temp5_i * temp4_i);
|
|
||||||
IM(ac->r12) = r01i -
|
|
||||||
(temp3_i * temp2_r - temp3_r * temp2_i) +
|
|
||||||
(temp5_i * temp4_r - temp5_r * temp4_i);
|
|
||||||
RE(ac->r22) = r11r -
|
|
||||||
(temp2_r * temp2_r + temp2_i * temp2_i) +
|
|
||||||
(temp4_r * temp4_r + temp4_i * temp4_i);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RE(ac->r01) = r01r;
|
|
||||||
IM(ac->r01) = r01i;
|
|
||||||
RE(ac->r02) = r02r;
|
|
||||||
IM(ac->r02) = r02i;
|
|
||||||
RE(ac->r11) = r11r;
|
|
||||||
|
|
||||||
ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(rel, (MUL_R(RE(ac->r12), RE(ac->r12)) + MUL_R(IM(ac->r12), IM(ac->r12))));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* calculate linear prediction coefficients using the covariance method */
|
|
||||||
#ifndef SBR_LOW_POWER
|
|
||||||
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
complex_t *alpha_0, complex_t *alpha_1, uint8_t k)
|
|
||||||
{
|
|
||||||
real_t tmp;
|
|
||||||
acorr_coef ac;
|
|
||||||
|
|
||||||
auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
|
|
||||||
|
|
||||||
if (ac.det == 0)
|
|
||||||
{
|
|
||||||
RE(alpha_1[k]) = 0;
|
|
||||||
IM(alpha_1[k]) = 0;
|
|
||||||
} else {
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)));
|
|
||||||
RE(alpha_1[k]) = DIV_R(tmp, ac.det);
|
|
||||||
tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11)));
|
|
||||||
IM(alpha_1[k]) = DIV_R(tmp, ac.det);
|
|
||||||
#else
|
|
||||||
tmp = REAL_CONST(1.0) / ac.det;
|
|
||||||
RE(alpha_1[k]) = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))) * tmp;
|
|
||||||
IM(alpha_1[k]) = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))) * tmp;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RE(ac.r11) == 0)
|
|
||||||
{
|
|
||||||
RE(alpha_0[k]) = 0;
|
|
||||||
IM(alpha_0[k]) = 0;
|
|
||||||
} else {
|
|
||||||
#ifdef FIXED_POINT
|
|
||||||
tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12)));
|
|
||||||
RE(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
|
|
||||||
tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12)));
|
|
||||||
IM(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
|
|
||||||
#else
|
|
||||||
tmp = 1.0f / RE(ac.r11);
|
|
||||||
RE(alpha_0[k]) = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))) * tmp;
|
|
||||||
IM(alpha_0[k]) = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))) * tmp;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) ||
|
|
||||||
(MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16)))
|
|
||||||
{
|
|
||||||
RE(alpha_0[k]) = 0;
|
|
||||||
IM(alpha_0[k]) = 0;
|
|
||||||
RE(alpha_1[k]) = 0;
|
|
||||||
IM(alpha_1[k]) = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
complex_t *alpha_0, complex_t *alpha_1, real_t *rxx)
|
|
||||||
{
|
|
||||||
uint8_t k;
|
|
||||||
real_t tmp;
|
|
||||||
acorr_coef ac;
|
|
||||||
|
|
||||||
for (k = 1; k < sbr->f_master[0]; k++)
|
|
||||||
{
|
|
||||||
auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
|
|
||||||
|
|
||||||
if (ac.det == 0)
|
|
||||||
{
|
|
||||||
RE(alpha_0[k]) = 0;
|
|
||||||
RE(alpha_1[k]) = 0;
|
|
||||||
} else {
|
|
||||||
tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
|
|
||||||
RE(alpha_0[k]) = DIV_R(tmp, (-ac.det));
|
|
||||||
|
|
||||||
tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
|
|
||||||
RE(alpha_1[k]) = DIV_R(tmp, ac.det);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4)))
|
|
||||||
{
|
|
||||||
RE(alpha_0[k]) = REAL_CONST(0);
|
|
||||||
RE(alpha_1[k]) = REAL_CONST(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reflection coefficient */
|
|
||||||
if (RE(ac.r11) == 0)
|
|
||||||
{
|
|
||||||
rxx[k] = COEF_CONST(0.0);
|
|
||||||
} else {
|
|
||||||
rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11));
|
|
||||||
rxx[k] = -rxx[k];
|
|
||||||
if (rxx[k] > COEF_CONST(1.0)) rxx[k] = COEF_CONST(1.0);
|
|
||||||
if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg)
|
|
||||||
{
|
|
||||||
uint8_t k;
|
|
||||||
|
|
||||||
rxx[0] = COEF_CONST(0.0);
|
|
||||||
deg[1] = COEF_CONST(0.0);
|
|
||||||
|
|
||||||
for (k = 2; k < sbr->k0; k++)
|
|
||||||
{
|
|
||||||
deg[k] = 0.0;
|
|
||||||
|
|
||||||
if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0)))
|
|
||||||
{
|
|
||||||
if (rxx[k-1] < 0.0)
|
|
||||||
{
|
|
||||||
deg[k] = COEF_CONST(1.0);
|
|
||||||
|
|
||||||
if (rxx[k-2] > COEF_CONST(0.0))
|
|
||||||
{
|
|
||||||
deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
|
|
||||||
}
|
|
||||||
} else if (rxx[k-2] > COEF_CONST(0.0)) {
|
|
||||||
deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0)))
|
|
||||||
{
|
|
||||||
if (rxx[k-1] > COEF_CONST(0.0))
|
|
||||||
{
|
|
||||||
deg[k] = COEF_CONST(1.0);
|
|
||||||
|
|
||||||
if (rxx[k-2] < COEF_CONST(0.0))
|
|
||||||
{
|
|
||||||
deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
|
|
||||||
}
|
|
||||||
} else if (rxx[k-2] < COEF_CONST(0.0)) {
|
|
||||||
deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* FIXED POINT: bwArray = COEF */
|
|
||||||
static real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev)
|
|
||||||
{
|
|
||||||
switch (invf_mode)
|
|
||||||
{
|
|
||||||
case 1: /* LOW */
|
|
||||||
if (invf_mode_prev == 0) /* NONE */
|
|
||||||
return COEF_CONST(0.6);
|
|
||||||
else
|
|
||||||
return COEF_CONST(0.75);
|
|
||||||
|
|
||||||
case 2: /* MID */
|
|
||||||
return COEF_CONST(0.9);
|
|
||||||
|
|
||||||
case 3: /* HIGH */
|
|
||||||
return COEF_CONST(0.98);
|
|
||||||
|
|
||||||
default: /* NONE */
|
|
||||||
if (invf_mode_prev == 1) /* LOW */
|
|
||||||
return COEF_CONST(0.6);
|
|
||||||
else
|
|
||||||
return COEF_CONST(0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXED POINT: bwArray = COEF */
|
|
||||||
static void calc_chirp_factors(sbr_info *sbr, uint8_t ch)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < sbr->N_Q; i++)
|
|
||||||
{
|
|
||||||
sbr->bwArray[ch][i] = mapNewBw(sbr->bs_invf_mode[ch][i], sbr->bs_invf_mode_prev[ch][i]);
|
|
||||||
|
|
||||||
if (sbr->bwArray[ch][i] < sbr->bwArray_prev[ch][i])
|
|
||||||
sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.75)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.25));
|
|
||||||
else
|
|
||||||
sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.90625)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.09375));
|
|
||||||
|
|
||||||
if (sbr->bwArray[ch][i] < COEF_CONST(0.015625))
|
|
||||||
sbr->bwArray[ch][i] = COEF_CONST(0.0);
|
|
||||||
|
|
||||||
if (sbr->bwArray[ch][i] >= COEF_CONST(0.99609375))
|
|
||||||
sbr->bwArray[ch][i] = COEF_CONST(0.99609375);
|
|
||||||
|
|
||||||
sbr->bwArray_prev[ch][i] = sbr->bwArray[ch][i];
|
|
||||||
sbr->bs_invf_mode_prev[ch][i] = sbr->bs_invf_mode[ch][i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void patch_construction(sbr_info *sbr)
|
|
||||||
{
|
|
||||||
uint8_t i, k;
|
|
||||||
uint8_t odd, sb;
|
|
||||||
uint8_t msb = sbr->k0;
|
|
||||||
uint8_t usb = sbr->kx;
|
|
||||||
uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 };
|
|
||||||
/* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */
|
|
||||||
uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)];
|
|
||||||
|
|
||||||
sbr->noPatches = 0;
|
|
||||||
|
|
||||||
if (goalSb < (sbr->kx + sbr->M))
|
|
||||||
{
|
|
||||||
for (i = 0, k = 0; sbr->f_master[i] < goalSb; i++)
|
|
||||||
k = i+1;
|
|
||||||
} else {
|
|
||||||
k = sbr->N_master;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sbr->N_master == 0)
|
|
||||||
{
|
|
||||||
sbr->noPatches = 0;
|
|
||||||
sbr->patchNoSubbands[0] = 0;
|
|
||||||
sbr->patchStartSubband[0] = 0;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
uint8_t j = k + 1;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
j--;
|
|
||||||
|
|
||||||
sb = sbr->f_master[j];
|
|
||||||
odd = (sb - 2 + sbr->k0) % 2;
|
|
||||||
} while (sb > (sbr->k0 - 1 + msb - odd));
|
|
||||||
|
|
||||||
sbr->patchNoSubbands[sbr->noPatches] = max(sb - usb, 0);
|
|
||||||
sbr->patchStartSubband[sbr->noPatches] = sbr->k0 - odd -
|
|
||||||
sbr->patchNoSubbands[sbr->noPatches];
|
|
||||||
|
|
||||||
if (sbr->patchNoSubbands[sbr->noPatches] > 0)
|
|
||||||
{
|
|
||||||
usb = sb;
|
|
||||||
msb = sb;
|
|
||||||
sbr->noPatches++;
|
|
||||||
} else {
|
|
||||||
msb = sbr->kx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sbr->f_master[k] - sb < 3)
|
|
||||||
k = sbr->N_master;
|
|
||||||
} while (sb != (sbr->kx + sbr->M));
|
|
||||||
|
|
||||||
if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1))
|
|
||||||
{
|
|
||||||
sbr->noPatches--;
|
|
||||||
}
|
|
||||||
|
|
||||||
sbr->noPatches = min(sbr->noPatches, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef __SBR_HFGEN_H__
|
|
||||||
#define __SBR_HFGEN_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
|
|
||||||
qmf_t Xhigh[MAX_NTSRHFG][64]
|
|
||||||
#ifdef SBR_LOW_POWER
|
|
||||||
,real_t *deg
|
|
||||||
#endif
|
|
||||||
,uint8_t ch);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,360 +0,0 @@
|
|||||||
/*
|
|
||||||
** 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_huff.c,v 1.21 2007/11/01 12:33:35 menno Exp $
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "structs.h"
|
|
||||||
|
|
||||||
#ifdef SBR_DEC
|
|
||||||
|
|
||||||
#include "sbr_syntax.h"
|
|
||||||
#include "bits.h"
|
|
||||||
#include "sbr_huff.h"
|
|
||||||
#include "sbr_e_nf.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef const int8_t (*sbr_huff_tab)[2];
|
|
||||||
|
|
||||||
static const int8_t t_huffman_env_1_5dB[120][2] = {
|
|
||||||
{ 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 },
|
|
||||||
{ 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 },
|
|
||||||
{ 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 },
|
|
||||||
{ 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 },
|
|
||||||
{ 17, 18 }, { -73, -56 }, { 19, 21 }, { -74, 20 },
|
|
||||||
{ -55, -75 }, { 22, 26 }, { 23, 24 }, { -54, -76 },
|
|
||||||
{ -77, 25 }, { -53, -78 }, { 27, 34 }, { 28, 29 },
|
|
||||||
{ -52, -79 }, { 30, 31 }, { -80, -51 }, { 32, 33 },
|
|
||||||
{ -83, -82 }, { -81, -50 }, { 35, 57 }, { 36, 40 },
|
|
||||||
{ 37, 38 }, { -88, -84 }, { -48, 39 }, { -90, -85 },
|
|
||||||
{ 41, 46 }, { 42, 43 }, { -49, -87 }, { 44, 45 },
|
|
||||||
{ -89, -86 }, {-124,-123 }, { 47, 50 }, { 48, 49 },
|
|
||||||
{-122,-121 }, {-120,-119 }, { 51, 54 }, { 52, 53 },
|
|
||||||
{-118,-117 }, {-116,-115 }, { 55, 56 }, {-114,-113 },
|
|
||||||
{-112,-111 }, { 58, 89 }, { 59, 74 }, { 60, 67 },
|
|
||||||
{ 61, 64 }, { 62, 63 }, {-110,-109 }, {-108,-107 },
|
|
||||||
{ 65, 66 }, {-106,-105 }, {-104,-103 }, { 68, 71 },
|
|
||||||
{ 69, 70 }, {-102,-101 }, {-100, -99 }, { 72, 73 },
|
|
||||||
{ -98, -97 }, { -96, -95 }, { 75, 82 }, { 76, 79 },
|
|
||||||
{ 77, 78 }, { -94, -93 }, { -92, -91 }, { 80, 81 },
|
|
||||||
{ -47, -46 }, { -45, -44 }, { 83, 86 }, { 84, 85 },
|
|
||||||
{ -43, -42 }, { -41, -40 }, { 87, 88 }, { -39, -38 },
|
|
||||||
{ -37, -36 }, { 90, 105 }, { 91, 98 }, { 92, 95 },
|
|
||||||
{ 93, 94 }, { -35, -34 }, { -33, -32 }, { 96, 97 },
|
|
||||||
{ -31, -30 }, { -29, -28 }, { 99, 102 }, { 100, 101 },
|
|
||||||
{ -27, -26 }, { -25, -24 }, { 103, 104 }, { -23, -22 },
|
|
||||||
{ -21, -20 }, { 106, 113 }, { 107, 110 }, { 108, 109 },
|
|
||||||
{ -19, -18 }, { -17, -16 }, { 111, 112 }, { -15, -14 },
|
|
||||||
{ -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 },
|
|
||||||
{ -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t f_huffman_env_1_5dB[120][2] = {
|
|
||||||
{ 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 },
|
|
||||||
{ 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 },
|
|
||||||
{ 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 },
|
|
||||||
{ -59, -71 }, { 14, 16 }, { -58, 15 }, { -72, -57 },
|
|
||||||
{ 17, 19 }, { -73, 18 }, { -56, -74 }, { 20, 23 },
|
|
||||||
{ 21, 22 }, { -55, -75 }, { -54, -53 }, { 24, 27 },
|
|
||||||
{ 25, 26 }, { -76, -52 }, { -77, -51 }, { 28, 31 },
|
|
||||||
{ 29, 30 }, { -50, -78 }, { -79, -49 }, { 32, 36 },
|
|
||||||
{ 33, 34 }, { -48, -47 }, { -80, 35 }, { -81, -82 },
|
|
||||||
{ 37, 47 }, { 38, 41 }, { 39, 40 }, { -83, -46 },
|
|
||||||
{ -45, -84 }, { 42, 44 }, { -85, 43 }, { -44, -43 },
|
|
||||||
{ 45, 46 }, { -88, -87 }, { -86, -90 }, { 48, 66 },
|
|
||||||
{ 49, 56 }, { 50, 53 }, { 51, 52 }, { -92, -42 },
|
|
||||||
{ -41, -39 }, { 54, 55 }, {-105, -89 }, { -38, -37 },
|
|
||||||
{ 57, 60 }, { 58, 59 }, { -94, -91 }, { -40, -36 },
|
|
||||||
{ 61, 63 }, { -20, 62 }, {-115,-110 }, { 64, 65 },
|
|
||||||
{-108,-107 }, {-101, -97 }, { 67, 89 }, { 68, 75 },
|
|
||||||
{ 69, 72 }, { 70, 71 }, { -95, -93 }, { -34, -27 },
|
|
||||||
{ 73, 74 }, { -22, -17 }, { -16,-124 }, { 76, 82 },
|
|
||||||
{ 77, 79 }, {-123, 78 }, {-122,-121 }, { 80, 81 },
|
|
||||||
{-120,-119 }, {-118,-117 }, { 83, 86 }, { 84, 85 },
|
|
||||||
{-116,-114 }, {-113,-112 }, { 87, 88 }, {-111,-109 },
|
|
||||||
{-106,-104 }, { 90, 105 }, { 91, 98 }, { 92, 95 },
|
|
||||||
{ 93, 94 }, {-103,-102 }, {-100, -99 }, { 96, 97 },
|
|
||||||
{ -98, -96 }, { -35, -33 }, { 99, 102 }, { 100, 101 },
|
|
||||||
{ -32, -31 }, { -30, -29 }, { 103, 104 }, { -28, -26 },
|
|
||||||
{ -25, -24 }, { 106, 113 }, { 107, 110 }, { 108, 109 },
|
|
||||||
{ -23, -21 }, { -19, -18 }, { 111, 112 }, { -15, -14 },
|
|
||||||
{ -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 },
|
|
||||||
{ -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t t_huffman_env_bal_1_5dB[48][2] = {
|
|
||||||
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 },
|
|
||||||
{ -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 },
|
|
||||||
{ -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 },
|
|
||||||
{ -70, -58 }, { 14, 28 }, { 15, 21 }, { 16, 18 },
|
|
||||||
{ -57, 17 }, { -71, -56 }, { 19, 20 }, { -88, -87 },
|
|
||||||
{ -86, -85 }, { 22, 25 }, { 23, 24 }, { -84, -83 },
|
|
||||||
{ -82, -81 }, { 26, 27 }, { -80, -79 }, { -78, -77 },
|
|
||||||
{ 29, 36 }, { 30, 33 }, { 31, 32 }, { -76, -75 },
|
|
||||||
{ -74, -73 }, { 34, 35 }, { -72, -55 }, { -54, -53 },
|
|
||||||
{ 37, 41 }, { 38, 39 }, { -52, -51 }, { -50, 40 },
|
|
||||||
{ -49, -48 }, { 42, 45 }, { 43, 44 }, { -47, -46 },
|
|
||||||
{ -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t f_huffman_env_bal_1_5dB[48][2] = {
|
|
||||||
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
|
|
||||||
{ -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 },
|
|
||||||
{ -58, 13 }, { 14, 17 }, { -71, 15 }, { -57, 16 },
|
|
||||||
{ -56, -73 }, { 18, 32 }, { 19, 25 }, { 20, 22 },
|
|
||||||
{ -72, 21 }, { -88, -87 }, { 23, 24 }, { -86, -85 },
|
|
||||||
{ -84, -83 }, { 26, 29 }, { 27, 28 }, { -82, -81 },
|
|
||||||
{ -80, -79 }, { 30, 31 }, { -78, -77 }, { -76, -75 },
|
|
||||||
{ 33, 40 }, { 34, 37 }, { 35, 36 }, { -74, -55 },
|
|
||||||
{ -54, -53 }, { 38, 39 }, { -52, -51 }, { -50, -49 },
|
|
||||||
{ 41, 44 }, { 42, 43 }, { -48, -47 }, { -46, -45 },
|
|
||||||
{ 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t t_huffman_env_3_0dB[62][2] = {
|
|
||||||
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 },
|
|
||||||
{ -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 },
|
|
||||||
{ -70, 13 }, { -71, -58 }, { 15, 18 }, { 16, 17 },
|
|
||||||
{ -72, -57 }, { -73, -74 }, { 19, 22 }, { -56, 20 },
|
|
||||||
{ -55, 21 }, { -54, -77 }, { 23, 31 }, { 24, 25 },
|
|
||||||
{ -75, -76 }, { 26, 27 }, { -78, -53 }, { 28, 29 },
|
|
||||||
{ -52, -95 }, { -94, 30 }, { -93, -92 }, { 32, 47 },
|
|
||||||
{ 33, 40 }, { 34, 37 }, { 35, 36 }, { -91, -90 },
|
|
||||||
{ -89, -88 }, { 38, 39 }, { -87, -86 }, { -85, -84 },
|
|
||||||
{ 41, 44 }, { 42, 43 }, { -83, -82 }, { -81, -80 },
|
|
||||||
{ 45, 46 }, { -79, -51 }, { -50, -49 }, { 48, 55 },
|
|
||||||
{ 49, 52 }, { 50, 51 }, { -48, -47 }, { -46, -45 },
|
|
||||||
{ 53, 54 }, { -44, -43 }, { -42, -41 }, { 56, 59 },
|
|
||||||
{ 57, 58 }, { -40, -39 }, { -38, -37 }, { 60, 61 },
|
|
||||||
{ -36, -35 }, { -34, -33 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t f_huffman_env_3_0dB[62][2] = {
|
|
||||||
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 },
|
|
||||||
{ 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 },
|
|
||||||
{ 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 },
|
|
||||||
{ 17, 19 }, { -56, 18 }, { -55, -73 }, { 20, 24 },
|
|
||||||
{ 21, 22 }, { -74, -54 }, { -53, 23 }, { -75, -76 },
|
|
||||||
{ 25, 30 }, { 26, 27 }, { -52, -51 }, { 28, 29 },
|
|
||||||
{ -77, -79 }, { -50, -49 }, { 31, 39 }, { 32, 35 },
|
|
||||||
{ 33, 34 }, { -78, -46 }, { -82, -88 }, { 36, 37 },
|
|
||||||
{ -83, -48 }, { -47, 38 }, { -86, -85 }, { 40, 47 },
|
|
||||||
{ 41, 44 }, { 42, 43 }, { -80, -44 }, { -43, -42 },
|
|
||||||
{ 45, 46 }, { -39, -87 }, { -84, -40 }, { 48, 55 },
|
|
||||||
{ 49, 52 }, { 50, 51 }, { -95, -94 }, { -93, -92 },
|
|
||||||
{ 53, 54 }, { -91, -90 }, { -89, -81 }, { 56, 59 },
|
|
||||||
{ 57, 58 }, { -45, -41 }, { -38, -37 }, { 60, 61 },
|
|
||||||
{ -36, -35 }, { -34, -33 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t t_huffman_env_bal_3_0dB[24][2] = {
|
|
||||||
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
|
|
||||||
{ -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 },
|
|
||||||
{ -76, -75 }, { 14, 15 }, { -74, -73 }, { -72, -71 },
|
|
||||||
{ 17, 20 }, { 18, 19 }, { -70, -59 }, { -58, -57 },
|
|
||||||
{ 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t f_huffman_env_bal_3_0dB[24][2] = {
|
|
||||||
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
|
|
||||||
{ -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 },
|
|
||||||
{ -58, -76 }, { 14, 17 }, { 15, 16 }, { -75, -74 },
|
|
||||||
{ -73, -72 }, { 18, 21 }, { 19, 20 }, { -71, -70 },
|
|
||||||
{ -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t t_huffman_noise_3_0dB[62][2] = {
|
|
||||||
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 },
|
|
||||||
{ -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 },
|
|
||||||
{ 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 },
|
|
||||||
{ 13, 14 }, { -59, -53 }, { -95, -94 }, { 16, 23 },
|
|
||||||
{ 17, 20 }, { 18, 19 }, { -93, -92 }, { -91, -90 },
|
|
||||||
{ 21, 22 }, { -89, -88 }, { -87, -86 }, { 24, 27 },
|
|
||||||
{ 25, 26 }, { -85, -84 }, { -83, -82 }, { 28, 29 },
|
|
||||||
{ -81, -80 }, { -79, -78 }, { 31, 46 }, { 32, 39 },
|
|
||||||
{ 33, 36 }, { 34, 35 }, { -77, -76 }, { -75, -74 },
|
|
||||||
{ 37, 38 }, { -73, -72 }, { -71, -70 }, { 40, 43 },
|
|
||||||
{ 41, 42 }, { -58, -57 }, { -56, -55 }, { 44, 45 },
|
|
||||||
{ -54, -52 }, { -51, -50 }, { 47, 54 }, { 48, 51 },
|
|
||||||
{ 49, 50 }, { -49, -48 }, { -47, -46 }, { 52, 53 },
|
|
||||||
{ -45, -44 }, { -43, -42 }, { 55, 58 }, { 56, 57 },
|
|
||||||
{ -41, -40 }, { -39, -38 }, { 59, 60 }, { -37, -36 },
|
|
||||||
{ -35, 61 }, { -34, -33 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int8_t t_huffman_noise_bal_3_0dB[24][2] = {
|
|
||||||
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 },
|
|
||||||
{ -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 },
|
|
||||||
{ -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 },
|
|
||||||
{ -72, -71 }, { -70, -69 }, { 15, 16 }, { -68, -67 },
|
|
||||||
{ -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 },
|
|
||||||
{ -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
|
|
||||||
{
|
|
||||||
uint8_t bit;
|
|
||||||
int16_t index = 0;
|
|
||||||
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
|
||||||
bit = (uint8_t)faad_get1bit(ld);
|
|
||||||
index = t_huff[index][bit];
|
|
||||||
}
|
|
||||||
|
|
||||||
return index + 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* table 10 */
|
|
||||||
void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch)
|
|
||||||
{
|
|
||||||
uint8_t env, band;
|
|
||||||
int8_t delta = 0;
|
|
||||||
sbr_huff_tab t_huff, f_huff;
|
|
||||||
|
|
||||||
if ((sbr->L_E[ch] == 1) && (sbr->bs_frame_class[ch] == FIXFIX))
|
|
||||||
sbr->amp_res[ch] = 0;
|
|
||||||
else
|
|
||||||
sbr->amp_res[ch] = sbr->bs_amp_res;
|
|
||||||
|
|
||||||
if ((sbr->bs_coupling) && (ch == 1))
|
|
||||||
{
|
|
||||||
delta = 1;
|
|
||||||
if (sbr->amp_res[ch])
|
|
||||||
{
|
|
||||||
t_huff = t_huffman_env_bal_3_0dB;
|
|
||||||
f_huff = f_huffman_env_bal_3_0dB;
|
|
||||||
} else {
|
|
||||||
t_huff = t_huffman_env_bal_1_5dB;
|
|
||||||
f_huff = f_huffman_env_bal_1_5dB;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
delta = 0;
|
|
||||||
if (sbr->amp_res[ch])
|
|
||||||
{
|
|
||||||
t_huff = t_huffman_env_3_0dB;
|
|
||||||
f_huff = f_huffman_env_3_0dB;
|
|
||||||
} else {
|
|
||||||
t_huff = t_huffman_env_1_5dB;
|
|
||||||
f_huff = f_huffman_env_1_5dB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (env = 0; env < sbr->L_E[ch]; env++)
|
|
||||||
{
|
|
||||||
if (sbr->bs_df_env[ch][env] == 0)
|
|
||||||
{
|
|
||||||
if ((sbr->bs_coupling == 1) && (ch == 1))
|
|
||||||
{
|
|
||||||
if (sbr->amp_res[ch])
|
|
||||||
{
|
|
||||||
sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 5
|
|
||||||
DEBUGVAR(1,272,"sbr_envelope(): bs_data_env")) << delta);
|
|
||||||
} else {
|
|
||||||
sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6
|
|
||||||
DEBUGVAR(1,273,"sbr_envelope(): bs_data_env")) << delta);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (sbr->amp_res[ch])
|
|
||||||
{
|
|
||||||
sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6
|
|
||||||
DEBUGVAR(1,274,"sbr_envelope(): bs_data_env")) << delta);
|
|
||||||
} else {
|
|
||||||
sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 7
|
|
||||||
DEBUGVAR(1,275,"sbr_envelope(): bs_data_env")) << delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (band = 1; band < sbr->n[sbr->f[ch][env]]; band++)
|
|
||||||
{
|
|
||||||
sbr->E[ch][band][env] = (sbr_huff_dec(ld, f_huff) << delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
for (band = 0; band < sbr->n[sbr->f[ch][env]]; band++)
|
|
||||||
{
|
|
||||||
sbr->E[ch][band][env] = (sbr_huff_dec(ld, t_huff) << delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_envelope_data(sbr, ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* table 11 */
|
|
||||||
void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch)
|
|
||||||
{
|
|
||||||
uint8_t noise, band;
|
|
||||||
int8_t delta = 0;
|
|
||||||
sbr_huff_tab t_huff, f_huff;
|
|
||||||
|
|
||||||
if ((sbr->bs_coupling == 1) && (ch == 1))
|
|
||||||
{
|
|
||||||
delta = 1;
|
|
||||||
t_huff = t_huffman_noise_bal_3_0dB;
|
|
||||||
f_huff = f_huffman_env_bal_3_0dB;
|
|
||||||
} else {
|
|
||||||
delta = 0;
|
|
||||||
t_huff = t_huffman_noise_3_0dB;
|
|
||||||
f_huff = f_huffman_env_3_0dB;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (noise = 0; noise < sbr->L_Q[ch]; noise++)
|
|
||||||
{
|
|
||||||
if(sbr->bs_df_noise[ch][noise] == 0)
|
|
||||||
{
|
|
||||||
if ((sbr->bs_coupling == 1) && (ch == 1))
|
|
||||||
{
|
|
||||||
sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
|
|
||||||
DEBUGVAR(1,276,"sbr_noise(): bs_data_noise")) << delta);
|
|
||||||
} else {
|
|
||||||
sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
|
|
||||||
DEBUGVAR(1,277,"sbr_noise(): bs_data_noise")) << delta);
|
|
||||||
}
|
|
||||||
for (band = 1; band < sbr->N_Q; band++)
|
|
||||||
{
|
|
||||||
sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, f_huff) << delta);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (band = 0; band < sbr->N_Q; band++)
|
|
||||||
{
|
|
||||||
sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, t_huff) << delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_noise_floor_data(sbr, ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user