├── .github └── workflows │ ├── gradle.yml │ └── native_build.yml ├── .gitignore ├── LICENSE ├── README.MD ├── build.gradle ├── cross ├── build.sh └── setup_docker.sh ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── native ├── .gitignore ├── CMakeLists.txt ├── bind │ ├── JNIDecoder.c │ ├── JNIEncoder.c │ ├── coder.c │ └── coder.h ├── interface │ ├── SKP_Silk_SDK_API.h │ ├── SKP_Silk_control.h │ ├── SKP_Silk_errors.h │ └── SKP_Silk_typedef.h ├── jni_include │ ├── inc_linux │ │ ├── jni.h │ │ └── jni_md.h │ ├── inc_mac │ │ ├── jni.h │ │ └── jni_md.h │ └── inc_win │ │ ├── jni.h │ │ └── jni_md.h ├── lame │ ├── CMakeLists.txt │ └── src │ │ ├── JNILame.c │ │ ├── JNILame.h │ │ ├── libmp3lame │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── VbrTag.c │ │ ├── VbrTag.h │ │ ├── bitstream.c │ │ ├── bitstream.h │ │ ├── depcomp │ │ ├── encoder.c │ │ ├── encoder.h │ │ ├── fft.c │ │ ├── fft.h │ │ ├── gain_analysis.c │ │ ├── gain_analysis.h │ │ ├── i386 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── choose_table.nas │ │ │ ├── cpu_feat.nas │ │ │ ├── fft.nas │ │ │ ├── fft3dn.nas │ │ │ ├── fftfpu.nas │ │ │ ├── fftsse.nas │ │ │ ├── ffttbl.nas │ │ │ ├── nasm.h │ │ │ └── scalar.nas │ │ ├── id3tag.c │ │ ├── id3tag.h │ │ ├── l3side.h │ │ ├── lame-analysis.h │ │ ├── lame.c │ │ ├── lame.h │ │ ├── lame.rc │ │ ├── lame_global_flags.h │ │ ├── lameerror.h │ │ ├── logoe.ico │ │ ├── machine.h │ │ ├── mpglib_interface.c │ │ ├── newmdct.c │ │ ├── newmdct.h │ │ ├── presets.c │ │ ├── psymodel.c │ │ ├── psymodel.h │ │ ├── quantize.c │ │ ├── quantize.h │ │ ├── quantize_pvt.c │ │ ├── quantize_pvt.h │ │ ├── reservoir.c │ │ ├── reservoir.h │ │ ├── set_get.c │ │ ├── set_get.h │ │ ├── tables.c │ │ ├── tables.h │ │ ├── takehiro.c │ │ ├── util.c │ │ ├── util.h │ │ ├── vbrquantize.c │ │ ├── vbrquantize.h │ │ ├── vector │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── lame_intrin.h │ │ │ └── xmm_quantize_sub.c │ │ ├── version.c │ │ └── version.h │ │ └── mpglib │ │ ├── AUTHORS │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README │ │ ├── common.c │ │ ├── common.h │ │ ├── dct64_i386.c │ │ ├── dct64_i386.h │ │ ├── decode_i386.c │ │ ├── decode_i386.h │ │ ├── depcomp │ │ ├── huffman.h │ │ ├── interface.c │ │ ├── interface.h │ │ ├── l2tables.h │ │ ├── layer1.c │ │ ├── layer1.h │ │ ├── layer2.c │ │ ├── layer2.h │ │ ├── layer3.c │ │ ├── layer3.h │ │ ├── mpg123.h │ │ ├── mpglib.h │ │ ├── tabinit.c │ │ └── tabinit.h ├── src │ ├── SKP_Silk_A2NLSF.c │ ├── SKP_Silk_A2NLSF_arm.S │ ├── SKP_Silk_AsmHelper.h │ ├── SKP_Silk_AsmPreproc.h │ ├── SKP_Silk_CNG.c │ ├── SKP_Silk_HP_variable_cutoff_FIX.c │ ├── SKP_Silk_Inlines.h │ ├── SKP_Silk_LBRR_reset.c │ ├── SKP_Silk_LPC_inv_pred_gain.c │ ├── SKP_Silk_LPC_synthesis_filter.c │ ├── SKP_Silk_LPC_synthesis_order16.c │ ├── SKP_Silk_LP_variable_cutoff.c │ ├── SKP_Silk_LSF_cos_table.c │ ├── SKP_Silk_LTP_analysis_filter_FIX.c │ ├── SKP_Silk_LTP_scale_ctrl_FIX.c │ ├── SKP_Silk_MA.c │ ├── SKP_Silk_MA_arm.S │ ├── SKP_Silk_NLSF2A.c │ ├── SKP_Silk_NLSF2A_stable.c │ ├── SKP_Silk_NLSF_MSVQ_decode.c │ ├── SKP_Silk_NLSF_MSVQ_encode_FIX.c │ ├── SKP_Silk_NLSF_VQ_rate_distortion_FIX.c │ ├── SKP_Silk_NLSF_VQ_sum_error_FIX.c │ ├── SKP_Silk_NLSF_VQ_sum_error_FIX_arm.S │ ├── SKP_Silk_NLSF_VQ_weights_laroia.c │ ├── SKP_Silk_NLSF_stabilize.c │ ├── SKP_Silk_NSQ.c │ ├── SKP_Silk_NSQ_del_dec.c │ ├── SKP_Silk_PLC.c │ ├── SKP_Silk_PLC.h │ ├── SKP_Silk_SigProc_FIX.h │ ├── SKP_Silk_VAD.c │ ├── SKP_Silk_VQ_nearest_neighbor_FIX.c │ ├── SKP_Silk_allpass_int_arm.S │ ├── SKP_Silk_ana_filt_bank_1.c │ ├── SKP_Silk_ana_filt_bank_1_arm.S │ ├── SKP_Silk_apply_sine_window.c │ ├── SKP_Silk_array_maxabs.c │ ├── SKP_Silk_array_maxabs_arm.S │ ├── SKP_Silk_autocorr.c │ ├── SKP_Silk_biquad.c │ ├── SKP_Silk_biquad_alt.c │ ├── SKP_Silk_burg_modified.c │ ├── SKP_Silk_bwexpander.c │ ├── SKP_Silk_bwexpander_32.c │ ├── SKP_Silk_clz_arm.S │ ├── SKP_Silk_code_signs.c │ ├── SKP_Silk_common_pitch_est_defines.h │ ├── SKP_Silk_control_audio_bandwidth.c │ ├── SKP_Silk_control_codec_FIX.c │ ├── SKP_Silk_corrMatrix_FIX.c │ ├── SKP_Silk_create_init_destroy.c │ ├── SKP_Silk_dec_API.c │ ├── SKP_Silk_decode_core.c │ ├── SKP_Silk_decode_core_arm.S │ ├── SKP_Silk_decode_frame.c │ ├── SKP_Silk_decode_parameters.c │ ├── SKP_Silk_decode_pitch.c │ ├── SKP_Silk_decode_pulses.c │ ├── SKP_Silk_decoder_set_fs.c │ ├── SKP_Silk_define.h │ ├── SKP_Silk_detect_SWB_input.c │ ├── SKP_Silk_div_oabi.c │ ├── SKP_Silk_enc_API.c │ ├── SKP_Silk_encode_frame_FIX.c │ ├── SKP_Silk_encode_parameters.c │ ├── SKP_Silk_encode_pulses.c │ ├── SKP_Silk_find_LPC_FIX.c │ ├── SKP_Silk_find_LTP_FIX.c │ ├── SKP_Silk_find_pitch_lags_FIX.c │ ├── SKP_Silk_find_pred_coefs_FIX.c │ ├── SKP_Silk_gain_quant.c │ ├── SKP_Silk_init_encoder_FIX.c │ ├── SKP_Silk_inner_prod_aligned.c │ ├── SKP_Silk_inner_prod_aligned_arm.S │ ├── SKP_Silk_interpolate.c │ ├── SKP_Silk_k2a.c │ ├── SKP_Silk_k2a_Q16.c │ ├── SKP_Silk_lin2log.c │ ├── SKP_Silk_lin2log_arm.S │ ├── SKP_Silk_log2lin.c │ ├── SKP_Silk_macros.h │ ├── SKP_Silk_macros_arm.h │ ├── SKP_Silk_main.h │ ├── SKP_Silk_main_FIX.h │ ├── SKP_Silk_noise_shape_analysis_FIX.c │ ├── SKP_Silk_pitch_analysis_core.c │ ├── SKP_Silk_pitch_est_defines.h │ ├── SKP_Silk_pitch_est_tables.c │ ├── SKP_Silk_prefilter_FIX.c │ ├── SKP_Silk_prefilter_FIX_arm.S │ ├── SKP_Silk_process_NLSFs_FIX.c │ ├── SKP_Silk_process_gains_FIX.c │ ├── SKP_Silk_quant_LTP_gains_FIX.c │ ├── SKP_Silk_range_coder.c │ ├── SKP_Silk_regularize_correlations_FIX.c │ ├── SKP_Silk_resampler.c │ ├── SKP_Silk_resampler_down2.c │ ├── SKP_Silk_resampler_down2_3.c │ ├── SKP_Silk_resampler_down2_arm.S │ ├── SKP_Silk_resampler_down3.c │ ├── SKP_Silk_resampler_private.h │ ├── SKP_Silk_resampler_private_AR2.c │ ├── SKP_Silk_resampler_private_AR2_arm.S │ ├── SKP_Silk_resampler_private_ARMA4.c │ ├── SKP_Silk_resampler_private_ARMA4_arm.S │ ├── SKP_Silk_resampler_private_IIR_FIR.c │ ├── SKP_Silk_resampler_private_IIR_FIR_arm.S │ ├── SKP_Silk_resampler_private_copy.c │ ├── SKP_Silk_resampler_private_down4.c │ ├── SKP_Silk_resampler_private_down_FIR.c │ ├── SKP_Silk_resampler_private_down_FIR_arm.S │ ├── SKP_Silk_resampler_private_up2_HQ.c │ ├── SKP_Silk_resampler_private_up2_HQ_arm.S │ ├── SKP_Silk_resampler_private_up4.c │ ├── SKP_Silk_resampler_rom.c │ ├── SKP_Silk_resampler_rom.h │ ├── SKP_Silk_resampler_rom_arm.S │ ├── SKP_Silk_resampler_structs.h │ ├── SKP_Silk_resampler_up2.c │ ├── SKP_Silk_resampler_up2_arm.S │ ├── SKP_Silk_residual_energy16_FIX.c │ ├── SKP_Silk_residual_energy_FIX.c │ ├── SKP_Silk_scale_copy_vector16.c │ ├── SKP_Silk_scale_vector.c │ ├── SKP_Silk_schur.c │ ├── SKP_Silk_schur64.c │ ├── SKP_Silk_schur64_arm.S │ ├── SKP_Silk_setup_complexity.h │ ├── SKP_Silk_shell_coder.c │ ├── SKP_Silk_sigm_Q15.c │ ├── SKP_Silk_sigm_Q15_arm.S │ ├── SKP_Silk_solve_LS_FIX.c │ ├── SKP_Silk_sort.c │ ├── SKP_Silk_structs.h │ ├── SKP_Silk_structs_FIX.h │ ├── SKP_Silk_sum_sqr_shift.c │ ├── SKP_Silk_sum_sqr_shift_arm.S │ ├── SKP_Silk_tables.h │ ├── SKP_Silk_tables_LTP.c │ ├── SKP_Silk_tables_NLSF_CB0_10.c │ ├── SKP_Silk_tables_NLSF_CB0_10.h │ ├── SKP_Silk_tables_NLSF_CB0_16.c │ ├── SKP_Silk_tables_NLSF_CB0_16.h │ ├── SKP_Silk_tables_NLSF_CB1_10.c │ ├── SKP_Silk_tables_NLSF_CB1_10.h │ ├── SKP_Silk_tables_NLSF_CB1_16.c │ ├── SKP_Silk_tables_NLSF_CB1_16.h │ ├── SKP_Silk_tables_gain.c │ ├── SKP_Silk_tables_other.c │ ├── SKP_Silk_tables_pitch_lag.c │ ├── SKP_Silk_tables_pulses_per_block.c │ ├── SKP_Silk_tables_sign.c │ ├── SKP_Silk_tables_type_offset.c │ ├── SKP_Silk_tuning_parameters.h │ ├── SKP_Silk_warped_autocorrelation_FIX.c │ └── SKP_Silk_warped_autocorrelation_FIX_arm.S └── test │ ├── Decoder.c │ ├── Encoder.c │ └── signalCompare.c ├── settings.gradle └── src ├── main └── java │ └── io │ └── github │ └── mzdluo123 │ └── silk4j │ ├── AudioUtils.java │ ├── LameBuilder.java │ ├── LameCoder.java │ ├── NativeLibLoader.java │ └── SilkCoder.java └── test ├── java └── io │ └── github │ └── mzdluo123 │ └── silk4j │ └── test │ └── CoderTest.java └── resources ├── 77b18b66-e4d5-4847-8c44-cad582d75ad4.silk ├── out.pcm └── silk.mp3 /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Set up JDK 8 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 8 21 | - name: Compile Java 22 | run: chmod +x gradlew && ./gradlew jar 23 | - name: Compile Native 24 | run: | 25 | cd native 26 | mkdir cmake-build-debug 27 | cd cmake-build-debug 28 | cmake .. 29 | make -j8 30 | - name: Run test 31 | run: ./gradlew test 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build 3 | .idea -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Silk4j 2 | 3 | silkv3编码器的Java接口,为mirai相关生态提供语音编解码方案 4 | 5 | 6 | # 导入依赖 7 | 8 | ``` 9 | // 要使用maven仓库导入,需要先为你的账号生成一个访问token才能正常拉取 10 | repositories { 11 | maven { 12 | url 'https://maven.pkg.github.com/mzdluo123/silk4j' 13 | credentials { 14 | username = '你的用户名' 15 | password = '你的token' 16 | } 17 | } 18 | } 19 | dependencies { 20 | implementation("io.github.mzdluo123:silk4j:版本号") 21 | } 22 | ``` 23 | 版本号请到https://github.com/mzdluo123/silk4j/packages/ 查看 24 | 25 | 你也可以到action页面下载AllInOne中的jar来开始使用 26 | 27 | # 使用 28 | 29 | ```java 30 | 31 | // 请使用这个类完成编码 32 | // 所有的编码默认都只使用左声道 33 | public class AudioUtils { 34 | //使用之前需要初始化 35 | public static void init() throws IOException { 36 | } 37 | // 初始化时可选指定缓存目录,未指定则使用系统目录 38 | public static void init(File tmpDir) throws IOException { 39 | 40 | } 41 | // 以下为编码函数,只可以同时进行一个编码任务,如需pcm文件请看源代码 42 | // 返回的文件在缓存目录内,使用完毕请删除 43 | public static File mp3ToSilk(File mp3File) throws IOException { 44 | 45 | } 46 | public static File mp3ToSilk(InputStream mp3FileStream) throws IOException { 47 | 48 | } 49 | 50 | public static File silkToMp3(File silkFile) throws IOException { 51 | 52 | } 53 | 54 | public static File silkToMp3(InputStream silkFileStream) throws IOException { 55 | 56 | } 57 | 58 | } 59 | 60 | ``` 61 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id("maven-publish") 4 | } 5 | 6 | group 'io.github.mzdluo123' 7 | version '1.2-dev' 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | jar { 14 | from sourceSets.main.output 15 | } 16 | 17 | publishing { 18 | repositories { 19 | maven { 20 | name = "GitHubPackages" 21 | url = uri("https://maven.pkg.github.com/mzdluo123/silk4j") 22 | credentials { 23 | username = project.findProperty("gpr.user") ?: "mzdluo123" 24 | password = project.findProperty("gpr.key") ?: System.getenv("GITHUBTOKEN") 25 | } 26 | } 27 | } 28 | publications { 29 | gpr(MavenPublication) { 30 | from(components["java"]) 31 | } 32 | } 33 | } 34 | 35 | dependencies { 36 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' 37 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' 38 | } 39 | 40 | //static def makeCmd() { 41 | // if (org.gradle.internal.os.OperatingSystem.current().isWindows()) { 42 | // return "mingw32-make" 43 | // } else { 44 | // return "make" 45 | // } 46 | //} 47 | // 48 | //task compileCPP() { 49 | // doLast { 50 | // mkdir("${projectDir}/native/cmake-build-debug") 51 | // exec { 52 | // workingDir "${projectDir}/native/cmake-build-debug" 53 | // commandLine "cmake", "-DCMAKE_BUILD_TYPE=Debug", "${projectDir}/native" 54 | // standardOutput = System.out 55 | // } 56 | // 57 | // exec { 58 | // workingDir "${projectDir}/native/cmake-build-debug" 59 | // commandLine "cmake", "-build", "${projectDir}/native/cmake-build-debug" 60 | // standardOutput = System.out 61 | // } 62 | // exec { 63 | // workingDir "${projectDir}/native/cmake-build-debug" 64 | // commandLine makeCmd(), "-j8" 65 | // standardOutput = System.out 66 | // } 67 | // } 68 | // 69 | //} 70 | 71 | test { 72 | useJUnitPlatform() 73 | } 74 | -------------------------------------------------------------------------------- /cross/build.sh: -------------------------------------------------------------------------------- 1 | cd native 2 | mkdir cmake-build-debug 3 | cd cmake-build-debug 4 | rm -rf CMakeCache.txt 5 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CACHEFILE_DIR=$PWD -Dcross_triple=$CROSS .. 6 | make install -j8 -------------------------------------------------------------------------------- /cross/setup_docker.sh: -------------------------------------------------------------------------------- 1 | docker run --rm -v $GITHUB_WORKSPACE:/work --env CROSS=$CROSS dockcross/$CROSS bash -c '/work/cross/build.sh' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /native/.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build-debug -------------------------------------------------------------------------------- /native/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(native) 3 | 4 | 5 | IF (WIN32) 6 | include_directories(jni_include/inc_win) 7 | ELSEIF (APPLE) 8 | include_directories(jni_include/inc_mac) 9 | ELSEIF (UNIX) 10 | include_directories(jni_include/inc_linux) 11 | ELSE() 12 | set(JAVA_AWT_LIBRARY NotNeeded) 13 | set(JAVA_JVM_LIBRARY NotNeeded) 14 | find_package(JNI REQUIRED) 15 | 16 | # 加入jni支持 17 | include_directories(${JAVA_INCLUDE_PATH}) 18 | include_directories(${JAVA_INCLUDE_PATH2}) 19 | ENDIF () 20 | 21 | 22 | include_directories(../build/generated/sources/headers/java/main/) 23 | add_subdirectory(lame) 24 | 25 | #SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../build/classes/java/main/io/github/mzdluo123/silk4j) 26 | 27 | AUX_SOURCE_DIRECTORY(src SRC_DIR) 28 | 29 | #AUX_SOURCE_DIRECTORY(test SRC_DIR) 30 | 31 | AUX_SOURCE_DIRECTORY(bind SRC_DIR) 32 | 33 | include_directories(src interface) 34 | 35 | set(CMAKE_ANDROID_ARM_MODE ON) 36 | set(CMAKE_ANDROID_ARM_NEON ON) 37 | set(CMAKE_ANDROID_STL_TYPE system ) 38 | 39 | add_library(silk SHARED ${SRC_DIR} bind/JNIEncoder.c bind/coder.h bind/coder.c) 40 | 41 | install(TARGETS silk lame 42 | CONFIGURATIONS Debug 43 | LIBRARY DESTINATION ${CMAKE_CACHEFILE_DIR}/Debug 44 | RUNTIME DESTINATION ${CMAKE_CACHEFILE_DIR}/Debug 45 | ) 46 | install(TARGETS silk lame 47 | CONFIGURATIONS Release 48 | LIBRARY DESTINATION ${CMAKE_CACHEFILE_DIR}/Release/ 49 | RUNTIME DESTINATION ${CMAKE_CACHEFILE_DIR}/Release/ 50 | ) 51 | 52 | 53 | -------------------------------------------------------------------------------- /native/bind/coder.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mzdlu on 2021-02-05. 3 | // 4 | #include "coder.h" 5 | 6 | 7 | #ifdef _WIN32 8 | 9 | unsigned long GetHighResolutionTime() /* O: time in usec*/ 10 | { 11 | /* Returns a time counter in microsec */ 12 | /* the resolution is platform dependent */ 13 | /* but is typically 1.62 us resolution */ 14 | LARGE_INTEGER lpPerformanceCount; 15 | LARGE_INTEGER lpFrequency; 16 | QueryPerformanceCounter(&lpPerformanceCount); 17 | QueryPerformanceFrequency(&lpFrequency); 18 | return (unsigned long) ((1000000 * (lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart); 19 | } 20 | 21 | #else // Linux or Mac 22 | unsigned long GetHighResolutionTime() /* O: time in usec*/ 23 | { 24 | struct timeval tv; 25 | gettimeofday(&tv, 0); 26 | return((tv.tv_sec*1000000)+(tv.tv_usec)); 27 | } 28 | #endif // _WIN32 -------------------------------------------------------------------------------- /native/bind/coder.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mzdlu on 2021-02-05. 3 | // 4 | #ifndef __NATIVE_CODER_H 5 | #define __NATIVE_CODER_H 6 | 7 | unsigned long GetHighResolutionTime(); 8 | 9 | #ifdef _WIN32 10 | #define _CRT_SECURE_NO_DEPRECATE 1 11 | #endif 12 | 13 | 14 | #include 15 | #include 16 | #include 17 | #include "SKP_Silk_SDK_API.h" 18 | #include "SKP_Silk_SigProc_FIX.h" 19 | 20 | /* Define codec specific settings should be moved to h file */ 21 | #define MAX_BYTES_PER_FRAME 1024 22 | #define MAX_INPUT_FRAMES 5 23 | #define MAX_FRAME_LENGTH 480 24 | #define FRAME_LENGTH_MS 20 25 | #define MAX_API_FS_KHZ 48 26 | #define MAX_LBRR_DELAY 2 27 | 28 | #ifdef _SYSTEM_IS_BIG_ENDIAN 29 | /* Function to convert a little endian int16 to a */ 30 | /* big endian int16 or vica verca */ 31 | void swap_endian( 32 | SKP_int16 vec[], 33 | SKP_int len 34 | ) 35 | { 36 | SKP_int i; 37 | SKP_int16 tmp; 38 | SKP_uint8 *p1, *p2; 39 | 40 | for( i = 0; i < len; i++ ){ 41 | tmp = vec[ i ]; 42 | p1 = (SKP_uint8 *)&vec[ i ]; p2 = (SKP_uint8 *)&tmp; 43 | p1[ 0 ] = p2[ 1 ]; p1[ 1 ] = p2[ 0 ]; 44 | } 45 | } 46 | #endif 47 | 48 | #if (defined(_WIN32) || defined(_WINCE)) 49 | 50 | #include /* timer */ 51 | 52 | #else // Linux or Mac 53 | #include 54 | #endif 55 | 56 | 57 | 58 | #endif //__NATIVE_CODER_H 59 | -------------------------------------------------------------------------------- /native/interface/SKP_Silk_errors.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_ERRORS_H 29 | #define SKP_SILK_ERRORS_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" 33 | { 34 | #endif 35 | 36 | /******************/ 37 | /* Error messages */ 38 | /******************/ 39 | #define SKP_SILK_NO_ERROR 0 40 | 41 | /**************************/ 42 | /* Encoder error messages */ 43 | /**************************/ 44 | 45 | /* Input length is not a multiplum of 10 ms, or length is longer than the packet length */ 46 | #define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -1 47 | 48 | /* Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */ 49 | #define SKP_SILK_ENC_FS_NOT_SUPPORTED -2 50 | 51 | /* Packet size not 20, 40, 60, 80 or 100 ms */ 52 | #define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -3 53 | 54 | /* Allocated payload buffer too short */ 55 | #define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -4 56 | 57 | /* Loss rate not between 0 and 100 percent */ 58 | #define SKP_SILK_ENC_INVALID_LOSS_RATE -5 59 | 60 | /* Complexity setting not valid, use 0, 1 or 2 */ 61 | #define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -6 62 | 63 | /* Inband FEC setting not valid, use 0 or 1 */ 64 | #define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -7 65 | 66 | /* DTX setting not valid, use 0 or 1 */ 67 | #define SKP_SILK_ENC_INVALID_DTX_SETTING -8 68 | 69 | /* Internal encoder error */ 70 | #define SKP_SILK_ENC_INTERNAL_ERROR -9 71 | 72 | /**************************/ 73 | /* Decoder error messages */ 74 | /**************************/ 75 | 76 | /* Output sampling frequency lower than internal decoded sampling frequency */ 77 | #define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -10 78 | 79 | /* Payload size exceeded the maximum allowed 1024 bytes */ 80 | #define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -11 81 | 82 | /* Payload has bit errors */ 83 | #define SKP_SILK_DEC_PAYLOAD_ERROR -12 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /native/jni_include/inc_linux/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * %W% %E% 3 | * 4 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT __attribute__((__visibility__("default"))) 12 | #define JNIIMPORT 13 | #define JNICALL 14 | 15 | typedef int jint; 16 | #ifdef _LP64 /* 64-bit Solaris */ 17 | typedef long jlong; 18 | #else 19 | typedef long long jlong; 20 | #endif 21 | 22 | typedef signed char jbyte; 23 | 24 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 25 | -------------------------------------------------------------------------------- /native/jni_include/inc_mac/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.19 05/11/17 3 | * 4 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 | * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT __attribute__((visibility("default"))) 12 | #define JNIIMPORT 13 | #define JNICALL 14 | 15 | #if defined(__LP64__) && __LP64__ /* for -Wundef */ 16 | typedef int jint; 17 | #else 18 | typedef long jint; 19 | #endif 20 | typedef long long jlong; 21 | typedef signed char jbyte; 22 | 23 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 24 | -------------------------------------------------------------------------------- /native/jni_include/inc_win/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.14 03/12/19 3 | * 4 | * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 | * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT __declspec(dllexport) 12 | #define JNIIMPORT __declspec(dllimport) 13 | #define JNICALL __stdcall 14 | 15 | typedef long jint; 16 | typedef __int64 jlong; 17 | typedef signed char jbyte; 18 | 19 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 20 | -------------------------------------------------------------------------------- /native/lame/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | aux_source_directory(src/libmp3lame LAME_SRC_DIR) 2 | aux_source_directory(src/mpglib LAME_SRC_DIR) 3 | 4 | include_directories(src src/libmp3lame src/mpglib) 5 | 6 | add_library(lame SHARED ${LAME_SRC_DIR} src/JNILame.c src/JNILame.h) -------------------------------------------------------------------------------- /native/lame/src/JNILame.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mzdlu on 2021-02-05. 3 | // 4 | 5 | #ifndef NATIVE_JNILAME_H 6 | #define NATIVE_JNILAME_H 7 | #include "io_github_mzdluo123_silk4j_LameCoder.h" 8 | #include "lame.h" 9 | #include 10 | 11 | 12 | lame_global_flags *initializeDefault( 13 | JNIEnv *env); 14 | 15 | lame_global_flags *initialize( 16 | JNIEnv *env, 17 | 18 | jint inSamplerate, jint outChannel, 19 | jint outSamplerate, jint outBitrate, jfloat scaleInput, jint mode, jint vbrMode, 20 | jint quality, jint vbrQuality, jint abrMeanBitrate, jint lowpassFreq, jint highpassFreq, 21 | jstring id3tagTitle, jstring id3tagArtist, jstring id3tagAlbum, 22 | jstring id3tagYear, jstring id3tagComment); 23 | 24 | //jint encode( 25 | // JNIEnv *env, lame_global_flags *glf, 26 | // jshortArray buffer_l, jshortArray buffer_r, 27 | // jint samples, jbyteArray mp3buf); 28 | 29 | //jint encodeBufferInterleaved( 30 | // JNIEnv *env, lame_global_flags *glf, 31 | // jshortArray pcm, jint samples, jbyteArray mp3buf); 32 | // 33 | //jint flush( 34 | // JNIEnv *env, lame_global_flags *glf, 35 | // jbyteArray mp3buf); 36 | 37 | void close( 38 | lame_global_flags *glf); 39 | 40 | 41 | #endif //NATIVE_JNILAME_H 42 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/Makefile.am: -------------------------------------------------------------------------------- 1 | ## $Id: Makefile.am,v 1.41 2016/01/29 21:06:26 aleidinger Exp $ 2 | 3 | include $(top_srcdir)/Makefile.am.global 4 | 5 | SUBDIRS = i386 vector 6 | 7 | lib_LTLIBRARIES = libmp3lame.la 8 | 9 | if HAVE_NASM 10 | cpu_ldadd = $(top_builddir)/libmp3lame/@CPUTYPE@/liblameasmroutines.la 11 | endif 12 | if WITH_VECTOR 13 | vector_ldadd = $(top_builddir)/libmp3lame/vector/liblamevectorroutines.la 14 | endif 15 | 16 | if LIB_WITH_DECODER 17 | decoder_ldadd = $(top_builddir)/mpglib/libmpgdecoder.la 18 | else 19 | decoder_ldadd = 20 | endif 21 | 22 | libmp3lame_la_LIBADD = $(cpu_ldadd) $(vector_ldadd) $(decoder_ldadd) \ 23 | $(CONFIG_MATH_LIB) 24 | libmp3lame_la_LDFLAGS = -version-info @LIB_MAJOR_VERSION@:@LIB_MINOR_VERSION@ \ 25 | -export-symbols $(top_srcdir)/include/libmp3lame.sym \ 26 | -no-undefined 27 | 28 | INCLUDES = @INCLUDES@ -I$(top_srcdir)/mpglib -I$(top_builddir) 29 | 30 | DEFS = @DEFS@ @CONFIG_DEFS@ 31 | 32 | EXTRA_DIST = \ 33 | lame.rc \ 34 | vbrquantize.h \ 35 | logoe.ico 36 | 37 | libmp3lame_la_SOURCES = \ 38 | VbrTag.c \ 39 | bitstream.c \ 40 | encoder.c \ 41 | fft.c \ 42 | gain_analysis.c \ 43 | id3tag.c \ 44 | lame.c \ 45 | newmdct.c \ 46 | presets.c \ 47 | psymodel.c \ 48 | quantize.c \ 49 | quantize_pvt.c \ 50 | reservoir.c \ 51 | set_get.c \ 52 | tables.c \ 53 | takehiro.c \ 54 | util.c \ 55 | vbrquantize.c \ 56 | version.c \ 57 | mpglib_interface.c 58 | 59 | noinst_HEADERS= \ 60 | VbrTag.h \ 61 | bitstream.h \ 62 | encoder.h \ 63 | fft.h \ 64 | gain_analysis.h \ 65 | id3tag.h \ 66 | l3side.h \ 67 | lame-analysis.h \ 68 | lame_global_flags.h \ 69 | lameerror.h \ 70 | machine.h \ 71 | newmdct.h \ 72 | psymodel.h \ 73 | quantize.h \ 74 | quantize_pvt.h \ 75 | reservoir.h \ 76 | set_get.h \ 77 | tables.h \ 78 | util.h \ 79 | vbrquantize.h \ 80 | version.h 81 | 82 | CLEANFILES = lclint.txt 83 | 84 | LCLINTFLAGS= \ 85 | +posixlib \ 86 | +showsummary \ 87 | +showalluses \ 88 | +whichlib \ 89 | +forcehints \ 90 | -fixedformalarray \ 91 | +matchanyintegral \ 92 | -Dlint 93 | 94 | lclint.txt: ${libmp3lame_la_SOURCES} ${noinst_HEADERS} 95 | @lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${libmp3lame_la_SOURCES} 2>&1 >lclint.txt || true 96 | 97 | lclint: lclint.txt 98 | more lclint.txt 99 | 100 | #$(OBJECTS): libtool 101 | #libtool: $(LIBTOOL_DEPS) 102 | # $(SHELL) $(top_builddir)/config.status --recheck 103 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/VbrTag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Xing VBR tagging for LAME. 3 | * 4 | * Copyright (c) 1999 A.L. Faber 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_VRBTAG_H 23 | #define LAME_VRBTAG_H 24 | 25 | 26 | /* ----------------------------------------------------------- 27 | * A Vbr header may be present in the ancillary 28 | * data field of the first frame of an mp3 bitstream 29 | * The Vbr header (optionally) contains 30 | * frames total number of audio frames in the bitstream 31 | * bytes total number of bytes in the bitstream 32 | * toc table of contents 33 | 34 | * toc (table of contents) gives seek points 35 | * for random access 36 | * the ith entry determines the seek point for 37 | * i-percent duration 38 | * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes 39 | * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes 40 | */ 41 | 42 | 43 | #include 44 | 45 | #define FRAMES_FLAG 0x0001 46 | #define BYTES_FLAG 0x0002 47 | #define TOC_FLAG 0x0004 48 | #define VBR_SCALE_FLAG 0x0008 49 | 50 | #define NUMTOCENTRIES 100 51 | 52 | #ifndef lame_internal_flags_defined 53 | #define lame_internal_flags_defined 54 | struct lame_internal_flags; 55 | typedef struct lame_internal_flags lame_internal_flags; 56 | #endif 57 | 58 | 59 | /*structure to receive extracted header */ 60 | /* toc may be NULL*/ 61 | typedef struct { 62 | int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */ 63 | int samprate; /* determined from MPEG header */ 64 | int flags; /* from Vbr header data */ 65 | int frames; /* total bit stream frames from Vbr header data */ 66 | int bytes; /* total bit stream bytes from Vbr header data */ 67 | int vbr_scale; /* encoded vbr scale from Vbr header data */ 68 | unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */ 69 | int headersize; /* size of VBR header, in bytes */ 70 | int enc_delay; /* encoder delay */ 71 | int enc_padding; /* encoder paddign added at end of stream */ 72 | } VBRTAGDATA; 73 | 74 | int GetVbrTag(VBRTAGDATA * pTagData, const unsigned char *buf); 75 | 76 | int InitVbrTag(lame_global_flags * gfp); 77 | int PutVbrTag(lame_global_flags const *gfp, FILE * fid); 78 | void AddVbrFrame(lame_internal_flags * gfc); 79 | void UpdateMusicCRC(uint16_t * crc, const unsigned char *buffer, int size); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MP3 bitstream Output interface for LAME 3 | * 4 | * Copyright (c) 1999 Takehiro TOMINAGA 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_BITSTREAM_H 23 | #define LAME_BITSTREAM_H 24 | 25 | int getframebits(const lame_internal_flags * gfc); 26 | 27 | int format_bitstream(lame_internal_flags * gfc); 28 | 29 | void flush_bitstream(lame_internal_flags * gfc); 30 | void add_dummy_byte(lame_internal_flags * gfc, unsigned char val, unsigned int n); 31 | 32 | int copy_buffer(lame_internal_flags * gfc, unsigned char *buffer, int buffer_size, 33 | int update_crc); 34 | void init_bit_stream_w(lame_internal_flags * gfc); 35 | void CRC_writeheader(lame_internal_flags const *gfc, char *buffer); 36 | int compute_flushbits(const lame_internal_flags * gfp, int *nbytes); 37 | 38 | int get_max_frame_buffer_size_by_constraint(SessionConfig_t const * cfg, int constraint); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/fft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Fast Fourier Transform include file 3 | * 4 | * Copyright (c) 2000 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_FFT_H 23 | #define LAME_FFT_H 24 | 25 | void fft_long(lame_internal_flags const *const gfc, FLOAT x_real[BLKSIZE], 26 | int chn, const sample_t *const data[2]); 27 | 28 | void fft_short(lame_internal_flags const *const gfc, FLOAT x_real[3][BLKSIZE_s], 29 | int chn, const sample_t *const data[2]); 30 | 31 | void init_fft(lame_internal_flags * const gfc); 32 | 33 | #endif 34 | 35 | /* End of fft.h */ 36 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/i386/Makefile.am: -------------------------------------------------------------------------------- 1 | ## $Id: Makefile.am,v 1.28 2013/06/12 09:16:29 rbrito Exp $ 2 | 3 | AUTOMAKE_OPTIONS = foreign 4 | 5 | DEFS = @DEFS@ @CONFIG_DEFS@ 6 | 7 | ECHO ?= echo 8 | 9 | nasm_sources = \ 10 | choose_table.nas \ 11 | cpu_feat.nas \ 12 | fft3dn.nas \ 13 | fftsse.nas 14 | 15 | if HAVE_NASM 16 | noinst_LTLIBRARIES = liblameasmroutines.la 17 | liblameasmroutines_la_SOURCES = $(nasm_sources) 18 | liblameasmroutines_la_DEPENDENCIES = $(nasm_sources:.nas.lo) 19 | am_liblameasmroutines_la_OBJECTS = \ 20 | choose_table$U.lo \ 21 | cpu_feat$U.lo \ 22 | fft3dn$U.lo \ 23 | fftsse$U.lo 24 | endif 25 | 26 | noinst_HEADERS = nasm.h 27 | 28 | INCLUDES = @INCLUDES@ -I$(top_srcdir)/libmp3lame/@CPUTYPE@ 29 | 30 | SUFFIXES = .nas .lo 31 | 32 | EXTRA_liblameasmroutines_la_SOURCES = $(nasm_sources) 33 | 34 | CLEANFILES = \ 35 | choose_table.o.lst \ 36 | choose_table.lo.lst \ 37 | cpu_feat.o.lst \ 38 | cpu_feat.lo.lst \ 39 | fft3dn.o.lst \ 40 | fft3dn.lo.lst \ 41 | fftsse.o.lst \ 42 | fftsse.lo.lst 43 | 44 | EXTRA_DIST = \ 45 | fft.nas \ 46 | fftfpu.nas \ 47 | ffttbl.nas \ 48 | scalar.nas 49 | 50 | NASM = @NASM@ 51 | NASMFLAGS=@NASM_FORMAT@ -i $(top_srcdir)/libmp3lame/@CPUTYPE@/ 52 | 53 | .nas.o: $< nasm.h 54 | $(NASM) $(NASMFLAGS) $< -o $@ -l $@.lst 55 | 56 | .nas.lo: $< nasm.h 57 | $(ECHO) '# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)' >$@ 58 | $(ECHO) "pic_object='$*.o'" >>$@ 59 | $(ECHO) "non_pic_object='$*.o'" >>$@ 60 | $(NASM) $(NASMFLAGS) $< -o $*.o -l $@.lst 61 | 62 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 63 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 64 | LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ 65 | $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 66 | CCLD = $(CC) 67 | LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 68 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ 69 | 70 | 71 | #$(OBJECTS): libtool 72 | #libtool: $(LIBTOOL_DEPS) 73 | # $(SHELL) $(top_builddir)/config.status --recheck 74 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/i386/cpu_feat.nas: -------------------------------------------------------------------------------- 1 | ; 2 | ; 3 | ; assembler routines to detect CPU-features 4 | ; 5 | ; MMX / 3DNow! / SSE / SSE2 6 | ; 7 | ; for the LAME project 8 | ; Frank Klemm, Robert Hegemann 2000-10-12 9 | ; 10 | 11 | %include "nasm.h" 12 | 13 | globaldef has_MMX_nasm 14 | globaldef has_3DNow_nasm 15 | globaldef has_SSE_nasm 16 | globaldef has_SSE2_nasm 17 | 18 | segment_code 19 | 20 | testCPUID: 21 | pushfd 22 | pop eax 23 | mov ecx,eax 24 | xor eax,0x200000 25 | push eax 26 | popfd 27 | pushfd 28 | pop eax 29 | cmp eax,ecx 30 | ret 31 | 32 | ;--------------------------------------- 33 | ; int has_MMX_nasm (void) 34 | ;--------------------------------------- 35 | 36 | has_MMX_nasm: 37 | pushad 38 | call testCPUID 39 | jz return0 ; no CPUID command, so no MMX 40 | 41 | mov eax,0x1 42 | CPUID 43 | test edx,0x800000 44 | jz return0 ; no MMX support 45 | jmp return1 ; MMX support 46 | 47 | ;--------------------------------------- 48 | ; int has_SSE_nasm (void) 49 | ;--------------------------------------- 50 | 51 | has_SSE_nasm: 52 | pushad 53 | call testCPUID 54 | jz return0 ; no CPUID command, so no SSE 55 | 56 | mov eax,0x1 57 | CPUID 58 | test edx,0x02000000 59 | jz return0 ; no SSE support 60 | jmp return1 ; SSE support 61 | 62 | ;--------------------------------------- 63 | ; int has_SSE2_nasm (void) 64 | ;--------------------------------------- 65 | 66 | has_SSE2_nasm: 67 | pushad 68 | call testCPUID 69 | jz return0 ; no CPUID command, so no SSE2 70 | 71 | mov eax,0x1 72 | CPUID 73 | test edx,0x04000000 74 | jz return0 ; no SSE2 support 75 | jmp return1 ; SSE2 support 76 | 77 | ;--------------------------------------- 78 | ; int has_3DNow_nasm (void) 79 | ;--------------------------------------- 80 | 81 | has_3DNow_nasm: 82 | pushad 83 | call testCPUID 84 | jz return0 ; no CPUID command, so no 3DNow! 85 | 86 | mov eax,0x80000000 87 | CPUID 88 | cmp eax,0x80000000 89 | jbe return0 ; no extended MSR(1), so no 3DNow! 90 | 91 | mov eax,0x80000001 92 | CPUID 93 | test edx,0x80000000 94 | jz return0 ; no 3DNow! support 95 | ; 3DNow! support 96 | return1: 97 | popad 98 | xor eax,eax 99 | inc eax 100 | ret 101 | 102 | return0: 103 | popad 104 | xor eax,eax 105 | ret 106 | 107 | end 108 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/i386/fft.nas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/native/lame/src/libmp3lame/i386/fft.nas -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/i386/fftsse.nas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/native/lame/src/libmp3lame/i386/fftsse.nas -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/i386/ffttbl.nas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/native/lame/src/libmp3lame/i386/ffttbl.nas -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/id3tag.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LAME_ID3_H 3 | #define LAME_ID3_H 4 | 5 | 6 | #include 7 | 8 | #define CHANGED_FLAG (1U << 0) 9 | #define ADD_V2_FLAG (1U << 1) 10 | #define V1_ONLY_FLAG (1U << 2) 11 | #define V2_ONLY_FLAG (1U << 3) 12 | #define SPACE_V1_FLAG (1U << 4) 13 | #define PAD_V2_FLAG (1U << 5) 14 | 15 | enum { 16 | MIMETYPE_NONE = 0, 17 | MIMETYPE_JPEG, 18 | MIMETYPE_PNG, 19 | MIMETYPE_GIF 20 | }; 21 | 22 | typedef struct FrameDataNode { 23 | struct FrameDataNode *nxt; 24 | uint32_t fid; /* Frame Identifier */ 25 | char lng[4]; /* 3-character language descriptor */ 26 | struct { 27 | union { 28 | char *l; /* ptr to Latin-1 chars */ 29 | unsigned short *u; /* ptr to UCS-2 text */ 30 | unsigned char *b; /* ptr to raw bytes */ 31 | } ptr; 32 | size_t dim; 33 | int enc; /* 0:Latin-1, 1:UCS-2, 2:RAW */ 34 | } dsc , txt; 35 | } FrameDataNode; 36 | 37 | 38 | typedef struct id3tag_spec { 39 | /* private data members */ 40 | unsigned int flags; 41 | int year; 42 | char *title; 43 | char *artist; 44 | char *album; 45 | char *comment; 46 | int track_id3v1; 47 | int genre_id3v1; 48 | unsigned char *albumart; 49 | unsigned int albumart_size; 50 | unsigned int padding_size; 51 | int albumart_mimetype; 52 | char language[4]; /* the language of the frame's content, according to ISO-639-2 */ 53 | FrameDataNode *v2_head, *v2_tail; 54 | } id3tag_spec; 55 | 56 | 57 | /* write tag into stream at current position */ 58 | extern int id3tag_write_v2(lame_global_flags * gfp); 59 | extern int id3tag_write_v1(lame_global_flags * gfp); 60 | /* 61 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't 62 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters), 63 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used. 64 | */ 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/l3side.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Layer 3 side include file 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_L3SIDE_H 23 | #define LAME_L3SIDE_H 24 | 25 | /* max scalefactor band, max(SBMAX_l, SBMAX_s*3, (SBMAX_s-3)*3+8) */ 26 | #define SFBMAX (SBMAX_s*3) 27 | 28 | /* Layer III side information. */ 29 | typedef struct { 30 | int l[1 + SBMAX_l]; 31 | int s[1 + SBMAX_s]; 32 | int psfb21[1 + PSFB21]; 33 | int psfb12[1 + PSFB12]; 34 | } scalefac_struct; 35 | 36 | 37 | typedef struct { 38 | FLOAT l[SBMAX_l]; 39 | FLOAT s[SBMAX_s][3]; 40 | } III_psy_xmin; 41 | 42 | typedef struct { 43 | III_psy_xmin thm; 44 | III_psy_xmin en; 45 | } III_psy_ratio; 46 | 47 | typedef struct { 48 | FLOAT xr[576]; 49 | int l3_enc[576]; 50 | int scalefac[SFBMAX]; 51 | FLOAT xrpow_max; 52 | 53 | int part2_3_length; 54 | int big_values; 55 | int count1; 56 | int global_gain; 57 | int scalefac_compress; 58 | int block_type; 59 | int mixed_block_flag; 60 | int table_select[3]; 61 | int subblock_gain[3 + 1]; 62 | int region0_count; 63 | int region1_count; 64 | int preflag; 65 | int scalefac_scale; 66 | int count1table_select; 67 | 68 | int part2_length; 69 | int sfb_lmax; 70 | int sfb_smin; 71 | int psy_lmax; 72 | int sfbmax; 73 | int psymax; 74 | int sfbdivide; 75 | int width[SFBMAX]; 76 | int window[SFBMAX]; 77 | int count1bits; 78 | /* added for LSF */ 79 | const int *sfb_partition_table; 80 | int slen[4]; 81 | 82 | int max_nonzero_coeff; 83 | char energy_above_cutoff[SFBMAX]; 84 | } gr_info; 85 | 86 | typedef struct { 87 | gr_info tt[2][2]; 88 | int main_data_begin; 89 | int private_bits; 90 | int resvDrain_pre; 91 | int resvDrain_post; 92 | int scfsi[2][4]; 93 | } III_side_info_t; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/lame-analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GTK plotting routines source file 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_GTKANAL_H 23 | #define LAME_GTKANAL_H 24 | 25 | 26 | #define READ_AHEAD 40 /* number of frames to read ahead */ 27 | #define MAXMPGLAG READ_AHEAD /* if the mpg123 lag becomes bigger than this 28 | we have to stop */ 29 | #define NUMBACK 6 /* number of frames we can back up */ 30 | #define NUMPINFO (NUMBACK+READ_AHEAD+1) 31 | 32 | 33 | 34 | struct plotting_data { 35 | int frameNum; /* current frame number */ 36 | int frameNum123; 37 | int num_samples; /* number of pcm samples read for this frame */ 38 | double frametime; /* starting time of frame, in seconds */ 39 | double pcmdata[2][1600]; 40 | double pcmdata2[2][1152 + 1152 - DECDELAY]; 41 | double xr[2][2][576]; 42 | double mpg123xr[2][2][576]; 43 | double ms_ratio[2]; 44 | double ms_ener_ratio[2]; 45 | 46 | /* L,R, M and S values */ 47 | double energy_save[4][BLKSIZE]; /* psymodel is one ahead */ 48 | double energy[2][4][BLKSIZE]; 49 | double pe[2][4]; 50 | double thr[2][4][SBMAX_l]; 51 | double en[2][4][SBMAX_l]; 52 | double thr_s[2][4][3 * SBMAX_s]; 53 | double en_s[2][4][3 * SBMAX_s]; 54 | double ers_save[4]; /* psymodel is one ahead */ 55 | double ers[2][4]; 56 | 57 | double sfb[2][2][SBMAX_l]; 58 | double sfb_s[2][2][3 * SBMAX_s]; 59 | double LAMEsfb[2][2][SBMAX_l]; 60 | double LAMEsfb_s[2][2][3 * SBMAX_s]; 61 | 62 | int LAMEqss[2][2]; 63 | int qss[2][2]; 64 | int big_values[2][2]; 65 | int sub_gain[2][2][3]; 66 | 67 | double xfsf[2][2][SBMAX_l]; 68 | double xfsf_s[2][2][3 * SBMAX_s]; 69 | 70 | int over[2][2]; 71 | double tot_noise[2][2]; 72 | double max_noise[2][2]; 73 | double over_noise[2][2]; 74 | int over_SSD[2][2]; 75 | int blocktype[2][2]; 76 | int scalefac_scale[2][2]; 77 | int preflag[2][2]; 78 | int mpg123blocktype[2][2]; 79 | int mixed[2][2]; 80 | int mainbits[2][2]; 81 | int sfbits[2][2]; 82 | int LAMEmainbits[2][2]; 83 | int LAMEsfbits[2][2]; 84 | int framesize, stereo, js, ms_stereo, i_stereo, emph, bitrate, sampfreq, maindata; 85 | int crc, padding; 86 | int scfsi[2], mean_bits, resvsize; 87 | int totbits; 88 | }; 89 | #ifndef plotting_data_defined 90 | #define plotting_data_defined 91 | typedef struct plotting_data plotting_data; 92 | #endif 93 | #if 0 94 | extern plotting_data *pinfo; 95 | #endif 96 | #endif 97 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/lame.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "version.h" 3 | 4 | #ifdef _DLL 5 | IDI_ICON1 ICON DISCARDABLE "logoe.ico" 6 | #else 7 | IDI_ICON1 ICON DISCARDABLE "logoe.ico" 8 | #endif 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_TYPE_VERSION,LAME_PATCH_VERSION 12 | PRODUCTVERSION LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_TYPE_VERSION,LAME_PATCH_VERSION 13 | FILEFLAGSMASK 0x3fL 14 | #ifdef _DEBUG 15 | FILEFLAGS VS_FF_DEBUG 16 | #else 17 | FILEFLAGS 0x0L 18 | #endif 19 | FILEOS VOS__WINDOWS32 20 | #ifdef _DLL 21 | FILETYPE VFT_DLL 22 | #else 23 | FILETYPE VFT_APP 24 | #endif 25 | FILESUBTYPE 0x0L 26 | BEGIN 27 | BLOCK "StringFileInfo" 28 | BEGIN 29 | BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual 30 | BEGIN 31 | VALUE "CompanyName", LAME_URL "\0" 32 | VALUE "FileDescription", "MP3 Encoder.\0" 33 | VALUE "FileVersion", LAME_VERSION_STRING "\0" 34 | VALUE "LegalCopyright", "Copyright (C) 1999-2011 The L.A.M.E. Team\0" 35 | #ifdef _DLL 36 | VALUE "OriginalFilename", STR(_DLL) "\0" 37 | #else 38 | VALUE "OriginalFilename", STR(_APP) "\0" 39 | #endif 40 | VALUE "ProductName", "L.A.M.E.\0" 41 | VALUE "ProductVersion", LAME_VERSION_STRING "\0" 42 | END 43 | END 44 | BLOCK "VarFileInfo" 45 | BEGIN 46 | VALUE "Translation", 0x409, 1252 // mandatory by convention 47 | END 48 | END 49 | /* End of Version info */ 50 | 51 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/lameerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A collection of LAME Error Codes 3 | * 4 | * Please use the constants defined here instead of some arbitrary 5 | * values. Currently the values starting at -10 to avoid intersection 6 | * with the -1, -2, -3 and -4 used in the current code. 7 | * 8 | * May be this should be a part of the include/lame.h. 9 | */ 10 | 11 | typedef enum { 12 | LAME_OKAY = 0, 13 | LAME_NOERROR = 0, 14 | LAME_GENERICERROR = -1, 15 | LAME_NOMEM = -10, 16 | LAME_BADBITRATE = -11, 17 | LAME_BADSAMPFREQ = -12, 18 | LAME_INTERNALERROR = -13, 19 | 20 | FRONTEND_READERROR = -80, 21 | FRONTEND_WRITEERROR = -81, 22 | FRONTEND_FILETOOLARGE = -82, 23 | 24 | } lame_errorcodes_t; 25 | 26 | /* end of lameerror.h */ 27 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/logoe.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/native/lame/src/libmp3lame/logoe.ico -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/newmdct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * New Modified DCT include file 3 | * 4 | * Copyright (c) 1999 Takehiro TOMINAGA 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_NEWMDCT_H 23 | #define LAME_NEWMDCT_H 24 | 25 | void mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1); 26 | 27 | #endif /* LAME_NEWMDCT_H */ 28 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/psymodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * psymodel.h 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_PSYMODEL_H 23 | #define LAME_PSYMODEL_H 24 | 25 | 26 | int L3psycho_anal_ns(lame_internal_flags * gfc, 27 | const sample_t *const buffer[2], int gr, 28 | III_psy_ratio ratio[2][2], 29 | III_psy_ratio MS_ratio[2][2], 30 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]); 31 | 32 | int L3psycho_anal_vbr(lame_internal_flags * gfc, 33 | const sample_t *const buffer[2], int gr, 34 | III_psy_ratio ratio[2][2], 35 | III_psy_ratio MS_ratio[2][2], 36 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]); 37 | 38 | 39 | int psymodel_init(lame_global_flags const* gfp); 40 | 41 | 42 | #define rpelev 2 43 | #define rpelev2 16 44 | #define rpelev_s 2 45 | #define rpelev2_s 16 46 | 47 | /* size of each partition band, in barks: */ 48 | #define DELBARK .34 49 | 50 | 51 | /* tuned for output level (sensitive to energy scale) */ 52 | #define VO_SCALE (1./( 14752*14752 )/(BLKSIZE/2)) 53 | 54 | #define temporalmask_sustain_sec 0.01 55 | 56 | #define NS_PREECHO_ATT0 0.8 57 | #define NS_PREECHO_ATT1 0.6 58 | #define NS_PREECHO_ATT2 0.3 59 | 60 | #define NS_MSFIX 3.5 61 | #define NSATTACKTHRE 4.4 62 | #define NSATTACKTHRE_S 25 63 | 64 | #endif /* LAME_PSYMODEL_H */ 65 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/quantize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MP3 quantization 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_QUANTIZE_H 23 | #define LAME_QUANTIZE_H 24 | 25 | void CBR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2], 26 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]); 27 | 28 | void VBR_old_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2], 29 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]); 30 | 31 | void VBR_new_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2], 32 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]); 33 | 34 | void ABR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2], 35 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]); 36 | 37 | 38 | #endif /* LAME_QUANTIZE_H */ 39 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/reservoir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bit reservoir include file 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_RESERVOIR_H 23 | #define LAME_RESERVOIR_H 24 | 25 | int ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits); 26 | void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *max_bits, 27 | int cbr); 28 | void ResvAdjust(lame_internal_flags * gfc, gr_info const *gi); 29 | void ResvFrameEnd(lame_internal_flags * gfc, int mean_bits); 30 | 31 | #endif /* LAME_RESERVOIR_H */ 32 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/set_get.h: -------------------------------------------------------------------------------- 1 | /* 2 | * set_get.h -- Internal set/get definitions 3 | * 4 | * Copyright (C) 2003 Gabriel Bouvigne / Lame project 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __SET_GET_H__ 22 | #define __SET_GET_H__ 23 | 24 | #include 25 | 26 | #if defined(__cplusplus) 27 | extern "C" { 28 | #endif 29 | 30 | /* select psychoacoustic model */ 31 | 32 | /* manage short blocks */ 33 | int CDECL lame_set_short_threshold(lame_global_flags *, float, float); 34 | int CDECL lame_set_short_threshold_lrm(lame_global_flags *, float); 35 | float CDECL lame_get_short_threshold_lrm(const lame_global_flags *); 36 | int CDECL lame_set_short_threshold_s(lame_global_flags *, float); 37 | float CDECL lame_get_short_threshold_s(const lame_global_flags *); 38 | 39 | 40 | int CDECL lame_set_maskingadjust(lame_global_flags *, float); 41 | float CDECL lame_get_maskingadjust(const lame_global_flags *); 42 | 43 | int CDECL lame_set_maskingadjust_short(lame_global_flags *, float); 44 | float CDECL lame_get_maskingadjust_short(const lame_global_flags *); 45 | 46 | /* select ATH formula 4 shape */ 47 | int CDECL lame_set_ATHcurve(lame_global_flags *, float); 48 | float CDECL lame_get_ATHcurve(const lame_global_flags *); 49 | 50 | int CDECL lame_set_preset_notune(lame_global_flags *, int); 51 | 52 | /* substep shaping method */ 53 | int CDECL lame_set_substep(lame_global_flags *, int); 54 | int CDECL lame_get_substep(const lame_global_flags *); 55 | 56 | /* scalefactors scale */ 57 | int CDECL lame_set_sfscale(lame_global_flags *, int); 58 | int CDECL lame_get_sfscale(const lame_global_flags *); 59 | 60 | /* subblock gain */ 61 | int CDECL lame_set_subblock_gain(lame_global_flags *, int); 62 | int CDECL lame_get_subblock_gain(const lame_global_flags *); 63 | 64 | 65 | 66 | /*presets*/ 67 | int apply_preset(lame_global_flags *, int preset, int enforce); 68 | 69 | void CDECL lame_set_tune(lame_t, float); /* FOR INTERNAL USE ONLY */ 70 | void CDECL lame_set_msfix(lame_t gfp, double msfix); 71 | 72 | 73 | #if defined(__cplusplus) 74 | } 75 | #endif 76 | #endif 77 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MPEG layer 3 tables include file 3 | * 4 | * Copyright (c) 1999 Albert L Faber 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_TABLES_H 23 | #define LAME_TABLES_H 24 | 25 | #if 0 26 | typedef struct { 27 | unsigned char no; 28 | unsigned char width; 29 | unsigned char minval_2; 30 | float quiet_thr; 31 | float norm; 32 | float bark; 33 | } type1_t; 34 | 35 | typedef struct { 36 | unsigned char no; 37 | unsigned char width; 38 | float quiet_thr; 39 | float norm; 40 | float SNR; 41 | float bark; 42 | } type2_t; 43 | 44 | typedef struct { 45 | unsigned int no:5; 46 | unsigned int cbw:3; 47 | unsigned int bu:6; 48 | unsigned int bo:6; 49 | unsigned int w1_576:10; 50 | unsigned int w2_576:10; 51 | } type34_t; 52 | 53 | typedef struct { 54 | size_t len1; 55 | const type1_t *const tab1; 56 | size_t len2; 57 | const type2_t *const tab2; 58 | size_t len3; 59 | const type34_t *const tab3; 60 | size_t len4; 61 | const type34_t *const tab4; 62 | } type5_t; 63 | 64 | extern const type5_t table5[6]; 65 | 66 | #endif 67 | 68 | #define HTN 34 69 | 70 | struct huffcodetab { 71 | const unsigned int xlen; /* max. x-index+ */ 72 | const unsigned int linmax; /* max number to be stored in linbits */ 73 | const uint16_t *table; /* pointer to array[xlen][ylen] */ 74 | const uint8_t *hlen; /* pointer to array[xlen][ylen] */ 75 | }; 76 | 77 | extern const struct huffcodetab ht[HTN]; 78 | /* global memory block */ 79 | /* array of all huffcodtable headers */ 80 | /* 0..31 Huffman code table 0..31 */ 81 | /* 32,33 count1-tables */ 82 | 83 | extern const uint8_t t32l[]; 84 | extern const uint8_t t33l[]; 85 | 86 | extern const uint32_t largetbl[16 * 16]; 87 | extern const uint32_t table23[3 * 3]; 88 | extern const uint32_t table56[4 * 4]; 89 | 90 | extern const int scfsi_band[5]; 91 | 92 | extern const int bitrate_table [3][16]; 93 | extern const int samplerate_table [3][ 4]; 94 | 95 | #endif /* LAME_TABLES_H */ 96 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/vbrquantize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MP3 VBR quantization 3 | * 4 | * Copyright (c) 1999 Mark Taylor 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_VBRQUANTIZE_H 23 | #define LAME_VBRQUANTIZE_H 24 | 25 | int VBR_encode_frame(lame_internal_flags * gfc, const FLOAT xr34orig[2][2][576], 26 | const FLOAT l3_xmin[2][2][SFBMAX], const int maxbits[2][2]); 27 | 28 | #endif /* LAME_VBRQUANTIZE_H */ 29 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/vector/Makefile.am: -------------------------------------------------------------------------------- 1 | ## $Id: Makefile.am,v 1.1 2007/01/09 10:15:53 aleidinger Exp $ 2 | 3 | include $(top_srcdir)/Makefile.am.global 4 | 5 | if WITH_XMM 6 | noinst_LTLIBRARIES = liblamevectorroutines.la 7 | endif 8 | 9 | ##liblamecpuroutines_la_LIBADD = 10 | ##liblamecpuroutines_la_LDFLAGS = 11 | 12 | INCLUDES = @INCLUDES@ \ 13 | -I$(top_srcdir)/libmp3lame \ 14 | -I$(top_srcdir)/mpglib \ 15 | -I$(top_builddir) 16 | 17 | DEFS = @DEFS@ @CONFIG_DEFS@ 18 | 19 | xmm_sources = xmm_quantize_sub.c 20 | 21 | if WITH_XMM 22 | liblamevectorroutines_la_SOURCES = $(xmm_sources) 23 | endif 24 | 25 | noinst_HEADERS = lame_intrin.h 26 | 27 | EXTRA_liblamevectorroutines_la_SOURCES = $(xmm_sources) 28 | 29 | CLEANFILES = lclint.txt 30 | 31 | LCLINTFLAGS= \ 32 | +posixlib \ 33 | +showsummary \ 34 | +showalluses \ 35 | +whichlib \ 36 | +forcehints \ 37 | -fixedformalarray \ 38 | +matchanyintegral \ 39 | -Dlint 40 | 41 | lclint.txt: ${liblamecpuroutines_la_SOURCES} ${noinst_HEADERS} 42 | @lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${liblamecpuroutines_la_SOURCES} 2>&1 >lclint.txt || true 43 | 44 | lclint: lclint.txt 45 | more lclint.txt 46 | 47 | #$(OBJECTS): libtool 48 | #libtool: $(LIBTOOL_DEPS) 49 | # $(SHELL) $(top_builddir)/config.status --recheck 50 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/vector/lame_intrin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lame_intrin.h include file 3 | * 4 | * Copyright (c) 2006 Gabriel Bouvigne 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | 23 | #ifndef LAME_INTRIN_H 24 | #define LAME_INTRIN_H 25 | 26 | 27 | void 28 | init_xrpow_core_sse(gr_info * const cod_info, FLOAT xrpow[576], int upper, FLOAT * sum); 29 | 30 | void 31 | fht_SSE2(FLOAT* , int); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /native/lame/src/libmp3lame/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Version numbering for LAME. 3 | * 4 | * Copyright (c) 1999 A.L. Faber 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_VERSION_H 23 | #define LAME_VERSION_H 24 | 25 | 26 | /* 27 | * To make a string from a token, use the # operator: 28 | */ 29 | #ifndef STR 30 | # define __STR(x) #x 31 | # define STR(x) __STR(x) 32 | #endif 33 | 34 | # define LAME_URL "http://lame.sf.net" 35 | 36 | 37 | # define LAME_MAJOR_VERSION 3 /* Major version number */ 38 | # define LAME_MINOR_VERSION 100 /* Minor version number */ 39 | # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */ 40 | # define LAME_PATCH_VERSION 0 /* Patch level */ 41 | # define LAME_ALPHA_VERSION (LAME_TYPE_VERSION==0) 42 | # define LAME_BETA_VERSION (LAME_TYPE_VERSION==1) 43 | # define LAME_RELEASE_VERSION (LAME_TYPE_VERSION==2) 44 | 45 | # define PSY_MAJOR_VERSION 1 /* Major version number */ 46 | # define PSY_MINOR_VERSION 0 /* Minor version number */ 47 | # define PSY_ALPHA_VERSION 0 /* Set number if this is an alpha version, otherwise zero */ 48 | # define PSY_BETA_VERSION 0 /* Set number if this is a beta version, otherwise zero */ 49 | 50 | #if LAME_ALPHA_VERSION 51 | #define LAME_PATCH_LEVEL_STRING " alpha " STR(LAME_PATCH_VERSION) 52 | #endif 53 | #if LAME_BETA_VERSION 54 | #define LAME_PATCH_LEVEL_STRING " beta " STR(LAME_PATCH_VERSION) 55 | #endif 56 | #if LAME_RELEASE_VERSION 57 | #if LAME_PATCH_VERSION 58 | #define LAME_PATCH_LEVEL_STRING " release " STR(LAME_PATCH_VERSION) 59 | #else 60 | #define LAME_PATCH_LEVEL_STRING "" 61 | #endif 62 | #endif 63 | 64 | # define LAME_VERSION_STRING STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) LAME_PATCH_LEVEL_STRING 65 | 66 | #endif /* LAME_VERSION_H */ 67 | 68 | /* End of version.h */ 69 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/AUTHORS: -------------------------------------------------------------------------------- 1 | Michael Hipp Author of orignal mpglib version 0.2a. 2 | 3 | Albert L. Faber 4 | Aleksander Korzynski 5 | Alexander Leidinger 6 | Frank Klemm 7 | Gabriel Bouvigne 8 | Leigh Smith 9 | Mark Taylor 10 | Myers Carpenter 11 | Naoki Shibata 12 | Robert Hegemann 13 | Sigbjorn Skjaeret 14 | Stefan Bellon 15 | Steve Lhomme 16 | Takehiro TOMINAGA 17 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## $Id: Makefile.am,v 1.18 2010/10/30 13:21:02 robert Exp $ 2 | 3 | include $(top_srcdir)/Makefile.am.global 4 | 5 | INCLUDES = @INCLUDES@ -I$(top_srcdir)/libmp3lame -I$(top_builddir) 6 | 7 | EXTRA_DIST = \ 8 | AUTHORS \ 9 | README 10 | 11 | DEFS = @DEFS@ @CONFIG_DEFS@ 12 | 13 | noinst_LTLIBRARIES = libmpgdecoder.la 14 | 15 | libmpgdecoder_la_SOURCES = common.c \ 16 | dct64_i386.c \ 17 | decode_i386.c \ 18 | interface.c \ 19 | layer1.c \ 20 | layer2.c \ 21 | layer3.c \ 22 | tabinit.c 23 | 24 | noinst_HEADERS = common.h \ 25 | dct64_i386.h \ 26 | decode_i386.h \ 27 | huffman.h \ 28 | interface.h \ 29 | l2tables.h \ 30 | layer1.h \ 31 | layer2.h \ 32 | layer3.h \ 33 | mpg123.h \ 34 | mpglib.h \ 35 | tabinit.h 36 | 37 | LCLINTFLAGS= \ 38 | +posixlib \ 39 | +showsummary \ 40 | +showalluses \ 41 | +whichlib \ 42 | +forcehints \ 43 | -fixedformalarray \ 44 | +matchanyintegral \ 45 | -Dlint 46 | 47 | lclint.txt: ${libmpgdecoder_la_SOURCES} ${noinst_HEADERS} 48 | @lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${libmpgdecoder_la_SOURCES} 2>&1 >lclint.txt || true 49 | 50 | lclint: lclint.txt 51 | more lclint.txt 52 | 53 | #$(OBJECTS): libtool 54 | #libtool: $(LIBTOOL_DEPS) 55 | # $(SHELL) $(top_builddir)/config.status --recheck 56 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/README: -------------------------------------------------------------------------------- 1 | hip - Hip Isn't a Player 2 | A LGPLed mpeg audio decoding library. 3 | 4 | Based off of Michael Hipp's mpglib 0.2a , with many 5 | improvements by the lame development team (see AUTHORS). 6 | 7 | The interface to the library is based off of vorbisfile. If you add mp3 8 | support to your app using this library it should be a snap to add Ogg Vorbis 9 | support as well. 10 | 11 | This isn't as fast as mpg123 will be for decoding as none of it is in 12 | assmbler. 13 | 14 | Seeking currently isn't implemented. 15 | 16 | 17 | From mpglib's orginal README: 18 | ============================= 19 | 20 | PLEASE NOTE: This software may contain patented algorithms (at least 21 | patented in some countries). It may be not allowed to sell/use products 22 | based on this source code in these countries. Check this out first! 23 | 24 | COPYRIGHT of MP3 music: 25 | Please note, that the duplicating of copyrighted music without explicit 26 | permission violates the rights of the owner. 27 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | 23 | #ifndef COMMON_H_INCLUDED 24 | #define COMMON_H_INCLUDED 25 | 26 | #include "mpg123.h" 27 | #include "mpglib.h" 28 | 29 | extern const int tabsel_123[2][3][16]; 30 | extern const long freqs[9]; 31 | 32 | extern real muls[27][64]; 33 | 34 | 35 | int head_check(unsigned long head, int check_layer); 36 | int decode_header(PMPSTR mp, struct frame *fr, unsigned long newhead); 37 | unsigned int getbits(PMPSTR mp, int number_of_bits); 38 | unsigned int getbits_fast(PMPSTR mp, int number_of_bits); 39 | unsigned char get_leq_8_bits(PMPSTR mp, unsigned int number_of_bits); 40 | unsigned short get_leq_16_bits(PMPSTR mp, unsigned int number_of_bits); 41 | int set_pointer(PMPSTR mp, long backstep); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/dct64_i386.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef MPGLIB_DCT64_I386_H_INCLUDED 23 | #define MPGLIB_DCT64_I386_H_INCLUDED 24 | 25 | #include "common.h" 26 | 27 | void dct64(real * a, real * b, real * c); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/decode_i386.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef DECODE_I386_H_INCLUDED 23 | #define DECODE_I386_H_INCLUDED 24 | 25 | #include "common.h" 26 | 27 | int synth_1to1_mono(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt); 28 | int synth_1to1(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt); 29 | 30 | int synth_1to1_mono_unclipped(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt); 31 | int synth_1to1_unclipped(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef INTERFACE_H_INCLUDED 23 | #define INTERFACE_H_INCLUDED 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "common.h" 30 | 31 | int InitMP3(PMPSTR mp); 32 | int decodeMP3(PMPSTR mp, unsigned char *inmemory, int inmemsize, char *outmemory, 33 | int outmemsize, int *done); 34 | void ExitMP3(PMPSTR mp); 35 | 36 | /* added decodeMP3_unclipped to support returning raw floating-point values of samples. The representation 37 | of the floating-point numbers is defined in mpg123.h as #define real. It is 64-bit double by default. 38 | No more than 1152 samples per channel are allowed. */ 39 | int decodeMP3_unclipped(PMPSTR mp, unsigned char *inmemory, int inmemsize, char *outmemory, 40 | int outmemsize, int *done); 41 | 42 | /* added remove_buf to support mpglib seeking */ 43 | void remove_buf(PMPSTR mp); 44 | 45 | /* added audiodata_precedesframes to return the number of bitstream frames the audio data will precede the 46 | current frame by for Layer 3 data. Aids seeking. 47 | */ 48 | int audiodata_precedesframes(PMPSTR mp); 49 | 50 | /* Resets decoding. Aids seeking. */ 51 | void decode_reset(PMPSTR mp); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/layer1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAYER1_H_INCLUDED 23 | #define LAYER1_H_INCLUDED 24 | 25 | void hip_init_tables_layer1(void); 26 | int decode_layer1_sideinfo(PMPSTR mp); 27 | int decode_layer1_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/layer2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | 23 | #ifndef LAYER2_H_INCLUDED 24 | #define LAYER2_H_INCLUDED 25 | 26 | 27 | struct al_table2 { 28 | short bits; 29 | short d; 30 | }; 31 | 32 | 33 | 34 | void hip_init_tables_layer2(void); 35 | int decode_layer2_sideinfo(PMPSTR mp); 36 | int decode_layer2_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/layer3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAYER3_H_INCLUDED 23 | #define LAYER3_H_INCLUDED 24 | 25 | void hip_init_tables_layer3(void); 26 | int decode_layer3_sideinfo(PMPSTR mp); 27 | int decode_layer3_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point, 28 | int (*synth_1to1_mono_ptr) (PMPSTR, real *, unsigned char *, int *), 29 | int (*synth_1to1_ptr) (PMPSTR, real *, int, unsigned char *, int *)); 30 | int layer3_audiodata_precedesframes(PMPSTR mp); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/mpglib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | #ifndef _MPGLIB_H_ 22 | #define _MPGLIB_H_ 23 | 24 | #include "lame.h" 25 | 26 | #ifndef plotting_data_defined 27 | #define plotting_data_defined 28 | struct plotting_data; 29 | typedef struct plotting_data plotting_data; 30 | #endif 31 | 32 | 33 | extern void lame_report_fnc(lame_report_function f, const char *format, ...); 34 | 35 | struct buf { 36 | unsigned char *pnt; 37 | long size; 38 | long pos; 39 | struct buf *next; 40 | struct buf *prev; 41 | }; 42 | 43 | struct framebuf { 44 | struct buf *buf; 45 | long pos; 46 | struct frame *next; 47 | struct frame *prev; 48 | }; 49 | 50 | typedef struct mpstr_tag { 51 | struct buf *head, *tail; /* buffer linked list pointers, tail points to oldest buffer */ 52 | int vbr_header; /* 1 if valid Xing vbr header detected */ 53 | int num_frames; /* set if vbr header present */ 54 | int enc_delay; /* set if vbr header present */ 55 | int enc_padding; /* set if vbr header present */ 56 | /* header_parsed, side_parsed and data_parsed must be all set 1 57 | before the full frame has been parsed */ 58 | int header_parsed; /* 1 = header of current frame has been parsed */ 59 | int side_parsed; /* 1 = header of sideinfo of current frame has been parsed */ 60 | int data_parsed; 61 | int free_format; /* 1 = free format frame */ 62 | int old_free_format; /* 1 = last frame was free format */ 63 | int bsize; 64 | int framesize; 65 | int ssize; /* number of bytes used for side information, including 2 bytes for CRC-16 if present */ 66 | int dsize; 67 | int fsizeold; /* size of previous frame, -1 for first */ 68 | int fsizeold_nopadding; 69 | struct frame fr; /* holds the parameters decoded from the header */ 70 | struct III_sideinfo sideinfo; 71 | unsigned char bsspace[2][MAXFRAMESIZE + 1024]; /* bit stream space used ???? */ /* MAXFRAMESIZE */ 72 | real hybrid_block[2][2][SBLIMIT * SSLIMIT]; 73 | int hybrid_blc[2]; 74 | unsigned long header; 75 | int bsnum; 76 | real synth_buffs[2][2][0x110]; 77 | int synth_bo; 78 | int sync_bitstream; /* 1 = bitstream is yet to be synchronized */ 79 | 80 | int bitindex; 81 | unsigned char *wordpointer; 82 | plotting_data *pinfo; 83 | 84 | lame_report_function report_msg; 85 | lame_report_function report_dbg; 86 | lame_report_function report_err; 87 | } MPSTR, *PMPSTR; 88 | 89 | 90 | #define MP3_ERR -1 91 | #define MP3_OK 0 92 | #define MP3_NEED_MORE 1 93 | 94 | 95 | 96 | #endif /* _MPGLIB_H_ */ 97 | -------------------------------------------------------------------------------- /native/lame/src/mpglib/tabinit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2010 The L.A.M.E. project 3 | * 4 | * Initially written by Michael Hipp, see also AUTHORS and README. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef MPGLIB_TABINIT_H_INCLUDED 23 | #define MPGLIB_TABINIT_H_INCLUDED 24 | 25 | #include "mpg123.h" 26 | 27 | extern real decwin[512 + 32]; 28 | extern real *pnts[5]; 29 | 30 | void make_decode_tables(long scale); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_A2NLSF_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=6 32 | 33 | VARDEF y32, r3 34 | VARDEF pn1, r4 35 | VARDEF pn2, r5 36 | VARDEF lo, r6 37 | VARDEF hi, r8 38 | .globl SYM(SKP_Silk_A2NLSF_eval_poly) 39 | SYM(SKP_Silk_A2NLSF_eval_poly): 40 | stmdb sp!, {r4-r8, fp, ip, lr} 41 | add fp, sp, #28 42 | add r0, r0, r2, lsl #2 43 | ldr y32, [r0], #-4 44 | tst r2, #1 45 | beq LR(1, f) 46 | ldr pn1, [r0], #-4 47 | sub r2, r2, #1 48 | mov r1, r1, lsl #4 49 | L(0) 50 | smull lo, hi, y32, r1 51 | subs r2, r2, #1 52 | add y32, pn1, hi, lsl #16 53 | ldr pn1, [r0], #-4 54 | add y32, y32, lo, lsr #16 55 | bgt LR(0, b) 56 | smull lo, hi, y32, r1 57 | add y32, pn1, hi, lsl #16 58 | add r0, y32, lo, lsr #16 59 | ldmia sp!, {r4-r8, fp, ip, pc} 60 | 61 | L(1)/*EVEN:*/ 62 | add r0, r0, #4 63 | ldmdb r0!, {pn1, pn2} 64 | sub r2, r2, #2 65 | mov r1, r1, lsl #4 66 | L(0) 67 | smull lo, hi, y32, r1 68 | subs r2, r2, #2 69 | add y32, pn2, hi, lsl #16 70 | add y32, y32, lo, lsr #16 71 | smull lo, hi, y32, r1 72 | add y32, pn1, hi, lsl #16 73 | ldmdb r0!, {pn1, pn2} 74 | add y32, y32, lo, lsr #16 75 | bgt LR(0, b) 76 | smull lo, hi, y32, r1 77 | add y32, pn2, hi, lsl #16 78 | add y32, y32, lo, lsr #16 79 | smull lo, hi, y32, r1 80 | add y32, pn1, hi, lsl #16 81 | add r0, y32, lo, lsr #16 82 | ldmia sp!, {r4-r8, fp, ip, pc} 83 | END 84 | #endif 85 | #endif 86 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_LBRR_reset.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Resets LBRR buffer, used if packet size changes */ 31 | void SKP_Silk_LBRR_reset( 32 | SKP_Silk_encoder_state *psEncC /* I/O state */ 33 | ) 34 | { 35 | SKP_int i; 36 | 37 | for( i = 0; i < MAX_LBRR_DELAY; i++ ) { 38 | psEncC->LBRR_buffer[ i ].usage = SKP_SILK_NO_LBRR; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_NLSF2A_stable.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Convert NLSF parameters to stable AR prediction filter coefficients */ 31 | void SKP_Silk_NLSF2A_stable( 32 | SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */ 33 | const SKP_int pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */ 34 | const SKP_int LPC_order /* I LPC/LSF order */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 invGain_Q30; 39 | 40 | SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order ); 41 | 42 | /* Ensure stable LPCs */ 43 | for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) { 44 | if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) { 45 | SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */ 46 | } else { 47 | break; 48 | } 49 | } 50 | 51 | /* Reached the last iteration */ 52 | if( i == MAX_LPC_STABILIZE_ITERATIONS ) { 53 | SKP_assert( 0 ); 54 | for( i = 0; i < LPC_order; i++ ) { 55 | pAR_Q12[ i ] = 0; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /* Rate-Distortion calculations for multiple input data vectors */ 31 | void SKP_Silk_NLSF_VQ_rate_distortion_FIX( 32 | SKP_int32 *pRD_Q20, /* O Rate-distortion values [psNLSF_CBS->nVectors*N] */ 33 | const SKP_Silk_NLSF_CBS *psNLSF_CBS, /* I NLSF codebook stage struct */ 34 | const SKP_int *in_Q15, /* I Input vectors to be quantized */ 35 | const SKP_int *w_Q6, /* I Weight vector */ 36 | const SKP_int32 *rate_acc_Q5, /* I Accumulated rates from previous stage */ 37 | const SKP_int mu_Q15, /* I Weight between weighted error and rate */ 38 | const SKP_int N, /* I Number of input vectors to be quantized */ 39 | const SKP_int LPC_order /* I LPC order */ 40 | ) 41 | { 42 | SKP_int i, n; 43 | SKP_int32 *pRD_vec_Q20; 44 | 45 | /* Compute weighted quantization errors for all input vectors over one codebook stage */ 46 | SKP_Silk_NLSF_VQ_sum_error_FIX( pRD_Q20, in_Q15, w_Q6, psNLSF_CBS->CB_NLSF_Q15, 47 | N, psNLSF_CBS->nVectors, LPC_order ); 48 | 49 | /* Loop over input vectors */ 50 | pRD_vec_Q20 = pRD_Q20; 51 | for( n = 0; n < N; n++ ) { 52 | /* Add rate cost to error for each codebook vector */ 53 | for( i = 0; i < psNLSF_CBS->nVectors; i++ ) { 54 | SKP_assert( rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ] >= 0 ); 55 | SKP_assert( rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ] <= SKP_int16_MAX ); 56 | pRD_vec_Q20[ i ] = SKP_SMLABB( pRD_vec_Q20[ i ], rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ], mu_Q15 ); 57 | SKP_assert( pRD_vec_Q20[ i ] >= 0 ); 58 | } 59 | pRD_vec_Q20 += psNLSF_CBS->nVectors; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_array_maxabs.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_int16_array_maxabs.c * 30 | * * 31 | * Function that returns the maximum absolut value of * 32 | * the input vector * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Function that returns the maximum absolut value of the input vector */ 40 | #if (EMBEDDED_ARM<4) 41 | SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ 42 | const SKP_int16 *vec, /* I Input vector [len] */ 43 | const SKP_int32 len /* I Length of input vector */ 44 | ) 45 | { 46 | SKP_int32 max = 0, i, lvl = 0, ind; 47 | if( len == 0 ) return 0; 48 | 49 | ind = len - 1; 50 | max = SKP_SMULBB( vec[ ind ], vec[ ind ] ); 51 | for( i = len - 2; i >= 0; i-- ) { 52 | lvl = SKP_SMULBB( vec[ i ], vec[ i ] ); 53 | if( lvl > max ) { 54 | max = lvl; 55 | ind = i; 56 | } 57 | } 58 | 59 | /* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */ 60 | if( max >= 1073676289 ) { // (2^15-1)^2 = 1073676289 61 | return( SKP_int16_MAX ); 62 | } else { 63 | if( vec[ ind ] < 0 ) { 64 | return( -vec[ ind ] ); 65 | } else { 66 | return( vec[ ind ] ); 67 | } 68 | } 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_biquad.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_biquad.c * 30 | * * 31 | * Second order ARMA filter * 32 | * Can handle slowly varying filter coefficients * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Second order ARMA filter */ 40 | /* Can handle slowly varying filter coefficients */ 41 | void SKP_Silk_biquad( 42 | const SKP_int16 *in, /* I: input signal */ 43 | const SKP_int16 *B, /* I: MA coefficients, Q13 [3] */ 44 | const SKP_int16 *A, /* I: AR coefficients, Q13 [2] */ 45 | SKP_int32 *S, /* I/O: state vector [2] */ 46 | SKP_int16 *out, /* O: output signal */ 47 | const SKP_int32 len /* I: signal length */ 48 | ) 49 | { 50 | SKP_int k, in16; 51 | SKP_int32 A0_neg, A1_neg, S0, S1, out32, tmp32; 52 | 53 | S0 = S[ 0 ]; 54 | S1 = S[ 1 ]; 55 | A0_neg = -A[ 0 ]; 56 | A1_neg = -A[ 1 ]; 57 | for( k = 0; k < len; k++ ) { 58 | /* S[ 0 ], S[ 1 ]: Q13 */ 59 | in16 = in[ k ]; 60 | out32 = SKP_SMLABB( S0, in16, B[ 0 ] ); 61 | 62 | S0 = SKP_SMLABB( S1, in16, B[ 1 ] ); 63 | S0 += SKP_LSHIFT( SKP_SMULWB( out32, A0_neg ), 3 ); 64 | 65 | S1 = SKP_LSHIFT( SKP_SMULWB( out32, A1_neg ), 3 ); 66 | S1 = SKP_SMLABB( S1, in16, B[ 2 ] ); 67 | tmp32 = SKP_RSHIFT_ROUND( out32, 13 ) + 1; 68 | out[ k ] = (SKP_int16)SKP_SAT16( tmp32 ); 69 | } 70 | S[ 0 ] = S0; 71 | S[ 1 ] = S1; 72 | } 73 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_bwexpander.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Chirp (bandwidth expand) LP AR filter */ 31 | void SKP_Silk_bwexpander( 32 | SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ 33 | const SKP_int d, /* I Length of ar */ 34 | SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 chirp_minus_one_Q16; 39 | 40 | chirp_minus_one_Q16 = chirp_Q16 - 65536; 41 | 42 | /* NB: Dont use SKP_SMULWB, instead of SKP_RSHIFT_ROUND( SKP_MUL() , 16 ), below. */ 43 | /* Bias in SKP_SMULWB can lead to unstable filters */ 44 | for( i = 0; i < d - 1; i++ ) { 45 | ar[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ i ] ), 16 ); 46 | chirp_Q16 += SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); 47 | } 48 | ar[ d - 1 ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ d - 1 ] ), 16 ); 49 | } 50 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_bwexpander_32.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Chirp (bandwidth expand) LP AR filter */ 31 | void SKP_Silk_bwexpander_32( 32 | SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ 33 | const SKP_int d, /* I Length of ar */ 34 | SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 tmp_chirp_Q16; 39 | 40 | tmp_chirp_Q16 = chirp_Q16; 41 | for( i = 0; i < d - 1; i++ ) { 42 | ar[ i ] = SKP_SMULWW( ar[ i ], tmp_chirp_Q16 ); 43 | tmp_chirp_Q16 = SKP_SMULWW( chirp_Q16, tmp_chirp_Q16 ); 44 | } 45 | ar[ d - 1 ] = SKP_SMULWW( ar[ d - 1 ], tmp_chirp_Q16 ); 46 | } 47 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_clz_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if (EMBEDDED_ARM>0) && (EMBEDDED_ARM<5) 32 | 33 | .globl SYM(SKP_Silk_CLZ16) 34 | .globl SYM(SKP_Silk_CLZ32) 35 | 36 | SYM(SKP_Silk_CLZ16): 37 | str lr, [sp, #-4]! 38 | 39 | mov r2, r0 40 | mov r0, #0 41 | ands r1, r2, #0xF000 42 | movne r1, r2, asr #12 43 | bne 0f 44 | add r0, r0, #4 45 | ands r1, r2, #0xF00 46 | movne r1, r2, asr #8 47 | bne 0f 48 | add r0, r0, #4 49 | ands r1, r2, #0xF0 50 | movne r1, r2, asr #4 51 | bne 0f 52 | add r0, r0, #4 53 | mov r1, r2 54 | 0: 55 | ands r2, r1, #0x8 56 | bne 1f 57 | add r0, r0, #1 58 | ands r2, r1, #0x4 59 | bne 1f 60 | add r0, r0, #1 61 | ands r2, r1, #0x2 62 | bne 1f 63 | add r0, r0, #1 64 | ands r2, r1, #0x1 65 | bne 1f 66 | add r0, r0, #1 67 | 1: 68 | ldr pc, [sp], #4 69 | 70 | SYM(SKP_Silk_CLZ32): 71 | 72 | str lr, [sp, #-4]! 73 | 74 | mov r2, r0 75 | mov r0, #0 76 | ands r1, r2, #0xF0000000 77 | movne r1, r2, asr #28 78 | bne 0f 79 | add r0, r0, #4 80 | ands r1, r2, #0xF000000 81 | movne r1, r2, asr #24 82 | bne 0f 83 | add r0, r0, #4 84 | ands r1, r2, #0xF00000 85 | movne r1, r2, asr #20 86 | bne 0f 87 | add r0, r0, #4 88 | ands r1, r2, #0xF0000 89 | movne r1, r2, asr #16 90 | bne 0f 91 | add r0, r0, #4 92 | ands r1, r2, #0xF000 93 | movne r1, r2, asr #12 94 | bne 0f 95 | add r0, r0, #4 96 | ands r1, r2, #0xF00 97 | movne r1, r2, asr #8 98 | bne 0f 99 | add r0, r0, #4 100 | ands r1, r2, #0xF0 101 | movne r1, r2, asr #4 102 | bne 0f 103 | add r0, r0, #4 104 | mov r1, r2 105 | 0: 106 | ands r2, r1, #0x8 107 | bne 1f 108 | add r0, r0, #1 109 | ands r2, r1, #0x4 110 | bne 1f 111 | add r0, r0, #1 112 | ands r2, r1, #0x2 113 | bne 1f 114 | add r0, r0, #1 115 | ands r2, r1, #0x1 116 | bne 1f 117 | add r0, r0, #1 118 | 1: 119 | ldr pc, [sp], #4 120 | 121 | #endif 122 | #endif 123 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_create_init_destroy.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | 31 | /************************/ 32 | /* Init Decoder State */ 33 | /************************/ 34 | SKP_int SKP_Silk_init_decoder( 35 | SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */ 36 | ) 37 | { 38 | SKP_memset( psDec, 0, sizeof( SKP_Silk_decoder_state ) ); 39 | /* Set sampling rate to 24 kHz, and init non-zero values */ 40 | SKP_Silk_decoder_set_fs( psDec, 24 ); 41 | 42 | /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ 43 | psDec->first_frame_after_reset = 1; 44 | psDec->prev_inv_gain_Q16 = 65536; 45 | 46 | /* Reset CNG state */ 47 | SKP_Silk_CNG_Reset( psDec ); 48 | 49 | SKP_Silk_PLC_Reset( psDec ); 50 | 51 | return(0); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_decode_pitch.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /*********************************************************** 29 | * Pitch analyser function 30 | ********************************************************** */ 31 | #include "SKP_Silk_SigProc_FIX.h" 32 | #include "SKP_Silk_common_pitch_est_defines.h" 33 | 34 | void SKP_Silk_decode_pitch( 35 | SKP_int lagIndex, /* I */ 36 | SKP_int contourIndex, /* O */ 37 | SKP_int pitch_lags[], /* O 4 pitch values */ 38 | SKP_int Fs_kHz /* I sampling frequency (kHz) */ 39 | ) 40 | { 41 | SKP_int lag, i, min_lag; 42 | 43 | min_lag = SKP_SMULBB( PITCH_EST_MIN_LAG_MS, Fs_kHz ); 44 | 45 | /* Only for 24 / 16 kHz version for now */ 46 | lag = min_lag + lagIndex; 47 | if( Fs_kHz == 8 ) { 48 | /* Only a small codebook for 8 khz */ 49 | for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) { 50 | pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage2[ i ][ contourIndex ]; 51 | } 52 | } else { 53 | for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) { 54 | pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage3[ i ][ contourIndex ]; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_div_oabi.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_typedef.h" 29 | 30 | SKP_int32 SKP_DIV32_arm( SKP_int32 a32, SKP_int32 b32 ) { 31 | return ( ( SKP_int32 )( ( a32 ) / ( b32 ) ) ); 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_init_encoder_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /*********************************/ 31 | /* Initialize Silk Encoder state */ 32 | /*********************************/ 33 | SKP_int SKP_Silk_init_encoder_FIX( 34 | SKP_Silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */ 35 | ) { 36 | SKP_int ret = 0; 37 | /* Clear the entire encoder state */ 38 | SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FIX ) ); 39 | 40 | #if HIGH_PASS_INPUT 41 | psEnc->variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ 42 | psEnc->variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ 43 | #endif 44 | 45 | /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ 46 | psEnc->sCmn.first_frame_after_reset = 1; 47 | 48 | /* Initialize Silk VAD */ 49 | ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD ); 50 | 51 | /* Initialize NSQ */ 52 | psEnc->sCmn.sNSQ.prev_inv_gain_Q16 = 65536; 53 | psEnc->sCmn.sNSQ_LBRR.prev_inv_gain_Q16 = 65536; 54 | 55 | return( ret ); 56 | } 57 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_inner_prod_aligned.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_inner_prod_aligned.c * 30 | * * 31 | * * 32 | * Copyright 2008-2010 (c), Skype Limited * 33 | * Date: 080601 * 34 | * */ 35 | #include "SKP_Silk_SigProc_FIX.h" 36 | 37 | /* sum= for(i=0;i6, memory access can be reduced by half. */ 42 | 43 | #if (EMBEDDED_ARM<5) 44 | SKP_int32 SKP_Silk_inner_prod_aligned( 45 | const SKP_int16* const inVec1, /* I input vector 1 */ 46 | const SKP_int16* const inVec2, /* I input vector 2 */ 47 | const SKP_int len /* I vector lengths */ 48 | ) 49 | { 50 | SKP_int i; 51 | SKP_int32 sum = 0; 52 | for( i = 0; i < len; i++ ) { 53 | sum = SKP_SMLABB( sum, inVec1[ i ], inVec2[ i ] ); 54 | } 55 | return sum; 56 | } 57 | #endif 58 | 59 | #if (EMBEDDED_ARM<5) 60 | SKP_int64 SKP_Silk_inner_prod16_aligned_64( 61 | const SKP_int16 *inVec1, /* I input vector 1 */ 62 | const SKP_int16 *inVec2, /* I input vector 2 */ 63 | const SKP_int len /* I vector lengths */ 64 | ) 65 | { 66 | SKP_int i; 67 | SKP_int64 sum = 0; 68 | for( i = 0; i < len; i++ ) { 69 | sum = SKP_SMLALBB( sum, inVec1[ i ], inVec2[ i ] ); 70 | } 71 | return sum; 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_interpolate.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Interpolate two vectors */ 31 | void SKP_Silk_interpolate( 32 | SKP_int xi[ MAX_LPC_ORDER ], /* O interpolated vector */ 33 | const SKP_int x0[ MAX_LPC_ORDER ], /* I first vector */ 34 | const SKP_int x1[ MAX_LPC_ORDER ], /* I second vector */ 35 | const SKP_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ 36 | const SKP_int d /* I number of parameters */ 37 | ) 38 | { 39 | SKP_int i; 40 | 41 | SKP_assert( ifact_Q2 >= 0 ); 42 | SKP_assert( ifact_Q2 <= ( 1 << 2 ) ); 43 | 44 | for( i = 0; i < d; i++ ) { 45 | xi[ i ] = ( SKP_int )( ( SKP_int32 )x0[ i ] + SKP_RSHIFT( SKP_MUL( ( SKP_int32 )x1[ i ] - ( SKP_int32 )x0[ i ], ifact_Q2 ), 2 ) ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_k2a.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_k2a.c * 30 | * * 31 | * Step up function, converts reflection coefficients to prediction * 32 | * coefficients * 33 | * * 34 | * Copyright 2008 (c), Skype Limited * 35 | * Date: 080103 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Step up function, converts reflection coefficients to prediction coefficients */ 40 | void SKP_Silk_k2a( 41 | SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ 42 | const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ 43 | const SKP_int32 order /* I: Prediction order */ 44 | ) 45 | { 46 | SKP_int k, n; 47 | SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; 48 | 49 | for( k = 0; k < order; k++ ) { 50 | for( n = 0; n < k; n++ ) { 51 | Atmp[ n ] = A_Q24[ n ]; 52 | } 53 | for( n = 0; n < k; n++ ) { 54 | A_Q24[ n ] = SKP_SMLAWB( A_Q24[ n ], SKP_LSHIFT( Atmp[ k - n - 1 ], 1 ), rc_Q15[ k ] ); 55 | } 56 | A_Q24[ k ] = -SKP_LSHIFT( (SKP_int32)rc_Q15[ k ], 9 ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_k2a_Q16.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_k2a.c * 30 | * * 31 | * Step up function, converts reflection coefficients to prediction * 32 | * coefficients * 33 | * * 34 | * Copyright 2008 (c), Skype Limited * 35 | * Date: 080103 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Step up function, converts reflection coefficients to prediction coefficients */ 40 | void SKP_Silk_k2a_Q16( 41 | SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ 42 | const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ 43 | const SKP_int32 order /* I: Prediction order */ 44 | ) 45 | { 46 | SKP_int k, n; 47 | SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; 48 | 49 | for( k = 0; k < order; k++ ) { 50 | for( n = 0; n < k; n++ ) { 51 | Atmp[ n ] = A_Q24[ n ]; 52 | } 53 | for( n = 0; n < k; n++ ) { 54 | A_Q24[ n ] = SKP_SMLAWW( A_Q24[ n ], Atmp[ k - n - 1 ], rc_Q16[ k ] ); 55 | } 56 | A_Q24[ k ] = -SKP_LSHIFT( rc_Q16[ k ], 8 ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_lin2log.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_lin2log.c * 30 | * * 31 | * Convert input to a log scale * 32 | * Approximation of 128 * log2() * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | #if EMBEDDED_ARM<4 39 | /* Approximation of 128 * log2() (very close inverse of approx 2^() below) */ 40 | /* Convert input to a log scale */ 41 | SKP_int32 SKP_Silk_lin2log( const SKP_int32 inLin ) /* I: Input in linear scale */ 42 | { 43 | SKP_int32 lz, frac_Q7; 44 | 45 | SKP_Silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); 46 | 47 | /* Piece-wise parabolic approximation */ 48 | return( SKP_LSHIFT( 31 - lz, 7 ) + SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), 179 ) ); 49 | } 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_log2lin.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_log2lin.c * 30 | * * 31 | * Convert input to a linear scale * 32 | * * 33 | * Copyright 2006 (c), Skype Limited * 34 | * Date: 060221 * 35 | * */ 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | 38 | /* Approximation of 2^() (very close inverse of SKP_Silk_lin2log()) */ 39 | /* Convert input to a linear scale */ 40 | SKP_int32 SKP_Silk_log2lin( const SKP_int32 inLog_Q7 ) /* I: Input on log scale */ 41 | { 42 | SKP_int32 out, frac_Q7; 43 | 44 | if( inLog_Q7 < 0 ) { 45 | return( 0 ); 46 | } else if( inLog_Q7 >= ( 31 << 7 ) ) { 47 | /* Saturate, and prevent wrap-around */ 48 | return( SKP_int32_MAX ); 49 | } 50 | 51 | out = SKP_LSHIFT( 1, SKP_RSHIFT( inLog_Q7, 7 ) ); 52 | frac_Q7 = inLog_Q7 & 0x7F; 53 | if( inLog_Q7 < 2048 ) { 54 | /* Piece-wise parabolic approximation */ 55 | out = SKP_ADD_RSHIFT( out, SKP_MUL( out, SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 ); 56 | } else { 57 | /* Piece-wise parabolic approximation */ 58 | out = SKP_MLA( out, SKP_RSHIFT( out, 7 ), SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ); 59 | } 60 | return out; 61 | } 62 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_pitch_est_defines.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SIGPROCFIX_PITCH_EST_DEFINES_H 29 | #define SIGPROCFIX_PITCH_EST_DEFINES_H 30 | 31 | /************************************************************/ 32 | /* Definitions For Fix pitch estimator */ 33 | /************************************************************/ 34 | 35 | #define PITCH_EST_SHORTLAG_BIAS_Q15 6554 /* 0.2f. for logarithmic weighting */ 36 | #define PITCH_EST_PREVLAG_BIAS_Q15 6554 /* Prev lag bias */ 37 | #define PITCH_EST_FLATCONTOUR_BIAS_Q20 52429 /* 0.05f */ 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_pitch_est_tables.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_typedef.h" 29 | #include "SKP_Silk_common_pitch_est_defines.h" 30 | 31 | /********************************************************/ 32 | /* Auto Generated File from generate_pitch_est_tables.m */ 33 | /********************************************************/ 34 | 35 | const SKP_int16 SKP_Silk_CB_lags_stage2[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE2_EXT] = 36 | { 37 | {0, 2,-1,-1,-1, 0, 0, 1, 1, 0, 1}, 38 | {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, 39 | {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, 40 | {0,-1, 2, 1, 0, 1, 1, 0, 0,-1,-1} 41 | }; 42 | 43 | const SKP_int16 SKP_Silk_CB_lags_stage3[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE3_MAX] = 44 | { 45 | {-9,-7,-6,-5,-5,-4,-4,-3,-3,-2,-2,-2,-1,-1,-1, 0, 0, 0, 1, 1, 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 5, 6, 8}, 46 | {-3,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0,-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 2, 3}, 47 | { 3, 3, 2, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,-1, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2}, 48 | { 9, 8, 6, 5, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 0, 1, 1, 0, 0, 0,-1,-1,-1,-2,-2,-2,-3,-3,-4,-4,-5,-5,-6,-7} 49 | }; 50 | 51 | const SKP_int16 SKP_Silk_Lag_range_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ] = 52 | { 53 | /* Lags to search for low number of stage3 cbks */ 54 | { 55 | {-2,6}, 56 | {-1,5}, 57 | {-1,5}, 58 | {-2,7} 59 | }, 60 | /* Lags to search for middle number of stage3 cbks */ 61 | { 62 | {-4,8}, 63 | {-1,6}, 64 | {-1,6}, 65 | {-4,9} 66 | }, 67 | /* Lags to search for max number of stage3 cbks */ 68 | { 69 | {-9,12}, 70 | {-3,7}, 71 | {-2,7}, 72 | {-7,13} 73 | } 74 | }; 75 | 76 | const SKP_int16 SKP_Silk_cbk_sizes_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = 77 | { 78 | PITCH_EST_NB_CBKS_STAGE3_MIN, 79 | PITCH_EST_NB_CBKS_STAGE3_MID, 80 | PITCH_EST_NB_CBKS_STAGE3_MAX 81 | }; 82 | 83 | const SKP_int16 SKP_Silk_cbk_offsets_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = 84 | { 85 | ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MIN) >> 1), 86 | ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MID) >> 1), 87 | 0 88 | }; 89 | 90 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_regularize_correlations_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /* Add noise to matrix diagonal */ 31 | void SKP_Silk_regularize_correlations_FIX( 32 | SKP_int32 *XX, /* I/O Correlation matrices */ 33 | SKP_int32 *xx, /* I/O Correlation values */ 34 | SKP_int32 noise, /* I Noise to add */ 35 | SKP_int D /* I Dimension of XX */ 36 | ) 37 | { 38 | SKP_int i; 39 | for( i = 0; i < D; i++ ) { 40 | matrix_ptr( &XX[ 0 ], i, i, D ) = SKP_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise ); 41 | } 42 | xx[ 0 ] += noise; 43 | } 44 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_down2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | #define SKP_Silk_resampler_down2_0 0x2690 34 | #define SKP_Silk_resampler_down2_1 0x9B81 35 | 36 | VARDEF xy0, r4 37 | VARDEF xy1, r5 38 | VARDEF down2_coefs, _r7 39 | VARDEF S_0, r6 40 | VARDEF S_1, r8 41 | VARDEF in0, sb 42 | VARDEF in1, sl 43 | VARDEF out32, r0 44 | 45 | .set sp_S, 0 46 | .globl SYM(SKP_Silk_resampler_down2) 47 | SYM(SKP_Silk_resampler_down2): 48 | stmdb sp!, {r4-r10, fp, ip, lr} 49 | add fp, sp, #36 50 | sub sp, sp, #4 51 | ldrsh in0, [r2], #2 // Avoid un-aligned access 52 | ldrsh in1, [r2], #2 53 | str r0, [sp, #sp_S] 54 | ldmia r0, {S_0, S_1} 55 | mov down2_coefs, #0x26000000 56 | add down2_coefs, down2_coefs, #0x900000 57 | add down2_coefs, down2_coefs, #0x9B00 58 | add down2_coefs, down2_coefs, #0x81 59 | mov r3, r3, asr #1 60 | mov ip, #1024 61 | L(0) 62 | add out32, S_0, S_1 63 | rsb xy0, S_0, in0, lsl #10 64 | rsb xy1, S_1, in1, lsl #10 65 | smlawb xy0, xy0, down2_coefs, xy0 66 | smulwt xy1, xy1, down2_coefs 67 | add out32, out32, xy0 68 | add S_0, xy0, in0, lsl #10 69 | add out32, out32, xy1 70 | add S_1, xy1, in1, lsl #10 71 | #if EMBEDDED_ARM>=6 72 | qadd out32, out32, ip 73 | subs r3, r3, #1 74 | ssat out32, #16, out32, asr #11 75 | #ifdef _WINRT 76 | ble LR(1, f) 77 | ldrsh in0, [r2], #2 78 | ldrsh in1, [r2], #2 79 | L(1) 80 | #else 81 | ldrgtsh in0, [r2], #2 82 | ldrgtsh in1, [r2], #2 83 | #endif 84 | #else 85 | qadd out32, out32, ip 86 | cmp out32, #0x4000000 87 | movge out32, #0x4000000 88 | subge out32, out32, #1 89 | cmn out32, #0x4000000 90 | movlt out32, #0x4000000 91 | subs r3, r3, #1 92 | mov out32, out32, asr #11 93 | ldrgtsh in0, [r2], #2 94 | ldrgtsh in1, [r2], #2 95 | #endif 96 | 97 | strh out32, [r1], #2 98 | bgt LR(0, b) 99 | 100 | ldr r0, [sp, #sp_S] 101 | stmia r0, {S_0, S_1} 102 | 103 | add sp, sp, #4 104 | ldmia sp!, {r4-r10, fp, ip, pc} 105 | END 106 | #endif 107 | #endif 108 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_private_AR2.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_resampler_private_AR2. c * 30 | * * 31 | * Second order AR filter with single delay elements * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * */ 35 | 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | #include "SKP_Silk_resampler_private.h" 38 | 39 | #if (EMBEDDED_ARM<5) 40 | /* Second order AR filter with single delay elements */ 41 | void SKP_Silk_resampler_private_AR2( 42 | SKP_int32 S[], /* I/O: State vector [ 2 ] */ 43 | SKP_int32 out_Q8[], /* O: Output signal */ 44 | const SKP_int16 in[], /* I: Input signal */ 45 | const SKP_int16 A_Q14[], /* I: AR coefficients, Q14 */ 46 | SKP_int32 len /* I: Signal length */ 47 | ) 48 | { 49 | SKP_int32 k; 50 | SKP_int32 out32; 51 | 52 | for( k = 0; k < len; k++ ) { 53 | out32 = SKP_ADD_LSHIFT32( S[ 0 ], (SKP_int32)in[ k ], 8 ); 54 | out_Q8[ k ] = out32; 55 | out32 = SKP_LSHIFT( out32, 2 ); 56 | S[ 0 ] = SKP_SMLAWB( S[ 1 ], out32, A_Q14[ 0 ] ); 57 | S[ 1 ] = SKP_SMULWB( out32, A_Q14[ 1 ] ); 58 | } 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_private_AR2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | 34 | VARDEF len, r4 35 | VARDEF S_0, r5 36 | VARDEF S_1, r6 37 | VARDEF in0, _r7 38 | VARDEF out32, r8 39 | VARDEF A_Q140, sb 40 | VARDEF A_Q141, sl 41 | 42 | .set sp_S, 0 43 | .globl SYM(SKP_Silk_resampler_private_AR2) 44 | SYM(SKP_Silk_resampler_private_AR2): 45 | stmdb sp!, {r4-r10, fp, ip, lr} 46 | add fp, sp, #36 47 | sub sp, sp, #4 48 | .set sp_len, 44 49 | 50 | str r0, [sp, #sp_S] 51 | ldr S_0, [r0], #4 52 | ldr S_1, [r0], #-4 53 | ldr len, [sp, #sp_len] 54 | ldrsh A_Q140, [r3], #2 55 | ldrsh A_Q141, [r3] 56 | cmp len, #0 57 | beq LR(1, f) 58 | 59 | L(0) 60 | ldrsh in0, [r2], #2 61 | add out32, S_0, in0, lsl #8 62 | str out32, [r1], #4 63 | subs len, len, #1 64 | mov out32, out32, lsl #2 65 | smlawb S_0, out32, A_Q140, S_1 66 | smulwb S_1, out32, A_Q141 67 | bgt LR(0, b) 68 | 69 | str S_0, [r0], #4 70 | str S_1, [r0] 71 | L(1) 72 | add sp, sp, #4 73 | ldmia sp!, {r4-r10, fp, ip, pc} 74 | END 75 | #endif 76 | #endif 77 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_private_IIR_FIR_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | 34 | VARDEF ind, r4 35 | VARDEF tab1, r5 36 | VARDEF tab2, r6 37 | VARDEF tab3, _r7 38 | VARDEF val1, r8 39 | VARDEF val2, sb 40 | VARDEF val3, r2 41 | VARDEF val4, r3 42 | VARDEF tmp1, sl 43 | VARDEF tmp2, r2 44 | VARDEF tmp3, r3 45 | VARDEF tmp4, ip 46 | VARDEF out, sl 47 | 48 | .set sp_max_i, 0 49 | .set sp_inc, 4 50 | 51 | EXTERN SYM(SKP_Silk_resampler_frac_FIR_144_alt) 52 | .globl SYM(SKP_Silk_resampler_private_IIR_FIR_INTERPOL) 53 | SYM(SKP_Silk_resampler_private_IIR_FIR_INTERPOL): 54 | stmdb sp!, {r4-r10, fp, ip, lr} 55 | add fp, sp, #36 56 | sub sp, sp, #8 57 | str r2, [sp, #sp_max_i] 58 | str r3, [sp, #sp_inc] 59 | cmp r2, #0 60 | mov tmp3, #0xFF00 61 | mov ind, #0 62 | ble LR(1, f) 63 | add tmp3, tmp3, #0xFF 64 | L(0) 65 | ldr tmp1, TABLE(L0, =SKP_Silk_resampler_frac_FIR_144_alt) 66 | and tmp3, ind, tmp3 67 | mov tmp2, #144 68 | mov tmp4, ind, asr #16 69 | smulwb tmp2, tmp3, tmp2 70 | add tmp1, tmp1, tmp2, lsl #3 71 | add tmp1, tmp1, tmp2, lsl #2 72 | add tmp4, r1, tmp4, lsl #1 73 | 74 | ldmia tmp1, {tab1, tab2, tab3} 75 | ldrsh val1, [tmp4], #2 76 | ldrsh val2, [tmp4], #2 77 | ldrsh val3, [tmp4], #2 78 | ldrsh val4, [tmp4], #2 79 | smulbb out, val1, tab1 80 | smlabt out, val2, tab1, out 81 | ldrsh val1, [tmp4], #2 82 | ldrsh val2, [tmp4] 83 | smlabb out, val3, tab2, out 84 | smlabt out, val4, tab2, out 85 | ldr r2, [sp, #sp_max_i] 86 | ldr r3, [sp, #sp_inc] 87 | smlabb out, val1, tab3, out 88 | smlabt out, val2, tab3, out 89 | add ind, ind, r3 90 | adds out, out, #1<<14 91 | mov tmp3, #0xFF00 92 | #ifdef _WINRT 93 | bvc LR(2, f) 94 | mvn out, #0x80000000 95 | b LR(3, f) 96 | L(2) 97 | qadd out, out, out 98 | L(3) 99 | #else 100 | mvnvs out, #0x80000000 101 | qaddvc out, out, out 102 | #endif 103 | add tmp3, tmp3, #0xFF 104 | mov out, out, asr #16 105 | cmp ind, r2 106 | strh out, [r0], #2 107 | blt LR(0, b) 108 | L(1) 109 | add sp, sp, #8 110 | ldmia sp!, {r4-r10, fp, ip, pc} 111 | 112 | L(L0) 113 | DCD SYM(SKP_Silk_resampler_frac_FIR_144_alt) 114 | END 115 | #endif 116 | #endif 117 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_private_copy.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * File Name: SKP_Silk_resampler_private_copy.c * 30 | * * 31 | * Description: Copy. * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * All rights reserved. * 35 | * */ 36 | 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | #include "SKP_Silk_resampler_private.h" 39 | 40 | /* Copy */ 41 | void SKP_Silk_resampler_private_copy( 42 | void *SS, /* I/O: Resampler state (unused) */ 43 | SKP_int16 out[], /* O: Output signal */ 44 | const SKP_int16 in[], /* I: Input signal */ 45 | SKP_int32 inLen /* I: Number of input samples */ 46 | ) 47 | { 48 | SKP_memcpy( out, in, inLen * sizeof( SKP_int16 ) ); 49 | } 50 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_structs.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * File Name: SKP_Silk_resampler_structs.h * 30 | * * 31 | * Description: Structs for IIR/FIR resamplers * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * All rights reserved. * 35 | * * 36 | * */ 37 | 38 | #ifndef SKP_Silk_RESAMPLER_STRUCTS_H 39 | #define SKP_Silk_RESAMPLER_STRUCTS_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */ 46 | #define RESAMPLER_SUPPORT_ABOVE_48KHZ 1 47 | 48 | #define SKP_Silk_RESAMPLER_MAX_FIR_ORDER 16 49 | #define SKP_Silk_RESAMPLER_MAX_IIR_ORDER 6 50 | 51 | 52 | typedef struct _SKP_Silk_resampler_state_struct{ 53 | SKP_int32 sIIR[ SKP_Silk_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ 54 | SKP_int32 sFIR[ SKP_Silk_RESAMPLER_MAX_FIR_ORDER ]; 55 | SKP_int32 sDown2[ 2 ]; 56 | void (*resampler_function)( void *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 57 | void (*up2_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 58 | SKP_int32 batchSize; 59 | SKP_int32 invRatio_Q16; 60 | SKP_int32 FIR_Fracs; 61 | SKP_int32 input2x; 62 | const SKP_int16 *Coefs; 63 | #if RESAMPLER_SUPPORT_ABOVE_48KHZ 64 | SKP_int32 sDownPre[ 2 ]; 65 | SKP_int32 sUpPost[ 2 ]; 66 | void (*down_pre_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 67 | void (*up_post_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 68 | SKP_int32 batchSizePrePost; 69 | SKP_int32 ratio_Q16; 70 | SKP_int32 nPreDownsamplers; 71 | SKP_int32 nPostUpsamplers; 72 | #endif 73 | SKP_int32 magic_number; 74 | } SKP_Silk_resampler_state_struct; 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | #endif /* SKP_Silk_RESAMPLER_STRUCTS_H */ 80 | 81 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_resampler_up2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | #define SKP_Silk_resampler_up2_lq_0 0x1FA6 34 | #define SKP_Silk_resampler_up2_lq_1 0x8FAF 35 | 36 | VARDEF xy0, r4 37 | VARDEF xy1, r5 38 | VARDEF up2_coefs, _r7 39 | VARDEF S_0, r6 40 | VARDEF S_1, r8 41 | VARDEF in, sb 42 | VARDEF out0, sl 43 | VARDEF out1, r0 44 | 45 | .set sp_S, 0 46 | .globl SYM(SKP_Silk_resampler_up2) 47 | SYM(SKP_Silk_resampler_up2): 48 | stmdb sp!, {r4-r10, fp, ip, lr} 49 | add fp, sp, #36 50 | sub sp, sp, #4 51 | mov up2_coefs, #0x1F000000 52 | ldrsh in, [r2], #2 53 | add up2_coefs, up2_coefs, #0xA60000 54 | str r0, [sp, #sp_S] 55 | add up2_coefs, up2_coefs, #0x8F00 56 | ldmia r0, {S_0, S_1} 57 | add up2_coefs, up2_coefs, #0xAF 58 | mov ip, #512 59 | cmp r3, #0 60 | beq LR(1, f) 61 | L(0) 62 | mov in, in, lsl #10 63 | sub xy0, in, S_0 64 | sub xy1, in, S_1 65 | smulwt xy0, xy0, up2_coefs 66 | smlawb xy1, xy1, up2_coefs, xy1 67 | add out0, S_0, xy0 68 | add out1, S_1, xy1 69 | add S_0, in, xy0 70 | add S_1, in, xy1 71 | qadd out0, out0, ip 72 | qadd out1, out1, ip 73 | #if EMBEDDED_ARM<6 74 | cmp out0, #0x2000000 75 | movge out0, #0x2000000 76 | subge out0, out0, #1 77 | cmn out0, #0x2000000 78 | movlt out0, #0x2000000 79 | cmp out1, #0x2000000 80 | movge out1, #0x2000000 81 | subge out1 ,out1, #1 82 | cmn out1, #0x2000000 83 | movlt out1, #0x2000000 84 | mov out0, out0, asr #10 85 | mov out1, out1, asr #10 86 | #else 87 | ssat out0, #16, out0, asr #10 88 | ssat out1, #16, out1, asr #10 89 | #endif 90 | subs r3, r3, #1 91 | #ifdef _WINRT 92 | ble LR(2, f) 93 | ldrsh in, [r2], #2 94 | strh out0, [r1], #2 95 | strh out1, [r1], #2 96 | b LR(0, b) 97 | L(2) 98 | strh out0, [r1], #2 99 | strh out1, [r1], #2 100 | #else 101 | ldrgtsh in, [r2], #2 102 | strh out0, [r1], #2 103 | strh out1, [r1], #2 104 | bgt LR(0, b) 105 | #endif 106 | 107 | ldr r0, [sp, #sp_S] 108 | stmia r0, {S_0, S_1} 109 | L(1) 110 | add sp, sp, #4 111 | ldmia sp!, {r4-r10, fp, ip, pc} 112 | END 113 | #endif 114 | #endif 115 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_scale_copy_vector16.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Copy and multiply a vector by a constant */ 31 | void SKP_Silk_scale_copy_vector16( 32 | SKP_int16 *data_out, 33 | const SKP_int16 *data_in, 34 | SKP_int32 gain_Q16, /* (I): gain in Q16 */ 35 | const SKP_int dataSize /* (I): length */ 36 | ) 37 | { 38 | SKP_int i; 39 | SKP_int32 tmp32; 40 | 41 | for( i = 0; i < dataSize; i++ ) { 42 | tmp32 = SKP_SMULWB( gain_Q16, data_in[ i ] ); 43 | data_out[ i ] = (SKP_int16)SKP_CHECK_FIT16( tmp32 ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_scale_vector.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Multiply a vector by a constant */ 31 | void SKP_Silk_scale_vector32_Q26_lshift_18( 32 | SKP_int32 *data1, /* (I/O): Q0/Q18 */ 33 | SKP_int32 gain_Q26, /* (I): Q26 */ 34 | SKP_int dataSize /* (I): length */ 35 | ) 36 | { 37 | SKP_int i; 38 | 39 | for( i = 0; i < dataSize; i++ ) { 40 | data1[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( SKP_SMULL( data1[ i ], gain_Q26 ), 8 ) );// OUTPUT: Q18 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_sigm_Q15.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_sigm_Q15.c * 30 | * * 31 | * Approximate sigmoid function * 32 | * * 33 | * Copyright 2006 (c), Skype Limited * 34 | * Date: 060221 * 35 | * */ 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | #if EMBEDDED_ARM<4 38 | /********************************/ 39 | /* approximate sigmoid function */ 40 | /********************************/ 41 | /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ 42 | static const SKP_int32 sigm_LUT_slope_Q10[ 6 ] = { 43 | 237, 153, 73, 30, 12, 7 44 | }; 45 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */ 46 | static const SKP_int32 sigm_LUT_pos_Q15[ 6 ] = { 47 | 16384, 23955, 28861, 31213, 32178, 32548 48 | }; 49 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */ 50 | static const SKP_int32 sigm_LUT_neg_Q15[ 6 ] = { 51 | 16384, 8812, 3906, 1554, 589, 219 52 | }; 53 | 54 | SKP_int SKP_Silk_sigm_Q15( SKP_int in_Q5 ) 55 | { 56 | SKP_int ind; 57 | 58 | if( in_Q5 < 0 ) { 59 | /* Negative input */ 60 | in_Q5 = -in_Q5; 61 | if( in_Q5 >= 6 * 32 ) { 62 | return 0; /* Clip */ 63 | } else { 64 | /* Linear interpolation of look up table */ 65 | ind = SKP_RSHIFT( in_Q5, 5 ); 66 | return( sigm_LUT_neg_Q15[ ind ] - SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 67 | } 68 | } else { 69 | /* Positive input */ 70 | if( in_Q5 >= 6 * 32 ) { 71 | return 32767; /* clip */ 72 | } else { 73 | /* Linear interpolation of look up table */ 74 | ind = SKP_RSHIFT( in_Q5, 5 ); 75 | return( sigm_LUT_pos_Q15[ ind ] + SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 76 | } 77 | } 78 | } 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_sigm_Q15_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=4 32 | 33 | VARDEF ptr_slope, r6 34 | VARDEF ptr_LUT, _r7 35 | VARDEF in_Q5, r1 36 | VARDEF ind, r2 37 | VARDEF val_slope, r5 38 | VARDEF val_PUT, r4 39 | VARDEF in_Q5_tmp, r3 40 | 41 | .globl SYM(SKP_Silk_sigm_Q15) 42 | SYM(SKP_Silk_sigm_Q15): 43 | stmdb sp!, {r4-r7, fp, ip, lr} 44 | add fp, sp, #24 45 | cmp r0, #0 46 | ldr ptr_slope, TABLE(L0, =SKP_Silk_sigm_tab) 47 | 48 | mov in_Q5, r0 49 | rsblt in_Q5, r0, #0 50 | mov r0, #32768 51 | addlt ptr_slope, ptr_slope, #24 52 | movlt r0, #1 53 | add ptr_LUT, ptr_slope, #12 /*sigm_LUT_pos_Q15*/ 54 | cmp in_Q5, #192 /*6*32*/ 55 | sub r0, r0, #1 56 | 57 | bge LR(1, f) 58 | mov ind, in_Q5, asr #5 /*ind*/ 59 | mov ind, ind, lsl #1 60 | and in_Q5_tmp, in_Q5, #0x1F 61 | ldrsh val_slope, [ptr_slope, ind] /*sigm_LUT_slope_Q10*/ 62 | ldrsh val_PUT, [ptr_LUT, ind] /*sigm_LUT_pos/neg_Q15*/ 63 | mla r0, val_slope, in_Q5_tmp, val_PUT 64 | L(1) 65 | ldmia sp!, {r4-r7, fp, ip, pc} 66 | 67 | L(L0) 68 | DCD SYM(SKP_Silk_sigm_tab) 69 | 70 | SKP_TABLE SKP_Silk_sigm_tab, 2 71 | DCW 237, 153, 73, 30, 12, 7, \ 72 | 16384, 23955, 28861, 31213, 32178, 32548, \ 73 | -237, -153, -73, -30, -12, -7, \ 74 | 16384, 8812, 3906, 1554, 589, 219 75 | END 76 | #endif 77 | #endif 78 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_sum_sqr_shift_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=5 32 | 33 | VARDEF x0, r4 34 | VARDEF nrg_tmp, r5 35 | VARDEF shift, r6 36 | VARDEF nrg, _r7 37 | VARDEF idx, r8 38 | 39 | .globl SYM(SKP_Silk_sum_sqr_shift) 40 | SYM(SKP_Silk_sum_sqr_shift): 41 | stmdb sp!, {r4-r8, fp, ip, lr} 42 | add fp, sp, #28 43 | mov idx, r3 44 | ands nrg_tmp, r2, #2 45 | mov nrg, #0 46 | #ifdef _WINRT 47 | beq LR(6, f) 48 | ldrh x0, [r2], #2 49 | smulbb nrg, x0, x0 50 | sub idx, idx, #1 51 | L(6) 52 | #else 53 | ldrneh x0, [r2], #2 54 | smulbbne nrg, x0, x0 55 | subne idx, idx, #1 56 | #endif 57 | 58 | ldr r4, [r2], #4 59 | mov shift, #0 60 | sub idx, idx, #1 61 | L(0) 62 | subs idx, idx, #2 63 | SKP_SMLAD nrg, x0, x0, nrg 64 | #ifdef _WINRT 65 | ldrgt x0, [r2] 66 | addgt r2, r2, #4 67 | #else 68 | ldrgt x0, [r2], #4 69 | #endif 70 | cmp nrg, #0 71 | blt LR(1, f) 72 | cmp idx, #0 73 | bgt LR(0, b) 74 | beq LR(4, f) 75 | b LR(5, f) 76 | L(1) 77 | mov nrg, nrg, lsr #2 78 | mov shift, #2 79 | cmp idx, #0 80 | beq LR(4, f) 81 | blt LR(5, f) 82 | L(3) 83 | subs idx, idx, #2 84 | SKP_SMUAD nrg_tmp, x0, x0 85 | #ifdef _WINRT 86 | ldrgt x0, [r2] 87 | addgt r2, r2, #4 88 | mov nrg_tmp, nrg_tmp, lsr shift 89 | adds nrg, nrg, nrg_tmp 90 | #else 91 | ldrgt x0, [r2], #4 92 | add nrg, nrg, nrg_tmp, lsr shift 93 | cmp nrg, #0 94 | #endif 95 | movlt nrg, nrg, lsr #2 96 | addlt shift, shift, #2 97 | cmp idx, #0 98 | bgt LR(3, b) 99 | blt LR(5, f) 100 | L(4) 101 | ldrh x0, [r2] 102 | smulbb nrg_tmp, x0, x0 103 | #ifdef _WINRT 104 | mov nrg_tmp, nrg_tmp, lsr shift 105 | add nrg, nrg, nrg_tmp 106 | #else 107 | add nrg, nrg, nrg_tmp, lsr shift 108 | #endif 109 | L(5) 110 | ands nrg_tmp, nrg, #0xC0000000 111 | movne nrg, nrg, lsr #2 112 | addne shift, shift, #2 113 | str shift, [r1] 114 | str nrg, [r0] 115 | 116 | ldmia sp!, {r4-r8, fp, ip, pc} 117 | END 118 | #endif 119 | #endif 120 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_NLSF_CB0_10.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB0_10_H 29 | #define SKP_SILK_TABLES_NLSF_CB0_10_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB0_10_STAGES 6 39 | #define NLSF_MSVQ_CB0_10_VECTORS 120 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS + NLSF_MSVQ_CB0_10_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr[ NLSF_MSVQ_CB0_10_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx[ NLSF_MSVQ_CB0_10_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_NLSF_CB0_16.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB0_16_H 29 | #define SKP_SILK_TABLES_NLSF_CB0_16_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB0_16_STAGES 10 39 | #define NLSF_MSVQ_CB0_16_VECTORS 216 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ NLSF_MSVQ_CB0_16_VECTORS + NLSF_MSVQ_CB0_16_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr[ NLSF_MSVQ_CB0_16_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx[ NLSF_MSVQ_CB0_16_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_NLSF_CB1_10.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB1_10_H 29 | #define SKP_SILK_TABLES_NLSF_CB1_10_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB1_10_STAGES 6 39 | #define NLSF_MSVQ_CB1_10_VECTORS 72 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_10_CDF[ NLSF_MSVQ_CB1_10_VECTORS + NLSF_MSVQ_CB1_10_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr[ NLSF_MSVQ_CB1_10_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx[ NLSF_MSVQ_CB1_10_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_NLSF_CB1_16.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB1_16_H 29 | #define SKP_SILK_TABLES_NLSF_CB1_16_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB1_16_STAGES 10 39 | #define NLSF_MSVQ_CB1_16_VECTORS 104 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_16_CDF[ NLSF_MSVQ_CB1_16_VECTORS + NLSF_MSVQ_CB1_16_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr[ NLSF_MSVQ_CB1_16_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx[ NLSF_MSVQ_CB1_16_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_gain.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | 35 | const SKP_uint16 SKP_Silk_gain_CDF[ 2 ][ 65 ] = 36 | { 37 | { 38 | 0, 18, 45, 94, 181, 320, 519, 777, 39 | 1093, 1468, 1909, 2417, 2997, 3657, 4404, 5245, 40 | 6185, 7228, 8384, 9664, 11069, 12596, 14244, 16022, 41 | 17937, 19979, 22121, 24345, 26646, 29021, 31454, 33927, 42 | 36438, 38982, 41538, 44068, 46532, 48904, 51160, 53265, 43 | 55184, 56904, 58422, 59739, 60858, 61793, 62568, 63210, 44 | 63738, 64165, 64504, 64769, 64976, 65133, 65249, 65330, 45 | 65386, 65424, 65451, 65471, 65487, 65501, 65513, 65524, 46 | 65535 47 | }, 48 | { 49 | 0, 214, 581, 1261, 2376, 3920, 5742, 7632, 50 | 9449, 11157, 12780, 14352, 15897, 17427, 18949, 20462, 51 | 21957, 23430, 24889, 26342, 27780, 29191, 30575, 31952, 52 | 33345, 34763, 36200, 37642, 39083, 40519, 41930, 43291, 53 | 44602, 45885, 47154, 48402, 49619, 50805, 51959, 53069, 54 | 54127, 55140, 56128, 57101, 58056, 58979, 59859, 60692, 55 | 61468, 62177, 62812, 63368, 63845, 64242, 64563, 64818, 56 | 65023, 65184, 65306, 65391, 65447, 65482, 65505, 65521, 57 | 65535 58 | } 59 | }; 60 | 61 | const SKP_int SKP_Silk_gain_CDF_offset = 32; 62 | 63 | 64 | const SKP_uint16 SKP_Silk_delta_gain_CDF[ 46 ] = { 65 | 0, 2358, 3856, 7023, 15376, 53058, 59135, 61555, 66 | 62784, 63498, 63949, 64265, 64478, 64647, 64783, 64894, 67 | 64986, 65052, 65113, 65169, 65213, 65252, 65284, 65314, 68 | 65338, 65359, 65377, 65392, 65403, 65415, 65424, 65432, 69 | 65440, 65448, 65455, 65462, 65470, 65477, 65484, 65491, 70 | 65499, 65506, 65513, 65521, 65528, 65535 71 | }; 72 | 73 | const SKP_int SKP_Silk_delta_gain_CDF_offset = 5; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_sign.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | const SKP_uint16 SKP_Silk_sign_CDF[ 36 ] = 31 | { 32 | 37840, 36944, 36251, 35304, 33 | 34715, 35503, 34529, 34296, 34 | 34016, 47659, 44945, 42503, 35 | 40235, 38569, 40254, 37851, 36 | 37243, 36595, 43410, 44121, 37 | 43127, 40978, 38845, 40433, 38 | 38252, 37795, 36637, 59159, 39 | 55630, 51806, 48073, 45036, 40 | 48416, 43857, 42678, 41146, 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /native/src/SKP_Silk_tables_type_offset.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | const SKP_uint16 SKP_Silk_type_offset_CDF[ 5 ] = { 31 | 0, 37522, 41030, 44212, 65535 32 | }; 33 | 34 | const SKP_int SKP_Silk_type_offset_CDF_offset = 2; 35 | 36 | 37 | const SKP_uint16 SKP_Silk_type_offset_joint_CDF[ 4 ][ 5 ] = 38 | { 39 | { 40 | 0, 57686, 61230, 62358, 65535 41 | }, 42 | { 43 | 0, 18346, 40067, 43659, 65535 44 | }, 45 | { 46 | 0, 22694, 24279, 35507, 65535 47 | }, 48 | { 49 | 0, 6067, 7215, 13010, 65535 50 | } 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'silk4j' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/io/github/mzdluo123/silk4j/AudioUtils.java: -------------------------------------------------------------------------------- 1 | package io.github.mzdluo123.silk4j; 2 | 3 | import java.io.*; 4 | 5 | public class AudioUtils { 6 | private static File tempDir; 7 | 8 | /** 9 | * 初始化 10 | */ 11 | public static void init() throws IOException { 12 | init(new File(System.getProperty("java.io.tmpdir"))); 13 | } 14 | 15 | public static void init(File tmpDir) throws IOException { 16 | AudioUtils.tempDir = tmpDir; 17 | if (!tempDir.canWrite()) { 18 | throw new IOException("缓存目录无写入权限,请重试"); 19 | } 20 | NativeLibLoader.load(); 21 | } 22 | 23 | public static File mp3ToSilk(File mp3File, int bitRate) throws IOException { 24 | if (!mp3File.exists() || mp3File.length() == 0) { 25 | throw new IOException("文件不存在或为空"); 26 | } 27 | File pcmFile = getTempFile("pcm"); 28 | File silkFile = getTempFile("silk"); 29 | int sampleRate = LameCoder.decode(mp3File.getAbsolutePath(), pcmFile.getAbsolutePath()); 30 | SilkCoder.encode(pcmFile.getAbsolutePath(), silkFile.getAbsolutePath(), sampleRate, bitRate); 31 | pcmFile.delete(); 32 | return silkFile; 33 | } 34 | 35 | public static File mp3ToSilk(File mp3File) throws IOException { 36 | return mp3ToSilk(mp3File,24000); 37 | } 38 | 39 | public static File mp3ToSilk(InputStream mp3FileStream, int bitRate) throws IOException { 40 | File mp3File = getTempFile("mp3"); 41 | streamToTempFile(mp3FileStream, mp3File); 42 | return mp3ToSilk(mp3File, bitRate); 43 | } 44 | 45 | public static File mp3ToSilk(InputStream mp3FileStream) throws IOException { 46 | return mp3ToSilk(mp3FileStream,24000); 47 | } 48 | 49 | public static File silkToMp3(File silkFile, int bitrate) throws IOException { 50 | if (!silkFile.exists() || silkFile.length() == 0) { 51 | throw new IOException("文件不存在或为空"); 52 | } 53 | File pcmFile = getTempFile("pcm"); 54 | File mp3File = getTempFile("mp3"); 55 | SilkCoder.decode(silkFile.getAbsolutePath(), pcmFile.getAbsolutePath()); 56 | LameCoder.encode(pcmFile.getAbsolutePath(), mp3File.getAbsolutePath(), bitrate); 57 | pcmFile.delete(); 58 | return mp3File; 59 | } 60 | 61 | public static File silkToMp3(File silkFile) throws IOException { 62 | return silkToMp3(silkFile, 24000); 63 | } 64 | 65 | public static File silkToMp3(InputStream silkFileStream, int bitrate) throws IOException { 66 | File mp3File = getTempFile("silk"); 67 | streamToTempFile(silkFileStream, mp3File); 68 | return silkToMp3(mp3File, bitrate); 69 | } 70 | 71 | public static File silkToMp3(InputStream silkFileStream) throws IOException { 72 | return silkToMp3(silkFileStream, 24000); 73 | } 74 | 75 | static void streamToTempFile(InputStream inputStream, File tmpFile) throws IOException { 76 | FileOutputStream fileOutputStream = new FileOutputStream(tmpFile); 77 | byte[] buf = new byte[1024]; 78 | int bytesRead; 79 | while ((bytesRead = inputStream.read(buf)) > 0) { 80 | fileOutputStream.write(buf, 0, bytesRead); 81 | } 82 | inputStream.close(); 83 | fileOutputStream.close(); 84 | } 85 | 86 | 87 | static File getTempFile(String type) { 88 | String fileName = "mirai_audio_" + 89 | type + 90 | "_" + 91 | System.currentTimeMillis() + 92 | "." + 93 | type; 94 | return new File(tempDir, fileName); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/io/github/mzdluo123/silk4j/NativeLibLoader.java: -------------------------------------------------------------------------------- 1 | package io.github.mzdluo123.silk4j; 2 | 3 | import java.io.*; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | 8 | public class NativeLibLoader { 9 | 10 | public static void load() throws IOException { 11 | try { 12 | // 尝试直接加载 13 | System.loadLibrary("lame"); 14 | System.loadLibrary("silk"); 15 | } catch (UnsatisfiedLinkError ignore) { 16 | 17 | try { 18 | System.loadLibrary("liblame"); 19 | System.loadLibrary("libsilk"); 20 | } catch (UnsatisfiedLinkError i) { 21 | // 失败后 22 | loadFromResources(); 23 | } 24 | } 25 | 26 | 27 | } 28 | 29 | private static void loadFromResources() throws IOException { 30 | InputStream fileListInputStream = NativeLibLoader.class.getResourceAsStream("/silk4j_libs/filelist.txt"); 31 | if (fileListInputStream == null) { 32 | throw new FileNotFoundException("未找到文件列表,请尝试从GitHub下载最新的AllInOneJar"); 33 | } 34 | InputStreamReader inputStreamReader = new InputStreamReader(fileListInputStream); 35 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 36 | List fileList = bufferedReader.lines().collect(Collectors.toList()); 37 | int successCount = 0; 38 | for (String libFile : 39 | fileList) { 40 | if (successCount >= 2) { 41 | return; 42 | } 43 | String path = copyFileToTemp(NativeLibLoader.class.getResourceAsStream(libFile.substring(1))); 44 | try { 45 | System.load(path); 46 | successCount++; 47 | } catch (UnsatisfiedLinkError ignored) { 48 | new File(path).delete(); 49 | } 50 | } 51 | if (successCount < 2) { 52 | throw new UnsatisfiedLinkError("未找到适用于当前操作系统的动态链接库,请联系作者"); 53 | } 54 | } 55 | 56 | 57 | private static String copyFileToTemp(InputStream file) throws IOException { 58 | File temp = AudioUtils.getTempFile("lib"); 59 | AudioUtils.streamToTempFile(file, temp); 60 | return temp.getAbsolutePath(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/io/github/mzdluo123/silk4j/SilkCoder.java: -------------------------------------------------------------------------------- 1 | package io.github.mzdluo123.silk4j; 2 | 3 | import java.net.URL; 4 | 5 | public class SilkCoder { 6 | static native void decode(String source, String dest, int fs_Hz, int loss); 7 | 8 | public static void decode(String source, String dest) { 9 | decode(source, dest, 24000, 0); 10 | } 11 | 12 | 13 | public static native void encode(String source, 14 | String dest, 15 | boolean tencent, 16 | int fs_Hz, 17 | int maxInternalSampleRate, 18 | int packetSize, 19 | int packetLossPercentage, 20 | int useInBandFEC, 21 | int useDTX, 22 | int complexity, 23 | int bitRate); 24 | 25 | public static void encode(String source, 26 | String dest, 27 | int sampleRate, 28 | int bitRate 29 | ) { 30 | encode(source, 31 | dest, true, 32 | sampleRate, 33 | 24000, 34 | (20 * sampleRate) / 1000, 35 | 0, 36 | 0, 37 | 0, 38 | 2, 39 | bitRate); 40 | } 41 | 42 | public static void encode(String source, 43 | String dest, 44 | int sampleRate 45 | ){ 46 | encode(source, dest, sampleRate, 24000); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/io/github/mzdluo123/silk4j/test/CoderTest.java: -------------------------------------------------------------------------------- 1 | package io.github.mzdluo123.silk4j.test; 2 | 3 | import io.github.mzdluo123.silk4j.AudioUtils; 4 | import io.github.mzdluo123.silk4j.LameCoder; 5 | import io.github.mzdluo123.silk4j.SilkCoder; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | import static org.junit.jupiter.api.Assertions.assertTrue; 13 | 14 | public class CoderTest { 15 | @BeforeEach 16 | public void init() { 17 | File dll = new File("native/cmake-build-debug/libsilk.dll"); 18 | if (!dll.exists()) { 19 | dll = new File("native/cmake-build-debug/libsilk.so"); 20 | } 21 | 22 | System.load(dll.getAbsolutePath()); 23 | 24 | dll = new File("native/cmake-build-debug/lame/liblame.dll"); 25 | if (!dll.exists()) { 26 | dll = new File("native/cmake-build-debug/lame/liblame.so"); 27 | } 28 | 29 | System.load(dll.getAbsolutePath()); 30 | } 31 | 32 | @Test 33 | public void testSilkToMp3() { 34 | SilkCoder.decode("src/test/resources/77b18b66-e4d5-4847-8c44-cad582d75ad4.silk", "out.pcm"); 35 | File outFile = new File("out.pcm"); 36 | assertTrue(outFile.exists()); 37 | } 38 | 39 | @Test 40 | public void testEncode() { 41 | SilkCoder.encode("src/test/resources/out.pcm", "silk.amr", 16000); 42 | File outFile = new File("silk.amr"); 43 | assertTrue(outFile.exists()); 44 | 45 | } 46 | 47 | @Test 48 | public void testEncodeMp3() throws IOException { 49 | LameCoder.encode("src/test/resources/out.pcm", "silk.mp3", 16000); 50 | File outFile = new File("silk.mp3"); 51 | assertTrue(outFile.exists()); 52 | 53 | } 54 | 55 | @Test 56 | public void testDecodeMp3() throws IOException { 57 | LameCoder.decode("src/test/resources/silk.mp3", "decode.pcm"); 58 | File outFile = new File("decode.pcm"); 59 | assertTrue(outFile.exists()); 60 | } 61 | 62 | // @Test 63 | // public void testMp3ToSilk() throws IOException { 64 | // File outFile = AudioUtils.mp3ToSilk(new File("src/test/resources/tts.mp3")); 65 | // assertTrue(outFile.exists()); 66 | // } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/resources/77b18b66-e4d5-4847-8c44-cad582d75ad4.silk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/src/test/resources/77b18b66-e4d5-4847-8c44-cad582d75ad4.silk -------------------------------------------------------------------------------- /src/test/resources/out.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/src/test/resources/out.pcm -------------------------------------------------------------------------------- /src/test/resources/silk.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mzdluo123/silk4j/3d6f8ebb3d5d00055813ab9a693dee7b10f1184f/src/test/resources/silk.mp3 --------------------------------------------------------------------------------