├── AUTHORS ├── COPYING ├── ChangeLog ├── LICENSE_PLEASE_READ.txt ├── Makefile.am ├── Makefile.unix ├── NEWS ├── README ├── README.draft ├── autogen.sh ├── celt ├── _kiss_fft_guts.h ├── arch.h ├── arm │ ├── arm2gnu.pl │ ├── arm_celt_map.c │ ├── armcpu.c │ ├── armcpu.h │ ├── armopts.s.in │ ├── celt_pitch_xcorr_arm.s │ ├── fixed_armv4.h │ ├── fixed_armv5e.h │ ├── kiss_fft_armv4.h │ ├── kiss_fft_armv5e.h │ └── pitch_arm.h ├── bands.c ├── bands.h ├── celt.c ├── celt.h ├── celt_decoder.c ├── celt_encoder.c ├── celt_lpc.c ├── celt_lpc.h ├── cpu_support.h ├── cwrs.c ├── cwrs.h ├── dump_modes │ ├── Makefile │ └── dump_modes.c ├── ecintrin.h ├── entcode.c ├── entcode.h ├── entdec.c ├── entdec.h ├── entenc.c ├── entenc.h ├── fixed_c5x.h ├── fixed_c6x.h ├── fixed_debug.h ├── fixed_generic.h ├── float_cast.h ├── kiss_fft.c ├── kiss_fft.h ├── laplace.c ├── laplace.h ├── mathops.c ├── mathops.h ├── mdct.c ├── mdct.h ├── mfrngcod.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_float.h ├── tests │ ├── test_unit_cwrs32.c │ ├── test_unit_dft.c │ ├── test_unit_entropy.c │ ├── test_unit_laplace.c │ ├── test_unit_mathops.c │ ├── test_unit_mdct.c │ ├── test_unit_rotation.c │ └── test_unit_types.c ├── vq.c ├── vq.h └── x86 │ ├── celt_lpc_sse.c │ ├── celt_lpc_sse.h │ ├── pitch_sse.c │ ├── pitch_sse.h │ ├── x86_celt_map.c │ ├── x86_cpu.c │ └── x86_cpu.h ├── celt_headers.mk ├── celt_sources.mk ├── cisco-opus-optimization.pptx ├── configure.ac ├── doc ├── Doxyfile.in ├── Makefile.am ├── build_draft.sh ├── build_oggdraft.sh ├── customdoxygen.css ├── draft-ietf-codec-oggopus.xml ├── draft-ietf-codec-opus-update.xml ├── draft-ietf-codec-opus.xml ├── draft-ietf-payload-rtp-opus.xml ├── footer.html ├── footer.html.patch ├── header.html ├── header.html.patch ├── opus_logo.svg ├── release.txt └── trivial_example.c ├── include ├── opus.h ├── opus_custom.h ├── opus_defines.h ├── opus_multistream.h └── opus_types.h ├── m4 └── as-gcc-inline-assembly.m4 ├── opus-uninstalled.pc.in ├── opus.m4 ├── opus.pc.in ├── opus_headers.mk ├── opus_sources.mk ├── silk ├── A2NLSF.c ├── API.h ├── CNG.c ├── HP_variable_cutoff.c ├── Inlines.h ├── LPC_analysis_filter.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_del_dec.c ├── PLC.c ├── PLC.h ├── SigProc_FIX.h ├── VAD.c ├── VQ_WMat_EC.c ├── ana_filt_bank_1.c ├── arm │ ├── SigProc_FIX_armv4.h │ ├── SigProc_FIX_armv5e.h │ ├── macros_armv4.h │ └── macros_armv5e.h ├── biquad_alt.c ├── bwexpander.c ├── bwexpander_32.c ├── check_control_input.c ├── code_signs.c ├── control.h ├── control_SNR.c ├── control_audio_bandwidth.c ├── control_codec.c ├── debug.c ├── debug.h ├── dec_API.c ├── decode_core.c ├── decode_frame.c ├── decode_indices.c ├── decode_parameters.c ├── decode_pitch.c ├── decode_pulses.c ├── decoder_set_fs.c ├── define.h ├── enc_API.c ├── encode_indices.c ├── encode_pulses.c ├── errors.h ├── fixed │ ├── LTP_analysis_filter_FIX.c │ ├── LTP_scale_ctrl_FIX.c │ ├── apply_sine_window_FIX.c │ ├── autocorr_FIX.c │ ├── burg_modified_FIX.c │ ├── corrMatrix_FIX.c │ ├── encode_frame_FIX.c │ ├── find_LPC_FIX.c │ ├── find_LTP_FIX.c │ ├── find_pitch_lags_FIX.c │ ├── find_pred_coefs_FIX.c │ ├── k2a_FIX.c │ ├── k2a_Q16_FIX.c │ ├── main_FIX.h │ ├── noise_shape_analysis_FIX.c │ ├── pitch_analysis_core_FIX.c │ ├── prefilter_FIX.c │ ├── process_gains_FIX.c │ ├── regularize_correlations_FIX.c │ ├── residual_energy16_FIX.c │ ├── residual_energy_FIX.c │ ├── schur64_FIX.c │ ├── schur_FIX.c │ ├── solve_LS_FIX.c │ ├── structs_FIX.h │ ├── vector_ops_FIX.c │ ├── warped_autocorrelation_FIX.c │ └── x86 │ │ ├── burg_modified_FIX_sse.c │ │ ├── prefilter_FIX_sse.c │ │ └── vector_ops_FIX_sse.c ├── float │ ├── LPC_analysis_filter_FLP.c │ ├── LPC_inv_pred_gain_FLP.c │ ├── LTP_analysis_filter_FLP.c │ ├── LTP_scale_ctrl_FLP.c │ ├── SigProc_FLP.h │ ├── apply_sine_window_FLP.c │ ├── autocorrelation_FLP.c │ ├── burg_modified_FLP.c │ ├── bwexpander_FLP.c │ ├── corrMatrix_FLP.c │ ├── encode_frame_FLP.c │ ├── energy_FLP.c │ ├── find_LPC_FLP.c │ ├── find_LTP_FLP.c │ ├── find_pitch_lags_FLP.c │ ├── find_pred_coefs_FLP.c │ ├── inner_product_FLP.c │ ├── k2a_FLP.c │ ├── levinsondurbin_FLP.c │ ├── main_FLP.h │ ├── noise_shape_analysis_FLP.c │ ├── pitch_analysis_core_FLP.c │ ├── prefilter_FLP.c │ ├── process_gains_FLP.c │ ├── regularize_correlations_FLP.c │ ├── residual_energy_FLP.c │ ├── scale_copy_vector_FLP.c │ ├── scale_vector_FLP.c │ ├── schur_FLP.c │ ├── solve_LS_FLP.c │ ├── sort_FLP.c │ ├── structs_FLP.h │ ├── warped_autocorrelation_FLP.c │ └── wrappers_FLP.c ├── gain_quant.c ├── init_decoder.c ├── init_encoder.c ├── inner_prod_aligned.c ├── interpolate.c ├── lin2log.c ├── log2lin.c ├── macros.h ├── main.h ├── 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 ├── tuning_parameters.h ├── typedef.h └── x86 │ ├── NSQ_del_dec_sse.c │ ├── NSQ_sse.c │ ├── SigProc_FIX_sse.h │ ├── VAD_sse.c │ ├── VQ_WMat_EC_sse.c │ ├── main_sse.h │ ├── silk_cpu.h │ └── x86_silk_map.c ├── silk_headers.mk ├── silk_sources.mk ├── src ├── analysis.c ├── analysis.h ├── mlp.c ├── mlp.h ├── mlp_data.c ├── mlp_train.c ├── mlp_train.h ├── opus.c ├── opus_compare.c ├── opus_decoder.c ├── opus_demo.c ├── opus_encoder.c ├── opus_multistream.c ├── opus_multistream_decoder.c ├── opus_multistream_encoder.c ├── opus_private.h ├── repacketizer.c ├── repacketizer_demo.c └── tansig_table.h ├── tests ├── run_vectors.sh ├── test_opus_api.c ├── test_opus_common.h ├── test_opus_decode.c ├── test_opus_encode.c └── test_opus_padding.c ├── version.mk └── win32 ├── VS2010 ├── celt.vcxproj ├── celt.vcxproj.filters ├── opus.sln ├── opus.vcxproj ├── opus.vcxproj.filters ├── opus_demo.vcxproj ├── opus_demo.vcxproj.filters ├── silk_common.vcxproj ├── silk_common.vcxproj.filters ├── silk_fixed.vcxproj ├── silk_fixed.vcxproj.filters ├── silk_float.vcxproj ├── silk_float.vcxproj.filters ├── test_opus_api.vcxproj ├── test_opus_api.vcxproj.filters ├── test_opus_decode.vcxproj ├── test_opus_decode.vcxproj.filters ├── test_opus_encode.vcxproj └── test_opus_encode.vcxproj.filters ├── config.h └── genversion.bat /AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin (jmvalin@jmvalin.ca) 2 | Koen Vos (koenvos74@gmail.com) 3 | Timothy Terriberry (tterribe@xiph.org) 4 | Karsten Vandborg Sorensen (karsten.vandborg.sorensen@skype.net) 5 | Soren Skak Jensen (ssjensen@gn.com) 6 | Gregory Maxwell (greg@xiph.org) 7 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, 2 | Jean-Marc Valin, Timothy B. Terriberry, 3 | CSIRO, Gregory Maxwell, Mark Borgerding, 4 | Erik de Castro Lopo 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of Internet Society, IETF or IETF Trust, nor the 18 | names of specific contributors, may be used to endorse or promote 19 | products derived from this software without specific prior written 20 | permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 26 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | Opus is subject to the royalty-free patent licenses which are 35 | specified at: 36 | 37 | Xiph.Org Foundation: 38 | https://datatracker.ietf.org/ipr/1524/ 39 | 40 | Microsoft Corporation: 41 | https://datatracker.ietf.org/ipr/1914/ 42 | 43 | Broadcom Corporation: 44 | https://datatracker.ietf.org/ipr/1526/ 45 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco/opus/89928e92923323f15ca6c480be17ddbf5428fe26/ChangeLog -------------------------------------------------------------------------------- /LICENSE_PLEASE_READ.txt: -------------------------------------------------------------------------------- 1 | Contributions to the collaboration shall not be considered confidential. 2 | 3 | Each contributor represents and warrants that it has the right and 4 | authority to license copyright in its contributions to the collaboration. 5 | 6 | Each contributor agrees to license the copyright in the contributions 7 | under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License. 8 | 9 | Please see the IPR statements submitted to the IETF for the complete 10 | patent licensing details: 11 | 12 | Xiph.Org Foundation: 13 | https://datatracker.ietf.org/ipr/1524/ 14 | 15 | Microsoft Corporation: 16 | https://datatracker.ietf.org/ipr/1914/ 17 | 18 | Skype Limited: 19 | https://datatracker.ietf.org/ipr/1602/ 20 | 21 | Broadcom Corporation: 22 | https://datatracker.ietf.org/ipr/1526/ 23 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco/opus/89928e92923323f15ca6c480be17ddbf5428fe26/NEWS -------------------------------------------------------------------------------- /README.draft: -------------------------------------------------------------------------------- 1 | To build this source code, simply type: 2 | 3 | % make 4 | 5 | If this does not work, or if you want to change the default configuration 6 | (e.g., to compile for a fixed-point architecture), simply edit the options 7 | in the Makefile. 8 | 9 | An up-to-date implementation conforming to this standard is available in a 10 | Git repository at git://git.xiph.org/opus.git or on a website at: 11 | http://opus-codec.org/ 12 | However, although that implementation is expected to remain conformant 13 | with the standard, it is the code in this RFC that shall remain normative. 14 | To build from the git repository instead of using this RFC, follow these 15 | steps: 16 | 17 | 1) Clone the repository (latest implementation of this standard at the time 18 | of publication) 19 | 20 | % git clone git://git.opus-codec.org/opus.git 21 | % cd opus 22 | 23 | 2) Compile 24 | 25 | % ./autogen.sh 26 | % ./configure 27 | % make 28 | 29 | Once you have compiled the codec, there will be a opus_demo executable in 30 | the top directory. 31 | 32 | Usage: opus_demo [-e] 33 | [options] 34 | opus_demo -d [options] 35 | 36 | 37 | mode: voip | audio | restricted-lowdelay 38 | options: 39 | -e : only runs the encoder (output the bit-stream) 40 | -d : only runs the decoder (reads the bit-stream as input) 41 | -cbr : enable constant bitrate; default: variable bitrate 42 | -cvbr : enable constrained variable bitrate; default: unconstrained 43 | -bandwidth : audio bandwidth (from narrowband to fullband); 44 | default: sampling rate 45 | -framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 46 | -max_payload : maximum payload size in bytes, default: 1024 47 | -complexity : complexity, 0 (lowest) ... 10 (highest); default: 10 48 | -inbandfec : enable SILK inband FEC 49 | -forcemono : force mono encoding, even for stereo input 50 | -dtx : enable SILK DTX 51 | -loss : simulate packet loss, in percent (0-100); default: 0 52 | 53 | input and output are little endian signed 16-bit PCM files or opus bitstreams 54 | with simple opus_demo proprietary framing. 55 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to set up the build system: configure, makefiles, etc. 3 | set -e 4 | 5 | srcdir=`dirname $0` 6 | test -n "$srcdir" && cd "$srcdir" 7 | 8 | echo "Updating build configuration files, please wait...." 9 | 10 | ACLOCAL_FLAGS="-I m4" 11 | autoreconf -isf 12 | -------------------------------------------------------------------------------- /celt/arm/arm_celt_map.c: -------------------------------------------------------------------------------- 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 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "pitch.h" 33 | 34 | #if defined(OPUS_HAVE_RTCD) 35 | 36 | # if defined(FIXED_POINT) 37 | opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, 38 | const opus_val16 *, opus_val32 *, int , int) = { 39 | celt_pitch_xcorr_c, /* ARMv4 */ 40 | MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */ 41 | MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */ 42 | MAY_HAVE_NEON(celt_pitch_xcorr) /* NEON */ 43 | }; 44 | # else 45 | # error "Floating-point implementation is not supported by ARM asm yet." \ 46 | "Reconfigure with --disable-rtcd or send patches." 47 | # endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /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 | # endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /celt/arm/fixed_armv4.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2013 Xiph.Org Foundation and contributors */ 2 | /* 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef FIXED_ARMv4_H 28 | #define FIXED_ARMv4_H 29 | 30 | /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ 31 | #undef MULT16_32_Q16 32 | static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) 33 | { 34 | unsigned rd_lo; 35 | int rd_hi; 36 | __asm__( 37 | "#MULT16_32_Q16\n\t" 38 | "smull %0, %1, %2, %3\n\t" 39 | : "=&r"(rd_lo), "=&r"(rd_hi) 40 | : "%r"(b),"r"(a<<16) 41 | ); 42 | return rd_hi; 43 | } 44 | #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv4(a, b)) 45 | 46 | 47 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 48 | #undef MULT16_32_Q15 49 | static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) 50 | { 51 | unsigned rd_lo; 52 | int rd_hi; 53 | __asm__( 54 | "#MULT16_32_Q15\n\t" 55 | "smull %0, %1, %2, %3\n\t" 56 | : "=&r"(rd_lo), "=&r"(rd_hi) 57 | : "%r"(b), "r"(a<<16) 58 | ); 59 | /*We intentionally don't OR in the high bit of rd_lo for speed.*/ 60 | return rd_hi<<1; 61 | } 62 | #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv4(a, b)) 63 | 64 | 65 | /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add. 66 | b must fit in 31 bits. 67 | Result fits in 32 bits. */ 68 | #undef MAC16_32_Q15 69 | #define MAC16_32_Q15(c, a, b) ADD32(c, MULT16_32_Q15(a, b)) 70 | 71 | /** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. 72 | Result fits in 32 bits. */ 73 | #undef MAC16_32_Q16 74 | #define MAC16_32_Q16(c, a, b) ADD32(c, MULT16_32_Q16(a, b)) 75 | 76 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ 77 | #undef MULT32_32_Q31 78 | #define MULT32_32_Q31(a,b) (opus_val32)((((opus_int64)(a)) * ((opus_int64)(b)))>>31) 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /celt/arm/pitch_arm.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(PITCH_ARM_H) 29 | # define PITCH_ARM_H 30 | 31 | # include "armcpu.h" 32 | 33 | # if defined(FIXED_POINT) 34 | 35 | # if defined(OPUS_ARM_MAY_HAVE_NEON) 36 | opus_val32 celt_pitch_xcorr_neon(const opus_val16 *_x, const opus_val16 *_y, 37 | opus_val32 *xcorr, int len, int max_pitch); 38 | # endif 39 | 40 | # if defined(OPUS_ARM_MAY_HAVE_MEDIA) 41 | # define celt_pitch_xcorr_media MAY_HAVE_EDSP(celt_pitch_xcorr) 42 | # endif 43 | 44 | # if defined(OPUS_ARM_MAY_HAVE_EDSP) 45 | opus_val32 celt_pitch_xcorr_edsp(const opus_val16 *_x, const opus_val16 *_y, 46 | opus_val32 *xcorr, int len, int max_pitch); 47 | # endif 48 | 49 | # if !defined(OPUS_HAVE_RTCD) 50 | # define OVERRIDE_PITCH_XCORR (1) 51 | # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ 52 | ((void)(arch),PRESUME_NEON(celt_pitch_xcorr)(_x, _y, xcorr, len, max_pitch)) 53 | # endif 54 | 55 | # endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /celt/celt_lpc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009-2010 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PLC_H 29 | #define PLC_H 30 | 31 | #include "arch.h" 32 | #include "cpu_support.h" 33 | 34 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) 35 | #include "x86/celt_lpc_sse.h" 36 | #endif 37 | 38 | #define LPC_ORDER 24 39 | 40 | void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); 41 | 42 | void celt_fir_c( 43 | const opus_val16 *x, 44 | const opus_val16 *num, 45 | opus_val16 *y, 46 | int N, 47 | int ord, 48 | opus_val16 *mem, 49 | const int arch); 50 | 51 | #if !defined(OPUS_X86_MAY_HAVE_SSE4_1) 52 | #define celt_fir(x, num, y, N, ord, mem, arch) \ 53 | (celt_fir_c(x, num, y, N, ord, mem, arch)) 54 | #endif 55 | 56 | void celt_iir(const opus_val32 *x, 57 | const opus_val16 *den, 58 | opus_val32 *y, 59 | int N, 60 | int ord, 61 | opus_val16 *mem, 62 | const int arch); 63 | 64 | int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, 65 | const opus_val16 *window, int overlap, int lag, int n, int arch); 66 | 67 | #endif /* PLC_H */ 68 | -------------------------------------------------------------------------------- /celt/cpu_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Xiph.Org Foundation 2 | * Copyright (c) 2013 Parrot */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef CPU_SUPPORT_H 29 | #define CPU_SUPPORT_H 30 | 31 | #include "opus_types.h" 32 | #include "opus_defines.h" 33 | 34 | #if defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_ASM) 35 | #include "arm/armcpu.h" 36 | 37 | /* We currently support 4 ARM variants: 38 | * arch[0] -> ARMv4 39 | * arch[1] -> ARMv5E 40 | * arch[2] -> ARMv6 41 | * arch[3] -> NEON 42 | */ 43 | #define OPUS_ARCHMASK 3 44 | 45 | #elif defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) 46 | 47 | #include "x86/x86_cpu.h" 48 | /* We currently support 3 x86 variants: 49 | * arch[0] -> non-sse 50 | * arch[1] -> sse2 51 | * arch[2] -> sse4.1 52 | * arch[3] -> NULL 53 | */ 54 | #define OPUS_ARCHMASK 3 55 | int opus_select_arch(void); 56 | 57 | #else 58 | #define OPUS_ARCHMASK 0 59 | 60 | static OPUS_INLINE int opus_select_arch(void) 61 | { 62 | return 0; 63 | } 64 | #endif 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /celt/cwrs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2007-2009 Timothy B. Terriberry 4 | Written by Timothy B. Terriberry and Jean-Marc Valin */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef CWRS_H 31 | #define CWRS_H 32 | 33 | #include "arch.h" 34 | #include "stack_alloc.h" 35 | #include "entenc.h" 36 | #include "entdec.h" 37 | 38 | #ifdef CUSTOM_MODES 39 | int log2_frac(opus_uint32 val, int frac); 40 | #endif 41 | 42 | void get_required_bits(opus_int16 *bits, int N, int K, int frac); 43 | 44 | void encode_pulses(const int *_y, int N, int K, ec_enc *enc); 45 | 46 | opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); 47 | 48 | #endif /* CWRS_H */ 49 | -------------------------------------------------------------------------------- /celt/dump_modes/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-O2 -Wall -Wextra -DHAVE_CONFIG_H 2 | INCLUDES=-I. -I../ -I../.. -I../../include 3 | 4 | all: dump_modes 5 | 6 | dump_modes: 7 | $(CC) $(CFLAGS) $(INCLUDES) -DCUSTOM_MODES_ONLY -DCUSTOM_MODES dump_modes.c ../modes.c ../cwrs.c ../rate.c ../entenc.c ../entdec.c ../mathops.c ../mdct.c ../kiss_fft.c -o dump_modes -lm 8 | 9 | clean: 10 | rm -f dump_modes 11 | -------------------------------------------------------------------------------- /celt/fixed_c5x.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Jean-Marc Valin */ 2 | /** 3 | @file fixed_c5x.h 4 | @brief Fixed-point operations for the TI C5x DSP family 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef FIXED_C5X_H 32 | #define FIXED_C5X_H 33 | 34 | #include "dsplib.h" 35 | 36 | #undef IMUL32 37 | static OPUS_INLINE long IMUL32(long i, long j) 38 | { 39 | long ac0, ac1; 40 | ac0 = _lmpy(i>>16,j); 41 | ac1 = ac0 + _lmpy(i,j>>16); 42 | return _lmpyu(i,j) + (ac1<<16); 43 | } 44 | 45 | #undef MAX16 46 | #define MAX16(a,b) _max(a,b) 47 | 48 | #undef MIN16 49 | #define MIN16(a,b) _min(a,b) 50 | 51 | #undef MAX32 52 | #define MAX32(a,b) _lmax(a,b) 53 | 54 | #undef MIN32 55 | #define MIN32(a,b) _lmin(a,b) 56 | 57 | #undef VSHR32 58 | #define VSHR32(a, shift) _lshl(a,-(shift)) 59 | 60 | #undef MULT16_16_Q15 61 | #define MULT16_16_Q15(a,b) (_smpy(a,b)) 62 | 63 | #undef MULT16_16SU 64 | #define MULT16_16SU(a,b) _lmpysu(a,b) 65 | 66 | #undef MULT_16_16 67 | #define MULT_16_16(a,b) _lmpy(a,b) 68 | 69 | /* FIXME: This is technically incorrect and is bound to cause problems. Is there any cleaner solution? */ 70 | #undef MULT16_32_Q15 71 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15)) 72 | 73 | #define celt_ilog2(x) (30 - _lnorm(x)) 74 | #define OVERRIDE_CELT_ILOG2 75 | 76 | #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) 77 | #define OVERRIDE_CELT_MAXABS16 78 | 79 | #endif /* FIXED_C5X_H */ 80 | -------------------------------------------------------------------------------- /celt/fixed_c6x.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008 CSIRO */ 2 | /** 3 | @file fixed_c6x.h 4 | @brief Fixed-point operations for the TI C6x DSP family 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef FIXED_C6X_H 32 | #define FIXED_C6X_H 33 | 34 | #undef MULT16_16SU 35 | #define MULT16_16SU(a,b) _mpysu(a,b) 36 | 37 | #undef MULT_16_16 38 | #define MULT_16_16(a,b) _mpy(a,b) 39 | 40 | #define celt_ilog2(x) (30 - _norm(x)) 41 | #define OVERRIDE_CELT_ILOG2 42 | 43 | #undef MULT16_32_Q15 44 | #define MULT16_32_Q15(a,b) (_mpylill(a, b) >> 15) 45 | 46 | #if 0 47 | #include "dsplib.h" 48 | 49 | #undef MAX16 50 | #define MAX16(a,b) _max(a,b) 51 | 52 | #undef MIN16 53 | #define MIN16(a,b) _min(a,b) 54 | 55 | #undef MAX32 56 | #define MAX32(a,b) _lmax(a,b) 57 | 58 | #undef MIN32 59 | #define MIN32(a,b) _lmin(a,b) 60 | 61 | #undef VSHR32 62 | #define VSHR32(a, shift) _lshl(a,-(shift)) 63 | 64 | #undef MULT16_16_Q15 65 | #define MULT16_16_Q15(a,b) (_smpy(a,b)) 66 | 67 | #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) 68 | #define OVERRIDE_CELT_MAXABS16 69 | 70 | #endif /* FIXED_C6X_H */ 71 | -------------------------------------------------------------------------------- /celt/laplace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /* 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "entenc.h" 30 | #include "entdec.h" 31 | 32 | /** Encode a value that is assumed to be the realisation of a 33 | Laplace-distributed random process 34 | @param enc Entropy encoder state 35 | @param value Value to encode 36 | @param fs Probability of 0, multiplied by 32768 37 | @param decay Probability of the value +/- 1, multiplied by 16384 38 | */ 39 | void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay); 40 | 41 | /** Decode a value that is assumed to be the realisation of a 42 | Laplace-distributed random process 43 | @param dec Entropy decoder state 44 | @param fs Probability of 0, multiplied by 32768 45 | @param decay Probability of the value +/- 1, multiplied by 16384 46 | @return Value decoded 47 | */ 48 | int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay); 49 | -------------------------------------------------------------------------------- /celt/mdct.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2008 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 | /* This is a simple MDCT implementation that uses a N/4 complex FFT 30 | to do most of the work. It should be relatively straightforward to 31 | plug in pretty much and FFT here. 32 | 33 | This replaces the Vorbis FFT (and uses the exact same API), which 34 | was a bit too messy and that was ending up duplicating code 35 | (might as well use the same FFT everywhere). 36 | 37 | The algorithm is similar to (and inspired from) Fabrice Bellard's 38 | MDCT implementation in FFMPEG, but has differences in signs, ordering 39 | and scaling in many places. 40 | */ 41 | 42 | #ifndef MDCT_H 43 | #define MDCT_H 44 | 45 | #include "opus_defines.h" 46 | #include "kiss_fft.h" 47 | #include "arch.h" 48 | 49 | typedef struct { 50 | int n; 51 | int maxshift; 52 | const kiss_fft_state *kfft[4]; 53 | const kiss_twiddle_scalar * OPUS_RESTRICT trig; 54 | } mdct_lookup; 55 | 56 | int clt_mdct_init(mdct_lookup *l,int N, int maxshift); 57 | void clt_mdct_clear(mdct_lookup *l); 58 | 59 | /** Compute a forward MDCT and scale by 4/N, trashes the input array */ 60 | void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, 61 | kiss_fft_scalar * OPUS_RESTRICT out, 62 | const opus_val16 *window, int overlap, int shift, int stride); 63 | 64 | /** Compute a backward MDCT (no scaling) and performs weighted overlap-add 65 | (scales implicitly by 1/2) */ 66 | void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, 67 | kiss_fft_scalar * OPUS_RESTRICT out, 68 | const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /celt/mfrngcod.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2001-2008 Timothy B. Terriberry 2 | Copyright (c) 2008-2009 Xiph.Org Foundation */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !defined(_mfrngcode_H) 29 | # define _mfrngcode_H (1) 30 | # include "entcode.h" 31 | 32 | /*Constants used by the entropy encoder/decoder.*/ 33 | 34 | /*The number of bits to output at a time.*/ 35 | # define EC_SYM_BITS (8) 36 | /*The total number of bits in each of the state registers.*/ 37 | # define EC_CODE_BITS (32) 38 | /*The maximum symbol value.*/ 39 | # define EC_SYM_MAX ((1U<>EC_SYM_BITS) 46 | /*The number of bits available for the last, partial symbol in the code field.*/ 47 | # define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1) 48 | #endif 49 | -------------------------------------------------------------------------------- /celt/modes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Copyright (c) 2008 Gregory Maxwell 4 | Written by Jean-Marc Valin and Gregory Maxwell */ 5 | /* 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef MODES_H 31 | #define MODES_H 32 | 33 | #include "opus_types.h" 34 | #include "celt.h" 35 | #include "arch.h" 36 | #include "mdct.h" 37 | #include "entenc.h" 38 | #include "entdec.h" 39 | 40 | #define MAX_PERIOD 1024 41 | 42 | typedef struct { 43 | int size; 44 | const opus_int16 *index; 45 | const unsigned char *bits; 46 | const unsigned char *caps; 47 | } PulseCache; 48 | 49 | /** Mode definition (opaque) 50 | @brief Mode definition 51 | */ 52 | struct OpusCustomMode { 53 | opus_int32 Fs; 54 | int overlap; 55 | 56 | int nbEBands; 57 | int effEBands; 58 | opus_val16 preemph[4]; 59 | const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ 60 | 61 | int maxLM; 62 | int nbShortMdcts; 63 | int shortMdctSize; 64 | 65 | int nbAllocVectors; /**< Number of lines in the matrix below */ 66 | const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ 67 | const opus_int16 *logN; 68 | 69 | const opus_val16 *window; 70 | mdct_lookup mdct; 71 | PulseCache cache; 72 | }; 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /celt/os_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: os_support.h 4 | This is the (tiny) OS abstraction layer. Aside from math.h, this is the 5 | only place where system headers are allowed. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 22 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 27 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef OS_SUPPORT_H 32 | #define OS_SUPPORT_H 33 | 34 | #ifdef CUSTOM_SUPPORT 35 | # include "custom_support.h" 36 | #endif 37 | 38 | #include "opus_types.h" 39 | #include "opus_defines.h" 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ 46 | #ifndef OVERRIDE_OPUS_ALLOC 47 | static OPUS_INLINE void *opus_alloc (size_t size) 48 | { 49 | return malloc(size); 50 | } 51 | #endif 52 | 53 | /** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */ 54 | #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH 55 | static OPUS_INLINE void *opus_alloc_scratch (size_t size) 56 | { 57 | /* Scratch space doesn't need to be cleared */ 58 | return opus_alloc(size); 59 | } 60 | #endif 61 | 62 | /** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */ 63 | #ifndef OVERRIDE_OPUS_FREE 64 | static OPUS_INLINE void opus_free (void *ptr) 65 | { 66 | free(ptr); 67 | } 68 | #endif 69 | 70 | /** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ 71 | #ifndef OVERRIDE_OPUS_COPY 72 | #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 73 | #endif 74 | 75 | /** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term 76 | provides compile-time type checking */ 77 | #ifndef OVERRIDE_OPUS_MOVE 78 | #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 79 | #endif 80 | 81 | /** Set n elements of dst to zero, starting at address s */ 82 | #ifndef OVERRIDE_OPUS_CLEAR 83 | #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) 84 | #endif 85 | 86 | /*#ifdef __GNUC__ 87 | #pragma GCC poison printf sprintf 88 | #pragma GCC poison malloc free realloc calloc 89 | #endif*/ 90 | 91 | #endif /* OS_SUPPORT_H */ 92 | 93 | -------------------------------------------------------------------------------- /celt/quant_bands.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /* 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef QUANT_BANDS 30 | #define QUANT_BANDS 31 | 32 | #include "arch.h" 33 | #include "modes.h" 34 | #include "entenc.h" 35 | #include "entdec.h" 36 | #include "mathops.h" 37 | 38 | #ifdef FIXED_POINT 39 | extern const signed char eMeans[25]; 40 | #else 41 | extern const opus_val16 eMeans[25]; 42 | #endif 43 | 44 | void amp2Log2(const CELTMode *m, int effEnd, int end, 45 | celt_ener *bandE, opus_val16 *bandLogE, int C); 46 | 47 | void log2Amp(const CELTMode *m, int start, int end, 48 | celt_ener *eBands, const opus_val16 *oldEBands, int C); 49 | 50 | void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, 51 | const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, 52 | opus_val16 *error, ec_enc *enc, int C, int LM, 53 | int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, 54 | int two_pass, int loss_rate, int lfe); 55 | 56 | void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C); 57 | 58 | void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C); 59 | 60 | void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM); 61 | 62 | void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C); 63 | 64 | void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C); 65 | 66 | #endif /* QUANT_BANDS */ 67 | -------------------------------------------------------------------------------- /celt/tests/test_unit_laplace.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation 2 | Written by Jean-Marc Valin and Timothy B. Terriberry */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include 33 | #include 34 | #include "laplace.h" 35 | #define CELT_C 36 | #include "stack_alloc.h" 37 | 38 | #include "entenc.c" 39 | #include "entdec.c" 40 | #include "entcode.c" 41 | #include "laplace.c" 42 | 43 | #define DATA_SIZE 40000 44 | 45 | int ec_laplace_get_start_freq(int decay) 46 | { 47 | opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); 48 | int fs = (ft*(16384-decay))/(16384+decay); 49 | return fs+LAPLACE_MINP; 50 | } 51 | 52 | int main(void) 53 | { 54 | int i; 55 | int ret = 0; 56 | ec_enc enc; 57 | ec_dec dec; 58 | unsigned char *ptr; 59 | int val[10000], decay[10000]; 60 | ALLOC_STACK; 61 | ptr = (unsigned char *)malloc(DATA_SIZE); 62 | ec_enc_init(&enc,ptr,DATA_SIZE); 63 | 64 | val[0] = 3; decay[0] = 6000; 65 | val[1] = 0; decay[1] = 5800; 66 | val[2] = -1; decay[2] = 5600; 67 | for (i=3;i<10000;i++) 68 | { 69 | val[i] = rand()%15-7; 70 | decay[i] = rand()%11000+5000; 71 | } 72 | for (i=0;i<10000;i++) 73 | ec_laplace_encode(&enc, &val[i], 74 | ec_laplace_get_start_freq(decay[i]), decay[i]); 75 | 76 | ec_enc_done(&enc); 77 | 78 | ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc)); 79 | 80 | for (i=0;i<10000;i++) 81 | { 82 | int d = ec_laplace_decode(&dec, 83 | ec_laplace_get_start_freq(decay[i]), decay[i]); 84 | if (d != val[i]) 85 | { 86 | fprintf (stderr, "Got %d instead of %d\n", d, val[i]); 87 | ret = 1; 88 | } 89 | } 90 | 91 | return ret; 92 | } 93 | -------------------------------------------------------------------------------- /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 | #define CELT_C 37 | 38 | #include 39 | #include 40 | #include "vq.c" 41 | #include "cwrs.c" 42 | #include "entcode.c" 43 | #include "entenc.c" 44 | #include "entdec.c" 45 | #include "mathops.c" 46 | #include "bands.h" 47 | 48 | #include "pitch.c" 49 | #include "celt_lpc.c" 50 | #include 51 | #define MAX_SIZE 100 52 | 53 | int ret=0; 54 | void test_rotation(int N, int K) 55 | { 56 | int i; 57 | double err = 0, ener = 0, snr, snr0; 58 | opus_val16 x0[MAX_SIZE]; 59 | opus_val16 x1[MAX_SIZE]; 60 | for (i=0;i 20) 79 | { 80 | fprintf(stderr, "FAIL!\n"); 81 | ret = 1; 82 | } 83 | } 84 | 85 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2) 86 | #include "x86/pitch_sse.c" 87 | #if defined(OPUS_X86_MAY_HAVE_SSE4_1) 88 | #include "x86/celt_lpc_sse.c" 89 | #endif 90 | #include "x86/x86_celt_map.c" 91 | #endif 92 | 93 | int main(void) 94 | { 95 | ALLOC_STACK; 96 | test_rotation(15, 3); 97 | test_rotation(23, 5); 98 | test_rotation(50, 3); 99 | test_rotation(80, 1); 100 | return ret; 101 | } 102 | -------------------------------------------------------------------------------- /celt/tests/test_unit_types.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008-2011 Xiph.Org Foundation 2 | Written by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include "config.h" 30 | #endif 31 | 32 | #include "opus_types.h" 33 | #include 34 | 35 | int main(void) 36 | { 37 | opus_int16 i = 1; 38 | i <<= 14; 39 | if (i>>14 != 1) 40 | { 41 | fprintf(stderr, "opus_int16 isn't 16 bits\n"); 42 | return 1; 43 | } 44 | if (sizeof(opus_int16)*2 != sizeof(opus_int32)) 45 | { 46 | fprintf(stderr, "16*2 != 32\n"); 47 | return 1; 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /celt/vq.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007-2008 CSIRO 2 | Copyright (c) 2007-2009 Xiph.Org Foundation 3 | Written by Jean-Marc Valin */ 4 | /** 5 | @file vq.h 6 | @brief Vector quantisation of the residual 7 | */ 8 | /* 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 16 | - Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef VQ_H 34 | #define VQ_H 35 | 36 | #include "entenc.h" 37 | #include "entdec.h" 38 | #include "modes.h" 39 | 40 | /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of 41 | * the pitch and a combination of pulses such that its norm is still equal 42 | * to 1. This is the function that will typically require the most CPU. 43 | * @param X Residual signal to quantise/encode (returns quantised version) 44 | * @param N Number of samples to encode 45 | * @param K Number of pulses to use 46 | * @param enc Entropy encoder state 47 | * @ret A mask indicating which blocks in the band received pulses 48 | */ 49 | unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, 50 | ec_enc *enc 51 | #ifdef RESYNTH 52 | , opus_val16 gain 53 | #endif 54 | ); 55 | 56 | /** Algebraic pulse decoder 57 | * @param X Decoded normalised spectrum (returned) 58 | * @param N Number of samples to decode 59 | * @param K Number of pulses to use 60 | * @param dec Entropy decoder state 61 | * @ret A mask indicating which blocks in the band received pulses 62 | */ 63 | unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, 64 | ec_dec *dec, opus_val16 gain); 65 | 66 | void renormalise_vector(celt_norm *X, int N, opus_val16 gain, const int arch); 67 | 68 | int stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, const int arch); 69 | 70 | #endif /* VQ_H */ 71 | -------------------------------------------------------------------------------- /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) 36 | void celt_fir_sse4_1( 37 | const opus_val16 *x, 38 | const opus_val16 *num, 39 | opus_val16 *y, 40 | int N, 41 | int ord, 42 | opus_val16 *mem, 43 | const int arch); 44 | 45 | extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( 46 | const opus_val16 *x, 47 | const opus_val16 *num, 48 | opus_val16 *y, 49 | int N, 50 | int ord, 51 | opus_val16 *mem, 52 | const int arch); 53 | 54 | # define celt_fir(x, num, y, N, ord, mem, arch) \ 55 | ((*CELT_FIR_IMPL[(arch) & OPUS_ARCHMASK])(x, num, y, N, ord, mem, arch)) 56 | 57 | #endif 58 | #endif -------------------------------------------------------------------------------- /celt/x86/x86_celt_map.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 | #if defined(HAVE_CONFIG_H) 29 | #include "config.h" 30 | #endif 31 | 32 | #include "x86/x86_cpu.h" 33 | #include "celt_lpc.h" 34 | #include "pitch.h" 35 | #include "pitch_sse.h" 36 | 37 | void (*const CELT_FIR_IMPL[ OPUS_ARCHMASK + 1 ] )( 38 | const opus_val16 *x, 39 | const opus_val16 *num, 40 | opus_val16 *y, 41 | int N, 42 | int ord, 43 | opus_val16 *mem, 44 | const int arch 45 | ) = { 46 | celt_fir_c, /* non-sse */ 47 | celt_fir_c, 48 | MAY_HAVE_SSE4_1( celt_fir ), /* sse4.1 */ 49 | NULL 50 | }; 51 | 52 | void (*const XCORR_KERNEL_IMPL[ OPUS_ARCHMASK + 1 ] )( 53 | const opus_val16 *x, 54 | const opus_val16 *y, 55 | opus_val32 sum[ 4 ], 56 | int len 57 | ) = { 58 | xcorr_kernel_c, /* non-sse */ 59 | xcorr_kernel_c, 60 | MAY_HAVE_SSE4_1( xcorr_kernel ), /* sse4.1 */ 61 | NULL 62 | }; 63 | 64 | opus_val32 (*const CELT_INNER_PROD_IMPL[ OPUS_ARCHMASK + 1 ] )( 65 | const opus_val16 *x, 66 | const opus_val16 *y, 67 | int N 68 | ) = { 69 | celt_inner_prod_c, /* non-sse */ 70 | MAY_HAVE_SSE2( celt_inner_prod ), 71 | MAY_HAVE_SSE4_1( celt_inner_prod ), /* sse4.1 */ 72 | NULL 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /celt/x86/x86_cpu.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 "cpu_support.h" 33 | #include "macros.h" 34 | #include "main.h" 35 | #include "pitch.h" 36 | #include "x86_cpu.h" 37 | 38 | #ifdef _WIN32 39 | 40 | #include 41 | #define cpuid(info,x) __cpuid(info,x) 42 | #else 43 | 44 | #if defined(CPU_INFO_BY_C) 45 | #include 46 | #endif 47 | 48 | static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) 49 | { 50 | #if defined(CPU_INFO_BY_ASM) 51 | __asm__ __volatile__ ( 52 | "cpuid": 53 | "=a" (CPUInfo[0]), 54 | "=b" (CPUInfo[1]), 55 | "=c" (CPUInfo[2]), 56 | "=d" (CPUInfo[3]) : 57 | "a" (InfoType), "c" (0) 58 | ); 59 | #elif defined(CPU_INFO_BY_C) 60 | __get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3])); 61 | #endif 62 | } 63 | 64 | #endif 65 | 66 | #include "SigProc_FIX.h" 67 | #include "celt_lpc.h" 68 | 69 | typedef struct CPU_Feature{ 70 | /* SIMD: 128-bit */ 71 | int HW_SSE2; 72 | int HW_SSE41; 73 | } CPU_Feature; 74 | 75 | #define OPUS_DEFAULT 0 76 | #define OPUS_SSE2 1 77 | #define OPUS_SSE4_1 2 78 | 79 | static void opus_cpu_feature_check(CPU_Feature *cpu_feature) 80 | { 81 | unsigned int info[ 4 ] = {0, 0, 0, 0}; 82 | unsigned int nIds = 0; 83 | unsigned int nExIds = 0; 84 | 85 | cpuid( info, 0 ); 86 | nIds = info[ 0 ]; 87 | cpuid( info, 0x80000000 ); 88 | nExIds = info[ 0 ]; 89 | 90 | if ( nIds >= 0x00000001 ){ 91 | cpuid( info, 0x00000001 ); 92 | cpu_feature->HW_SSE2 = ( info[ 3 ] & ( (int)1 << 26 ) ) != 0; 93 | cpu_feature->HW_SSE41 = ( info[ 2 ] & ( (int)1 << 19 ) ) != 0; 94 | } 95 | } 96 | 97 | int opus_select_arch(void) 98 | { 99 | CPU_Feature cpu_feature = { 0, 0 }; 100 | 101 | opus_cpu_feature_check(&cpu_feature); 102 | 103 | if ( cpu_feature.HW_SSE41) 104 | { 105 | return OPUS_SSE4_1; 106 | } 107 | else if (cpu_feature.HW_SSE2) 108 | { 109 | return OPUS_SSE2; 110 | } 111 | 112 | return OPUS_DEFAULT; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /celt/x86/x86_cpu.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 X86_CPU_H 29 | #define X86_CPU_H 30 | 31 | #if defined(OPUS_X86_MAY_HAVE_SSE2) 32 | # define MAY_HAVE_SSE2(name) name ## _sse2 33 | # else 34 | # define MAY_HAVE_SSE2(name) name ## _c 35 | # endif 36 | 37 | # if defined(OPUS_X86_MAY_HAVE_SSE4_1) 38 | # define MAY_HAVE_SSE4_1(name) name ## _sse4_1 39 | #else 40 | # define MAY_HAVE_SSE4_1(name) name ## _c 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /celt_headers.mk: -------------------------------------------------------------------------------- 1 | CELT_HEAD = \ 2 | celt/arch.h \ 3 | celt/bands.h \ 4 | celt/celt.h \ 5 | celt/cpu_support.h \ 6 | include/opus_types.h \ 7 | include/opus_defines.h \ 8 | include/opus_custom.h \ 9 | celt/cwrs.h \ 10 | celt/ecintrin.h \ 11 | celt/entcode.h \ 12 | celt/entdec.h \ 13 | celt/entenc.h \ 14 | celt/fixed_debug.h \ 15 | celt/fixed_generic.h \ 16 | celt/float_cast.h \ 17 | celt/_kiss_fft_guts.h \ 18 | celt/kiss_fft.h \ 19 | celt/laplace.h \ 20 | celt/mathops.h \ 21 | celt/mdct.h \ 22 | celt/mfrngcod.h \ 23 | celt/modes.h \ 24 | celt/os_support.h \ 25 | celt/pitch.h \ 26 | celt/celt_lpc.h \ 27 | celt/x86/celt_lpc_sse.h \ 28 | celt/quant_bands.h \ 29 | celt/rate.h \ 30 | celt/stack_alloc.h \ 31 | celt/vq.h \ 32 | celt/static_modes_float.h \ 33 | celt/static_modes_fixed.h \ 34 | celt/arm/armcpu.h \ 35 | celt/arm/fixed_armv4.h \ 36 | celt/arm/fixed_armv5e.h \ 37 | celt/arm/kiss_fft_armv4.h \ 38 | celt/arm/kiss_fft_armv5e.h \ 39 | celt/arm/pitch_arm.h \ 40 | celt/x86/pitch_sse.h \ 41 | celt/x86/x86_cpu.h 42 | -------------------------------------------------------------------------------- /celt_sources.mk: -------------------------------------------------------------------------------- 1 | CELT_SOURCES = celt/bands.c \ 2 | celt/celt.c \ 3 | celt/celt_encoder.c \ 4 | celt/celt_decoder.c \ 5 | celt/cwrs.c \ 6 | celt/entcode.c \ 7 | celt/entdec.c \ 8 | celt/entenc.c \ 9 | celt/kiss_fft.c \ 10 | celt/laplace.c \ 11 | celt/mathops.c \ 12 | celt/mdct.c \ 13 | celt/modes.c \ 14 | celt/pitch.c \ 15 | celt/celt_lpc.c \ 16 | celt/quant_bands.c \ 17 | celt/rate.c \ 18 | celt/vq.c 19 | 20 | CELT_SOURCE_SSE = celt/x86/x86_cpu.c \ 21 | celt/x86/x86_celt_map.c \ 22 | celt/x86/pitch_sse.c 23 | 24 | CELT_SOURCE_SSE4_1 = celt/x86/celt_lpc_sse.c 25 | 26 | CELT_SOURCES_ARM = \ 27 | celt/arm/armcpu.c \ 28 | celt/arm/arm_celt_map.c 29 | 30 | CELT_SOURCES_ARM_ASM = \ 31 | celt/arm/celt_pitch_xcorr_arm.s 32 | 33 | CELT_AM_SOURCES_ARM_ASM = \ 34 | celt/arm/armopts.s.in 35 | -------------------------------------------------------------------------------- /cisco-opus-optimization.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco/opus/89928e92923323f15ca6c480be17ddbf5428fe26/cisco-opus-optimization.pptx -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | DOCINPUTS = $(top_srcdir)/include/opus.h \ 4 | $(top_srcdir)/include/opus_multistream.h \ 5 | $(top_srcdir)/include/opus_defines.h \ 6 | $(top_srcdir)/include/opus_types.h \ 7 | $(top_srcdir)/include/opus_custom.h \ 8 | $(top_srcdir)/doc/header.html \ 9 | $(top_srcdir)/doc/footer.html \ 10 | $(top_srcdir)/doc/customdoxygen.css 11 | 12 | EXTRA_DIST = customdoxygen.css Doxyfile.in footer.html header.html \ 13 | opus_logo.svg trivial_example.c 14 | 15 | 16 | if HAVE_DOXYGEN 17 | 18 | all-local: doxygen-build.stamp 19 | 20 | doxygen-build.stamp: Doxyfile $(DOCINPUTS) 21 | doxygen 22 | touch $@ 23 | 24 | install-data-local: 25 | $(INSTALL) -d $(DESTDIR)$(docdir)/html/search 26 | for f in `find html -type f \! -name "installdox"`; do \ 27 | $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \ 28 | done 29 | 30 | $(INSTALL) -d $(DESTDIR)$(mandir)/man3 31 | cd man && find man3 -type f -name opus_*.3 \ 32 | -exec $(INSTALL_DATA) \{} $(DESTDIR)$(mandir)/man3 \; 33 | 34 | clean-local: 35 | $(RM) -r html 36 | $(RM) -r latex 37 | $(RM) -r man 38 | $(RM) doxygen-build.stamp 39 | 40 | uninstall-local: 41 | $(RM) -r $(DESTDIR)$(docdir)/html 42 | $(RM) $(DESTDIR)$(mandir)/man3/opus_*.3 $(DESTDIR)$(mandir)/man3/opus.h.3 43 | 44 | endif 45 | -------------------------------------------------------------------------------- /doc/build_oggdraft.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2012 Xiph.Org Foundation and Mozilla Corporation 4 | # 5 | # This file is extracted from RFC6716. Please see that RFC for additional 6 | # information. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # - Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # - Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # 19 | # - Neither the name of Internet Society, IETF or IETF Trust, nor the 20 | # names of specific contributors, may be used to endorse or promote 21 | # products derived from this software without specific prior written 22 | # permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 28 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | #Stop on errors 37 | set -e 38 | #Set the CWD to the location of this script 39 | [ -n "${0%/*}" ] && cd "${0%/*}" 40 | 41 | if test -z `which xml2rfc 2> /dev/null`; then 42 | echo "Error: couldn't find xml2rfc." 43 | echo 44 | echo "Please install xml2rfc version 2 or later." 45 | echo "E.g. 'pip install xml2rfc' or follow the instructions" 46 | echo "on http://pypi.python.org/pypi/xml2rfc/ or tools.ietf.org." 47 | exit 1 48 | fi 49 | 50 | echo running xml2rfc 51 | # version 2 syntax 52 | xml2rfc draft-ietf-codec-oggopus.xml --text --html 53 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | For more information visit the Opus Website. 12 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/footer.html.patch: -------------------------------------------------------------------------------- 1 | --- footer.orig.html 2012-06-11 00:32:00.237427961 -0400 2 | +++ footer.html 2012-06-11 00:45:51.518437796 -0400 3 | @@ -6,11 +6,15 @@ 4 | 5 | 6 | 7 | -