├── .cproject ├── .project ├── .travis.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── LICENSE_PLEASE_READ.txt ├── Makefile.am ├── Makefile.in ├── Makefile.mips ├── Makefile.unix ├── NEWS ├── Profiling ├── tracer_profiling.c └── tracer_profiling.h ├── README ├── README.draft ├── README.md ├── _config.yml ├── aclocal.m4 ├── appveyor.yml ├── autogen.sh ├── celt ├── _kiss_fft_guts.h ├── arch.h ├── arm │ ├── arm2gnu.pl │ ├── arm_celt_map.c │ ├── arm_celt_mapv1.c │ ├── armcpu.c │ ├── armcpu.h │ ├── armcpuv2.c │ ├── armcpuv2.h │ ├── armopts-gnu.S │ ├── armopts.s.in │ ├── celt_armv7e_fft.c │ ├── celt_armv7e_intr.h │ ├── celt_armv7e_mdct.c │ ├── celt_ne10_fft.c │ ├── celt_ne10_mdct.c │ ├── celt_neon_intr.c │ ├── celt_pitch_xcorr_arm-gnu.S │ ├── celt_pitch_xcorr_arm-gnu2.S │ ├── celt_pitch_xcorr_arm.s │ ├── fft_arm.h │ ├── fixed_arm64.h │ ├── fixed_armv4.h │ ├── fixed_armv5e.h │ ├── fixed_armv7e.h │ ├── kiss_fft_armv4.h │ ├── kiss_fft_armv5e.h │ ├── kiss_fft_armv7e.h │ ├── mdct_arm.h │ └── pitch_arm.h ├── bands.c ├── bands.h ├── celt.c ├── celt.h ├── celt_decoder.c ├── celt_encoder.c ├── celt_lpc.c ├── celt_lpc.h ├── cpu_support.h ├── cwrs.c ├── cwrs.h ├── dump_modes │ ├── Makefile │ ├── dump_modes.c │ ├── dump_modes_arch.h │ └── dump_modes_arm_ne10.c ├── ecintrin.h ├── entcode.c ├── entcode.h ├── entdec.c ├── entdec.h ├── entenc.c ├── entenc.h ├── fixed_c5x.h ├── fixed_c6x.h ├── fixed_debug.h ├── fixed_generic.h ├── float_cast.h ├── kiss_fft.c ├── kiss_fft.h ├── laplace.c ├── laplace.h ├── mathops.c ├── mathops.h ├── mathops_armv7e.c ├── mathops_armv7e.h ├── mdct.c ├── mdct.h ├── mfrngcod.h ├── mips │ ├── celt_mipsr1.h │ ├── fixed_generic_mipsr1.h │ ├── kiss_fft_mipsr1.h │ ├── mdct_mipsr1.h │ ├── pitch_mipsr1.h │ └── vq_mipsr1.h ├── modes.c ├── modes.h ├── opus_custom_demo.c ├── os_support.h ├── pitch.c ├── pitch.h ├── quant_bands.c ├── quant_bands.h ├── rate.c ├── rate.h ├── stack_alloc.h ├── static_modes_fixed.h ├── static_modes_fixed_arm_ne10.h ├── static_modes_fixed_armv7e.h ├── static_modes_float.h ├── static_modes_float_arm_ne10.h ├── tests │ ├── test_unit_cwrs32.c │ ├── test_unit_dft.c │ ├── test_unit_entropy.c │ ├── test_unit_laplace.c │ ├── test_unit_mathops.c │ ├── test_unit_mdct.c │ ├── test_unit_rotation.c │ └── test_unit_types.c ├── vq.c ├── vq.h └── x86 │ ├── celt_lpc_sse.c │ ├── celt_lpc_sse.h │ ├── pitch_sse.c │ ├── pitch_sse.h │ ├── pitch_sse2.c │ ├── pitch_sse4_1.c │ ├── vq_sse.h │ ├── vq_sse2.c │ ├── x86_celt_map.c │ ├── x86cpu.c │ └── x86cpu.h ├── celt_headers.mk ├── celt_sources.mk ├── compile ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── doc ├── Doxyfile.in ├── Makefile.am ├── Makefile.in ├── TODO ├── build_draft.sh ├── build_isobmff.sh ├── build_oggdraft.sh ├── customdoxygen.css ├── draft-ietf-codec-oggopus.xml ├── draft-ietf-codec-opus-update.xml ├── draft-ietf-codec-opus.xml ├── draft-ietf-payload-rtp-opus.xml ├── footer.html ├── header.html ├── opus_in_isobmff.css ├── opus_in_isobmff.html ├── opus_logo.svg ├── opus_update.patch ├── release.txt └── trivial_example.c ├── include ├── config.h ├── opus.h ├── opus_custom.h ├── opus_defines.h ├── opus_multistream.h └── opus_types.h ├── install-sh ├── ltmain.sh ├── m4 ├── as-gcc-inline-assembly.m4 ├── libtool.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 ├── lt~obsolete.m4 └── opus-intrinsics.m4 ├── missing ├── opus-uninstalled.pc.in ├── opus.m4 ├── opus.pc.in ├── opus_headers.mk ├── opus_sources.mk ├── package_version ├── releases.sha2 ├── silk ├── A2NLSF.c ├── API.h ├── CNG.c ├── HP_variable_cutoff.c ├── Inlines.h ├── LPC_analysis_filter.c ├── LPC_fit.c ├── LPC_inv_pred_gain.c ├── LP_variable_cutoff.c ├── MacroCount.h ├── MacroDebug.h ├── NLSF2A.c ├── NLSF_VQ.c ├── NLSF_VQ_weights_laroia.c ├── NLSF_decode.c ├── NLSF_del_dec_quant.c ├── NLSF_encode.c ├── NLSF_stabilize.c ├── NLSF_unpack.c ├── NSQ.c ├── NSQ.h ├── NSQ_del_dec.c ├── PLC.c ├── PLC.h ├── SigProc_FIX.h ├── VAD.c ├── VQ_WMat_EC.c ├── ana_filt_bank_1.c ├── arm │ ├── LPC_inv_pred_gain_arm.h │ ├── LPC_inv_pred_gain_neon_intr.c │ ├── NSQ_del_dec_arm.h │ ├── NSQ_del_dec_neon_intr.c │ ├── NSQ_neon.c │ ├── NSQ_neon.h │ ├── SigProc_FIX_armv4.h │ ├── SigProc_FIX_armv5e.h │ ├── arm_silk_map.c │ ├── macros_arm64.h │ ├── macros_armv4.h │ └── macros_armv5e.h ├── biquad_alt.c ├── bwexpander.c ├── bwexpander_32.c ├── check_control_input.c ├── code_signs.c ├── control.h ├── control_SNR.c ├── control_audio_bandwidth.c ├── control_codec.c ├── debug.c ├── debug.h ├── dec_API.c ├── decode_core.c ├── decode_frame.c ├── decode_indices.c ├── decode_parameters.c ├── decode_pitch.c ├── decode_pulses.c ├── decoder_set_fs.c ├── define.h ├── enc_API.c ├── encode_indices.c ├── encode_pulses.c ├── errors.h ├── fixed │ ├── LTP_analysis_filter_FIX.c │ ├── LTP_scale_ctrl_FIX.c │ ├── apply_sine_window_FIX.c │ ├── autocorr_FIX.c │ ├── burg_modified_FIX.c │ ├── corrMatrix_FIX.c │ ├── encode_frame_FIX.c │ ├── find_LPC_FIX.c │ ├── find_LTP_FIX.c │ ├── find_pitch_lags_FIX.c │ ├── find_pred_coefs_FIX.c │ ├── k2a_FIX.c │ ├── k2a_Q16_FIX.c │ ├── main_FIX.h │ ├── mips │ │ ├── noise_shape_analysis_FIX_mipsr1.h │ │ ├── prefilter_FIX_mipsr1.h │ │ └── warped_autocorrelation_FIX_mipsr1.h │ ├── noise_shape_analysis_FIX.c │ ├── pitch_analysis_core_FIX.c │ ├── prefilter_FIX.c │ ├── process_gains_FIX.c │ ├── regularize_correlations_FIX.c │ ├── residual_energy16_FIX.c │ ├── residual_energy_FIX.c │ ├── schur64_FIX.c │ ├── schur_FIX.c │ ├── solve_LS_FIX.c │ ├── structs_FIX.h │ ├── vector_ops_FIX.c │ ├── warped_autocorrelation_FIX.c │ └── x86 │ │ ├── burg_modified_FIX_sse.c │ │ ├── prefilter_FIX_sse.c │ │ └── vector_ops_FIX_sse.c ├── float │ ├── LPC_analysis_filter_FLP.c │ ├── LPC_inv_pred_gain_FLP.c │ ├── LTP_analysis_filter_FLP.c │ ├── LTP_scale_ctrl_FLP.c │ ├── SigProc_FLP.h │ ├── apply_sine_window_FLP.c │ ├── autocorrelation_FLP.c │ ├── burg_modified_FLP.c │ ├── bwexpander_FLP.c │ ├── corrMatrix_FLP.c │ ├── encode_frame_FLP.c │ ├── energy_FLP.c │ ├── find_LPC_FLP.c │ ├── find_LTP_FLP.c │ ├── find_pitch_lags_FLP.c │ ├── find_pred_coefs_FLP.c │ ├── inner_product_FLP.c │ ├── k2a_FLP.c │ ├── levinsondurbin_FLP.c │ ├── main_FLP.h │ ├── noise_shape_analysis_FLP.c │ ├── pitch_analysis_core_FLP.c │ ├── prefilter_FLP.c │ ├── process_gains_FLP.c │ ├── regularize_correlations_FLP.c │ ├── residual_energy_FLP.c │ ├── scale_copy_vector_FLP.c │ ├── scale_vector_FLP.c │ ├── schur_FLP.c │ ├── solve_LS_FLP.c │ ├── sort_FLP.c │ ├── structs_FLP.h │ ├── warped_autocorrelation_FLP.c │ └── wrappers_FLP.c ├── gain_quant.c ├── init_decoder.c ├── init_encoder.c ├── inner_prod_aligned.c ├── interpolate.c ├── lin2log.c ├── log2lin.c ├── macros.h ├── main.h ├── mips │ ├── NSQ_del_dec_mipsr1.h │ ├── macros_mipsr1.h │ └── sigproc_fix_mipsr1.h ├── pitch_est_defines.h ├── pitch_est_tables.c ├── process_NLSFs.c ├── quant_LTP_gains.c ├── resampler.c ├── resampler_down2.c ├── resampler_down2_3.c ├── resampler_private.h ├── resampler_private_AR2.c ├── resampler_private_IIR_FIR.c ├── resampler_private_down_FIR.c ├── resampler_private_up2_HQ.c ├── resampler_rom.c ├── resampler_rom.h ├── resampler_structs.h ├── shell_coder.c ├── sigm_Q15.c ├── sort.c ├── stereo_LR_to_MS.c ├── stereo_MS_to_LR.c ├── stereo_decode_pred.c ├── stereo_encode_pred.c ├── stereo_find_predictor.c ├── stereo_quant_pred.c ├── structs.h ├── sum_sqr_shift.c ├── table_LSF_cos.c ├── tables.h ├── tables_LTP.c ├── tables_NLSF_CB_NB_MB.c ├── tables_NLSF_CB_WB.c ├── tables_gain.c ├── tables_other.c ├── tables_pitch_lag.c ├── tables_pulses_per_block.c ├── tests │ └── test_unit_LPC_inv_pred_gain.c ├── tuning_parameters.h ├── typedef.h └── x86 │ ├── NSQ_del_dec_sse.c │ ├── NSQ_sse.c │ ├── SigProc_FIX_sse.h │ ├── VAD_sse.c │ ├── VQ_WMat_EC_sse.c │ ├── main_sse.h │ └── x86_silk_map.c ├── silk_headers.mk ├── silk_sources.mk ├── src ├── analysis.c ├── analysis.h ├── mlp.c ├── mlp.h ├── mlp_data.c ├── mlp_train.c ├── mlp_train.h ├── opus.c ├── opus_compare.c ├── opus_decoder.c ├── opus_demo.c ├── opus_encoder.c ├── opus_multistream.c ├── opus_multistream_decoder.c ├── opus_multistream_encoder.c ├── opus_private.h ├── repacketizer.c ├── repacketizer_demo.c └── tansig_table.h ├── test-driver ├── tests ├── opus_decode_fuzzer.c ├── opus_decode_fuzzer.options ├── opus_encode_regressions.c ├── run_vectors.sh ├── test_opus_api.c ├── test_opus_common.h ├── test_opus_decode.c ├── test_opus_encode.c └── test_opus_padding.c ├── version.mk └── win32 ├── VS2010 ├── celt.vcxproj ├── celt.vcxproj.filters ├── opus.sln ├── opus.vcxproj ├── opus.vcxproj.filters ├── opus_demo.vcxproj ├── opus_demo.vcxproj.filters ├── silk_common.vcxproj ├── silk_common.vcxproj.filters ├── silk_fixed.vcxproj ├── silk_fixed.vcxproj.filters ├── silk_float.vcxproj ├── silk_float.vcxproj.filters ├── test_opus_api.vcxproj ├── test_opus_api.vcxproj.filters ├── test_opus_decode.vcxproj ├── test_opus_decode.vcxproj.filters ├── test_opus_encode.vcxproj └── test_opus_encode.vcxproj.filters ├── VS2015 ├── common.props ├── opus.sln ├── opus.vcxproj ├── opus.vcxproj.filters ├── opus_demo.vcxproj ├── opus_demo.vcxproj.filters ├── test_opus_api.vcxproj ├── test_opus_api.vcxproj.filters ├── test_opus_decode.vcxproj ├── test_opus_decode.vcxproj.filters ├── test_opus_encode.vcxproj └── test_opus_encode.vcxproj.filters ├── config.h └── genversion.bat /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Opus_ST 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | compiler: 4 | - gcc 5 | - clang 6 | 7 | os: 8 | - linux 9 | - osx 10 | 11 | env: 12 | - CONFIG="" 13 | - CONFIG="--enable-assertions" 14 | - CONFIG="--enable-fixed-point" 15 | - CONFIG="--enable-fixed-point --disable-float-api" 16 | - CONFIG="--enable-fixed-point --enable-assertions" 17 | 18 | script: 19 | - ./autogen.sh 20 | - ./configure $CONFIG 21 | - make distcheck 22 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin (jmvalin@jmvalin.ca) 2 | Koen Vos (koenvos74@gmail.com) 3 | Timothy Terriberry (tterribe@xiph.org) 4 | Karsten Vandborg Sorensen (karsten.vandborg.sorensen@skype.net) 5 | Soren Skak Jensen (ssjensen@gn.com) 6 | Gregory Maxwell (greg@xiph.org) 7 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, 2 | Jean-Marc Valin, Timothy B. Terriberry, 3 | CSIRO, Gregory Maxwell, Mark Borgerding, 4 | Erik de Castro Lopo 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 18 | names of specific contributors, may be used to endorse or promote 19 | products derived from this software without specific prior written 20 | permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 26 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | Opus is subject to the royalty-free patent licenses which are 35 | specified at: 36 | 37 | Xiph.Org Foundation: 38 | https://datatracker.ietf.org/ipr/1524/ 39 | 40 | Microsoft Corporation: 41 | https://datatracker.ietf.org/ipr/1914/ 42 | 43 | Broadcom Corporation: 44 | https://datatracker.ietf.org/ipr/1526/ 45 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Daparrag/Opus_CotexM4_microcontroller/7023730ce5f8e0ba662acbbb739714829fa63d21/ChangeLog -------------------------------------------------------------------------------- /LICENSE_PLEASE_READ.txt: -------------------------------------------------------------------------------- 1 | Contributions to the collaboration shall not be considered confidential. 2 | 3 | Each contributor represents and warrants that it has the right and 4 | authority to license copyright in its contributions to the collaboration. 5 | 6 | Each contributor agrees to license the copyright in the contributions 7 | under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License. 8 | 9 | Please see the IPR statements submitted to the IETF for the complete 10 | patent licensing details: 11 | 12 | Xiph.Org Foundation: 13 | https://datatracker.ietf.org/ipr/1524/ 14 | 15 | Microsoft Corporation: 16 | https://datatracker.ietf.org/ipr/1914/ 17 | 18 | Skype Limited: 19 | https://datatracker.ietf.org/ipr/1602/ 20 | 21 | Broadcom Corporation: 22 | https://datatracker.ietf.org/ipr/1526/ 23 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Daparrag/Opus_CotexM4_microcontroller/7023730ce5f8e0ba662acbbb739714829fa63d21/NEWS -------------------------------------------------------------------------------- /Profiling/tracer_profiling.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file tracer_profiling.h 4 | * @author Central Lab 5 | * @version V1.0.0 6 | * @date 28-January-2016 7 | * @brief Header for codec_profiling.c module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | 30 | /* Define to prevent recursive inclusion -------------------------------------*/ 31 | #ifndef __TRACER_PROFILING_H 32 | #define __TRACER_PROFILING_H 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "main_usb.h" 35 | #include "cube_hal.h" 36 | #include "stm32xx_it.h" 37 | 38 | #define PROF_ON 1 39 | #define PROF_OFF 0 40 | #define PROF_BUSY 2 41 | 42 | #define MAX_ENTRIES 10 43 | 44 | struct profile { 45 | int state; 46 | int already_setup; 47 | }; 48 | 49 | struct profile_fun{ 50 | int16_t num_child; 51 | int32_t deph_level; 52 | void* fun_addrs; 53 | int cycles; 54 | int16_t count; 55 | void* parent_addrs; 56 | struct profile_fun *next_fun[MAX_ENTRIES]; 57 | }; 58 | 59 | extern struct profile _profparam; 60 | 61 | 62 | 63 | 64 | /* Private define ------------------------------------------------------------*/ 65 | /* Private macro -------------------------------------------------------------*/ 66 | /* Private typedef -----------------------------------------------------------*/ 67 | /* Private variables ---------------------------------------------------------*/ 68 | void __attribute__ ((constructor,no_instrument_function)) trace_begin (void); 69 | void __attribute__ ((destructor,no_instrument_function)) trace_end(void); 70 | void __attribute__ ((no_instrument_function)) __cyg_profile_func_enter(void *func, void *caller); 71 | void __attribute__ ((no_instrument_function)) __cyg_profile_func_exit(void *func, void *caller); 72 | void __attribute__ ((no_instrument_function)) start_profile(int start); 73 | void __attribute__ ((no_instrument_function)) Error_profile(void); 74 | 75 | #endif /* __TRACER_PROFILING_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /README.draft: -------------------------------------------------------------------------------- 1 | To build this source code, simply type: 2 | 3 | % make 4 | 5 | If this does not work, or if you want to change the default configuration 6 | (e.g., to compile for a fixed-point architecture), simply edit the options 7 | in the Makefile. 8 | 9 | An up-to-date implementation conforming to this standard is available in a 10 | Git repository at https://git.xiph.org/opus.git or on a website at: 11 | https://opus-codec.org/ 12 | However, although that implementation is expected to remain conformant 13 | with the standard, it is the code in this RFC that shall remain normative. 14 | To build from the git repository instead of using this RFC, follow these 15 | steps: 16 | 17 | 1) Clone the repository (latest implementation of this standard at the time 18 | of publication) 19 | 20 | % git clone https://git.xiph.org/opus.git 21 | % cd opus 22 | 23 | 2) Compile 24 | 25 | % ./autogen.sh 26 | % ./configure 27 | % make 28 | 29 | Once you have compiled the codec, there will be a opus_demo executable in 30 | the top directory. 31 | 32 | Usage: opus_demo [-e] 33 | [options] 34 | opus_demo -d [options] 35 | 36 | 37 | mode: voip | audio | restricted-lowdelay 38 | options: 39 | -e : only runs the encoder (output the bit-stream) 40 | -d : only runs the decoder (reads the bit-stream as input) 41 | -cbr : enable constant bitrate; default: variable bitrate 42 | -cvbr : enable constrained variable bitrate; default: unconstrained 43 | -bandwidth : audio bandwidth (from narrowband to fullband); 44 | default: sampling rate 45 | -framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 46 | -max_payload : maximum payload size in bytes, default: 1024 47 | -complexity : complexity, 0 (lowest) ... 10 (highest); default: 10 48 | -inbandfec : enable SILK inband FEC 49 | -forcemono : force mono encoding, even for stereo input 50 | -dtx : enable SILK DTX 51 | -loss : simulate packet loss, in percent (0-100); default: 0 52 | 53 | input and output are little endian signed 16-bit PCM files or opus bitstreams 54 | with simple opus_demo proprietary framing. 55 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2015 2 | configuration: 3 | - Debug 4 | - DebugDLL 5 | - DebugDLL_fixed 6 | - Release 7 | - ReleaseDLL 8 | - ReleaseDLL_fixed 9 | 10 | platform: 11 | - Win32 12 | - x64 13 | 14 | build: 15 | project: win32\VS2015\opus.sln 16 | parallel: true 17 | verbosity: minimal 18 | 19 | after_build: 20 | - cmd: >- 21 | mkdir %APPVEYOR_BUILD_FOLDER%\artifacts 22 | 23 | cd %APPVEYOR_BUILD_FOLDER%\win32\VS2015\%PLATFORM%\%CONFIGURATION% 24 | 25 | for %%a in (lib dll exp pdb) do if exist opus.%%a copy opus.%%a %APPVEYOR_BUILD_FOLDER%\artifacts\ 26 | 27 | cd %APPVEYOR_BUILD_FOLDER% 28 | 29 | 7z a opus.zip .\artifacts\* include\*.h 30 | 31 | test_script: 32 | - cmd: >- 33 | cd %APPVEYOR_BUILD_FOLDER%\win32\VS2015\%PLATFORM%\%CONFIGURATION% 34 | 35 | test_opus_api.exe 36 | 37 | test_opus_decode.exe 38 | 39 | test_opus_encode.exe 40 | 41 | artifacts: 42 | - path: opus.zip 43 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2010-2015 Xiph.Org Foundation and contributors. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the COPYING file. 5 | 6 | # Run this to set up the build system: configure, makefiles, etc. 7 | set -e 8 | 9 | srcdir=`dirname $0` 10 | test -n "$srcdir" && cd "$srcdir" 11 | 12 | echo "Updating build configuration files, please wait...." 13 | 14 | autoreconf -isf 15 | -------------------------------------------------------------------------------- /celt/arm/armcpuv2.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Xiph.Org Foundation 2 | * Copyright (c) 2013 Parrot */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #if !defined(ARMCPU_H) 30 | # define ARMCPU_H 31 | 32 | 33 | # if defined(OPUS_ARM_MAY_HAVE_EDSP) 34 | # define MAY_HAVE_EDSP(name) name ## _edsp //this "##" puts two token together in this case the tokens & <_edsp> 35 | # else 36 | # define MAY_HAVE_EDSP(name) name ## _c 37 | # endif 38 | 39 | # if defined(OPUS_ARM_MAY_HAVE_MEDIA) 40 | # define MAY_HAVE_MEDIA(name) name ## _media 41 | # else 42 | # define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) 43 | # endif 44 | 45 | # if defined(OPUS_ARM_MAY_HAVE_NEON) 46 | # define MAY_HAVE_NEON(name) name ## _neon 47 | # else 48 | # define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) 49 | # endif 50 | 51 | # if defined(OPUS_ARM_PRESUME_EDSP) 52 | # define PRESUME_EDSP(name) name ## _edsp 53 | # else 54 | # define PRESUME_EDSP(name) name ## _c 55 | # endif 56 | 57 | # if defined(OPUS_ARM_PRESUME_MEDIA) 58 | # define PRESUME_MEDIA(name) name ## _media 59 | # else 60 | # define PRESUME_MEDIA(name) PRESUME_EDSP(name) 61 | # endif 62 | 63 | # if defined(OPUS_ARM_PRESUME_NEON) 64 | # define PRESUME_NEON(name) name ## _neon 65 | # else 66 | # define PRESUME_NEON(name) PRESUME_MEDIA(name) 67 | # endif 68 | 69 | 70 | 71 | # if defined(OPUS_HAVE_RTCD) 72 | int opus_select_arch(void); 73 | 74 | #define OPUS_ARCH_ARM_V4 (0) 75 | #define OPUS_ARCH_ARM_EDSP (1) 76 | #define OPUS_ARCH_ARM_MEDIA (2) 77 | #define OPUS_ARCH_ARM_NEON (3) 78 | # endif 79 | 80 | # if defined(OPUS_HAVE_CORTEX_M)/*new_D*/ 81 | int opus_select_arch(void); 82 | #define OPUS_ARCH_ARM_ARM6M (4) 83 | #define OPUS_ARCH_ARM_ARM7M (5) 84 | #define OPUS_ARCH_ARM_ARMv7E (6) /*include for support ARMv7E-M architecture*/ 85 | 86 | # endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /celt/arm/armopts-gnu.S: -------------------------------------------------------------------------------- 1 | .syntax unified 2 | /* Copyright (C) 2013 Mozilla Corporation */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | @ Set the following to 1 if we have EDSP instructions 29 | @ (LDRD/STRD, etc., ARMv5E and later). 30 | .set OPUS_ARM_MAY_HAVE_EDSP, 0 31 | 32 | @ Set the following to 1 if we have ARMv6 media instructions. 33 | .set OPUS_ARM_MAY_HAVE_MEDIA, 0 34 | 35 | @ Set the following to 1 if we have NEON (some ARMv7) 36 | .set OPUS_ARM_MAY_HAVE_NEON, 0 37 | 38 | @ Set the following to 1 if we have CORTEX_M4 (some ARMv7E-M)/*New_D*/ 39 | .set USE_CORTEX_M4, 1 40 | @ END: 41 | -------------------------------------------------------------------------------- /celt/arm/armopts.s.in: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2013 Mozilla Corporation */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | ; Set the following to 1 if we have EDSP instructions 28 | ; (LDRD/STRD, etc., ARMv5E and later). 29 | OPUS_ARM_MAY_HAVE_EDSP * @OPUS_ARM_MAY_HAVE_EDSP@ 30 | 31 | ; Set the following to 1 if we have ARMv6 media instructions. 32 | OPUS_ARM_MAY_HAVE_MEDIA * @OPUS_ARM_MAY_HAVE_MEDIA@ 33 | 34 | ; Set the following to 1 if we have NEON (some ARMv7) 35 | OPUS_ARM_MAY_HAVE_NEON * @OPUS_ARM_MAY_HAVE_NEON@ 36 | 37 | ; Set the following to 1 if we have CORTEX_M4 (some ARMv7E-M)/*New_D*/ 38 | USE_CORTEX_M4 * @USE_CORTEX_M4@ 39 | END 40 | -------------------------------------------------------------------------------- /celt/arm/celt_armv7e_intr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * celt_armv7e_intr.h 3 | * 4 | * Created on: Nov 2, 2017 5 | * Author: Homer 6 | */ 7 | 8 | #ifndef CELT_ARMV7E_INTR_H_ 9 | #define CELT_ARMV7E_INTR_H_ 10 | 11 | 12 | #include "arm_math.h" 13 | 14 | /** saturate a 32-bits signed value */ 15 | #undef SATURATE 16 | static OPUS_INLINE opus_val32 SATURATE_armv7e (opus_val32 value, opus_val8 sat) 17 | { 18 | return __SSAT(value,sat); 19 | } 20 | 21 | #define SATURATE (x,a) (SATURATE_armv7e(x,a)) 22 | 23 | #undef SATURATE 24 | 25 | /** sum two 16-bits signed values in parallel */ 26 | #undef ADD2_16 27 | static OPUS_INLINE opus_val32 ADD2_16_armv7e (opus_val32 val_a, opus_val32 val_b) 28 | { 29 | return __SADD16(val_a,val_b); 30 | } 31 | 32 | #define ADD2_16(a,b) (ADD2_16_armv7e(a,b)) 33 | 34 | /** Subtract two 16-bits signed values in parallel */ 35 | #undef SUB2_16(a,b) 36 | static OPUS_INLINE opus_val32 SUB2_16_armv7e (opus_val32 val_a, opus_val32 val_b) 37 | { 38 | return __SSUB16(a,b); 39 | } 40 | #define SUB2_16(a,b) ( SUB2_16_armv7e(a,b)) 41 | 42 | 43 | 44 | /** 45 | * @brief This function enables to exchange two halfwords of one operand and perform one 16-bit 46 | * integer subtraction 47 | * @param opus_val32 val1: first operand for the addition in the low halfword, 48 | * and the first operand for the subtraction in the high halfword. 49 | * @param opus_val32 val2: second operand for the addition in the high halfword, 50 | * and the second operand for the subtraction in the low halfword. 51 | * @retval opus_val32 res : res[15:0]= val1[15:0] + val2[31:16] 52 | * res[15:0]= val1[31:16] - val2[15:0] 53 | */ 54 | #undef ADD_SUB_H 55 | static OPUS_INLINE opus_val32 ADD_SUB_H_armv7e (opus_val32 val1, opus_val32 val2) 56 | { 57 | return __SSAX(a,b); 58 | } 59 | #define ADD_SUB_H(a,b) (ADD_SUB_H_armv7e(a,b)) 60 | 61 | /** 62 | * @brief This function enables to exchange two halfwords of the second operand, add the high halfwords 63 | * and subtract the low halfword 64 | * @param opus_val32 val1: first operand for the subtraction in the high halfword, 65 | * and the first operand for the addition in the lower halfword. 66 | * @param opus_val32 val2: second operand for the subtraction in the high halfword, 67 | * and the second operand for the addition in the low halfword. 68 | * @retval opus_val32 res : res[15:0]= val1[15:0] - val2[31:16] 69 | * res[15:0]= val1[31:16] + val2[15:0] 70 | */ 71 | #undef SUB_ADD_H 72 | static OPUS_INLINE opus_val32 SUB_ADD_H_armv7e (opus_val32 val1, opus_val32 val2) 73 | { 74 | return __UASX(a,b); 75 | } 76 | 77 | #define SUB_ADD_H(a,b) (SUB_ADD_H_armv7e(a,b)) 78 | 79 | 80 | 81 | 82 | 83 | /**This function counts The number of leading zeros of a data value */ 84 | #undef EC_CLZ 85 | static OPUS_INLINE opus_val32 EC_CLZ_armv7e (opus_val32 _x) 86 | { 87 | return __CLZ(_x); 88 | } 89 | #define EC_CLZ(_x) (EC_CLZ_armv7e(_x)) 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | #endif /* CELT_ARMV7E_INTR_H_ */ 100 | -------------------------------------------------------------------------------- /celt/arm/fixed_arm64.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2015 Vidyo */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef FIXED_ARM64_H 28 | #define FIXED_ARM64_H 29 | 30 | #include 31 | 32 | #undef SIG2WORD16 33 | #define SIG2WORD16(x) (vqmovns_s32(PSHR32((x), SIG_SHIFT))) 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /celt/arm/fixed_armv4.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2013 Xiph.Org Foundation and contributors */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef FIXED_ARMv4_H 28 | #define FIXED_ARMv4_H 29 | 30 | /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ 31 | #undef MULT16_32_Q16 32 | static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) 33 | { 34 | unsigned rd_lo; 35 | int rd_hi; 36 | __asm__( 37 | "#MULT16_32_Q16\n\t" 38 | "smull %0, %1, %2, %3\n\t" 39 | : "=&r"(rd_lo), "=&r"(rd_hi) 40 | : "%r"(b),"r"(SHL32(a,16)) 41 | ); 42 | return rd_hi; 43 | } 44 | #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv4(a, b)) 45 | 46 | 47 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 48 | #undef MULT16_32_Q15 49 | static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) 50 | { 51 | unsigned rd_lo; 52 | int rd_hi; 53 | __asm__( 54 | "#MULT16_32_Q15\n\t" 55 | "smull %0, %1, %2, %3\n\t" 56 | : "=&r"(rd_lo), "=&r"(rd_hi) 57 | : "%r"(b), "r"(SHL32(a,16)) 58 | ); 59 | /*We intentionally don't OR in the high bit of rd_lo for speed.*/ 60 | return SHL32(rd_hi,1); 61 | } 62 | #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv4(a, b)) 63 | 64 | 65 | /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add. 66 | b must fit in 31 bits. 67 | Result fits in 32 bits. */ 68 | #undef MAC16_32_Q15 69 | #define MAC16_32_Q15(c, a, b) ADD32(c, MULT16_32_Q15(a, b)) 70 | 71 | /** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. 72 | Result fits in 32 bits. */ 73 | #undef MAC16_32_Q16 74 | #define MAC16_32_Q16(c, a, b) ADD32(c, MULT16_32_Q16(a, b)) 75 | 76 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ 77 | #undef MULT32_32_Q31 78 | #define MULT32_32_Q31(a,b) (opus_val32)((((opus_int64)(a)) * ((opus_int64)(b)))>>31) 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /celt/arm/kiss_fft_armv7e.h: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2013, Xiph.Org Foundation and contributors. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE.*/ 25 | 26 | #ifndef KISS_FFT_ARMv7E_H 27 | #define KISS_FFT_ARMv7E_H 28 | 29 | #ifdef HAVE_CONFIG_H /*new_D*/ 30 | #include "config.h" 31 | #endif 32 | 33 | #include "kiss_fft_armv5e.h" 34 | /*Complex Multiplication*/ 35 | void C_MUL32_armv7e(opus_val32 * in_cplxA, opus_val32 * in_cplxB, opus_val32 out_dest, opus_val32 nsamples){ 36 | 37 | } 38 | /*Complex Conjugates input vector*/ 39 | void CPLX_CONJ_armv7e(opus_val32 * in_cplxA,opus_val32 * dest_vect,opus_val32 nsamples){ 40 | 41 | } 42 | 43 | 44 | 45 | #endif /*KISS_FFT_ARMv7E_H*/ 46 | -------------------------------------------------------------------------------- /celt/celt_lpc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009-2010 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PLC_H 29 | #define PLC_H 30 | 31 | #include "arch.h" 32 | #include "cpu_support.h" 33 | 34 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) 35 | #include "x86/celt_lpc_sse.h" 36 | #endif 37 | 38 | #define LPC_ORDER 24 39 | 40 | void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); 41 | 42 | void celt_fir_c( 43 | const opus_val16 *x, 44 | const opus_val16 *num, 45 | opus_val16 *y, 46 | int N, 47 | int ord, 48 | opus_val16 *mem, 49 | int arch); 50 | 51 | #if !defined(OVERRIDE_CELT_FIR) 52 | #define celt_fir(x, num, y, N, ord, mem, arch) \ 53 | (celt_fir_c(x, num, y, N, ord, mem, arch)) 54 | #endif 55 | 56 | void celt_iir(const opus_val32 *x, 57 | const opus_val16 *den, 58 | opus_val32 *y, 59 | int N, 60 | int ord, 61 | opus_val16 *mem, 62 | int arch); 63 | 64 | int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, 65 | const opus_val16 *window, int overlap, int lag, int n, int arch); 66 | 67 | #endif /* PLC_H */ 68 | -------------------------------------------------------------------------------- /celt/cpu_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Xiph.Org Foundation 2 | * Copyright (c) 2013 Parrot */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef CPU_SUPPORT_H 29 | #define CPU_SUPPORT_H 30 | 31 | #include "opus_types.h" 32 | #include "opus_defines.h" 33 | 34 | #if defined(OPUS_HAVE_RTCD) && \ 35 | (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) 36 | #include "arm/armcpu.h" 37 | 38 | /* We currently support 4 ARM variants: 39 | * arch[0] -> ARMv4 40 | * arch[1] -> ARMv5E 41 | * arch[2] -> ARMv6 42 | * arch[3] -> NEON 43 | */ 44 | #define OPUS_ARCHMASK 3 45 | 46 | #elif (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ 47 | (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ 48 | (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ 49 | (defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)) 50 | 51 | #include "x86/x86cpu.h" 52 | /* We currently support 5 x86 variants: 53 | * arch[0] -> non-sse 54 | * arch[1] -> sse 55 | * arch[2] -> sse2 56 | * arch[3] -> sse4.1 57 | * arch[4] -> avx 58 | */ 59 | #define OPUS_ARCHMASK 7 60 | int opus_select_arch(void); 61 | 62 | #elif defined(USE_CORTEX_M4) 63 | #include "arm/armcpu.h" 64 | #define OPUS_ARCHMASK 1 65 | 66 | #else 67 | #define OPUS_ARCHMASK 0 68 | 69 | static OPUS_INLINE int opus_select_arch(void) 70 | { 71 | return 0; 72 | } 73 | #endif 74 | #endif 75 | -------------------------------------------------------------------------------- /celt/cwrs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2007-2009 Timothy B. Terriberry 4 | Written by Timothy B. Terriberry and Jean-Marc Valin */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef CWRS_H 31 | #define CWRS_H 32 | 33 | #include "arch.h" 34 | #include "stack_alloc.h" 35 | #include "entenc.h" 36 | #include "entdec.h" 37 | 38 | #ifdef CUSTOM_MODES 39 | int log2_frac(opus_uint32 val, int frac); 40 | #endif 41 | 42 | void get_required_bits(opus_int16 *bits, int N, int K, int frac); 43 | 44 | void encode_pulses(const int *_y, int N, int K, ec_enc *enc); 45 | 46 | opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); 47 | 48 | #endif /* CWRS_H */ 49 | -------------------------------------------------------------------------------- /celt/dump_modes/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS=-O2 -Wall -Wextra -DHAVE_CONFIG_H 3 | INCLUDES=-I. -I../ -I../.. -I../../include 4 | 5 | SOURCES = dump_modes.c \ 6 | ../modes.c \ 7 | ../cwrs.c \ 8 | ../rate.c \ 9 | ../entcode.c \ 10 | ../entenc.c \ 11 | ../entdec.c \ 12 | ../mathops.c \ 13 | ../mdct.c \ 14 | ../kiss_fft.c 15 | 16 | ifdef HAVE_ARM_NE10 17 | CC = gcc 18 | CFLAGS += -mfpu=neon 19 | INCLUDES += -I$(NE10_INCDIR) -DHAVE_ARM_NE10 -DOPUS_ARM_PRESUME_NEON_INTR 20 | LIBS = -L$(NE10_LIBDIR) -lNE10 21 | SOURCES += ../arm/celt_ne10_fft.c \ 22 | dump_modes_arm_ne10.c \ 23 | ../arm/armcpu.c 24 | endif 25 | 26 | all: dump_modes 27 | 28 | dump_modes: 29 | $(PREFIX)$(CC) $(CFLAGS) $(INCLUDES) -DCUSTOM_MODES_ONLY -DCUSTOM_MODES $(SOURCES) -o $@ $(LIBS) -lm 30 | 31 | clean: 32 | rm -f dump_modes 33 | -------------------------------------------------------------------------------- /celt/dump_modes/dump_modes_arch.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Xiph.Org Foundation 2 | Written by Viswanath Puttagunta */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef DUMP_MODE_ARCH_H 29 | #define DUMP_MODE_ARCH_H 30 | 31 | void dump_modes_arch_init(); 32 | void dump_mode_arch(CELTMode *mode); 33 | void dump_modes_arch_finalize(); 34 | 35 | #if !defined(FIXED_POINT) 36 | #define ARM_NE10_ARCH_FILE_NAME "static_modes_float_arm_ne10.h" 37 | #else 38 | #define ARM_NE10_ARCH_FILE_NAME "static_modes_fixed_arm_ne10.h" 39 | #endif 40 | 41 | #if defined(HAVE_ARM_NE10) 42 | #define OVERRIDE_FFT (1) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /celt/fixed_c5x.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Jean-Marc Valin */ 2 | /** 3 | @file fixed_c5x.h 4 | @brief Fixed-point operations for the TI C5x DSP family 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef FIXED_C5X_H 32 | #define FIXED_C5X_H 33 | 34 | #include "dsplib.h" 35 | 36 | #undef IMUL32 37 | static OPUS_INLINE long IMUL32(long i, long j) 38 | { 39 | long ac0, ac1; 40 | ac0 = _lmpy(i>>16,j); 41 | ac1 = ac0 + _lmpy(i,j>>16); 42 | return _lmpyu(i,j) + (ac1<<16); 43 | } 44 | 45 | #undef MAX16 46 | #define MAX16(a,b) _max(a,b) 47 | 48 | #undef MIN16 49 | #define MIN16(a,b) _min(a,b) 50 | 51 | #undef MAX32 52 | #define MAX32(a,b) _lmax(a,b) 53 | 54 | #undef MIN32 55 | #define MIN32(a,b) _lmin(a,b) 56 | 57 | #undef VSHR32 58 | #define VSHR32(a, shift) _lshl(a,-(shift)) 59 | 60 | #undef MULT16_16_Q15 61 | #define MULT16_16_Q15(a,b) (_smpy(a,b)) 62 | 63 | #undef MULT16_16SU 64 | #define MULT16_16SU(a,b) _lmpysu(a,b) 65 | 66 | #undef MULT_16_16 67 | #define MULT_16_16(a,b) _lmpy(a,b) 68 | 69 | /* FIXME: This is technically incorrect and is bound to cause problems. Is there any cleaner solution? */ 70 | #undef MULT16_32_Q15 71 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15)) 72 | 73 | #define celt_ilog2(x) (30 - _lnorm(x)) 74 | #define OVERRIDE_CELT_ILOG2 75 | 76 | #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) 77 | #define OVERRIDE_CELT_MAXABS16 78 | 79 | #endif /* FIXED_C5X_H */ 80 | -------------------------------------------------------------------------------- /celt/fixed_c6x.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 CSIRO */ 2 | /** 3 | @file fixed_c6x.h 4 | @brief Fixed-point operations for the TI C6x DSP family 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef FIXED_C6X_H 32 | #define FIXED_C6X_H 33 | 34 | #undef MULT16_16SU 35 | #define MULT16_16SU(a,b) _mpysu(a,b) 36 | 37 | #undef MULT_16_16 38 | #define MULT_16_16(a,b) _mpy(a,b) 39 | 40 | #define celt_ilog2(x) (30 - _norm(x)) 41 | #define OVERRIDE_CELT_ILOG2 42 | 43 | #undef MULT16_32_Q15 44 | #define MULT16_32_Q15(a,b) (_mpylill(a, b) >> 15) 45 | 46 | #if 0 47 | #include "dsplib.h" 48 | 49 | #undef MAX16 50 | #define MAX16(a,b) _max(a,b) 51 | 52 | #undef MIN16 53 | #define MIN16(a,b) _min(a,b) 54 | 55 | #undef MAX32 56 | #define MAX32(a,b) _lmax(a,b) 57 | 58 | #undef MIN32 59 | #define MIN32(a,b) _lmin(a,b) 60 | 61 | #undef VSHR32 62 | #define VSHR32(a, shift) _lshl(a,-(shift)) 63 | 64 | #undef MULT16_16_Q15 65 | #define MULT16_16_Q15(a,b) (_smpy(a,b)) 66 | 67 | #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) 68 | #define OVERRIDE_CELT_MAXABS16 69 | 70 | #endif /* FIXED_C6X_H */ 71 | -------------------------------------------------------------------------------- /celt/laplace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /* 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "entenc.h" 30 | #include "entdec.h" 31 | 32 | /** Encode a value that is assumed to be the realisation of a 33 | Laplace-distributed random process 34 | @param enc Entropy encoder state 35 | @param value Value to encode 36 | @param fs Probability of 0, multiplied by 32768 37 | @param decay Probability of the value +/- 1, multiplied by 16384 38 | */ 39 | void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay); 40 | 41 | /** Decode a value that is assumed to be the realisation of a 42 | Laplace-distributed random process 43 | @param dec Entropy decoder state 44 | @param fs Probability of 0, multiplied by 32768 45 | @param decay Probability of the value +/- 1, multiplied by 16384 46 | @return Value decoded 47 | */ 48 | int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay); 49 | -------------------------------------------------------------------------------- /celt/mfrngcod.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001-2008 Timothy B. Terriberry 2 | Copyright (c) 2008-2009 Xiph.Org Foundation */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !defined(_mfrngcode_H) 29 | # define _mfrngcode_H (1) 30 | # include "entcode.h" 31 | 32 | /*Constants used by the entropy encoder/decoder.*/ 33 | 34 | /*The number of bits to output at a time.*/ 35 | # define EC_SYM_BITS (8) 36 | /*The total number of bits in each of the state registers.*/ 37 | # define EC_CODE_BITS (32) 38 | /*The maximum symbol value.*/ 39 | # define EC_SYM_MAX ((1U<>EC_SYM_BITS) 46 | /*The number of bits available for the last, partial symbol in the code field.*/ 47 | # define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1) 48 | #endif 49 | -------------------------------------------------------------------------------- /celt/modes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2008 Gregory Maxwell 4 | Written by Jean-Marc Valin and Gregory Maxwell */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef MODES_H 31 | #define MODES_H 32 | 33 | #include "opus_types.h" 34 | #include "celt.h" 35 | #include "arch.h" 36 | #include "mdct.h" 37 | #include "entenc.h" 38 | #include "entdec.h" 39 | 40 | #define MAX_PERIOD 1024 41 | 42 | typedef struct { 43 | int size; 44 | const opus_int16 *index; 45 | const unsigned char *bits; 46 | const unsigned char *caps; 47 | } PulseCache; 48 | 49 | /** Mode definition (opaque) 50 | @brief Mode definition 51 | */ 52 | struct OpusCustomMode { 53 | opus_int32 Fs; 54 | int overlap; 55 | 56 | int nbEBands; 57 | int effEBands; 58 | opus_val16 preemph[4]; 59 | const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ 60 | 61 | int maxLM; 62 | int nbShortMdcts; 63 | int shortMdctSize; 64 | 65 | int nbAllocVectors; /**< Number of lines in the matrix below */ 66 | const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ 67 | const opus_int16 *logN; 68 | 69 | const opus_val16 *window; 70 | mdct_lookup mdct; 71 | PulseCache cache; 72 | }; 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /celt/quant_bands.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /* 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef QUANT_BANDS 30 | #define QUANT_BANDS 31 | 32 | #include "arch.h" 33 | #include "modes.h" 34 | #include "entenc.h" 35 | #include "entdec.h" 36 | #include "mathops.h" 37 | 38 | #ifdef FIXED_POINT 39 | extern const signed char eMeans[25]; 40 | #else 41 | extern const opus_val16 eMeans[25]; 42 | #endif 43 | 44 | void amp2Log2(const CELTMode *m, int effEnd, int end, 45 | celt_ener *bandE, opus_val16 *bandLogE, int C); 46 | 47 | void log2Amp(const CELTMode *m, int start, int end, 48 | celt_ener *eBands, const opus_val16 *oldEBands, int C); 49 | 50 | void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, 51 | const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, 52 | opus_val16 *error, ec_enc *enc, int C, int LM, 53 | int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, 54 | int two_pass, int loss_rate, int lfe); 55 | 56 | void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C); 57 | 58 | void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C); 59 | 60 | void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM); 61 | 62 | void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C); 63 | 64 | void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C); 65 | 66 | #endif /* QUANT_BANDS */ 67 | -------------------------------------------------------------------------------- /celt/static_modes_fixed_armv7e.h: -------------------------------------------------------------------------------- 1 | #ifndef ARMV7E_FFT_PARAMS48000_960 2 | #define ARMV7E_FFT_PARAMS48000_960 3 | 4 | 5 | static const arch_fft_state cfg_arch_480 = { 6 | 0, 7 | NULL, 8 | }; 9 | 10 | static const arch_fft_state cfg_arch_240 = { 11 | 0, 12 | NULL, 13 | }; 14 | 15 | 16 | static const arch_fft_state cfg_arch_120 = { 17 | 0, 18 | NULL, 19 | }; 20 | 21 | static const arch_fft_state cfg_arch_60 = { 22 | 0, 23 | NULL, 24 | }; 25 | 26 | #endif /* end ARMV7E_FFT_PARAMS48000_960 */ -------------------------------------------------------------------------------- /celt/tests/test_unit_laplace.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation 2 | Written by Jean-Marc Valin and Timothy B. Terriberry */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | #include "laplace.h" 35 | #define CELT_C 36 | #include "stack_alloc.h" 37 | 38 | #include "entenc.c" 39 | #include "entdec.c" 40 | #include "entcode.c" 41 | #include "laplace.c" 42 | 43 | #define DATA_SIZE 40000 44 | 45 | int ec_laplace_get_start_freq(int decay) 46 | { 47 | opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); 48 | int fs = (ft*(16384-decay))/(16384+decay); 49 | return fs+LAPLACE_MINP; 50 | } 51 | 52 | int main(void) 53 | { 54 | int i; 55 | int ret = 0; 56 | ec_enc enc; 57 | ec_dec dec; 58 | unsigned char *ptr; 59 | int val[10000], decay[10000]; 60 | ALLOC_STACK; 61 | ptr = (unsigned char *)malloc(DATA_SIZE); 62 | ec_enc_init(&enc,ptr,DATA_SIZE); 63 | 64 | val[0] = 3; decay[0] = 6000; 65 | val[1] = 0; decay[1] = 5800; 66 | val[2] = -1; decay[2] = 5600; 67 | for (i=3;i<10000;i++) 68 | { 69 | val[i] = rand()%15-7; 70 | decay[i] = rand()%11000+5000; 71 | } 72 | for (i=0;i<10000;i++) 73 | ec_laplace_encode(&enc, &val[i], 74 | ec_laplace_get_start_freq(decay[i]), decay[i]); 75 | 76 | ec_enc_done(&enc); 77 | 78 | ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc)); 79 | 80 | for (i=0;i<10000;i++) 81 | { 82 | int d = ec_laplace_decode(&dec, 83 | ec_laplace_get_start_freq(decay[i]), decay[i]); 84 | if (d != val[i]) 85 | { 86 | fprintf (stderr, "Got %d instead of %d\n", d, val[i]); 87 | ret = 1; 88 | } 89 | } 90 | 91 | free(ptr); 92 | return ret; 93 | } 94 | -------------------------------------------------------------------------------- /celt/tests/test_unit_types.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "opus_types.h" 33 | #include 34 | 35 | int main(void) 36 | { 37 | opus_int16 i = 1; 38 | i <<= 14; 39 | if (i>>14 != 1) 40 | { 41 | fprintf(stderr, "opus_int16 isn't 16 bits\n"); 42 | return 1; 43 | } 44 | if (sizeof(opus_int16)*2 != sizeof(opus_int32)) 45 | { 46 | fprintf(stderr, "16*2 != 32\n"); 47 | return 1; 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /celt/vq.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /** 5 | @file vq.h 6 | @brief Vector quantisation of the residual 7 | */ 8 | /* 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 16 | - Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef VQ_H 34 | #define VQ_H 35 | 36 | #include "entenc.h" 37 | #include "entdec.h" 38 | #include "modes.h" 39 | 40 | #if defined(MIPSr1_ASM) 41 | #include "mips/vq_mipsr1.h" 42 | #endif 43 | 44 | 45 | /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of 46 | * the pitch and a combination of pulses such that its norm is still equal 47 | * to 1. This is the function that will typically require the most CPU. 48 | * @param X Residual signal to quantise/encode (returns quantised version) 49 | * @param N Number of samples to encode 50 | * @param K Number of pulses to use 51 | * @param enc Entropy encoder state 52 | * @ret A mask indicating which blocks in the band received pulses 53 | */ 54 | unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, 55 | ec_enc *enc 56 | #ifdef RESYNTH 57 | , opus_val16 gain 58 | #endif 59 | ); 60 | 61 | /** Algebraic pulse decoder 62 | * @param X Decoded normalised spectrum (returned) 63 | * @param N Number of samples to decode 64 | * @param K Number of pulses to use 65 | * @param dec Entropy decoder state 66 | * @ret A mask indicating which blocks in the band received pulses 67 | */ 68 | unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, 69 | ec_dec *dec, opus_val16 gain); 70 | 71 | void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch); 72 | 73 | int stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch); 74 | 75 | #endif /* VQ_H */ 76 | -------------------------------------------------------------------------------- /celt/x86/celt_lpc_sse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014, Cisco Systems, INC 2 | Written by XiangMingZhu WeiZhou MinPeng YanWang 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef CELT_LPC_SSE_H 29 | #define CELT_LPC_SSE_H 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include "config.h" 33 | #endif 34 | 35 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) 36 | #define OVERRIDE_CELT_FIR 37 | 38 | void celt_fir_sse4_1( 39 | const opus_val16 *x, 40 | const opus_val16 *num, 41 | opus_val16 *y, 42 | int N, 43 | int ord, 44 | opus_val16 *mem, 45 | int arch); 46 | 47 | #if defined(OPUS_X86_PRESUME_SSE4_1) 48 | #define celt_fir(x, num, y, N, ord, mem, arch) \ 49 | ((void)arch, celt_fir_sse4_1(x, num, y, N, ord, mem, arch)) 50 | 51 | #else 52 | 53 | extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( 54 | const opus_val16 *x, 55 | const opus_val16 *num, 56 | opus_val16 *y, 57 | int N, 58 | int ord, 59 | opus_val16 *mem, 60 | int arch); 61 | 62 | # define celt_fir(x, num, y, N, ord, mem, arch) \ 63 | ((*CELT_FIR_IMPL[(arch) & OPUS_ARCHMASK])(x, num, y, N, ord, mem, arch)) 64 | 65 | #endif 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /celt/x86/vq_sse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Jean-Marc Valin */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef VQ_SSE_H 28 | #define VQ_SSE_H 29 | 30 | #if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) 31 | #define OVERRIDE_OP_PVQ_SEARCH 32 | 33 | opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); 34 | 35 | #if defined(OPUS_X86_PRESUME_SSE2) 36 | #define op_pvq_search(x, iy, K, N, arch) \ 37 | (op_pvq_search_sse2(x, iy, K, N, arch)) 38 | 39 | #else 40 | 41 | extern opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_ARCHMASK + 1])( 42 | celt_norm *_X, int *iy, int K, int N, int arch); 43 | 44 | # define op_pvq_search(X, iy, K, N, arch) \ 45 | ((*OP_PVQ_SEARCH_IMPL[(arch) & OPUS_ARCHMASK])(X, iy, K, N, arch)) 46 | 47 | #endif 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /celt_headers.mk: -------------------------------------------------------------------------------- 1 | CELT_HEAD = \ 2 | celt/arch.h \ 3 | celt/bands.h \ 4 | celt/celt.h \ 5 | celt/cpu_support.h \ 6 | include/opus_types.h \ 7 | include/opus_defines.h \ 8 | include/opus_custom.h \ 9 | celt/cwrs.h \ 10 | celt/ecintrin.h \ 11 | celt/entcode.h \ 12 | celt/entdec.h \ 13 | celt/entenc.h \ 14 | celt/fixed_debug.h \ 15 | celt/fixed_generic.h \ 16 | celt/float_cast.h \ 17 | celt/_kiss_fft_guts.h \ 18 | celt/kiss_fft.h \ 19 | celt/laplace.h \ 20 | celt/mathops.h \ 21 | celt/mdct.h \ 22 | celt/mfrngcod.h \ 23 | celt/modes.h \ 24 | celt/os_support.h \ 25 | celt/pitch.h \ 26 | celt/celt_lpc.h \ 27 | celt/x86/celt_lpc_sse.h \ 28 | celt/quant_bands.h \ 29 | celt/rate.h \ 30 | celt/stack_alloc.h \ 31 | celt/vq.h \ 32 | celt/static_modes_float.h \ 33 | celt/static_modes_fixed.h \ 34 | celt/static_modes_float_arm_ne10.h \ 35 | celt/static_modes_fixed_arm_ne10.h \ 36 | celt/arm/armcpu.h \ 37 | celt/arm/fixed_armv4.h \ 38 | celt/arm/fixed_armv5e.h \ 39 | celt/arm/kiss_fft_armv4.h \ 40 | celt/arm/kiss_fft_armv5e.h \ 41 | celt/arm/pitch_arm.h \ 42 | celt/arm/fft_arm.h \ 43 | celt/arm/mdct_arm.h \ 44 | celt/mips/celt_mipsr1.h \ 45 | celt/mips/fixed_generic_mipsr1.h \ 46 | celt/mips/kiss_fft_mipsr1.h \ 47 | celt/mips/mdct_mipsr1.h \ 48 | celt/mips/pitch_mipsr1.h \ 49 | celt/mips/vq_mipsr1.h \ 50 | celt/x86/pitch_sse.h \ 51 | celt/x86/x86cpu.h 52 | -------------------------------------------------------------------------------- /celt_sources.mk: -------------------------------------------------------------------------------- 1 | CELT_SOURCES = celt/bands.c \ 2 | celt/celt.c \ 3 | celt/celt_encoder.c \ 4 | celt/celt_decoder.c \ 5 | celt/cwrs.c \ 6 | celt/entcode.c \ 7 | celt/entdec.c \ 8 | celt/entenc.c \ 9 | celt/kiss_fft.c \ 10 | celt/laplace.c \ 11 | celt/mathops.c \ 12 | celt/mdct.c \ 13 | celt/modes.c \ 14 | celt/pitch.c \ 15 | celt/celt_lpc.c \ 16 | celt/quant_bands.c \ 17 | celt/rate.c \ 18 | celt/vq.c 19 | 20 | CELT_SOURCES_SSE = celt/x86/x86cpu.c \ 21 | celt/x86/x86_celt_map.c \ 22 | celt/x86/pitch_sse.c 23 | 24 | CELT_SOURCES_SSE2 = celt/x86/pitch_sse2.c 25 | 26 | CELT_SOURCES_SSE4_1 = celt/x86/celt_lpc_sse.c \ 27 | celt/x86/pitch_sse4_1.c 28 | 29 | CELT_SOURCES_ARM = \ 30 | celt/arm/armcpu.c \ 31 | celt/arm/arm_celt_map.c 32 | 33 | CELT_SOURCES_ARM_ASM = \ 34 | celt/arm/celt_pitch_xcorr_arm.s 35 | 36 | CELT_AM_SOURCES_ARM_ASM = \ 37 | celt/arm/armopts.s.in 38 | 39 | CELT_SOURCES_ARM_NEON_INTR = \ 40 | celt/arm/celt_neon_intr.c 41 | 42 | CELT_SOURCES_ARM_NE10= \ 43 | celt/arm/celt_ne10_fft.c \ 44 | celt/arm/celt_ne10_mdct.c 45 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | DOCINPUTS = $(top_srcdir)/include/opus.h \ 4 | $(top_srcdir)/include/opus_multistream.h \ 5 | $(top_srcdir)/include/opus_defines.h \ 6 | $(top_srcdir)/include/opus_types.h \ 7 | $(top_srcdir)/include/opus_custom.h \ 8 | $(top_srcdir)/doc/header.html \ 9 | $(top_srcdir)/doc/footer.html \ 10 | $(top_srcdir)/doc/customdoxygen.css 11 | 12 | EXTRA_DIST = customdoxygen.css Doxyfile.in footer.html header.html \ 13 | opus_logo.svg trivial_example.c 14 | 15 | 16 | if HAVE_DOXYGEN 17 | 18 | all-local: doxygen-build.stamp 19 | 20 | doxygen-build.stamp: Doxyfile $(DOCINPUTS) 21 | doxygen 22 | touch $@ 23 | 24 | install-data-local: 25 | $(INSTALL) -d $(DESTDIR)$(docdir)/html/search 26 | for f in `find html -type f \! -name "installdox"`; do \ 27 | $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \ 28 | done 29 | 30 | $(INSTALL) -d $(DESTDIR)$(mandir)/man3 31 | cd man && find man3 -type f -name opus_*.3 \ 32 | -exec $(INSTALL_DATA) \{} $(DESTDIR)$(mandir)/man3 \; 33 | 34 | clean-local: 35 | $(RM) -r html 36 | $(RM) -r latex 37 | $(RM) -r man 38 | $(RM) doxygen-build.stamp 39 | 40 | uninstall-local: 41 | $(RM) -r $(DESTDIR)$(docdir)/html 42 | $(RM) $(DESTDIR)$(mandir)/man3/opus_*.3 $(DESTDIR)$(mandir)/man3/opus.h.3 43 | 44 | endif 45 | -------------------------------------------------------------------------------- /doc/TODO: -------------------------------------------------------------------------------- 1 | define audio bandwidth as frequency range 2 | 3 | repeat padding recommendation 4 | 5 | ptime: refer to RFC 6 | 7 | Opus does not provide any confidentiality or integrity protection 8 | -------------------------------------------------------------------------------- /doc/build_isobmff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2014 Xiph.Org Foundation and Mozilla Foundation 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # - Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # - Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | #Stop on errors 29 | set -e 30 | #Set the CWD to the location of this script 31 | [ -n "${0%/*}" ] && cd "${0%/*}" 32 | 33 | HTML=opus_in_isobmff.html 34 | 35 | echo downloading updates... 36 | CSS=${HTML%%.html}.css 37 | wget -q http://vfrmaniac.fushizen.eu/contents/${HTML} -O ${HTML} 38 | wget -q http://vfrmaniac.fushizen.eu/style.css -O ${CSS} 39 | 40 | echo updating links... 41 | cat ${HTML} | sed -e "s/\\.\\.\\/style.css/${CSS}/" > ${HTML}+ && mv ${HTML}+ ${HTML} 42 | 43 | echo stripping... 44 | cat ${HTML} | sed -e 's///g' > ${HTML}+ && mv ${HTML}+ ${HTML} 45 | cat ${HTML} | sed -e 's/ *$//g' > ${HTML}+ && mv ${HTML}+ ${HTML} 46 | cat ${CSS} | sed -e 's/ *$//g' > ${CSS}+ && mv ${CSS}+ ${CSS} 47 | 48 | 49 | VERSION=$(fgrep Version ${HTML} | sed 's/.*Version \([0-9]\.[0-9]\.[0-9]\).*/\1/') 50 | echo Now at version ${VERSION} 51 | -------------------------------------------------------------------------------- /doc/build_oggdraft.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2012 Xiph.Org Foundation and Mozilla Corporation 4 | # 5 | # This file is extracted from RFC6716. Please see that RFC for additional 6 | # information. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # - Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # - Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # 19 | # - Neither the name of Internet Society, IETF or IETF Trust, nor the 20 | # names of specific contributors, may be used to endorse or promote 21 | # products derived from this software without specific prior written 22 | # permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 28 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | #Stop on errors 37 | set -e 38 | #Set the CWD to the location of this script 39 | [ -n "${0%/*}" ] && cd "${0%/*}" 40 | 41 | if test -z `which xml2rfc 2> /dev/null`; then 42 | echo "Error: couldn't find xml2rfc." 43 | echo 44 | echo "Please install xml2rfc version 2 or later." 45 | echo "E.g. 'pip install xml2rfc' or follow the instructions" 46 | echo "on http://pypi.python.org/pypi/xml2rfc/ or tools.ietf.org." 47 | exit 1 48 | fi 49 | 50 | echo running xml2rfc 51 | # version 2 syntax 52 | xml2rfc draft-ietf-codec-oggopus.xml --text --html 53 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | For more information visit the Opus Website. 12 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $projectname: $title 7 | $title 8 | 9 | 10 | $treeview 11 | $search 12 | $mathjax 13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
27 |
Opus
28 |
30 | 33 | 35 |
31 |
$projectbrief
32 |
$projectnumber 34 |
36 |
41 |
$projectbrief
42 |
$searchbox
53 |
54 | 55 | -------------------------------------------------------------------------------- /doc/opus_in_isobmff.css: -------------------------------------------------------------------------------- 1 | /* Normal links */ 2 | .normal_link a:link 3 | { 4 | color : yellow; 5 | } 6 | .normal_link a:visited 7 | { 8 | color : green; 9 | } 10 | 11 | /* Boxes */ 12 | .pre 13 | { 14 | white-space: pre; /* CSS 2.0 */ 15 | white-space: pre-wrap; /* CSS 2.1 */ 16 | white-space: -pre-wrap; /* Opera 4-6 */ 17 | white-space: -o-pre-wrap; /* Opera 7 */ 18 | white-space: -moz-pre-wrap; /* Mozilla */ 19 | white-space: -hp-pre-wrap; /* HP Printers */ 20 | word-wrap : break-word; /* IE 5+ */ 21 | } 22 | 23 | .title_box 24 | { 25 | width : 470px; 26 | height : 70px; 27 | margin : 2px 50px 2px 2px; 28 | padding : 10px; 29 | border : 1px solid black; 30 | background-color : #666666; 31 | white-space : pre; 32 | float : left; 33 | text-align : center; 34 | color : #C0C0C0; 35 | font-size : 50pt; 36 | font-style : italic; 37 | } 38 | 39 | .subindex_box 40 | { 41 | margin : 5px; 42 | padding : 14px 22px; 43 | border : 1px solid black; 44 | background-color : #778877; 45 | float : left; 46 | text-align : center; 47 | color : #115555; 48 | font-size : 32pt; 49 | } 50 | 51 | .frame_box 52 | { 53 | margin : 10px; 54 | padding : 10px; 55 | border : 0px; 56 | background-color : #084040; 57 | text-align : left; 58 | color : #C0C0C0; 59 | font-family : monospace; 60 | } 61 | -------------------------------------------------------------------------------- /doc/release.txt: -------------------------------------------------------------------------------- 1 | = Release checklist = 2 | 3 | == Source release == 4 | 5 | - Check for uncommitted changes to master. 6 | - Update OPUS_LT_* API versioning in configure.ac. 7 | - Tag the release commit with 'git tag -s vN.M'. 8 | - Include release notes in the tag annotation. 9 | - Verify 'make distcheck' produces a tarball with 10 | the desired name. 11 | - Push tag to public repo. 12 | - Upload source package 'opus-${version}.tar.gz' 13 | - Add to https://svn.xiph.org/releases/opus/ 14 | - Update checksum files 15 | - svn commit 16 | - Copy to archive.mozilla.org/pub/opus/ 17 | - Update checksum files there as well. 18 | - Add release notes to https://svn.xiph.org/websites/opus-codec.org/ 19 | - Update links and checksums on the downloads page. 20 | - Add a copy of the documentation to 21 | and update the links. 22 | - Update /topic in #opus IRC channel. 23 | 24 | Releases are commited to https://svn.xiph.org/releases/opus/ 25 | which propagates to downloads.xiph.org, and copied manually 26 | to https://archive.mozilla.org/pub/opus/ 27 | 28 | Website updates are committed to https://svn.xiph.org/websites/opus-codec.org/ 29 | which propagates to https://opus-codec.org/ 30 | 31 | == Binary release == 32 | 33 | We usually build opus-tools binaries for MacOS and Windows. 34 | 35 | Binary releases are copied manually to 36 | https://archive.mozilla.org/pub/opus/win32/ 37 | 38 | For Mac, submit a pull request to homebrew. 39 | 40 | == Website updates == 41 | 42 | For major releases, recreate the files on https://opus-codec.org/examples/ 43 | with the next encoder. 44 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef CONFIG_H 29 | #define CONFIG_H 30 | 31 | #define VAR_ARRAYS 32 | //#define USE_ALLOCA 33 | 34 | /* Comment out the next line for floating-point code */ 35 | #define FIXED_POINT 1 36 | 37 | #define OPUS_BUILD 1 38 | 39 | 40 | 41 | 42 | //#include "version.h" 43 | 44 | 45 | 46 | #endif /* CONFIG_H */ 47 | 48 | -------------------------------------------------------------------------------- /m4/as-gcc-inline-assembly.m4: -------------------------------------------------------------------------------- 1 | dnl as-gcc-inline-assembly.m4 0.1.0 2 | 3 | dnl autostars m4 macro for detection of gcc inline assembly 4 | 5 | dnl David Schleef 6 | 7 | dnl AS_COMPILER_FLAG(ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) 8 | dnl Tries to compile with the given CFLAGS. 9 | dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, 10 | dnl and ACTION-IF-NOT-ACCEPTED otherwise. 11 | 12 | AC_DEFUN([AS_GCC_INLINE_ASSEMBLY], 13 | [ 14 | AC_MSG_CHECKING([if compiler supports gcc-style inline assembly]) 15 | 16 | AC_TRY_COMPILE([], [ 17 | #ifdef __GNUC_MINOR__ 18 | #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004 19 | #error GCC before 3.4 has critical bugs compiling inline assembly 20 | #endif 21 | #endif 22 | __asm__ (""::) ], [flag_ok=yes], [flag_ok=no]) 23 | 24 | if test "X$flag_ok" = Xyes ; then 25 | $1 26 | true 27 | else 28 | $2 29 | true 30 | fi 31 | AC_MSG_RESULT([$flag_ok]) 32 | ]) 33 | 34 | AC_DEFUN([AS_ASM_ARM_NEON], 35 | [ 36 | AC_MSG_CHECKING([if assembler supports NEON instructions on ARM]) 37 | 38 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("vorr d0,d0,d0")])], 39 | [AC_MSG_RESULT([yes]) 40 | $1], 41 | [AC_MSG_RESULT([no]) 42 | $2]) 43 | ]) 44 | 45 | AC_DEFUN([AS_ASM_ARM_NEON_FORCE], 46 | [ 47 | AC_MSG_CHECKING([if assembler supports NEON instructions on ARM]) 48 | 49 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv7-a\n.fpu neon\n.object_arch armv4t\nvorr d0,d0,d0")])], 50 | [AC_MSG_RESULT([yes]) 51 | $1], 52 | [AC_MSG_RESULT([no]) 53 | $2]) 54 | ]) 55 | 56 | AC_DEFUN([AS_ASM_ARM_MEDIA], 57 | [ 58 | AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM]) 59 | 60 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("shadd8 r3,r3,r3")])], 61 | [AC_MSG_RESULT([yes]) 62 | $1], 63 | [AC_MSG_RESULT([no]) 64 | $2]) 65 | ]) 66 | 67 | AC_DEFUN([AS_ASM_ARM_MEDIA_FORCE], 68 | [ 69 | AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM]) 70 | 71 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv6\n.object_arch armv4t\nshadd8 r3,r3,r3")])], 72 | [AC_MSG_RESULT([yes]) 73 | $1], 74 | [AC_MSG_RESULT([no]) 75 | $2]) 76 | ]) 77 | 78 | AC_DEFUN([AS_ASM_ARM_EDSP], 79 | [ 80 | AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM]) 81 | 82 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("qadd r3,r3,r3")])], 83 | [AC_MSG_RESULT([yes]) 84 | $1], 85 | [AC_MSG_RESULT([no]) 86 | $2]) 87 | ]) 88 | 89 | AC_DEFUN([AS_ASM_ARM_EDSP_FORCE], 90 | [ 91 | AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM]) 92 | 93 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv5te\n.object_arch armv4t\nqadd r3,r3,r3")])], 94 | [AC_MSG_RESULT([yes]) 95 | $1], 96 | [AC_MSG_RESULT([no]) 97 | $2]) 98 | ]) 99 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/opus-intrinsics.m4: -------------------------------------------------------------------------------- 1 | dnl opus-intrinsics.m4 2 | dnl macro for testing for support for compiler intrinsics, either by default or with a compiler flag 3 | 4 | dnl OPUS_CHECK_INTRINSICS(NAME-OF-INTRINSICS, COMPILER-FLAG-FOR-INTRINSICS, VAR-IF-PRESENT, VAR-IF-DEFAULT, TEST-PROGRAM-HEADER, TEST-PROGRAM-BODY) 5 | AC_DEFUN([OPUS_CHECK_INTRINSICS], 6 | [ 7 | AC_MSG_CHECKING([if compiler supports $1 intrinsics]) 8 | AC_LINK_IFELSE( 9 | [AC_LANG_PROGRAM($5, $6)], 10 | [ 11 | $3=1 12 | $4=1 13 | AC_MSG_RESULT([yes]) 14 | ],[ 15 | $4=0 16 | AC_MSG_RESULT([no]) 17 | AC_MSG_CHECKING([if compiler supports $1 intrinsics with $2]) 18 | save_CFLAGS="$CFLAGS"; CFLAGS="$2 $CFLAGS" 19 | AC_LINK_IFELSE([AC_LANG_PROGRAM($5, $6)], 20 | [ 21 | AC_MSG_RESULT([yes]) 22 | $3=1 23 | ],[ 24 | AC_MSG_RESULT([no]) 25 | $3=0 26 | ]) 27 | CFLAGS="$save_CFLAGS" 28 | ]) 29 | ]) 30 | -------------------------------------------------------------------------------- /opus-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | # Opus codec reference implementation uninstalled pkg-config file 2 | 3 | libdir=${pcfiledir}/.libs 4 | includedir=${pcfiledir} 5 | 6 | Name: opus uninstalled 7 | Description: Opus IETF audio codec (not installed, @PC_BUILD@) 8 | Version: @VERSION@ 9 | Requires: 10 | Conflicts: 11 | Libs: ${libdir}/libopus.a @LIBM@ 12 | Cflags: -I${pcfiledir}/@top_srcdir@/include 13 | -------------------------------------------------------------------------------- /opus.pc.in: -------------------------------------------------------------------------------- 1 | # Opus codec reference implementation pkg-config file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: Opus 9 | Description: Opus IETF audio codec (@PC_BUILD@ build) 10 | URL: http://opus-codec.org/ 11 | Version: @VERSION@ 12 | Requires: 13 | Conflicts: 14 | Libs: -L${libdir} -lopus 15 | Libs.private: @LIBM@ 16 | Cflags: -I${includedir}/opus 17 | -------------------------------------------------------------------------------- /opus_headers.mk: -------------------------------------------------------------------------------- 1 | OPUS_HEAD = \ 2 | include/opus.h \ 3 | include/opus_multistream.h \ 4 | src/opus_private.h \ 5 | src/analysis.h \ 6 | src/mlp.h \ 7 | src/tansig_table.h 8 | -------------------------------------------------------------------------------- /opus_sources.mk: -------------------------------------------------------------------------------- 1 | OPUS_SOURCES = src/opus.c \ 2 | src/opus_decoder.c \ 3 | src/opus_encoder.c \ 4 | src/opus_multistream.c \ 5 | src/opus_multistream_encoder.c \ 6 | src/opus_multistream_decoder.c \ 7 | src/repacketizer.c 8 | 9 | OPUS_SOURCES_FLOAT = \ 10 | src/analysis.c \ 11 | src/mlp.c \ 12 | src/mlp_data.c 13 | -------------------------------------------------------------------------------- /package_version: -------------------------------------------------------------------------------- 1 | PACKAGE_VERSION="1.1.2" 2 | -------------------------------------------------------------------------------- /silk/NLSF_unpack.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main.h" 33 | 34 | /* Unpack predictor values and indices for entropy coding tables */ 35 | void silk_NLSF_unpack( 36 | opus_int16 ec_ix[], /* O Indices to entropy tables [ LPC_ORDER ] */ 37 | opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ 38 | const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ 39 | const opus_int CB1_index /* I Index of vector in first LSF codebook */ 40 | ) 41 | { 42 | opus_int i; 43 | opus_uint8 entry; 44 | const opus_uint8 *ec_sel_ptr; 45 | 46 | ec_sel_ptr = &psNLSF_CB->ec_sel[ CB1_index * psNLSF_CB->order / 2 ]; 47 | for( i = 0; i < psNLSF_CB->order; i += 2 ) { 48 | entry = *ec_sel_ptr++; 49 | ec_ix [ i ] = silk_SMULBB( silk_RSHIFT( entry, 1 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 ); 50 | pred_Q8[ i ] = psNLSF_CB->pred_Q8[ i + ( entry & 1 ) * ( psNLSF_CB->order - 1 ) ]; 51 | ec_ix [ i + 1 ] = silk_SMULBB( silk_RSHIFT( entry, 5 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 ); 52 | pred_Q8[ i + 1 ] = psNLSF_CB->pred_Q8[ i + ( silk_RSHIFT( entry, 4 ) & 1 ) * ( psNLSF_CB->order - 1 ) + 1 ]; 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /silk/arm/LPC_inv_pred_gain_arm.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2017 Google Inc. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SILK_LPC_INV_PRED_GAIN_ARM_H 29 | # define SILK_LPC_INV_PRED_GAIN_ARM_H 30 | 31 | # include "celt/arm/armcpu.h" 32 | 33 | # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) 34 | opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse prediction gain in energy domain, Q30 */ 35 | const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ 36 | const opus_int order /* I Prediction order */ 37 | ); 38 | 39 | # if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) 40 | # define OVERRIDE_silk_LPC_inverse_pred_gain (1) 41 | # define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), PRESUME_NEON(silk_LPC_inverse_pred_gain)(A_Q12, order)) 42 | # endif 43 | # endif 44 | 45 | # if !defined(OVERRIDE_silk_LPC_inverse_pred_gain) 46 | /*Is run-time CPU detection enabled on this platform?*/ 47 | # if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) 48 | extern opus_int32 (*const SILK_LPC_INVERSE_PRED_GAIN_IMPL[OPUS_ARCHMASK+1])(const opus_int16 *A_Q12, const opus_int order); 49 | # define OVERRIDE_silk_LPC_inverse_pred_gain (1) 50 | # define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((*SILK_LPC_INVERSE_PRED_GAIN_IMPL[(arch)&OPUS_ARCHMASK])(A_Q12, order)) 51 | # elif defined(OPUS_ARM_PRESUME_NEON_INTR) 52 | # define OVERRIDE_silk_LPC_inverse_pred_gain (1) 53 | # define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), silk_LPC_inverse_pred_gain_neon(A_Q12, order)) 54 | # endif 55 | # endif 56 | 57 | #endif /* end SILK_LPC_INV_PRED_GAIN_ARM_H */ 58 | -------------------------------------------------------------------------------- /silk/arm/SigProc_FIX_armv4.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (C) 2013 Xiph.Org Foundation and contributors 3 | Copyright (c) 2013 Parrot 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 13 | names of specific contributors, may be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | ***********************************************************************/ 28 | 29 | #ifndef SILK_SIGPROC_FIX_ARMv4_H 30 | #define SILK_SIGPROC_FIX_ARMv4_H 31 | 32 | #undef silk_MLA 33 | static OPUS_INLINE opus_int32 silk_MLA_armv4(opus_int32 a, opus_int32 b, 34 | opus_int32 c) 35 | { 36 | opus_int32 res; 37 | __asm__( 38 | "#silk_MLA\n\t" 39 | "mla %0, %1, %2, %3\n\t" 40 | : "=&r"(res) 41 | : "r"(b), "r"(c), "r"(a) 42 | ); 43 | return res; 44 | } 45 | #define silk_MLA(a, b, c) (silk_MLA_armv4(a, b, c)) 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /silk/arm/SigProc_FIX_armv5e.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Copyright (c) 2013 Parrot 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 13 | names of specific contributors, may be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | ***********************************************************************/ 28 | 29 | #ifndef SILK_SIGPROC_FIX_ARMv5E_H 30 | #define SILK_SIGPROC_FIX_ARMv5E_H 31 | 32 | #undef silk_SMULTT 33 | static OPUS_INLINE opus_int32 silk_SMULTT_armv5e(opus_int32 a, opus_int32 b) 34 | { 35 | opus_int32 res; 36 | __asm__( 37 | "#silk_SMULTT\n\t" 38 | "smultt %0, %1, %2\n\t" 39 | : "=r"(res) 40 | : "%r"(a), "r"(b) 41 | ); 42 | return res; 43 | } 44 | #define silk_SMULTT(a, b) (silk_SMULTT_armv5e(a, b)) 45 | 46 | #undef silk_SMLATT 47 | static OPUS_INLINE opus_int32 silk_SMLATT_armv5e(opus_int32 a, opus_int32 b, 48 | opus_int32 c) 49 | { 50 | opus_int32 res; 51 | __asm__( 52 | "#silk_SMLATT\n\t" 53 | "smlatt %0, %1, %2, %3\n\t" 54 | : "=r"(res) 55 | : "%r"(b), "r"(c), "r"(a) 56 | ); 57 | return res; 58 | } 59 | #define silk_SMLATT(a, b, c) (silk_SMLATT_armv5e(a, b, c)) 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /silk/arm/macros_arm64.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (C) 2015 Vidyo 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SILK_MACROS_ARM64_H 29 | #define SILK_MACROS_ARM64_H 30 | 31 | #include 32 | 33 | #undef silk_ADD_SAT32 34 | #define silk_ADD_SAT32(a, b) (vqadds_s32((a), (b))) 35 | 36 | #undef silk_SUB_SAT32 37 | #define silk_SUB_SAT32(a, b) (vqsubs_s32((a), (b))) 38 | 39 | #endif /* SILK_MACROS_ARM64_H */ 40 | -------------------------------------------------------------------------------- /silk/bwexpander.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Chirp (bandwidth expand) LP AR filter */ 35 | void silk_bwexpander( 36 | opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ 37 | const opus_int d, /* I Length of ar */ 38 | opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ 39 | ) 40 | { 41 | opus_int i; 42 | opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536; 43 | 44 | /* NB: Dont use silk_SMULWB, instead of silk_RSHIFT_ROUND( silk_MUL(), 16 ), below. */ 45 | /* Bias in silk_SMULWB can lead to unstable filters */ 46 | for( i = 0; i < d - 1; i++ ) { 47 | ar[ i ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ i ] ), 16 ); 48 | chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); 49 | } 50 | ar[ d - 1 ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ d - 1 ] ), 16 ); 51 | } 52 | -------------------------------------------------------------------------------- /silk/bwexpander_32.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Chirp (bandwidth expand) LP AR filter */ 35 | void silk_bwexpander_32( 36 | opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ 37 | const opus_int d, /* I Length of ar */ 38 | opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ 39 | ) 40 | { 41 | opus_int i; 42 | opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536; 43 | 44 | for( i = 0; i < d - 1; i++ ) { 45 | ar[ i ] = silk_SMULWW( chirp_Q16, ar[ i ] ); 46 | chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); 47 | } 48 | ar[ d - 1 ] = silk_SMULWW( chirp_Q16, ar[ d - 1 ] ); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /silk/fixed/LTP_scale_ctrl_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main_FIX.h" 33 | 34 | /* Calculation of LTP state scaling */ 35 | void silk_LTP_scale_ctrl_FIX( 36 | silk_encoder_state_FIX *psEnc, /* I/O encoder state */ 37 | silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ 38 | opus_int condCoding /* I The type of conditional coding to use */ 39 | ) 40 | { 41 | opus_int round_loss; 42 | 43 | if( condCoding == CODE_INDEPENDENTLY ) { 44 | /* Only scale if first frame in packet */ 45 | round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket; 46 | psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT( 47 | silk_SMULWB( silk_SMULBB( round_loss, psEncCtrl->LTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 ); 48 | } else { 49 | /* Default is minimum scaling */ 50 | psEnc->sCmn.indices.LTP_scaleIndex = 0; 51 | } 52 | psEncCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ]; 53 | } 54 | -------------------------------------------------------------------------------- /silk/fixed/autocorr_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | #include "celt_lpc.h" 34 | 35 | /* Compute autocorrelation */ 36 | void silk_autocorr( 37 | opus_int32 *results, /* O Result (length correlationCount) */ 38 | opus_int *scale, /* O Scaling of the correlation vector */ 39 | const opus_int16 *inputData, /* I Input data to correlate */ 40 | const opus_int inputDataSize, /* I Length of input */ 41 | const opus_int correlationCount, /* I Number of correlation taps to compute */ 42 | int arch /* I Run-time architecture */ 43 | ) 44 | { 45 | opus_int corrCount; 46 | corrCount = silk_min_int( inputDataSize, correlationCount ); 47 | *scale = _celt_autocorr(inputData, results, NULL, 0, corrCount-1, inputDataSize, arch); 48 | } 49 | -------------------------------------------------------------------------------- /silk/fixed/k2a_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Step up function, converts reflection coefficients to prediction coefficients */ 35 | void silk_k2a( 36 | opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ 37 | const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */ 38 | const opus_int32 order /* I Prediction order */ 39 | ) 40 | { 41 | opus_int k, n; 42 | opus_int32 Atmp[ SILK_MAX_ORDER_LPC ]; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | for( n = 0; n < k; n++ ) { 46 | Atmp[ n ] = A_Q24[ n ]; 47 | } 48 | for( n = 0; n < k; n++ ) { 49 | A_Q24[ n ] = silk_SMLAWB( A_Q24[ n ], silk_LSHIFT( Atmp[ k - n - 1 ], 1 ), rc_Q15[ k ] ); 50 | } 51 | A_Q24[ k ] = -silk_LSHIFT( (opus_int32)rc_Q15[ k ], 9 ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /silk/fixed/k2a_Q16_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Step up function, converts reflection coefficients to prediction coefficients */ 35 | void silk_k2a_Q16( 36 | opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ 37 | const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */ 38 | const opus_int32 order /* I Prediction order */ 39 | ) 40 | { 41 | opus_int k, n; 42 | opus_int32 Atmp[ SILK_MAX_ORDER_LPC ]; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | for( n = 0; n < k; n++ ) { 46 | Atmp[ n ] = A_Q24[ n ]; 47 | } 48 | for( n = 0; n < k; n++ ) { 49 | A_Q24[ n ] = silk_SMLAWW( A_Q24[ n ], Atmp[ k - n - 1 ], rc_Q16[ k ] ); 50 | } 51 | A_Q24[ k ] = -silk_LSHIFT( rc_Q16[ k ], 8 ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /silk/fixed/regularize_correlations_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main_FIX.h" 33 | 34 | /* Add noise to matrix diagonal */ 35 | void silk_regularize_correlations_FIX( 36 | opus_int32 *XX, /* I/O Correlation matrices */ 37 | opus_int32 *xx, /* I/O Correlation values */ 38 | opus_int32 noise, /* I Noise to add */ 39 | opus_int D /* I Dimension of XX */ 40 | ) 41 | { 42 | opus_int i; 43 | for( i = 0; i < D; i++ ) { 44 | matrix_ptr( &XX[ 0 ], i, i, D ) = silk_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise ); 45 | } 46 | xx[ 0 ] += noise; 47 | } 48 | -------------------------------------------------------------------------------- /silk/float/LTP_scale_ctrl_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main_FLP.h" 33 | 34 | void silk_LTP_scale_ctrl_FLP( 35 | silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ 36 | silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ 37 | opus_int condCoding /* I The type of conditional coding to use */ 38 | ) 39 | { 40 | opus_int round_loss; 41 | 42 | if( condCoding == CODE_INDEPENDENTLY ) { 43 | /* Only scale if first frame in packet */ 44 | round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket; 45 | psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT( round_loss * psEncCtrl->LTPredCodGain * 0.1f, 0.0f, 2.0f ); 46 | } else { 47 | /* Default is minimum scaling */ 48 | psEnc->sCmn.indices.LTP_scaleIndex = 0; 49 | } 50 | 51 | psEncCtrl->LTP_scale = (silk_float)silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f; 52 | } 53 | -------------------------------------------------------------------------------- /silk/float/autocorrelation_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "typedef.h" 33 | #include "SigProc_FLP.h" 34 | 35 | /* compute autocorrelation */ 36 | void silk_autocorrelation_FLP( 37 | silk_float *results, /* O result (length correlationCount) */ 38 | const silk_float *inputData, /* I input data to correlate */ 39 | opus_int inputDataSize, /* I length of input */ 40 | opus_int correlationCount /* I number of correlation taps to compute */ 41 | ) 42 | { 43 | opus_int i; 44 | 45 | if( correlationCount > inputDataSize ) { 46 | correlationCount = inputDataSize; 47 | } 48 | 49 | for( i = 0; i < correlationCount; i++ ) { 50 | results[ i ] = (silk_float)silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /silk/float/bwexpander_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* Chirp (bw expand) LP AR filter */ 35 | void silk_bwexpander_FLP( 36 | silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ 37 | const opus_int d, /* I length of ar */ 38 | const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ 39 | ) 40 | { 41 | opus_int i; 42 | silk_float cfac = chirp; 43 | 44 | for( i = 0; i < d - 1; i++ ) { 45 | ar[ i ] *= cfac; 46 | cfac *= chirp; 47 | } 48 | ar[ d - 1 ] *= cfac; 49 | } 50 | -------------------------------------------------------------------------------- /silk/float/energy_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* sum of squares of a silk_float array, with result as double */ 35 | double silk_energy_FLP( 36 | const silk_float *data, 37 | opus_int dataSize 38 | ) 39 | { 40 | opus_int i, dataSize4; 41 | double result; 42 | 43 | /* 4x unrolled loop */ 44 | result = 0.0; 45 | dataSize4 = dataSize & 0xFFFC; 46 | for( i = 0; i < dataSize4; i += 4 ) { 47 | result += data[ i + 0 ] * (double)data[ i + 0 ] + 48 | data[ i + 1 ] * (double)data[ i + 1 ] + 49 | data[ i + 2 ] * (double)data[ i + 2 ] + 50 | data[ i + 3 ] * (double)data[ i + 3 ]; 51 | } 52 | 53 | /* add any remaining products */ 54 | for( ; i < dataSize; i++ ) { 55 | result += data[ i ] * (double)data[ i ]; 56 | } 57 | 58 | silk_assert( result >= 0.0 ); 59 | return result; 60 | } 61 | -------------------------------------------------------------------------------- /silk/float/inner_product_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* inner product of two silk_float arrays, with result as double */ 35 | double silk_inner_product_FLP( 36 | const silk_float *data1, 37 | const silk_float *data2, 38 | opus_int dataSize 39 | ) 40 | { 41 | opus_int i, dataSize4; 42 | double result; 43 | 44 | /* 4x unrolled loop */ 45 | result = 0.0; 46 | dataSize4 = dataSize & 0xFFFC; 47 | for( i = 0; i < dataSize4; i += 4 ) { 48 | result += data1[ i + 0 ] * (double)data2[ i + 0 ] + 49 | data1[ i + 1 ] * (double)data2[ i + 1 ] + 50 | data1[ i + 2 ] * (double)data2[ i + 2 ] + 51 | data1[ i + 3 ] * (double)data2[ i + 3 ]; 52 | } 53 | 54 | /* add any remaining products */ 55 | for( ; i < dataSize; i++ ) { 56 | result += data1[ i ] * (double)data2[ i ]; 57 | } 58 | 59 | return result; 60 | } 61 | -------------------------------------------------------------------------------- /silk/float/k2a_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* step up function, converts reflection coefficients to prediction coefficients */ 35 | void silk_k2a_FLP( 36 | silk_float *A, /* O prediction coefficients [order] */ 37 | const silk_float *rc, /* I reflection coefficients [order] */ 38 | opus_int32 order /* I prediction order */ 39 | ) 40 | { 41 | opus_int k, n; 42 | silk_float Atmp[ SILK_MAX_ORDER_LPC ]; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | for( n = 0; n < k; n++ ) { 46 | Atmp[ n ] = A[ n ]; 47 | } 48 | for( n = 0; n < k; n++ ) { 49 | A[ n ] += Atmp[ k - n - 1 ] * rc[ k ]; 50 | } 51 | A[ k ] = -rc[ k ]; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /silk/float/regularize_correlations_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main_FLP.h" 33 | 34 | /* Add noise to matrix diagonal */ 35 | void silk_regularize_correlations_FLP( 36 | silk_float *XX, /* I/O Correlation matrices */ 37 | silk_float *xx, /* I/O Correlation values */ 38 | const silk_float noise, /* I Noise energy to add */ 39 | const opus_int D /* I Dimension of XX */ 40 | ) 41 | { 42 | opus_int i; 43 | 44 | for( i = 0; i < D; i++ ) { 45 | matrix_ptr( &XX[ 0 ], i, i, D ) += noise; 46 | } 47 | xx[ 0 ] += noise; 48 | } 49 | -------------------------------------------------------------------------------- /silk/float/scale_copy_vector_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* copy and multiply a vector by a constant */ 35 | void silk_scale_copy_vector_FLP( 36 | silk_float *data_out, 37 | const silk_float *data_in, 38 | silk_float gain, 39 | opus_int dataSize 40 | ) 41 | { 42 | opus_int i, dataSize4; 43 | 44 | /* 4x unrolled loop */ 45 | dataSize4 = dataSize & 0xFFFC; 46 | for( i = 0; i < dataSize4; i += 4 ) { 47 | data_out[ i + 0 ] = gain * data_in[ i + 0 ]; 48 | data_out[ i + 1 ] = gain * data_in[ i + 1 ]; 49 | data_out[ i + 2 ] = gain * data_in[ i + 2 ]; 50 | data_out[ i + 3 ] = gain * data_in[ i + 3 ]; 51 | } 52 | 53 | /* any remaining elements */ 54 | for( ; i < dataSize; i++ ) { 55 | data_out[ i ] = gain * data_in[ i ]; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /silk/float/scale_vector_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | /* multiply a vector by a constant */ 35 | void silk_scale_vector_FLP( 36 | silk_float *data1, 37 | silk_float gain, 38 | opus_int dataSize 39 | ) 40 | { 41 | opus_int i, dataSize4; 42 | 43 | /* 4x unrolled loop */ 44 | dataSize4 = dataSize & 0xFFFC; 45 | for( i = 0; i < dataSize4; i += 4 ) { 46 | data1[ i + 0 ] *= gain; 47 | data1[ i + 1 ] *= gain; 48 | data1[ i + 2 ] *= gain; 49 | data1[ i + 3 ] *= gain; 50 | } 51 | 52 | /* any remaining elements */ 53 | for( ; i < dataSize; i++ ) { 54 | data1[ i ] *= gain; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /silk/float/schur_FLP.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FLP.h" 33 | 34 | silk_float silk_schur_FLP( /* O returns residual energy */ 35 | silk_float refl_coef[], /* O reflection coefficients (length order) */ 36 | const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ 37 | opus_int order /* I order */ 38 | ) 39 | { 40 | opus_int k, n; 41 | silk_float C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; 42 | silk_float Ctmp1, Ctmp2, rc_tmp; 43 | 44 | silk_assert( order==6||order==8||order==10||order==12||order==14||order==16 ); 45 | 46 | /* Copy correlations */ 47 | for( k = 0; k < order+1; k++ ) { 48 | C[ k ][ 0 ] = C[ k ][ 1 ] = auto_corr[ k ]; 49 | } 50 | 51 | for( k = 0; k < order; k++ ) { 52 | /* Get reflection coefficient */ 53 | rc_tmp = -C[ k + 1 ][ 0 ] / silk_max_float( C[ 0 ][ 1 ], 1e-9f ); 54 | 55 | /* Save the output */ 56 | refl_coef[ k ] = rc_tmp; 57 | 58 | /* Update correlations */ 59 | for( n = 0; n < order - k; n++ ) { 60 | Ctmp1 = C[ n + k + 1 ][ 0 ]; 61 | Ctmp2 = C[ n ][ 1 ]; 62 | C[ n + k + 1 ][ 0 ] = Ctmp1 + Ctmp2 * rc_tmp; 63 | C[ n ][ 1 ] = Ctmp2 + Ctmp1 * rc_tmp; 64 | } 65 | } 66 | 67 | /* Return residual energy */ 68 | return C[ 0 ][ 1 ]; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /silk/init_decoder.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main.h" 33 | 34 | /************************/ 35 | /* Init Decoder State */ 36 | /************************/ 37 | opus_int silk_init_decoder( 38 | silk_decoder_state *psDec /* I/O Decoder state pointer */ 39 | ) 40 | { 41 | /* Clear the entire encoder state, except anything copied */ 42 | silk_memset( psDec, 0, sizeof( silk_decoder_state ) ); 43 | 44 | /* Used to deactivate LSF interpolation */ 45 | psDec->first_frame_after_reset = 1; 46 | psDec->prev_gain_Q16 = 65536; 47 | 48 | /* Reset CNG state */ 49 | silk_CNG_Reset( psDec ); 50 | 51 | /* Reset PLC state */ 52 | silk_PLC_Reset( psDec ); 53 | 54 | return(0); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /silk/init_encoder.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | #ifdef FIXED_POINT 32 | #include "main_FIX.h" 33 | #else 34 | #include "main_FLP.h" 35 | #endif 36 | #include "tuning_parameters.h" 37 | #include "cpu_support.h" 38 | 39 | /*********************************/ 40 | /* Initialize Silk Encoder state */ 41 | /*********************************/ 42 | opus_int silk_init_encoder( 43 | silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */ 44 | int arch /* I Run-time architecture */ 45 | ) 46 | { 47 | opus_int ret = 0; 48 | 49 | /* Clear the entire encoder state */ 50 | silk_memset( psEnc, 0, sizeof( silk_encoder_state_Fxx ) ); 51 | 52 | psEnc->sCmn.arch = arch; 53 | 54 | psEnc->sCmn.variable_HP_smth1_Q15 = silk_LSHIFT( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ), 8 ); 55 | psEnc->sCmn.variable_HP_smth2_Q15 = psEnc->sCmn.variable_HP_smth1_Q15; 56 | 57 | /* Used to deactivate LSF interpolation, pitch prediction */ 58 | psEnc->sCmn.first_frame_after_reset = 1; 59 | 60 | /* Initialize Silk VAD */ 61 | ret += silk_VAD_Init( &psEnc->sCmn.sVAD ); 62 | 63 | return ret; 64 | } 65 | -------------------------------------------------------------------------------- /silk/inner_prod_aligned.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | opus_int32 silk_inner_prod_aligned_scale( 35 | const opus_int16 *const inVec1, /* I input vector 1 */ 36 | const opus_int16 *const inVec2, /* I input vector 2 */ 37 | const opus_int scale, /* I number of bits to shift */ 38 | const opus_int len /* I vector lengths */ 39 | ) 40 | { 41 | opus_int i; 42 | opus_int32 sum = 0; 43 | for( i = 0; i < len; i++ ) { 44 | sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale ); 45 | } 46 | return sum; 47 | } 48 | -------------------------------------------------------------------------------- /silk/interpolate.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main.h" 33 | 34 | /* Interpolate two vectors */ 35 | void silk_interpolate( 36 | opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ 37 | const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ 38 | const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ 39 | const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ 40 | const opus_int d /* I number of parameters */ 41 | ) 42 | { 43 | opus_int i; 44 | 45 | silk_assert( ifact_Q2 >= 0 ); 46 | silk_assert( ifact_Q2 <= 4 ); 47 | 48 | for( i = 0; i < d; i++ ) { 49 | xi[ i ] = (opus_int16)silk_ADD_RSHIFT( x0[ i ], silk_SMULBB( x1[ i ] - x0[ i ], ifact_Q2 ), 2 ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /silk/lin2log.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | /* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */ 34 | /* Convert input to a log scale */ 35 | opus_int32 silk_lin2log( 36 | const opus_int32 inLin /* I input in linear scale */ 37 | ) 38 | { 39 | opus_int32 lz, frac_Q7; 40 | 41 | silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); 42 | 43 | /* Piece-wise parabolic approximation */ 44 | return silk_LSHIFT( 31 - lz, 7 ) + silk_SMLAWB( frac_Q7, silk_MUL( frac_Q7, 128 - frac_Q7 ), 179 ); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /silk/log2lin.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | 34 | /* Approximation of 2^() (very close inverse of silk_lin2log()) */ 35 | /* Convert input to a linear scale */ 36 | opus_int32 silk_log2lin( 37 | const opus_int32 inLog_Q7 /* I input on log scale */ 38 | ) 39 | { 40 | opus_int32 out, frac_Q7; 41 | 42 | if( inLog_Q7 < 0 ) { 43 | return 0; 44 | } else if ( inLog_Q7 >= 3967 ) { 45 | return silk_int32_MAX; 46 | } 47 | 48 | out = silk_LSHIFT( 1, silk_RSHIFT( inLog_Q7, 7 ) ); 49 | frac_Q7 = inLog_Q7 & 0x7F; 50 | if( inLog_Q7 < 2048 ) { 51 | /* Piece-wise parabolic approximation */ 52 | out = silk_ADD_RSHIFT32( out, silk_MUL( out, silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 ); 53 | } else { 54 | /* Piece-wise parabolic approximation */ 55 | out = silk_MLA( out, silk_RSHIFT( out, 7 ), silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) ); 56 | } 57 | return out; 58 | } 59 | -------------------------------------------------------------------------------- /silk/mips/macros_mipsr1.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | 29 | #ifndef __SILK_MACROS_MIPSR1_H__ 30 | #define __SILK_MACROS_MIPSR1_H__ 31 | 32 | #define mips_clz(x) __builtin_clz(x) 33 | 34 | #undef silk_SMULWB 35 | static inline int silk_SMULWB(int a, int b) 36 | { 37 | long long ac; 38 | int c; 39 | 40 | ac = __builtin_mips_mult(a, (opus_int32)(opus_int16)b); 41 | c = __builtin_mips_extr_w(ac, 16); 42 | 43 | return c; 44 | } 45 | 46 | #undef silk_SMLAWB 47 | #define silk_SMLAWB(a32, b32, c32) ((a32) + silk_SMULWB(b32, c32)) 48 | 49 | #undef silk_SMULWW 50 | static inline int silk_SMULWW(int a, int b) 51 | { 52 | long long ac; 53 | int c; 54 | 55 | ac = __builtin_mips_mult(a, b); 56 | c = __builtin_mips_extr_w(ac, 16); 57 | 58 | return c; 59 | } 60 | 61 | #undef silk_SMLAWW 62 | static inline int silk_SMLAWW(int a, int b, int c) 63 | { 64 | long long ac; 65 | int res; 66 | 67 | ac = __builtin_mips_mult(b, c); 68 | res = __builtin_mips_extr_w(ac, 16); 69 | res += a; 70 | 71 | return res; 72 | } 73 | 74 | #define OVERRIDE_silk_CLZ16 75 | static inline opus_int32 silk_CLZ16(opus_int16 in16) 76 | { 77 | int re32; 78 | opus_int32 in32 = (opus_int32 )in16; 79 | re32 = mips_clz(in32); 80 | re32-=16; 81 | return re32; 82 | } 83 | 84 | #define OVERRIDE_silk_CLZ32 85 | static inline opus_int32 silk_CLZ32(opus_int32 in32) 86 | { 87 | int re32; 88 | re32 = mips_clz(in32); 89 | return re32; 90 | } 91 | 92 | #endif /* __SILK_MACROS_MIPSR1_H__ */ 93 | -------------------------------------------------------------------------------- /silk/mips/sigproc_fix_mipsr1.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SILK_SIGPROC_FIX_MIPSR1_H 29 | #define SILK_SIGPROC_FIX_MIPSR1_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" 33 | { 34 | #endif 35 | 36 | #undef silk_SAT16 37 | static inline short int silk_SAT16(int a) 38 | { 39 | int c; 40 | c = __builtin_mips_shll_s_w(a, 16); 41 | c = c>>16; 42 | 43 | return c; 44 | } 45 | 46 | #undef silk_LSHIFT_SAT32 47 | static inline int silk_LSHIFT_SAT32(int a, int shift) 48 | { 49 | int r; 50 | 51 | r = __builtin_mips_shll_s_w(a, shift); 52 | 53 | return r; 54 | } 55 | 56 | #undef silk_RSHIFT_ROUND 57 | static inline int silk_RSHIFT_ROUND(int a, int shift) 58 | { 59 | int r; 60 | 61 | r = __builtin_mips_shra_r_w(a, shift); 62 | return r; 63 | } 64 | 65 | #endif /* SILK_SIGPROC_FIX_MIPSR1_H */ 66 | -------------------------------------------------------------------------------- /silk/resampler_private_AR2.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "SigProc_FIX.h" 33 | #include "resampler_private.h" 34 | 35 | /* Second order AR filter with single delay elements */ 36 | void silk_resampler_private_AR2( 37 | opus_int32 S[], /* I/O State vector [ 2 ] */ 38 | opus_int32 out_Q8[], /* O Output signal */ 39 | const opus_int16 in[], /* I Input signal */ 40 | const opus_int16 A_Q14[], /* I AR coefficients, Q14 */ 41 | opus_int32 len /* I Signal length */ 42 | ) 43 | { 44 | opus_int32 k; 45 | opus_int32 out32; 46 | 47 | for( k = 0; k < len; k++ ) { 48 | out32 = silk_ADD_LSHIFT32( S[ 0 ], (opus_int32)in[ k ], 8 ); 49 | out_Q8[ k ] = out32; 50 | out32 = silk_LSHIFT( out32, 2 ); 51 | S[ 0 ] = silk_SMLAWB( S[ 1 ], out32, A_Q14[ 0 ] ); 52 | S[ 1 ] = silk_SMULWB( out32, A_Q14[ 1 ] ); 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /silk/resampler_structs.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SILK_RESAMPLER_STRUCTS_H 29 | #define SILK_RESAMPLER_STRUCTS_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | #define SILK_RESAMPLER_MAX_FIR_ORDER 36 36 | #define SILK_RESAMPLER_MAX_IIR_ORDER 6 37 | 38 | typedef struct _silk_resampler_state_struct{ 39 | opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ 40 | union{ 41 | opus_int32 i32[ SILK_RESAMPLER_MAX_FIR_ORDER ]; 42 | opus_int16 i16[ SILK_RESAMPLER_MAX_FIR_ORDER ]; 43 | } sFIR; 44 | opus_int16 delayBuf[ 48 ]; 45 | opus_int resampler_function; 46 | opus_int batchSize; 47 | opus_int32 invRatio_Q16; 48 | opus_int FIR_Order; 49 | opus_int FIR_Fracs; 50 | opus_int Fs_in_kHz; 51 | opus_int Fs_out_kHz; 52 | opus_int inputDelay; 53 | const opus_int16 *Coefs; 54 | } silk_resampler_state_struct; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif /* SILK_RESAMPLER_STRUCTS_H */ 60 | 61 | -------------------------------------------------------------------------------- /silk/sigm_Q15.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | /* Approximate sigmoid function */ 33 | 34 | #include "SigProc_FIX.h" 35 | 36 | /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ 37 | static const opus_int32 sigm_LUT_slope_Q10[ 6 ] = { 38 | 237, 153, 73, 30, 12, 7 39 | }; 40 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */ 41 | static const opus_int32 sigm_LUT_pos_Q15[ 6 ] = { 42 | 16384, 23955, 28861, 31213, 32178, 32548 43 | }; 44 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */ 45 | static const opus_int32 sigm_LUT_neg_Q15[ 6 ] = { 46 | 16384, 8812, 3906, 1554, 589, 219 47 | }; 48 | 49 | opus_int silk_sigm_Q15( 50 | opus_int in_Q5 /* I */ 51 | ) 52 | { 53 | opus_int ind; 54 | 55 | if( in_Q5 < 0 ) { 56 | /* Negative input */ 57 | in_Q5 = -in_Q5; 58 | if( in_Q5 >= 6 * 32 ) { 59 | return 0; /* Clip */ 60 | } else { 61 | /* Linear interpolation of look up table */ 62 | ind = silk_RSHIFT( in_Q5, 5 ); 63 | return( sigm_LUT_neg_Q15[ ind ] - silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 64 | } 65 | } else { 66 | /* Positive input */ 67 | if( in_Q5 >= 6 * 32 ) { 68 | return 32767; /* clip */ 69 | } else { 70 | /* Linear interpolation of look up table */ 71 | ind = silk_RSHIFT( in_Q5, 5 ); 72 | return( sigm_LUT_pos_Q15[ ind ] + silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 73 | } 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /silk/stereo_encode_pred.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "main.h" 33 | 34 | /* Entropy code the mid/side quantization indices */ 35 | void silk_stereo_encode_pred( 36 | ec_enc *psRangeEnc, /* I/O Compressor data structure */ 37 | opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ 38 | ) 39 | { 40 | opus_int n; 41 | 42 | /* Entropy coding */ 43 | n = 5 * ix[ 0 ][ 2 ] + ix[ 1 ][ 2 ]; 44 | silk_assert( n < 25 ); 45 | ec_enc_icdf( psRangeEnc, n, silk_stereo_pred_joint_iCDF, 8 ); 46 | for( n = 0; n < 2; n++ ) { 47 | silk_assert( ix[ n ][ 0 ] < 3 ); 48 | silk_assert( ix[ n ][ 1 ] < STEREO_QUANT_SUB_STEPS ); 49 | ec_enc_icdf( psRangeEnc, ix[ n ][ 0 ], silk_uniform3_iCDF, 8 ); 50 | ec_enc_icdf( psRangeEnc, ix[ n ][ 1 ], silk_uniform5_iCDF, 8 ); 51 | } 52 | } 53 | 54 | /* Entropy code the mid-only flag */ 55 | void silk_stereo_encode_mid_only( 56 | ec_enc *psRangeEnc, /* I/O Compressor data structure */ 57 | opus_int8 mid_only_flag 58 | ) 59 | { 60 | /* Encode flag that only mid channel is coded */ 61 | ec_enc_icdf( psRangeEnc, mid_only_flag, silk_stereo_only_code_mid_iCDF, 8 ); 62 | } 63 | -------------------------------------------------------------------------------- /silk/tables_gain.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "tables.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" 36 | { 37 | #endif 38 | 39 | const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] = 40 | { 41 | { 42 | 224, 112, 44, 15, 3, 2, 1, 0 43 | }, 44 | { 45 | 254, 237, 192, 132, 70, 23, 4, 0 46 | }, 47 | { 48 | 255, 252, 226, 155, 61, 11, 2, 0 49 | } 50 | }; 51 | 52 | const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ] = { 53 | 250, 245, 234, 203, 71, 50, 42, 38, 54 | 35, 33, 31, 29, 28, 27, 26, 25, 55 | 24, 23, 22, 21, 20, 19, 18, 17, 56 | 16, 15, 14, 13, 12, 11, 10, 9, 57 | 8, 7, 6, 5, 4, 3, 2, 1, 58 | 0 59 | }; 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /silk/tables_pitch_lag.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "tables.h" 33 | 34 | const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ] = { 35 | 253, 250, 244, 233, 212, 182, 150, 131, 36 | 120, 110, 98, 85, 72, 60, 49, 40, 37 | 32, 25, 19, 15, 13, 11, 9, 8, 38 | 7, 6, 5, 4, 3, 2, 1, 0 39 | }; 40 | 41 | const opus_uint8 silk_pitch_delta_iCDF[21] = { 42 | 210, 208, 206, 203, 199, 193, 183, 168, 43 | 142, 104, 74, 52, 37, 27, 20, 14, 44 | 10, 6, 4, 2, 0 45 | }; 46 | 47 | const opus_uint8 silk_pitch_contour_iCDF[34] = { 48 | 223, 201, 183, 167, 152, 138, 124, 111, 49 | 98, 88, 79, 70, 62, 56, 50, 44, 50 | 39, 35, 31, 27, 24, 21, 18, 16, 51 | 14, 12, 10, 8, 6, 4, 3, 2, 52 | 1, 0 53 | }; 54 | 55 | const opus_uint8 silk_pitch_contour_NB_iCDF[11] = { 56 | 188, 176, 155, 138, 119, 97, 67, 43, 57 | 26, 10, 0 58 | }; 59 | 60 | const opus_uint8 silk_pitch_contour_10_ms_iCDF[12] = { 61 | 165, 119, 80, 61, 47, 35, 27, 20, 62 | 14, 9, 4, 0 63 | }; 64 | 65 | const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[3] = { 66 | 113, 63, 0 67 | }; 68 | 69 | 70 | -------------------------------------------------------------------------------- /silk_headers.mk: -------------------------------------------------------------------------------- 1 | SILK_HEAD = \ 2 | silk/debug.h \ 3 | silk/control.h \ 4 | silk/errors.h \ 5 | silk/API.h \ 6 | silk/typedef.h \ 7 | silk/define.h \ 8 | silk/main.h \ 9 | silk/x86/main_sse.h \ 10 | silk/PLC.h \ 11 | silk/structs.h \ 12 | silk/tables.h \ 13 | silk/tuning_parameters.h \ 14 | silk/Inlines.h \ 15 | silk/MacroCount.h \ 16 | silk/MacroDebug.h \ 17 | silk/macros.h \ 18 | silk/pitch_est_defines.h \ 19 | silk/resampler_private.h \ 20 | silk/resampler_rom.h \ 21 | silk/resampler_structs.h \ 22 | silk/SigProc_FIX.h \ 23 | silk/x86/SigProc_FIX_sse.h \ 24 | silk/arm/macros_armv4.h \ 25 | silk/arm/macros_armv5e.h \ 26 | silk/arm/SigProc_FIX_armv4.h \ 27 | silk/arm/SigProc_FIX_armv5e.h \ 28 | silk/fixed/main_FIX.h \ 29 | silk/fixed/structs_FIX.h \ 30 | silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h \ 31 | silk/fixed/mips/prefilter_FIX_mipsr1.h \ 32 | silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h \ 33 | silk/float/main_FLP.h \ 34 | silk/float/structs_FLP.h \ 35 | silk/float/SigProc_FLP.h \ 36 | silk/mips/macros_mipsr1.h \ 37 | silk/mips/NSQ_del_dec_mipsr1.h \ 38 | silk/mips/sigproc_fix_mipsr1.h 39 | -------------------------------------------------------------------------------- /src/mlp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Octasic Inc. 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MLP_H_ 29 | #define _MLP_H_ 30 | 31 | #include "arch.h" 32 | 33 | typedef struct { 34 | int layers; 35 | const int *topo; 36 | const float *weights; 37 | } MLP; 38 | 39 | extern const MLP net; 40 | 41 | void mlp_process(const MLP *m, const float *in, float *out); 42 | 43 | #endif /* _MLP_H_ */ 44 | -------------------------------------------------------------------------------- /src/mlp_train.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Octasic Inc. 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MLP_TRAIN_H_ 29 | #define _MLP_TRAIN_H_ 30 | 31 | #include 32 | #include 33 | 34 | double tansig_table[501]; 35 | static inline double tansig_double(double x) 36 | { 37 | return 2./(1.+exp(-2.*x)) - 1.; 38 | } 39 | static inline void build_tansig_table(void) 40 | { 41 | int i; 42 | for (i=0;i<501;i++) 43 | tansig_table[i] = tansig_double(.04*(i-250)); 44 | } 45 | 46 | static inline double tansig_approx(double x) 47 | { 48 | int i; 49 | double y, dy; 50 | if (x>=10) 51 | return 1; 52 | if (x<=-10) 53 | return -1; 54 | i = lrint(25*x); 55 | x -= .04*i; 56 | y = tansig_table[250+i]; 57 | dy = 1-y*y; 58 | y = y + x*dy*(1 - y*x); 59 | return y; 60 | } 61 | 62 | static inline float randn(float sd) 63 | { 64 | float U1, U2, S, x; 65 | do { 66 | U1 = ((float)rand())/RAND_MAX; 67 | U2 = ((float)rand())/RAND_MAX; 68 | U1 = 2*U1-1; 69 | U2 = 2*U2-1; 70 | S = U1*U1 + U2*U2; 71 | } while (S >= 1 || S == 0.0f); 72 | x = sd*sqrt(-2 * log(S) / S) * U1; 73 | return x; 74 | } 75 | 76 | 77 | typedef struct { 78 | int layers; 79 | int *topo; 80 | double **weights; 81 | double **best_weights; 82 | double *in_rate; 83 | } MLPTrain; 84 | 85 | 86 | #endif /* _MLP_TRAIN_H_ */ 87 | -------------------------------------------------------------------------------- /src/opus_multistream.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "opus_multistream.h" 33 | #include "opus.h" 34 | #include "opus_private.h" 35 | #include "stack_alloc.h" 36 | #include 37 | #include "float_cast.h" 38 | #include "os_support.h" 39 | 40 | 41 | int validate_layout(const ChannelLayout *layout) 42 | { 43 | int i, max_channel; 44 | 45 | max_channel = layout->nb_streams+layout->nb_coupled_streams; 46 | if (max_channel>255) 47 | return 0; 48 | for (i=0;inb_channels;i++) 49 | { 50 | if (layout->mapping[i] >= max_channel && layout->mapping[i] != 255) 51 | return 0; 52 | } 53 | return 1; 54 | } 55 | 56 | 57 | int get_left_channel(const ChannelLayout *layout, int stream_id, int prev) 58 | { 59 | int i; 60 | i = (prev<0) ? 0 : prev+1; 61 | for (;inb_channels;i++) 62 | { 63 | if (layout->mapping[i]==stream_id*2) 64 | return i; 65 | } 66 | return -1; 67 | } 68 | 69 | int get_right_channel(const ChannelLayout *layout, int stream_id, int prev) 70 | { 71 | int i; 72 | i = (prev<0) ? 0 : prev+1; 73 | for (;inb_channels;i++) 74 | { 75 | if (layout->mapping[i]==stream_id*2+1) 76 | return i; 77 | } 78 | return -1; 79 | } 80 | 81 | int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev) 82 | { 83 | int i; 84 | i = (prev<0) ? 0 : prev+1; 85 | for (;inb_channels;i++) 86 | { 87 | if (layout->mapping[i]==stream_id+layout->nb_coupled_streams) 88 | return i; 89 | } 90 | return -1; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/tansig_table.h: -------------------------------------------------------------------------------- 1 | /* This file is auto-generated by gen_tables */ 2 | 3 | static const float tansig_table[201] = { 4 | 0.000000f, 0.039979f, 0.079830f, 0.119427f, 0.158649f, 5 | 0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f, 6 | 0.379949f, 0.413644f, 0.446244f, 0.477700f, 0.507977f, 7 | 0.537050f, 0.564900f, 0.591519f, 0.616909f, 0.641077f, 8 | 0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f, 9 | 0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.821040f, 10 | 0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f, 11 | 0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.915420f, 12 | 0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f, 13 | 0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.961090f, 14 | 0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f, 15 | 0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f, 16 | 0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f, 17 | 0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.992020f, 18 | 0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f, 19 | 0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f, 20 | 0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.997590f, 21 | 0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f, 22 | 0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f, 23 | 0.999000f, 0.999076f, 0.999147f, 0.999213f, 0.999273f, 24 | 0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f, 25 | 0.999550f, 0.999585f, 0.999617f, 0.999646f, 0.999673f, 26 | 0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f, 27 | 0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f, 28 | 0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f, 29 | 0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f, 30 | 0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f, 31 | 0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.999970f, 32 | 0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.999980f, 33 | 0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f, 34 | 0.999988f, 0.999989f, 0.999990f, 0.999990f, 0.999991f, 35 | 0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f, 36 | 0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f, 37 | 0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, 38 | 0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, 39 | 0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f, 40 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 41 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 42 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 43 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 44 | 1.000000f, 45 | }; 46 | -------------------------------------------------------------------------------- /tests/opus_decode_fuzzer.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 1000000 3 | -------------------------------------------------------------------------------- /tests/test_opus_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Xiph.Org Foundation 2 | Written by Gregory Maxwell */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | static OPUS_INLINE void deb2_impl(unsigned char *_t,unsigned char **_p,int _k,int _x,int _y) 29 | { 30 | int i; 31 | if(_x>2){ 32 | if(_y<3)for(i=0;i<_y;i++)*(--*_p)=_t[i+1]; 33 | }else{ 34 | _t[_x]=_t[_x-_y]; 35 | deb2_impl(_t,_p,_k,_x+1,_y); 36 | for(i=_t[_x-_y]+1;i<_k;i++){ 37 | _t[_x]=i; 38 | deb2_impl(_t,_p,_k,_x+1,_x); 39 | } 40 | } 41 | } 42 | 43 | /*Generates a De Bruijn sequence (k,2) with length k^2*/ 44 | static OPUS_INLINE void debruijn2(int _k, unsigned char *_res) 45 | { 46 | unsigned char *p; 47 | unsigned char *t; 48 | t=malloc(sizeof(unsigned char)*_k*2); 49 | memset(t,0,sizeof(unsigned char)*_k*2); 50 | p=&_res[_k*_k]; 51 | deb2_impl(t,&p,_k,1,1); 52 | free(t); 53 | } 54 | 55 | /*MWC RNG of George Marsaglia*/ 56 | static opus_uint32 Rz, Rw; 57 | static OPUS_INLINE opus_uint32 fast_rand(void) 58 | { 59 | Rz=36969*(Rz&65535)+(Rz>>16); 60 | Rw=18000*(Rw&65535)+(Rw>>16); 61 | return (Rz<<16)+Rw; 62 | } 63 | static opus_uint32 iseed; 64 | 65 | #ifdef __GNUC__ 66 | __attribute__((noreturn)) 67 | #endif 68 | static OPUS_INLINE void _test_failed(const char *file, int line) 69 | { 70 | fprintf(stderr,"\n ***************************************************\n"); 71 | fprintf(stderr," *** A fatal error was detected. ***\n"); 72 | fprintf(stderr," ***************************************************\n"); 73 | fprintf(stderr,"Please report this failure and include\n"); 74 | fprintf(stderr,"'make check SEED=%u fails %s at line %d for %s'\n",iseed,file,line,opus_get_version_string()); 75 | fprintf(stderr,"and any relevant details about your system.\n\n"); 76 | abort(); 77 | } 78 | #define test_failed() _test_failed(__FILE__, __LINE__); 79 | -------------------------------------------------------------------------------- /tests/test_opus_padding.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Xiph.Org Foundation 2 | Written by Jüri Aedla and Ralph Giles */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* Check for overflow in reading the padding length. 29 | * http://lists.xiph.org/pipermail/opus/2012-November/001834.html 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | #include "opus.h" 36 | #include "test_opus_common.h" 37 | 38 | #define PACKETSIZE 16909318 39 | #define CHANNELS 2 40 | #define FRAMESIZE 5760 41 | 42 | int test_overflow(void) 43 | { 44 | OpusDecoder *decoder; 45 | int result; 46 | int error; 47 | 48 | unsigned char *in = malloc(PACKETSIZE); 49 | opus_int16 *out = malloc(FRAMESIZE*CHANNELS*sizeof(*out)); 50 | 51 | fprintf(stderr, " Checking for padding overflow... "); 52 | if (!in || !out) { 53 | fprintf(stderr, "FAIL (out of memory)\n"); 54 | return -1; 55 | } 56 | in[0] = 0xff; 57 | in[1] = 0x41; 58 | memset(in + 2, 0xff, PACKETSIZE - 3); 59 | in[PACKETSIZE-1] = 0x0b; 60 | 61 | decoder = opus_decoder_create(48000, CHANNELS, &error); 62 | result = opus_decode(decoder, in, PACKETSIZE, out, FRAMESIZE, 0); 63 | opus_decoder_destroy(decoder); 64 | 65 | free(in); 66 | free(out); 67 | 68 | if (result != OPUS_INVALID_PACKET) { 69 | fprintf(stderr, "FAIL!\n"); 70 | test_failed(); 71 | } 72 | 73 | fprintf(stderr, "OK.\n"); 74 | 75 | return 1; 76 | } 77 | 78 | int main(void) 79 | { 80 | const char *oversion; 81 | int tests = 0;; 82 | 83 | iseed = 0; 84 | oversion = opus_get_version_string(); 85 | if (!oversion) test_failed(); 86 | fprintf(stderr, "Testing %s padding.\n", oversion); 87 | 88 | tests += test_overflow(); 89 | 90 | fprintf(stderr, "All padding tests passed.\n"); 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /version.mk: -------------------------------------------------------------------------------- 1 | # static version string; update manually every release. 2 | PACKAGE_VERSION = "1.1.2" 3 | -------------------------------------------------------------------------------- /win32/VS2010/opus_demo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /win32/VS2010/test_opus_api.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /win32/VS2010/test_opus_decode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4a0dd677-931f-4728-afe5-b761149fc7eb} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /win32/VS2010/test_opus_encode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {546c8d9a-103e-4f78-972b-b44e8d3c8aba} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /win32/VS2015/opus_demo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /win32/VS2015/test_opus_api.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /win32/VS2015/test_opus_decode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4a0dd677-931f-4728-afe5-b761149fc7eb} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /win32/VS2015/test_opus_encode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {546c8d9a-103e-4f78-972b-b44e8d3c8aba} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | -------------------------------------------------------------------------------- /win32/config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2011, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | 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 Internet Society, IETF or IETF Trust, nor the 12 | names of specific contributors, may be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef CONFIG_H 29 | #define CONFIG_H 30 | 31 | #define USE_ALLOCA 1 32 | 33 | /* Comment out the next line for floating-point code */ 34 | /*#define FIXED_POINT 1 */ 35 | 36 | #define OPUS_BUILD 1 37 | 38 | #if defined(_M_IX86) || defined(_M_X64) 39 | /* Can always compile SSE intrinsics (no special compiler flags necessary) */ 40 | #define OPUS_X86_MAY_HAVE_SSE 41 | #define OPUS_X86_MAY_HAVE_SSE2 42 | #define OPUS_X86_MAY_HAVE_SSE4_1 43 | 44 | /* Presume SSE functions, if compiled to use SSE/SSE2/AVX (note that AMD64 implies SSE2, and AVX 45 | implies SSE4.1) */ 46 | #if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) || defined(__AVX__) 47 | #define OPUS_X86_PRESUME_SSE 1 48 | #endif 49 | #if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(__AVX__) 50 | #define OPUS_X86_PRESUME_SSE2 1 51 | #endif 52 | #if defined(__AVX__) 53 | #define OPUS_X86_PRESUME_SSE4_1 1 54 | #endif 55 | 56 | #if !defined(OPUS_X86_PRESUME_SSE4_1) || !defined(OPUS_X86_PRESUME_SSE2) || !defined(OPUS_X86_PRESUME_SSE) 57 | #define OPUS_HAVE_RTCD 1 58 | #endif 59 | 60 | #endif 61 | 62 | #include "version.h" 63 | 64 | #endif /* CONFIG_H */ 65 | -------------------------------------------------------------------------------- /win32/genversion.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal enableextensions enabledelayedexpansion 4 | 5 | for /f %%v in ('git --git-dir="%~dp0..\.git" describe --tags --match "v*"') do set version=%%v 6 | 7 | if not "%version%"=="" goto :gotversion 8 | 9 | if exist "%~dp0..\version.mk" goto :getversion 10 | 11 | echo Git cannot be found, nor can version.mk. Generating unknown version. 12 | 13 | set version=unknown 14 | 15 | goto :gotversion 16 | 17 | :getversion 18 | 19 | for /f "delims== tokens=2" %%v in (%~dps0..\version.mk) do set version=%%v 20 | 21 | set version=!version:^"=! 22 | set version=!version: =! 23 | 24 | :gotversion 25 | 26 | set version_out=#define %~2 "%version%" 27 | set version_mk=%~2 = "%version%" 28 | 29 | echo %version_out%> "%~1_temp" 30 | 31 | if %version%==unknown goto :skipgenerate 32 | 33 | echo # static version string; update manually every release.> "%~dp0..\version.mk" 34 | echo %version_mk%>> "%~dp0..\version.mk" 35 | 36 | :skipgenerate 37 | 38 | echo n | comp "%~1_temp" "%~1" > NUL 2> NUL 39 | 40 | if not errorlevel 1 goto exit 41 | 42 | copy /y "%~1_temp" "%~1" 43 | 44 | :exit 45 | 46 | del "%~1_temp" 47 | --------------------------------------------------------------------------------