├── .clang-format ├── .git-blame-ignore-revs ├── .github └── workflows │ └── cmake.yml ├── .gitignore ├── .gitmodules ├── AUTHORS ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING ├── NEWS.md ├── PATENTS ├── README.md ├── common_audio ├── signal_processing │ ├── auto_corr_to_refl_coef.c │ ├── auto_correlation.c │ ├── complex_bit_reverse.c │ ├── complex_bit_reverse_arm.S │ ├── complex_bit_reverse_mips.c │ ├── complex_fft.c │ ├── complex_fft_mips.c │ ├── complex_fft_tables.h │ ├── copy_set_operations.c │ ├── cross_correlation.c │ ├── cross_correlation_mips.c │ ├── cross_correlation_neon.c │ ├── division_operations.c │ ├── dot_product_with_scale.cc │ ├── dot_product_with_scale.h │ ├── downsample_fast.c │ ├── downsample_fast_mips.c │ ├── downsample_fast_neon.c │ ├── energy.c │ ├── filter_ar.c │ ├── filter_ar_fast_q12.c │ ├── filter_ar_fast_q12_armv7.S │ ├── filter_ar_fast_q12_mips.c │ ├── filter_ma_fast_q12.c │ ├── get_hanning_window.c │ ├── get_scaling_square.c │ ├── ilbc_specific_functions.c │ ├── include │ │ ├── real_fft.h │ │ ├── signal_processing_library.h │ │ ├── spl_inl.h │ │ ├── spl_inl_armv7.h │ │ └── spl_inl_mips.h │ ├── levinson_durbin.c │ ├── lpc_to_refl_coef.c │ ├── min_max_operations.c │ ├── min_max_operations_mips.c │ ├── min_max_operations_neon.c │ ├── randomization_functions.c │ ├── real_fft.c │ ├── real_fft_unittest.cc │ ├── refl_coef_to_lpc.c │ ├── resample.c │ ├── resample_48khz.c │ ├── resample_by_2.c │ ├── resample_by_2_internal.c │ ├── resample_by_2_internal.h │ ├── resample_by_2_mips.c │ ├── resample_fractional.c │ ├── signal_processing_unittest.cc │ ├── spl_init.c │ ├── spl_inl.c │ ├── spl_sqrt.c │ ├── splitting_filter.c │ ├── sqrt_of_one_minus_x_squared.c │ ├── vector_scaling_operations.c │ └── vector_scaling_operations_mips.c └── third_party │ └── spl_sqrt_floor │ ├── BUILD.gn │ ├── LICENSE │ ├── README.chromium │ ├── spl_sqrt_floor.c │ ├── spl_sqrt_floor.h │ ├── spl_sqrt_floor_arm.S │ └── spl_sqrt_floor_mips.c ├── iLBC_test2.c ├── ilbc.h ├── libilbc.pc.in ├── make-archive.sh ├── modules └── audio_coding │ └── codecs │ └── ilbc │ ├── abs_quant.c │ ├── abs_quant.h │ ├── abs_quant_loop.c │ ├── abs_quant_loop.h │ ├── audio_decoder_ilbc.cc │ ├── audio_decoder_ilbc.h │ ├── audio_encoder_ilbc.cc │ ├── audio_encoder_ilbc.h │ ├── augmented_cb_corr.c │ ├── augmented_cb_corr.h │ ├── bw_expand.c │ ├── bw_expand.h │ ├── cb_construct.c │ ├── cb_construct.h │ ├── cb_mem_energy.c │ ├── cb_mem_energy.h │ ├── cb_mem_energy_augmentation.c │ ├── cb_mem_energy_augmentation.h │ ├── cb_mem_energy_calc.c │ ├── cb_mem_energy_calc.h │ ├── cb_search.c │ ├── cb_search.h │ ├── cb_search_core.c │ ├── cb_search_core.h │ ├── cb_update_best_index.c │ ├── cb_update_best_index.h │ ├── chebyshev.c │ ├── chebyshev.h │ ├── comp_corr.c │ ├── comp_corr.h │ ├── complexityMeasures.m │ ├── constants.c │ ├── constants.h │ ├── create_augmented_vec.c │ ├── create_augmented_vec.h │ ├── decode.c │ ├── decode.h │ ├── decode_residual.c │ ├── decode_residual.h │ ├── decoder_interpolate_lsf.c │ ├── decoder_interpolate_lsf.h │ ├── defines.h │ ├── do_plc.c │ ├── do_plc.h │ ├── encode.c │ ├── encode.h │ ├── energy_inverse.c │ ├── energy_inverse.h │ ├── enh_upsample.c │ ├── enh_upsample.h │ ├── enhancer.c │ ├── enhancer.h │ ├── enhancer_interface.c │ ├── enhancer_interface.h │ ├── filtered_cb_vecs.c │ ├── filtered_cb_vecs.h │ ├── frame_classify.c │ ├── frame_classify.h │ ├── gain_dequant.c │ ├── gain_dequant.h │ ├── gain_quant.c │ ├── gain_quant.h │ ├── get_cd_vec.c │ ├── get_cd_vec.h │ ├── get_lsp_poly.c │ ├── get_lsp_poly.h │ ├── get_sync_seq.c │ ├── get_sync_seq.h │ ├── hp_input.c │ ├── hp_input.h │ ├── hp_output.c │ ├── hp_output.h │ ├── ilbc.c │ ├── ilbc.h │ ├── ilbc_unittest.cc │ ├── index_conv_dec.c │ ├── index_conv_dec.h │ ├── index_conv_enc.c │ ├── index_conv_enc.h │ ├── init_decode.c │ ├── init_decode.h │ ├── init_encode.c │ ├── init_encode.h │ ├── interpolate.c │ ├── interpolate.h │ ├── interpolate_samples.c │ ├── interpolate_samples.h │ ├── lpc_encode.c │ ├── lpc_encode.h │ ├── lsf_check.c │ ├── lsf_check.h │ ├── lsf_interpolate_to_poly_dec.c │ ├── lsf_interpolate_to_poly_dec.h │ ├── lsf_interpolate_to_poly_enc.c │ ├── lsf_interpolate_to_poly_enc.h │ ├── lsf_to_lsp.c │ ├── lsf_to_lsp.h │ ├── lsf_to_poly.c │ ├── lsf_to_poly.h │ ├── lsp_to_lsf.c │ ├── lsp_to_lsf.h │ ├── my_corr.c │ ├── my_corr.h │ ├── nearest_neighbor.c │ ├── nearest_neighbor.h │ ├── pack_bits.c │ ├── pack_bits.h │ ├── poly_to_lsf.c │ ├── poly_to_lsf.h │ ├── poly_to_lsp.c │ ├── poly_to_lsp.h │ ├── refiner.c │ ├── refiner.h │ ├── simple_interpolate_lsf.c │ ├── simple_interpolate_lsf.h │ ├── simple_lpc_analysis.c │ ├── simple_lpc_analysis.h │ ├── simple_lsf_dequant.c │ ├── simple_lsf_dequant.h │ ├── simple_lsf_quant.c │ ├── simple_lsf_quant.h │ ├── smooth.c │ ├── smooth.h │ ├── smooth_out_data.c │ ├── smooth_out_data.h │ ├── sort_sq.c │ ├── sort_sq.h │ ├── split_vq.c │ ├── split_vq.h │ ├── state_construct.c │ ├── state_construct.h │ ├── state_search.c │ ├── state_search.h │ ├── swap_bytes.c │ ├── swap_bytes.h │ ├── test │ ├── empty.cc │ ├── iLBC_test.c │ ├── iLBC_testLib.c │ └── iLBC_testprogram.c │ ├── unpack_bits.c │ ├── unpack_bits.h │ ├── vq3.c │ ├── vq3.h │ ├── vq4.c │ ├── vq4.h │ ├── window32_w32.c │ ├── window32_w32.h │ ├── xcorr_coef.c │ └── xcorr_coef.h ├── rtc_base ├── checks.cc ├── checks.h ├── compile_assert_c.h ├── numerics │ ├── safe_compare.h │ ├── safe_conversions.h │ └── safe_conversions_impl.h ├── sanitizer.h ├── system │ ├── DEPS │ ├── arch.h │ ├── asm_defines.h │ ├── inline.h │ └── rtc_export.h └── type_traits.h └── sample.pcm /.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | --- 5 | Language: Java 6 | BasedOnStyle: Google 7 | --- 8 | Language: ObjC 9 | BasedOnStyle: Google 10 | BinPackParameters: false 11 | BinPackArguments: false 12 | ColumnLimit: 100 13 | ObjCBlockIndentWidth: 2 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignOperands: false 16 | AlwaysBreakBeforeMultilineStrings: false 17 | AllowShortFunctionsOnASingleLine: Inline 18 | BreakBeforeTernaryOperators: false 19 | IndentWrappedFunctionNames: true 20 | ContinuationIndentWidth: 4 21 | ObjCSpaceBeforeProtocolList: true 22 | --- 23 | Language: Cpp 24 | IncludeBlocks: Regroup 25 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # git hyper-blame master ignore list. 2 | # 3 | # This file contains a list of git hashes of revisions to be ignored by git 4 | # hyper-blame (in depot_tools). These revisions are considered "unimportant" in 5 | # that they are unlikely to be what you are interested in when blaming. 6 | # 7 | # Instructions: 8 | # - Only large (generally automated) reformatting or renaming CLs should be 9 | # added to this list. Do not put things here just because you feel they are 10 | # trivial or unimportant. If in doubt, do not put it on this list. 11 | # - Precede each revision with a comment containing the first line of its log. 12 | # - Only put full 40-character hashes on this list (not short hashes or any 13 | # other revision reference). 14 | # - Append to the bottom of the file (revisions should be in chronological order 15 | # from oldest to newest). 16 | # - Because you must use a hash, you need to append to this list in a follow-up 17 | # CL to the actual reformatting CL that you are trying to ignore. 18 | 19 | # Format all Java in WebRTC. 20 | b6760f9e4442410f2bcb6090b3b89bf709e2fce2 21 | # Format all C++ in WebRTC. 22 | 665174fdbb4e0540eccb27cf7412348f1b65534c 23 | # Format almost all C++ in WebRTC. Again. Mostly #include reordering. 24 | a4d873786f10eedd72de25ad0d94ad7c53c1f68a 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.so 3 | *.so.* 4 | *.a 5 | *.o 6 | *.lib 7 | *.dylib 8 | *.cmake 9 | *.pc 10 | CMakeCache.txt 11 | CMakeFiles 12 | Makefile 13 | install_manifest.txt 14 | .ninja_deps 15 | .ninja_log 16 | 17 | ilbc_export.h 18 | ilbc_test 19 | ilbc_test2 20 | 21 | # From upstream 22 | *.DS_Store 23 | *.Makefile 24 | *.host.mk 25 | *.ncb 26 | *.ninja 27 | *.props 28 | *.pyc 29 | *.rules 30 | *.scons 31 | *.sdf 32 | *.sln 33 | *.suo 34 | *.target.mk 35 | *.targets 36 | *.user 37 | *.vcproj 38 | *.vcxproj 39 | *.vcxproj.filters 40 | *.vpj 41 | *.vpw 42 | *.vpwhistu 43 | *.vtg 44 | *.xcodeproj 45 | *.xcworkspace 46 | *_proto.xml 47 | *_proto_cpp.xml 48 | *~ 49 | .*.sw? 50 | .cache 51 | .cipd 52 | .clangd 53 | .classpath 54 | .cproject 55 | .gdb_history 56 | .gdbinit 57 | .landmines 58 | .metadata 59 | .project 60 | .pydevproject 61 | .settings 62 | .sw? 63 | /Makefile 64 | /base 65 | /build 66 | /buildtools 67 | /ios 68 | /mojo 69 | /out 70 | /testing 71 | /third_party 72 | /tools 73 | /tools_webrtc/android/profiling/flamegraph 74 | /tools_webrtc/android/profiling/simpleperf 75 | /tools_webrtc/audio_quality/linux/pesq 76 | /tools_webrtc/audio_quality/linux/PolqaOem64 77 | /tools_webrtc/audio_quality/mac/pesq 78 | /tools_webrtc/audio_quality/win/*.exe 79 | /tools_webrtc/audio_quality/win/*.dll 80 | /tools_webrtc/video_quality_toolchain/linux/ffmpeg 81 | /tools_webrtc/video_quality_toolchain/linux/zxing 82 | /tools_webrtc/video_quality_toolchain/mac/ffmpeg 83 | /tools_webrtc/video_quality_toolchain/mac/zxing 84 | /tools_webrtc/video_quality_toolchain/win/*.dll 85 | /tools_webrtc/video_quality_toolchain/win/*.exe 86 | /rtc_tools/testing/*.zip 87 | /rtc_tools/testing/*.gz 88 | /rtc_tools/testing/golang/*/*.gz 89 | /rtc_tools/testing/golang/*/*.zip 90 | /rtc_tools/testing/webrtc_apprtc_browsertest/* 91 | /rtc_tools/testing/browsertest/* 92 | /x86-generic_out/ 93 | /xcodebuild 94 | /.vscode 95 | !webrtc/* 96 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "abseil"] 2 | path = abseil-cpp 3 | url = https://github.com/abseil/abseil-cpp.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | Only bug fixes and upstream merges are allowed. If you would like to fix 5 | the source code that would benefit upstream as well, please consider sending 6 | your patch to WebRTC first. 7 | 8 | How Do I Merge Upstream Changes? 9 | -------------------------------- 10 | 11 | Try 12 | ```sh 13 | git remote add upstream https://chromium.googlesource.com/external/webrtc 14 | git fetch upstream 15 | git merge upstream/lkgr 16 | # LKGR = latest known good revision 17 | # https://chromium.googlesource.com/chromiumos/docs/+/master/glossary.md 18 | ``` 19 | 20 | Delete all directories other than 21 | * common\_audio/signal\_processing/ 22 | * modules/audio\_coding/codecs/ilbc/ 23 | 24 | Cherry pick what's needed from rtc\_base/. Update the abseil-cpp submodule. 25 | 26 | **Always check `git status` before committing the merge** to make sure 27 | nothing unneeded is added!!! 28 | 29 | ### Changes from upstream 30 | 31 | We try to keep the overlaid changes to a minimum. However, here are a few 32 | changes we had to make: 33 | * Add the `ILBC_EXPORT` annotation to various functions in headers 34 | * Make the following files #include their header: 35 | * modules/audio\_coding/codecs/ilbc/decode.c 36 | * modules/audio\_coding/codecs/ilbc/encode.c 37 | * Support a few more platforms in rtc\_base/system/arch.h 38 | 39 | ### Generating ilbc.h 40 | 41 | This packaged library exposes a single header: ilbc.h. Past versions of 42 | upstream WebRTC have this header directly, but starting from version 3.0.0 we 43 | maintain our own copy of it. Here are some instructions for updating it: 44 | 45 | 1. Start with modules/audio\_coding/codecs/ilbc/ilbc.h. 46 | 2. Add in the macros and structs from 47 | modules/audio\_coding/codecs/ilbc/defines.h. Delete all macros and structs 48 | that were not already previously exposed (e.g., all macros under the 49 | ["PLC"](https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/modules/audio_coding/codecs/ilbc/defines.h;l=96;drc=a12c42a6b2d979c1bca1c4263354335fa6bd759d) 50 | heading and the iLBC\_bits structure). 51 | 3. Add in the function prototypes from 52 | * modules/audio\_coding/codecs/ilbc/init\_decode.h 53 | * modules/audio\_coding/codecs/ilbc/init\_encode.h 54 | * modules/audio\_coding/codecs/ilbc/decode.h 55 | * modules/audio\_coding/codecs/ilbc/encode.h 56 | 4. Add a few deprecated typedefs for backwards compatibility. 57 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, The WebRTC project authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | 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 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | 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 COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the WebRTC code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the WebRTC code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the WebRTC code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the WebRTC code package or any code incorporated 20 | within this implementation of the WebRTC code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the WebRTC code package shall terminate as 24 | of the date such litigation is filed. 25 | -------------------------------------------------------------------------------- /common_audio/signal_processing/auto_correlation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | #include "rtc_base/checks.h" 14 | 15 | size_t WebRtcSpl_AutoCorrelation(const int16_t* in_vector, 16 | size_t in_vector_length, 17 | size_t order, 18 | int32_t* result, 19 | int* scale) { 20 | int32_t sum = 0; 21 | size_t i = 0, j = 0; 22 | int16_t smax = 0; 23 | int scaling = 0; 24 | 25 | RTC_DCHECK_LE(order, in_vector_length); 26 | 27 | // Find the maximum absolute value of the samples. 28 | smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length); 29 | 30 | // In order to avoid overflow when computing the sum we should scale the 31 | // samples so that (in_vector_length * smax * smax) will not overflow. 32 | if (smax == 0) { 33 | scaling = 0; 34 | } else { 35 | // Number of bits in the sum loop. 36 | int nbits = WebRtcSpl_GetSizeInBits((uint32_t)in_vector_length); 37 | // Number of bits to normalize smax. 38 | int t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 39 | 40 | if (t > nbits) { 41 | scaling = 0; 42 | } else { 43 | scaling = nbits - t; 44 | } 45 | } 46 | 47 | // Perform the actual correlation calculation. 48 | for (i = 0; i < order + 1; i++) { 49 | sum = 0; 50 | /* Unroll the loop to improve performance. */ 51 | for (j = 0; i + j + 3 < in_vector_length; j += 4) { 52 | sum += (in_vector[j + 0] * in_vector[i + j + 0]) >> scaling; 53 | sum += (in_vector[j + 1] * in_vector[i + j + 1]) >> scaling; 54 | sum += (in_vector[j + 2] * in_vector[i + j + 2]) >> scaling; 55 | sum += (in_vector[j + 3] * in_vector[i + j + 3]) >> scaling; 56 | } 57 | for (; j < in_vector_length - i; j++) { 58 | sum += (in_vector[j] * in_vector[i + j]) >> scaling; 59 | } 60 | *result++ = sum; 61 | } 62 | 63 | *scale = scaling; 64 | return order + 1; 65 | } 66 | -------------------------------------------------------------------------------- /common_audio/signal_processing/copy_set_operations.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the implementation of functions 14 | * WebRtcSpl_MemSetW16() 15 | * WebRtcSpl_MemSetW32() 16 | * WebRtcSpl_MemCpyReversedOrder() 17 | * WebRtcSpl_CopyFromEndW16() 18 | * WebRtcSpl_ZerosArrayW16() 19 | * WebRtcSpl_ZerosArrayW32() 20 | * 21 | * The description header can be found in signal_processing_library.h 22 | * 23 | */ 24 | 25 | #include 26 | #include "common_audio/signal_processing/include/signal_processing_library.h" 27 | 28 | 29 | void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, size_t length) 30 | { 31 | size_t j; 32 | int16_t *arrptr = ptr; 33 | 34 | for (j = length; j > 0; j--) 35 | { 36 | *arrptr++ = set_value; 37 | } 38 | } 39 | 40 | void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, size_t length) 41 | { 42 | size_t j; 43 | int32_t *arrptr = ptr; 44 | 45 | for (j = length; j > 0; j--) 46 | { 47 | *arrptr++ = set_value; 48 | } 49 | } 50 | 51 | void WebRtcSpl_MemCpyReversedOrder(int16_t* dest, 52 | int16_t* source, 53 | size_t length) 54 | { 55 | size_t j; 56 | int16_t* destPtr = dest; 57 | int16_t* sourcePtr = source; 58 | 59 | for (j = 0; j < length; j++) 60 | { 61 | *destPtr-- = *sourcePtr++; 62 | } 63 | } 64 | 65 | void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in, 66 | size_t length, 67 | size_t samples, 68 | int16_t *vector_out) 69 | { 70 | // Copy the last of the input vector to vector_out 71 | WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); 72 | } 73 | 74 | void WebRtcSpl_ZerosArrayW16(int16_t *vector, size_t length) 75 | { 76 | WebRtcSpl_MemSetW16(vector, 0, length); 77 | } 78 | 79 | void WebRtcSpl_ZerosArrayW32(int32_t *vector, size_t length) 80 | { 81 | WebRtcSpl_MemSetW32(vector, 0, length); 82 | } 83 | -------------------------------------------------------------------------------- /common_audio/signal_processing/cross_correlation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/signal_processing/include/signal_processing_library.h" 12 | 13 | /* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */ 14 | void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation, 15 | const int16_t* seq1, 16 | const int16_t* seq2, 17 | size_t dim_seq, 18 | size_t dim_cross_correlation, 19 | int right_shifts, 20 | int step_seq2) { 21 | size_t i = 0, j = 0; 22 | 23 | for (i = 0; i < dim_cross_correlation; i++) { 24 | int32_t corr = 0; 25 | for (j = 0; j < dim_seq; j++) 26 | corr += (seq1[j] * seq2[j]) >> right_shifts; 27 | seq2 += step_seq2; 28 | *cross_correlation++ = corr; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common_audio/signal_processing/dot_product_with_scale.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "common_audio/signal_processing/dot_product_with_scale.h" 12 | 13 | #include "rtc_base/numerics/safe_conversions.h" 14 | 15 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 16 | const int16_t* vector2, 17 | size_t length, 18 | int scaling) { 19 | int64_t sum = 0; 20 | size_t i = 0; 21 | 22 | /* Unroll the loop to improve performance. */ 23 | for (i = 0; i + 3 < length; i += 4) { 24 | sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; 25 | sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; 26 | sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; 27 | sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; 28 | } 29 | for (; i < length; i++) { 30 | sum += (vector1[i] * vector2[i]) >> scaling; 31 | } 32 | 33 | return rtc::saturated_cast(sum); 34 | } 35 | -------------------------------------------------------------------------------- /common_audio/signal_processing/dot_product_with_scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 12 | #define COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 13 | 14 | #include 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | // Calculates the dot product between two (int16_t) vectors. 22 | // 23 | // Input: 24 | // - vector1 : Vector 1 25 | // - vector2 : Vector 2 26 | // - vector_length : Number of samples used in the dot product 27 | // - scaling : The number of right bit shifts to apply on each term 28 | // during calculation to avoid overflow, i.e., the 29 | // output will be in Q(-|scaling|) 30 | // 31 | // Return value : The dot product in Q(-scaling) 32 | int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 33 | const int16_t* vector2, 34 | size_t length, 35 | int scaling); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | #endif // COMMON_AUDIO_SIGNAL_PROCESSING_DOT_PRODUCT_WITH_SCALE_H_ 41 | -------------------------------------------------------------------------------- /common_audio/signal_processing/energy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_Energy(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int32_t WebRtcSpl_Energy(int16_t* vector, 21 | size_t vector_length, 22 | int* scale_factor) 23 | { 24 | int32_t en = 0; 25 | size_t i; 26 | int scaling = 27 | WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); 28 | size_t looptimes = vector_length; 29 | int16_t *vectorptr = vector; 30 | 31 | for (i = 0; i < looptimes; i++) 32 | { 33 | en += (*vectorptr * *vectorptr) >> scaling; 34 | vectorptr++; 35 | } 36 | *scale_factor = scaling; 37 | 38 | return en; 39 | } 40 | -------------------------------------------------------------------------------- /common_audio/signal_processing/filter_ar_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "stddef.h" 12 | 13 | #include "rtc_base/checks.h" 14 | #include "common_audio/signal_processing/include/signal_processing_library.h" 15 | 16 | // TODO(bjornv): Change the return type to report errors. 17 | 18 | void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, 19 | int16_t* data_out, 20 | const int16_t* __restrict coefficients, 21 | size_t coefficients_length, 22 | size_t data_length) { 23 | size_t i = 0; 24 | size_t j = 0; 25 | 26 | RTC_DCHECK_GT(data_length, 0); 27 | RTC_DCHECK_GT(coefficients_length, 1); 28 | 29 | for (i = 0; i < data_length; i++) { 30 | int64_t output = 0; 31 | int64_t sum = 0; 32 | 33 | for (j = coefficients_length - 1; j > 0; j--) { 34 | // Negative overflow is permitted here, because this is 35 | // auto-regressive filters, and the state for each batch run is 36 | // stored in the "negative" positions of the output vector. 37 | sum += coefficients[j] * data_out[(ptrdiff_t) i - (ptrdiff_t) j]; 38 | } 39 | 40 | output = coefficients[0] * data_in[i]; 41 | output -= sum; 42 | 43 | // Saturate and store the output. 44 | output = WEBRTC_SPL_SAT(134215679, output, -134217728); 45 | data_out[i] = (int16_t)((output + 2048) >> 12); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common_audio/signal_processing/filter_ma_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_FilterMAFastQ12(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | #include "rtc_base/sanitizer.h" 21 | 22 | void WebRtcSpl_FilterMAFastQ12(const int16_t* in_ptr, 23 | int16_t* out_ptr, 24 | const int16_t* B, 25 | size_t B_length, 26 | size_t length) 27 | { 28 | size_t i, j; 29 | 30 | rtc_MsanCheckInitialized(B, sizeof(B[0]), B_length); 31 | rtc_MsanCheckInitialized(in_ptr - B_length + 1, sizeof(in_ptr[0]), 32 | B_length + length - 1); 33 | 34 | for (i = 0; i < length; i++) 35 | { 36 | int32_t o = 0; 37 | 38 | for (j = 0; j < B_length; j++) 39 | { 40 | // Negative overflow is permitted here, because this is 41 | // auto-regressive filters, and the state for each batch run is 42 | // stored in the "negative" positions of the output vector. 43 | o += B[j] * in_ptr[(ptrdiff_t) i - (ptrdiff_t) j]; 44 | } 45 | 46 | // If output is higher than 32768, saturate it. Same with negative side 47 | // 2^27 = 134217728, which corresponds to 32768 in Q12 48 | 49 | // Saturate the output 50 | o = WEBRTC_SPL_SAT((int32_t)134215679, o, (int32_t)-134217728); 51 | 52 | *out_ptr++ = (int16_t)((o + (int32_t)2048) >> 12); 53 | } 54 | return; 55 | } 56 | -------------------------------------------------------------------------------- /common_audio/signal_processing/get_scaling_square.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_GetScalingSquare(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector, 21 | size_t in_vector_length, 22 | size_t times) 23 | { 24 | int16_t nbits = WebRtcSpl_GetSizeInBits((uint32_t)times); 25 | size_t i; 26 | int16_t smax = -1; 27 | int16_t sabs; 28 | int16_t *sptr = in_vector; 29 | int16_t t; 30 | size_t looptimes = in_vector_length; 31 | 32 | for (i = looptimes; i > 0; i--) 33 | { 34 | sabs = (*sptr > 0 ? *sptr++ : -*sptr++); 35 | smax = (sabs > smax ? sabs : smax); 36 | } 37 | t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 38 | 39 | if (smax == 0) 40 | { 41 | return 0; // Since norm(0) returns 0 42 | } else 43 | { 44 | return (t > nbits) ? 0 : nbits - t; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common_audio/signal_processing/lpc_to_refl_coef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_LpcToReflCoef(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | #define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50 21 | 22 | void WebRtcSpl_LpcToReflCoef(int16_t* a16, int use_order, int16_t* k16) 23 | { 24 | int m, k; 25 | int32_t tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER]; 26 | int32_t tmp_inv_denom32; 27 | int16_t tmp_inv_denom16; 28 | 29 | k16[use_order - 1] = a16[use_order] << 3; // Q12<<3 => Q15 30 | for (m = use_order - 1; m > 0; m--) 31 | { 32 | // (1 - k^2) in Q30 33 | tmp_inv_denom32 = 1073741823 - k16[m] * k16[m]; 34 | // (1 - k^2) in Q15 35 | tmp_inv_denom16 = (int16_t)(tmp_inv_denom32 >> 15); 36 | 37 | for (k = 1; k <= m; k++) 38 | { 39 | // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); 40 | 41 | // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 42 | tmp32[k] = (a16[k] << 16) - (k16[m] * a16[m - k + 1] << 1); 43 | 44 | tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 45 | } 46 | 47 | for (k = 1; k < m; k++) 48 | { 49 | a16[k] = (int16_t)(tmp32[k] >> 1); // Q13>>1 => Q12 50 | } 51 | 52 | tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191); 53 | k16[m - 1] = (int16_t)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15 54 | } 55 | return; 56 | } 57 | -------------------------------------------------------------------------------- /common_audio/signal_processing/refl_coef_to_lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_ReflCoefToLpc(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_ReflCoefToLpc(const int16_t *k, int use_order, int16_t *a) 21 | { 22 | int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; 23 | int16_t *aptr, *aptr2, *anyptr; 24 | const int16_t *kptr; 25 | int m, i; 26 | 27 | kptr = k; 28 | *a = 4096; // i.e., (Word16_MAX >> 3)+1. 29 | *any = *a; 30 | a[1] = *k >> 3; 31 | 32 | for (m = 1; m < use_order; m++) 33 | { 34 | kptr++; 35 | aptr = a; 36 | aptr++; 37 | aptr2 = &a[m]; 38 | anyptr = any; 39 | anyptr++; 40 | 41 | any[m + 1] = *kptr >> 3; 42 | for (i = 0; i < m; i++) 43 | { 44 | *anyptr = *aptr + (int16_t)((*aptr2 * *kptr) >> 15); 45 | anyptr++; 46 | aptr++; 47 | aptr2--; 48 | } 49 | 50 | aptr = a; 51 | anyptr = any; 52 | for (i = 0; i < (m + 2); i++) 53 | { 54 | *aptr = *anyptr; 55 | aptr++; 56 | anyptr++; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common_audio/signal_processing/resample_by_2_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * This header file contains some internal resampling functions. 13 | * 14 | */ 15 | 16 | #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_RESAMPLE_BY_2_INTERNAL_H_ 17 | #define COMMON_AUDIO_SIGNAL_PROCESSING_RESAMPLE_BY_2_INTERNAL_H_ 18 | 19 | #include 20 | 21 | /******************************************************************* 22 | * resample_by_2_fast.c 23 | * Functions for internal use in the other resample functions 24 | ******************************************************************/ 25 | void WebRtcSpl_DownBy2IntToShort(int32_t* in, 26 | int32_t len, 27 | int16_t* out, 28 | int32_t* state); 29 | 30 | void WebRtcSpl_DownBy2ShortToInt(const int16_t* in, 31 | int32_t len, 32 | int32_t* out, 33 | int32_t* state); 34 | 35 | void WebRtcSpl_UpBy2ShortToInt(const int16_t* in, 36 | int32_t len, 37 | int32_t* out, 38 | int32_t* state); 39 | 40 | void WebRtcSpl_UpBy2IntToInt(const int32_t* in, 41 | int32_t len, 42 | int32_t* out, 43 | int32_t* state); 44 | 45 | void WebRtcSpl_UpBy2IntToShort(const int32_t* in, 46 | int32_t len, 47 | int16_t* out, 48 | int32_t* state); 49 | 50 | void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, 51 | int32_t len, 52 | int32_t* out, 53 | int32_t* state); 54 | 55 | void WebRtcSpl_LPBy2IntToInt(const int32_t* in, 56 | int32_t len, 57 | int32_t* out, 58 | int32_t* state); 59 | 60 | #endif // COMMON_AUDIO_SIGNAL_PROCESSING_RESAMPLE_BY_2_INTERNAL_H_ 61 | -------------------------------------------------------------------------------- /common_audio/signal_processing/spl_inl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | #include "common_audio/signal_processing/include/spl_inl.h" 14 | 15 | // Table used by WebRtcSpl_CountLeadingZeros32_NotBuiltin. For each uint32_t n 16 | // that's a sequence of 0 bits followed by a sequence of 1 bits, the entry at 17 | // index (n * 0x8c0b2891) >> 26 in this table gives the number of zero bits in 18 | // n. 19 | const int8_t kWebRtcSpl_CountLeadingZeros32_Table[64] = { 20 | 32, 8, 17, -1, -1, 14, -1, -1, -1, 20, -1, -1, -1, 28, -1, 18, 21 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 26, 25, 24, 22 | 4, 11, 23, 31, 3, 7, 10, 16, 22, 30, -1, -1, 2, 6, 13, 9, 23 | -1, 15, -1, 21, -1, 29, 19, -1, -1, -1, -1, -1, 1, 27, 5, 12, 24 | }; 25 | -------------------------------------------------------------------------------- /common_audio/signal_processing/sqrt_of_one_minus_x_squared.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_SqrtOfOneMinusXSquared(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "common_audio/signal_processing/include/signal_processing_library.h" 19 | 20 | void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t *xQ15, size_t vector_length, 21 | int16_t *yQ15) 22 | { 23 | int32_t sq; 24 | size_t m; 25 | int16_t tmp; 26 | 27 | for (m = 0; m < vector_length; m++) 28 | { 29 | tmp = xQ15[m]; 30 | sq = tmp * tmp; // x^2 in Q30 31 | sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 32 | sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 33 | yQ15[m] = (int16_t)sq; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common_audio/third_party/spl_sqrt_floor/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the ../../../LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("../../../webrtc.gni") 10 | 11 | rtc_library("spl_sqrt_floor") { 12 | visibility = [ "../..:common_audio_c" ] 13 | sources = [ "spl_sqrt_floor.h" ] 14 | deps = [] 15 | if (current_cpu == "arm") { 16 | sources += [ "spl_sqrt_floor_arm.S" ] 17 | 18 | deps += [ "../../../rtc_base/system:asm_defines" ] 19 | } else if (current_cpu == "mipsel") { 20 | sources += [ "spl_sqrt_floor_mips.c" ] 21 | } else { 22 | sources += [ "spl_sqrt_floor.c" ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common_audio/third_party/spl_sqrt_floor/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Wilco Dijkstra, 1996. The following email exchange establishes the 3 | * license. 4 | * 5 | * From: Wilco Dijkstra 6 | * Date: Fri, Jun 24, 2011 at 3:20 AM 7 | * Subject: Re: sqrt routine 8 | * To: Kevin Ma 9 | * Hi Kevin, 10 | * Thanks for asking. Those routines are public domain (originally posted to 11 | * comp.sys.arm a long time ago), so you can use them freely for any purpose. 12 | * Cheers, 13 | * Wilco 14 | * 15 | * ----- Original Message ----- 16 | * From: "Kevin Ma" 17 | * To: 18 | * Sent: Thursday, June 23, 2011 11:44 PM 19 | * Subject: Fwd: sqrt routine 20 | * Hi Wilco, 21 | * I saw your sqrt routine from several web sites, including 22 | * http://www.finesse.demon.co.uk/steven/sqrt.html. 23 | * Just wonder if there's any copyright information with your Successive 24 | * approximation routines, or if I can freely use it for any purpose. 25 | * Thanks. 26 | * Kevin 27 | */ 28 | -------------------------------------------------------------------------------- /common_audio/third_party/spl_sqrt_floor/README.chromium: -------------------------------------------------------------------------------- 1 | Name: sql sqrt floor 2 | Short Name: sql_sqrt_floor 3 | URL: http://www.pertinentdetail.org/sqrt 4 | Version: 0 5 | Date: 2018-03-22 6 | License: Custom license 7 | License File: LICENSE 8 | Security Critical: yes 9 | 10 | Description: 11 | Sqrt routine, originally was posted to the USENET group comp.sys.arm on 12 | 20 Jun 1996. 13 | -------------------------------------------------------------------------------- /common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | // 14 | // WebRtcSpl_SqrtFloor(...) 15 | // 16 | // Returns the square root of the input value |value|. The precision of this 17 | // function is rounding down integer precision, i.e., sqrt(8) gives 2 as answer. 18 | // If |value| is a negative number then 0 is returned. 19 | // 20 | // Algorithm: 21 | // 22 | // An iterative 4 cylce/bit routine 23 | // 24 | // Input: 25 | // - value : Value to calculate sqrt of 26 | // 27 | // Return value : Result of the sqrt calculation 28 | // 29 | int32_t WebRtcSpl_SqrtFloor(int32_t value); 30 | -------------------------------------------------------------------------------- /libilbc.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: libilbc 5 | Description: Internet Low Bitrate Codec (iLBC) library 6 | Version: @PROJECT_VERSION@ 7 | Libs: -L${libdir} -lilbc 8 | Cflags: -I${includedir}/ 9 | -------------------------------------------------------------------------------- /make-archive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version="$1" 4 | if [ -z "$version" ]; then 5 | echo "Usage: $0 " 6 | exit 1 7 | fi 8 | 9 | GPG_SIGNING_KEY='-u 7FE6B095B582B0D4!' 10 | 11 | set -ex 12 | 13 | git clean -fxd 14 | git submodule foreach --recursive --quiet 'cd $toplevel/$sm_path; git clean -fxd' 15 | 16 | tmpdir=$(mktemp -d) 17 | out=$tmpdir/libilbc-$version 18 | mkdir $out 19 | 20 | cur=$(pwd) 21 | 22 | # We can't use git archive since we want to bundle the submodule. 23 | 24 | { 25 | git grep --cached -l '' 26 | git submodule foreach --recursive --quiet 'git ls-files --with-tree="$sha1" | sed "s#^#$path/#"' | grep -v 'testdata\|_test\.cc$' 27 | } | xargs -I{} cp --parents -a {} $out 28 | 29 | cd $tmpdir 30 | 31 | tar -cf $cur/libilbc-$version.tar libilbc-$version 32 | zstd -19 $cur/libilbc-$version.tar 33 | gzip -9 $cur/libilbc-$version.tar 34 | zip -r -9 $cur/libilbc-$version.zip libilbc-$version 35 | 36 | cd - 37 | 38 | for f in libilbc-$version.*; do 39 | gpg -ab $GPG_SIGNING_KEY $f 40 | done 41 | 42 | sha256sum libilbc-$version.* 43 | sha512sum libilbc-$version.* 44 | b2sum libilbc-$version.* 45 | 46 | rm -rf $tmpdir 47 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/abs_quant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_AbsQuant.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * predictive noise shaping encoding of scaled start state 29 | * (subrutine for WebRtcIlbcfix_StateSearch) 30 | *---------------------------------------------------------------*/ 31 | 32 | void WebRtcIlbcfix_AbsQuant( 33 | IlbcEncoder* iLBCenc_inst, 34 | /* (i) Encoder instance */ 35 | iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax 36 | and idxVec, uses state_first as 37 | input) */ 38 | int16_t* in, /* (i) vector to encode */ 39 | int16_t* weightDenum /* (i) denominator of synthesis filter */ 40 | ); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/abs_quant_loop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_AbsQuantLoop.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * predictive noise shaping encoding of scaled start state 27 | * (subrutine for WebRtcIlbcfix_StateSearch) 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_AbsQuantLoop(int16_t* syntOutIN, 31 | int16_t* in_weightedIN, 32 | int16_t* weightDenumIN, 33 | size_t* quantLenIN, 34 | int16_t* idxVecIN); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include "api/audio_codecs/audio_decoder.h" 20 | #include "rtc_base/buffer.h" 21 | #include "rtc_base/constructor_magic.h" 22 | 23 | typedef struct iLBC_decinst_t_ IlbcDecoderInstance; 24 | 25 | namespace webrtc { 26 | 27 | class AudioDecoderIlbcImpl final : public AudioDecoder { 28 | public: 29 | AudioDecoderIlbcImpl(); 30 | ~AudioDecoderIlbcImpl() override; 31 | bool HasDecodePlc() const override; 32 | size_t DecodePlc(size_t num_frames, int16_t* decoded) override; 33 | void Reset() override; 34 | std::vector ParsePayload(rtc::Buffer&& payload, 35 | uint32_t timestamp) override; 36 | int SampleRateHz() const override; 37 | size_t Channels() const override; 38 | 39 | protected: 40 | int DecodeInternal(const uint8_t* encoded, 41 | size_t encoded_len, 42 | int sample_rate_hz, 43 | int16_t* decoded, 44 | SpeechType* speech_type) override; 45 | 46 | private: 47 | IlbcDecoderInstance* dec_state_; 48 | RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderIlbcImpl); 49 | }; 50 | 51 | } // namespace webrtc 52 | #endif // MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ 53 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ 12 | #define MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include "absl/types/optional.h" 20 | #include "api/audio_codecs/audio_encoder.h" 21 | #include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" 22 | #include "api/units/time_delta.h" 23 | #include "modules/audio_coding/codecs/ilbc/ilbc.h" 24 | #include "rtc_base/constructor_magic.h" 25 | 26 | namespace webrtc { 27 | 28 | class AudioEncoderIlbcImpl final : public AudioEncoder { 29 | public: 30 | AudioEncoderIlbcImpl(const AudioEncoderIlbcConfig& config, int payload_type); 31 | ~AudioEncoderIlbcImpl() override; 32 | 33 | int SampleRateHz() const override; 34 | size_t NumChannels() const override; 35 | size_t Num10MsFramesInNextPacket() const override; 36 | size_t Max10MsFramesInAPacket() const override; 37 | int GetTargetBitrate() const override; 38 | EncodedInfo EncodeImpl(uint32_t rtp_timestamp, 39 | rtc::ArrayView audio, 40 | rtc::Buffer* encoded) override; 41 | void Reset() override; 42 | absl::optional> GetFrameLengthRange() 43 | const override; 44 | 45 | private: 46 | size_t RequiredOutputSizeBytes() const; 47 | 48 | static constexpr size_t kMaxSamplesPerPacket = 480; 49 | const int frame_size_ms_; 50 | const int payload_type_; 51 | const size_t num_10ms_frames_per_packet_; 52 | size_t num_10ms_frames_buffered_; 53 | uint32_t first_timestamp_in_buffer_; 54 | int16_t input_buffer_[kMaxSamplesPerPacket]; 55 | IlbcEncoderInstance* encoder_; 56 | RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderIlbcImpl); 57 | }; 58 | 59 | } // namespace webrtc 60 | #endif // MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ 61 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/augmented_cb_corr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_AugmentedCbCorr.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/augmented_cb_corr.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | void WebRtcIlbcfix_AugmentedCbCorr( 25 | int16_t *target, /* (i) Target vector */ 26 | int16_t *buffer, /* (i) Memory buffer */ 27 | int16_t *interpSamples, /* (i) buffer with 28 | interpolated samples */ 29 | int32_t *crossDot, /* (o) The cross correlation between 30 | the target and the Augmented 31 | vector */ 32 | size_t low, /* (i) Lag to start from (typically 33 | 20) */ 34 | size_t high, /* (i) Lag to end at (typically 39) */ 35 | int scale) /* (i) Scale factor to use for 36 | the crossDot */ 37 | { 38 | size_t lagcount; 39 | size_t ilow; 40 | int16_t *targetPtr; 41 | int32_t *crossDotPtr; 42 | int16_t *iSPtr=interpSamples; 43 | 44 | /* Calculate the correlation between the target and the 45 | interpolated codebook. The correlation is calculated in 46 | 3 sections with the interpolated part in the middle */ 47 | crossDotPtr=crossDot; 48 | for (lagcount=low; lagcount<=high; lagcount++) { 49 | 50 | ilow = lagcount - 4; 51 | 52 | /* Compute dot product for the first (lagcount-4) samples */ 53 | (*crossDotPtr) = WebRtcSpl_DotProductWithScale(target, buffer-lagcount, ilow, scale); 54 | 55 | /* Compute dot product on the interpolated samples */ 56 | (*crossDotPtr) += WebRtcSpl_DotProductWithScale(target+ilow, iSPtr, 4, scale); 57 | targetPtr = target + lagcount; 58 | iSPtr += lagcount-ilow; 59 | 60 | /* Compute dot product for the remaining samples */ 61 | (*crossDotPtr) += WebRtcSpl_DotProductWithScale(targetPtr, buffer-lagcount, SUBL-lagcount, scale); 62 | crossDotPtr++; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/augmented_cb_corr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_AugmentedCbCorr.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Calculate correlation between target and Augmented codebooks 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_AugmentedCbCorr( 30 | int16_t* target, /* (i) Target vector */ 31 | int16_t* buffer, /* (i) Memory buffer */ 32 | int16_t* interpSamples, /* (i) buffer with 33 | interpolated samples */ 34 | int32_t* crossDot, /* (o) The cross correlation between 35 | the target and the Augmented 36 | vector */ 37 | size_t low, /* (i) Lag to start from (typically 38 | 20) */ 39 | size_t high, /* (i) Lag to end at (typically 39 */ 40 | int scale); /* (i) Scale factor to use for the crossDot */ 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/bw_expand.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_BwExpand.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/bw_expand.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * lpc bandwidth expansion 25 | *---------------------------------------------------------------*/ 26 | 27 | /* The output is in the same domain as the input */ 28 | void WebRtcIlbcfix_BwExpand( 29 | int16_t *out, /* (o) the bandwidth expanded lpc coefficients */ 30 | int16_t *in, /* (i) the lpc coefficients before bandwidth 31 | expansion */ 32 | int16_t *coef, /* (i) the bandwidth expansion factor Q15 */ 33 | int16_t length /* (i) the length of lpc coefficient vectors */ 34 | ) { 35 | int i; 36 | 37 | out[0] = in[0]; 38 | for (i = 1; i < length; i++) { 39 | /* out[i] = coef[i] * in[i] with rounding. 40 | in[] and out[] are in Q12 and coef[] is in Q15 41 | */ 42 | out[i] = (int16_t)((coef[i] * in[i] + 16384) >> 15); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/bw_expand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_BwExpand.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * lpc bandwidth expansion 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_BwExpand( 30 | int16_t* out, /* (o) the bandwidth expanded lpc coefficients */ 31 | int16_t* in, /* (i) the lpc coefficients before bandwidth 32 | expansion */ 33 | int16_t* coef, /* (i) the bandwidth expansion factor Q15 */ 34 | int16_t length /* (i) the length of lpc coefficient vectors */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_construct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbConstruct.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "absl/base/attributes.h" 27 | #include "modules/audio_coding/codecs/ilbc/defines.h" 28 | 29 | /*----------------------------------------------------------------* 30 | * Construct decoded vector from codebook and gains. 31 | *---------------------------------------------------------------*/ 32 | 33 | // Returns true on success, false on failure. 34 | ABSL_MUST_USE_RESULT 35 | bool WebRtcIlbcfix_CbConstruct( 36 | int16_t* decvector, /* (o) Decoded vector */ 37 | const int16_t* index, /* (i) Codebook indices */ 38 | const int16_t* gain_index, /* (i) Gain quantization indices */ 39 | int16_t* mem, /* (i) Buffer for codevector construction */ 40 | size_t lMem, /* (i) Length of buffer */ 41 | size_t veclen /* (i) Length of vector */ 42 | ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_mem_energy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbMemEnergy.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ 21 | 22 | #include 23 | #include 24 | 25 | void WebRtcIlbcfix_CbMemEnergy( 26 | size_t range, 27 | int16_t* CB, /* (i) The CB memory (1:st section) */ 28 | int16_t* filteredCB, /* (i) The filtered CB memory (2:nd section) */ 29 | size_t lMem, /* (i) Length of the CB memory */ 30 | size_t lTarget, /* (i) Length of the target vector */ 31 | int16_t* energyW16, /* (o) Energy in the CB vectors */ 32 | int16_t* energyShifts, /* (o) Shift value of the energy */ 33 | int scale, /* (i) The scaling of all energy values */ 34 | size_t base_size /* (i) Index to where energy values should be stored */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbMemEnergyAugmentation.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ 21 | 22 | #include 23 | #include 24 | 25 | void WebRtcIlbcfix_CbMemEnergyAugmentation( 26 | int16_t* interpSamples, /* (i) The interpolated samples */ 27 | int16_t* CBmem, /* (i) The CB memory */ 28 | int scale, /* (i) The scaling of all energy values */ 29 | size_t base_size, /* (i) Index to where energy values should be stored */ 30 | int16_t* energyW16, /* (o) Energy in the CB vectors */ 31 | int16_t* energyShifts /* (o) Shift value of the energy */ 32 | ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbMemEnergyCalc.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /* Compute the energy of the rest of the cb memory 24 | * by step wise adding and subtracting the next 25 | * sample and the last sample respectively */ 26 | void WebRtcIlbcfix_CbMemEnergyCalc( 27 | int32_t energy, /* (i) input start energy */ 28 | size_t range, /* (i) number of iterations */ 29 | int16_t *ppi, /* (i) input pointer 1 */ 30 | int16_t *ppo, /* (i) input pointer 2 */ 31 | int16_t *energyW16, /* (o) Energy in the CB vectors */ 32 | int16_t *energyShifts, /* (o) Shift value of the energy */ 33 | int scale, /* (i) The scaling of all energy values */ 34 | size_t base_size /* (i) Index to where energy values should be stored */ 35 | ) 36 | { 37 | size_t j; 38 | int16_t shft; 39 | int32_t tmp; 40 | int16_t *eSh_ptr; 41 | int16_t *eW16_ptr; 42 | 43 | 44 | eSh_ptr = &energyShifts[1+base_size]; 45 | eW16_ptr = &energyW16[1+base_size]; 46 | 47 | for (j = 0; j + 1 < range; j++) { 48 | 49 | /* Calculate next energy by a +/- 50 | operation on the edge samples */ 51 | tmp = (*ppi) * (*ppi) - (*ppo) * (*ppo); 52 | energy += tmp >> scale; 53 | energy = WEBRTC_SPL_MAX(energy, 0); 54 | 55 | ppi--; 56 | ppo--; 57 | 58 | /* Normalize the energy into a int16_t and store 59 | the number of shifts */ 60 | 61 | shft = (int16_t)WebRtcSpl_NormW32(energy); 62 | *eSh_ptr++ = shft; 63 | 64 | tmp = energy << shft; 65 | *eW16_ptr++ = (int16_t)(tmp >> 16); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbMemEnergyCalc.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ 21 | 22 | #include 23 | #include 24 | 25 | void WebRtcIlbcfix_CbMemEnergyCalc( 26 | int32_t energy, /* (i) input start energy */ 27 | size_t range, /* (i) number of iterations */ 28 | int16_t* ppi, /* (i) input pointer 1 */ 29 | int16_t* ppo, /* (i) input pointer 2 */ 30 | int16_t* energyW16, /* (o) Energy in the CB vectors */ 31 | int16_t* energyShifts, /* (o) Shift value of the energy */ 32 | int scale, /* (i) The scaling of all energy values */ 33 | size_t base_size /* (i) Index to where energy values should be stored */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbSearch.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | void WebRtcIlbcfix_CbSearch( 28 | IlbcEncoder* iLBCenc_inst, 29 | /* (i) the encoder state structure */ 30 | int16_t* index, /* (o) Codebook indices */ 31 | int16_t* gain_index, /* (o) Gain quantization indices */ 32 | int16_t* intarget, /* (i) Target vector for encoding */ 33 | int16_t* decResidual, /* (i) Decoded residual for codebook construction */ 34 | size_t lMem, /* (i) Length of buffer */ 35 | size_t lTarget, /* (i) Length of vector */ 36 | int16_t* weightDenum, /* (i) weighting filter coefficients in Q12 */ 37 | size_t block /* (i) the subblock number */ 38 | ); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_search_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbSearchCore.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ 21 | 22 | #include 23 | #include 24 | 25 | void WebRtcIlbcfix_CbSearchCore( 26 | int32_t* cDot, /* (i) Cross Correlation */ 27 | size_t range, /* (i) Search range */ 28 | int16_t stage, /* (i) Stage of this search */ 29 | int16_t* inverseEnergy, /* (i) Inversed energy */ 30 | int16_t* inverseEnergyShift, /* (i) Shifts of inversed energy 31 | with the offset 2*16-29 */ 32 | int32_t* Crit, /* (o) The criteria */ 33 | size_t* bestIndex, /* (o) Index that corresponds to 34 | maximum criteria (in this 35 | vector) */ 36 | int32_t* bestCrit, /* (o) Value of critera for the 37 | chosen index */ 38 | int16_t* bestCritSh); /* (o) The domain of the chosen 39 | criteria */ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/cb_update_best_index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CbUpdateBestIndex.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ 21 | 22 | #include 23 | #include 24 | 25 | void WebRtcIlbcfix_CbUpdateBestIndex( 26 | int32_t CritNew, /* (i) New Potentially best Criteria */ 27 | int16_t CritNewSh, /* (i) Shift value of above Criteria */ 28 | size_t IndexNew, /* (i) Index of new Criteria */ 29 | int32_t cDotNew, /* (i) Cross dot of new index */ 30 | int16_t invEnergyNew, /* (i) Inversed energy new index */ 31 | int16_t energyShiftNew, /* (i) Energy shifts of new index */ 32 | int32_t* CritMax, /* (i/o) Maximum Criteria (so far) */ 33 | int16_t* shTotMax, /* (i/o) Shifts of maximum criteria */ 34 | size_t* bestIndex, /* (i/o) Index that corresponds to 35 | maximum criteria */ 36 | int16_t* bestGain); /* (i/o) Gain in Q14 that corresponds 37 | to maximum criteria */ 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/chebyshev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Chebyshev.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*------------------------------------------------------------------* 26 | * Calculate the Chevyshev polynomial series 27 | * F(w) = 2*exp(-j5w)*C(x) 28 | * C(x) = (T_0(x) + f(1)T_1(x) + ... + f(4)T_1(x) + f(5)/2) 29 | * T_i(x) is the i:th order Chebyshev polynomial 30 | *------------------------------------------------------------------*/ 31 | 32 | int16_t WebRtcIlbcfix_Chebyshev( 33 | /* (o) Result of C(x) */ 34 | int16_t x, /* (i) Value to the Chevyshev polynomial */ 35 | int16_t* f /* (i) The coefficients in the polynomial */ 36 | ); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/comp_corr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CompCorr.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/comp_corr.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * Compute cross correlation and pitch gain for pitch prediction 25 | * of last subframe at given lag. 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_CompCorr( 29 | int32_t *corr, /* (o) cross correlation */ 30 | int32_t *ener, /* (o) energy */ 31 | int16_t *buffer, /* (i) signal buffer */ 32 | size_t lag, /* (i) pitch lag */ 33 | size_t bLen, /* (i) length of buffer */ 34 | size_t sRange, /* (i) correlation search length */ 35 | int16_t scale /* (i) number of rightshifts to use */ 36 | ){ 37 | int16_t *w16ptr; 38 | 39 | w16ptr=&buffer[bLen-sRange-lag]; 40 | 41 | /* Calculate correlation and energy */ 42 | (*corr)=WebRtcSpl_DotProductWithScale(&buffer[bLen-sRange], w16ptr, sRange, scale); 43 | (*ener)=WebRtcSpl_DotProductWithScale(w16ptr, w16ptr, sRange, scale); 44 | 45 | /* For zero energy set the energy to 0 in order to avoid potential 46 | problems for coming divisions */ 47 | if (*ener == 0) { 48 | *corr = 0; 49 | *ener = 1; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/comp_corr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CompCorr.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Compute cross correlation and pitch gain for pitch prediction 27 | * of last subframe at given lag. 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_CompCorr(int32_t* corr, /* (o) cross correlation */ 31 | int32_t* ener, /* (o) energy */ 32 | int16_t* buffer, /* (i) signal buffer */ 33 | size_t lag, /* (i) pitch lag */ 34 | size_t bLen, /* (i) length of buffer */ 35 | size_t sRange, /* (i) correlation search length */ 36 | int16_t scale /* (i) number of rightshifts to use */ 37 | ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/complexityMeasures.m: -------------------------------------------------------------------------------- 1 | % % Copyright(c) 2011 The WebRTC project authors.All Rights Reserved.% 2 | % Use of this source code is governed by a BSD 3 | - 4 | style license % that can be found in the LICENSE file in the root of the source 5 | % tree.An additional intellectual property rights grant can be found 6 | % in the file PATENTS.All contributing project authors may 7 | % be found in the AUTHORS file in the root of the source tree.% 8 | 9 | clear; 10 | pack; 11 | % 12 | % Enter the path to YOUR executable and remember to define the perprocessor 13 | % variable PRINT_MIPS te get the instructions printed to the screen. 14 | % 15 | command = '!iLBCtest.exe 30 speechAndBGnoise.pcm out1.bit out1.pcm tlm10_30ms.dat'; 16 | cout=' > st.txt'; %saves to matlab variable 'st' 17 | eval(strcat(command,cout)); 18 | if(length(cout)>3) 19 | load st.txt 20 | else 21 | disp('No cout file to load') 22 | end 23 | 24 | % initialize vector to zero 25 | index = find(st(1:end,1)==-1); 26 | indexnonzero = find(st(1:end,1)>0); 27 | frames = length(index)-indexnonzero(1)+1; 28 | start = indexnonzero(1) - 1; 29 | functionOrder=max(st(:,2)); 30 | new=zeros(frames,functionOrder); 31 | 32 | for i = 1:frames, 33 | for j = index(start-1+i)+1:(index(start+i)-1), 34 | new(i,st(j,2)) = new(i,st(j,2)) + st(j,1); 35 | end 36 | end 37 | 38 | result=zeros(functionOrder,3); 39 | for i=1:functionOrder 40 | nonzeroelements = find(new(1:end,i)>0); 41 | result(i,1)=i; 42 | 43 | % Compute each function's mean complexity 44 | % result(i,2)=(sum(new(nonzeroelements,i))/(length(nonzeroelements)*0.03))/1000000; 45 | 46 | % Compute each function's maximum complexity in encoding 47 | % and decoding respectively and then add it together: 48 | % result(i,3)=(max(new(1:end,i))/0.03)/1000000; 49 | result(i,3)=(max(new(1:size(new,1)/2,i))/0.03)/1000000 + (max(new(size(new,1)/2+1:end,i))/0.03)/1000000; 50 | end 51 | 52 | result 53 | 54 | % Compute maximum complexity for a single frame (enc/dec separately and together) 55 | maxEncComplexityInAFrame = (max(sum(new(1:size(new,1)/2,:),2))/0.03)/1000000 56 | maxDecComplexityInAFrame = (max(sum(new(size(new,1)/2+1:end,:),2))/0.03)/1000000 57 | totalComplexity = maxEncComplexityInAFrame + maxDecComplexityInAFrame 58 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/create_augmented_vec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_CreateAugmentedVec.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Recreate a specific codebook vector from the augmented part. 27 | * 28 | *----------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_CreateAugmentedVec( 31 | size_t index, /* (i) Index for the augmented vector to be 32 | created */ 33 | const int16_t* buffer, /* (i) Pointer to the end of the codebook memory 34 | that is used for creation of the augmented 35 | codebook */ 36 | int16_t* cbVec); /* (o) The construced codebook vector */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Decode.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ 21 | 22 | #include 23 | 24 | #include "absl/base/attributes.h" 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | #include "ilbc_export.h" 28 | 29 | /*----------------------------------------------------------------* 30 | * main decoder function 31 | *---------------------------------------------------------------*/ 32 | 33 | // Returns 0 on success, -1 on error. 34 | ILBC_EXPORT 35 | ABSL_MUST_USE_RESULT 36 | int WebRtcIlbcfix_DecodeImpl( 37 | int16_t* decblock, /* (o) decoded signal block */ 38 | const uint16_t* bytes, /* (i) encoded signal bits */ 39 | IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state 40 | structure */ 41 | int16_t mode /* (i) 0: bad packet, PLC, 42 | 1: normal */ 43 | ); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/decode_residual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_DecodeResidual.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "absl/base/attributes.h" 27 | #include "modules/audio_coding/codecs/ilbc/defines.h" 28 | 29 | /*----------------------------------------------------------------* 30 | * frame residual decoder function (subrutine to iLBC_decode) 31 | *---------------------------------------------------------------*/ 32 | 33 | // Returns true on success, false on failure. In case of failure, the decoder 34 | // state may be corrupted and needs resetting. 35 | ABSL_MUST_USE_RESULT 36 | bool WebRtcIlbcfix_DecodeResidual( 37 | IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state structure */ 38 | iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits, which are used 39 | for the decoding */ 40 | int16_t* decresidual, /* (o) decoded residual frame */ 41 | int16_t* syntdenum /* (i) the decoded synthesis filter 42 | coefficients */ 43 | ); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_DecoderInterpolateLsp.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * obtain synthesis and weighting filters form lsf coefficients 29 | *---------------------------------------------------------------*/ 30 | 31 | void WebRtcIlbcfix_DecoderInterpolateLsp( 32 | int16_t* syntdenum, /* (o) synthesis filter coefficients */ 33 | int16_t* weightdenum, /* (o) weighting denumerator 34 | coefficients */ 35 | int16_t* lsfdeq, /* (i) dequantized lsf coefficients */ 36 | int16_t length, /* (i) length of lsf coefficient vector */ 37 | IlbcDecoder* iLBCdec_inst 38 | /* (i) the decoder state structure */ 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/do_plc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_DoThePlc.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * Packet loss concealment routine. Conceals a residual signal 29 | * and LP parameters. If no packet loss, update state. 30 | *---------------------------------------------------------------*/ 31 | 32 | void WebRtcIlbcfix_DoThePlc( 33 | int16_t* PLCresidual, /* (o) concealed residual */ 34 | int16_t* PLClpc, /* (o) concealed LP parameters */ 35 | int16_t PLI, /* (i) packet loss indicator 36 | 0 - no PL, 1 = PL */ 37 | int16_t* decresidual, /* (i) decoded residual */ 38 | int16_t* lpc, /* (i) decoded LPC (only used for no PL) */ 39 | size_t inlag, /* (i) pitch lag */ 40 | IlbcDecoder* iLBCdec_inst 41 | /* (i/o) decoder instance */ 42 | ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Encode.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | #include "ilbc_export.h" 28 | 29 | /*----------------------------------------------------------------* 30 | * main encoder function 31 | *---------------------------------------------------------------*/ 32 | 33 | ILBC_EXPORT 34 | void WebRtcIlbcfix_EncodeImpl( 35 | uint16_t* bytes, /* (o) encoded data bits iLBC */ 36 | const int16_t* block, /* (i) speech vector to encode */ 37 | IlbcEncoder* iLBCenc_inst /* (i/o) the general encoder 38 | state */ 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/energy_inverse.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_EnergyInverse.c 16 | 17 | ******************************************************************/ 18 | 19 | /* Inverses the in vector in into Q29 domain */ 20 | 21 | #include "modules/audio_coding/codecs/ilbc/energy_inverse.h" 22 | 23 | void WebRtcIlbcfix_EnergyInverse( 24 | int16_t *energy, /* (i/o) Energy and inverse 25 | energy (in Q29) */ 26 | size_t noOfEnergies) /* (i) The length of the energy 27 | vector */ 28 | { 29 | int32_t Nom=(int32_t)0x1FFFFFFF; 30 | int16_t *energyPtr; 31 | size_t i; 32 | 33 | /* Set the minimum energy value to 16384 to avoid overflow */ 34 | energyPtr=energy; 35 | for (i=0; i 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /* Inverses the in vector in into Q29 domain */ 28 | 29 | void WebRtcIlbcfix_EnergyInverse( 30 | int16_t* 31 | energy, /* (i/o) Energy and inverse 32 | energy (in Q29) */ 33 | size_t noOfEnergies); /* (i) The length of the energy 34 | vector */ 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/enh_upsample.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_EnhUpsample.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENH_UPSAMPLE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENH_UPSAMPLE_H_ 21 | 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * upsample finite array assuming zeros outside bounds 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_EnhUpsample( 29 | int32_t* useq1, /* (o) upsampled output sequence */ 30 | int16_t* seq1 /* (i) unupsampled sequence */ 31 | ); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/enhancer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Enhancer.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/enhancer.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | #include "modules/audio_coding/codecs/ilbc/get_sync_seq.h" 24 | #include "modules/audio_coding/codecs/ilbc/smooth.h" 25 | 26 | /*----------------------------------------------------------------* 27 | * perform enhancement on idata+centerStartPos through 28 | * idata+centerStartPos+ENH_BLOCKL-1 29 | *---------------------------------------------------------------*/ 30 | 31 | void WebRtcIlbcfix_Enhancer( 32 | int16_t *odata, /* (o) smoothed block, dimension blockl */ 33 | int16_t *idata, /* (i) data buffer used for enhancing */ 34 | size_t idatal, /* (i) dimension idata */ 35 | size_t centerStartPos, /* (i) first sample current block within idata */ 36 | size_t *period, /* (i) pitch period array (pitch bward-in time) */ 37 | const size_t *plocs, /* (i) locations where period array values valid */ 38 | size_t periodl /* (i) dimension of period and plocs */ 39 | ){ 40 | /* Stack based */ 41 | int16_t surround[ENH_BLOCKL]; 42 | 43 | WebRtcSpl_MemSetW16(surround, 0, ENH_BLOCKL); 44 | 45 | /* get said second sequence of segments */ 46 | 47 | WebRtcIlbcfix_GetSyncSeq(idata, idatal, centerStartPos, period, plocs, 48 | periodl, ENH_HL, surround); 49 | 50 | /* compute the smoothed output from said second sequence */ 51 | 52 | WebRtcIlbcfix_Smooth(odata, idata + centerStartPos, surround); 53 | } 54 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/enhancer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Enhancer.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * perform enhancement on idata+centerStartPos through 27 | * idata+centerStartPos+ENH_BLOCKL-1 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_Enhancer( 31 | int16_t* odata, /* (o) smoothed block, dimension blockl */ 32 | int16_t* idata, /* (i) data buffer used for enhancing */ 33 | size_t idatal, /* (i) dimension idata */ 34 | size_t centerStartPos, /* (i) first sample current block within idata */ 35 | size_t* period, /* (i) pitch period array (pitch bward-in time) */ 36 | const size_t* plocs, /* (i) locations where period array values valid */ 37 | size_t periodl /* (i) dimension of period and plocs */ 38 | ); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/enhancer_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_EnhancerInterface.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_INTERFACE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_INTERFACE_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * interface for enhancer 29 | *---------------------------------------------------------------*/ 30 | 31 | size_t // (o) Estimated lag in end of in[] 32 | WebRtcIlbcfix_EnhancerInterface(int16_t* out, // (o) enhanced signal 33 | const int16_t* in, // (i) unenhanced signal 34 | IlbcDecoder* iLBCdec_inst); // (i) buffers etc 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_FilteredCbVecs.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * Construct an additional codebook vector by filtering the 26 | * initial codebook buffer. This vector is then used to expand 27 | * the codebook with an additional section. 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_FilteredCbVecs( 31 | int16_t *cbvectors, /* (o) Codebook vector for the higher section */ 32 | int16_t *CBmem, /* (i) Codebook memory that is filtered to create a 33 | second CB section */ 34 | size_t lMem, /* (i) Length of codebook memory */ 35 | size_t samples /* (i) Number of samples to filter */ 36 | ) { 37 | 38 | /* Set up the memory, start with zero state */ 39 | WebRtcSpl_MemSetW16(CBmem+lMem, 0, CB_HALFFILTERLEN); 40 | WebRtcSpl_MemSetW16(CBmem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN); 41 | WebRtcSpl_MemSetW16(cbvectors, 0, lMem-samples); 42 | 43 | /* Filter to obtain the filtered CB memory */ 44 | 45 | WebRtcSpl_FilterMAFastQ12( 46 | CBmem+CB_HALFFILTERLEN+lMem-samples, cbvectors+lMem-samples, 47 | (int16_t*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, samples); 48 | 49 | return; 50 | } 51 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_FilteredCbVecs.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Construct an additional codebook vector by filtering the 27 | * initial codebook buffer. This vector is then used to expand 28 | * the codebook with an additional section. 29 | *---------------------------------------------------------------*/ 30 | 31 | void WebRtcIlbcfix_FilteredCbVecs( 32 | int16_t* cbvectors, /* (o) Codebook vector for the higher section */ 33 | int16_t* CBmem, /* (i) Codebook memory that is filtered to create a 34 | second CB section */ 35 | size_t lMem, /* (i) Length of codebook memory */ 36 | size_t samples /* (i) Number of samples to filter */ 37 | ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/frame_classify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_FrameClassify.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | size_t WebRtcIlbcfix_FrameClassify( 28 | /* (o) Index to the max-energy sub frame */ 29 | IlbcEncoder* iLBCenc_inst, 30 | /* (i/o) the encoder state structure */ 31 | int16_t* residualFIX /* (i) lpc residual signal */ 32 | ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/gain_dequant.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GainDequant.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/gain_dequant.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * decoder for quantized gains in the gain-shape coding of 26 | * residual 27 | *---------------------------------------------------------------*/ 28 | 29 | int16_t WebRtcIlbcfix_GainDequant( 30 | /* (o) quantized gain value (Q14) */ 31 | int16_t index, /* (i) quantization index */ 32 | int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ 33 | int16_t stage /* (i) The stage of the search */ 34 | ){ 35 | int16_t scale; 36 | const int16_t *gain; 37 | 38 | /* obtain correct scale factor */ 39 | 40 | scale=WEBRTC_SPL_ABS_W16(maxIn); 41 | scale = WEBRTC_SPL_MAX(1638, scale); /* if lower than 0.1, set it to 0.1 */ 42 | 43 | /* select the quantization table and return the decoded value */ 44 | gain = WebRtcIlbcfix_kGain[stage]; 45 | 46 | return (int16_t)((scale * gain[index] + 8192) >> 14); 47 | } 48 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/gain_dequant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GainDequant.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * decoder for quantized gains in the gain-shape coding of 26 | * residual 27 | *---------------------------------------------------------------*/ 28 | 29 | int16_t WebRtcIlbcfix_GainDequant( 30 | /* (o) quantized gain value (Q14) */ 31 | int16_t index, /* (i) quantization index */ 32 | int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ 33 | int16_t stage /* (i) The stage of the search */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/gain_quant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GainQuant.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * quantizer for the gain in the gain-shape coding of residual 26 | *---------------------------------------------------------------*/ 27 | 28 | int16_t 29 | WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ 30 | int16_t gain, /* (i) gain value Q14 */ 31 | int16_t maxIn, /* (i) maximum of gain value Q14 */ 32 | int16_t stage, /* (i) The stage of the search */ 33 | int16_t* index /* (o) quantization index */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/get_cd_vec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GetCbVec.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_CD_VEC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_CD_VEC_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "absl/base/attributes.h" 27 | #include "modules/audio_coding/codecs/ilbc/defines.h" 28 | 29 | // Returns true on success, false on failure. In case of failure, the decoder 30 | // state may be corrupted and needs resetting. 31 | ABSL_MUST_USE_RESULT 32 | bool WebRtcIlbcfix_GetCbVec( 33 | int16_t* cbvec, /* (o) Constructed codebook vector */ 34 | int16_t* mem, /* (i) Codebook buffer */ 35 | size_t index, /* (i) Codebook index */ 36 | size_t lMem, /* (i) Length of codebook buffer */ 37 | size_t cbveclen /* (i) Codebook vector length */ 38 | ); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/get_lsp_poly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GetLspPoly.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * Construct the polynomials F1(z) and F2(z) from the LSP 25 | * (Computations are done in Q24) 26 | * 27 | * The expansion is performed using the following recursion: 28 | * 29 | * f[0] = 1; 30 | * tmp = -2.0 * lsp[0]; 31 | * f[1] = tmp; 32 | * for (i=2; i<=5; i++) { 33 | * b = -2.0 * lsp[2*i-2]; 34 | * f[i] = tmp*f[i-1] + 2.0*f[i-2]; 35 | * for (j=i; j>=2; j--) { 36 | * f[j] = f[j] + tmp*f[j-1] + f[j-2]; 37 | * } 38 | * f[i] = f[i] + tmp; 39 | * } 40 | *---------------------------------------------------------------*/ 41 | 42 | void WebRtcIlbcfix_GetLspPoly( 43 | int16_t *lsp, /* (i) LSP in Q15 */ 44 | int32_t *f) /* (o) polonymial in Q24 */ 45 | { 46 | int32_t tmpW32; 47 | int i, j; 48 | int16_t high, low; 49 | int16_t *lspPtr; 50 | int32_t *fPtr; 51 | 52 | lspPtr = lsp; 53 | fPtr = f; 54 | /* f[0] = 1.0 (Q24) */ 55 | (*fPtr) = (int32_t)16777216; 56 | fPtr++; 57 | 58 | (*fPtr) = WEBRTC_SPL_MUL((*lspPtr), -1024); 59 | fPtr++; 60 | lspPtr+=2; 61 | 62 | for(i=2; i<=5; i++) 63 | { 64 | (*fPtr) = fPtr[-2]; 65 | 66 | for(j=i; j>1; j--) 67 | { 68 | /* Compute f[j] = f[j] + tmp*f[j-1] + f[j-2]; */ 69 | high = (int16_t)(fPtr[-1] >> 16); 70 | low = (int16_t)((fPtr[-1] & 0xffff) >> 1); 71 | 72 | tmpW32 = 4 * high * *lspPtr + 4 * ((low * *lspPtr) >> 15); 73 | 74 | (*fPtr) += fPtr[-2]; 75 | (*fPtr) -= tmpW32; 76 | fPtr--; 77 | } 78 | *fPtr -= *lspPtr * (1 << 10); 79 | 80 | fPtr+=i; 81 | lspPtr+=2; 82 | } 83 | return; 84 | } 85 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/get_lsp_poly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GetLspPoly.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * Construct the polynomials F1(z) and F2(z) from the LSP 26 | * (Computations are done in Q24) 27 | * 28 | * The expansion is performed using the following recursion: 29 | * 30 | * f[0] = 1; 31 | * tmp = -2.0 * lsp[0]; 32 | * f[1] = tmp; 33 | * for (i=2; i<=5; i++) { 34 | * b = -2.0 * lsp[2*i-2]; 35 | * f[i] = tmp*f[i-1] + 2.0*f[i-2]; 36 | * for (j=i; j>=2; j--) { 37 | * f[j] = f[j] + tmp*f[j-1] + f[j-2]; 38 | * } 39 | * f[i] = f[i] + tmp; 40 | * } 41 | *---------------------------------------------------------------*/ 42 | 43 | void WebRtcIlbcfix_GetLspPoly(int16_t* lsp, /* (i) LSP in Q15 */ 44 | int32_t* f); /* (o) polonymial in Q24 */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/get_sync_seq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_GetSyncSeq.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * get the pitch-synchronous sample sequence 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_GetSyncSeq( 30 | int16_t* idata, /* (i) original data */ 31 | size_t idatal, /* (i) dimension of data */ 32 | size_t centerStartPos, /* (i) where current block starts */ 33 | size_t* period, /* (i) rough-pitch-period array (Q-2) */ 34 | const size_t* plocs, /* (i) where periods of period array are taken (Q-2) */ 35 | size_t periodl, /* (i) dimension period array */ 36 | size_t hl, /* (i) 2*hl+1 is the number of sequences */ 37 | int16_t* surround /* (i/o) The contribution from this sequence 38 | summed with earlier contributions */ 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/hp_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_HpInput.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ 21 | 22 | #include 23 | #include 24 | 25 | // clang-format off 26 | // Bad job here. https://bugs.llvm.org/show_bug.cgi?id=34274 27 | void WebRtcIlbcfix_HpInput( 28 | int16_t* signal, /* (i/o) signal vector */ 29 | int16_t* ba, /* (i) B- and A-coefficients (2:nd order) 30 | {b[0] b[1] b[2] -a[1] -a[2]} 31 | a[0] is assumed to be 1.0 */ 32 | int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] 33 | yhi[n-2] ylow[n-2] */ 34 | int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ 35 | size_t len); /* (i) Number of samples to filter */ 36 | // clang-format on 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/hp_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_HpOutput.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ 21 | 22 | #include 23 | #include 24 | 25 | // clang-format off 26 | // Bad job here. https://bugs.llvm.org/show_bug.cgi?id=34274 27 | void WebRtcIlbcfix_HpOutput( 28 | int16_t* signal, /* (i/o) signal vector */ 29 | int16_t* ba, /* (i) B- and A-coefficients (2:nd order) 30 | {b[0] b[1] b[2] -a[1] -a[2]} a[0] 31 | is assumed to be 1.0 */ 32 | int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] 33 | yhi[n-2] ylow[n-2] */ 34 | int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ 35 | size_t len); /* (i) Number of samples to filter */ 36 | // clang-format on 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/index_conv_dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_IndexConvDec.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/index_conv_dec.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | void WebRtcIlbcfix_IndexConvDec( 24 | int16_t *index /* (i/o) Codebook indexes */ 25 | ){ 26 | int k; 27 | 28 | for (k=4;k<6;k++) { 29 | /* Readjust the second and third codebook index for the first 40 sample 30 | so that they look the same as the first (in terms of lag) 31 | */ 32 | if ((index[k]>=44)&&(index[k]<108)) { 33 | index[k]+=64; 34 | } else if ((index[k]>=108)&&(index[k]<128)) { 35 | index[k]+=128; 36 | } else { 37 | /* ERROR */ 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/index_conv_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_IndexConvDec.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ 21 | 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | void WebRtcIlbcfix_IndexConvDec(int16_t* index /* (i/o) Codebook indexes */ 25 | ); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/index_conv_enc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | IiLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_IndexConvEnc.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/index_conv_enc.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * Convert the codebook indexes to make the search easier 25 | *---------------------------------------------------------------*/ 26 | 27 | void WebRtcIlbcfix_IndexConvEnc( 28 | int16_t *index /* (i/o) Codebook indexes */ 29 | ){ 30 | int k; 31 | 32 | for (k=4;k<6;k++) { 33 | /* Readjust the second and third codebook index so that it is 34 | packetized into 7 bits (before it was put in lag-wise the same 35 | way as for the first codebook which uses 8 bits) 36 | */ 37 | if ((index[k]>=108)&&(index[k]<172)) { 38 | index[k]-=64; 39 | } else if (index[k]>=236) { 40 | index[k]-=128; 41 | } else { 42 | /* ERROR */ 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/index_conv_enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_IndexConvEnc.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * Convert the codebook indexes to make the search easier 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_IndexConvEnc(int16_t* index /* (i/o) Codebook indexes */ 29 | ); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/init_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_InitDecode.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/ilbc/defines.h" 25 | 26 | #include "ilbc_export.h" 27 | 28 | /*----------------------------------------------------------------* 29 | * Initiation of decoder instance. 30 | *---------------------------------------------------------------*/ 31 | 32 | ILBC_EXPORT 33 | int WebRtcIlbcfix_InitDecode(/* (o) Number of decoded samples */ 34 | IlbcDecoder* 35 | iLBCdec_inst, /* (i/o) Decoder instance */ 36 | int16_t mode, /* (i) frame size mode */ 37 | int use_enhancer /* (i) 1 to use enhancer 38 | 0 to run without enhancer */ 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/init_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_InitEncode.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/ilbc/defines.h" 25 | 26 | #include "ilbc_export.h" 27 | 28 | /*----------------------------------------------------------------* 29 | * Initiation of encoder instance. 30 | *---------------------------------------------------------------*/ 31 | 32 | ILBC_EXPORT 33 | int WebRtcIlbcfix_InitEncode(/* (o) Number of bytes encoded */ 34 | IlbcEncoder* 35 | iLBCenc_inst, /* (i/o) Encoder instance */ 36 | int16_t mode /* (i) frame size mode */ 37 | ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/interpolate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Interpolate.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/interpolate.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * interpolation between vectors 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Interpolate( 29 | int16_t *out, /* (o) output vector */ 30 | int16_t *in1, /* (i) first input vector */ 31 | int16_t *in2, /* (i) second input vector */ 32 | int16_t coef, /* (i) weight coefficient in Q14 */ 33 | int16_t length) /* (i) number of sample is vectors */ 34 | { 35 | int i; 36 | int16_t invcoef; 37 | 38 | /* 39 | Performs the operation out[i] = in[i]*coef + (1-coef)*in2[i] (with rounding) 40 | */ 41 | 42 | invcoef = 16384 - coef; /* 16384 = 1.0 (Q14)*/ 43 | for (i = 0; i < length; i++) { 44 | out[i] = (int16_t)((coef * in1[i] + invcoef * in2[i] + 8192) >> 14); 45 | } 46 | 47 | return; 48 | } 49 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/interpolate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Interpolate.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * interpolation between vectors 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Interpolate( 29 | int16_t* out, /* (o) output vector */ 30 | int16_t* in1, /* (i) first input vector */ 31 | int16_t* in2, /* (i) second input vector */ 32 | int16_t coef, /* (i) weight coefficient in Q14 */ 33 | int16_t length); /* (i) number of sample is vectors */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/interpolate_samples.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_InterpolateSamples.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/interpolate_samples.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | void WebRtcIlbcfix_InterpolateSamples( 25 | int16_t *interpSamples, /* (o) The interpolated samples */ 26 | int16_t *CBmem, /* (i) The CB memory */ 27 | size_t lMem /* (i) Length of the CB memory */ 28 | ) { 29 | int16_t *ppi, *ppo, i, j, temp1, temp2; 30 | int16_t *tmpPtr; 31 | 32 | /* Calculate the 20 vectors of interpolated samples (4 samples each) 33 | that are used in the codebooks for lag 20 to 39 */ 34 | tmpPtr = interpSamples; 35 | for (j=0; j<20; j++) { 36 | temp1 = 0; 37 | temp2 = 3; 38 | ppo = CBmem+lMem-4; 39 | ppi = CBmem+lMem-j-24; 40 | for (i=0; i<4; i++) { 41 | 42 | *tmpPtr++ = (int16_t)((WebRtcIlbcfix_kAlpha[temp2] * *ppo) >> 15) + 43 | (int16_t)((WebRtcIlbcfix_kAlpha[temp1] * *ppi) >> 15); 44 | 45 | ppo++; 46 | ppi++; 47 | temp1++; 48 | temp2--; 49 | } 50 | } 51 | 52 | return; 53 | } 54 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/interpolate_samples.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_InterpolateSamples.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Construct the interpolated samples for the Augmented CB 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_InterpolateSamples( 30 | int16_t* interpSamples, /* (o) The interpolated samples */ 31 | int16_t* CBmem, /* (i) The CB memory */ 32 | size_t lMem /* (i) Length of the CB memory */ 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lpc_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LpcEncode.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * lpc encoder 29 | *---------------------------------------------------------------*/ 30 | 31 | void WebRtcIlbcfix_LpcEncode( 32 | int16_t* syntdenum, /* (i/o) synthesis filter coefficients 33 | before/after encoding */ 34 | int16_t* weightdenum, /* (i/o) weighting denumerator coefficients 35 | before/after encoding */ 36 | int16_t* lsf_index, /* (o) lsf quantization index */ 37 | int16_t* data, /* (i) Speech to do LPC analysis on */ 38 | IlbcEncoder* iLBCenc_inst 39 | /* (i/o) the encoder state structure */ 40 | ); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_check.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LsfCheck.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/lsf_check.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * check for stability of lsf coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | int WebRtcIlbcfix_LsfCheck( 29 | int16_t *lsf, /* LSF parameters */ 30 | int dim, /* dimension of LSF */ 31 | int NoAn) /* No of analysis per frame */ 32 | { 33 | int k,n,m, Nit=2, change=0,pos; 34 | const int16_t eps=319; /* 0.039 in Q13 (50 Hz)*/ 35 | const int16_t eps2=160; /* eps/2.0 in Q13;*/ 36 | const int16_t maxlsf=25723; /* 3.14; (4000 Hz)*/ 37 | const int16_t minlsf=82; /* 0.01; (0 Hz)*/ 38 | 39 | /* LSF separation check*/ 40 | for (n=0;nmaxlsf) { 65 | lsf[pos]=maxlsf; 66 | change=1; 67 | } 68 | } 69 | } 70 | } 71 | 72 | return change; 73 | } 74 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_check.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LsfCheck.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * check for stability of lsf coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | int WebRtcIlbcfix_LsfCheck(int16_t* lsf, /* LSF parameters */ 29 | int dim, /* dimension of LSF */ 30 | int NoAn); /* No of analysis per frame */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LspInterpolate2PolyDec.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | #include "modules/audio_coding/codecs/ilbc/interpolate.h" 23 | #include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" 24 | 25 | /*----------------------------------------------------------------* 26 | * interpolation of lsf coefficients for the decoder 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_LspInterpolate2PolyDec( 30 | int16_t *a, /* (o) lpc coefficients Q12 */ 31 | int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ 32 | int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ 33 | int16_t coef, /* (i) weighting coefficient to use between 34 | lsf1 and lsf2 Q14 */ 35 | int16_t length /* (i) length of coefficient vectors */ 36 | ){ 37 | int16_t lsftmp[LPC_FILTERORDER]; 38 | 39 | /* interpolate LSF */ 40 | WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); 41 | 42 | /* Compute the filter coefficients from the LSF */ 43 | WebRtcIlbcfix_Lsf2Poly(a, lsftmp); 44 | } 45 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LspInterpolate2PolyDec.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * interpolation of lsf coefficients for the decoder 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_LspInterpolate2PolyDec( 29 | int16_t* a, /* (o) lpc coefficients Q12 */ 30 | int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ 31 | int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ 32 | int16_t coef, /* (i) weighting coefficient to use between 33 | lsf1 and lsf2 Q14 */ 34 | int16_t length /* (i) length of coefficient vectors */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LsfInterpolate2PloyEnc.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | #include "modules/audio_coding/codecs/ilbc/interpolate.h" 23 | #include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" 24 | 25 | /*----------------------------------------------------------------* 26 | * lsf interpolator and conversion from lsf to a coefficients 27 | * (subrutine to SimpleInterpolateLSF) 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_LsfInterpolate2PloyEnc( 31 | int16_t *a, /* (o) lpc coefficients Q12 */ 32 | int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ 33 | int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ 34 | int16_t coef, /* (i) weighting coefficient to use between 35 | lsf1 and lsf2 Q14 */ 36 | int16_t length /* (i) length of coefficient vectors */ 37 | ) { 38 | /* Stack based */ 39 | int16_t lsftmp[LPC_FILTERORDER]; 40 | 41 | /* interpolate LSF */ 42 | WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); 43 | 44 | /* Compute the filter coefficients from the LSF */ 45 | WebRtcIlbcfix_Lsf2Poly(a, lsftmp); 46 | 47 | return; 48 | } 49 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_LsfInterpolate2PloyEnc.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * lsf interpolator and conversion from lsf to a coefficients 26 | * (subrutine to SimpleInterpolateLSF) 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_LsfInterpolate2PloyEnc( 30 | int16_t* a, /* (o) lpc coefficients Q12 */ 31 | int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ 32 | int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ 33 | int16_t coef, /* (i) weighting coefficient to use between 34 | lsf1 and lsf2 Q14 */ 35 | int16_t length /* (i) length of coefficient vectors */ 36 | ); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_to_lsp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Lsf2Lsp.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/lsf_to_lsp.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * conversion from lsf to lsp coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Lsf2Lsp( 29 | int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */ 30 | int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */ 31 | int16_t m /* (i) number of coefficients */ 32 | ) { 33 | int16_t i, k; 34 | int16_t diff; /* difference, which is used for the 35 | linear approximation (Q8) */ 36 | int16_t freq; /* normalized frequency in Q15 (0..1) */ 37 | int32_t tmpW32; 38 | 39 | for(i=0; i> 15); 42 | /* 20861: 1.0/(2.0*PI) in Q17 */ 43 | /* 44 | Upper 8 bits give the index k and 45 | Lower 8 bits give the difference, which needs 46 | to be approximated linearly 47 | */ 48 | k = freq >> 8; 49 | diff = (freq&0x00ff); 50 | 51 | /* Guard against getting outside table */ 52 | 53 | if (k>63) { 54 | k = 63; 55 | } 56 | 57 | /* Calculate linear approximation */ 58 | tmpW32 = WebRtcIlbcfix_kCosDerivative[k] * diff; 59 | lsp[i] = WebRtcIlbcfix_kCos[k] + (int16_t)(tmpW32 >> 12); 60 | } 61 | 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_to_lsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Lsf2Lsp.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * conversion from lsf to lsp coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Lsf2Lsp( 29 | int16_t* lsf, /* (i) lsf in Q13 values between 0 and pi */ 30 | int16_t* lsp, /* (o) lsp in Q15 values between -1 and 1 */ 31 | int16_t m /* (i) number of coefficients */ 32 | ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_to_poly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Lsf2Poly.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | #include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" 24 | #include "modules/audio_coding/codecs/ilbc/lsf_to_lsp.h" 25 | 26 | void WebRtcIlbcfix_Lsf2Poly( 27 | int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */ 28 | int16_t *lsf /* (i) line spectral frequencies in Q13 */ 29 | ) { 30 | int32_t f[2][6]; /* f[0][] and f[1][] corresponds to 31 | F1(z) and F2(z) respectivly */ 32 | int32_t *f1ptr, *f2ptr; 33 | int16_t *a1ptr, *a2ptr; 34 | int32_t tmpW32; 35 | int16_t lsp[10]; 36 | int i; 37 | 38 | /* Convert lsf to lsp */ 39 | WebRtcIlbcfix_Lsf2Lsp(lsf, lsp, LPC_FILTERORDER); 40 | 41 | /* Get F1(z) and F2(z) from the lsp */ 42 | f1ptr=f[0]; 43 | f2ptr=f[1]; 44 | WebRtcIlbcfix_GetLspPoly(&lsp[0],f1ptr); 45 | WebRtcIlbcfix_GetLspPoly(&lsp[1],f2ptr); 46 | 47 | /* for i = 5 down to 1 48 | Compute f1[i] += f1[i-1]; 49 | and f2[i] += f2[i-1]; 50 | */ 51 | f1ptr=&f[0][5]; 52 | f2ptr=&f[1][5]; 53 | for (i=5; i>0; i--) 54 | { 55 | (*f1ptr) += (*(f1ptr-1)); 56 | (*f2ptr) -= (*(f2ptr-1)); 57 | f1ptr--; 58 | f2ptr--; 59 | } 60 | 61 | /* Get the A(z) coefficients 62 | a[0] = 1.0 63 | for i = 1 to 5 64 | a[i] = (f1[i] + f2[i] + round)>>13; 65 | for i = 1 to 5 66 | a[11-i] = (f1[i] - f2[i] + round)>>13; 67 | */ 68 | a[0]=4096; 69 | a1ptr=&a[1]; 70 | a2ptr=&a[10]; 71 | f1ptr=&f[0][1]; 72 | f2ptr=&f[1][1]; 73 | for (i=5; i>0; i--) 74 | { 75 | tmpW32 = (*f1ptr) + (*f2ptr); 76 | *a1ptr = (int16_t)((tmpW32 + 4096) >> 13); 77 | 78 | tmpW32 = (*f1ptr) - (*f2ptr); 79 | *a2ptr = (int16_t)((tmpW32 + 4096) >> 13); 80 | 81 | a1ptr++; 82 | a2ptr--; 83 | f1ptr++; 84 | f2ptr++; 85 | } 86 | 87 | return; 88 | } 89 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsf_to_poly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Lsf2Poly.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * Convert from LSF coefficients to A coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Lsf2Poly( 29 | int16_t* a, /* (o) predictor coefficients (order = 10) in Q12 */ 30 | int16_t* lsf /* (i) line spectral frequencies in Q13 */ 31 | ); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/lsp_to_lsf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Lsp2Lsf.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * conversion from LSP coefficients to LSF coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Lsp2Lsf( 29 | int16_t* lsp, /* (i) lsp vector -1...+1 in Q15 */ 30 | int16_t* lsf, /* (o) Lsf vector 0...Pi in Q13 31 | (ordered, so that lsf[i] 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * compute cross correlation between sequences 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_MyCorr(int32_t* corr, /* (o) correlation of seq1 and seq2 */ 30 | const int16_t* seq1, /* (i) first sequence */ 31 | size_t dim1, /* (i) dimension first seq1 */ 32 | const int16_t* seq2, /* (i) second sequence */ 33 | size_t dim2 /* (i) dimension seq2 */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/nearest_neighbor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_NearestNeighbor.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/nearest_neighbor.h" 20 | 21 | void WebRtcIlbcfix_NearestNeighbor(size_t* index, 22 | const size_t* array, 23 | size_t value, 24 | size_t arlength) { 25 | size_t i; 26 | size_t min_diff = (size_t)-1; 27 | for (i = 0; i < arlength; i++) { 28 | const size_t diff = 29 | (array[i] < value) ? (value - array[i]) : (array[i] - value); 30 | if (diff < min_diff) { 31 | *index = i; 32 | min_diff = diff; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/nearest_neighbor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_NearestNeighbor.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Find index in array such that the array element with said 27 | * index is the element of said array closest to "value" 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_NearestNeighbor( 31 | size_t* index, /* (o) index of array element closest to value */ 32 | const size_t* array, /* (i) data array (Q2) */ 33 | size_t value, /* (i) value (Q2) */ 34 | size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/pack_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_PackBits.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ 21 | 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * unpacking of bits from bitstream, i.e., vector of bytes 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_PackBits( 29 | uint16_t* bitstream, /* (o) The packetized bitstream */ 30 | iLBC_bits* enc_bits, /* (i) Encoded bits */ 31 | int16_t mode /* (i) Codec mode (20 or 30) */ 32 | ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/poly_to_lsf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Poly2Lsf.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/poly_to_lsf.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/lsp_to_lsf.h" 23 | #include "modules/audio_coding/codecs/ilbc/poly_to_lsp.h" 24 | 25 | void WebRtcIlbcfix_Poly2Lsf( 26 | int16_t *lsf, /* (o) lsf coefficients (Q13) */ 27 | int16_t *a /* (i) A coefficients (Q12) */ 28 | ) { 29 | int16_t lsp[10]; 30 | WebRtcIlbcfix_Poly2Lsp(a, lsp, (int16_t*)WebRtcIlbcfix_kLspMean); 31 | WebRtcIlbcfix_Lsp2Lsf(lsp, lsf, 10); 32 | } 33 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/poly_to_lsf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Poly2Lsf.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * conversion from lpc coefficients to lsf coefficients 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Poly2Lsf(int16_t* lsf, /* (o) lsf coefficients (Q13) */ 29 | int16_t* a /* (i) A coefficients (Q12) */ 30 | ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/poly_to_lsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Poly2Lsp.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * conversion from lpc coefficients to lsp coefficients 26 | * function is only for 10:th order LPC 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_Poly2Lsp( 30 | int16_t* a, /* (o) A coefficients in Q12 */ 31 | int16_t* lsp, /* (i) LSP coefficients in Q15 */ 32 | int16_t* old_lsp /* (i) old LSP coefficients that are used if the new 33 | coefficients turn out to be unstable */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/refiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Refiner.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * find segment starting near idata+estSegPos that has highest 27 | * correlation with idata+centerStartPos through 28 | * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a 29 | * resolution of ENH_UPSO times the original of the original 30 | * sampling rate 31 | *---------------------------------------------------------------*/ 32 | 33 | void WebRtcIlbcfix_Refiner( 34 | size_t* updStartPos, /* (o) updated start point (Q-2) */ 35 | int16_t* idata, /* (i) original data buffer */ 36 | size_t idatal, /* (i) dimension of idata */ 37 | size_t centerStartPos, /* (i) beginning center segment */ 38 | size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ 39 | int16_t* surround, /* (i/o) The contribution from this sequence 40 | summed with earlier contributions */ 41 | int16_t gain /* (i) Gain to use for this sequence */ 42 | ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleInterpolateLsf.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/ilbc/defines.h" 25 | 26 | /*----------------------------------------------------------------* 27 | * lsf interpolator (subrutine to LPCencode) 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_SimpleInterpolateLsf( 31 | int16_t* syntdenum, /* (o) the synthesis filter denominator 32 | resulting from the quantized 33 | interpolated lsf Q12 */ 34 | int16_t* weightdenum, /* (o) the weighting filter denominator 35 | resulting from the unquantized 36 | interpolated lsf Q12 */ 37 | int16_t* lsf, /* (i) the unquantized lsf coefficients Q13 */ 38 | int16_t* lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ 39 | int16_t* lsfold, /* (i) the unquantized lsf coefficients of 40 | the previous signal frame Q13 */ 41 | int16_t* lsfdeqold, /* (i) the dequantized lsf coefficients of the 42 | previous signal frame Q13 */ 43 | int16_t length, /* (i) should equate FILTERORDER */ 44 | IlbcEncoder* iLBCenc_inst 45 | /* (i/o) the encoder state structure */ 46 | ); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleLpcAnalysis.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/ilbc/defines.h" 25 | 26 | /*----------------------------------------------------------------* 27 | * lpc analysis (subrutine to LPCencode) 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_SimpleLpcAnalysis( 31 | int16_t* lsf, /* (o) lsf coefficients */ 32 | int16_t* data, /* (i) new block of speech */ 33 | IlbcEncoder* iLBCenc_inst 34 | /* (i/o) the encoder state structure */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleLsfDeQ.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | 24 | /*----------------------------------------------------------------* 25 | * obtain dequantized lsf coefficients from quantization index 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_SimpleLsfDeQ( 29 | int16_t *lsfdeq, /* (o) dequantized lsf coefficients */ 30 | int16_t *index, /* (i) quantization index */ 31 | int16_t lpc_n /* (i) number of LPCs */ 32 | ){ 33 | int i, j, pos, cb_pos; 34 | 35 | /* decode first LSF */ 36 | 37 | pos = 0; 38 | cb_pos = 0; 39 | for (i = 0; i < LSF_NSPLIT; i++) { 40 | for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { 41 | lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + j + index[i] * 42 | WebRtcIlbcfix_kLsfDimCb[i]]; 43 | } 44 | pos += WebRtcIlbcfix_kLsfDimCb[i]; 45 | cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i]; 46 | } 47 | 48 | if (lpc_n>1) { 49 | /* decode last LSF */ 50 | pos = 0; 51 | cb_pos = 0; 52 | for (i = 0; i < LSF_NSPLIT; i++) { 53 | for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { 54 | lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[ 55 | cb_pos + index[LSF_NSPLIT + i] * WebRtcIlbcfix_kLsfDimCb[i] + j]; 56 | } 57 | pos += WebRtcIlbcfix_kLsfDimCb[i]; 58 | cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i]; 59 | } 60 | } 61 | return; 62 | } 63 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleLsfDeQ.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * obtain dequantized lsf coefficients from quantization index 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_SimpleLsfDeQ( 29 | int16_t* lsfdeq, /* (o) dequantized lsf coefficients */ 30 | int16_t* index, /* (i) quantization index */ 31 | int16_t lpc_n /* (i) number of LPCs */ 32 | ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_lsf_quant.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleLsfQ.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/simple_lsf_quant.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | #include "modules/audio_coding/codecs/ilbc/split_vq.h" 24 | 25 | /*----------------------------------------------------------------* 26 | * lsf quantizer (subrutine to LPCencode) 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_SimpleLsfQ( 30 | int16_t *lsfdeq, /* (o) dequantized lsf coefficients 31 | (dimension FILTERORDER) Q13 */ 32 | int16_t *index, /* (o) quantization index */ 33 | int16_t *lsf, /* (i) the lsf coefficient vector to be 34 | quantized (dimension FILTERORDER) Q13 */ 35 | int16_t lpc_n /* (i) number of lsf sets to quantize */ 36 | ){ 37 | 38 | /* Quantize first LSF with memoryless split VQ */ 39 | WebRtcIlbcfix_SplitVq( lsfdeq, index, lsf, 40 | (int16_t*)WebRtcIlbcfix_kLsfCb, (int16_t*)WebRtcIlbcfix_kLsfDimCb, (int16_t*)WebRtcIlbcfix_kLsfSizeCb); 41 | 42 | if (lpc_n==2) { 43 | /* Quantize second LSF with memoryless split VQ */ 44 | WebRtcIlbcfix_SplitVq( lsfdeq + LPC_FILTERORDER, index + LSF_NSPLIT, 45 | lsf + LPC_FILTERORDER, (int16_t*)WebRtcIlbcfix_kLsfCb, 46 | (int16_t*)WebRtcIlbcfix_kLsfDimCb, (int16_t*)WebRtcIlbcfix_kLsfSizeCb); 47 | } 48 | return; 49 | } 50 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/simple_lsf_quant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SimpleLsfQ.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * lsf quantizer (subrutine to LPCencode) 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_SimpleLsfQ( 29 | int16_t* lsfdeq, /* (o) dequantized lsf coefficients 30 | (dimension FILTERORDER) Q13 */ 31 | int16_t* index, /* (o) quantization index */ 32 | int16_t* lsf, /* (i) the lsf coefficient vector to be 33 | quantized (dimension FILTERORDER) Q13 */ 34 | int16_t lpc_n /* (i) number of lsf sets to quantize */ 35 | ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/smooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Smooth.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * find the smoothed output data 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Smooth(int16_t* odata, /* (o) smoothed output */ 29 | int16_t* current, /* (i) the un enhanced residual for 30 | this block */ 31 | int16_t* surround /* (i) The approximation from the 32 | surrounding sequences */ 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/smooth_out_data.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Smooth_odata.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/smooth_out_data.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | #include "rtc_base/sanitizer.h" 24 | 25 | // An s32 + s32 -> s32 addition that's allowed to overflow. (It's still 26 | // undefined behavior, so not a good idea; this just makes UBSan ignore the 27 | // violation, so that our old code can continue to do what it's always been 28 | // doing.) 29 | static inline int32_t RTC_NO_SANITIZE("signed-integer-overflow") 30 | OverflowingAdd_S32_S32_To_S32(int32_t a, int32_t b) { 31 | return a + b; 32 | } 33 | 34 | int32_t WebRtcIlbcfix_Smooth_odata( 35 | int16_t *odata, 36 | int16_t *psseq, 37 | int16_t *surround, 38 | int16_t C) 39 | { 40 | int i; 41 | 42 | int16_t err; 43 | int32_t errs; 44 | 45 | for(i=0;i<80;i++) { 46 | odata[i]= (int16_t)((C * surround[i] + 1024) >> 11); 47 | } 48 | 49 | errs=0; 50 | for(i=0;i<80;i++) { 51 | err = (psseq[i] - odata[i]) >> 3; 52 | errs = OverflowingAdd_S32_S32_To_S32(errs, err * err); // errs in Q-6 53 | } 54 | 55 | return errs; 56 | } 57 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/smooth_out_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Smooth_odata.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * help function to WebRtcIlbcfix_Smooth() 26 | *---------------------------------------------------------------*/ 27 | 28 | int32_t WebRtcIlbcfix_Smooth_odata(int16_t* odata, 29 | int16_t* psseq, 30 | int16_t* surround, 31 | int16_t C); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/sort_sq.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SortSq.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/sort_sq.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * scalar quantization 25 | *---------------------------------------------------------------*/ 26 | 27 | void WebRtcIlbcfix_SortSq( 28 | int16_t *xq, /* (o) the quantized value */ 29 | int16_t *index, /* (o) the quantization index */ 30 | int16_t x, /* (i) the value to quantize */ 31 | const int16_t *cb, /* (i) the quantization codebook */ 32 | int16_t cb_size /* (i) the size of the quantization codebook */ 33 | ){ 34 | int i; 35 | 36 | if (x <= cb[0]) { 37 | *index = 0; 38 | *xq = cb[0]; 39 | } else { 40 | i = 0; 41 | while ((x > cb[i]) && (i < (cb_size-1))) { 42 | i++; 43 | } 44 | 45 | if (x > (((int32_t)cb[i] + cb[i - 1] + 1) >> 1)) { 46 | *index = i; 47 | *xq = cb[i]; 48 | } else { 49 | *index = i - 1; 50 | *xq = cb[i - 1]; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/sort_sq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SortSq.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * scalar quantization 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_SortSq( 29 | int16_t* xq, /* (o) the quantized value */ 30 | int16_t* index, /* (o) the quantization index */ 31 | int16_t x, /* (i) the value to quantize */ 32 | const int16_t* cb, /* (i) the quantization codebook */ 33 | int16_t cb_size /* (i) the size of the quantization codebook */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/split_vq.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SplitVq.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/split_vq.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" 23 | #include "modules/audio_coding/codecs/ilbc/vq3.h" 24 | #include "modules/audio_coding/codecs/ilbc/vq4.h" 25 | 26 | /*----------------------------------------------------------------* 27 | * split vector quantization 28 | *---------------------------------------------------------------*/ 29 | 30 | void WebRtcIlbcfix_SplitVq( 31 | int16_t *qX, /* (o) the quantized vector in Q13 */ 32 | int16_t *index, /* (o) a vector of indexes for all vector 33 | codebooks in the split */ 34 | int16_t *X, /* (i) the vector to quantize */ 35 | int16_t *CB, /* (i) the quantizer codebook in Q13 */ 36 | int16_t *dim, /* (i) the dimension of X and qX */ 37 | int16_t *cbsize /* (i) the number of vectors in the codebook */ 38 | ) { 39 | 40 | int16_t *qXPtr, *indexPtr, *CBPtr, *XPtr; 41 | 42 | /* Quantize X with the 3 vectror quantization tables */ 43 | 44 | qXPtr=qX; 45 | indexPtr=index; 46 | CBPtr=CB; 47 | XPtr=X; 48 | WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[0]); 49 | 50 | qXPtr+=3; 51 | indexPtr+=1; 52 | CBPtr+=(dim[0]*cbsize[0]); 53 | XPtr+=3; 54 | WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[1]); 55 | 56 | qXPtr+=3; 57 | indexPtr+=1; 58 | CBPtr+=(dim[1]*cbsize[1]); 59 | XPtr+=3; 60 | WebRtcIlbcfix_Vq4(qXPtr, indexPtr, CBPtr, XPtr, cbsize[2]); 61 | 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/split_vq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SplitVq.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * split vector quantization 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_SplitVq( 29 | int16_t* qX, /* (o) the quantized vector in Q13 */ 30 | int16_t* index, /* (o) a vector of indexes for all vector 31 | codebooks in the split */ 32 | int16_t* X, /* (i) the vector to quantize */ 33 | int16_t* CB, /* (i) the quantizer codebook in Q13 */ 34 | int16_t* dim, /* (i) the dimension of X and qX */ 35 | int16_t* cbsize /* (i) the number of vectors in the codebook */ 36 | ); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/state_construct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_StateConstruct.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_CONSTRUCT_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_CONSTRUCT_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Generate the start state from the quantized indexes 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_StateConstruct( 30 | size_t idxForMax, /* (i) 6-bit index for the quantization of 31 | max amplitude */ 32 | int16_t* idxVec, /* (i) vector of quantization indexes */ 33 | int16_t* syntDenum, /* (i) synthesis filter denumerator */ 34 | int16_t* Out_fix, /* (o) the decoded state vector */ 35 | size_t len /* (i) length of a state vector */ 36 | ); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/state_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_StateSearch.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "modules/audio_coding/codecs/ilbc/defines.h" 26 | 27 | /*----------------------------------------------------------------* 28 | * encoding of start state 29 | *---------------------------------------------------------------*/ 30 | 31 | void WebRtcIlbcfix_StateSearch( 32 | IlbcEncoder* iLBCenc_inst, 33 | /* (i) Encoder instance */ 34 | iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (output idxForMax 35 | and idxVec, input state_first) */ 36 | int16_t* residual, /* (i) target residual vector */ 37 | int16_t* syntDenum, /* (i) lpc synthesis filter */ 38 | int16_t* weightDenum /* (i) weighting filter denuminator */ 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/swap_bytes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SwapBytes.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/swap_bytes.h" 20 | 21 | /*----------------------------------------------------------------* 22 | * Swap bytes (to simplify operations on Little Endian machines) 23 | *---------------------------------------------------------------*/ 24 | 25 | void WebRtcIlbcfix_SwapBytes( 26 | const uint16_t* input, /* (i) the sequence to swap */ 27 | size_t wordLength, /* (i) number or uint16_t to swap */ 28 | uint16_t* output /* (o) the swapped sequence */ 29 | ) { 30 | size_t k; 31 | for (k = wordLength; k > 0; k--) { 32 | *output++ = (*input >> 8)|(*input << 8); 33 | input++; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/swap_bytes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_SwapBytes.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * Swap bytes (to simplify operations on Little Endian machines) 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_SwapBytes( 30 | const uint16_t* input, /* (i) the sequence to swap */ 31 | size_t wordLength, /* (i) number or uint16_t to swap */ 32 | uint16_t* output /* (o) the swapped sequence */ 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/test/empty.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimothyGu/libilbc/6adb26d4a4e159cd66d4b4c5e411cd3de0ab6b5e/modules/audio_coding/codecs/ilbc/test/empty.cc -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/unpack_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_UnpackBits.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ 21 | 22 | #include 23 | 24 | #include "modules/audio_coding/codecs/ilbc/defines.h" 25 | 26 | /*----------------------------------------------------------------* 27 | * unpacking of bits from bitstream, i.e., vector of bytes 28 | *---------------------------------------------------------------*/ 29 | 30 | int16_t 31 | WebRtcIlbcfix_UnpackBits(/* (o) "Empty" frame indicator */ 32 | const uint16_t* 33 | bitstream, /* (i) The packatized bitstream */ 34 | iLBC_bits* 35 | enc_bits, /* (o) Paramerers from bitstream */ 36 | int16_t mode /* (i) Codec mode (20 or 30) */ 37 | ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/vq3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Vq3.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/vq3.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * vector quantization 25 | *---------------------------------------------------------------*/ 26 | 27 | void WebRtcIlbcfix_Vq3( 28 | int16_t *Xq, /* quantized vector (Q13) */ 29 | int16_t *index, 30 | int16_t *CB, /* codebook in Q13 */ 31 | int16_t *X, /* vector to quantize (Q13) */ 32 | int16_t n_cb 33 | ){ 34 | int16_t i, j; 35 | int16_t pos, minindex=0; 36 | int16_t tmp; 37 | int32_t dist, mindist; 38 | 39 | pos = 0; 40 | mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ 41 | 42 | /* Find the codebook with the lowest square distance */ 43 | for (j = 0; j < n_cb; j++) { 44 | tmp = X[0] - CB[pos]; 45 | dist = tmp * tmp; 46 | for (i = 1; i < 3; i++) { 47 | tmp = X[i] - CB[pos + i]; 48 | dist += tmp * tmp; 49 | } 50 | 51 | if (dist < mindist) { 52 | mindist = dist; 53 | minindex = j; 54 | } 55 | pos += 3; 56 | } 57 | 58 | /* Store the quantized codebook and the index */ 59 | for (i = 0; i < 3; i++) { 60 | Xq[i] = CB[minindex*3 + i]; 61 | } 62 | *index = minindex; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/vq3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Vq3.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * Vector quantization of order 3 (based on MSE) 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Vq3( 29 | int16_t* Xq, /* (o) the quantized vector (Q13) */ 30 | int16_t* index, /* (o) the quantization index */ 31 | int16_t* CB, /* (i) the vector quantization codebook (Q13) */ 32 | int16_t* X, /* (i) the vector to quantize (Q13) */ 33 | int16_t n_cb /* (i) the number of vectors in the codebook */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/vq4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Vq4.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/vq4.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/constants.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * vector quantization 25 | *---------------------------------------------------------------*/ 26 | 27 | void WebRtcIlbcfix_Vq4( 28 | int16_t *Xq, /* quantized vector (Q13) */ 29 | int16_t *index, 30 | int16_t *CB, /* codebook in Q13 */ 31 | int16_t *X, /* vector to quantize (Q13) */ 32 | int16_t n_cb 33 | ){ 34 | int16_t i, j; 35 | int16_t pos, minindex=0; 36 | int16_t tmp; 37 | int32_t dist, mindist; 38 | 39 | pos = 0; 40 | mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ 41 | 42 | /* Find the codebook with the lowest square distance */ 43 | for (j = 0; j < n_cb; j++) { 44 | tmp = X[0] - CB[pos]; 45 | dist = tmp * tmp; 46 | for (i = 1; i < 4; i++) { 47 | tmp = X[i] - CB[pos + i]; 48 | dist += tmp * tmp; 49 | } 50 | 51 | if (dist < mindist) { 52 | mindist = dist; 53 | minindex = j; 54 | } 55 | pos += 4; 56 | } 57 | 58 | /* Store the quantized codebook and the index */ 59 | for (i = 0; i < 4; i++) { 60 | Xq[i] = CB[minindex*4 + i]; 61 | } 62 | *index = minindex; 63 | } 64 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/vq4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Vq4.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ 21 | 22 | #include 23 | 24 | /*----------------------------------------------------------------* 25 | * Vector quantization of order 4 (based on MSE) 26 | *---------------------------------------------------------------*/ 27 | 28 | void WebRtcIlbcfix_Vq4( 29 | int16_t* Xq, /* (o) the quantized vector (Q13) */ 30 | int16_t* index, /* (o) the quantization index */ 31 | int16_t* CB, /* (i) the vector quantization codebook (Q13) */ 32 | int16_t* X, /* (i) the vector to quantize (Q13) */ 33 | int16_t n_cb /* (i) the number of vectors in the codebook */ 34 | ); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/window32_w32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Window32W32.c 16 | 17 | ******************************************************************/ 18 | 19 | #include "modules/audio_coding/codecs/ilbc/window32_w32.h" 20 | 21 | #include "modules/audio_coding/codecs/ilbc/defines.h" 22 | 23 | /*----------------------------------------------------------------* 24 | * window multiplication 25 | *---------------------------------------------------------------*/ 26 | 27 | void WebRtcIlbcfix_Window32W32( 28 | int32_t *z, /* Output */ 29 | int32_t *x, /* Input (same domain as Output)*/ 30 | const int32_t *y, /* Q31 Window */ 31 | size_t N /* length to process */ 32 | ) { 33 | size_t i; 34 | int16_t x_low, x_hi, y_low, y_hi; 35 | int16_t left_shifts; 36 | int32_t temp; 37 | 38 | left_shifts = (int16_t)WebRtcSpl_NormW32(x[0]); 39 | WebRtcSpl_VectorBitShiftW32(x, N, x, (int16_t)(-left_shifts)); 40 | 41 | 42 | /* The double precision numbers use a special representation: 43 | * w32 = hi<<16 + lo<<1 44 | */ 45 | for (i = 0; i < N; i++) { 46 | /* Extract higher bytes */ 47 | x_hi = (int16_t)(x[i] >> 16); 48 | y_hi = (int16_t)(y[i] >> 16); 49 | 50 | /* Extract lower bytes, defined as (w32 - hi<<16)>>1 */ 51 | x_low = (int16_t)((x[i] - (x_hi << 16)) >> 1); 52 | 53 | y_low = (int16_t)((y[i] - (y_hi << 16)) >> 1); 54 | 55 | /* Calculate z by a 32 bit multiplication using both low and high from x and y */ 56 | temp = ((x_hi * y_hi) << 1) + ((x_hi * y_low) >> 14); 57 | 58 | z[i] = temp + ((x_low * y_hi) >> 14); 59 | } 60 | 61 | WebRtcSpl_VectorBitShiftW32(z, N, z, left_shifts); 62 | 63 | return; 64 | } 65 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/window32_w32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_Window32W32.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * window multiplication 27 | *---------------------------------------------------------------*/ 28 | 29 | void WebRtcIlbcfix_Window32W32(int32_t* z, /* Output */ 30 | int32_t* x, /* Input (same domain as Output)*/ 31 | const int32_t* y, /* Q31 Window */ 32 | size_t N /* length to process */ 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/audio_coding/codecs/ilbc/xcorr_coef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /****************************************************************** 12 | 13 | iLBC Speech Coder ANSI-C Source Code 14 | 15 | WebRtcIlbcfix_XcorrCoef.h 16 | 17 | ******************************************************************/ 18 | 19 | #ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ 20 | #define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ 21 | 22 | #include 23 | #include 24 | 25 | /*----------------------------------------------------------------* 26 | * cross correlation which finds the optimal lag for the 27 | * crossCorr*crossCorr/(energy) criteria 28 | *---------------------------------------------------------------*/ 29 | 30 | size_t WebRtcIlbcfix_XcorrCoef( 31 | int16_t* target, /* (i) first array */ 32 | int16_t* regressor, /* (i) second array */ 33 | size_t subl, /* (i) dimension arrays */ 34 | size_t searchLen, /* (i) the search lenght */ 35 | size_t offset, /* (i) samples offset between arrays */ 36 | int16_t step /* (i) +1 or -1 */ 37 | ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /rtc_base/compile_assert_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_COMPILE_ASSERT_C_H_ 12 | #define RTC_BASE_COMPILE_ASSERT_C_H_ 13 | 14 | // Use this macro to verify at compile time that certain restrictions are met. 15 | // The argument is the boolean expression to evaluate. 16 | // Example: 17 | // RTC_COMPILE_ASSERT(sizeof(foo) < 128); 18 | // Note: In C++, use static_assert instead! 19 | #define RTC_COMPILE_ASSERT(expression) \ 20 | switch (0) { \ 21 | case 0: \ 22 | case expression:; \ 23 | } 24 | 25 | #endif // RTC_BASE_COMPILE_ASSERT_C_H_ 26 | -------------------------------------------------------------------------------- /rtc_base/system/DEPS: -------------------------------------------------------------------------------- 1 | specific_include_rules = { 2 | "thread_registry\.cc": [ 3 | "+sdk/android/native_api/stacktrace/stacktrace.h", 4 | ], 5 | "warn_current_thread_is_deadlocked\.cc": [ 6 | "+sdk/android/native_api/stacktrace/stacktrace.h", 7 | ], 8 | } 9 | -------------------------------------------------------------------------------- /rtc_base/system/asm_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_ASM_DEFINES_H_ 12 | #define RTC_BASE_SYSTEM_ASM_DEFINES_H_ 13 | 14 | // clang-format off 15 | // clang formatting breaks everything here, e.g. concatenating directives, 16 | // due to absence of context via asm keyword. 17 | 18 | #if defined(__linux__) && defined(__ELF__) 19 | .section .note.GNU-stack,"",%progbits 20 | #endif 21 | 22 | // Define the macros used in ARM assembly code, so that for Mac or iOS builds 23 | // we add leading underscores for the function names. 24 | #ifdef __APPLE__ 25 | .macro GLOBAL_FUNCTION name 26 | .global _\name 27 | .private_extern _\name 28 | .endm 29 | .macro DEFINE_FUNCTION name 30 | _\name: 31 | .endm 32 | .macro CALL_FUNCTION name 33 | bl _\name 34 | .endm 35 | .macro GLOBAL_LABEL name 36 | .global _\name 37 | .private_extern _\name 38 | .endm 39 | #else 40 | .macro GLOBAL_FUNCTION name 41 | .global \name 42 | .hidden \name 43 | .endm 44 | .macro DEFINE_FUNCTION name 45 | #if defined(__linux__) && defined(__ELF__) 46 | .type \name,%function 47 | #endif 48 | \name: 49 | .endm 50 | .macro CALL_FUNCTION name 51 | bl \name 52 | .endm 53 | .macro GLOBAL_LABEL name 54 | .global \name 55 | .hidden \name 56 | .endm 57 | #endif 58 | 59 | // With Apple's clang compiler, for instructions ldrb, strh, etc., 60 | // the condition code is after the width specifier. Here we define 61 | // only the ones that are actually used in the assembly files. 62 | #if (defined __llvm__) && (defined __APPLE__) 63 | .macro streqh reg1, reg2, num 64 | strheq \reg1, \reg2, \num 65 | .endm 66 | #endif 67 | 68 | .text 69 | 70 | // clang-format on 71 | 72 | #endif // RTC_BASE_SYSTEM_ASM_DEFINES_H_ 73 | -------------------------------------------------------------------------------- /rtc_base/system/inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_INLINE_H_ 12 | #define RTC_BASE_SYSTEM_INLINE_H_ 13 | 14 | #if defined(_MSC_VER) 15 | 16 | #define RTC_FORCE_INLINE __forceinline 17 | #define RTC_NO_INLINE __declspec(noinline) 18 | 19 | #elif defined(__GNUC__) 20 | 21 | #define RTC_FORCE_INLINE __attribute__((__always_inline__)) 22 | #define RTC_NO_INLINE __attribute__((__noinline__)) 23 | 24 | #else 25 | 26 | #define RTC_FORCE_INLINE 27 | #define RTC_NO_INLINE 28 | 29 | #endif 30 | 31 | #endif // RTC_BASE_SYSTEM_INLINE_H_ 32 | -------------------------------------------------------------------------------- /rtc_base/system/rtc_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef RTC_BASE_SYSTEM_RTC_EXPORT_H_ 12 | #define RTC_BASE_SYSTEM_RTC_EXPORT_H_ 13 | 14 | // RTC_EXPORT is used to mark symbols as exported or imported when WebRTC is 15 | // built or used as a shared library. 16 | // When WebRTC is built as a static library the RTC_EXPORT macro expands to 17 | // nothing. 18 | 19 | #ifdef WEBRTC_ENABLE_SYMBOL_EXPORT 20 | 21 | #ifdef WEBRTC_WIN 22 | 23 | #ifdef WEBRTC_LIBRARY_IMPL 24 | #define RTC_EXPORT __declspec(dllexport) 25 | #else 26 | #define RTC_EXPORT __declspec(dllimport) 27 | #endif 28 | 29 | #else // WEBRTC_WIN 30 | 31 | #if __has_attribute(visibility) && defined(WEBRTC_LIBRARY_IMPL) 32 | #define RTC_EXPORT __attribute__((visibility("default"))) 33 | #endif 34 | 35 | #endif // WEBRTC_WIN 36 | 37 | #endif // WEBRTC_ENABLE_SYMBOL_EXPORT 38 | 39 | #ifndef RTC_EXPORT 40 | #define RTC_EXPORT 41 | #endif 42 | 43 | #endif // RTC_BASE_SYSTEM_RTC_EXPORT_H_ 44 | -------------------------------------------------------------------------------- /sample.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimothyGu/libilbc/6adb26d4a4e159cd66d4b4c5e411cd3de0ab6b5e/sample.pcm --------------------------------------------------------------------------------