├── FLAC ├── AUTHORS ├── COPYING.GPL ├── README ├── all.h ├── assert.h ├── bitmath.c ├── bitreader.c ├── callback.h ├── cpu.c ├── crc.c ├── export.h ├── fixed.c ├── float.c ├── format.c ├── format.h ├── lpc.c ├── md5.c ├── memory.c ├── memory.h ├── metadata.h ├── metadata_iterators.c ├── metadata_object.c ├── ordinals.h ├── private │ ├── all.h │ ├── bitmath.h │ ├── bitreader.h │ ├── cpu.h │ ├── crc.h │ ├── fixed.h │ ├── float.h │ ├── format.h │ ├── lpc.h │ ├── macros.h │ ├── md5.h │ ├── memory.h │ ├── metadata.h │ └── window.h ├── protected │ ├── all.h │ └── stream_decoder.h ├── share │ ├── alloc.h │ ├── compat.h │ └── endswap.h ├── stream_decoder.c ├── stream_decoder.h └── window.c ├── README.md ├── aac.cpp ├── aac ├── aaccommon.h ├── aacdec.c ├── aacdec.h ├── aactabs.c ├── armgcc │ ├── CVS │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── sbrcov.s │ ├── sbrqmfak.s │ └── sbrqmfsk.s ├── armgcc_nosyms │ ├── CVS │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── sbrcov.S │ ├── sbrqmfak.S │ └── sbrqmfsk.S ├── bitstream.c ├── bitstream.h ├── buffers.c ├── coder.h ├── dct4.c ├── decelmnt.c ├── dequant.c ├── docs │ ├── callgraph_aac.doc │ ├── callgraph_sbr.doc │ ├── cpuusage.xls │ └── memory.xls ├── fft.c ├── filefmt.c ├── huffman.c ├── hufftabs.c ├── imdct.c ├── noiseless.c ├── pns.c ├── readme.txt ├── sbr.c ├── sbr.h ├── sbrfft.c ├── sbrfreq.c ├── sbrhfadj.c ├── sbrhfgen.c ├── sbrhuff.c ├── sbrimdct.c ├── sbrmath.c ├── sbrqmf.c ├── sbrside.c ├── sbrtabs.c ├── statname.h ├── stproc.c ├── tns.c ├── trigtabs.c └── trigtabs_fltgen.c ├── asmpoly_thumb2.S ├── audiobuffer.h ├── codecs.cpp ├── codecs.h ├── common ├── assembly.h └── readme.txt ├── examples ├── AacFilePlayer │ └── AacFilePlayer.ino ├── AacFlashPlayer │ ├── AacFlashPlayer.ino │ └── enterauthorizationcode.h ├── Complete_MP3_AAC_MP4_M4A_example │ └── Complete_MP3_AAC_MP4_M4A_example.ino ├── FlacFilePlayer │ ├── FlacFilePlayer.ino │ ├── T1_1024.FLA │ ├── T1_128.FLA │ ├── T1_256.FLA │ └── T1_512.FLA ├── Mp3FilePlayer │ └── Mp3FilePlayer.ino ├── Mp3FilePlayerLFS │ └── Mp3FilePlayerLFS.ino ├── Mp3FilePlayerMSC │ └── Mp3FilePlayerMSC.ino ├── OpusFilePlayer │ └── OpusFilePlayer.ino ├── mjs │ ├── MTP_TEST_AUDIO │ │ └── MTP_TEST_AUDIO.ino │ └── PLAYALL_SD_ONLY │ │ └── PLAYALL_SD_ONLY.ino ├── sd2serialflash │ └── sd2serialflash.ino └── testfiles │ ├── 256K.OPU │ ├── SDTEST1.mp3 │ ├── SDTEST2.mp3 │ ├── SDTEST3.mp3 │ └── SDTEST4.mp3 ├── fixinclude.py ├── flac.cpp ├── keywords.txt ├── library.properties ├── memcpy_frominterleaved.S ├── mp3.cpp ├── mp3 ├── LICENSE.txt ├── RCSL.txt ├── RPSL.txt ├── asmpoly_thumb2.S ├── bitstream.c ├── buffers.c ├── coder.h ├── dct32.c ├── dequant.c ├── doc │ └── polyphase.c ├── dqchan.c ├── huffman.c ├── hufftabs.c ├── imdct.c ├── mp3common.h ├── mp3dec.c ├── mp3dec.h ├── mp3tabs.c ├── mpadecobjfixpt.h ├── scalfact.c ├── statname.h ├── stproc.c ├── subband.c └── trigtabs.c ├── oggcrctable.h ├── oggparse.cpp ├── oggparse.h ├── opus.cpp ├── opus ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── Makefile.mips ├── Makefile.unix ├── NEWS ├── OpusConfig.cmake.in ├── README ├── aclocal.m4 ├── celt │ ├── _kiss_fft_guts.h │ ├── arch.h │ ├── arm │ │ ├── arm2gnu.pl │ │ ├── arm_celt_map.c │ │ ├── armcpu.c │ │ ├── armcpu.h │ │ ├── armopts.s.in │ │ ├── celt_fft_ne10.c │ │ ├── celt_mdct_ne10.c │ │ ├── celt_neon_intr.c │ │ ├── celt_pitch_xcorr_arm-gnu.S │ │ ├── celt_pitch_xcorr_arm.s │ │ ├── fft_arm.h │ │ ├── fixed_arm64.h │ │ ├── fixed_armv4.h │ │ ├── fixed_armv5e.h │ │ ├── kiss_fft_armv4.h │ │ ├── kiss_fft_armv5e.h │ │ ├── mdct_arm.h │ │ ├── pitch_arm.h │ │ └── pitch_neon_intr.c │ ├── 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 │ ├── ecintrin.h │ ├── entcode.c │ ├── entcode.h │ ├── entdec.c │ ├── entdec.h │ ├── entenc.c │ ├── entenc.h │ ├── fixed_debug.h │ ├── fixed_generic.h │ ├── float_cast.h │ ├── kiss_fft.c │ ├── kiss_fft.h │ ├── laplace.c │ ├── laplace.h │ ├── mathops.c │ ├── mathops.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_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.h │ │ ├── celt_lpc_sse4_1.c │ │ ├── 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.cmake.in ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── doc │ ├── Doxyfile.in │ ├── Makefile.am │ ├── Makefile.in │ ├── TODO │ ├── customdoxygen.css │ ├── footer.html │ ├── header.html │ ├── opus_logo.svg │ └── trivial_example.c ├── include │ ├── opus.h │ ├── opus_custom.h │ ├── opus_defines.h │ ├── opus_multistream.h │ ├── opus_projection.h │ └── opus_types.h ├── install-sh ├── ltmain.sh ├── m4 │ ├── as-gcc-inline-assembly.m4 │ ├── ax_add_fortify_source.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_config.cmake ├── opus_functions.cmake ├── opus_headers.mk ├── opus_sources.cmake ├── opus_sources.mk ├── package_version ├── 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 │ │ ├── biquad_alt_arm.h │ │ ├── biquad_alt_neon_intr.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 │ │ ├── arm │ │ │ ├── warped_autocorrelation_FIX_arm.h │ │ │ └── warped_autocorrelation_FIX_neon_intr.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 │ │ │ └── warped_autocorrelation_FIX_mipsr1.h │ │ ├── noise_shape_analysis_FIX.c │ │ ├── pitch_analysis_core_FIX.c │ │ ├── process_gains_FIX.c │ │ ├── regularize_correlations_FIX.c │ │ ├── residual_energy16_FIX.c │ │ ├── residual_energy_FIX.c │ │ ├── schur64_FIX.c │ │ ├── schur_FIX.c │ │ ├── structs_FIX.h │ │ ├── vector_ops_FIX.c │ │ ├── warped_autocorrelation_FIX.c │ │ └── x86 │ │ │ ├── burg_modified_FIX_sse4_1.c │ │ │ └── vector_ops_FIX_sse4_1.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 │ │ ├── main_FLP.h │ │ ├── noise_shape_analysis_FLP.c │ │ ├── pitch_analysis_core_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 │ │ ├── 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_sse4_1.c │ │ ├── NSQ_sse4_1.c │ │ ├── SigProc_FIX_sse.h │ │ ├── VAD_sse4_1.c │ │ ├── VQ_WMat_EC_sse4_1.c │ │ ├── main_sse.h │ │ └── x86_silk_map.c ├── silk_headers.mk ├── silk_sources.mk ├── src │ ├── analysis.c │ ├── analysis.h │ ├── mapping_matrix.c │ ├── mapping_matrix.h │ ├── mlp.c │ ├── mlp.h │ ├── mlp_data.c │ ├── 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 │ ├── opus_projection_decoder.c │ ├── opus_projection_encoder.c │ ├── repacketizer.c │ ├── repacketizer_demo.c │ └── tansig_table.h ├── test-driver └── tests │ ├── 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 │ └── test_opus_projection.c ├── opusconfig.h ├── play_sd_aac.cpp ├── play_sd_aac.h ├── play_sd_flac.cpp ├── play_sd_flac.h ├── play_sd_mp3.cpp ├── play_sd_mp3.h ├── play_sd_opus.cpp └── play_sd_opus.h /FLAC/AUTHORS: -------------------------------------------------------------------------------- 1 | /* FLAC - Free Lossless Audio Codec 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org Foundation 4 | * 5 | * This file is part the FLAC project. FLAC is comprised of several 6 | * components distributed under different licenses. The codec libraries 7 | * are distributed under Xiph.Org's BSD-like license (see the file 8 | * COPYING.Xiph in this distribution). All other programs, libraries, and 9 | * plugins are distributed under the GPL (see COPYING.GPL). The documentation 10 | * is distributed under the Gnu FDL (see COPYING.FDL). Each file in the 11 | * FLAC distribution contains at the top the terms under which it may be 12 | * distributed. 13 | * 14 | * Since this particular file is relevant to all components of FLAC, 15 | * it may be distributed under the Xiph.Org license, which is the least 16 | * restrictive of those mentioned above. See the file COPYING.Xiph in this 17 | * distribution. 18 | */ 19 | 20 | Current FLAC maintainer: Erik de Castro Lopo 21 | 22 | Original author: Josh Coalson 23 | 24 | Website : https://www.xiph.org/flac/ 25 | 26 | FLAC is an Open Source lossless audio codec originally developed by Josh Coalson 27 | between 2001 and 2009. From 2009 to 2012 FLAC was basically unmaintained. In 28 | 2012 the Erik de Castro Lopo became the chief maintainer as part of the 29 | Xiph.Org Foundation. 30 | 31 | Other major contributors and their contributions: 32 | 33 | "lvqcl" 34 | * Visual Studio build system. 35 | * Optimisations in the encoder and decoder. 36 | 37 | "Janne Hyvärinen" 38 | * Visual Studio build system. 39 | * Unicode handling on Windows. 40 | 41 | "Andrey Astafiev" 42 | * Russian translation of the HTML documentation 43 | 44 | "Miroslav Lichvar" 45 | * IA-32 assembly versions of several libFLAC routines 46 | 47 | "Brady Patterson" 48 | * AIFF file support, PPC assembly versions of libFLAC routines 49 | 50 | "Daisuke Shimamura" 51 | * i18n support in the XMMS plugin 52 | 53 | "X-Fixer" 54 | * Configuration system, tag editing, and file info in the Winamp2 plugin 55 | 56 | "Matt Zimmerman" 57 | * Libtool/autoconf/automake make system, flac man page 58 | 59 | -------------------------------------------------------------------------------- /FLAC/assert.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__ASSERT_H 34 | #define FLAC__ASSERT_H 35 | 36 | /* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ 37 | #ifdef DEBUG 38 | #include 39 | #define FLAC__ASSERT(x) assert(x) 40 | #define FLAC__ASSERT_DECLARATION(x) x 41 | #else 42 | #define FLAC__ASSERT(x) 43 | #define FLAC__ASSERT_DECLARATION(x) 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /FLAC/memory.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__MEMORY_H 34 | #define FLAC__PRIVATE__MEMORY_H 35 | 36 | #ifdef HAVE_CONFIG_H 37 | #include 38 | #endif 39 | 40 | #include /* for size_t */ 41 | 42 | #include "private/float.h" 43 | #include "FLAC/ordinals.h" /* for FLAC__bool */ 44 | 45 | /* Returns the unaligned address returned by malloc. 46 | * Use free() on this address to deallocate. 47 | */ 48 | void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); 49 | FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); 50 | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); 51 | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); 52 | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); 53 | #ifndef FLAC__INTEGER_ONLY_LIBRARY 54 | FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); 55 | #endif 56 | void *safe_malloc_mul_2op_p(size_t size1, size_t size2); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /FLAC/private/all.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__ALL_H 34 | #define FLAC__PRIVATE__ALL_H 35 | 36 | #include "bitmath.h" 37 | #include "bitreader.h" 38 | #include "bitwriter.h" 39 | #include "cpu.h" 40 | #include "crc.h" 41 | #include "fixed.h" 42 | #include "float.h" 43 | #include "format.h" 44 | #include "lpc.h" 45 | #include "md5.h" 46 | #include "memory.h" 47 | #include "metadata.h" 48 | #include "stream_encoder_framing.h" 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /FLAC/private/crc.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__CRC_H 34 | #define FLAC__PRIVATE__CRC_H 35 | 36 | #include "FLAC/ordinals.h" 37 | 38 | /* 8 bit CRC generator, MSB shifted first 39 | ** polynomial = x^8 + x^2 + x^1 + x^0 40 | ** init = 0 41 | */ 42 | extern FLAC__byte const FLAC__crc8_table[256]; 43 | #define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)]; 44 | void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc); 45 | void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc); 46 | FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len); 47 | 48 | /* 16 bit CRC generator, MSB shifted first 49 | ** polynomial = x^16 + x^15 + x^2 + x^0 50 | ** init = 0 51 | */ 52 | extern unsigned const FLAC__crc16_table[256]; 53 | 54 | #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) 55 | /* this alternate may be faster on some systems/compilers */ 56 | #if 0 57 | #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff) 58 | #endif 59 | 60 | unsigned FLAC__crc16(const FLAC__byte *data, unsigned len); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /FLAC/private/format.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__FORMAT_H 34 | #define FLAC__PRIVATE__FORMAT_H 35 | 36 | #include "FLAC/format.h" 37 | 38 | unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order); 39 | unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize); 40 | unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order); 41 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 42 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 43 | FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /FLAC/private/macros.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2012-2014 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef FLAC__PRIVATE__MACROS_H 33 | #define FLAC__PRIVATE__MACROS_H 34 | 35 | #if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3)) 36 | 37 | #define flac_max(a,b) \ 38 | ({ __typeof__ (a) _a = (a); \ 39 | __typeof__ (b) _b = (b); \ 40 | _a > _b ? _a : _b; }) 41 | 42 | #define MIN_PASTE(A,B) A##B 43 | #define MIN_IMPL(A,B,L) ({ \ 44 | __typeof__(A) MIN_PASTE(__a,L) = (A); \ 45 | __typeof__(B) MIN_PASTE(__b,L) = (B); \ 46 | MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \ 47 | }) 48 | 49 | #define flac_min(A,B) MIN_IMPL(A,B,__COUNTER__) 50 | 51 | /* Whatever other unix that has sys/param.h */ 52 | #elif defined(HAVE_SYS_PARAM_H) 53 | #include 54 | #define flac_max(a,b) MAX(a,b) 55 | #define flac_min(a,b) MIN(a,b) 56 | 57 | /* Windows VS has them in stdlib.h.. XXX:Untested */ 58 | #elif defined(_MSC_VER) 59 | #include 60 | #define flac_max(a,b) __max(a,b) 61 | #define flac_min(a,b) __min(a,b) 62 | #endif 63 | 64 | #ifndef MIN 65 | #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 66 | #endif 67 | 68 | #ifndef MAX 69 | #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /FLAC/private/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef FLAC__PRIVATE__MD5_H 2 | #define FLAC__PRIVATE__MD5_H 3 | 4 | /* 5 | * This is the header file for the MD5 message-digest algorithm. 6 | * The algorithm is due to Ron Rivest. This code was 7 | * written by Colin Plumb in 1993, no copyright is claimed. 8 | * This code is in the public domain; do with it what you wish. 9 | * 10 | * Equivalent code is available from RSA Data Security, Inc. 11 | * This code has been tested against that, and is equivalent, 12 | * except that you don't need to include two pages of legalese 13 | * with every copy. 14 | * 15 | * To compute the message digest of a chunk of bytes, declare an 16 | * MD5Context structure, pass it to MD5Init, call MD5Update as 17 | * needed on buffers full of bytes, and then call MD5Final, which 18 | * will fill a supplied 16-byte array with the digest. 19 | * 20 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 21 | * header definitions; now uses stuff from dpkg's config.h 22 | * - Ian Jackson . 23 | * Still in the public domain. 24 | * 25 | * Josh Coalson: made some changes to integrate with libFLAC. 26 | * Still in the public domain, with no warranty. 27 | */ 28 | 29 | #include "FLAC/ordinals.h" 30 | 31 | typedef union { 32 | FLAC__byte *p8; 33 | FLAC__int16 *p16; 34 | FLAC__int32 *p32; 35 | } FLAC__multibyte; 36 | 37 | typedef struct { 38 | FLAC__uint32 in[16]; 39 | FLAC__uint32 buf[4]; 40 | FLAC__uint32 bytes[2]; 41 | FLAC__multibyte internal_buf; 42 | size_t capacity; 43 | } FLAC__MD5Context; 44 | 45 | void FLAC__MD5Init(FLAC__MD5Context *context); 46 | void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); 47 | 48 | FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /FLAC/private/memory.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__MEMORY_H 34 | #define FLAC__PRIVATE__MEMORY_H 35 | 36 | #ifdef HAVE_CONFIG_H 37 | #include 38 | #endif 39 | 40 | #include /* for size_t */ 41 | 42 | #include "float.h" 43 | #include "FLAC/ordinals.h" /* for FLAC__bool */ 44 | 45 | /* Returns the unaligned address returned by malloc. 46 | * Use free() on this address to deallocate. 47 | */ 48 | void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); 49 | FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); 50 | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); 51 | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); 52 | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); 53 | #ifndef FLAC__INTEGER_ONLY_LIBRARY 54 | FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); 55 | #endif 56 | void *safe_malloc_mul_2op_p(size_t size1, size_t size2); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /FLAC/private/metadata.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2002-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PRIVATE__METADATA_H 34 | #define FLAC__PRIVATE__METADATA_H 35 | 36 | #include "FLAC/metadata.h" 37 | 38 | /* WATCHOUT: all malloc()ed data in the block is free()ed; this may not 39 | * be a consistent state (e.g. PICTURE) or equivalent to the initial 40 | * state after FLAC__metadata_object_new() 41 | */ 42 | void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object); 43 | 44 | void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /FLAC/protected/all.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PROTECTED__ALL_H 34 | #define FLAC__PROTECTED__ALL_H 35 | 36 | #include "stream_decoder.h" 37 | #include "stream_encoder.h" 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /FLAC/protected/stream_decoder.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2014 Xiph.Org 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 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 FOUNDATION OR 24 | * 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 FLAC__PROTECTED__STREAM_DECODER_H 34 | #define FLAC__PROTECTED__STREAM_DECODER_H 35 | 36 | #include "FLAC/stream_decoder.h" 37 | #if FLAC__HAS_OGG 38 | #include "private/ogg_decoder_aspect.h" 39 | #endif 40 | 41 | typedef struct FLAC__StreamDecoderProtected { 42 | FLAC__StreamDecoderState state; 43 | FLAC__StreamDecoderInitStatus initstate; 44 | unsigned channels; 45 | FLAC__ChannelAssignment channel_assignment; 46 | unsigned bits_per_sample; 47 | unsigned sample_rate; /* in Hz */ 48 | unsigned blocksize; /* in samples (per channel) */ 49 | FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */ 50 | #if FLAC__HAS_OGG 51 | FLAC__OggDecoderAspect ogg_decoder_aspect; 52 | #endif 53 | } FLAC__StreamDecoderProtected; 54 | 55 | /* 56 | * return the number of input bytes consumed 57 | */ 58 | unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /FLAC/share/endswap.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2012-2014 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 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /* It is assumed that this header will be included after "config.h". */ 33 | 34 | #if HAVE_BSWAP32 /* GCC and Clang */ 35 | 36 | /* GCC prior to 4.8 didn't provide bswap16 on x86_64 */ 37 | #if ! HAVE_BSWAP16 38 | static inline unsigned short __builtin_bswap16(unsigned short a) 39 | { 40 | return (a<<8)|(a>>8); 41 | } 42 | #endif 43 | 44 | #define ENDSWAP_16(x) (__builtin_bswap16 (x)) 45 | #define ENDSWAP_32(x) (__builtin_bswap32 (x)) 46 | 47 | #elif defined _MSC_VER /* Windows. Apparently in . */ 48 | 49 | #define ENDSWAP_16(x) (_byteswap_ushort (x)) 50 | #define ENDSWAP_32(x) (_byteswap_ulong (x)) 51 | 52 | #elif defined HAVE_BYTESWAP_H /* Linux */ 53 | 54 | #include 55 | 56 | #define ENDSWAP_16(x) (bswap_16 (x)) 57 | #define ENDSWAP_32(x) (bswap_32 (x)) 58 | 59 | #else 60 | 61 | #define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8)) 62 | #define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24)) 63 | 64 | #endif 65 | 66 | 67 | /* Host to little-endian byte swapping. */ 68 | #if CPU_IS_BIG_ENDIAN 69 | 70 | #define H2LE_16(x) ENDSWAP_16 (x) 71 | #define H2LE_32(x) ENDSWAP_32 (x) 72 | 73 | #else 74 | 75 | #define H2LE_16(x) (x) 76 | #define H2LE_32(x) (x) 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Arduino-Teensy-Codec-lib 2 | ====================== 3 | 4 | Audiolibrary plugin, plays up to 320 kbps MP3, MP4(AAC), M4A(AAC), AAC-Raw or FLAC in software without external hardware - 5 | with only 48MHz. 6 | 7 | - Optimized for ARM Thumb2. 8 | - Play from SD, built-in Flash or optional serial Flash (with audio-shield) 9 | - Flac 4-24 BIT, (Teensy <= 3.2: Blocksize 128-1024 Bytes) 10 | 11 | TODO: 12 | - parse ID3 / APE / MP4 for extended information 13 | 14 | not possible: SBR (aac-HE (low bitrate)) - (not enough ram). 15 | -------------------------------------------------------------------------------- /aac.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "common/assembly.h" 3 | 4 | #include "aac/aacdec.h" 5 | #include "aac/aacdec.c" 6 | #include "aac/bitstream.c" 7 | #include "aac/buffers.c" 8 | #include "aac/noiseless.c" 9 | #include "aac/filefmt.c" 10 | #include "aac/dequant.c" 11 | #include "aac/decelmnt.c" 12 | #include "aac/stproc.c" 13 | #include "aac/pns.c" 14 | #include "aac/tns.c" 15 | #include "aac/dct4.c" 16 | #include "aac/imdct.c" 17 | #include "aac/fft.c" 18 | 19 | #include "aac/aactabs.c" 20 | #include "aac/trigtabs.c" 21 | 22 | #include "aac/huffman.c" 23 | #include "aac/hufftabs.c" -------------------------------------------------------------------------------- /aac/armgcc/CVS/Entries: -------------------------------------------------------------------------------- 1 | /sbrcov.s/1.1/Sat Feb 26 01:47:35 2005// 2 | /sbrqmfak.s/1.1/Sat Feb 26 01:47:35 2005// 3 | /sbrqmfsk.s/1.1/Sat Feb 26 01:47:35 2005// 4 | D 5 | -------------------------------------------------------------------------------- /aac/armgcc/CVS/Repository: -------------------------------------------------------------------------------- 1 | /cvsroot/datatype/aac/codec/fixpt/decoder/real/asm/armgcc 2 | -------------------------------------------------------------------------------- /aac/armgcc/CVS/Root: -------------------------------------------------------------------------------- 1 | :ext:andreas-s@cvs.helixcommunity.org:/cvsroot/datatype 2 | -------------------------------------------------------------------------------- /aac/armgcc_nosyms/CVS/Entries: -------------------------------------------------------------------------------- 1 | /sbrcov.s/1.1/Fri Apr 8 21:59:46 2005// 2 | /sbrqmfak.s/1.1/Fri Apr 8 21:59:46 2005// 3 | /sbrqmfsk.s/1.1/Fri Apr 8 21:59:46 2005// 4 | D 5 | -------------------------------------------------------------------------------- /aac/armgcc_nosyms/CVS/Repository: -------------------------------------------------------------------------------- 1 | /cvsroot/datatype/aac/codec/fixpt/decoder/real/asm/armgcc_nosyms 2 | -------------------------------------------------------------------------------- /aac/armgcc_nosyms/CVS/Root: -------------------------------------------------------------------------------- 1 | :ext:andreas-s@cvs.helixcommunity.org:/cvsroot/datatype 2 | -------------------------------------------------------------------------------- /aac/docs/callgraph_aac.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/aac/docs/callgraph_aac.doc -------------------------------------------------------------------------------- /aac/docs/callgraph_sbr.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/aac/docs/callgraph_sbr.doc -------------------------------------------------------------------------------- /aac/docs/cpuusage.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/aac/docs/cpuusage.xls -------------------------------------------------------------------------------- /aac/docs/memory.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/aac/docs/memory.xls -------------------------------------------------------------------------------- /aac/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/aac/readme.txt -------------------------------------------------------------------------------- /audiobuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Audiocodecs 3 | 4 | Copyright (c) 2014 Frank Bösing 5 | 6 | This library is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library. If not, see . 18 | 19 | 20 | Diese Bibliothek ist freie Software: Sie können es unter den Bedingungen 21 | der GNU General Public License, wie von der Free Software Foundation, 22 | Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren 23 | veröffentlichten Version, weiterverbreiten und/oder modifizieren. 24 | 25 | Diese Bibliothek wird in der Hoffnung, dass es nützlich sein wird, aber 26 | OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite 27 | Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. 28 | Siehe die GNU General Public License für weitere Details. 29 | 30 | Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 31 | Programm erhalten haben. Wenn nicht, siehe . 32 | 33 | */ 34 | 35 | #ifndef audiobuffer_h_ 36 | #define audiobuffer_h_ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | class AudioBuffer 43 | { 44 | public: 45 | AudioBuffer() { init(); } 46 | ~AudioBuffer(){ if (data) free(data); init(); } 47 | void allocMem(size_t size){ 48 | __disable_irq(); 49 | data = (int16_t*) malloc(size * AUDIO_BLOCK_SAMPLES * sizeof(int16_t)); 50 | if (data) bufsize=freespace=size; else bufsize=freespace=0; 51 | read=write=0; 52 | __enable_irq(); 53 | } 54 | size_t available(){ return freespace; } 55 | size_t used(){ return bufsize-freespace; } 56 | size_t getBufsize(void) {return bufsize;} 57 | int16_t *alloc(void) 58 | { 59 | int16_t *ret = NULL; 60 | __disable_irq(); 61 | if (freespace > 0) 62 | { 63 | freespace--; 64 | ret = data + write * AUDIO_BLOCK_SAMPLES; 65 | write++; 66 | if (write >= bufsize) write=0; 67 | } 68 | __enable_irq(); 69 | return ret; 70 | } 71 | int16_t *get(void) 72 | { 73 | int16_t *ret = NULL; 74 | __disable_irq(); 75 | if (freespace < bufsize) { 76 | freespace++; 77 | ret = data + read * AUDIO_BLOCK_SAMPLES; 78 | read++; 79 | if (read >= bufsize) read=0; 80 | } 81 | __enable_irq(); 82 | return ret; 83 | } 84 | protected: 85 | void init(void) {bufsize=freespace=read=write=0;data=NULL;} 86 | int16_t *data; 87 | size_t bufsize, freespace, read, write; 88 | 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /common/readme.txt: -------------------------------------------------------------------------------- 1 | TODO: 2 | Add more files here. 3 | 4 | Candidates: huffman, bitstream, buffers.... -------------------------------------------------------------------------------- /examples/AacFilePlayer/AacFilePlayer.ino: -------------------------------------------------------------------------------- 1 | // Simple AAC/MP4/M4A file player example 2 | // 3 | // Requires the audio shield: 4 | // http://www.pjrc.com/store/teensy3_audio.html 5 | // 6 | // This example code is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // GUItool: begin automatically generated code 16 | AudioPlaySdAac playAac1; //xy=154,78 17 | AudioOutputI2S i2s1; //xy=334,89 18 | AudioConnection patchCord1(playAac1, 0, i2s1, 0); 19 | AudioConnection patchCord2(playAac1, 1, i2s1, 1); 20 | AudioControlSGTL5000 sgtl5000_1; //xy=240,153 21 | // GUItool: end automatically generated code 22 | 23 | void setup() { 24 | Serial.begin(9600); 25 | 26 | // Audio connections require memory to work. For more 27 | // detailed information, see the MemoryAndCpuUsage example 28 | AudioMemory(2); 29 | 30 | sgtl5000_1.enable(); 31 | sgtl5000_1.volume(0.5); 32 | 33 | SPI.setMOSI(7); 34 | SPI.setSCK(14); 35 | 36 | if (!(SD.begin(10))) { 37 | // stop here, but print a message repetitively 38 | while (1) { 39 | Serial.println("Unable to access the SD card"); 40 | delay(500); 41 | } 42 | } 43 | } 44 | 45 | void playFile(const char *filename) 46 | { 47 | Serial.print("Playing file: "); 48 | Serial.println(filename); 49 | 50 | // Start playing the file. This sketch continues to 51 | // run while the file plays. 52 | playAac1.play(filename); 53 | 54 | // Simply wait for the file to finish playing. 55 | while (playAac1.isPlaying()) { 56 | // uncomment these lines if your audio shield 57 | // has the optional volume pot soldered 58 | //float vol = analogRead(15); 59 | //vol = vol / 1024; 60 | // sgtl5000_1.volume(vol); 61 | 62 | #if 0 63 | Serial.print("Max Usage: "); 64 | Serial.print(playAac1.processorUsageMax()); 65 | Serial.print("% Audio, "); 66 | Serial.print(playAac1.processorUsageMaxDecoder()); 67 | Serial.print("% Decoding max, "); 68 | 69 | Serial.print(playAac1.processorUsageMaxSD()); 70 | Serial.print("% SD max, "); 71 | 72 | Serial.print(AudioProcessorUsageMax()); 73 | Serial.println("% All"); 74 | 75 | AudioProcessorUsageMaxReset(); 76 | playAac1.processorUsageMaxReset(); 77 | playAac1.processorUsageMaxResetDecoder(); 78 | #endif 79 | 80 | delay(200); 81 | } 82 | 83 | 84 | 85 | } 86 | 87 | 88 | void loop() { 89 | playFile("aac1.aac"); 90 | playFile("mp42.mp4"); 91 | playFile("mp41.mp4"); 92 | playFile("aac2.m4a"); 93 | playFile("aac1.m4a"); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /examples/AacFlashPlayer/AacFlashPlayer.ino: -------------------------------------------------------------------------------- 1 | // Simple AAC/MP4/M4A file player example 2 | // Plays Audio from Teensy Flash 3 | // 4 | // Tip: Use https://code.google.com/p/bin2h/ 5 | // to convert files to *.h or equivalent tool. 6 | // 7 | // Requires the audio shield: 8 | // http://www.pjrc.com/store/teensy3_audio.html 9 | // 10 | // This example code is in the public domain. 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include "enterauthorizationcode.h" 19 | 20 | 21 | // GUItool: begin automatically generated code 22 | AudioPlaySdAac playAac1; //xy=154,78 23 | AudioOutputI2S i2s1; //xy=334,89 24 | AudioConnection patchCord1(playAac1, 0, i2s1, 0); 25 | AudioConnection patchCord2(playAac1, 1, i2s1, 1); 26 | AudioControlSGTL5000 sgtl5000_1; //xy=240,153 27 | // GUItool: end automatically generated code 28 | 29 | void setup() { 30 | Serial.begin(9600); 31 | 32 | delay(1000); 33 | // Audio connections require memory to work. For more 34 | // detailed information, see the MemoryAndCpuUsage example 35 | AudioMemory(2); 36 | 37 | sgtl5000_1.enable(); 38 | sgtl5000_1.volume(0.5); 39 | 40 | SPI.setMOSI(7); 41 | SPI.setSCK(14); 42 | } 43 | 44 | 45 | void loop() { 46 | Serial.println("Enter authorization code.\r\n"); 47 | playAac1.play((uint8_t*)&enterauthorizationcode_data, enterauthorizationcode_data_len); 48 | while (playAac1.isPlaying()) {;} 49 | delay(2000); 50 | } 51 | -------------------------------------------------------------------------------- /examples/FlacFilePlayer/FlacFilePlayer.ino: -------------------------------------------------------------------------------- 1 | // Simple Flac file player example 2 | // 3 | // Requires the audio shield: 4 | // http://www.pjrc.com/store/teensy3_audio.html 5 | // 6 | // This example code is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | 16 | // GUItool: begin automatically generated code 17 | AudioPlaySdFlac playFlac1; //xy=154,78 18 | AudioOutputI2S i2s1; //xy=334,89 19 | AudioConnection patchCord1(playFlac1, 0, i2s1, 0); 20 | AudioConnection patchCord2(playFlac1, 1, i2s1, 1); 21 | AudioControlSGTL5000 sgtl5000_1; //xy=240,153 22 | // GUItool: end automatically generated code 23 | 24 | void setup() { 25 | Serial.begin(9600); 26 | 27 | // Audio connections require memory to work. For more 28 | // detailed information, see the MemoryAndCpuUsage example 29 | AudioMemory(6); 30 | 31 | sgtl5000_1.enable(); 32 | sgtl5000_1.volume(0.5); 33 | 34 | SPI.setMOSI(7); 35 | SPI.setSCK(14); 36 | if (!(SD.begin(10))) { 37 | // stop here, but print a message repetitively 38 | while (1) { 39 | Serial.println("Unable to access the SD card"); 40 | delay(500); 41 | } 42 | } 43 | } 44 | 45 | void playFile(const char *filename) 46 | { 47 | Serial.print("Playing file: "); 48 | Serial.println(filename); 49 | 50 | // Start playing the file. This sketch continues to 51 | // run while the file plays. 52 | playFlac1.play(filename); 53 | 54 | // Simply wait for the file to finish playing. 55 | while (playFlac1.isPlaying()) { 56 | // uncomment these lines if your audio shield 57 | // has the optional volume pot soldered 58 | //float vol = analogRead(15); 59 | //vol = vol / 1024; 60 | // sgtl5000_1.volume(vol); 61 | 62 | #if 1 63 | Serial.print(AudioProcessorUsageMax()); 64 | Serial.println("% Audio"); 65 | AudioProcessorUsageMaxReset(); 66 | #endif 67 | delay(200); 68 | } 69 | 70 | } 71 | 72 | 73 | void loop() { 74 | playFile("T1_128.FLA"); 75 | 76 | delay(500); 77 | } 78 | -------------------------------------------------------------------------------- /examples/FlacFilePlayer/T1_1024.FLA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/FlacFilePlayer/T1_1024.FLA -------------------------------------------------------------------------------- /examples/FlacFilePlayer/T1_128.FLA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/FlacFilePlayer/T1_128.FLA -------------------------------------------------------------------------------- /examples/FlacFilePlayer/T1_256.FLA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/FlacFilePlayer/T1_256.FLA -------------------------------------------------------------------------------- /examples/FlacFilePlayer/T1_512.FLA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/FlacFilePlayer/T1_512.FLA -------------------------------------------------------------------------------- /examples/Mp3FilePlayer/Mp3FilePlayer.ino: -------------------------------------------------------------------------------- 1 | // Simple MP3 player example 2 | // 3 | // Requires the audio shield: 4 | // http://www.pjrc.com/store/teensy3_audio.html 5 | // 6 | // This example code is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | 16 | // GUItool: begin automatically generated code 17 | AudioPlaySdMp3 playMp31; //xy=154,78 18 | AudioOutputI2S i2s1; //xy=334,89 19 | AudioConnection patchCord1(playMp31, 0, i2s1, 0); 20 | AudioConnection patchCord2(playMp31, 1, i2s1, 1); 21 | AudioControlSGTL5000 sgtl5000_1; //xy=240,153 22 | // GUItool: end automatically generated code 23 | 24 | void setup() { 25 | Serial.begin(9600); 26 | 27 | // Audio connections require memory to work. For more 28 | // detailed information, see the MemoryAndCpuUsage example 29 | AudioMemory(5); 30 | 31 | sgtl5000_1.enable(); 32 | sgtl5000_1.volume(0.5); 33 | 34 | SPI.setMOSI(7); 35 | SPI.setSCK(14); 36 | if (!(SD.begin(10))) { 37 | // stop here, but print a message repetitively 38 | while (1) { 39 | Serial.println("Unable to access the SD card"); 40 | delay(500); 41 | } 42 | } 43 | } 44 | 45 | void playFile(const char *filename) 46 | { 47 | Serial.print("Playing file: "); 48 | Serial.println(filename); 49 | 50 | // Start playing the file. This sketch continues to 51 | // run while the file plays. 52 | playMp31.play(filename); 53 | 54 | // Simply wait for the file to finish playing. 55 | while (playMp31.isPlaying()) { 56 | // uncomment these lines if your audio shield 57 | // has the optional volume pot soldered 58 | //float vol = analogRead(15); 59 | //vol = vol / 1024; 60 | // sgtl5000_1.volume(vol); 61 | 62 | #if 0 63 | Serial.print("Max Usage: "); 64 | Serial.print(playMp31.processorUsageMax()); 65 | Serial.print("% Audio, "); 66 | Serial.print(playMp31.processorUsageMaxDecoder()); 67 | Serial.print("% Decoding max, "); 68 | 69 | Serial.print(playMp31.processorUsageMaxSD()); 70 | Serial.print("% SD max, "); 71 | 72 | Serial.print(AudioProcessorUsageMax()); 73 | Serial.println("% All"); 74 | 75 | AudioProcessorUsageMaxReset(); 76 | playMp31.processorUsageMaxReset(); 77 | playMp31.processorUsageMaxResetDecoder(); 78 | #endif 79 | 80 | delay(250); 81 | } 82 | } 83 | 84 | 85 | void loop() { 86 | playFile("ForTag.mp3"); 87 | playFile("Tom.mp3"); 88 | playFile("Foreverm.mp3"); 89 | delay(500); 90 | } 91 | -------------------------------------------------------------------------------- /examples/Mp3FilePlayerMSC/Mp3FilePlayerMSC.ino: -------------------------------------------------------------------------------- 1 | // Simple MP3 player example for USB drives. 2 | // 3 | // Requires the audio shield: 4 | // http://www.pjrc.com/store/teensy3_audio.html 5 | // 6 | // This example code is in the public domain. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Setup USBHost_t36 and as many HUB ports as needed. 16 | USBHost myusb; 17 | USBHub hub1(myusb); 18 | USBHub hub2(myusb); 19 | USBHub hub3(myusb); 20 | USBHub hub4(myusb); 21 | 22 | 23 | USBFilesystem mscFS1(myusb); 24 | USBDrive drive1(myusb); 25 | 26 | // GUItool: begin automatically generated code 27 | AudioPlaySdMp3 playMp31; //xy=154,78 28 | AudioOutputI2S i2s1; //xy=334,89 29 | AudioConnection patchCord1(playMp31, 0, i2s1, 0); 30 | AudioConnection patchCord2(playMp31, 1, i2s1, 1); 31 | AudioControlSGTL5000 sgtl5000_1; //xy=240,153 32 | // GUItool: end automatically generated code 33 | 34 | void setup() { 35 | Serial.begin(9600); 36 | 37 | // Audio connections require memory to work. For more 38 | // detailed information, see the MemoryAndCpuUsage example 39 | AudioMemory(5); 40 | 41 | sgtl5000_1.enable(); 42 | sgtl5000_1.volume(0.7); 43 | 44 | // Initialize USBHost_t36 45 | myusb.begin(); 46 | delay(100); 47 | 48 | if (!mscFS1.begin(&drive1)) { 49 | // stop here, but print a message repetitively 50 | while (1) { 51 | Serial.println("Unable to access the drive..."); 52 | delay(500); 53 | } 54 | } 55 | myusb.Task(); 56 | } 57 | 58 | void playFile(const char *filename) 59 | { 60 | Serial.printf("Playing file: %s\r\n",filename); 61 | // Start playing the file. This sketch continues to 62 | // run while the file plays. 63 | playMp31.play(&mscFS1, filename); 64 | // Simply wait for the file to finish playing. 65 | while (playMp31.isPlaying()) { 66 | // uncomment these lines if your audio shield 67 | // has the optional volume pot soldered 68 | float vol = analogRead(15); 69 | vol = vol / 1024; 70 | sgtl5000_1.volume(vol); 71 | delay(250); 72 | } 73 | } 74 | 75 | 76 | void loop() { 77 | // playFile("ForTag.mp3"); 78 | // playFile("Tom.mp3"); 79 | // playFile("Foreverm.mp3"); 80 | delay(500); 81 | } 82 | -------------------------------------------------------------------------------- /examples/testfiles/256K.OPU: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/testfiles/256K.OPU -------------------------------------------------------------------------------- /examples/testfiles/SDTEST1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/testfiles/SDTEST1.mp3 -------------------------------------------------------------------------------- /examples/testfiles/SDTEST2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/testfiles/SDTEST2.mp3 -------------------------------------------------------------------------------- /examples/testfiles/SDTEST3.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/testfiles/SDTEST3.mp3 -------------------------------------------------------------------------------- /examples/testfiles/SDTEST4.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/examples/testfiles/SDTEST4.mp3 -------------------------------------------------------------------------------- /fixinclude.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | import re 5 | from pathlib import Path 6 | import os 7 | 8 | cfiles = [] 9 | hfiles = [] 10 | 11 | d = Path(sys.argv[1]).resolve() 12 | for path in d.rglob('*.c'): 13 | cfiles += [path] 14 | for path in d.rglob('*.h'): 15 | hfiles += [path] 16 | 17 | print(cfiles) 18 | print(hfiles) 19 | 20 | for fn in cfiles + hfiles: 21 | print(fn) 22 | pd = fn.parent 23 | lines = open(fn).readlines() 24 | f = open(fn, "w") 25 | for line in lines: 26 | m = re.match('# *include *("|<)([^">]*)("|>)', line) 27 | if m: 28 | hname = Path(m.group(2)).name 29 | found = False 30 | for hf in hfiles: 31 | if hname == hf.name: 32 | assert not found 33 | found = True 34 | print("",os.path.relpath(hf, pd)) 35 | f.write('#include "' + os.path.relpath(hf, pd) + '"\n') 36 | if not found: 37 | f.write(line) 38 | else: 39 | f.write(line) 40 | -------------------------------------------------------------------------------- /flac.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define VERSION "1.3.1" 3 | #define FLAC__INTEGER_ONLY_LIBRARY 1 4 | //#define FLAC__OVERFLOW_DETECT 1 5 | #define HAVE_BSWAP32 1 6 | #define HAVE_BSWAP16 1 7 | 8 | #include "FLAC/all.h" 9 | #include "FLAC/lpc.c" 10 | #include "FLAC/format.c" 11 | #include "FLAC/float.c" 12 | #include "FLAC/fixed.c" 13 | #include "FLAC/md5.c" 14 | #include "FLAC/crc.c" 15 | #include "FLAC/bitreader.c" 16 | #include "FLAC/bitmath.c" 17 | #include "FLAC/memory.c" 18 | #include "FLAC/stream_decoder.c" 19 | #include "FLAC/cpu.c" 20 | 21 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | AudioPlaySdMp3 KEYWORD2 16 | AudioPlaySdAac KEYWORD2 17 | 18 | ####################################### 19 | # Constants (LITERAL1) 20 | ####################################### 21 | 22 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Audiocodecs 2 | version=0.32 3 | author=Frank Boesing 4 | maintainer=Frank Boesing 5 | sentence=Audiocodecs for Teensy 6 | paragraph= 7 | category=Communication 8 | url=https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib 9 | architectures=* 10 | -------------------------------------------------------------------------------- /memcpy_frominterleaved.S: -------------------------------------------------------------------------------- 1 | /* 2 | Helix library Arduino interface 3 | 4 | Copyright (c) 2014-2016 Frank Bösing 5 | 6 | This library is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library. If not, see . 18 | 19 | The helix decoder itself as a different license, look at the subdirectories for more info. 20 | 21 | Diese Bibliothek ist freie Software: Sie können es unter den Bedingungen 22 | der GNU General Public License, wie von der Free Software Foundation, 23 | Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren 24 | veröffentlichten Version, weiterverbreiten und/oder modifizieren. 25 | 26 | Diese Bibliothek wird in der Hoffnung, dass es nützlich sein wird, aber 27 | OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite 28 | Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. 29 | Siehe die GNU General Public License für weitere Details. 30 | 31 | Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 32 | Programm erhalten haben. Wenn nicht, siehe . 33 | 34 | Der Helixdecoder selbst hat eine eigene Lizenz, bitte für mehr Informationen 35 | in den Unterverzeichnissen nachsehen. 36 | 37 | */ 38 | 39 | #if TEENSYDUINO>132 40 | #include 41 | #else 42 | #define AUDIO_BLOCK_SAMPLES 128 43 | #endif 44 | 45 | //Fast copy decoded data (interleaved LRLRLR) to the two audiobuffers (LLL, RRR) 46 | 47 | .cpu cortex-m4 48 | .syntax unified 49 | .thumb 50 | .text 51 | .align 2 52 | .global memcpy_frominterleaved 53 | 54 | /* void memcpy_frominterleaved(int16_t *dst1, int16_t *dst2, int16_t *src); */ 55 | .global memcpy_frominterleaved 56 | .thumb_func 57 | memcpy_frominterleaved: 58 | 59 | @ r0: dst1 60 | @ r1: dst2 61 | @ r2: src 62 | 63 | push {r4-r11,r14} 64 | add r14,r0,#AUDIO_BLOCK_SAMPLES * 2 65 | .align 2 66 | .loop: 67 | 68 | .irp offset, 1,2,3,4 69 | 70 | //load 8 words (32 byte) at once into r3-r10 increase adress of r2 71 | ldmia r2!,{r3, r4, r5, r6, r7, r8, r9, r10} 72 | 73 | pkhbt r11, r3, r4, lsl #16 74 | pkhbt r12, r5, r6, lsl #16 75 | stmia r0!,{r11,r12} 76 | 77 | pkhtb r11, r4, r3, asr #16 78 | pkhtb r12, r6, r5, asr #16 79 | stmia r1!,{r11,r12} 80 | 81 | pkhbt r3, r7, r8, lsl #16 82 | pkhbt r4, r9, r10, lsl #16 83 | stmia r0!,{r3,r4} 84 | 85 | pkhtb r5, r8, r7, asr #16 86 | pkhtb r6, r10, r9, asr #16 87 | stmia r1!,{r5,r6} 88 | 89 | .endr 90 | 91 | cmp r14, r0 92 | bne .loop 93 | 94 | pop {r4-r11,r14} 95 | 96 | BX lr 97 | .END 98 | -------------------------------------------------------------------------------- /mp3.cpp: -------------------------------------------------------------------------------- 1 | 2 | //#include 3 | 4 | #include "common/assembly.h" 5 | 6 | #include "mp3/mp3dec.h" 7 | #include "mp3/mp3dec.c" 8 | #include "mp3/mp3tabs.c" 9 | 10 | #include "mp3/bitstream.c" 11 | #include "mp3/buffers.c" 12 | #include "mp3/dct32.c" 13 | #include "mp3/dequant.c" 14 | #include "mp3/dqchan.c" 15 | //#include "mp3/polyphase.c" 16 | 17 | 18 | 19 | #include "mp3/imdct.c" 20 | #include "mp3/scalfact.c" 21 | #include "mp3/stproc.c" 22 | #include "mp3/subband.c" 23 | #include "mp3/trigtabs.c" 24 | 25 | #include "mp3/huffman.c" 26 | #include "mp3/hufftabs.c" -------------------------------------------------------------------------------- /mp3/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. 2 | 3 | The contents of this directory, and (except where otherwise 4 | indicated) the directories included within this directory, are 5 | subject to the current version of the RealNetworks Public Source 6 | License (the "RPSL") available at RPSL.txt in this directory, unless 7 | you have licensed the directory under the current version of the 8 | RealNetworks Community Source License (the "RCSL") available at 9 | RCSL.txt in this directory, in which case the RCSL will apply. You 10 | may also obtain the license terms directly from RealNetworks. You 11 | may not use the files in this directory except in compliance with the 12 | RPSL or, if you have a valid RCSL with RealNetworks applicable to 13 | this directory, the RCSL. Please see the applicable RPSL or RCSL for 14 | the rights, obligations and limitations governing use of the contents 15 | of the directory. 16 | 17 | This directory is part of the Helix DNA Technology. RealNetworks is 18 | the developer of the Original Code and owns the copyrights in the 19 | portions it created. 20 | 21 | This directory, and the directories included with this directory, are 22 | distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY 23 | OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY 24 | DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 25 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 26 | QUIET ENJOYMENT OR NON-INFRINGEMENT. 27 | 28 | Technology Compatibility Kit Test Suite(s) Location: 29 | http://www.helixcommunity.org/content/tck 30 | 31 | -------------------------------------------------------------------------------- /mp3/RCSL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/mp3/RCSL.txt -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/opus/ChangeLog -------------------------------------------------------------------------------- /opus/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankBoesing/Arduino-Teensy-Codec-lib/25eaddfab4afff5ac1c0d623ce1cddbc07155910/opus/NEWS -------------------------------------------------------------------------------- /opus/OpusConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(OPUS_VERSION @PROJECT_VERSION@) 2 | set(OPUS_VERSION_STRING @PROJECT_VERSION@) 3 | set(OPUS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) 4 | set(OPUS_VERSION_MINOR @PROJECT_VERSION_MINOR@) 5 | set(OPUS_VERSION_PATCH @PROJECT_VERSION_PATCH@) 6 | 7 | @PACKAGE_INIT@ 8 | 9 | set_and_check(OPUS_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 10 | set_and_check(OPUS_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") 11 | 12 | include(${CMAKE_CURRENT_LIST_DIR}/OpusTargets.cmake) 13 | 14 | set(OPUS_LIBRARY Opus::opus) 15 | set(OPUS_LIBRARIES Opus::opus) 16 | 17 | check_required_components(Opus) 18 | 19 | set(OPUS_FOUND 1) 20 | -------------------------------------------------------------------------------- /opus/celt/arm/armcpu.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 | #if !defined(ARMCPU_H) 29 | # define ARMCPU_H 30 | 31 | # if defined(OPUS_ARM_MAY_HAVE_EDSP) 32 | # define MAY_HAVE_EDSP(name) name ## _edsp 33 | # else 34 | # define MAY_HAVE_EDSP(name) name ## _c 35 | # endif 36 | 37 | # if defined(OPUS_ARM_MAY_HAVE_MEDIA) 38 | # define MAY_HAVE_MEDIA(name) name ## _media 39 | # else 40 | # define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) 41 | # endif 42 | 43 | # if defined(OPUS_ARM_MAY_HAVE_NEON) 44 | # define MAY_HAVE_NEON(name) name ## _neon 45 | # else 46 | # define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) 47 | # endif 48 | 49 | # if defined(OPUS_ARM_PRESUME_EDSP) 50 | # define PRESUME_EDSP(name) name ## _edsp 51 | # else 52 | # define PRESUME_EDSP(name) name ## _c 53 | # endif 54 | 55 | # if defined(OPUS_ARM_PRESUME_MEDIA) 56 | # define PRESUME_MEDIA(name) name ## _media 57 | # else 58 | # define PRESUME_MEDIA(name) PRESUME_EDSP(name) 59 | # endif 60 | 61 | # if defined(OPUS_ARM_PRESUME_NEON) 62 | # define PRESUME_NEON(name) name ## _neon 63 | # else 64 | # define PRESUME_NEON(name) PRESUME_MEDIA(name) 65 | # endif 66 | 67 | # if defined(OPUS_HAVE_RTCD) 68 | int opus_select_arch(void); 69 | 70 | #define OPUS_ARCH_ARM_V4 (0) 71 | #define OPUS_ARCH_ARM_EDSP (1) 72 | #define OPUS_ARCH_ARM_MEDIA (2) 73 | #define OPUS_ARCH_ARM_NEON (3) 74 | 75 | # endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /opus/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 | END 38 | -------------------------------------------------------------------------------- /opus/celt/arm/fft_arm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Xiph.Org Foundation 2 | Written by Viswanath Puttagunta */ 3 | /** 4 | @file fft_arm.h 5 | @brief ARM Neon Intrinsic optimizations for fft using NE10 library 6 | */ 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 | 34 | #if !defined(FFT_ARM_H) 35 | #define FFT_ARM_H 36 | 37 | #include "../kiss_fft.h" 38 | 39 | #if defined(HAVE_ARM_NE10) 40 | 41 | int opus_fft_alloc_arm_neon(kiss_fft_state *st); 42 | void opus_fft_free_arm_neon(kiss_fft_state *st); 43 | 44 | void opus_fft_neon(const kiss_fft_state *st, 45 | const kiss_fft_cpx *fin, 46 | kiss_fft_cpx *fout); 47 | 48 | void opus_ifft_neon(const kiss_fft_state *st, 49 | const kiss_fft_cpx *fin, 50 | kiss_fft_cpx *fout); 51 | 52 | #if !defined(OPUS_HAVE_RTCD) 53 | #define OVERRIDE_OPUS_FFT (1) 54 | 55 | #define opus_fft_alloc_arch(_st, arch) \ 56 | ((void)(arch), opus_fft_alloc_arm_neon(_st)) 57 | 58 | #define opus_fft_free_arch(_st, arch) \ 59 | ((void)(arch), opus_fft_free_arm_neon(_st)) 60 | 61 | #define opus_fft(_st, _fin, _fout, arch) \ 62 | ((void)(arch), opus_fft_neon(_st, _fin, _fout)) 63 | 64 | #define opus_ifft(_st, _fin, _fout, arch) \ 65 | ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) 66 | 67 | #endif /* OPUS_HAVE_RTCD */ 68 | 69 | #endif /* HAVE_ARM_NE10 */ 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/celt/arm/mdct_arm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Xiph.Org Foundation 2 | Written by Viswanath Puttagunta */ 3 | /** 4 | @file arm_mdct.h 5 | @brief ARM Neon Intrinsic optimizations for mdct using NE10 library 6 | */ 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 | #if !defined(MDCT_ARM_H) 34 | #define MDCT_ARM_H 35 | 36 | #include "../mdct.h" 37 | 38 | #if defined(HAVE_ARM_NE10) 39 | /** Compute a forward MDCT and scale by 4/N, trashes the input array */ 40 | void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, 41 | kiss_fft_scalar * OPUS_RESTRICT out, 42 | const opus_val16 *window, int overlap, 43 | int shift, int stride, int arch); 44 | 45 | void clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, 46 | kiss_fft_scalar * OPUS_RESTRICT out, 47 | const opus_val16 *window, int overlap, 48 | int shift, int stride, int arch); 49 | 50 | #if !defined(OPUS_HAVE_RTCD) 51 | #define OVERRIDE_OPUS_MDCT (1) 52 | #define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ 53 | clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) 54 | #define clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ 55 | clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) 56 | #endif /* OPUS_HAVE_RTCD */ 57 | #endif /* HAVE_ARM_NE10 */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /opus/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 | int arch); 49 | 50 | #if !defined(OVERRIDE_CELT_FIR) 51 | #define celt_fir(x, num, y, N, ord, arch) \ 52 | (celt_fir_c(x, num, y, N, ord, arch)) 53 | #endif 54 | 55 | void celt_iir(const opus_val32 *x, 56 | const opus_val16 *den, 57 | opus_val32 *y, 58 | int N, 59 | int ord, 60 | opus_val16 *mem, 61 | int arch); 62 | 63 | int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, 64 | const opus_val16 *window, int overlap, int lag, int n, int arch); 65 | 66 | #endif /* PLC_H */ 67 | -------------------------------------------------------------------------------- /opus/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 "../include/opus_types.h" 32 | #include "../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 | #else 63 | #define OPUS_ARCHMASK 0 64 | 65 | static OPUS_INLINE int opus_select_arch(void) 66 | { 67 | return 0; 68 | } 69 | #endif 70 | #endif 71 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 "../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 | -------------------------------------------------------------------------------- /opus/celt/tests/test_unit_rotation.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 | #ifndef CUSTOM_MODES 33 | #define CUSTOM_MODES 34 | #endif 35 | 36 | #include 37 | #include 38 | #include "../vq.h" 39 | #include "../bands.h" 40 | #include "../stack_alloc.h" 41 | #include 42 | 43 | 44 | #define MAX_SIZE 100 45 | 46 | int ret=0; 47 | void test_rotation(int N, int K) 48 | { 49 | int i; 50 | double err = 0, ener = 0, snr, snr0; 51 | opus_val16 x0[MAX_SIZE]; 52 | opus_val16 x1[MAX_SIZE]; 53 | for (i=0;i 20) 72 | { 73 | fprintf(stderr, "FAIL!\n"); 74 | ret = 1; 75 | } 76 | } 77 | 78 | int main(void) 79 | { 80 | ALLOC_STACK; 81 | test_rotation(15, 3); 82 | test_rotation(23, 5); 83 | test_rotation(50, 3); 84 | test_rotation(80, 1); 85 | return ret; 86 | } 87 | -------------------------------------------------------------------------------- /opus/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 "../../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 | -------------------------------------------------------------------------------- /opus/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 | int arch); 45 | 46 | #if defined(OPUS_X86_PRESUME_SSE4_1) 47 | #define celt_fir(x, num, y, N, ord, arch) \ 48 | ((void)arch, celt_fir_sse4_1(x, num, y, N, ord, arch)) 49 | 50 | #else 51 | 52 | extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( 53 | const opus_val16 *x, 54 | const opus_val16 *num, 55 | opus_val16 *y, 56 | int N, 57 | int ord, 58 | int arch); 59 | 60 | # define celt_fir(x, num, y, N, ord, arch) \ 61 | ((*CELT_FIR_IMPL[(arch) & OPUS_ARCHMASK])(x, num, y, N, ord, arch)) 62 | 63 | #endif 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /opus/celt/x86/celt_lpc_sse4_1.c: -------------------------------------------------------------------------------- 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 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include "../celt_lpc.h" 36 | #include "../stack_alloc.h" 37 | #include "../mathops.h" 38 | #include "../pitch.h" 39 | #include "x86cpu.h" 40 | 41 | #if defined(FIXED_POINT) 42 | 43 | void celt_fir_sse4_1(const opus_val16 *x, 44 | const opus_val16 *num, 45 | opus_val16 *y, 46 | int N, 47 | int ord, 48 | int arch) 49 | { 50 | int i,j; 51 | VARDECL(opus_val16, rnum); 52 | 53 | __m128i vecNoA; 54 | opus_int32 noA ; 55 | SAVE_STACK; 56 | 57 | ALLOC(rnum, ord, opus_val16); 58 | for(i=0;i> 1; 61 | vecNoA = _mm_set_epi32(noA, noA, noA, noA); 62 | 63 | for (i=0;i 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 23 | 24 | 25 |
14 | For more information visit the Opus Website. 15 | 17 | 22 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/m4/ax_add_fortify_source.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # Modified from https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_ADD_FORTIFY_SOURCE 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether -D_FORTIFY_SOURCE=2 can be added to CFLAGS without macro 12 | # redefinition warnings. Some distributions (such as Gentoo Linux) enable 13 | # _FORTIFY_SOURCE globally in their compilers, leading to unnecessary 14 | # warnings in the form of 15 | # 16 | # :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] 17 | # : note: this is the location of the previous definition 18 | # 19 | # which is a problem if -Werror is enabled. This macro checks whether 20 | # _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2 21 | # to CFLAGS. 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2017 David Seifert 26 | # 27 | # Copying and distribution of this file, with or without modification, are 28 | # permitted in any medium without royalty provided the copyright notice 29 | # and this notice are preserved. This file is offered as-is, without any 30 | # warranty. 31 | 32 | #serial 1 33 | 34 | AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ 35 | AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CFLAGS]) 36 | AC_LINK_IFELSE([ 37 | AC_LANG_SOURCE( 38 | [[ 39 | int main() { 40 | #ifndef _FORTIFY_SOURCE 41 | return 0; 42 | #else 43 | this_is_an_error; 44 | #endif 45 | } 46 | ]] 47 | )], [ 48 | AC_MSG_RESULT([yes]) 49 | CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" 50 | ], [ 51 | AC_MSG_RESULT([no]) 52 | ]) 53 | ]) 54 | -------------------------------------------------------------------------------- /opus/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2015 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 4179 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.6]) 16 | m4_define([LT_PACKAGE_REVISION], [2.4.6]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.6' 20 | macro_revision='2.4.6' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /opus/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="$CFLAGS $2" 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/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.la @LIBM@ 12 | Cflags: -I${pcfiledir}/@top_srcdir@/include 13 | -------------------------------------------------------------------------------- /opus/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: https://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/opus_config.cmake: -------------------------------------------------------------------------------- 1 | include(opus_functions.cmake) 2 | 3 | configure_file(config.h.cmake.in config.h @ONLY) 4 | add_definitions(-DHAVE_CONFIG_H) 5 | 6 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 7 | set_property(GLOBAL PROPERTY C_STANDARD 99) 8 | 9 | if(MSVC) 10 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 11 | endif() 12 | 13 | include(CheckLibraryExists) 14 | check_library_exists(m floor "" HAVE_LIBM) 15 | if(HAVE_LIBM) 16 | list(APPEND OPUS_REQUIRED_LIBRARIES m) 17 | endif() 18 | 19 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)") 20 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 21 | set(OPUS_CPU_X64 1) 22 | else() 23 | set(OPUS_CPU_X86 1) 24 | endif() 25 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") 26 | set(OPUS_CPU_ARM 1) 27 | endif() 28 | 29 | opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) 30 | 31 | if(OPUS_CPU_X86 OR OPUS_CPU_X64) 32 | opus_detect_sse(COMPILER_SUPPORT_SIMD) 33 | elseif(OPUS_CPU_ARM) 34 | opus_detect_neon(COMPILER_SUPPORT_NEON) 35 | if(COMPILER_SUPPORT_NEON) 36 | option(OPUS_USE_NEON "Option to turn off SSE" ON) 37 | option(OPUS_MAY_SUPPORT_NEON "Does runtime check for neon support" ON) 38 | option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF) 39 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") 40 | set(OPUS_PRESUME_NEON ON) 41 | endif() 42 | endif() 43 | endif() 44 | -------------------------------------------------------------------------------- /opus/opus_headers.mk: -------------------------------------------------------------------------------- 1 | OPUS_HEAD = \ 2 | include/opus.h \ 3 | include/opus_multistream.h \ 4 | include/opus_projection.h \ 5 | src/opus_private.h \ 6 | src/analysis.h \ 7 | src/mapping_matrix.h \ 8 | src/mlp.h \ 9 | src/tansig_table.h 10 | -------------------------------------------------------------------------------- /opus/opus_sources.cmake: -------------------------------------------------------------------------------- 1 | include(opus_functions.cmake) 2 | 3 | get_opus_sources(SILK_SOURCES silk_sources.mk silk_sources) 4 | get_opus_sources(SILK_SOURCES_FLOAT silk_sources.mk silk_sources_float) 5 | get_opus_sources(SILK_SOURCES_FIXED silk_sources.mk silk_sources_fixed) 6 | get_opus_sources(SILK_SOURCES_SSE4_1 silk_sources.mk silk_sources_sse4_1) 7 | get_opus_sources(SILK_SOURCES_FIXED_SSE4_1 silk_sources.mk 8 | silk_sources_fixed_sse4_1) 9 | get_opus_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk 10 | silk_sources_arm_neon_intr) 11 | get_opus_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk 12 | silk_sources_fixed_arm_neon_intr) 13 | 14 | get_opus_sources(OPUS_SOURCES opus_sources.mk opus_sources) 15 | get_opus_sources(OPUS_SOURCES_FLOAT opus_sources.mk opus_sources_float) 16 | 17 | get_opus_sources(CELT_SOURCES celt_sources.mk celt_sources) 18 | get_opus_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) 19 | get_opus_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) 20 | get_opus_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1) 21 | get_opus_sources(CELT_SOURCES_ARM celt_sources.mk celt_sources_arm) 22 | get_opus_sources(CELT_SOURCES_ARM_ASM celt_sources.mk celt_sources_arm_asm) 23 | get_opus_sources(CELT_AM_SOURCES_ARM_ASM celt_sources.mk 24 | celt_am_sources_arm_asm) 25 | get_opus_sources(CELT_SOURCES_ARM_NEON_INTR celt_sources.mk 26 | celt_sources_arm_neon_intr) 27 | get_opus_sources(CELT_SOURCES_ARM_NE10 celt_sources.mk celt_sources_arm_ne10) 28 | 29 | get_opus_sources(opus_demo_SOURCES Makefile.am opus_demo_sources) 30 | get_opus_sources(opus_custom_demo_SOURCES Makefile.am opus_custom_demo_sources) 31 | get_opus_sources(opus_compare_SOURCES Makefile.am opus_compare_sources) 32 | get_opus_sources(tests_test_opus_api_SOURCES Makefile.am test_opus_api_sources) 33 | get_opus_sources(tests_test_opus_encode_SOURCES Makefile.am 34 | test_opus_encode_sources) 35 | get_opus_sources(tests_test_opus_decode_SOURCES Makefile.am 36 | test_opus_decode_sources) 37 | get_opus_sources(tests_test_opus_padding_SOURCES Makefile.am 38 | test_opus_padding_sources) 39 | -------------------------------------------------------------------------------- /opus/opus_sources.mk: -------------------------------------------------------------------------------- 1 | OPUS_SOURCES = \ 2 | src/opus.c \ 3 | src/opus_decoder.c \ 4 | src/opus_encoder.c \ 5 | src/opus_multistream.c \ 6 | src/opus_multistream_encoder.c \ 7 | src/opus_multistream_decoder.c \ 8 | src/repacketizer.c \ 9 | src/opus_projection_encoder.c \ 10 | src/opus_projection_decoder.c \ 11 | src/mapping_matrix.c 12 | 13 | OPUS_SOURCES_FLOAT = \ 14 | src/analysis.c \ 15 | src/mlp.c \ 16 | src/mlp_data.c 17 | -------------------------------------------------------------------------------- /opus/package_version: -------------------------------------------------------------------------------- 1 | PACKAGE_VERSION="1.3.1" 2 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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/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 | -------------------------------------------------------------------------------- /opus/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 rc, tmp1, tmp2; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | rc = rc_Q15[ k ]; 46 | for( n = 0; n < (k + 1) >> 1; n++ ) { 47 | tmp1 = A_Q24[ n ]; 48 | tmp2 = A_Q24[ k - n - 1 ]; 49 | A_Q24[ n ] = silk_SMLAWB( tmp1, silk_LSHIFT( tmp2, 1 ), rc ); 50 | A_Q24[ k - n - 1 ] = silk_SMLAWB( tmp2, silk_LSHIFT( tmp1, 1 ), rc ); 51 | } 52 | A_Q24[ k ] = -silk_LSHIFT( (opus_int32)rc_Q15[ k ], 9 ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /opus/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 rc, tmp1, tmp2; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | rc = rc_Q16[ k ]; 46 | for( n = 0; n < (k + 1) >> 1; n++ ) { 47 | tmp1 = A_Q24[ n ]; 48 | tmp2 = A_Q24[ k - n - 1 ]; 49 | A_Q24[ n ] = silk_SMLAWW( tmp1, tmp2, rc ); 50 | A_Q24[ k - n - 1 ] = silk_SMLAWW( tmp2, tmp1, rc ); 51 | } 52 | A_Q24[ k ] = -silk_LSHIFT( rc, 8 ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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; 41 | double result; 42 | 43 | /* 4x unrolled loop */ 44 | result = 0.0; 45 | for( i = 0; i < dataSize - 3; i += 4 ) { 46 | result += data[ i + 0 ] * (double)data[ i + 0 ] + 47 | data[ i + 1 ] * (double)data[ i + 1 ] + 48 | data[ i + 2 ] * (double)data[ i + 2 ] + 49 | data[ i + 3 ] * (double)data[ i + 3 ]; 50 | } 51 | 52 | /* add any remaining products */ 53 | for( ; i < dataSize; i++ ) { 54 | result += data[ i ] * (double)data[ i ]; 55 | } 56 | 57 | silk_assert( result >= 0.0 ); 58 | return result; 59 | } 60 | -------------------------------------------------------------------------------- /opus/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; 42 | double result; 43 | 44 | /* 4x unrolled loop */ 45 | result = 0.0; 46 | for( i = 0; i < dataSize - 3; i += 4 ) { 47 | result += data1[ i + 0 ] * (double)data2[ i + 0 ] + 48 | data1[ i + 1 ] * (double)data2[ i + 1 ] + 49 | data1[ i + 2 ] * (double)data2[ i + 2 ] + 50 | data1[ i + 3 ] * (double)data2[ i + 3 ]; 51 | } 52 | 53 | /* add any remaining products */ 54 | for( ; i < dataSize; i++ ) { 55 | result += data1[ i ] * (double)data2[ i ]; 56 | } 57 | 58 | return result; 59 | } 60 | -------------------------------------------------------------------------------- /opus/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 rck, tmp1, tmp2; 43 | 44 | for( k = 0; k < order; k++ ) { 45 | rck = rc[ k ]; 46 | for( n = 0; n < (k + 1) >> 1; n++ ) { 47 | tmp1 = A[ n ]; 48 | tmp2 = A[ k - n - 1 ]; 49 | A[ n ] = tmp1 + tmp2 * rck; 50 | A[ k - n - 1 ] = tmp2 + tmp1 * rck; 51 | } 52 | A[ k ] = -rck; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | psDec->arch = opus_select_arch(); 48 | 49 | /* Reset CNG state */ 50 | silk_CNG_Reset( psDec ); 51 | 52 | /* Reset PLC state */ 53 | silk_PLC_Reset( psDec ); 54 | 55 | return(0); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /opus/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 "fixed/main_FIX.h" 33 | #else 34 | #include "float/main_FLP.h" 35 | #endif 36 | #include "tuning_parameters.h" 37 | #include "../celt/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | celt_assert( ifact_Q2 >= 0 ); 46 | celt_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 | -------------------------------------------------------------------------------- /opus/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_ADD_LSHIFT32( silk_SMLAWB( frac_Q7, silk_MUL( frac_Q7, 128 - frac_Q7 ), 179 ), 31 - lz, 7 ); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | #undef silk_SAT16 32 | static inline short int silk_SAT16(int a) 33 | { 34 | int c; 35 | c = __builtin_mips_shll_s_w(a, 16); 36 | c = c>>16; 37 | 38 | return c; 39 | } 40 | 41 | #undef silk_LSHIFT_SAT32 42 | static inline int silk_LSHIFT_SAT32(int a, int shift) 43 | { 44 | int r; 45 | 46 | r = __builtin_mips_shll_s_w(a, shift); 47 | 48 | return r; 49 | } 50 | 51 | #undef silk_RSHIFT_ROUND 52 | static inline int silk_RSHIFT_ROUND(int a, int shift) 53 | { 54 | int r; 55 | 56 | r = __builtin_mips_shra_r_w(a, shift); 57 | return r; 58 | } 59 | 60 | #endif /* SILK_SIGPROC_FIX_MIPSR1_H */ 61 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 | celt_assert( n < 25 ); 45 | ec_enc_icdf( psRangeEnc, n, silk_stereo_pred_joint_iCDF, 8 ); 46 | for( n = 0; n < 2; n++ ) { 47 | celt_assert( ix[ n ][ 0 ] < 3 ); 48 | celt_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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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/NSQ.h \ 19 | silk/pitch_est_defines.h \ 20 | silk/resampler_private.h \ 21 | silk/resampler_rom.h \ 22 | silk/resampler_structs.h \ 23 | silk/SigProc_FIX.h \ 24 | silk/x86/SigProc_FIX_sse.h \ 25 | silk/arm/biquad_alt_arm.h \ 26 | silk/arm/LPC_inv_pred_gain_arm.h \ 27 | silk/arm/macros_armv4.h \ 28 | silk/arm/macros_armv5e.h \ 29 | silk/arm/macros_arm64.h \ 30 | silk/arm/SigProc_FIX_armv4.h \ 31 | silk/arm/SigProc_FIX_armv5e.h \ 32 | silk/arm/NSQ_del_dec_arm.h \ 33 | silk/arm/NSQ_neon.h \ 34 | silk/fixed/main_FIX.h \ 35 | silk/fixed/structs_FIX.h \ 36 | silk/fixed/arm/warped_autocorrelation_FIX_arm.h \ 37 | silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h \ 38 | silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h \ 39 | silk/float/main_FLP.h \ 40 | silk/float/structs_FLP.h \ 41 | silk/float/SigProc_FLP.h \ 42 | silk/mips/macros_mipsr1.h \ 43 | silk/mips/NSQ_del_dec_mipsr1.h \ 44 | silk/mips/sigproc_fix_mipsr1.h 45 | -------------------------------------------------------------------------------- /opus/src/mlp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 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 FOUNDATION OR 18 | 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 _MLP_H_ 28 | #define _MLP_H_ 29 | 30 | #include "../include/opus_types.h" 31 | 32 | #define WEIGHTS_SCALE (1.f/128) 33 | 34 | #define MAX_NEURONS 32 35 | 36 | typedef struct { 37 | const opus_int8 *bias; 38 | const opus_int8 *input_weights; 39 | int nb_inputs; 40 | int nb_neurons; 41 | int sigmoid; 42 | } DenseLayer; 43 | 44 | typedef struct { 45 | const opus_int8 *bias; 46 | const opus_int8 *input_weights; 47 | const opus_int8 *recurrent_weights; 48 | int nb_inputs; 49 | int nb_neurons; 50 | } GRULayer; 51 | 52 | extern const DenseLayer layer0; 53 | extern const GRULayer layer1; 54 | extern const DenseLayer layer2; 55 | 56 | void compute_dense(const DenseLayer *layer, float *output, const float *input); 57 | 58 | void compute_gru(const GRULayer *gru, float *state, const float *input); 59 | 60 | #endif /* _MLP_H_ */ 61 | -------------------------------------------------------------------------------- /opus/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 "../include/opus_multistream.h" 33 | #include "../include/opus.h" 34 | #include "opus_private.h" 35 | #include "../celt/stack_alloc.h" 36 | #include 37 | #include "../celt/float_cast.h" 38 | #include "../celt/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 | -------------------------------------------------------------------------------- /opus/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 | -------------------------------------------------------------------------------- /opus/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 "../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 | -------------------------------------------------------------------------------- /play_sd_mp3.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Audiocodecs 3 | 4 | Copyright (c) 2014 Frank Bösing 5 | 6 | This library is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library. If not, see . 18 | 19 | The helix decoder itself as a different license, look at the subdirectories for more info. 20 | 21 | Diese Bibliothek ist freie Software: Sie können es unter den Bedingungen 22 | der GNU General Public License, wie von der Free Software Foundation, 23 | Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren 24 | veröffentlichten Version, weiterverbreiten und/oder modifizieren. 25 | 26 | Diese Bibliothek wird in der Hoffnung, dass es nützlich sein wird, aber 27 | OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite 28 | Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. 29 | Siehe die GNU General Public License für weitere Details. 30 | 6790´tzui# 31 | Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 32 | Programm erhalten haben. Wenn nicht, siehe . 33 | 34 | Der Helixdecoder selbst hat eine eigene Lizenz, bitte für mehr Informationen 35 | in den Unterverzeichnissen nachsehen. 36 | 37 | */ 38 | 39 | /* The Helix-Library is modified for Teensy 3.1 */ 40 | 41 | #ifndef play_sd_mp3_h_ 42 | #define play_sd_mp3_h_ 43 | 44 | #include "codecs.h" 45 | #include "AudioStream.h" 46 | #include "spi_interrupt.h" 47 | #include "mp3/mp3dec.h" 48 | 49 | class AudioPlaySdMp3 : public AudioCodec 50 | { 51 | public: 52 | void stop(void); 53 | int play(FS *fs, const char *filename) {stop(); if (!fopen(fs,filename)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 54 | int play(const char *filename) {stop();if (!fopen(filename)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 55 | int play(const size_t p, const size_t size) {stop();if (!fopen(p,size)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 56 | int play(const uint8_t*p, const size_t size) {stop();if (!fopen(p,size)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 57 | 58 | protected: 59 | uint8_t *sd_buf; 60 | uint8_t *sd_p; 61 | int sd_left; 62 | 63 | short *buf[2]; 64 | size_t decoded_length[2]; 65 | size_t decoding_block; 66 | unsigned int decoding_state; //state 0: read sd, state 1: decode 67 | 68 | size_t size_id3; 69 | uintptr_t play_pos; 70 | 71 | HMP3Decoder hMP3Decoder; 72 | MP3FrameInfo mp3FrameInfo; 73 | 74 | int play(void); 75 | void update(void); 76 | friend void decodeMp3(void); 77 | }; 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /play_sd_opus.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Audiocodecs 3 | 4 | Copyright (c) 2020 jcj83429 5 | 6 | This library is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library. If not, see . 18 | 19 | Diese Bibliothek ist freie Software: Sie können es unter den Bedingungen 20 | der GNU General Public License, wie von der Free Software Foundation, 21 | Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren 22 | veröffentlichten Version, weiterverbreiten und/oder modifizieren. 23 | 24 | Diese Bibliothek wird in der Hoffnung, dass es nützlich sein wird, aber 25 | OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite 26 | Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. 27 | Siehe die GNU General Public License für weitere Details. 28 | 29 | Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 30 | Programm erhalten haben. Wenn nicht, siehe . 31 | */ 32 | 33 | #include "codecs.h" 34 | #include "AudioStream.h" 35 | #include "oggparse.h" 36 | #include "opus/include/opus.h" 37 | 38 | class AudioPlaySdOpus : public OggStreamReader 39 | { 40 | public: 41 | int play(FS *fs, const char *filename) {stop(); if (!fopen(fs,filename)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 42 | int play(const char *filename) {stop();if (!fopen(filename)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 43 | int play(const size_t p, const size_t size) {stop();if (!fopen(p,size)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 44 | int play(const uint8_t*p, const size_t size) {stop();if (!fopen(p,size)) return ERR_CODEC_FILE_NOT_FOUND; return play();} 45 | void stop(void); 46 | bool seek(uint32_t); 47 | 48 | protected: 49 | 50 | OpusDecoder *opusDecoder = NULL; 51 | 52 | uint8_t *bitstream_buf = NULL; 53 | // because opus frame sizes are not a multiple of 128, we decode into this third buffer and copy to the 2 buffers, which are multiples of 128 54 | int16_t *decbuf = NULL; 55 | int16_t decbuflen = 0; 56 | int16_t *buf[2] = {0}; 57 | int16_t decoded_length[2]; 58 | size_t decoding_block; 59 | unsigned int decoding_state; //state 0: read sd, state 1: decode 60 | 61 | uintptr_t play_pos; 62 | 63 | float output_gain = 0; 64 | 65 | int play(void); 66 | void update(void); 67 | void fill_buf_from_decbuf(void); 68 | bool parse_opus_header(void); 69 | bool parse_metadata_tags(void); 70 | friend void decodeOpus(void); 71 | }; 72 | --------------------------------------------------------------------------------