├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake-build-debug └── bin │ └── test_player ├── cmake ├── .DS_Store ├── AndroidNdkGdb.cmake ├── AndroidNdkModules.cmake ├── FindAVCODEC.cmake ├── FindAVUTIL.cmake ├── FindMYSQL.cmake ├── FindSDL2.cmake ├── FindZLMEDIAKIT.cmake ├── FindZLTOOLKIT.cmake ├── android.toolchain.cmake └── iOS.cmake └── src ├── .DS_Store ├── AudioDec ├── AudioDec.cpp └── AudioDec.h ├── MediaPlayer ├── .DS_Store ├── H264Decoder.h ├── MediaPlayerImp.cpp ├── MediaPlayerImp.h ├── MediaPlayerWrapper.cpp ├── MediaPlayerWrapper.h └── YuvDisplayer.h ├── SDLAudioMixer ├── AudioSRC.cpp ├── AudioSRC.h ├── SDLAudioDevice.cpp └── SDLAudioDevice.h ├── libFaad ├── analysis.h ├── bits.c ├── bits.h ├── cfft.c ├── cfft.h ├── cfft_tab.h ├── codebook │ ├── hcb.h │ ├── hcb_1.h │ ├── hcb_10.h │ ├── hcb_11.h │ ├── hcb_2.h │ ├── hcb_3.h │ ├── hcb_4.h │ ├── hcb_5.h │ ├── hcb_6.h │ ├── hcb_7.h │ ├── hcb_8.h │ ├── hcb_9.h │ └── hcb_sf.h ├── common.c ├── common.h ├── config.h ├── decoder.c ├── drc.c ├── drc.h ├── drm_dec.c ├── drm_dec.h ├── error.c ├── error.h ├── faad.h ├── filtbank.c ├── filtbank.h ├── fixed.h ├── hcr.c ├── huffman.c ├── huffman.h ├── ic_predict.c ├── ic_predict.h ├── iq_table.h ├── is.c ├── is.h ├── kbd_win.h ├── lt_predict.c ├── lt_predict.h ├── mdct.c ├── mdct.h ├── mdct_tab.h ├── mp4.c ├── mp4.h ├── ms.c ├── ms.h ├── neaacdec.h ├── output.c ├── output.h ├── pns.c ├── pns.h ├── ps_dec.c ├── ps_dec.h ├── ps_syntax.c ├── ps_tables.h ├── pulse.c ├── pulse.h ├── rvlc.c ├── rvlc.h ├── sbr_dct.c ├── sbr_dct.h ├── sbr_dec.c ├── sbr_dec.h ├── sbr_e_nf.c ├── sbr_e_nf.h ├── sbr_fbt.c ├── sbr_fbt.h ├── sbr_hfadj.c ├── sbr_hfadj.h ├── sbr_hfgen.c ├── sbr_hfgen.h ├── sbr_huff.c ├── sbr_huff.h ├── sbr_noise.h ├── sbr_qmf.c ├── sbr_qmf.h ├── sbr_qmf_c.h ├── sbr_syntax.c ├── sbr_syntax.h ├── sbr_tf_grid.c ├── sbr_tf_grid.h ├── sine_win.h ├── specrec.c ├── specrec.h ├── ssr.c ├── ssr.h ├── ssr_fb.c ├── ssr_fb.h ├── ssr_ipqf.c ├── ssr_ipqf.h ├── ssr_win.h ├── structs.h ├── syntax.c ├── syntax.h ├── tns.c └── tns.h └── test_player.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(MediaPlayer) 2 | cmake_minimum_required(VERSION 2.8) 3 | #SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") 4 | 5 | #使能c++11 6 | #add_compile_options(-std=c++11) 7 | set(CMAKE_CXX_STANDARD 11) 8 | 9 | #加载自定义模块 10 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") 11 | #设置库文件路径 12 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 13 | #设置可执行程序路径 14 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 15 | 16 | #设置工程源码根目录 17 | set(ToolKit_Root ${CMAKE_SOURCE_DIR}/../ZLMediaKit/ZLToolKit/src) 18 | set(MediaKit_Root ${CMAKE_SOURCE_DIR}/../ZLMediaKit/src) 19 | set(MediaPlayer_Root ${CMAKE_SOURCE_DIR}/src) 20 | 21 | #设置头文件目录 22 | INCLUDE_DIRECTORIES(${ToolKit_Root}) 23 | INCLUDE_DIRECTORIES(${MediaKit_Root}) 24 | INCLUDE_DIRECTORIES(${MediaPlayer_Root}) 25 | INCLUDE_DIRECTORIES(${MediaPlayer_Root}/libFaad) 26 | 27 | add_definitions(-DHAVE_CONFIG_H) 28 | 29 | #收集源代码 30 | file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c) 31 | file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c) 32 | file(GLOB MediaPlayer_src_list ${MediaPlayer_Root}/*/*.cpp ${MediaPlayer_Root}/*/*.h ${MediaPlayer_Root}/*/*.c) 33 | 34 | #去除win32的适配代码 35 | if (NOT WIN32) 36 | list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c) 37 | endif () 38 | 39 | set(LINK_LIB_LIST) 40 | 41 | if (NOT WIN32) 42 | list(APPEND LINK_LIB_LIST pthread dl) 43 | else () 44 | list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi) 45 | endif () 46 | 47 | #添加库 48 | add_library(zltoolkit STATIC ${ToolKit_src_list}) 49 | add_library(zlmediakit STATIC ${MediaKit_src_list}) 50 | add_library(mediaplayer STATIC ${MediaPlayer_src_list}) 51 | 52 | 53 | target_link_libraries(zltoolkit ${LINK_LIB_LIST}) 54 | target_link_libraries(zlmediakit zltoolkit ${LINK_LIB_LIST}) 55 | target_link_libraries(mediaplayer zlmediakit zltoolkit ${LINK_LIB_LIST}) 56 | 57 | #查找ffmpeg/libavcodec是否安装 58 | find_package(AVCODEC QUIET) 59 | if (AVCODEC_FOUND) 60 | include_directories(${AVCODEC_INCLUDE_DIR}) 61 | list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES}) 62 | message(STATUS "找到libavcodec库:\"${AVCODEC_INCLUDE_DIR} ${AVCODEC_LIBRARIES}\"") 63 | endif (AVCODEC_FOUND) 64 | 65 | #查找ffmpeg/libavcodec是否安装 66 | find_package(AVUTIL QUIET) 67 | if (AVUTIL_FOUND) 68 | include_directories(${AVUTIL_INCLUDE_DIR}) 69 | list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES}) 70 | message(STATUS "找到libavutil库:\"${AVUTIL_INCLUDE_DIR} ${AVUTIL_LIBRARIES}\"") 71 | endif (AVUTIL_FOUND) 72 | 73 | #查找SDL2是否安装 74 | find_package(SDL2 QUIET) 75 | if (SDL2_FOUND) 76 | include_directories(${SDL2_INCLUDE_DIR}) 77 | list(APPEND LINK_LIB_LIST ${SDL2_LIBRARY}) 78 | message(STATUS "找到SDL2:${SDL2_INCLUDE_DIR},${SDL2_LIBRARY}") 79 | endif (SDL2_FOUND) 80 | 81 | 82 | add_executable(test_player src/test_player.cpp) 83 | 84 | IF (CMAKE_SYSTEM_NAME MATCHES "Linux") 85 | list(APPEND LINK_LIB_LIST swresample z) 86 | endif() 87 | 88 | target_link_libraries(test_player mediaplayer zlmediakit zltoolkit ${LINK_LIB_LIST}) 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 xiongziliang <771730766@qq.com> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZLMediaPlayer 2 | 一个简单的rtmp/rtsp播放器,支持windows/linux/macos 3 | 编译前请先安装ZLToolKit,ZLMediaKit 4 | 5 | -------------------------------------------------------------------------------- /cmake-build-debug/bin/test_player: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/cmake-build-debug/bin/test_player -------------------------------------------------------------------------------- /cmake/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/cmake/.DS_Store -------------------------------------------------------------------------------- /cmake/AndroidNdkGdb.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, Pavel Rojtberg 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, 8 | # this list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # 3. Neither the name of the copyright holder nor the names of its 15 | # contributors may be used to endorse or promote products derived from this 16 | # software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | 30 | # ------------------------------------------------------------------------------ 31 | # Usage: 32 | # 1. place AndroidNdkGdb.cmake somewhere inside ${CMAKE_MODULE_PATH} 33 | # 2. inside your project add 34 | # 35 | # include(AndroidNdkGdb) 36 | # android_ndk_gdb_enable() 37 | # # for each target 38 | # add_library(MyLibrary ...) 39 | # android_ndk_gdb_debuggable(MyLibrary) 40 | 41 | 42 | # add gdbserver and general gdb configuration to project 43 | # also create a mininal NDK skeleton so ndk-gdb finds the paths 44 | # 45 | # the optional parameter defines the path to the android project. 46 | # uses PROJECT_SOURCE_DIR by default. 47 | macro(android_ndk_gdb_enable) 48 | if(ANDROID) 49 | # create custom target that depends on the real target so it gets executed afterwards 50 | add_custom_target(NDK_GDB ALL) 51 | 52 | if(${ARGC}) 53 | set(ANDROID_PROJECT_DIR ${ARGV0}) 54 | else() 55 | set(ANDROID_PROJECT_DIR ${PROJECT_SOURCE_DIR}) 56 | endif() 57 | 58 | set(NDK_GDB_SOLIB_PATH ${ANDROID_PROJECT_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/) 59 | file(MAKE_DIRECTORY ${NDK_GDB_SOLIB_PATH}) 60 | 61 | # 1. generate essential Android Makefiles 62 | file(MAKE_DIRECTORY ${ANDROID_PROJECT_DIR}/jni) 63 | if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Android.mk) 64 | file(WRITE ${ANDROID_PROJECT_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n") 65 | endif() 66 | if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Application.mk) 67 | file(WRITE ${ANDROID_PROJECT_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n") 68 | endif() 69 | 70 | # 2. generate gdb.setup 71 | get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES) 72 | string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}") 73 | file(WRITE ${LIBRARY_OUTPUT_PATH}/gdb.setup "set solib-search-path ${NDK_GDB_SOLIB_PATH}\n") 74 | file(APPEND ${LIBRARY_OUTPUT_PATH}/gdb.setup "directory ${PROJECT_INCLUDES}\n") 75 | 76 | # 3. copy gdbserver executable 77 | file(COPY ${ANDROID_NDK}/prebuilt/android-${ANDROID_ARCH_NAME}/gdbserver/gdbserver DESTINATION ${LIBRARY_OUTPUT_PATH}) 78 | endif() 79 | endmacro() 80 | 81 | # register a target for remote debugging 82 | # copies the debug version to NDK_GDB_SOLIB_PATH then strips symbols of original 83 | macro(android_ndk_gdb_debuggable TARGET_NAME) 84 | if(ANDROID) 85 | get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION) 86 | 87 | # create custom target that depends on the real target so it gets executed afterwards 88 | add_dependencies(NDK_GDB ${TARGET_NAME}) 89 | 90 | # 4. copy lib to obj 91 | add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TARGET_LOCATION} ${NDK_GDB_SOLIB_PATH}) 92 | 93 | # 5. strip symbols 94 | add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION}) 95 | endif() 96 | endmacro() 97 | -------------------------------------------------------------------------------- /cmake/AndroidNdkModules.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, Pavel Rojtberg 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, 8 | # this list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # 3. Neither the name of the copyright holder nor the names of its 15 | # contributors may be used to endorse or promote products derived from this 16 | # software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | 30 | macro(android_ndk_import_module_cpufeatures) 31 | if(ANDROID) 32 | include_directories(${ANDROID_NDK}/sources/android/cpufeatures) 33 | add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) 34 | target_link_libraries(cpufeatures dl) 35 | endif() 36 | endmacro() 37 | 38 | macro(android_ndk_import_module_native_app_glue) 39 | if(ANDROID) 40 | include_directories(${ANDROID_NDK}/sources/android/native_app_glue) 41 | add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) 42 | target_link_libraries(native_app_glue log) 43 | endif() 44 | endmacro() 45 | 46 | macro(android_ndk_import_module_ndk_helper) 47 | if(ANDROID) 48 | android_ndk_import_module_cpufeatures() 49 | android_ndk_import_module_native_app_glue() 50 | 51 | include_directories(${ANDROID_NDK}/sources/android/ndk_helper) 52 | file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c) 53 | add_library(ndk_helper ${_NDK_HELPER_SRCS}) 54 | target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue) 55 | 56 | unset(_NDK_HELPER_SRCS) 57 | endif() 58 | endmacro() -------------------------------------------------------------------------------- /cmake/FindAVCODEC.cmake: -------------------------------------------------------------------------------- 1 | find_path(AVCODEC_INCLUDE_DIR 2 | NAMES libavcodec/avcodec.h 3 | PATHS $ENV{HOME}/ffmpeg/include) 4 | 5 | find_library(AVCODEC_LIBRARY 6 | NAMES avcodec 7 | PATHS $ENV{HOME}/ffmpeg/lib) 8 | 9 | set(AVCODEC_LIBRARIES ${AVCODEC_LIBRARY}) 10 | set(AVCODEC_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR}) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | 14 | find_package_handle_standard_args(AVCODEC DEFAULT_MSG AVCODEC_LIBRARY AVCODEC_INCLUDE_DIR) 15 | -------------------------------------------------------------------------------- /cmake/FindAVUTIL.cmake: -------------------------------------------------------------------------------- 1 | find_path(AVUTIL_INCLUDE_DIR 2 | NAMES libavutil/avutil.h 3 | PATHS $ENV{HOME}/ffmpeg/include) 4 | 5 | find_library(AVUTIL_LIBRARY 6 | NAMES avutil 7 | PATHS $ENV{HOME}/ffmpeg/lib) 8 | 9 | set(AVUTIL_LIBRARIES ${AVUTIL_LIBRARY}) 10 | set(AVUTIL_INCLUDE_DIRS ${AVUTIL_INCLUDE_DIR}) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | 14 | find_package_handle_standard_args(AVUTIL DEFAULT_MSG AVUTIL_LIBRARY AVUTIL_INCLUDE_DIR) 15 | -------------------------------------------------------------------------------- /cmake/FindMYSQL.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find MySQL / MySQL Embedded library 2 | # Find the MySQL includes and client library 3 | # This module defines 4 | # MYSQL_INCLUDE_DIR, where to find mysql.h 5 | # MYSQL_LIBRARIES, the libraries needed to use MySQL. 6 | # MYSQL_LIB_DIR, path to the MYSQL_LIBRARIES 7 | # MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded. 8 | # MYSQL_EMBEDDED_LIB_DIR, path to the MYSQL_EMBEDDED_LIBRARIES 9 | # MYSQL_FOUND, If false, do not try to use MySQL. 10 | # MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded. 11 | 12 | # Copyright (c) 2006-2008, Jarosław Staniek 13 | # 14 | # Redistribution and use is allowed according to the terms of the BSD license. 15 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 16 | 17 | include(CheckCXXSourceCompiles) 18 | 19 | if(WIN32) 20 | find_path(MYSQL_INCLUDE_DIR mysql.h 21 | PATHS 22 | $ENV{MYSQL_INCLUDE_DIR} 23 | $ENV{MYSQL_DIR}/include 24 | $ENV{ProgramFiles}/MySQL/*/include 25 | $ENV{SystemDrive}/MySQL/*/include 26 | $ENV{ProgramW6432}/MySQL/*/include 27 | ) 28 | else(WIN32) 29 | find_path(MYSQL_INCLUDE_DIR mysql/mysql.h 30 | PATHS 31 | $ENV{MYSQL_INCLUDE_DIR} 32 | $ENV{MYSQL_DIR}/include 33 | /usr/local/mysql/include 34 | /opt/mysql/mysql/include 35 | PATH_SUFFIXES 36 | mysql 37 | ) 38 | endif(WIN32) 39 | 40 | if(WIN32) 41 | if (${CMAKE_BUILD_TYPE}) 42 | string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) 43 | endif() 44 | 45 | # path suffix for debug/release mode 46 | # binary_dist: mysql binary distribution 47 | # build_dist: custom build 48 | if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") 49 | set(binary_dist debug) 50 | set(build_dist Debug) 51 | else(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") 52 | ADD_DEFINITIONS(-DDBUG_OFF) 53 | set(binary_dist opt) 54 | set(build_dist Release) 55 | endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") 56 | 57 | # find_library(MYSQL_LIBRARIES NAMES mysqlclient 58 | set(MYSQL_LIB_PATHS 59 | $ENV{MYSQL_DIR}/lib/${binary_dist} 60 | $ENV{MYSQL_DIR}/libmysql/${build_dist} 61 | $ENV{MYSQL_DIR}/client/${build_dist} 62 | $ENV{ProgramFiles}/MySQL/*/lib/${binary_dist} 63 | $ENV{SystemDrive}/MySQL/*/lib/${binary_dist} 64 | $ENV{MYSQL_DIR}/lib/opt 65 | $ENV{MYSQL_DIR}/client/release 66 | $ENV{ProgramFiles}/MySQL/*/lib/opt 67 | $ENV{ProgramFiles}/MySQL/*/lib/ 68 | $ENV{SystemDrive}/MySQL/*/lib/opt 69 | $ENV{ProgramW6432}/MySQL/*/lib 70 | ) 71 | find_library(MYSQL_LIBRARIES NAMES libmysql 72 | PATHS 73 | ${MYSQL_LIB_PATHS} 74 | ) 75 | else(WIN32) 76 | # find_library(MYSQL_LIBRARIES NAMES mysqlclient 77 | set(MYSQL_LIB_PATHS 78 | $ENV{MYSQL_DIR}/libmysql_r/.libs 79 | $ENV{MYSQL_DIR}/lib 80 | $ENV{MYSQL_DIR}/lib/mysql 81 | /usr/local/mysql/lib 82 | /opt/mysql/mysql/lib 83 | $ENV{MYSQL_DIR}/libmysql_r/.libs 84 | $ENV{MYSQL_DIR}/lib 85 | $ENV{MYSQL_DIR}/lib/mysql 86 | /usr/local/mysql/lib 87 | /opt/mysql/mysql/lib 88 | PATH_SUFFIXES 89 | mysql 90 | ) 91 | find_library(MYSQL_LIBRARIES NAMES mysqlclient 92 | PATHS 93 | ${MYSQL_LIB_PATHS} 94 | ) 95 | endif(WIN32) 96 | 97 | find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld 98 | PATHS 99 | ${MYSQL_LIB_PATHS} 100 | ) 101 | 102 | if(MYSQL_LIBRARIES) 103 | get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIBRARIES} PATH) 104 | endif(MYSQL_LIBRARIES) 105 | 106 | if(MYSQL_EMBEDDED_LIBRARIES) 107 | get_filename_component(MYSQL_EMBEDDED_LIB_DIR ${MYSQL_EMBEDDED_LIBRARIES} PATH) 108 | endif(MYSQL_EMBEDDED_LIBRARIES) 109 | 110 | set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} ) 111 | set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} ) 112 | check_cxx_source_compiles( "#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION ) 113 | 114 | if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) 115 | set(MYSQL_FOUND TRUE) 116 | message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") 117 | else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) 118 | set(MYSQL_FOUND FALSE) 119 | message(STATUS "MySQL not found.") 120 | endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) 121 | 122 | if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) 123 | set(MYSQL_EMBEDDED_FOUND TRUE) 124 | message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}") 125 | else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) 126 | set(MYSQL_EMBEDDED_FOUND FALSE) 127 | message(STATUS "MySQL Embedded not found.") 128 | endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) 129 | 130 | mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES) 131 | -------------------------------------------------------------------------------- /cmake/FindSDL2.cmake: -------------------------------------------------------------------------------- 1 | find_path(SDL2_INCLUDE_DIR 2 | NAMES SDL2/SDL.h 3 | HINTS SDL2 4 | PATHS $ENV{HOME}/sdl2/include) 5 | 6 | find_library(SDL2_LIBRARY 7 | NAMES SDL2 8 | PATHS $ENV{HOME}/sdl2/lib/x86) 9 | 10 | set(SDL2_LIBRARIES ${SDL2_LIBRARY}) 11 | set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) 12 | 13 | include(FindPackageHandleStandardArgs) 14 | 15 | find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDE_DIR) -------------------------------------------------------------------------------- /cmake/FindZLMEDIAKIT.cmake: -------------------------------------------------------------------------------- 1 | find_path(ZLMEDIAKIT_INCLUDE_DIR 2 | NAMES Rtsp/Rtsp.h 3 | PATHS 4 | ${PROJECT_SOURCE_DIR}/../ZLMediaKit/src 5 | $ENV{HOME}/ZLMediaKit/include) 6 | 7 | find_library(ZLMEDIAKIT_LIBRARY 8 | NAMES ZLMediaKit 9 | PATHS 10 | ${PROJECT_SOURCE_DIR}/../ZLMediaKit/build/lib 11 | $ENV{HOME}/ZLMediaKit/lib) 12 | 13 | set(ZLMEDIAKIT_LIBRARIES ${ZLMEDIAKIT_LIBRARY}) 14 | set(ZLMEDIAKIT_INCLUDE_DIRS ${ZLMEDIAKIT_INCLUDE_DIR}) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | 18 | find_package_handle_standard_args(ZLMEDIAKIT DEFAULT_MSG ZLMEDIAKIT_LIBRARY ZLMEDIAKIT_INCLUDE_DIR) 19 | 20 | -------------------------------------------------------------------------------- /cmake/FindZLTOOLKIT.cmake: -------------------------------------------------------------------------------- 1 | find_path(ZLTOOLKIT_INCLUDE_DIR 2 | NAMES Network/Socket.h 3 | PATHS 4 | ${PROJECT_SOURCE_DIR}/../ZLToolKit/src 5 | $ENV{HOME}/ZLToolKit/include) 6 | 7 | find_library(ZLTOOLKIT_LIBRARY 8 | NAMES ZLToolKit 9 | PATHS 10 | ${PROJECT_SOURCE_DIR}/../ZLToolKit/build/lib 11 | $ENV{HOME}/ZLToolKit/lib) 12 | 13 | set(ZLTOOLKIT_LIBRARIES ${ZLTOOLKIT_LIBRARY}) 14 | set(ZLTOOLKIT_INCLUDE_DIRS ${ZLTOOLKIT_INCLUDE_DIR}) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | 18 | find_package_handle_standard_args(ZLTOOLKIT DEFAULT_MSG ZLTOOLKIT_LIBRARY ZLTOOLKIT_INCLUDE_DIR) 19 | -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/src/.DS_Store -------------------------------------------------------------------------------- /src/AudioDec/AudioDec.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "AudioDec.h" 26 | #include "libFaad/faad.h" 27 | AudioDec::AudioDec() { 28 | // TODO Auto-generated constructor stub 29 | _handle=nullptr; 30 | samplebit=16; 31 | } 32 | 33 | AudioDec::~AudioDec() { 34 | // TODO Auto-generated destructor stub 35 | if(_handle != nullptr){ 36 | NeAACDecClose((NeAACDecHandle)_handle); 37 | _handle =nullptr; 38 | } 39 | } 40 | 41 | bool AudioDec::Init(const void *adtshed,int hedlen) { 42 | _handle = NeAACDecOpen(); 43 | if(_handle == nullptr){ 44 | return false; 45 | } 46 | char err = NeAACDecInit((NeAACDecHandle)_handle, ( unsigned char *)adtshed, hedlen, &samplerate, &channels); 47 | if (err != 0) 48 | { 49 | return false; 50 | } 51 | return true; 52 | 53 | } 54 | 55 | int AudioDec::InputData(const void *data, int len, unsigned char** pOutBuffer) { 56 | NeAACDecFrameInfo hInfo; 57 | NeAACDecHandle handle = (NeAACDecHandle)_handle; 58 | * pOutBuffer=(unsigned char*)NeAACDecDecode(handle, &hInfo, (unsigned char*)data,len); 59 | if (!((hInfo.error == 0) && (hInfo.samples > 0))){ 60 | return 0; 61 | } 62 | return hInfo.samples*hInfo.channels; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/AudioDec/AudioDec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef AUDIODEC_H_ 26 | #define AUDIODEC_H_ 27 | 28 | class AudioDec { 29 | public: 30 | AudioDec(void); 31 | virtual ~AudioDec(void); 32 | bool Init(const void *adtshed, int hedlen = 7); 33 | int InputData(const void *data, int len, unsigned char **pOutBuffer); 34 | unsigned char getChannels() const { 35 | return channels; 36 | } 37 | unsigned long getSamplerate() const { 38 | return samplerate; 39 | } 40 | unsigned char getSamplebit() const { 41 | return samplebit; 42 | } 43 | private: 44 | void *_handle; 45 | unsigned long samplerate; 46 | unsigned char channels; 47 | unsigned char samplebit; 48 | }; 49 | 50 | #endif /* AUDIODEC_H_ */ 51 | -------------------------------------------------------------------------------- /src/MediaPlayer/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/src/MediaPlayer/.DS_Store -------------------------------------------------------------------------------- /src/MediaPlayer/H264Decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef H264Decoder_H_ 26 | #define H264Decoder_H_ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "Util/ResourcePool.h" 32 | #include "Util/logger.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | #include "libavcodec/avcodec.h" 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #if defined(_WIN32) 43 | #pragma comment(lib,"avcodec.lib") 44 | #pragma comment(lib,"avutil.lib") 45 | #endif//defined(_WIN32) 46 | 47 | using namespace std; 48 | using namespace ZL::Util; 49 | 50 | class YuvFrame{ 51 | public: 52 | YuvFrame() { 53 | frame.reset(av_frame_alloc(), [](AVFrame *pFrame) { 54 | av_frame_unref(pFrame); 55 | av_frame_free(&pFrame); 56 | }); 57 | } 58 | ~YuvFrame() { 59 | } 60 | std::shared_ptr frame; 61 | uint32_t dts; 62 | uint32_t pts; 63 | }; 64 | class H264Decoder 65 | { 66 | public: 67 | H264Decoder(void){ 68 | avcodec_register_all(); 69 | av_log_set_level(AV_LOG_QUIET); 70 | AVCodec *pCodec = avcodec_find_decoder(AV_CODEC_ID_H264); 71 | if (!pCodec) { 72 | throw std::runtime_error("avcodec_find_decoder failed"); 73 | } 74 | 75 | pCodec->capabilities |= AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS ; 76 | m_pContext.reset(avcodec_alloc_context3(pCodec), [](AVCodecContext *pCtx) { 77 | avcodec_close(pCtx); 78 | avcodec_free_context(&pCtx); 79 | }); 80 | if (!m_pContext) { 81 | throw std::runtime_error("avcodec_alloc_context3 failed"); 82 | } 83 | m_pContext->thread_count = thread::hardware_concurrency(); 84 | m_pContext->refcounted_frames = 1; 85 | if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED) { 86 | /* we do not send complete frames */ 87 | m_pContext->flags |= AV_CODEC_FLAG_TRUNCATED; 88 | } 89 | if(avcodec_open2(m_pContext.get(), pCodec, NULL)< 0){ 90 | throw std::runtime_error("avcodec_open2 failed"); 91 | } 92 | } 93 | virtual ~H264Decoder(void){} 94 | std::shared_ptr inputVideo(unsigned char* data,unsigned int dataSize,uint32_t dts, uint32_t pts){ 95 | AVPacket pkt; 96 | av_init_packet(&pkt); 97 | pkt.data = data; 98 | pkt.size = dataSize; 99 | pkt.dts = dts; 100 | pkt.pts = pts; 101 | int iGotPicture ; 102 | auto frame = m_pool.obtain(); 103 | auto iLen = avcodec_decode_video2(m_pContext.get(), frame->frame.get(), &iGotPicture, &pkt); 104 | if (!iGotPicture || iLen < 0) { 105 | //m_pool.quit(frame); 106 | return nullptr; 107 | } 108 | return frame; 109 | } 110 | private: 111 | std::shared_ptr m_pContext; 112 | ResourcePool m_pool; 113 | }; 114 | 115 | #endif /* H264Decoder_H_ */ 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/MediaPlayer/MediaPlayerImp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "Player/MediaPlayer.h" 32 | #include "SDLAudioMixer/SDLAudioDevice.h" 33 | using namespace std; 34 | 35 | class PcmPacket; 36 | class AudioDec; 37 | class YuvFrame; 38 | class YuvDisplayer; 39 | class H264Parser; 40 | class H264Decoder; 41 | class MediaPlayerImp; 42 | 43 | 44 | class MediaPlayerDelegate 45 | { 46 | public: 47 | MediaPlayerDelegate() {} 48 | virtual ~MediaPlayerDelegate() {} 49 | virtual void onPlayResult(MediaPlayerImp *sender, const SockException &err) {}; 50 | virtual void onProgress(MediaPlayerImp *sender, float progress) {}; 51 | virtual void onAutoPaused(MediaPlayerImp *sender) {}; 52 | virtual void onShutdown(MediaPlayerImp *sender, const SockException &err) {}; 53 | virtual void onDrawFrame(MediaPlayerImp *sender, const std::shared_ptr &frame) {}; 54 | }; 55 | 56 | 57 | class MediaPlayerImp : public MediaPlayer,public AudioSRCDelegate, public std::enable_shared_from_this 58 | { 59 | public: 60 | typedef std::shared_ptr Ptr; 61 | typedef std::function Task; 62 | typedef std::function onTask; 63 | 64 | MediaPlayerImp(); 65 | virtual ~MediaPlayerImp(); 66 | 67 | void setOnThreadSwitch(const onTask &); 68 | void play(const char *url) override; 69 | void teardown() override; 70 | void rePlay(); 71 | void seekTo(float progress) override; 72 | const string & getUrl() const; 73 | bool isPlaying() const; 74 | 75 | void enableAudio(bool flag); 76 | bool isEnableAudio() const; 77 | 78 | void pause(bool flag) override; 79 | bool isPaused() const; 80 | void setPauseAuto(bool flag); 81 | 82 | void setDelegate(const std::shared_ptr &delegate); 83 | void reDraw(); 84 | 85 | //audio 86 | void setPCMBufferSize(int size) override; 87 | int getPCMSampleBit() override; 88 | int getPCMSampleRate() override; 89 | int getPCMChannel() override; 90 | int getPCMData(char *buf, int bufsize) override; 91 | 92 | static void globalInitialization(); 93 | static void globalUninitialization(); 94 | private: 95 | std::shared_ptr _delegate; 96 | uint32_t _audioPktMS = 0;//每个音频包的时长(单位毫秒) 97 | uint32_t _playedAudioStamp = 0;//被播放音频的时间戳 98 | uint32_t _firstVideoStamp = 0;//起始视频时间戳 99 | 100 | Ticker _systemStamp;//系统时间戳 101 | Ticker _onPorgressStamp;//记录上次触发onPorgress回调的时间戳 102 | 103 | std::shared_ptr _aacDec;////aac软件解码器 104 | std::shared_ptr _audioSrc; 105 | RingBuffer::Ptr _audioBuffer;//音频环形缓存 106 | RingBuffer::RingReader::Ptr _audioReader;//音频环形缓存读取器 107 | 108 | recursive_mutex _mtx_mapYuv;//yuv视频缓存锁 109 | std::shared_ptr _frame;//当前yuv 110 | multimap > _mapYuv;//yuv视频缓存 111 | std::shared_ptr _h264Parser;//h264 解析器,用于生产pts 112 | std::shared_ptr _h264Decoder;//h264硬件解码器 113 | 114 | string _url; 115 | string _pcmBuf; 116 | bool _playing = false; 117 | bool _enableAudio = true; 118 | bool _pause = false; 119 | bool _pauseAuto = true; 120 | onTask _ontask; 121 | int _pcmBufSize = 2048; 122 | 123 | void onRecvAudio(const AdtsFrame &data); 124 | void onRecvVideo(const H264Frame &data); 125 | void onH264(const H264Frame &data); 126 | void onAAC(const AdtsFrame &data); 127 | void tickProgress(); 128 | void onDrawFrame(); 129 | void pause(bool pause, bool flag); 130 | void setupEvent(); 131 | void onDecoded(const std::shared_ptr &frame); 132 | }; 133 | -------------------------------------------------------------------------------- /src/MediaPlayer/MediaPlayerWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #pragma once 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | using namespace std; 31 | 32 | #if !defined(__MINGW32__) && defined(_WIN32) 33 | #ifdef MediaPlayer_shared_EXPORTS 34 | #define MediaPlayer_API __declspec(dllexport) 35 | #else 36 | #define MediaPlayer_API __declspec(dllimport) 37 | #endif 38 | #else 39 | #define MediaPlayer_API 40 | #endif //!defined(__MINGW32__) 41 | 42 | 43 | class YuvFrame; 44 | class YuvDisplayer; 45 | class MediaPlayerImp; 46 | class MediaPlayerWrapper; 47 | class MediaPlayerDelegateHelper; 48 | 49 | class MediaPlayer_API MediaPlayerWrapperDelegate 50 | { 51 | public: 52 | friend class MediaPlayerDelegateHelper; 53 | MediaPlayerWrapperDelegate(); 54 | virtual ~MediaPlayerWrapperDelegate(); 55 | virtual void onPlayResult(MediaPlayerWrapper *sender, int errCode,const char *errMsg) {}; 56 | virtual void onProgress(MediaPlayerWrapper *sender, float progress) {}; 57 | virtual void onAutoPaused(MediaPlayerWrapper *sender) {}; 58 | virtual void onShutdown(MediaPlayerWrapper *sender, int errCode, const char *errMsg) {}; 59 | virtual void* onGetWinID(MediaPlayerWrapper *sender) const { return nullptr; }; 60 | protected: 61 | std::shared_ptr _display; 62 | void onDrawFrame(MediaPlayerWrapper *sender, const std::shared_ptr &frame); 63 | }; 64 | 65 | class MediaPlayer_API MediaPlayerWrapperDelegateImp : public MediaPlayerWrapperDelegate 66 | { 67 | public: 68 | MediaPlayerWrapperDelegateImp(void * win); 69 | virtual ~MediaPlayerWrapperDelegateImp(); 70 | private: 71 | void *_win; 72 | void* onGetWinID(MediaPlayerWrapper *sender) const override; 73 | }; 74 | 75 | class MediaPlayer_API MediaPlayerWrapper 76 | { 77 | public: 78 | friend class MediaPlayerWrapperHelper; 79 | typedef std::shared_ptr Ptr; 80 | typedef std::function Task; 81 | typedef std::function onTask; 82 | 83 | MediaPlayerWrapper(); 84 | virtual ~MediaPlayerWrapper(); 85 | 86 | void setOnThreadSwitch(const onTask &); 87 | void setOption(const char *key, int val); 88 | 89 | void play(const char *url); 90 | void teardown(); 91 | void rePlay(); 92 | const string & getUrl() const; 93 | bool isPlaying() const; 94 | 95 | void enableAudio(bool flag); 96 | bool isEnableAudio() const; 97 | 98 | void pause(bool flag) ; 99 | bool isPaused() const; 100 | void setPauseAuto(bool flag); 101 | 102 | int getVideoHeight() const ; 103 | int getVideoWidth() const ; 104 | float getVideoFps() const ; 105 | int getAudioSampleRate() const ; 106 | int getAudioSampleBit() const ; 107 | int getAudioChannel() const ; 108 | float getRtpLossRate(int iTrackId = -1) ; 109 | const string& getPps() const ; 110 | const string& getSps() const ; 111 | const string& getAudioCfg() const ; 112 | bool containAudio() const ; 113 | bool containVideo() const ; 114 | bool isInited() const ; 115 | float getDuration() const ; 116 | float getProgress() const ; 117 | void seekTo(float fProgress); 118 | void reDraw(); 119 | private: 120 | std::shared_ptr _player; 121 | std::shared_ptr _delegate; 122 | 123 | void addDelegate(MediaPlayerWrapperDelegate * delegate); 124 | void delDelegate(MediaPlayerWrapperDelegate * delegate); 125 | int delegateSize() const; 126 | }; 127 | 128 | class MediaPlayer_API MediaPlayerWrapperHelper 129 | { 130 | public: 131 | MediaPlayerWrapperHelper() ; 132 | virtual ~MediaPlayerWrapperHelper() ; 133 | 134 | static MediaPlayerWrapperHelper &Instance(); 135 | void setOnThreadSwitch(const MediaPlayerWrapper::onTask &); 136 | void addDelegate(const char *url,MediaPlayerWrapperDelegate * delegate); 137 | void delDelegate(const char *url, MediaPlayerWrapperDelegate * delegate); 138 | std::shared_ptr getPlayer(const char *url); 139 | 140 | static void globalInitialization(); 141 | static void globalUninitialization(); 142 | static void runSdlLoop(); 143 | static void stopSdlLoop(); 144 | private: 145 | recursive_mutex _mutex; 146 | MediaPlayerWrapper::onTask _ontask; 147 | unordered_map > _mapPlayer; 148 | }; 149 | 150 | -------------------------------------------------------------------------------- /src/MediaPlayer/YuvDisplayer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #ifndef YUVDISPLAYER_H_ 25 | #define YUVDISPLAYER_H_ 26 | #include 27 | #include "Util/onceToken.h" 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | #include "SDL2/SDL.h" 32 | #include "libavcodec/avcodec.h" 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #if defined(_WIN32) 38 | #pragma comment(lib,"SDL2.lib") 39 | #endif //defined(_WIN32) 40 | 41 | using namespace ZL::Util; 42 | 43 | class YuvDisplayer { 44 | public: 45 | YuvDisplayer(void *hwnd = nullptr,const char *title = "untitled"){ 46 | _title = title; 47 | _hwnd = hwnd; 48 | } 49 | virtual ~YuvDisplayer(){ 50 | if (_texture) { 51 | SDL_DestroyTexture(_texture); 52 | _texture = nullptr; 53 | } 54 | if (_render) { 55 | SDL_DestroyRenderer(_render); 56 | _render = nullptr; 57 | } 58 | if (_win) { 59 | SDL_DestroyWindow(_win); 60 | _win = nullptr; 61 | } 62 | } 63 | bool displayYUV(AVFrame *pFrame){ 64 | if (!_win) { 65 | if (_hwnd) { 66 | _win = SDL_CreateWindowFrom(_hwnd); 67 | }else { 68 | _win = SDL_CreateWindow(_title.data(), 69 | SDL_WINDOWPOS_UNDEFINED, 70 | SDL_WINDOWPOS_UNDEFINED, 71 | pFrame->width, 72 | pFrame->height, 73 | SDL_WINDOW_OPENGL); 74 | } 75 | } 76 | if (_win && ! _render){ 77 | #if 0 78 | SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ 79 | SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware 80 | acceleration */ 81 | SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized 82 | with the refresh rate */ 83 | SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports 84 | rendering to texture */ 85 | #endif 86 | #if defined(__linux__) 87 | _render = SDL_CreateRenderer(_win, -1, SDL_RENDERER_SOFTWARE); 88 | #else 89 | _render = SDL_CreateRenderer(_win, -1, SDL_RENDERER_ACCELERATED); 90 | #endif 91 | } 92 | if (_render && !_texture) { 93 | _texture = SDL_CreateTexture(_render, SDL_PIXELFORMAT_IYUV, 94 | SDL_TEXTUREACCESS_STREAMING, 95 | pFrame->width, 96 | pFrame->height); 97 | } 98 | if (_texture) { 99 | SDL_UpdateYUVTexture(_texture, nullptr, 100 | pFrame->data[0], pFrame->linesize[0], 101 | pFrame->data[1], pFrame->linesize[1], 102 | pFrame->data[2], pFrame->linesize[2]); 103 | 104 | //SDL_UpdateTexture(_texture, nullptr, pFrame->data[0], pFrame->linesize[0]); 105 | SDL_RenderClear(_render); 106 | SDL_RenderCopy(_render, _texture, nullptr, nullptr); 107 | SDL_RenderPresent(_render); 108 | return true; 109 | } 110 | return false; 111 | } 112 | private: 113 | string _title; 114 | SDL_Window *_win = nullptr; 115 | SDL_Renderer *_render = nullptr; 116 | SDL_Texture *_texture = nullptr; 117 | void *_hwnd = nullptr; 118 | }; 119 | 120 | #endif /* YUVDISPLAYER_H_ */ 121 | -------------------------------------------------------------------------------- /src/SDLAudioMixer/AudioSRC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "Util/logger.h" 26 | #include "AudioSRC.h" 27 | #include 28 | 29 | using namespace ZL::Util; 30 | 31 | AudioSRC::AudioSRC(AudioSRCDelegate *del) { 32 | _delegate = del; 33 | } 34 | AudioSRC::~AudioSRC() { 35 | } 36 | void AudioSRC::setOutputAudioConfig(const SDL_AudioSpec& cfg) { 37 | int freq = _delegate->getPCMSampleRate(); 38 | int format = _delegate->getPCMSampleBit() == 16 ? AUDIO_S16 : AUDIO_S8; 39 | int channels = _delegate->getPCMChannel(); 40 | if(-1 == SDL_BuildAudioCVT(&_audioCvt,format,channels,freq,cfg.format,cfg.channels,cfg.freq)){ 41 | throw std::runtime_error("the format conversion is not supported"); 42 | } 43 | InfoL << freq << " " << format << " " << channels ; 44 | InfoL << _audioCvt.needed << " " 45 | << _audioCvt.src_format << " " 46 | << _audioCvt.dst_format << " " 47 | << _audioCvt.rate_incr << " " 48 | << _audioCvt.len_mult << " " 49 | << _audioCvt.len_ratio << " "; 50 | } 51 | void AudioSRC::setEnableMix(bool flag){ 52 | _enableMix = flag; 53 | } 54 | int AudioSRC::getPCMData(char* buf, int bufsize) { 55 | if(!_enableMix){ 56 | return 0; 57 | } 58 | if(!_pcmSize){ 59 | _pcmSize = bufsize / _audioCvt.len_ratio; 60 | _delegate->setPCMBufferSize(_pcmSize); 61 | InfoL << _pcmSize; 62 | } 63 | if(!_delegate->getPCMData(buf,_pcmSize)){ 64 | return 0; 65 | } 66 | _audioCvt.buf = (Uint8 *)buf; 67 | _audioCvt.len = _pcmSize; 68 | if(0 != SDL_ConvertAudio(&_audioCvt)){ 69 | _audioCvt.len_cvt = 0; 70 | TraceL << "SDL_ConvertAudio falied"; 71 | } 72 | //return _audioCvt.len_cvt; 73 | if(_audioCvt.len_cvt == bufsize) 74 | { 75 | return bufsize; 76 | } 77 | if(_audioCvt.len_cvt){ 78 | _pcmBuf.append(buf,_audioCvt.len_cvt); 79 | } 80 | if(_pcmBuf.size() < bufsize){ 81 | return 0; 82 | } 83 | memcpy(buf,_pcmBuf.data(),bufsize); 84 | _pcmBuf.erase(0,bufsize); 85 | return bufsize; 86 | } 87 | -------------------------------------------------------------------------------- /src/SDLAudioMixer/AudioSRC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef SDLAUDIOMIXER_AUDIOSRC_H_ 26 | #define SDLAUDIOMIXER_AUDIOSRC_H_ 27 | 28 | #include 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | #include "SDL2/SDL.h" 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #if defined(_WIN32) 40 | #pragma comment(lib,"SDL2.lib") 41 | #endif //defined(_WIN32) 42 | 43 | using namespace std; 44 | 45 | 46 | class AudioSRCDelegate{ 47 | public: 48 | virtual ~AudioSRCDelegate(){}; 49 | virtual void setPCMBufferSize(int bufsize) = 0; 50 | virtual int getPCMSampleBit() = 0; 51 | virtual int getPCMSampleRate() = 0; 52 | virtual int getPCMChannel() = 0; 53 | virtual int getPCMData(char *buf, int bufsize) = 0; 54 | }; 55 | class AudioSRC 56 | { 57 | public: 58 | typedef std::shared_ptr Ptr; 59 | AudioSRC(AudioSRCDelegate *); 60 | virtual ~AudioSRC(); 61 | void setEnableMix(bool flag); 62 | void setOutputAudioConfig(const SDL_AudioSpec &cfg); 63 | //此处buf大小务必要比bufsize大的多 64 | int getPCMData(char *buf, int bufsize); 65 | private: 66 | AudioSRCDelegate *_delegate; 67 | SDL_AudioCVT _audioCvt; 68 | bool _enableMix = true; 69 | int _pcmSize = 0; 70 | string _pcmBuf; 71 | }; 72 | #endif /* SDLAUDIOMIXER_AUDIOSRC_H_ */ 73 | -------------------------------------------------------------------------------- /src/SDLAudioMixer/SDLAudioDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #include "SDLAudioDevice.h" 25 | 26 | SDLAudioDevice& SDLAudioDevice::Instance() { 27 | static SDLAudioDevice *instance(new SDLAudioDevice); 28 | return *instance; 29 | } 30 | 31 | SDLAudioDevice::SDLAudioDevice() { 32 | SDL_AudioSpec wanted_spec; 33 | wanted_spec.freq = DEFAULT_SAMPLERATE; 34 | wanted_spec.format = DEFAULT_SAMPLEBIT == 16 ? AUDIO_S16 : AUDIO_S8; 35 | wanted_spec.channels = DEFAULT_CHANNEL; 36 | wanted_spec.silence = 0; 37 | wanted_spec.samples = DEFAULT_PCMSIZE / (DEFAULT_CHANNEL * DEFAULT_SAMPLEBIT / 8) ; 38 | wanted_spec.size = DEFAULT_PCMSIZE; 39 | wanted_spec.callback = SDLAudioDevice::onReqPCM; 40 | wanted_spec.userdata = this; 41 | if (SDL_OpenAudio(&wanted_spec, &_audioConfig)<0) { 42 | // throw std::runtime_error("SDL_OpenAudio failed"); 43 | InfoL << "SDL_OpenAudio failed"; 44 | } 45 | _pcmBuf.reset(new char[_audioConfig.size * 10],[](char *ptr){ 46 | delete [] ptr; 47 | }); 48 | } 49 | 50 | SDLAudioDevice::~SDLAudioDevice() { 51 | } 52 | 53 | void SDLAudioDevice::addChannel(AudioSRC* chn) { 54 | lock_guard lck(_mutexChannel); 55 | if(_channelSet.empty()){ 56 | SDL_PauseAudio(false); 57 | } 58 | chn->setOutputAudioConfig(_audioConfig); 59 | _channelSet.emplace(chn); 60 | } 61 | 62 | void SDLAudioDevice::delChannel(AudioSRC* chn) { 63 | lock_guard lck(_mutexChannel); 64 | _channelSet.erase(chn); 65 | if(_channelSet.empty()){ 66 | SDL_PauseAudio(true); 67 | } 68 | } 69 | 70 | void SDLAudioDevice::onReqPCM(void* userdata, Uint8* stream, int len) { 71 | SDLAudioDevice *_this = (SDLAudioDevice *)userdata; 72 | _this->onReqPCM((char *)stream,len); 73 | } 74 | 75 | void SDLAudioDevice::onReqPCM(char* stream, int len) { 76 | lock_guard lck(_mutexChannel); 77 | int size; 78 | int channel = 0; 79 | for(auto &chn : _channelSet){ 80 | if(channel ==0 ){ 81 | size = chn->getPCMData(_pcmBuf.get(),len); 82 | if(size){ 83 | //InfoL << len << " " << size; 84 | memcpy(stream,_pcmBuf.get(),size); 85 | } 86 | }else{ 87 | size = chn->getPCMData(_pcmBuf.get(),len); 88 | if(size){ 89 | //InfoL << len << " " << size; 90 | SDL_MixAudio((Uint8*)stream,(Uint8*)_pcmBuf.get(),size,SDL_MIX_MAXVOLUME); 91 | } 92 | } 93 | if(size){ 94 | channel++; 95 | } 96 | } 97 | 98 | if(!channel){ 99 | memset(stream,0,len); 100 | } 101 | } 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/SDLAudioMixer/SDLAudioDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef SDLAUDIOMIXER_SDLAUDIODEVICE_H_ 26 | #define SDLAUDIOMIXER_SDLAUDIODEVICE_H_ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "AudioSRC.h" 34 | #include "Util/logger.h" 35 | #include "Util/onceToken.h" 36 | using namespace std; 37 | using namespace ZL::Util; 38 | 39 | #define DEFAULT_SAMPLERATE 32000 40 | #define DEFAULT_SAMPLEBIT 16 41 | #define DEFAULT_CHANNEL 2 42 | #define DEFAULT_PCMSIZE 4096 43 | 44 | class SDLAudioDevice{ 45 | public: 46 | void addChannel(AudioSRC *chn); 47 | void delChannel(AudioSRC *chn); 48 | static SDLAudioDevice &Instance(); 49 | virtual ~SDLAudioDevice(); 50 | protected: 51 | private: 52 | SDLAudioDevice(); 53 | static void onReqPCM (void *userdata, Uint8 * stream,int len); 54 | void onReqPCM (char * stream,int len); 55 | 56 | unordered_set _channelSet; 57 | recursive_mutex _mutexChannel; 58 | SDL_AudioSpec _audioConfig; 59 | std::shared_ptr _pcmBuf; 60 | }; 61 | 62 | #endif /* SDLAUDIOMIXER_SDLAUDIODEVICE_H_ */ 63 | -------------------------------------------------------------------------------- /src/libFaad/analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | #ifndef __ANALYSIS_H__ 32 | #define __ANALYSIS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | #ifdef ANALYSIS 40 | #define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg 41 | #define DEBUGVAR(A,B,C) ,A,B,C 42 | extern uint16_t dbg_count; 43 | #else 44 | #define DEBUGDEC 45 | #define DEBUGVAR(A,B,C) 46 | #endif 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /src/libFaad/cfft.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | #ifndef __CFFT_H__ 32 | #define __CFFT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | uint16_t n; 41 | uint16_t ifac[15]; 42 | complex_t *work; 43 | complex_t *tab; 44 | } cfft_info; 45 | 46 | 47 | void cfftf(cfft_info *cfft, complex_t *c); 48 | void cfftb(cfft_info *cfft, complex_t *c); 49 | cfft_info *cffti(uint16_t n); 50 | void cfftu(cfft_info *cfft); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $ 29 | **/ 30 | 31 | #ifndef __HCB_H__ 32 | #define __HCB_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* 39 | * Optimal huffman decoding for AAC taken from: 40 | * "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by 41 | * VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO 42 | * AES paper 5436 43 | * 44 | * 2 methods are used for huffman decoding: 45 | * - binary search 46 | * - 2-step table lookup 47 | * 48 | * The choice of the "optimal" method is based on the fact that if the 49 | * memory size for the Two-step is exorbitantly high then the decision 50 | * is Binary search for that codebook. However, for marginally more memory 51 | * size, if Twostep outperforms even the best case of Binary then the 52 | * decision is Two-step for that codebook. 53 | * 54 | * The following methods are used for the different tables. 55 | * codebook "optimal" method 56 | * HCB_1 2-Step 57 | * HCB_2 2-Step 58 | * HCB_3 Binary 59 | * HCB_4 2-Step 60 | * HCB_5 Binary 61 | * HCB_6 2-Step 62 | * HCB_7 Binary 63 | * HCB_8 2-Step 64 | * HCB_9 Binary 65 | * HCB_10 2-Step 66 | * HCB_11 2-Step 67 | * HCB_SF Binary 68 | * 69 | */ 70 | 71 | 72 | #define ZERO_HCB 0 73 | #define FIRST_PAIR_HCB 5 74 | #define ESC_HCB 11 75 | #define QUAD_LEN 4 76 | #define PAIR_LEN 2 77 | #define NOISE_HCB 13 78 | #define INTENSITY_HCB2 14 79 | #define INTENSITY_HCB 15 80 | 81 | /* 1st step table */ 82 | typedef struct 83 | { 84 | uint8_t offset; 85 | uint8_t extra_bits; 86 | } hcb; 87 | 88 | /* 2nd step table with quadruple data */ 89 | typedef struct 90 | { 91 | uint8_t bits; 92 | int8_t x; 93 | int8_t y; 94 | } hcb_2_pair; 95 | 96 | typedef struct 97 | { 98 | uint8_t bits; 99 | int8_t x; 100 | int8_t y; 101 | int8_t v; 102 | int8_t w; 103 | } hcb_2_quad; 104 | 105 | /* binary search table */ 106 | typedef struct 107 | { 108 | uint8_t is_leaf; 109 | int8_t data[4]; 110 | } hcb_bin_quad; 111 | 112 | typedef struct 113 | { 114 | uint8_t is_leaf; 115 | int8_t data[2]; 116 | } hcb_bin_pair; 117 | 118 | hcb *hcb_table[]; 119 | hcb_2_quad *hcb_2_quad_table[]; 120 | hcb_2_pair *hcb_2_pair_table[]; 121 | hcb_bin_pair *hcb_bin_table[]; 122 | uint8_t hcbN[]; 123 | uint8_t unsigned_cb[]; 124 | int hcb_2_quad_table_size[]; 125 | int hcb_2_pair_table_size[]; 126 | int hcb_bin_table_size[]; 127 | 128 | #include "codebook/hcb_1.h" 129 | #include "codebook/hcb_2.h" 130 | #include "codebook/hcb_3.h" 131 | #include "codebook/hcb_4.h" 132 | #include "codebook/hcb_5.h" 133 | #include "codebook/hcb_6.h" 134 | #include "codebook/hcb_7.h" 135 | #include "codebook/hcb_8.h" 136 | #include "codebook/hcb_9.h" 137 | #include "codebook/hcb_10.h" 138 | #include "codebook/hcb_11.h" 139 | #include "codebook/hcb_sf.h" 140 | 141 | 142 | #ifdef __cplusplus 143 | } 144 | #endif 145 | #endif 146 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_1.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_1 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static hcb hcb1_1[] = { 40 | { /* 00000 */ 0, 0 }, 41 | { /* */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* */ 0, 0 }, 45 | { /* */ 0, 0 }, 46 | { /* */ 0, 0 }, 47 | { /* */ 0, 0 }, 48 | { /* */ 0, 0 }, 49 | { /* */ 0, 0 }, 50 | { /* */ 0, 0 }, 51 | { /* */ 0, 0 }, 52 | { /* */ 0, 0 }, 53 | { /* */ 0, 0 }, 54 | { /* */ 0, 0 }, 55 | { /* */ 0, 0 }, 56 | { /* 10000 */ 1, 0 }, 57 | { /* 10001 */ 2, 0 }, 58 | { /* 10010 */ 3, 0 }, 59 | { /* 10011 */ 4, 0 }, 60 | { /* 10100 */ 5, 0 }, 61 | { /* 10101 */ 6, 0 }, 62 | { /* 10110 */ 7, 0 }, 63 | { /* 10111 */ 8, 0 }, 64 | 65 | /* 7 bit codewords */ 66 | { /* 11000 */ 9, 2 }, 67 | { /* 11001 */ 13, 2 }, 68 | { /* 11010 */ 17, 2 }, 69 | { /* 11011 */ 21, 2 }, 70 | { /* 11100 */ 25, 2 }, 71 | { /* 11101 */ 29, 2 }, 72 | 73 | /* 9 bit codewords */ 74 | { /* 11110 */ 33, 4 }, 75 | 76 | /* 9/10/11 bit codewords */ 77 | { /* 11111 */ 49, 6 } 78 | }; 79 | 80 | /* 2nd step table 81 | * 82 | * Gives size of codeword and actual data (x,y,v,w) 83 | */ 84 | static hcb_2_quad hcb1_2[] = { 85 | /* 1 bit codeword */ 86 | { 1, 0, 0, 0, 0 }, 87 | 88 | /* 5 bit codewords */ 89 | { 5, 1, 0, 0, 0 }, 90 | { 5, -1, 0, 0, 0 }, 91 | { 5, 0, 0, 0, -1 }, 92 | { 5, 0, 1, 0, 0 }, 93 | { 5, 0, 0, 0, 1 }, 94 | { 5, 0, 0, -1, 0 }, 95 | { 5, 0, 0, 1, 0 }, 96 | { 5, 0, -1, 0, 0 }, 97 | 98 | /* 7 bit codewords */ 99 | /* first 5 bits: 11000 */ 100 | { 7, 1, -1, 0, 0 }, 101 | { 7, -1, 1, 0, 0 }, 102 | { 7, 0, 0, -1, 1 }, 103 | { 7, 0, 1, -1, 0 }, 104 | /* first 5 bits: 11001 */ 105 | { 7, 0, -1, 1, 0 }, 106 | { 7, 0, 0, 1, -1 }, 107 | { 7, 1, 1, 0, 0 }, 108 | { 7, 0, 0, -1, -1 }, 109 | /* first 5 bits: 11010 */ 110 | { 7, -1, -1, 0, 0 }, 111 | { 7, 0, -1, -1, 0 }, 112 | { 7, 1, 0, -1, 0 }, 113 | { 7, 0, 1, 0, -1 }, 114 | /* first 5 bits: 11011 */ 115 | { 7, -1, 0, 1, 0 }, 116 | { 7, 0, 0, 1, 1 }, 117 | { 7, 1, 0, 1, 0 }, 118 | { 7, 0, -1, 0, 1 }, 119 | /* first 5 bits: 11100 */ 120 | { 7, 0, 1, 1, 0 }, 121 | { 7, 0, 1, 0, 1 }, 122 | { 7, -1, 0, -1, 0 }, 123 | { 7, 1, 0, 0, 1 }, 124 | /* first 5 bits: 11101 */ 125 | { 7, -1, 0, 0, -1 }, 126 | { 7, 1, 0, 0, -1 }, 127 | { 7, -1, 0, 0, 1 }, 128 | { 7, 0, -1, 0, -1 }, 129 | 130 | /* 9 bit codeword */ 131 | /* first 5 bits: 11110 */ 132 | { 9, 1, 1, -1, 0 }, 133 | { 9, -1, 1, -1, 0 }, 134 | { 9, 1, -1, 1, 0 }, 135 | { 9, 0, 1, 1, -1 }, 136 | { 9, 0, 1, -1, 1 }, 137 | { 9, 0, -1, 1, 1 }, 138 | { 9, 0, -1, 1, -1 }, 139 | { 9, 1, -1, -1, 0 }, 140 | { 9, 1, 0, -1, 1 }, 141 | { 9, 0, 1, -1, -1 }, 142 | { 9, -1, 1, 1, 0 }, 143 | { 9, -1, 0, 1, -1 }, 144 | { 9, -1, -1, 1, 0 }, 145 | { 9, 0, -1, -1, 1 }, 146 | { 9, 1, -1, 0, 1 }, 147 | { 9, 1, -1, 0, -1 }, 148 | 149 | /* 9/10/11 bit codewords */ 150 | /* first 5 bits: 11111 */ 151 | /* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */ 152 | { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, 153 | { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, 154 | { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, 155 | { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, 156 | { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, 157 | { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, 158 | { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, 159 | { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, 160 | /* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */ 161 | { 10, -1, -1, 0, 1 }, { 10, -1, -1, 0, 1 }, 162 | { 10, -1, 0, -1, -1 }, { 10, -1, 0, -1, -1 }, 163 | { 10, 1, 1, 0, -1 }, { 10, 1, 1, 0, -1 }, 164 | { 10, 1, 0, -1, -1 }, { 10, 1, 0, -1, -1 }, 165 | { 10, -1, 0, -1, 1 }, { 10, -1, 0, -1, 1 }, 166 | { 10, -1, -1, 0, -1 }, { 10, -1, -1, 0, -1 }, 167 | { 10, -1, 0, 1, 1 }, { 10, -1, 0, 1, 1 }, 168 | { 10, 1, 0, 1, 1 }, { 10, 1, 0, 1, 1 }, 169 | /* 11 bit */ 170 | { 11, 1, -1, 1, -1 }, 171 | { 11, -1, 1, -1, 1 }, 172 | { 11, -1, 1, 1, -1 }, 173 | { 11, 1, -1, -1, 1 }, 174 | { 11, 1, 1, 1, 1 }, 175 | { 11, -1, -1, 1, 1 }, 176 | { 11, 1, 1, -1, -1 }, 177 | { 11, -1, -1, 1, -1 }, 178 | { 11, -1, -1, -1, -1 }, 179 | { 11, 1, 1, -1, 1 }, 180 | { 11, 1, -1, 1, 1 }, 181 | { 11, -1, 1, 1, 1 }, 182 | { 11, -1, 1, -1, -1 }, 183 | { 11, -1, -1, -1, 1 }, 184 | { 11, 1, -1, -1, -1 }, 185 | { 11, 1, 1, 1, -1 } 186 | }; 187 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_2.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_2.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_2 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static hcb hcb2_1[] = { 40 | { /* 00000 */ 0, 0 }, 41 | { /* */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* 00100 */ 1, 0 }, 45 | { /* */ 1, 0 }, 46 | { /* 00110 */ 2, 0 }, 47 | { /* 00111 */ 3, 0 }, 48 | { /* 01000 */ 4, 0 }, 49 | { /* 01001 */ 5, 0 }, 50 | { /* 01010 */ 6, 0 }, 51 | { /* 01011 */ 7, 0 }, 52 | { /* 01100 */ 8, 0 }, 53 | 54 | /* 6 bit codewords */ 55 | { /* 01101 */ 9, 1 }, 56 | { /* 01110 */ 11, 1 }, 57 | { /* 01111 */ 13, 1 }, 58 | { /* 10000 */ 15, 1 }, 59 | { /* 10001 */ 17, 1 }, 60 | { /* 10010 */ 19, 1 }, 61 | { /* 10011 */ 21, 1 }, 62 | { /* 10100 */ 23, 1 }, 63 | { /* 10101 */ 25, 1 }, 64 | { /* 10110 */ 27, 1 }, 65 | { /* 10111 */ 29, 1 }, 66 | { /* 11000 */ 31, 1 }, 67 | 68 | /* 7 bit codewords */ 69 | { /* 11001 */ 33, 2 }, 70 | { /* 11010 */ 37, 2 }, 71 | { /* 11011 */ 41, 2 }, 72 | 73 | /* 7/8 bit codewords */ 74 | { /* 11100 */ 45, 3 }, 75 | 76 | /* 8 bit codewords */ 77 | { /* 11101 */ 53, 3 }, 78 | { /* 11110 */ 61, 3 }, 79 | 80 | /* 8/9 bit codewords */ 81 | { /* 11111 */ 69, 4 } 82 | }; 83 | 84 | /* 2nd step table 85 | * 86 | * Gives size of codeword and actual data (x,y,v,w) 87 | */ 88 | static hcb_2_quad hcb2_2[] = { 89 | /* 3 bit codeword */ 90 | { 3, 0, 0, 0, 0 }, 91 | 92 | /* 4 bit codeword */ 93 | { 4, 1, 0, 0, 0 }, 94 | 95 | /* 5 bit codewords */ 96 | { 5, -1, 0, 0, 0 }, 97 | { 5, 0, 0, 0, 1 }, 98 | { 5, 0, 0, -1, 0 }, 99 | { 5, 0, 0, 0, -1 }, 100 | { 5, 0, -1, 0, 0 }, 101 | { 5, 0, 0, 1, 0 }, 102 | { 5, 0, 1, 0, 0 }, 103 | 104 | /* 6 bit codewords */ 105 | { 6, 0, -1, 1, 0 }, 106 | { 6, -1, 1, 0, 0 }, 107 | { 6, 0, 1, -1, 0 }, 108 | { 6, 0, 0, 1, -1 }, 109 | { 6, 0, 1, 0, -1 }, 110 | { 6, 0, 0, -1, 1 }, 111 | { 6, -1, 0, 0, -1 }, 112 | { 6, 1, -1, 0, 0 }, 113 | { 6, 1, 0, -1, 0 }, 114 | { 6, -1, -1, 0, 0 }, 115 | { 6, 0, 0, -1, -1 }, 116 | { 6, 1, 0, 1, 0 }, 117 | { 6, 1, 0, 0, 1 }, 118 | { 6, 0, -1, 0, 1 }, 119 | { 6, -1, 0, 1, 0 }, 120 | { 6, 0, 1, 0, 1 }, 121 | { 6, 0, -1, -1, 0 }, 122 | { 6, -1, 0, 0, 1 }, 123 | { 6, 0, -1, 0, -1 }, 124 | { 6, -1, 0, -1, 0 }, 125 | { 6, 1, 1, 0, 0 }, 126 | { 6, 0, 1, 1, 0 }, 127 | { 6, 0, 0, 1, 1 }, 128 | { 6, 1, 0, 0, -1 }, 129 | 130 | /* 7 bit codewords */ 131 | { 7, 0, 1, -1, 1 }, 132 | { 7, 1, 0, -1, 1 }, 133 | { 7, -1, 1, -1, 0 }, 134 | { 7, 0, -1, 1, -1 }, 135 | { 7, 1, -1, 1, 0 }, 136 | { 7, 1, 1, 0, -1 }, 137 | { 7, 1, 0, 1, 1 }, 138 | { 7, -1, 1, 1, 0 }, 139 | { 7, 0, -1, -1, 1 }, 140 | { 7, 1, 1, 1, 0 }, 141 | { 7, -1, 0, 1, -1 }, 142 | { 7, -1, -1, -1, 0 }, 143 | 144 | /* 7/8 bit codewords */ 145 | { 7, -1, 0, -1, 1 }, { 7, -1, 0, -1, 1 }, 146 | { 7, 1, -1, -1, 0 }, { 7, 1, -1, -1, 0 }, 147 | { 7, 1, 1, -1, 0 }, { 7, 1, 1, -1, 0 }, 148 | { 8, 1, -1, 0, 1 }, 149 | { 8, -1, 1, 0, -1 }, 150 | 151 | /* 8 bit codewords */ 152 | { 8, -1, -1, 1, 0 }, 153 | { 8, -1, 0, 1, 1 }, 154 | { 8, -1, -1, 0, 1 }, 155 | { 8, -1, -1, 0, -1 }, 156 | { 8, 0, -1, -1, -1 }, 157 | { 8, 1, 0, 1, -1 }, 158 | { 8, 1, 0, -1, -1 }, 159 | { 8, 0, 1, -1, -1 }, 160 | { 8, 0, 1, 1, 1 }, 161 | { 8, -1, 1, 0, 1 }, 162 | { 8, -1, 0, -1, -1 }, 163 | { 8, 0, 1, 1, -1 }, 164 | { 8, 1, -1, 0, -1 }, 165 | { 8, 0, -1, 1, 1 }, 166 | { 8, 1, 1, 0, 1 }, 167 | { 8, 1, -1, 1, -1 }, 168 | 169 | /* 8/9 bit codewords */ 170 | { 8, -1, 1, -1, 1 }, { 8, -1, 1, -1, 1 }, 171 | { 9, 1, -1, -1, 1 }, 172 | { 9, -1, -1, -1, -1 }, 173 | { 9, -1, 1, 1, -1 }, 174 | { 9, -1, 1, 1, 1 }, 175 | { 9, 1, 1, 1, 1 }, 176 | { 9, -1, -1, 1, -1 }, 177 | { 9, 1, -1, 1, 1 }, 178 | { 9, -1, 1, -1, -1 }, 179 | { 9, -1, -1, 1, 1 }, 180 | { 9, 1, 1, -1, -1 }, 181 | { 9, 1, -1, -1, -1 }, 182 | { 9, -1, -1, -1, 1 }, 183 | { 9, 1, 1, -1, 1 }, 184 | { 9, 1, 1, 1, -1 } 185 | }; 186 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_5.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_5.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* Binary search huffman table HCB_5 */ 32 | 33 | 34 | static hcb_bin_pair hcb5[] = { 35 | { /* 0 */ 0, { 1, 2 } }, 36 | { /* 1 */ 1, { 0, 0 } }, /* 0 */ 37 | { /* 2 */ 0, { 1, 2 } }, 38 | { /* 3 */ 0, { 2, 3 } }, 39 | { /* 4 */ 0, { 3, 4 } }, 40 | { /* 5 */ 0, { 4, 5 } }, 41 | { /* 6 */ 0, { 5, 6 } }, 42 | { /* 7 */ 0, { 6, 7 } }, 43 | { /* 8 */ 0, { 7, 8 } }, 44 | { /* 9 */ 1, { -1, 0 } }, /* 1000 */ 45 | { /* 10 */ 1, { 1, 0 } }, /* 1001 */ 46 | { /* 11 */ 1, { 0, 1 } }, /* 1010 */ 47 | { /* 12 */ 1, { 0, -1 } }, /* 1011 */ 48 | { /* 13 */ 0, { 4, 5 } }, 49 | { /* 14 */ 0, { 5, 6 } }, 50 | { /* 15 */ 0, { 6, 7 } }, 51 | { /* 16 */ 0, { 7, 8 } }, 52 | { /* 17 */ 1, { 1, -1 } }, 53 | { /* 18 */ 1, { -1, 1 } }, 54 | { /* 19 */ 1, { -1, -1 } }, 55 | { /* 20 */ 1, { 1, 1 } }, 56 | { /* 21 */ 0, { 4, 5 } }, 57 | { /* 22 */ 0, { 5, 6 } }, 58 | { /* 23 */ 0, { 6, 7 } }, 59 | { /* 24 */ 0, { 7, 8 } }, 60 | { /* 25 */ 0, { 8, 9 } }, 61 | { /* 26 */ 0, { 9, 10 } }, 62 | { /* 27 */ 0, { 10, 11 } }, 63 | { /* 28 */ 0, { 11, 12 } }, 64 | { /* 29 */ 0, { 12, 13 } }, 65 | { /* 30 */ 0, { 13, 14 } }, 66 | { /* 31 */ 0, { 14, 15 } }, 67 | { /* 32 */ 0, { 15, 16 } }, 68 | { /* 33 */ 1, { -2, 0 } }, 69 | { /* 34 */ 1, { 0, 2 } }, 70 | { /* 35 */ 1, { 2, 0 } }, 71 | { /* 36 */ 1, { 0, -2 } }, 72 | { /* 37 */ 0, { 12, 13 } }, 73 | { /* 38 */ 0, { 13, 14 } }, 74 | { /* 39 */ 0, { 14, 15 } }, 75 | { /* 40 */ 0, { 15, 16 } }, 76 | { /* 41 */ 0, { 16, 17 } }, 77 | { /* 42 */ 0, { 17, 18 } }, 78 | { /* 43 */ 0, { 18, 19 } }, 79 | { /* 44 */ 0, { 19, 20 } }, 80 | { /* 45 */ 0, { 20, 21 } }, 81 | { /* 46 */ 0, { 21, 22 } }, 82 | { /* 47 */ 0, { 22, 23 } }, 83 | { /* 48 */ 0, { 23, 24 } }, 84 | { /* 49 */ 1, { -2, -1 } }, 85 | { /* 50 */ 1, { 2, 1 } }, 86 | { /* 51 */ 1, { -1, -2 } }, 87 | { /* 52 */ 1, { 1, 2 } }, 88 | { /* 53 */ 1, { -2, 1 } }, 89 | { /* 54 */ 1, { 2, -1 } }, 90 | { /* 55 */ 1, { -1, 2 } }, 91 | { /* 56 */ 1, { 1, -2 } }, 92 | { /* 57 */ 1, { -3, 0 } }, 93 | { /* 58 */ 1, { 3, 0 } }, 94 | { /* 59 */ 1, { 0, -3 } }, 95 | { /* 60 */ 1, { 0, 3 } }, 96 | { /* 61 */ 0, { 12, 13 } }, 97 | { /* 62 */ 0, { 13, 14 } }, 98 | { /* 63 */ 0, { 14, 15 } }, 99 | { /* 64 */ 0, { 15, 16 } }, 100 | { /* 65 */ 0, { 16, 17 } }, 101 | { /* 66 */ 0, { 17, 18 } }, 102 | { /* 67 */ 0, { 18, 19 } }, 103 | { /* 68 */ 0, { 19, 20 } }, 104 | { /* 69 */ 0, { 20, 21 } }, 105 | { /* 70 */ 0, { 21, 22 } }, 106 | { /* 71 */ 0, { 22, 23 } }, 107 | { /* 72 */ 0, { 23, 24 } }, 108 | { /* 73 */ 1, { -3, -1 } }, 109 | { /* 74 */ 1, { 1, 3 } }, 110 | { /* 75 */ 1, { 3, 1 } }, 111 | { /* 76 */ 1, { -1, -3 } }, 112 | { /* 77 */ 1, { -3, 1 } }, 113 | { /* 78 */ 1, { 3, -1 } }, 114 | { /* 79 */ 1, { 1, -3 } }, 115 | { /* 80 */ 1, { -1, 3 } }, 116 | { /* 81 */ 1, { -2, 2 } }, 117 | { /* 82 */ 1, { 2, 2 } }, 118 | { /* 83 */ 1, { -2, -2 } }, 119 | { /* 84 */ 1, { 2, -2 } }, 120 | { /* 85 */ 0, { 12, 13 } }, 121 | { /* 86 */ 0, { 13, 14 } }, 122 | { /* 87 */ 0, { 14, 15 } }, 123 | { /* 88 */ 0, { 15, 16 } }, 124 | { /* 89 */ 0, { 16, 17 } }, 125 | { /* 90 */ 0, { 17, 18 } }, 126 | { /* 91 */ 0, { 18, 19 } }, 127 | { /* 92 */ 0, { 19, 20 } }, 128 | { /* 93 */ 0, { 20, 21 } }, 129 | { /* 94 */ 0, { 21, 22 } }, 130 | { /* 95 */ 0, { 22, 23 } }, 131 | { /* 96 */ 0, { 23, 24 } }, 132 | { /* 97 */ 1, { -3, -2 } }, 133 | { /* 98 */ 1, { 3, -2 } }, 134 | { /* 99 */ 1, { -2, 3 } }, 135 | { /* 00 */ 1, { 2, -3 } }, 136 | { /* 01 */ 1, { 3, 2 } }, 137 | { /* 02 */ 1, { 2, 3 } }, 138 | { /* 03 */ 1, { -3, 2 } }, 139 | { /* 04 */ 1, { -2, -3 } }, 140 | { /* 05 */ 1, { 0, -4 } }, 141 | { /* 06 */ 1, { -4, 0 } }, 142 | { /* 07 */ 1, { 4, 1 } }, 143 | { /* 08 */ 1, { 4, 0 } }, 144 | { /* 09 */ 0, { 12, 13 } }, 145 | { /* 10 */ 0, { 13, 14 } }, 146 | { /* 11 */ 0, { 14, 15 } }, 147 | { /* 12 */ 0, { 15, 16 } }, 148 | { /* 13 */ 0, { 16, 17 } }, 149 | { /* 14 */ 0, { 17, 18 } }, 150 | { /* 15 */ 0, { 18, 19 } }, 151 | { /* 16 */ 0, { 19, 20 } }, 152 | { /* 17 */ 0, { 20, 21 } }, 153 | { /* 18 */ 0, { 21, 22 } }, 154 | { /* 19 */ 0, { 22, 23 } }, 155 | { /* 20 */ 0, { 23, 24 } }, 156 | { /* 21 */ 1, { -4, -1 } }, 157 | { /* 22 */ 1, { 0, 4 } }, 158 | { /* 23 */ 1, { 4, -1 } }, 159 | { /* 24 */ 1, { -1, -4 } }, 160 | { /* 25 */ 1, { 1, 4 } }, 161 | { /* 26 */ 1, { -1, 4 } }, 162 | { /* 27 */ 1, { -4, 1 } }, 163 | { /* 28 */ 1, { 1, -4 } }, 164 | { /* 29 */ 1, { 3, -3 } }, 165 | { /* 30 */ 1, { -3, -3 } }, 166 | { /* 31 */ 1, { -3, 3 } }, 167 | { /* 32 */ 1, { -2, 4 } }, 168 | { /* 33 */ 1, { -4, -2 } }, 169 | { /* 34 */ 1, { 4, 2 } }, 170 | { /* 35 */ 1, { 2, -4 } }, 171 | { /* 36 */ 1, { 2, 4 } }, 172 | { /* 37 */ 1, { 3, 3 } }, 173 | { /* 38 */ 1, { -4, 2 } }, 174 | { /* 39 */ 0, { 6, 7 } }, 175 | { /* 40 */ 0, { 7, 8 } }, 176 | { /* 41 */ 0, { 8, 9 } }, 177 | { /* 42 */ 0, { 9, 10 } }, 178 | { /* 43 */ 0, { 10, 11 } }, 179 | { /* 44 */ 0, { 11, 12 } }, 180 | { /* 45 */ 1, { -2, -4 } }, 181 | { /* 46 */ 1, { 4, -2 } }, 182 | { /* 47 */ 1, { 3, -4 } }, 183 | { /* 48 */ 1, { -4, -3 } }, 184 | { /* 49 */ 1, { -4, 3 } }, 185 | { /* 50 */ 1, { 3, 4 } }, 186 | { /* 51 */ 1, { -3, 4 } }, 187 | { /* 52 */ 1, { 4, 3 } }, 188 | { /* 53 */ 1, { 4, -3 } }, 189 | { /* 54 */ 1, { -3, -4 } }, 190 | { /* 55 */ 0, { 2, 3 } }, 191 | { /* 56 */ 0, { 3, 4 } }, 192 | { /* 57 */ 1, { 4, -4 } }, 193 | { /* 58 */ 1, { -4, 4 } }, 194 | { /* 59 */ 1, { 4, 4 } }, 195 | { /* 60 */ 1, { -4, -4 } } 196 | }; 197 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_6.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_6.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_6 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static hcb hcb6_1[] = { 40 | /* 4 bit codewords */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* 00010 */ 1, 0 }, 44 | { /* */ 1, 0 }, 45 | { /* 00100 */ 2, 0 }, 46 | { /* */ 2, 0 }, 47 | { /* 00110 */ 3, 0 }, 48 | { /* */ 3, 0 }, 49 | { /* 01000 */ 4, 0 }, 50 | { /* */ 4, 0 }, 51 | { /* 01010 */ 5, 0 }, 52 | { /* */ 5, 0 }, 53 | { /* 01100 */ 6, 0 }, 54 | { /* */ 6, 0 }, 55 | { /* 01110 */ 7, 0 }, 56 | { /* */ 7, 0 }, 57 | { /* 10000 */ 8, 0 }, 58 | { /* */ 8, 0 }, 59 | 60 | /* 6 bit codewords */ 61 | { /* 10010 */ 9, 1 }, 62 | { /* 10011 */ 11, 1 }, 63 | { /* 10100 */ 13, 1 }, 64 | { /* 10101 */ 15, 1 }, 65 | { /* 10110 */ 17, 1 }, 66 | { /* 10111 */ 19, 1 }, 67 | { /* 11000 */ 21, 1 }, 68 | { /* 11001 */ 23, 1 }, 69 | 70 | /* 7 bit codewords */ 71 | { /* 11010 */ 25, 2 }, 72 | { /* 11011 */ 29, 2 }, 73 | { /* 11100 */ 33, 2 }, 74 | 75 | /* 7/8 bit codewords */ 76 | { /* 11101 */ 37, 3 }, 77 | 78 | /* 8/9 bit codewords */ 79 | { /* 11110 */ 45, 4 }, 80 | 81 | /* 9/10/11 bit codewords */ 82 | { /* 11111 */ 61, 6 } 83 | }; 84 | 85 | /* 2nd step table 86 | * 87 | * Gives size of codeword and actual data (x,y,v,w) 88 | */ 89 | static hcb_2_pair hcb6_2[] = { 90 | /* 4 bit codewords */ 91 | { 4, 0, 0 }, 92 | { 4, 1, 0 }, 93 | { 4, 0, -1 }, 94 | { 4, 0, 1 }, 95 | { 4, -1, 0 }, 96 | { 4, 1, 1 }, 97 | { 4, -1, 1 }, 98 | { 4, 1, -1 }, 99 | { 4, -1, -1 }, 100 | 101 | /* 6 bit codewords */ 102 | { 6, 2, -1 }, 103 | { 6, 2, 1 }, 104 | { 6, -2, 1 }, 105 | { 6, -2, -1 }, 106 | { 6, -2, 0 }, 107 | { 6, -1, 2 }, 108 | { 6, 2, 0 }, 109 | { 6, 1, -2 }, 110 | { 6, 1, 2 }, 111 | { 6, 0, -2 }, 112 | { 6, -1, -2 }, 113 | { 6, 0, 2 }, 114 | { 6, 2, -2 }, 115 | { 6, -2, 2 }, 116 | { 6, -2, -2 }, 117 | { 6, 2, 2 }, 118 | 119 | /* 7 bit codewords */ 120 | { 7, -3, 1 }, 121 | { 7, 3, 1 }, 122 | { 7, 3, -1 }, 123 | { 7, -1, 3 }, 124 | { 7, -3, -1 }, 125 | { 7, 1, 3 }, 126 | { 7, 1, -3 }, 127 | { 7, -1, -3 }, 128 | { 7, 3, 0 }, 129 | { 7, -3, 0 }, 130 | { 7, 0, -3 }, 131 | { 7, 0, 3 }, 132 | 133 | /* 7/8 bit codewords */ 134 | { 7, 3, 2 }, { 7, 3, 2 }, 135 | { 8, -3, -2 }, 136 | { 8, -2, 3 }, 137 | { 8, 2, 3 }, 138 | { 8, 3, -2 }, 139 | { 8, 2, -3 }, 140 | { 8, -2, -3 }, 141 | 142 | /* 8 bit codewords */ 143 | { 8, -3, 2 }, { 8, -3, 2 }, 144 | { 8, 3, 3 }, { 8, 3, 3 }, 145 | { 9, 3, -3 }, 146 | { 9, -3, -3 }, 147 | { 9, -3, 3 }, 148 | { 9, 1, -4 }, 149 | { 9, -1, -4 }, 150 | { 9, 4, 1 }, 151 | { 9, -4, 1 }, 152 | { 9, -4, -1 }, 153 | { 9, 1, 4 }, 154 | { 9, 4, -1 }, 155 | { 9, -1, 4 }, 156 | { 9, 0, -4 }, 157 | 158 | /* 9/10/11 bit codewords */ 159 | { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, 160 | { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, 161 | { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, 162 | { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, 163 | { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, 164 | { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, 165 | { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, 166 | { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, 167 | { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, 168 | { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, 169 | { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, 170 | { 10, -3, -4 }, { 10, -3, -4 }, 171 | { 10, -3, 4 }, { 10, -3, 4 }, 172 | { 10, 3, -4 }, { 10, 3, -4 }, 173 | { 10, 4, -3 }, { 10, 4, -3 }, 174 | { 10, 3, 4 }, { 10, 3, 4 }, 175 | { 10, 4, 3 }, { 10, 4, 3 }, 176 | { 10, -4, 3 }, { 10, -4, 3 }, 177 | { 10, -4, -3 }, { 10, -4, -3 }, 178 | { 11, 4, 4 }, 179 | { 11, -4, 4 }, 180 | { 11, -4, -4 }, 181 | { 11, 4, -4 } 182 | }; 183 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_7.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_7.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* Binary search huffman table HCB_7 */ 32 | 33 | 34 | static hcb_bin_pair hcb7[] = { 35 | { /* 0 */ 0, { 1, 2 } }, 36 | { /* 1 */ 1, { 0, 0 } }, 37 | { /* 2 */ 0, { 1, 2 } }, 38 | { /* 3 */ 0, { 2, 3 } }, 39 | { /* 4 */ 0, { 3, 4 } }, 40 | { /* 5 */ 1, { 1, 0 } }, 41 | { /* 6 */ 1, { 0, 1 } }, 42 | { /* 7 */ 0, { 2, 3 } }, 43 | { /* 8 */ 0, { 3, 4 } }, 44 | { /* 9 */ 1, { 1, 1 } }, 45 | { /* 10 */ 0, { 3, 4 } }, 46 | { /* 11 */ 0, { 4, 5 } }, 47 | { /* 12 */ 0, { 5, 6 } }, 48 | { /* 13 */ 0, { 6, 7 } }, 49 | { /* 14 */ 0, { 7, 8 } }, 50 | { /* 15 */ 0, { 8, 9 } }, 51 | { /* 16 */ 0, { 9, 10 } }, 52 | { /* 17 */ 0, { 10, 11 } }, 53 | { /* 18 */ 0, { 11, 12 } }, 54 | { /* 19 */ 1, { 2, 1 } }, 55 | { /* 20 */ 1, { 1, 2 } }, 56 | { /* 21 */ 1, { 2, 0 } }, 57 | { /* 22 */ 1, { 0, 2 } }, 58 | { /* 23 */ 0, { 8, 9 } }, 59 | { /* 24 */ 0, { 9, 10 } }, 60 | { /* 25 */ 0, { 10, 11 } }, 61 | { /* 26 */ 0, { 11, 12 } }, 62 | { /* 27 */ 0, { 12, 13 } }, 63 | { /* 28 */ 0, { 13, 14 } }, 64 | { /* 29 */ 0, { 14, 15 } }, 65 | { /* 30 */ 0, { 15, 16 } }, 66 | { /* 31 */ 1, { 3, 1 } }, 67 | { /* 32 */ 1, { 1, 3 } }, 68 | { /* 33 */ 1, { 2, 2 } }, 69 | { /* 34 */ 1, { 3, 0 } }, 70 | { /* 35 */ 1, { 0, 3 } }, 71 | { /* 36 */ 0, { 11, 12 } }, 72 | { /* 37 */ 0, { 12, 13 } }, 73 | { /* 38 */ 0, { 13, 14 } }, 74 | { /* 39 */ 0, { 14, 15 } }, 75 | { /* 40 */ 0, { 15, 16 } }, 76 | { /* 41 */ 0, { 16, 17 } }, 77 | { /* 42 */ 0, { 17, 18 } }, 78 | { /* 43 */ 0, { 18, 19 } }, 79 | { /* 44 */ 0, { 19, 20 } }, 80 | { /* 45 */ 0, { 20, 21 } }, 81 | { /* 46 */ 0, { 21, 22 } }, 82 | { /* 47 */ 1, { 2, 3 } }, 83 | { /* 48 */ 1, { 3, 2 } }, 84 | { /* 49 */ 1, { 1, 4 } }, 85 | { /* 50 */ 1, { 4, 1 } }, 86 | { /* 51 */ 1, { 1, 5 } }, 87 | { /* 52 */ 1, { 5, 1 } }, 88 | { /* 53 */ 1, { 3, 3 } }, 89 | { /* 54 */ 1, { 2, 4 } }, 90 | { /* 55 */ 1, { 0, 4 } }, 91 | { /* 56 */ 1, { 4, 0 } }, 92 | { /* 57 */ 0, { 12, 13 } }, 93 | { /* 58 */ 0, { 13, 14 } }, 94 | { /* 59 */ 0, { 14, 15 } }, 95 | { /* 60 */ 0, { 15, 16 } }, 96 | { /* 61 */ 0, { 16, 17 } }, 97 | { /* 62 */ 0, { 17, 18 } }, 98 | { /* 63 */ 0, { 18, 19 } }, 99 | { /* 64 */ 0, { 19, 20 } }, 100 | { /* 65 */ 0, { 20, 21 } }, 101 | { /* 66 */ 0, { 21, 22 } }, 102 | { /* 67 */ 0, { 22, 23 } }, 103 | { /* 68 */ 0, { 23, 24 } }, 104 | { /* 69 */ 1, { 4, 2 } }, 105 | { /* 70 */ 1, { 2, 5 } }, 106 | { /* 71 */ 1, { 5, 2 } }, 107 | { /* 72 */ 1, { 0, 5 } }, 108 | { /* 73 */ 1, { 6, 1 } }, 109 | { /* 74 */ 1, { 5, 0 } }, 110 | { /* 75 */ 1, { 1, 6 } }, 111 | { /* 76 */ 1, { 4, 3 } }, 112 | { /* 77 */ 1, { 3, 5 } }, 113 | { /* 78 */ 1, { 3, 4 } }, 114 | { /* 79 */ 1, { 5, 3 } }, 115 | { /* 80 */ 1, { 2, 6 } }, 116 | { /* 81 */ 1, { 6, 2 } }, 117 | { /* 82 */ 1, { 1, 7 } }, 118 | { /* 83 */ 0, { 10, 11 } }, 119 | { /* 84 */ 0, { 11, 12 } }, 120 | { /* 85 */ 0, { 12, 13 } }, 121 | { /* 86 */ 0, { 13, 14 } }, 122 | { /* 87 */ 0, { 14, 15 } }, 123 | { /* 88 */ 0, { 15, 16 } }, 124 | { /* 89 */ 0, { 16, 17 } }, 125 | { /* 90 */ 0, { 17, 18 } }, 126 | { /* 91 */ 0, { 18, 19 } }, 127 | { /* 92 */ 0, { 19, 20 } }, 128 | { /* 93 */ 1, { 3, 6 } }, 129 | { /* 94 */ 1, { 0, 6 } }, 130 | { /* 95 */ 1, { 6, 0 } }, 131 | { /* 96 */ 1, { 4, 4 } }, 132 | { /* 97 */ 1, { 7, 1 } }, 133 | { /* 98 */ 1, { 4, 5 } }, 134 | { /* 99 */ 1, { 7, 2 } }, 135 | { /* 00 */ 1, { 5, 4 } }, 136 | { /* 01 */ 1, { 6, 3 } }, 137 | { /* 02 */ 1, { 2, 7 } }, 138 | { /* 03 */ 1, { 7, 3 } }, 139 | { /* 04 */ 1, { 6, 4 } }, 140 | { /* 05 */ 1, { 5, 5 } }, 141 | { /* 06 */ 1, { 4, 6 } }, 142 | { /* 07 */ 1, { 3, 7 } }, 143 | { /* 08 */ 0, { 5, 6 } }, 144 | { /* 09 */ 0, { 6, 7 } }, 145 | { /* 10 */ 0, { 7, 8 } }, 146 | { /* 11 */ 0, { 8, 9 } }, 147 | { /* 12 */ 0, { 9, 10 } }, 148 | { /* 13 */ 1, { 7, 0 } }, 149 | { /* 14 */ 1, { 0, 7 } }, 150 | { /* 15 */ 1, { 6, 5 } }, 151 | { /* 16 */ 1, { 5, 6 } }, 152 | { /* 17 */ 1, { 7, 4 } }, 153 | { /* 18 */ 1, { 4, 7 } }, 154 | { /* 19 */ 1, { 5, 7 } }, 155 | { /* 20 */ 1, { 7, 5 } }, 156 | { /* 21 */ 0, { 2, 3 } }, 157 | { /* 22 */ 0, { 3, 4 } }, 158 | { /* 23 */ 1, { 7, 6 } }, 159 | { /* 24 */ 1, { 6, 6 } }, 160 | { /* 25 */ 1, { 6, 7 } }, 161 | { /* 26 */ 1, { 7, 7 } } 162 | }; 163 | -------------------------------------------------------------------------------- /src/libFaad/codebook/hcb_8.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: hcb_8.h,v 1.5 2007/11/01 12:34:11 menno Exp $ 29 | **/ 30 | 31 | /* 2-step huffman table HCB_8 */ 32 | 33 | 34 | /* 1st step: 5 bits 35 | * 2^5 = 32 entries 36 | * 37 | * Used to find offset into 2nd step table and number of extra bits to get 38 | */ 39 | static hcb hcb8_1[] = { 40 | /* 3 bit codeword */ 41 | { /* 00000 */ 0, 0 }, 42 | { /* */ 0, 0 }, 43 | { /* */ 0, 0 }, 44 | { /* */ 0, 0 }, 45 | 46 | /* 4 bit codewords */ 47 | { /* 00100 */ 1, 0 }, 48 | { /* */ 1, 0 }, 49 | { /* 00110 */ 2, 0 }, 50 | { /* */ 2, 0 }, 51 | { /* 01000 */ 3, 0 }, 52 | { /* */ 3, 0 }, 53 | { /* 01010 */ 4, 0 }, 54 | { /* */ 4, 0 }, 55 | { /* 01100 */ 5, 0 }, 56 | { /* */ 5, 0 }, 57 | 58 | /* 5 bit codewords */ 59 | { /* 01110 */ 6, 0 }, 60 | { /* 01111 */ 7, 0 }, 61 | { /* 10000 */ 8, 0 }, 62 | { /* 10001 */ 9, 0 }, 63 | { /* 10010 */ 10, 0 }, 64 | { /* 10011 */ 11, 0 }, 65 | { /* 10100 */ 12, 0 }, 66 | 67 | /* 6 bit codewords */ 68 | { /* 10101 */ 13, 1 }, 69 | { /* 10110 */ 15, 1 }, 70 | { /* 10111 */ 17, 1 }, 71 | { /* 11000 */ 19, 1 }, 72 | { /* 11001 */ 21, 1 }, 73 | 74 | /* 7 bit codewords */ 75 | { /* 11010 */ 23, 2 }, 76 | { /* 11011 */ 27, 2 }, 77 | { /* 11100 */ 31, 2 }, 78 | 79 | /* 7/8 bit codewords */ 80 | { /* 11101 */ 35, 3 }, 81 | 82 | /* 8 bit codewords */ 83 | { /* 11110 */ 43, 3 }, 84 | 85 | /* 8/9/10 bit codewords */ 86 | { /* 11111 */ 51, 5 } 87 | }; 88 | 89 | /* 2nd step table 90 | * 91 | * Gives size of codeword and actual data (x,y,v,w) 92 | */ 93 | static hcb_2_pair hcb8_2[] = { 94 | /* 3 bit codeword */ 95 | { 3, 1, 1 }, 96 | 97 | /* 4 bit codewords */ 98 | { 4, 2, 1 }, 99 | { 4, 1, 0 }, 100 | { 4, 1, 2 }, 101 | { 4, 0, 1 }, 102 | { 4, 2, 2 }, 103 | 104 | /* 5 bit codewords */ 105 | { 5, 0, 0 }, 106 | { 5, 2, 0 }, 107 | { 5, 0, 2 }, 108 | { 5, 3, 1 }, 109 | { 5, 1, 3 }, 110 | { 5, 3, 2 }, 111 | { 5, 2, 3 }, 112 | 113 | /* 6 bit codewords */ 114 | { 6, 3, 3 }, 115 | { 6, 4, 1 }, 116 | { 6, 1, 4 }, 117 | { 6, 4, 2 }, 118 | { 6, 2, 4 }, 119 | { 6, 3, 0 }, 120 | { 6, 0, 3 }, 121 | { 6, 4, 3 }, 122 | { 6, 3, 4 }, 123 | { 6, 5, 2 }, 124 | 125 | /* 7 bit codewords */ 126 | { 7, 5, 1 }, 127 | { 7, 2, 5 }, 128 | { 7, 1, 5 }, 129 | { 7, 5, 3 }, 130 | { 7, 3, 5 }, 131 | { 7, 4, 4 }, 132 | { 7, 5, 4 }, 133 | { 7, 0, 4 }, 134 | { 7, 4, 5 }, 135 | { 7, 4, 0 }, 136 | { 7, 2, 6 }, 137 | { 7, 6, 2 }, 138 | 139 | /* 7/8 bit codewords */ 140 | { 7, 6, 1 }, { 7, 6, 1 }, 141 | { 7, 1, 6 }, { 7, 1, 6 }, 142 | { 8, 3, 6 }, 143 | { 8, 6, 3 }, 144 | { 8, 5, 5 }, 145 | { 8, 5, 0 }, 146 | 147 | /* 8 bit codewords */ 148 | { 8, 6, 4 }, 149 | { 8, 0, 5 }, 150 | { 8, 4, 6 }, 151 | { 8, 7, 1 }, 152 | { 8, 7, 2 }, 153 | { 8, 2, 7 }, 154 | { 8, 6, 5 }, 155 | { 8, 7, 3 }, 156 | 157 | /* 8/9/10 bit codewords */ 158 | { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, 159 | { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, 160 | { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, 161 | { 9, 6, 6 }, { 9, 6, 6 }, 162 | { 9, 7, 4 }, { 9, 7, 4 }, 163 | { 9, 6, 0 }, { 9, 6, 0 }, 164 | { 9, 4, 7 }, { 9, 4, 7 }, 165 | { 9, 0, 6 }, { 9, 0, 6 }, 166 | { 9, 7, 5 }, { 9, 7, 5 }, 167 | { 9, 7, 6 }, { 9, 7, 6 }, 168 | { 9, 6, 7 }, { 9, 6, 7 }, 169 | { 10, 5, 7 }, 170 | { 10, 7, 0 }, 171 | { 10, 0, 7 }, 172 | { 10, 7, 7 } 173 | }; 174 | -------------------------------------------------------------------------------- /src/libFaad/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * config.h 3 | * 4 | * Created on: 2014-7-1 5 | * Author: root 6 | */ 7 | 8 | #ifndef CONFIG_H_ 9 | #define CONFIG_H_ 10 | 11 | /* config.h. Generated from config.h.in by configure. */ 12 | /* config.h.in. Generated from configure.in by autoheader. */ 13 | 14 | /* Define if you want to use libfaad together with Digital Radio Mondiale 15 | (DRM) */ 16 | /* #undef DRM */ 17 | 18 | /* Define if you want support for Digital Radio Mondiale (DRM) parametric 19 | stereo */ 20 | /* #undef DRM_PS */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_DLFCN_H 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_ERRNO_H 1 27 | 28 | /* Define if needed */ 29 | /* #undef HAVE_FLOAT32_T */ 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_FLOAT_H 1 33 | 34 | /* Define to 1 if you have the `getpwuid' function. */ 35 | #define HAVE_GETPWUID 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_INTTYPES_H 1 39 | 40 | /* Define if you have the IOKit API */ 41 | /* #undef HAVE_IOKIT_IOKITLIB_H */ 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_LIMITS_H 1 45 | 46 | /* Define if you have C99's lrintf function. */ 47 | #define HAVE_LRINTF 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | /* #undef HAVE_MATHF_H */ 51 | 52 | /* Define to 1 if you have the `memcpy' function. */ 53 | #define HAVE_MEMCPY 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_MEMORY_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_STDINT_H 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_STDLIB_H 1 63 | 64 | /* Define to 1 if you have the `strchr' function. */ 65 | #define HAVE_STRCHR 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_STRINGS_H 1 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_STRING_H 1 72 | 73 | /* Define to 1 if you have the `strsep' function. */ 74 | #define HAVE_STRSEP 1 75 | 76 | /* Define to 1 if you have the header file. */ 77 | /* #undef HAVE_SYSFS_LIBSYSFS_H */ 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_SYS_STAT_H 1 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_SYS_TIME_H 1 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #define HAVE_SYS_TYPES_H 1 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_UNISTD_H 1 90 | 91 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 92 | /* #undef NO_MINUS_C_MINUS_O */ 93 | 94 | /* Name of package */ 95 | #define PACKAGE "faad2" 96 | 97 | /* Define to the address where bug reports for this package should be sent. */ 98 | #define PACKAGE_BUGREPORT "" 99 | 100 | /* Define to the full name of this package. */ 101 | #define PACKAGE_NAME "" 102 | 103 | /* Define to the full name and version of this package. */ 104 | #define PACKAGE_STRING "" 105 | 106 | /* Define to the one symbol short name of this package. */ 107 | #define PACKAGE_TARNAME "" 108 | 109 | /* Define to the version of this package. */ 110 | #define PACKAGE_VERSION "" 111 | 112 | /* Define to 1 if you have the ANSI C header files. */ 113 | #define STDC_HEADERS 1 114 | 115 | /* Define to 1 if you can safely include both and . */ 116 | #define TIME_WITH_SYS_TIME 1 117 | 118 | /* Version number of package */ 119 | #define VERSION "2.7.0" 120 | 121 | /* Define to 1 if your processor stores words with the most significant byte 122 | first (like Motorola and SPARC, unlike Intel and VAX). */ 123 | /* #undef WORDS_BIGENDIAN */ 124 | 125 | /* Define to `__inline__' or `__inline' if that's what the C compiler 126 | calls it, or to nothing if 'inline' is not supported under any name. */ 127 | #ifndef __cplusplus 128 | /* #undef inline */ 129 | #endif 130 | 131 | /* Define to `long int' if does not define. */ 132 | /* #undef off_t */ 133 | 134 | 135 | #endif /* CONFIG_H_ */ 136 | -------------------------------------------------------------------------------- /src/libFaad/drc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drc.c,v 1.28 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include 35 | #include 36 | #include "syntax.h" 37 | #include "drc.h" 38 | 39 | drc_info *drc_init(real_t cut, real_t boost) 40 | { 41 | drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info)); 42 | memset(drc, 0, sizeof(drc_info)); 43 | 44 | drc->ctrl1 = cut; 45 | drc->ctrl2 = boost; 46 | 47 | drc->num_bands = 1; 48 | drc->band_top[0] = 1024/4 - 1; 49 | drc->dyn_rng_sgn[0] = 1; 50 | drc->dyn_rng_ctl[0] = 0; 51 | 52 | return drc; 53 | } 54 | 55 | void drc_end(drc_info *drc) 56 | { 57 | if (drc) faad_free(drc); 58 | } 59 | 60 | #ifdef FIXED_POINT 61 | static real_t drc_pow2_table[] = 62 | { 63 | COEF_CONST(0.5146511183), 64 | COEF_CONST(0.5297315472), 65 | COEF_CONST(0.5452538663), 66 | COEF_CONST(0.5612310242), 67 | COEF_CONST(0.5776763484), 68 | COEF_CONST(0.5946035575), 69 | COEF_CONST(0.6120267717), 70 | COEF_CONST(0.6299605249), 71 | COEF_CONST(0.6484197773), 72 | COEF_CONST(0.6674199271), 73 | COEF_CONST(0.6869768237), 74 | COEF_CONST(0.7071067812), 75 | COEF_CONST(0.7278265914), 76 | COEF_CONST(0.7491535384), 77 | COEF_CONST(0.7711054127), 78 | COEF_CONST(0.7937005260), 79 | COEF_CONST(0.8169577266), 80 | COEF_CONST(0.8408964153), 81 | COEF_CONST(0.8655365610), 82 | COEF_CONST(0.8908987181), 83 | COEF_CONST(0.9170040432), 84 | COEF_CONST(0.9438743127), 85 | COEF_CONST(0.9715319412), 86 | COEF_CONST(1.0000000000), 87 | COEF_CONST(1.0293022366), 88 | COEF_CONST(1.0594630944), 89 | COEF_CONST(1.0905077327), 90 | COEF_CONST(1.1224620483), 91 | COEF_CONST(1.1553526969), 92 | COEF_CONST(1.1892071150), 93 | COEF_CONST(1.2240535433), 94 | COEF_CONST(1.2599210499), 95 | COEF_CONST(1.2968395547), 96 | COEF_CONST(1.3348398542), 97 | COEF_CONST(1.3739536475), 98 | COEF_CONST(1.4142135624), 99 | COEF_CONST(1.4556531828), 100 | COEF_CONST(1.4983070769), 101 | COEF_CONST(1.5422108254), 102 | COEF_CONST(1.5874010520), 103 | COEF_CONST(1.6339154532), 104 | COEF_CONST(1.6817928305), 105 | COEF_CONST(1.7310731220), 106 | COEF_CONST(1.7817974363), 107 | COEF_CONST(1.8340080864), 108 | COEF_CONST(1.8877486254), 109 | COEF_CONST(1.9430638823) 110 | }; 111 | #endif 112 | 113 | void drc_decode(drc_info *drc, real_t *spec) 114 | { 115 | uint16_t i, bd, top; 116 | #ifdef FIXED_POINT 117 | int32_t exp, frac; 118 | #else 119 | real_t factor, exp; 120 | #endif 121 | uint16_t bottom = 0; 122 | 123 | if (drc->num_bands == 1) 124 | drc->band_top[0] = 1024/4 - 1; 125 | 126 | for (bd = 0; bd < drc->num_bands; bd++) 127 | { 128 | top = 4 * (drc->band_top[bd] + 1); 129 | 130 | #ifndef FIXED_POINT 131 | /* Decode DRC gain factor */ 132 | if (drc->dyn_rng_sgn[bd]) /* compress */ 133 | exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); 134 | else /* boost */ 135 | exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); 136 | factor = (real_t)pow(2.0, exp); 137 | 138 | /* Apply gain factor */ 139 | for (i = bottom; i < top; i++) 140 | spec[i] *= factor; 141 | #else 142 | /* Decode DRC gain factor */ 143 | if (drc->dyn_rng_sgn[bd]) /* compress */ 144 | { 145 | exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; 146 | frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; 147 | } else { /* boost */ 148 | exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; 149 | frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; 150 | } 151 | 152 | /* Apply gain factor */ 153 | if (exp < 0) 154 | { 155 | for (i = bottom; i < top; i++) 156 | { 157 | spec[i] >>= -exp; 158 | if (frac) 159 | spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); 160 | } 161 | } else { 162 | for (i = bottom; i < top; i++) 163 | { 164 | spec[i] <<= exp; 165 | if (frac) 166 | spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); 167 | } 168 | } 169 | #endif 170 | 171 | bottom = top; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/libFaad/drc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drc.h,v 1.22 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __DRC_H__ 32 | #define __DRC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define DRC_REF_LEVEL 20*4 /* -20 dB */ 39 | 40 | 41 | drc_info *drc_init(real_t cut, real_t boost); 42 | void drc_end(drc_info *drc); 43 | void drc_decode(drc_info *drc, real_t *spec); 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /src/libFaad/drm_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: drm_dec.h,v 1.8 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __DRM_DEC_H__ 32 | #define __DRM_DEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define DRM_PARAMETRIC_STEREO 0 41 | #define DRM_NUM_SA_BANDS 8 42 | #define DRM_NUM_PAN_BANDS 20 43 | #define NUM_OF_LINKS 3 44 | #define NUM_OF_QMF_CHANNELS 64 45 | #define NUM_OF_SUBSAMPLES 30 46 | #define MAX_SA_BAND 46 47 | #define MAX_PAN_BAND 64 48 | #define MAX_DELAY 5 49 | 50 | typedef struct 51 | { 52 | uint8_t drm_ps_data_available; 53 | uint8_t bs_enable_sa; 54 | uint8_t bs_enable_pan; 55 | 56 | uint8_t bs_sa_dt_flag; 57 | uint8_t bs_pan_dt_flag; 58 | 59 | uint8_t g_last_had_sa; 60 | uint8_t g_last_had_pan; 61 | 62 | int8_t bs_sa_data[DRM_NUM_SA_BANDS]; 63 | int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; 64 | 65 | int8_t g_sa_index[DRM_NUM_SA_BANDS]; 66 | int8_t g_pan_index[DRM_NUM_PAN_BANDS]; 67 | int8_t g_prev_sa_index[DRM_NUM_SA_BANDS]; 68 | int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS]; 69 | 70 | int8_t sa_decode_error; 71 | int8_t pan_decode_error; 72 | 73 | int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; 74 | int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS]; 75 | 76 | qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND]; 77 | 78 | complex_t d_buff[2][MAX_SA_BAND]; 79 | complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; 80 | 81 | uint8_t delay_buf_index_ser[NUM_OF_LINKS]; 82 | 83 | real_t prev_nrg[MAX_SA_BAND]; 84 | real_t prev_peakdiff[MAX_SA_BAND]; 85 | real_t peakdecay_fast[MAX_SA_BAND]; 86 | } drm_ps_info; 87 | 88 | 89 | uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); 90 | 91 | drm_ps_info *drm_ps_init(void); 92 | void drm_ps_free(drm_ps_info *ps); 93 | 94 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /src/libFaad/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: error.c,v 1.33 2008/09/19 23:31:39 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "error.h" 33 | 34 | char *err_msg[] = { 35 | "No error", 36 | "Gain control not yet implemented", 37 | "Pulse coding not allowed in short blocks", 38 | "Invalid huffman codebook", 39 | "Scalefactor out of range", 40 | "Unable to find ADTS syncword", 41 | "Channel coupling not yet implemented", 42 | "Channel configuration not allowed in error resilient frame", 43 | "Bit error in error resilient scalefactor decoding", 44 | "Error decoding huffman scalefactor (bitstream error)", 45 | "Error decoding huffman codeword (bitstream error)", 46 | "Non existent huffman codebook number found", 47 | "Invalid number of channels", 48 | "Maximum number of bitstream elements exceeded", 49 | "Input data buffer too small", 50 | "Array index out of range", 51 | "Maximum number of scalefactor bands exceeded", 52 | "Quantised value out of range", 53 | "LTP lag out of range", 54 | "Invalid SBR parameter decoded", 55 | "SBR called without being initialised", 56 | "Unexpected channel configuration change", 57 | "Error in program_config_element", 58 | "First SBR frame is not the same as first AAC frame", 59 | "Unexpected fill element with SBR data", 60 | "Not all elements were provided with SBR data", 61 | "LTP decoding not available", 62 | "Output data buffer too small", 63 | "CRC error in DRM data", 64 | "PNS not allowed in DRM data stream", 65 | "No standard extension payload allowed in DRM", 66 | "PCE shall be the first element in a frame", 67 | "Bitstream value not allowed by specification", 68 | "MAIN prediction not initialised" 69 | }; 70 | 71 | -------------------------------------------------------------------------------- /src/libFaad/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: error.h,v 1.27 2008/09/19 23:31:40 menno Exp $ 29 | **/ 30 | 31 | #ifndef __ERROR_H__ 32 | #define __ERROR_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define NUM_ERROR_MESSAGES 34 39 | extern char *err_msg[]; 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /src/libFaad/faad.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: faad.h,v 1.51 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | /* warn people for update */ 32 | //#pragma message("please update faad2 include filename and function names!") 33 | 34 | /* Backwards compatible link */ 35 | #include "neaacdec.h" 36 | -------------------------------------------------------------------------------- /src/libFaad/filtbank.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: filtbank.h,v 1.27 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __FILTBANK_H__ 32 | #define __FILTBANK_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | fb_info *filter_bank_init(uint16_t frame_len); 40 | void filter_bank_end(fb_info *fb); 41 | 42 | #ifdef LTP_DEC 43 | void filter_bank_ltp(fb_info *fb, 44 | uint8_t window_sequence, 45 | uint8_t window_shape, 46 | uint8_t window_shape_prev, 47 | real_t *in_data, 48 | real_t *out_mdct, 49 | uint8_t object_type, 50 | uint16_t frame_len); 51 | #endif 52 | 53 | void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, 54 | uint8_t window_shape_prev, real_t *freq_in, 55 | real_t *time_out, real_t *overlap, 56 | uint8_t object_type, uint16_t frame_len); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /src/libFaad/huffman.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: huffman.h,v 1.28 2007/11/01 12:33:30 menno Exp $ 29 | **/ 30 | 31 | #ifndef __HUFFMAN_H__ 32 | #define __HUFFMAN_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | int8_t huffman_scale_factor(bitfile *ld); 39 | uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp); 40 | #ifdef ERROR_RESILIENCE 41 | int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /src/libFaad/is.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: is.c,v 1.28 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include "syntax.h" 35 | #include "is.h" 36 | 37 | #ifdef FIXED_POINT 38 | static real_t pow05_table[] = { 39 | COEF_CONST(1.68179283050743), /* 0.5^(-3/4) */ 40 | COEF_CONST(1.41421356237310), /* 0.5^(-2/4) */ 41 | COEF_CONST(1.18920711500272), /* 0.5^(-1/4) */ 42 | COEF_CONST(1.0), /* 0.5^( 0/4) */ 43 | COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */ 44 | COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */ 45 | COEF_CONST(0.59460355750136) /* 0.5^(+3/4) */ 46 | }; 47 | #endif 48 | 49 | void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 50 | uint16_t frame_len) 51 | { 52 | uint8_t g, sfb, b; 53 | uint16_t i; 54 | #ifndef FIXED_POINT 55 | real_t scale; 56 | #else 57 | int32_t exp, frac; 58 | #endif 59 | 60 | uint16_t nshort = frame_len/8; 61 | uint8_t group = 0; 62 | 63 | for (g = 0; g < icsr->num_window_groups; g++) 64 | { 65 | /* Do intensity stereo decoding */ 66 | for (b = 0; b < icsr->window_group_length[g]; b++) 67 | { 68 | for (sfb = 0; sfb < icsr->max_sfb; sfb++) 69 | { 70 | if (is_intensity(icsr, g, sfb)) 71 | { 72 | #ifdef MAIN_DEC 73 | /* For scalefactor bands coded in intensity stereo the 74 | corresponding predictors in the right channel are 75 | switched to "off". 76 | */ 77 | ics->pred.prediction_used[sfb] = 0; 78 | icsr->pred.prediction_used[sfb] = 0; 79 | #endif 80 | 81 | #ifndef FIXED_POINT 82 | scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb])); 83 | #else 84 | exp = icsr->scale_factors[g][sfb] >> 2; 85 | frac = icsr->scale_factors[g][sfb] & 3; 86 | #endif 87 | 88 | /* Scale from left to right channel, 89 | do not touch left channel */ 90 | for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb+1], ics->swb_offset_max); i++) 91 | { 92 | #ifndef FIXED_POINT 93 | r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale); 94 | #else 95 | if (exp < 0) 96 | r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] << -exp; 97 | else 98 | r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] >> exp; 99 | r_spec[(group*nshort)+i] = MUL_C(r_spec[(group*nshort)+i], pow05_table[frac + 3]); 100 | #endif 101 | if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) 102 | r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i]; 103 | } 104 | } 105 | } 106 | group++; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/libFaad/is.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: is.h,v 1.20 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __IS_H__ 32 | #define __IS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 41 | uint16_t frame_len); 42 | 43 | static INLINE int8_t is_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) 44 | { 45 | switch (ics->sfb_cb[group][sfb]) 46 | { 47 | case INTENSITY_HCB: 48 | return 1; 49 | case INTENSITY_HCB2: 50 | return -1; 51 | default: 52 | return 0; 53 | } 54 | } 55 | 56 | static INLINE int8_t invert_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) 57 | { 58 | if (ics->ms_mask_present == 1) 59 | return (1-2*ics->ms_used[group][sfb]); 60 | return 1; 61 | } 62 | 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /src/libFaad/lt_predict.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: lt_predict.c,v 1.27 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | 32 | #include "common.h" 33 | #include "structs.h" 34 | 35 | #ifdef LTP_DEC 36 | 37 | #include 38 | #include "syntax.h" 39 | #include "lt_predict.h" 40 | #include "filtbank.h" 41 | #include "tns.h" 42 | 43 | 44 | /* static function declarations */ 45 | static int16_t real_to_int16(real_t sig_in); 46 | 47 | 48 | /* check if the object type is an object type that can have LTP */ 49 | uint8_t is_ltp_ot(uint8_t object_type) 50 | { 51 | #ifdef LTP_DEC 52 | if ((object_type == LTP) 53 | #ifdef ERROR_RESILIENCE 54 | || (object_type == ER_LTP) 55 | #endif 56 | #ifdef LD_DEC 57 | || (object_type == LD) 58 | #endif 59 | ) 60 | { 61 | return 1; 62 | } 63 | #endif 64 | 65 | return 0; 66 | } 67 | 68 | ALIGN static const real_t codebook[8] = 69 | { 70 | REAL_CONST(0.570829), 71 | REAL_CONST(0.696616), 72 | REAL_CONST(0.813004), 73 | REAL_CONST(0.911304), 74 | REAL_CONST(0.984900), 75 | REAL_CONST(1.067894), 76 | REAL_CONST(1.194601), 77 | REAL_CONST(1.369533) 78 | }; 79 | 80 | void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, 81 | int16_t *lt_pred_stat, fb_info *fb, uint8_t win_shape, 82 | uint8_t win_shape_prev, uint8_t sr_index, 83 | uint8_t object_type, uint16_t frame_len) 84 | { 85 | uint8_t sfb; 86 | uint16_t bin, i, num_samples; 87 | ALIGN real_t x_est[2048]; 88 | ALIGN real_t X_est[2048]; 89 | 90 | if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) 91 | { 92 | if (ltp->data_present) 93 | { 94 | num_samples = frame_len << 1; 95 | 96 | for(i = 0; i < num_samples; i++) 97 | { 98 | /* The extra lookback M (N/2 for LD, 0 for LTP) is handled 99 | in the buffer updating */ 100 | 101 | #if 0 102 | x_est[i] = MUL_R_C(lt_pred_stat[num_samples + i - ltp->lag], 103 | codebook[ltp->coef]); 104 | #else 105 | /* lt_pred_stat is a 16 bit int, multiplied with the fixed point real 106 | this gives a real for x_est 107 | */ 108 | x_est[i] = (real_t)lt_pred_stat[num_samples + i - ltp->lag] * codebook[ltp->coef]; 109 | #endif 110 | } 111 | 112 | filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev, 113 | x_est, X_est, object_type, frame_len); 114 | 115 | tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est, 116 | frame_len); 117 | 118 | for (sfb = 0; sfb < ltp->last_band; sfb++) 119 | { 120 | if (ltp->long_used[sfb]) 121 | { 122 | uint16_t low = ics->swb_offset[sfb]; 123 | uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); 124 | 125 | for (bin = low; bin < high; bin++) 126 | { 127 | spec[bin] += X_est[bin]; 128 | } 129 | } 130 | } 131 | } 132 | } 133 | } 134 | 135 | #ifdef FIXED_POINT 136 | static INLINE int16_t real_to_int16(real_t sig_in) 137 | { 138 | if (sig_in >= 0) 139 | { 140 | sig_in += (1 << (REAL_BITS-1)); 141 | if (sig_in >= REAL_CONST(32768)) 142 | return 32767; 143 | } else { 144 | sig_in += -(1 << (REAL_BITS-1)); 145 | if (sig_in <= REAL_CONST(-32768)) 146 | return -32768; 147 | } 148 | 149 | return (sig_in >> REAL_BITS); 150 | } 151 | #else 152 | static INLINE int16_t real_to_int16(real_t sig_in) 153 | { 154 | if (sig_in >= 0) 155 | { 156 | #ifndef HAS_LRINTF 157 | sig_in += 0.5f; 158 | #endif 159 | if (sig_in >= 32768.0f) 160 | return 32767; 161 | } else { 162 | #ifndef HAS_LRINTF 163 | sig_in += -0.5f; 164 | #endif 165 | if (sig_in <= -32768.0f) 166 | return -32768; 167 | } 168 | 169 | return lrintf(sig_in); 170 | } 171 | #endif 172 | 173 | void lt_update_state(int16_t *lt_pred_stat, real_t *time, real_t *overlap, 174 | uint16_t frame_len, uint8_t object_type) 175 | { 176 | uint16_t i; 177 | 178 | /* 179 | * The reference point for index i and the content of the buffer 180 | * lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the 181 | * last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1) 182 | * is always all zeros. The rest of lt_pred_stat (i<0) contains the previous 183 | * fully reconstructed time domain samples, i.e., output of the decoder. 184 | * 185 | * These values are shifted up by N*2 to avoid (i<0) 186 | * 187 | * For the LD object type an extra 512 samples lookback is accomodated here. 188 | */ 189 | #ifdef LD_DEC 190 | if (object_type == LD) 191 | { 192 | for (i = 0; i < frame_len; i++) 193 | { 194 | lt_pred_stat[i] /* extra 512 */ = lt_pred_stat[i + frame_len]; 195 | lt_pred_stat[frame_len + i] = lt_pred_stat[i + (frame_len * 2)]; 196 | lt_pred_stat[(frame_len * 2) + i] = real_to_int16(time[i]); 197 | lt_pred_stat[(frame_len * 3) + i] = real_to_int16(overlap[i]); 198 | } 199 | } else { 200 | #endif 201 | for (i = 0; i < frame_len; i++) 202 | { 203 | lt_pred_stat[i] = lt_pred_stat[i + frame_len]; 204 | lt_pred_stat[frame_len + i] = real_to_int16(time[i]); 205 | lt_pred_stat[(frame_len * 2) + i] = real_to_int16(overlap[i]); 206 | #if 0 /* set to zero once upon initialisation */ 207 | lt_pred_stat[(frame_len * 3) + i] = 0; 208 | #endif 209 | } 210 | #ifdef LD_DEC 211 | } 212 | #endif 213 | } 214 | 215 | #endif 216 | -------------------------------------------------------------------------------- /src/libFaad/lt_predict.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: lt_predict.h,v 1.20 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifdef LTP_DEC 32 | 33 | #ifndef __LT_PREDICT_H__ 34 | #define __LT_PREDICT_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include "filtbank.h" 41 | 42 | uint8_t is_ltp_ot(uint8_t object_type); 43 | 44 | void lt_prediction(ic_stream *ics, 45 | ltp_info *ltp, 46 | real_t *spec, 47 | int16_t *lt_pred_stat, 48 | fb_info *fb, 49 | uint8_t win_shape, 50 | uint8_t win_shape_prev, 51 | uint8_t sr_index, 52 | uint8_t object_type, 53 | uint16_t frame_len); 54 | 55 | void lt_update_state(int16_t *lt_pred_stat, 56 | real_t *time, 57 | real_t *overlap, 58 | uint16_t frame_len, 59 | uint8_t object_type); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/libFaad/mdct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/src/libFaad/mdct.c -------------------------------------------------------------------------------- /src/libFaad/mdct.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mdct.h,v 1.30 2007/11/01 12:33:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MDCT_H__ 32 | #define __MDCT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | mdct_info *faad_mdct_init(uint16_t N); 40 | void faad_mdct_end(mdct_info *mdct); 41 | void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out); 42 | void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out); 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /src/libFaad/mp4.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mp4.h,v 1.28 2009/02/05 00:51:03 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MP4_H__ 32 | #define __MP4_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "neaacdec.h" 39 | 40 | int8_t AudioSpecificConfig2(uint8_t *pBuffer, 41 | uint32_t buffer_size, 42 | mp4AudioSpecificConfig *mp4ASC, 43 | program_config *pce, uint8_t short_form); 44 | 45 | int8_t AudioSpecificConfigFromBitfile(bitfile *ld, 46 | mp4AudioSpecificConfig *mp4ASC, 47 | program_config *pce, uint32_t bsize, uint8_t short_form); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /src/libFaad/ms.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ms.c,v 1.21 2007/11/01 12:33:32 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #include "syntax.h" 35 | #include "ms.h" 36 | #include "is.h" 37 | #include "pns.h" 38 | 39 | void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 40 | uint16_t frame_len) 41 | { 42 | uint8_t g, b, sfb; 43 | uint8_t group = 0; 44 | uint16_t nshort = frame_len/8; 45 | 46 | uint16_t i, k; 47 | real_t tmp; 48 | 49 | if (ics->ms_mask_present >= 1) 50 | { 51 | for (g = 0; g < ics->num_window_groups; g++) 52 | { 53 | for (b = 0; b < ics->window_group_length[g]; b++) 54 | { 55 | for (sfb = 0; sfb < ics->max_sfb; sfb++) 56 | { 57 | /* If intensity stereo coding or noise substitution is on 58 | for a particular scalefactor band, no M/S stereo decoding 59 | is carried out. 60 | */ 61 | if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && 62 | !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) 63 | { 64 | for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb+1], ics->swb_offset_max); i++) 65 | { 66 | k = (group*nshort) + i; 67 | tmp = l_spec[k] - r_spec[k]; 68 | l_spec[k] = l_spec[k] + r_spec[k]; 69 | r_spec[k] = tmp; 70 | } 71 | } 72 | } 73 | group++; 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/libFaad/ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ms.h,v 1.19 2007/11/01 12:33:32 menno Exp $ 29 | **/ 30 | 31 | #ifndef __MS_H__ 32 | #define __MS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, 39 | uint16_t frame_len); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /src/libFaad/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: output.h,v 1.26 2009/01/26 23:51:15 menno Exp $ 29 | **/ 30 | 31 | #ifndef __OUTPUT_H__ 32 | #define __OUTPUT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void* output_to_PCM(NeAACDecStruct *hDecoder, 39 | real_t **input, 40 | void *samplebuffer, 41 | uint8_t channels, 42 | uint16_t frame_len, 43 | uint8_t format); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /src/libFaad/pns.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pns.h,v 1.27 2007/11/01 12:33:33 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PNS_H__ 32 | #define __PNS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | #define NOISE_OFFSET 90 41 | 42 | void pns_decode(ic_stream *ics_left, ic_stream *ics_right, 43 | real_t *spec_left, real_t *spec_right, uint16_t frame_len, 44 | uint8_t channel_pair, uint8_t object_type, 45 | /* RNG states */ uint32_t *__r1, uint32_t *__r2); 46 | 47 | static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) 48 | { 49 | if (ics->sfb_cb[group][sfb] == NOISE_HCB) 50 | return 1; 51 | return 0; 52 | } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif 58 | -------------------------------------------------------------------------------- /src/libFaad/ps_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ps_dec.h,v 1.13 2009/01/26 22:32:31 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PS_DEC_H__ 32 | #define __PS_DEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define EXTENSION_ID_PS 2 41 | 42 | #define MAX_PS_ENVELOPES 5 43 | #define NO_ALLPASS_LINKS 3 44 | 45 | typedef struct 46 | { 47 | /* bitstream parameters */ 48 | uint8_t enable_iid; 49 | uint8_t enable_icc; 50 | uint8_t enable_ext; 51 | 52 | uint8_t iid_mode; 53 | uint8_t icc_mode; 54 | uint8_t nr_iid_par; 55 | uint8_t nr_ipdopd_par; 56 | uint8_t nr_icc_par; 57 | 58 | uint8_t frame_class; 59 | uint8_t num_env; 60 | 61 | uint8_t border_position[MAX_PS_ENVELOPES+1]; 62 | 63 | uint8_t iid_dt[MAX_PS_ENVELOPES]; 64 | uint8_t icc_dt[MAX_PS_ENVELOPES]; 65 | 66 | uint8_t enable_ipdopd; 67 | uint8_t ipd_mode; 68 | uint8_t ipd_dt[MAX_PS_ENVELOPES]; 69 | uint8_t opd_dt[MAX_PS_ENVELOPES]; 70 | 71 | /* indices */ 72 | int8_t iid_index_prev[34]; 73 | int8_t icc_index_prev[34]; 74 | int8_t ipd_index_prev[17]; 75 | int8_t opd_index_prev[17]; 76 | int8_t iid_index[MAX_PS_ENVELOPES][34]; 77 | int8_t icc_index[MAX_PS_ENVELOPES][34]; 78 | int8_t ipd_index[MAX_PS_ENVELOPES][17]; 79 | int8_t opd_index[MAX_PS_ENVELOPES][17]; 80 | 81 | int8_t ipd_index_1[17]; 82 | int8_t opd_index_1[17]; 83 | int8_t ipd_index_2[17]; 84 | int8_t opd_index_2[17]; 85 | 86 | /* ps data was correctly read */ 87 | uint8_t ps_data_available; 88 | 89 | /* a header has been read */ 90 | uint8_t header_read; 91 | 92 | /* hybrid filterbank parameters */ 93 | void *hyb; 94 | uint8_t use34hybrid_bands; 95 | uint8_t numTimeSlotsRate; 96 | 97 | /**/ 98 | uint8_t num_groups; 99 | uint8_t num_hybrid_groups; 100 | uint8_t nr_par_bands; 101 | uint8_t nr_allpass_bands; 102 | uint8_t decay_cutoff; 103 | 104 | uint8_t *group_border; 105 | uint16_t *map_group2bk; 106 | 107 | /* filter delay handling */ 108 | uint8_t saved_delay; 109 | uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS]; 110 | uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS]; 111 | uint8_t delay_D[64]; 112 | uint8_t delay_buf_index_delay[64]; 113 | 114 | complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */ 115 | complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */ 116 | complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */ 117 | complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */ 118 | 119 | /* transients */ 120 | real_t alpha_decay; 121 | real_t alpha_smooth; 122 | 123 | real_t P_PeakDecayNrg[34]; 124 | real_t P_prev[34]; 125 | real_t P_SmoothPeakDecayDiffNrg_prev[34]; 126 | 127 | /* mixing and phase */ 128 | complex_t h11_prev[50]; 129 | complex_t h12_prev[50]; 130 | complex_t h21_prev[50]; 131 | complex_t h22_prev[50]; 132 | uint8_t phase_hist; 133 | complex_t ipd_prev[20][2]; 134 | complex_t opd_prev[20][2]; 135 | 136 | } ps_info; 137 | 138 | /* ps_syntax.c */ 139 | uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); 140 | 141 | /* ps_dec.c */ 142 | ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate); 143 | void ps_free(ps_info *ps); 144 | 145 | uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]); 146 | 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | #endif 152 | 153 | -------------------------------------------------------------------------------- /src/libFaad/pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pulse.c,v 1.21 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | #include "common.h" 31 | #include "structs.h" 32 | 33 | #include "syntax.h" 34 | #include "pulse.h" 35 | 36 | uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) 37 | { 38 | uint8_t i; 39 | uint16_t k; 40 | pulse_info *pul = &(ics->pul); 41 | 42 | k = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max); 43 | 44 | for (i = 0; i <= pul->number_pulse; i++) 45 | { 46 | k += pul->pulse_offset[i]; 47 | 48 | if (k >= framelen) 49 | return 15; /* should not be possible */ 50 | 51 | if (spec_data[k] > 0) 52 | spec_data[k] += pul->pulse_amp[i]; 53 | else 54 | spec_data[k] -= pul->pulse_amp[i]; 55 | } 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /src/libFaad/pulse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: pulse.h,v 1.20 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __PULSE_H__ 32 | #define __PULSE_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif 44 | -------------------------------------------------------------------------------- /src/libFaad/rvlc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: rvlc.h,v 1.17 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __RVLC_SCF_H__ 32 | #define __RVLC_SCF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | int8_t index; 41 | uint8_t len; 42 | uint32_t cw; 43 | } rvlc_huff_table; 44 | 45 | 46 | #define ESC_VAL 7 47 | 48 | 49 | uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld); 50 | uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /src/libFaad/sbr_dct.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_dct.h,v 1.19 2007/11/01 12:33:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_DCT_H__ 32 | #define __SBR_DCT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag); 39 | 40 | void DCT3_32_unscaled(real_t *y, real_t *x); 41 | void DCT4_32(real_t *y, real_t *x); 42 | void DST4_32(real_t *y, real_t *x); 43 | void DCT2_32_unscaled(real_t *y, real_t *x); 44 | void DCT4_16(real_t *y, real_t *x); 45 | void DCT2_16_unscaled(real_t *y, real_t *x); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/libFaad/sbr_e_nf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_E_NF_H__ 32 | #define __SBR_E_NF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | void extract_envelope_data(sbr_info *sbr, uint8_t ch); 40 | void extract_noise_floor_data(sbr_info *sbr, uint8_t ch); 41 | #ifndef FIXED_POINT 42 | void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch); 43 | void unmap_envelope_noise(sbr_info *sbr); 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/libFaad/sbr_fbt.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_FBT_H__ 32 | #define __SBR_FBT_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, 39 | uint32_t sample_rate); 40 | uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, 41 | uint8_t k0); 42 | uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, 43 | uint8_t bs_alter_scale); 44 | uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, 45 | uint8_t bs_freq_scale, uint8_t bs_alter_scale); 46 | uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, 47 | uint8_t k2); 48 | void limiter_frequency_table(sbr_info *sbr); 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /src/libFaad/sbr_hfadj.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HFADJ_H__ 32 | #define __SBR_HFADJ_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct 39 | { 40 | real_t G_lim_boost[MAX_L_E][MAX_M]; 41 | real_t Q_M_lim_boost[MAX_L_E][MAX_M]; 42 | real_t S_M_boost[MAX_L_E][MAX_M]; 43 | } sbr_hfadj_info; 44 | 45 | 46 | uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] 47 | #ifdef SBR_LOW_POWER 48 | ,real_t *deg 49 | #endif 50 | ,uint8_t ch); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/libFaad/sbr_hfgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HFGEN_H__ 32 | #define __SBR_HFGEN_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], 39 | qmf_t Xhigh[MAX_NTSRHFG][64] 40 | #ifdef SBR_LOW_POWER 41 | ,real_t *deg 42 | #endif 43 | ,uint8_t ch); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/libFaad/sbr_huff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_huff.h,v 1.21 2007/11/01 12:33:35 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_HUFF_H__ 32 | #define __SBR_HUFF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch); 40 | void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /src/libFaad/sbr_qmf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_qmf.h,v 1.25 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_QMF_H__ 32 | #define __SBR_QMF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | qmfa_info *qmfa_init(uint8_t channels); 39 | void qmfa_end(qmfa_info *qmfa); 40 | qmfs_info *qmfs_init(uint8_t channels); 41 | void qmfs_end(qmfs_info *qmfs); 42 | 43 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, 44 | qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx); 45 | void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 46 | real_t *output); 47 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 48 | real_t *output); 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /src/libFaad/sbr_syntax.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_syntax.h,v 1.23 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_SYNTAX_H__ 32 | #define __SBR_SYNTAX_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define T_HFGEN 8 41 | #define T_HFADJ 2 42 | 43 | #define EXT_SBR_DATA 13 44 | #define EXT_SBR_DATA_CRC 14 45 | 46 | #define FIXFIX 0 47 | #define FIXVAR 1 48 | #define VARFIX 2 49 | #define VARVAR 3 50 | 51 | #define LO_RES 0 52 | #define HI_RES 1 53 | 54 | #define NO_TIME_SLOTS_960 15 55 | #define NO_TIME_SLOTS 16 56 | #define RATE 2 57 | 58 | #define NOISE_FLOOR_OFFSET 6 59 | 60 | 61 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt, 62 | uint8_t resetFlag); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif /* __SBR_SYNTAX_H__ */ 68 | 69 | -------------------------------------------------------------------------------- /src/libFaad/sbr_tf_grid.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: sbr_tf_grid.h,v 1.17 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SBR_TF_GRID_H__ 32 | #define __SBR_TF_GRID_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch); 40 | void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /src/libFaad/specrec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: specrec.h,v 1.33 2009/01/26 23:51:15 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SPECREC_H__ 32 | #define __SPECREC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "syntax.h" 39 | 40 | uint8_t window_grouping_info(NeAACDecStruct *hDecoder, ic_stream *ics); 41 | uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_stream *ics2, 42 | element *cpe, int16_t *spec_data1, int16_t *spec_data2); 43 | uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics, element *sce, 44 | int16_t *spec_data); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /src/libFaad/ssr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr.c,v 1.19 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #ifdef SSR_DEC 35 | 36 | #include "syntax.h" 37 | #include "filtbank.h" 38 | #include "ssr.h" 39 | #include "ssr_fb.h" 40 | 41 | void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, 42 | uint8_t window_shape, uint8_t window_shape_prev, 43 | real_t *freq_in, real_t *time_out, real_t *overlap, 44 | real_t ipqf_buffer[SSR_BANDS][96/4], 45 | real_t *prev_fmd, uint16_t frame_len) 46 | { 47 | uint8_t band; 48 | uint16_t ssr_frame_len = frame_len/SSR_BANDS; 49 | real_t time_tmp[2048] = {0}; 50 | real_t output[1024] = {0}; 51 | 52 | for (band = 0; band < SSR_BANDS; band++) 53 | { 54 | int16_t j; 55 | 56 | /* uneven bands have inverted frequency scale */ 57 | if (band == 1 || band == 3) 58 | { 59 | for (j = 0; j < ssr_frame_len/2; j++) 60 | { 61 | real_t tmp; 62 | tmp = freq_in[j + ssr_frame_len*band]; 63 | freq_in[j + ssr_frame_len*band] = 64 | freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band]; 65 | freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band] = tmp; 66 | } 67 | } 68 | 69 | /* non-overlapping inverse filterbank for SSR */ 70 | ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev, 71 | freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len, 72 | ssr_frame_len); 73 | 74 | /* gain control */ 75 | ssr_gain_control(ssr, time_tmp, output, overlap, prev_fmd, 76 | band, window_sequence, ssr_frame_len); 77 | } 78 | 79 | /* inverse pqf to bring subbands together again */ 80 | ssr_ipqf(ssr, output, time_out, ipqf_buffer, frame_len, SSR_BANDS); 81 | } 82 | 83 | static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, 84 | real_t *overlap, real_t *prev_fmd, uint8_t band, 85 | uint8_t window_sequence, uint16_t frame_len) 86 | { 87 | uint16_t i; 88 | real_t gc_function[2*1024/SSR_BANDS]; 89 | 90 | if (window_sequence != EIGHT_SHORT_SEQUENCE) 91 | { 92 | ssr_gc_function(ssr, &prev_fmd[band * frame_len*2], 93 | gc_function, window_sequence, band, frame_len); 94 | 95 | for (i = 0; i < frame_len*2; i++) 96 | data[band * frame_len*2 + i] *= gc_function[i]; 97 | for (i = 0; i < frame_len; i++) 98 | { 99 | output[band*frame_len + i] = overlap[band*frame_len + i] + 100 | data[band*frame_len*2 + i]; 101 | } 102 | for (i = 0; i < frame_len; i++) 103 | { 104 | overlap[band*frame_len + i] = 105 | data[band*frame_len*2 + frame_len + i]; 106 | } 107 | } else { 108 | uint8_t w; 109 | for (w = 0; w < 8; w++) 110 | { 111 | uint16_t frame_len8 = frame_len/8; 112 | uint16_t frame_len16 = frame_len/16; 113 | 114 | ssr_gc_function(ssr, &prev_fmd[band*frame_len*2 + w*frame_len*2/8], 115 | gc_function, window_sequence, frame_len); 116 | 117 | for (i = 0; i < frame_len8*2; i++) 118 | data[band*frame_len*2 + w*frame_len8*2+i] *= gc_function[i]; 119 | for (i = 0; i < frame_len8; i++) 120 | { 121 | overlap[band*frame_len + i + 7*frame_len16 + w*frame_len8] += 122 | data[band*frame_len*2 + 2*w*frame_len8 + i]; 123 | } 124 | for (i = 0; i < frame_len8; i++) 125 | { 126 | overlap[band*frame_len + i + 7*frame_len16 + (w+1)*frame_len8] = 127 | data[band*frame_len*2 + 2*w*frame_len8 + frame_len8 + i]; 128 | } 129 | } 130 | for (i = 0; i < frame_len; i++) 131 | output[band*frame_len + i] = overlap[band*frame_len + i]; 132 | for (i = 0; i < frame_len; i++) 133 | overlap[band*frame_len + i] = overlap[band*frame_len + i + frame_len]; 134 | } 135 | } 136 | 137 | static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, 138 | real_t *gc_function, uint8_t window_sequence, 139 | uint8_t band, uint16_t frame_len) 140 | { 141 | uint16_t i; 142 | uint16_t len_area1, len_area2; 143 | int32_t aloc[10]; 144 | real_t alev[10]; 145 | 146 | switch (window_sequence) 147 | { 148 | case ONLY_LONG_SEQUENCE: 149 | len_area1 = frame_len/SSR_BANDS; 150 | len_area2 = 0; 151 | break; 152 | case LONG_START_SEQUENCE: 153 | len_area1 = (frame_len/SSR_BANDS)*7/32; 154 | len_area2 = (frame_len/SSR_BANDS)/16; 155 | break; 156 | case EIGHT_SHORT_SEQUENCE: 157 | len_area1 = (frame_len/8)/SSR_BANDS; 158 | len_area2 = 0; 159 | break; 160 | case LONG_STOP_SEQUENCE: 161 | len_area1 = (frame_len/SSR_BANDS); 162 | len_area2 = 0; 163 | break; 164 | } 165 | 166 | /* decode bitstream information */ 167 | 168 | /* build array M */ 169 | 170 | 171 | for (i = 0; i < frame_len*2; i++) 172 | gc_function[i] = 1; 173 | } 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /src/libFaad/ssr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr.h,v 1.19 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_H__ 32 | #define __SSR_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #define SSR_BANDS 4 39 | #define PQFTAPS 96 40 | 41 | void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, 42 | uint8_t window_shape, uint8_t window_shape_prev, 43 | real_t *freq_in, real_t *time_out, real_t *overlap, 44 | real_t ipqf_buffer[SSR_BANDS][96/4], 45 | real_t *prev_fmd, uint16_t frame_len); 46 | 47 | 48 | static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output, 49 | real_t *overlap, real_t *prev_fmd, uint8_t band, 50 | uint8_t window_sequence, uint16_t frame_len); 51 | static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd, 52 | real_t *gc_function, uint8_t window_sequence, 53 | uint16_t frame_len); 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif 60 | -------------------------------------------------------------------------------- /src/libFaad/ssr_fb.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_fb.h,v 1.16 2007/11/01 12:33:36 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_FB_H__ 32 | #define __SSR_FB_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | fb_info *ssr_filter_bank_init(uint16_t frame_len); 39 | void ssr_filter_bank_end(fb_info *fb); 40 | 41 | /*non overlapping inverse filterbank */ 42 | void ssr_ifilter_bank(fb_info *fb, 43 | uint8_t window_sequence, 44 | uint8_t window_shape, 45 | uint8_t window_shape_prev, 46 | real_t *freq_in, 47 | real_t *time_out, 48 | uint16_t frame_len); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /src/libFaad/ssr_ipqf.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_ipqf.c,v 1.18 2007/11/01 12:33:39 menno Exp $ 29 | **/ 30 | 31 | #include "common.h" 32 | #include "structs.h" 33 | 34 | #ifdef SSR_DEC 35 | 36 | #include "ssr.h" 37 | #include "ssr_ipqf.h" 38 | 39 | static real_t **app_pqfbuf; 40 | static real_t **pp_q0, **pp_t0, **pp_t1; 41 | 42 | void gc_set_protopqf(real_t *p_proto) 43 | { 44 | int j; 45 | static real_t a_half[48] = 46 | { 47 | 1.2206911375946939E-05, 1.7261986723798209E-05, 1.2300093657077942E-05, 48 | -1.0833943097791965E-05, -5.7772498639901686E-05, -1.2764767618947719E-04, 49 | -2.0965186675013334E-04, -2.8166673689263850E-04, -3.1234860429017460E-04, 50 | -2.6738519958452353E-04, -1.1949424681824722E-04, 1.3965139412648678E-04, 51 | 4.8864136409185725E-04, 8.7044629275148344E-04, 1.1949430269934793E-03, 52 | 1.3519708175026700E-03, 1.2346314373964412E-03, 7.6953209114159191E-04, 53 | -5.2242432579537141E-05, -1.1516092887213454E-03, -2.3538469841711277E-03, 54 | -3.4033123072127277E-03, -4.0028551071986133E-03, -3.8745415659693259E-03, 55 | -2.8321073426874310E-03, -8.5038892323704195E-04, 1.8856751185350931E-03, 56 | 4.9688741735340923E-03, 7.8056704536795926E-03, 9.7027909685901654E-03, 57 | 9.9960423120166159E-03, 8.2019366335594487E-03, 4.1642072876103365E-03, 58 | -1.8364453822737758E-03, -9.0384863094167686E-03, -1.6241528177129844E-02, 59 | -2.1939551286300665E-02, -2.4533179947088161E-02, -2.2591663337768787E-02, 60 | -1.5122066420044672E-02, -1.7971713448186293E-03, 1.6903413428575379E-02, 61 | 3.9672315874127042E-02, 6.4487527248102796E-02, 8.8850025474701726E-02, 62 | 0.1101132906105560 , 0.1258540205143761 , 0.1342239368467012 63 | }; 64 | 65 | for (j = 0; j < 48; ++j) 66 | { 67 | p_proto[j] = p_proto[95-j] = a_half[j]; 68 | } 69 | } 70 | 71 | void gc_setcoef_eff_pqfsyn(int mm, 72 | int kk, 73 | real_t *p_proto, 74 | real_t ***ppp_q0, 75 | real_t ***ppp_t0, 76 | real_t ***ppp_t1) 77 | { 78 | int i, k, n; 79 | real_t w; 80 | 81 | /* Set 1st Mul&Acc Coef's */ 82 | *ppp_q0 = (real_t **) calloc(mm, sizeof(real_t *)); 83 | for (n = 0; n < mm; ++n) 84 | { 85 | (*ppp_q0)[n] = (real_t *) calloc(mm, sizeof(real_t)); 86 | } 87 | for (n = 0; n < mm/2; ++n) 88 | { 89 | for (i = 0; i < mm; ++i) 90 | { 91 | w = (2*i+1)*(2*n+1-mm)*M_PI/(4*mm); 92 | (*ppp_q0)[n][i] = 2.0 * cos((real_t) w); 93 | 94 | w = (2*i+1)*(2*(mm+n)+1-mm)*M_PI/(4*mm); 95 | (*ppp_q0)[n + mm/2][i] = 2.0 * cos((real_t) w); 96 | } 97 | } 98 | 99 | /* Set 2nd Mul&Acc Coef's */ 100 | *ppp_t0 = (real_t **) calloc(mm, sizeof(real_t *)); 101 | *ppp_t1 = (real_t **) calloc(mm, sizeof(real_t *)); 102 | for (n = 0; n < mm; ++n) 103 | { 104 | (*ppp_t0)[n] = (real_t *) calloc(kk, sizeof(real_t)); 105 | (*ppp_t1)[n] = (real_t *) calloc(kk, sizeof(real_t)); 106 | } 107 | for (n = 0; n < mm; ++n) 108 | { 109 | for (k = 0; k < kk; ++k) 110 | { 111 | (*ppp_t0)[n][k] = mm * p_proto[2*k *mm + n]; 112 | (*ppp_t1)[n][k] = mm * p_proto[(2*k+1)*mm + n]; 113 | 114 | if (k%2 != 0) 115 | { 116 | (*ppp_t0)[n][k] = -(*ppp_t0)[n][k]; 117 | (*ppp_t1)[n][k] = -(*ppp_t1)[n][k]; 118 | } 119 | } 120 | } 121 | } 122 | 123 | void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data, 124 | real_t buffer[SSR_BANDS][96/4], 125 | uint16_t frame_len, uint8_t bands) 126 | { 127 | static int initFlag = 0; 128 | real_t a_pqfproto[PQFTAPS]; 129 | 130 | int i; 131 | 132 | if (initFlag == 0) 133 | { 134 | gc_set_protopqf(a_pqfproto); 135 | gc_setcoef_eff_pqfsyn(SSR_BANDS, PQFTAPS/(2*SSR_BANDS), a_pqfproto, 136 | &pp_q0, &pp_t0, &pp_t1); 137 | initFlag = 1; 138 | } 139 | 140 | for (i = 0; i < frame_len / SSR_BANDS; i++) 141 | { 142 | int l, n, k; 143 | int mm = SSR_BANDS; 144 | int kk = PQFTAPS/(2*SSR_BANDS); 145 | 146 | for (n = 0; n < mm; n++) 147 | { 148 | for (k = 0; k < 2*kk-1; k++) 149 | { 150 | buffer[n][k] = buffer[n][k+1]; 151 | } 152 | } 153 | 154 | for (n = 0; n < mm; n++) 155 | { 156 | real_t acc = 0.0; 157 | for (l = 0; l < mm; l++) 158 | { 159 | acc += pp_q0[n][l] * in_data[l*frame_len/SSR_BANDS + i]; 160 | } 161 | buffer[n][2*kk-1] = acc; 162 | } 163 | 164 | for (n = 0; n < mm/2; n++) 165 | { 166 | real_t acc = 0.0; 167 | for (k = 0; k < kk; k++) 168 | { 169 | acc += pp_t0[n][k] * buffer[n][2*kk-1-2*k]; 170 | } 171 | for (k = 0; k < kk; ++k) 172 | { 173 | acc += pp_t1[n][k] * buffer[n + mm/2][2*kk-2-2*k]; 174 | } 175 | out_data[i*SSR_BANDS + n] = acc; 176 | 177 | acc = 0.0; 178 | for (k = 0; k < kk; k++) 179 | { 180 | acc += pp_t0[mm-1-n][k] * buffer[n][2*kk-1-2*k]; 181 | } 182 | for (k = 0; k < kk; k++) 183 | { 184 | acc -= pp_t1[mm-1-n][k] * buffer[n + mm/2][2*kk-2-2*k]; 185 | } 186 | out_data[i*SSR_BANDS + mm-1-n] = acc; 187 | } 188 | } 189 | } 190 | 191 | #endif 192 | -------------------------------------------------------------------------------- /src/libFaad/ssr_ipqf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: ssr_ipqf.h,v 1.17 2007/11/01 12:33:39 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SSR_IPQF_H__ 32 | #define __SSR_IPQF_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data, 39 | real_t buffer[SSR_BANDS][96/4], 40 | uint16_t frame_len, uint8_t bands); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /src/libFaad/syntax.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xia-chu/ZLMediaPlayer/814f326e27d9571ad3fc29115eac9263262ae140/src/libFaad/syntax.c -------------------------------------------------------------------------------- /src/libFaad/syntax.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: syntax.h,v 1.60 2009/01/26 23:51:17 menno Exp $ 29 | **/ 30 | 31 | #ifndef __SYNTAX_H__ 32 | #define __SYNTAX_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | #include "bits.h" 39 | 40 | #define MAIN 1 41 | #define LC 2 42 | #define SSR 3 43 | #define LTP 4 44 | #define HE_AAC 5 45 | #define LD 23 46 | #define ER_LC 17 47 | #define ER_LTP 19 48 | #define DRM_ER_LC 27 /* special object type for DRM */ 49 | 50 | /* header types */ 51 | #define RAW 0 52 | #define ADIF 1 53 | #define ADTS 2 54 | #define LATM 3 55 | 56 | /* SBR signalling */ 57 | #define NO_SBR 0 58 | #define SBR_UPSAMPLED 1 59 | #define SBR_DOWNSAMPLED 2 60 | #define NO_SBR_UPSAMPLED 3 61 | 62 | /* DRM channel definitions */ 63 | #define DRMCH_MONO 1 64 | #define DRMCH_STEREO 2 65 | #define DRMCH_SBR_MONO 3 66 | #define DRMCH_SBR_STEREO 4 67 | #define DRMCH_SBR_PS_STEREO 5 68 | 69 | 70 | /* First object type that has ER */ 71 | #define ER_OBJECT_START 17 72 | 73 | 74 | /* Bitstream */ 75 | #define LEN_SE_ID 3 76 | #define LEN_TAG 4 77 | #define LEN_BYTE 8 78 | 79 | #define EXT_FIL 0 80 | #define EXT_FILL_DATA 1 81 | #define EXT_DATA_ELEMENT 2 82 | #define EXT_DYNAMIC_RANGE 11 83 | #define ANC_DATA 0 84 | 85 | /* Syntax elements */ 86 | #define ID_SCE 0x0 87 | #define ID_CPE 0x1 88 | #define ID_CCE 0x2 89 | #define ID_LFE 0x3 90 | #define ID_DSE 0x4 91 | #define ID_PCE 0x5 92 | #define ID_FIL 0x6 93 | #define ID_END 0x7 94 | 95 | #define ONLY_LONG_SEQUENCE 0x0 96 | #define LONG_START_SEQUENCE 0x1 97 | #define EIGHT_SHORT_SEQUENCE 0x2 98 | #define LONG_STOP_SEQUENCE 0x3 99 | 100 | #define ZERO_HCB 0 101 | #define FIRST_PAIR_HCB 5 102 | #define ESC_HCB 11 103 | #define QUAD_LEN 4 104 | #define PAIR_LEN 2 105 | #define NOISE_HCB 13 106 | #define INTENSITY_HCB2 14 107 | #define INTENSITY_HCB 15 108 | 109 | #define INVALID_SBR_ELEMENT 255 110 | 111 | int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, 112 | program_config *pce); 113 | 114 | uint8_t adts_frame(adts_header *adts, bitfile *ld); 115 | void get_adif_header(adif_header *adif, bitfile *ld); 116 | void raw_data_block(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, 117 | bitfile *ld, program_config *pce, drc_info *drc); 118 | uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld, 119 | int16_t *spectral_data); 120 | #ifdef DRM 121 | void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, 122 | bitfile *ld, program_config *pce, drc_info *drc); 123 | #endif 124 | uint32_t faad_latm_frame(latm_header *latm, bitfile *ld); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | #endif 130 | -------------------------------------------------------------------------------- /src/libFaad/tns.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: tns.h,v 1.23 2007/11/01 12:33:41 menno Exp $ 29 | **/ 30 | 31 | #ifndef __TNS_H__ 32 | #define __TNS_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | 39 | #define TNS_MAX_ORDER 20 40 | 41 | 42 | void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, 43 | uint8_t object_type, real_t *spec, uint16_t frame_len); 44 | void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, 45 | uint8_t object_type, real_t *spec, uint16_t frame_len); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /src/test_player.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2017 xiongziliang <771730766@qq.com> 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #include "MediaPlayer/MediaPlayerWrapper.h" 25 | 26 | 27 | #if defined(_WIN32) 28 | #include 29 | #include 30 | 31 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); //¥∞ø⁄∫Ø ˝Àµ√˜ 32 | //------------ ≥ı ºªØ¥∞ø⁄¿‡---------------- 33 | int WINAPI WinMain(HINSTANCE hInstance, //WinMain∫Ø ˝Àµ√˜ 34 | HINSTANCE hPrevInst, 35 | LPSTR lpszCmdLine, 36 | int nCmdShow){ 37 | HWND hwnd; 38 | MSG Msg; 39 | WNDCLASS wndclass; 40 | TCHAR lpszClassName[] = _T("¥∞ø⁄"); //¥∞ø⁄¿‡√˚ 41 | TCHAR lpszTitle[] = _T("My_Windows"); //¥∞ø⁄±ÍÂ√˚ 42 | //¥∞ø⁄¿‡µƒ∂®“ 43 | wndclass.style = 0; //¥∞ø⁄¿‡–ÕŒ™»± °¿‡–Õ 44 | wndclass.lpfnWndProc = WndProc; //¥∞ø⁄¥¶¿Ì∫Ø ˝Œ™WndProc 45 | wndclass.cbClsExtra = 0; //¥∞ø⁄¿‡Œfi¿©’π 46 | wndclass.cbWndExtra = 0; //¥∞ø⁄ µ¿˝Œfi¿©’π 47 | wndclass.hInstance = hInstance; //µ±«∞ µ¿˝æ‰±˙ 48 | wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); 49 | 50 | //¥∞ø⁄µƒ◊Ó–°ªØÕº±ÍŒ™»± °Õº±Í 51 | wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); 52 | //¥∞ø⁄≤…”√º˝Õ∑π‚±Í 53 | wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); 54 | 55 | //¥∞ø⁄±≥æ∞Œ™∞◊…´ 56 | wndclass.lpszMenuName = NULL; //¥∞ø⁄÷–Œfi≤Àµ• 57 | wndclass.lpszClassName = lpszClassName; 58 | //¥∞ø⁄¿‡√˚Œ™"¥∞ø⁄ æ¿˝" 59 | //--------------- ¥∞ø⁄¿‡µƒ◊¢≤· ----------------- 60 | if (!RegisterClass(&wndclass)) //»Áπ˚◊¢≤· ß∞‹‘Ú∑¢≥ˆæØ∏Ê…˘“Ù 61 | { 62 | MessageBeep(0); 63 | return FALSE; 64 | } 65 | 66 | //¥¥Ω®¥∞ø⁄ 67 | hwnd = CreateWindow(lpszClassName, //¥∞ø⁄¿‡√˚ 68 | lpszTitle, //¥∞ø⁄ µ¿˝µƒ±ÍÂ√˚ 69 | WS_OVERLAPPEDWINDOW, //¥∞ø⁄µƒ∑Á∏Ò 70 | CW_USEDEFAULT, 71 | CW_USEDEFAULT, //¥∞ø⁄◊Û…œΩ«◊¯±ÍŒ™»± °÷µ 72 | CW_USEDEFAULT, 73 | CW_USEDEFAULT, //¥∞ø⁄µƒ∏fl∫ÕøÌŒ™»± °÷µ 74 | NULL, //¥À¥∞ø⁄Œfi∏∏¥∞ø⁄ 75 | NULL, //¥À¥∞ø⁄Œfi÷˜≤Àµ• 76 | hInstance, //¥¥Ω®¥À¥∞ø⁄µƒ”¶”√≥Öڵƒµ±«∞扱˙ 77 | NULL); //≤ª π”√∏√÷µ 78 | 79 | MediaPlayerWrapperHelper::globalInitialization(); 80 | MediaPlayerWrapperHelper::Instance().addDelegate("rtmp://live.hkstv.hk.lxdns.com/live/hks", new MediaPlayerWrapperDelegateImp(hwnd)); 81 | MediaPlayerWrapperHelper::Instance().getPlayer("rtmp://live.hkstv.hk.lxdns.com/live/hks")->setPauseAuto(false); 82 | /*MediaPlayerWrapper::Ptr player(new MediaPlayerWrapper()); 83 | player->setOption("rtp_type",1); 84 | player->setPauseAuto(true); 85 | player->addDelegate(new MediaPlayerWrapperDelegateImp(hwnd)); 86 | player->addDelegate(new MediaPlayerWrapperDelegateImp(hwnd1));*/ 87 | 88 | //player->play("rtmp://douyucdn.cn/live/260965rO4IFm4Mat"); 89 | 90 | //player->play("rtmp://live.hkstv.hk.lxdns.com/live/hks"); 91 | //player->play("rtmp://192.168.0.124/live/obs"); 92 | //player->play("rtsp://192.168.0.233/live/test0"); 93 | //player->play("rtsp://192.168.0.124/record/live/obs/2017-08-16/11-21-47.mp4"); 94 | //player->play("rtsp://admin:jzan123456@192.168.0.122/live/test0"); 95 | 96 | //œ‘ æ¥∞ø⁄ 97 | ShowWindow(hwnd, nCmdShow); 98 | //ªÊ÷∆”√ªß«¯ 99 | UpdateWindow(hwnd); 100 | 101 | //œ˚œ¢—≠ª∑ 102 | while (GetMessage(&Msg, NULL, 0, 0)){ 103 | TranslateMessage(&Msg); 104 | DispatchMessage(&Msg); 105 | //MediaPlayerWrapperHelper::Instance().getPlayer("rtsp://192.168.0.233/live/test0")->reDraw(); 106 | } 107 | 108 | MediaPlayerWrapperHelper::globalUninitialization(); 109 | return Msg.wParam; //œ˚œ¢—≠ª∑Ω· ¯º¥≥ÖÚ÷’÷π ±Ω´–≈œ¢∑µªÿœµÕ≥ 110 | } 111 | 112 | 113 | //¥∞ø⁄∫Ø ˝ 114 | LRESULT CALLBACK WndProc(HWND hwnd, 115 | UINT message, 116 | WPARAM wParam, 117 | LPARAM lParam) 118 | { 119 | switch (message) { 120 | case WM_DESTROY: 121 | PostQuitMessage(0); //µ˜”√PostQuitMessage∑¢≥ˆWM_QUITœ˚œ¢ 122 | default: //»± ° ±≤…”√œµÕ≥œ˚œ¢»± °¥¶¿Ì∫Ø ˝ 123 | return DefWindowProc(hwnd, message, wParam, lParam); 124 | } 125 | return (0); 126 | } 127 | #else 128 | #include 129 | #include 130 | int main(int argc,char *argv[]){ 131 | //监听SIGINT信号,在按下 Ctrl + C后将调用stopSdlLoop方法通知runSdlLoop函数退出 132 | signal(SIGINT, [](int) { MediaPlayerWrapperHelper::stopSdlLoop();}); 133 | 134 | //初始化基础网络库 135 | MediaPlayerWrapperHelper::globalInitialization(); 136 | 137 | 138 | for(int i = 1 ;i < argc ; i++){ 139 | //添加播放器实例,你可以这么执行本程序: ./test_player rtmp://127.0.0.1/live/0 rtsp://127.0.0.1/live/0 ... 140 | MediaPlayerWrapperHelper::Instance().addDelegate(argv[i], new MediaPlayerWrapperDelegateImp(nullptr)); 141 | MediaPlayerWrapperHelper::Instance().getPlayer(argv[i])->setPauseAuto(false); 142 | } 143 | 144 | //执行sdl渲染循环线程,该操作将导致此线程阻塞 145 | //在macOS Majove 系统下,sdl渲染线程必须在main函数中执行,否则会黑屏 146 | //windows/linux系统下可以在后台线程执行runSdlLoop 147 | MediaPlayerWrapperHelper::runSdlLoop(); 148 | 149 | //释放基础网络库 150 | MediaPlayerWrapperHelper::globalUninitialization(); 151 | } 152 | 153 | 154 | 155 | 156 | #endif //defined(_WIN32) 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | --------------------------------------------------------------------------------