diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index 1995c6db04..0da1fe4fed 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -66,12 +66,6 @@ rtc_library("builtin_audio_decoder_factory") { "g722:audio_decoder_g722", ] defines = [] - if (rtc_include_ilbc) { - deps += [ "ilbc:audio_decoder_ilbc" ] - defines += [ "WEBRTC_USE_BUILTIN_ILBC=1" ] - } else { - defines += [ "WEBRTC_USE_BUILTIN_ILBC=0" ] - } if (rtc_include_opus) { deps += [ "opus:audio_decoder_multiopus", @@ -99,15 +93,6 @@ rtc_library("builtin_audio_encoder_factory") { "g722:audio_encoder_g722", ] defines = [] - if (rtc_include_ilbc) { - deps += [ - "..:field_trials_view", - "ilbc:audio_encoder_ilbc", - ] - defines += [ "WEBRTC_USE_BUILTIN_ILBC=1" ] - } else { - defines += [ "WEBRTC_USE_BUILTIN_ILBC=0" ] - } if (rtc_include_opus) { deps += [ "..:field_trials_view", diff --git a/api/audio_codecs/builtin_audio_decoder_factory.cc b/api/audio_codecs/builtin_audio_decoder_factory.cc index ce3b5348ff..643df54170 100644 --- a/api/audio_codecs/builtin_audio_decoder_factory.cc +++ b/api/audio_codecs/builtin_audio_decoder_factory.cc @@ -23,9 +23,6 @@ #include "api/audio_codecs/g711/audio_decoder_g711.h" #include "api/audio_codecs/g722/audio_decoder_g722.h" #include "api/scoped_refptr.h" -#if WEBRTC_USE_BUILTIN_ILBC -#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck -#endif #if WEBRTC_USE_BUILTIN_OPUS #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck @@ -62,11 +59,6 @@ rtc::scoped_refptr CreateBuiltinAudioDecoderFactory() { #endif AudioDecoderG722, - -#if WEBRTC_USE_BUILTIN_ILBC - AudioDecoderIlbc, -#endif - AudioDecoderG711, NotAdvertised>(); } diff --git a/api/audio_codecs/builtin_audio_encoder_factory.cc b/api/audio_codecs/builtin_audio_encoder_factory.cc index 8d9c62cb6b..50a9baae2c 100644 --- a/api/audio_codecs/builtin_audio_encoder_factory.cc +++ b/api/audio_codecs/builtin_audio_encoder_factory.cc @@ -24,9 +24,6 @@ #include "api/audio_codecs/g722/audio_encoder_g722.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" -#if WEBRTC_USE_BUILTIN_ILBC -#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" // nogncheck -#endif #if WEBRTC_USE_BUILTIN_OPUS #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" // nogncheck @@ -69,11 +66,6 @@ rtc::scoped_refptr CreateBuiltinAudioEncoderFactory() { #endif AudioEncoderG722, - -#if WEBRTC_USE_BUILTIN_ILBC - AudioEncoderIlbc, -#endif - AudioEncoderG711, NotAdvertised>(); } diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn deleted file mode 100644 index 8ab719fbc3..0000000000 --- a/api/audio_codecs/ilbc/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -import("../../../webrtc.gni") -if (is_android) { - import("//build/config/android/config.gni") - import("//build/config/android/rules.gni") -} - -rtc_source_set("audio_encoder_ilbc_config") { - visibility = [ "*" ] - sources = [ "audio_encoder_ilbc_config.h" ] -} - -rtc_library("audio_encoder_ilbc") { - visibility = [ "*" ] - poisonous = [ "audio_codecs" ] - sources = [ - "audio_encoder_ilbc.cc", - "audio_encoder_ilbc.h", - ] - deps = [ - ":audio_encoder_ilbc_config", - "..:audio_codecs_api", - "../../../api:field_trials_view", - "../../../modules/audio_coding:ilbc", - "../../../rtc_base:checks", - "../../../rtc_base:safe_conversions", - "../../../rtc_base:safe_minmax", - "../../../rtc_base:stringutils", - "//third_party/abseil-cpp/absl/strings", - ] -} - -rtc_library("audio_decoder_ilbc") { - visibility = [ "*" ] - poisonous = [ "audio_codecs" ] - sources = [ - "audio_decoder_ilbc.cc", - "audio_decoder_ilbc.h", - ] - deps = [ - "..:audio_codecs_api", - "../../../api:field_trials_view", - "../../../modules/audio_coding:ilbc", - "//third_party/abseil-cpp/absl/strings", - ] -} diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc deleted file mode 100644 index 4b1c7de21a..0000000000 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" - -#include -#include -#include - -#include "absl/strings/match.h" -#include "api/audio_codecs/audio_codec_pair_id.h" -#include "api/audio_codecs/audio_decoder.h" -#include "api/audio_codecs/audio_format.h" -#include "api/field_trials_view.h" -#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" - -namespace webrtc { - -std::optional AudioDecoderIlbc::SdpToConfig( - const SdpAudioFormat& format) { - if (absl::EqualsIgnoreCase(format.name, "ILBC") && - format.clockrate_hz == 8000 && format.num_channels == 1) { - return Config(); - } - return std::nullopt; -} - -void AudioDecoderIlbc::AppendSupportedDecoders( - std::vector* specs) { - specs->push_back({{"ILBC", 8000, 1}, {8000, 1, 13300}}); -} - -std::unique_ptr AudioDecoderIlbc::MakeAudioDecoder( - Config config, - std::optional /*codec_pair_id*/, - const FieldTrialsView* field_trials) { - return std::make_unique(); -} - -} // namespace webrtc diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/api/audio_codecs/ilbc/audio_decoder_ilbc.h deleted file mode 100644 index f1a89b9200..0000000000 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ -#define API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ - -#include -#include -#include - -#include "api/audio_codecs/audio_codec_pair_id.h" -#include "api/audio_codecs/audio_decoder.h" -#include "api/audio_codecs/audio_format.h" -#include "api/field_trials_view.h" - -namespace webrtc { - -// ILBC decoder API for use as a template parameter to -// CreateAudioDecoderFactory<...>(). -struct AudioDecoderIlbc { - struct Config {}; // Empty---no config values needed! - static std::optional SdpToConfig(const SdpAudioFormat& audio_format); - static void AppendSupportedDecoders(std::vector* specs); - static std::unique_ptr MakeAudioDecoder( - Config config, - std::optional codec_pair_id = std::nullopt, - const FieldTrialsView* field_trials = nullptr); -}; - -} // namespace webrtc - -#endif // API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc deleted file mode 100644 index 5fac14bf0e..0000000000 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" - -#include -#include -#include -#include -#include -#include - -#include "absl/strings/match.h" -#include "api/audio_codecs/audio_codec_pair_id.h" -#include "api/audio_codecs/audio_encoder.h" -#include "api/audio_codecs/audio_format.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" -#include "api/field_trials_view.h" -#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" -#include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_minmax.h" -#include "rtc_base/string_to_number.h" - -namespace webrtc { -namespace { -int GetIlbcBitrate(int ptime) { - switch (ptime) { - case 20: - case 40: - // 38 bytes per frame of 20 ms => 15200 bits/s. - return 15200; - case 30: - case 60: - // 50 bytes per frame of 30 ms => (approx) 13333 bits/s. - return 13333; - default: - RTC_CHECK_NOTREACHED(); - } -} -} // namespace - -std::optional AudioEncoderIlbc::SdpToConfig( - const SdpAudioFormat& format) { - if (!absl::EqualsIgnoreCase(format.name.c_str(), "ILBC") || - format.clockrate_hz != 8000 || format.num_channels != 1) { - return std::nullopt; - } - - AudioEncoderIlbcConfig config; - auto ptime_iter = format.parameters.find("ptime"); - if (ptime_iter != format.parameters.end()) { - auto ptime = rtc::StringToNumber(ptime_iter->second); - if (ptime && *ptime > 0) { - const int whole_packets = *ptime / 10; - config.frame_size_ms = rtc::SafeClamp(whole_packets * 10, 20, 60); - } - } - if (!config.IsOk()) { - RTC_DCHECK_NOTREACHED(); - return std::nullopt; - } - return config; -} - -void AudioEncoderIlbc::AppendSupportedEncoders( - std::vector* specs) { - const SdpAudioFormat fmt = {"ILBC", 8000, 1}; - const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt)); - specs->push_back({fmt, info}); -} - -AudioCodecInfo AudioEncoderIlbc::QueryAudioEncoder( - const AudioEncoderIlbcConfig& config) { - RTC_DCHECK(config.IsOk()); - return {8000, 1, GetIlbcBitrate(config.frame_size_ms)}; -} - -std::unique_ptr AudioEncoderIlbc::MakeAudioEncoder( - const AudioEncoderIlbcConfig& config, - int payload_type, - std::optional /*codec_pair_id*/, - const FieldTrialsView* field_trials) { - if (!config.IsOk()) { - RTC_DCHECK_NOTREACHED(); - return nullptr; - } - return std::make_unique(config, payload_type); -} - -} // namespace webrtc diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/api/audio_codecs/ilbc/audio_encoder_ilbc.h deleted file mode 100644 index 74c75fdf81..0000000000 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ -#define API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ - -#include -#include -#include - -#include "api/audio_codecs/audio_codec_pair_id.h" -#include "api/audio_codecs/audio_encoder.h" -#include "api/audio_codecs/audio_format.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" -#include "api/field_trials_view.h" - -namespace webrtc { - -// ILBC encoder API for use as a template parameter to -// CreateAudioEncoderFactory<...>(). -struct AudioEncoderIlbc { - using Config = AudioEncoderIlbcConfig; - static std::optional SdpToConfig( - const SdpAudioFormat& audio_format); - static void AppendSupportedEncoders(std::vector* specs); - static AudioCodecInfo QueryAudioEncoder(const AudioEncoderIlbcConfig& config); - static std::unique_ptr MakeAudioEncoder( - const AudioEncoderIlbcConfig& config, - int payload_type, - std::optional codec_pair_id = std::nullopt, - const FieldTrialsView* field_trials = nullptr); -}; - -} // namespace webrtc - -#endif // API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h b/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h deleted file mode 100644 index 4d82f9901c..0000000000 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_ -#define API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_ - -namespace webrtc { - -struct AudioEncoderIlbcConfig { - bool IsOk() const { - return (frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 || - frame_size_ms == 60); - } - int frame_size_ms = 30; // Valid values are 20, 30, 40, and 60 ms. - // Note that frame size 40 ms produces encodings with two 20 ms frames in - // them, and frame size 60 ms consists of two 30 ms frames. -}; - -} // namespace webrtc - -#endif // API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_ diff --git a/api/audio_codecs/test/BUILD.gn b/api/audio_codecs/test/BUILD.gn index e895884434..40714b196e 100644 --- a/api/audio_codecs/test/BUILD.gn +++ b/api/audio_codecs/test/BUILD.gn @@ -33,8 +33,6 @@ if (rtc_include_tests) { "../g711:audio_encoder_g711", "../g722:audio_decoder_g722", "../g722:audio_encoder_g722", - "../ilbc:audio_decoder_ilbc", - "../ilbc:audio_encoder_ilbc", "../opus:audio_decoder_opus", "../opus:audio_encoder_opus", ] diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc index 7994836ce5..164c149302 100644 --- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc @@ -22,7 +22,6 @@ #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/g711/audio_decoder_g711.h" #include "api/audio_codecs/g722/audio_decoder_g722.h" -#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -242,20 +241,6 @@ TEST(AudioDecoderFactoryTemplateTest, G722) { ASSERT_EQ(nullptr, dec3); } -TEST(AudioDecoderFactoryTemplateTest, Ilbc) { - const Environment env = CreateEnvironment(); - auto factory = CreateAudioDecoderFactory(); - EXPECT_THAT(factory->GetSupportedDecoders(), - ::testing::ElementsAre( - AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}})); - EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); - EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 8000, 1}, std::nullopt)); - auto dec = factory->Create(env, {"ilbc", 8000, 1}, std::nullopt); - ASSERT_NE(nullptr, dec); - EXPECT_EQ(8000, dec->SampleRateHz()); -} - TEST(AudioDecoderFactoryTemplateTest, L16) { const Environment env = CreateEnvironment(); auto factory = CreateAudioDecoderFactory(); diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc index ec60d91eeb..67147ba860 100644 --- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc @@ -22,7 +22,6 @@ #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/g711/audio_encoder_g711.h" #include "api/audio_codecs/g722/audio_encoder_g722.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -266,21 +265,6 @@ TEST(AudioEncoderFactoryTemplateTest, G722) { Pointer(Property(&AudioEncoder::SampleRateHz, 16000))); } -TEST(AudioEncoderFactoryTemplateTest, Ilbc) { - const Environment env = CreateEnvironment(); - auto factory = CreateAudioEncoderFactory(); - EXPECT_THAT(factory->GetSupportedEncoders(), - ::testing::ElementsAre( - AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13333}})); - EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); - EXPECT_EQ(AudioCodecInfo(8000, 1, 13333), - factory->QueryAudioEncoder({"ilbc", 8000, 1})); - - EXPECT_THAT(factory->Create(env, {"bar", 8000, 1}, {}), IsNull()); - EXPECT_THAT(factory->Create(env, {"ilbc", 8000, 1}, {}), - Pointer(Property(&AudioEncoder::SampleRateHz, 8000))); -} - TEST(AudioEncoderFactoryTemplateTest, L16) { const Environment env = CreateEnvironment(); auto factory = CreateAudioEncoderFactory(); diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index d74a595661..29eb1197d7 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -191,186 +191,6 @@ rtc_library("g722_c") { deps = [ "../third_party/g722:g722_3p" ] } -rtc_library("ilbc") { - visibility += webrtc_default_visibility - poisonous = [ "audio_codecs" ] - sources = [ - "codecs/ilbc/audio_decoder_ilbc.cc", - "codecs/ilbc/audio_decoder_ilbc.h", - "codecs/ilbc/audio_encoder_ilbc.cc", - "codecs/ilbc/audio_encoder_ilbc.h", - ] - - deps = [ - ":legacy_encoded_audio_frame", - "../../api:array_view", - "../../api/audio_codecs:audio_codecs_api", - "../../api/audio_codecs/ilbc:audio_encoder_ilbc_config", - "../../api/units:time_delta", - "../../common_audio", - "../../rtc_base:buffer", - "../../rtc_base:checks", - "../../rtc_base:logging", - "../../rtc_base:safe_conversions", - ] - public_deps += [ ":ilbc_c" ] # no-presubmit-check TODO(webrtc:8603) -} - -rtc_library("ilbc_c") { - poisonous = [ "audio_codecs" ] - sources = [ - "codecs/ilbc/abs_quant.c", - "codecs/ilbc/abs_quant.h", - "codecs/ilbc/abs_quant_loop.c", - "codecs/ilbc/abs_quant_loop.h", - "codecs/ilbc/augmented_cb_corr.c", - "codecs/ilbc/augmented_cb_corr.h", - "codecs/ilbc/bw_expand.c", - "codecs/ilbc/bw_expand.h", - "codecs/ilbc/cb_construct.c", - "codecs/ilbc/cb_construct.h", - "codecs/ilbc/cb_mem_energy.c", - "codecs/ilbc/cb_mem_energy.h", - "codecs/ilbc/cb_mem_energy_augmentation.c", - "codecs/ilbc/cb_mem_energy_augmentation.h", - "codecs/ilbc/cb_mem_energy_calc.c", - "codecs/ilbc/cb_mem_energy_calc.h", - "codecs/ilbc/cb_search.c", - "codecs/ilbc/cb_search.h", - "codecs/ilbc/cb_search_core.c", - "codecs/ilbc/cb_search_core.h", - "codecs/ilbc/cb_update_best_index.c", - "codecs/ilbc/cb_update_best_index.h", - "codecs/ilbc/chebyshev.c", - "codecs/ilbc/chebyshev.h", - "codecs/ilbc/comp_corr.c", - "codecs/ilbc/comp_corr.h", - "codecs/ilbc/constants.c", - "codecs/ilbc/constants.h", - "codecs/ilbc/create_augmented_vec.c", - "codecs/ilbc/create_augmented_vec.h", - "codecs/ilbc/decode.c", - "codecs/ilbc/decode.h", - "codecs/ilbc/decode_residual.c", - "codecs/ilbc/decode_residual.h", - "codecs/ilbc/decoder_interpolate_lsf.c", - "codecs/ilbc/decoder_interpolate_lsf.h", - "codecs/ilbc/defines.h", - "codecs/ilbc/do_plc.c", - "codecs/ilbc/do_plc.h", - "codecs/ilbc/encode.c", - "codecs/ilbc/encode.h", - "codecs/ilbc/energy_inverse.c", - "codecs/ilbc/energy_inverse.h", - "codecs/ilbc/enh_upsample.c", - "codecs/ilbc/enh_upsample.h", - "codecs/ilbc/enhancer.c", - "codecs/ilbc/enhancer.h", - "codecs/ilbc/enhancer_interface.c", - "codecs/ilbc/enhancer_interface.h", - "codecs/ilbc/filtered_cb_vecs.c", - "codecs/ilbc/filtered_cb_vecs.h", - "codecs/ilbc/frame_classify.c", - "codecs/ilbc/frame_classify.h", - "codecs/ilbc/gain_dequant.c", - "codecs/ilbc/gain_dequant.h", - "codecs/ilbc/gain_quant.c", - "codecs/ilbc/gain_quant.h", - "codecs/ilbc/get_cd_vec.c", - "codecs/ilbc/get_cd_vec.h", - "codecs/ilbc/get_lsp_poly.c", - "codecs/ilbc/get_lsp_poly.h", - "codecs/ilbc/get_sync_seq.c", - "codecs/ilbc/get_sync_seq.h", - "codecs/ilbc/hp_input.c", - "codecs/ilbc/hp_input.h", - "codecs/ilbc/hp_output.c", - "codecs/ilbc/hp_output.h", - "codecs/ilbc/ilbc.c", - "codecs/ilbc/ilbc.h", - "codecs/ilbc/index_conv_dec.c", - "codecs/ilbc/index_conv_dec.h", - "codecs/ilbc/index_conv_enc.c", - "codecs/ilbc/index_conv_enc.h", - "codecs/ilbc/init_decode.c", - "codecs/ilbc/init_decode.h", - "codecs/ilbc/init_encode.c", - "codecs/ilbc/init_encode.h", - "codecs/ilbc/interpolate.c", - "codecs/ilbc/interpolate.h", - "codecs/ilbc/interpolate_samples.c", - "codecs/ilbc/interpolate_samples.h", - "codecs/ilbc/lpc_encode.c", - "codecs/ilbc/lpc_encode.h", - "codecs/ilbc/lsf_check.c", - "codecs/ilbc/lsf_check.h", - "codecs/ilbc/lsf_interpolate_to_poly_dec.c", - "codecs/ilbc/lsf_interpolate_to_poly_dec.h", - "codecs/ilbc/lsf_interpolate_to_poly_enc.c", - "codecs/ilbc/lsf_interpolate_to_poly_enc.h", - "codecs/ilbc/lsf_to_lsp.c", - "codecs/ilbc/lsf_to_lsp.h", - "codecs/ilbc/lsf_to_poly.c", - "codecs/ilbc/lsf_to_poly.h", - "codecs/ilbc/lsp_to_lsf.c", - "codecs/ilbc/lsp_to_lsf.h", - "codecs/ilbc/my_corr.c", - "codecs/ilbc/my_corr.h", - "codecs/ilbc/nearest_neighbor.c", - "codecs/ilbc/nearest_neighbor.h", - "codecs/ilbc/pack_bits.c", - "codecs/ilbc/pack_bits.h", - "codecs/ilbc/poly_to_lsf.c", - "codecs/ilbc/poly_to_lsf.h", - "codecs/ilbc/poly_to_lsp.c", - "codecs/ilbc/poly_to_lsp.h", - "codecs/ilbc/refiner.c", - "codecs/ilbc/refiner.h", - "codecs/ilbc/simple_interpolate_lsf.c", - "codecs/ilbc/simple_interpolate_lsf.h", - "codecs/ilbc/simple_lpc_analysis.c", - "codecs/ilbc/simple_lpc_analysis.h", - "codecs/ilbc/simple_lsf_dequant.c", - "codecs/ilbc/simple_lsf_dequant.h", - "codecs/ilbc/simple_lsf_quant.c", - "codecs/ilbc/simple_lsf_quant.h", - "codecs/ilbc/smooth.c", - "codecs/ilbc/smooth.h", - "codecs/ilbc/smooth_out_data.c", - "codecs/ilbc/smooth_out_data.h", - "codecs/ilbc/sort_sq.c", - "codecs/ilbc/sort_sq.h", - "codecs/ilbc/split_vq.c", - "codecs/ilbc/split_vq.h", - "codecs/ilbc/state_construct.c", - "codecs/ilbc/state_construct.h", - "codecs/ilbc/state_search.c", - "codecs/ilbc/state_search.h", - "codecs/ilbc/swap_bytes.c", - "codecs/ilbc/swap_bytes.h", - "codecs/ilbc/unpack_bits.c", - "codecs/ilbc/unpack_bits.h", - "codecs/ilbc/vq3.c", - "codecs/ilbc/vq3.h", - "codecs/ilbc/vq4.c", - "codecs/ilbc/vq4.h", - "codecs/ilbc/window32_w32.c", - "codecs/ilbc/window32_w32.h", - "codecs/ilbc/xcorr_coef.c", - "codecs/ilbc/xcorr_coef.h", - ] - - deps = [ - "../../api/audio_codecs:audio_codecs_api", - "../../common_audio", - "../../common_audio:common_audio_c", - "../../rtc_base:checks", - "../../rtc_base:sanitizer", - "../../rtc_base/system:arch", - "//third_party/abseil-cpp/absl/base:core_headers", - ] -} - rtc_library("isac_vad") { visibility += [ "../audio_processing/vad:*" ] sources = [ @@ -949,9 +769,6 @@ if (rtc_include_tests) { "../../common_audio", "../../system_wrappers", ] - if (rtc_include_ilbc) { - audio_coding_deps += [ ":ilbc" ] - } if (rtc_include_opus) { audio_coding_deps += [ ":webrtc_opus" ] } @@ -985,8 +802,6 @@ if (rtc_include_tests) { ":audio_decoder_unittests", ":g711_test", ":g722_test", - ":ilbc_test", - ":neteq_ilbc_quality_test", ":neteq_opus_quality_test", ":neteq_pcm16b_quality_test", ":neteq_pcmu_quality_test", @@ -1046,8 +861,6 @@ if (rtc_include_tests) { "../../api/audio_codecs/g711:audio_encoder_g711", "../../api/audio_codecs/g722:audio_decoder_g722", "../../api/audio_codecs/g722:audio_encoder_g722", - "../../api/audio_codecs/ilbc:audio_decoder_ilbc", - "../../api/audio_codecs/ilbc:audio_encoder_ilbc", "../../api/audio_codecs/opus:audio_decoder_opus", "../../api/audio_codecs/opus:audio_encoder_opus", "../../api/environment", @@ -1171,7 +984,6 @@ if (rtc_include_tests) { defines = neteq_defines deps = [ - ":ilbc", ":neteq", ":neteq_input_audio_tools", ":neteq_tools", @@ -1377,7 +1189,6 @@ if (rtc_include_tests) { "../../api/audio_codecs/L16:audio_encoder_L16", "../../api/audio_codecs/g711:audio_encoder_g711", "../../api/audio_codecs/g722:audio_encoder_g722", - "../../api/audio_codecs/ilbc:audio_encoder_ilbc", "../../api/audio_codecs/opus:audio_encoder_opus", "../../api/environment:environment_factory", "../../rtc_base:checks", @@ -1469,25 +1280,6 @@ if (rtc_include_tests) { ] } - rtc_executable("neteq_ilbc_quality_test") { - testonly = true - - sources = [ "neteq/test/neteq_ilbc_quality_test.cc" ] - - deps = [ - ":ilbc", - ":neteq", - ":neteq_quality_test_support", - ":neteq_tools", - "../../rtc_base:checks", - "../../rtc_base:safe_conversions", - "../../test:fileutils", - "../../test:test_main", - "//testing/gtest", - "//third_party/abseil-cpp/absl/flags:flag", - ] - } - rtc_executable("neteq_pcmu_quality_test") { testonly = true @@ -1542,14 +1334,6 @@ if (rtc_include_tests) { } if (!build_with_chromium) { - rtc_executable("ilbc_test") { - testonly = true - - sources = [ "codecs/ilbc/test/iLBC_test.c" ] - - deps = [ ":ilbc" ] - } - rtc_executable("webrtc_opus_fec_test") { testonly = true @@ -1588,7 +1372,6 @@ if (rtc_include_tests) { "codecs/builtin_audio_encoder_factory_unittest.cc", "codecs/cng/audio_encoder_cng_unittest.cc", "codecs/cng/cng_unittest.cc", - "codecs/ilbc/ilbc_unittest.cc", "codecs/legacy_encoded_audio_frame_unittest.cc", "codecs/opus/audio_decoder_multi_channel_opus_unittest.cc", "codecs/opus/audio_encoder_multi_channel_opus_unittest.cc", @@ -1654,7 +1437,6 @@ if (rtc_include_tests) { ":audio_encoder_cng", ":audio_network_adaptor", ":g711", - ":ilbc", ":legacy_encoded_audio_frame", ":mocks", ":neteq", diff --git a/modules/audio_coding/audio_coding.gni b/modules/audio_coding/audio_coding.gni index 3b147091de..b5d75a7234 100644 --- a/modules/audio_coding/audio_coding.gni +++ b/modules/audio_coding/audio_coding.gni @@ -9,9 +9,6 @@ import("../../webrtc.gni") audio_codec_defines = [] -if (rtc_include_ilbc) { - audio_codec_defines += [ "WEBRTC_CODEC_ILBC" ] -} if (rtc_include_opus) { audio_codec_defines += [ "WEBRTC_CODEC_OPUS" ] } diff --git a/modules/audio_coding/codecs/ilbc/abs_quant.c b/modules/audio_coding/codecs/ilbc/abs_quant.c deleted file mode 100644 index 77da78ba7f..0000000000 --- a/modules/audio_coding/codecs/ilbc/abs_quant.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuant.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/abs_quant.h" - -#include "modules/audio_coding/codecs/ilbc/abs_quant_loop.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuant( - IlbcEncoder *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax - and idxVec, uses state_first as - input) */ - int16_t *in, /* (i) vector to encode */ - int16_t *weightDenum /* (i) denominator of synthesis filter */ - ) { - int16_t *syntOut; - size_t quantLen[2]; - - /* Stack based */ - int16_t syntOutBuf[LPC_FILTERORDER+STATE_SHORT_LEN_30MS]; - int16_t in_weightedVec[STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - int16_t *in_weighted = &in_weightedVec[LPC_FILTERORDER]; - - /* Initialize the buffers */ - WebRtcSpl_MemSetW16(syntOutBuf, 0, LPC_FILTERORDER+STATE_SHORT_LEN_30MS); - syntOut = &syntOutBuf[LPC_FILTERORDER]; - /* Start with zero state */ - WebRtcSpl_MemSetW16(in_weightedVec, 0, LPC_FILTERORDER); - - /* Perform the quantization loop in two sections of length quantLen[i], - where the perceptual weighting filter is updated at the subframe - border */ - - if (iLBC_encbits->state_first) { - quantLen[0]=SUBL; - quantLen[1]=iLBCenc_inst->state_short_len-SUBL; - } else { - quantLen[0]=iLBCenc_inst->state_short_len-SUBL; - quantLen[1]=SUBL; - } - - /* Calculate the weighted residual, switch perceptual weighting - filter at the subframe border */ - WebRtcSpl_FilterARFastQ12( - in, in_weighted, - weightDenum, LPC_FILTERORDER+1, quantLen[0]); - WebRtcSpl_FilterARFastQ12( - &in[quantLen[0]], &in_weighted[quantLen[0]], - &weightDenum[LPC_FILTERORDER+1], LPC_FILTERORDER+1, quantLen[1]); - - WebRtcIlbcfix_AbsQuantLoop( - syntOut, - in_weighted, - weightDenum, - quantLen, - iLBC_encbits->idxVec); - -} diff --git a/modules/audio_coding/codecs/ilbc/abs_quant.h b/modules/audio_coding/codecs/ilbc/abs_quant.h deleted file mode 100644 index 4a3f004ed3..0000000000 --- a/modules/audio_coding/codecs/ilbc/abs_quant.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuant.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuant( - IlbcEncoder* iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax - and idxVec, uses state_first as - input) */ - int16_t* in, /* (i) vector to encode */ - int16_t* weightDenum /* (i) denominator of synthesis filter */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/abs_quant_loop.c b/modules/audio_coding/codecs/ilbc/abs_quant_loop.c deleted file mode 100644 index cf9266299d..0000000000 --- a/modules/audio_coding/codecs/ilbc/abs_quant_loop.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuantLoop.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/abs_quant_loop.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/sort_sq.h" - -void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN, - int16_t *weightDenumIN, size_t *quantLenIN, - int16_t *idxVecIN ) { - size_t k1, k2; - int16_t index; - int32_t toQW32; - int32_t toQ32; - int16_t tmp16a; - int16_t xq; - - int16_t *syntOut = syntOutIN; - int16_t *in_weighted = in_weightedIN; - int16_t *weightDenum = weightDenumIN; - size_t *quantLen = quantLenIN; - int16_t *idxVec = idxVecIN; - - for(k1=0;k1<2;k1++) { - for(k2=0;k2 32767) { - toQ32 = (int32_t) 32767; - } else if (toQ32 < -32768) { - toQ32 = (int32_t) -32768; - } - - /* Quantize the state */ - if (toQW32<(-7577)) { - /* To prevent negative overflow */ - index=0; - } else if (toQW32>8151) { - /* To prevent positive overflow */ - index=7; - } else { - /* Find the best quantization index - (state_sq3Tbl is in Q13 and toQ is in Q11) - */ - WebRtcIlbcfix_SortSq(&xq, &index, - (int16_t)toQ32, - WebRtcIlbcfix_kStateSq3, 8); - } - - /* Store selected index */ - (*idxVec++) = index; - - /* Compute decoded sample and update of the prediction filter */ - tmp16a = ((WebRtcIlbcfix_kStateSq3[index] + 2 ) >> 2); - - *syntOut = (int16_t) (tmp16a + (int32_t)(*in_weighted) - toQW32); - - syntOut++; in_weighted++; - } - /* Update perceptual weighting filter at subframe border */ - weightDenum += 11; - } -} diff --git a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h b/modules/audio_coding/codecs/ilbc/abs_quant_loop.h deleted file mode 100644 index 841d73b9fb..0000000000 --- a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuantLoop.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ - -#include -#include - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuantLoop(int16_t* syntOutIN, - int16_t* in_weightedIN, - int16_t* weightDenumIN, - size_t* quantLenIN, - int16_t* idxVecIN); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc deleted file mode 100644 index 57b5abbe23..0000000000 --- a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/ilbc.h" -#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" - -namespace webrtc { - -AudioDecoderIlbcImpl::AudioDecoderIlbcImpl() { - WebRtcIlbcfix_DecoderCreate(&dec_state_); - WebRtcIlbcfix_Decoderinit30Ms(dec_state_); -} - -AudioDecoderIlbcImpl::~AudioDecoderIlbcImpl() { - WebRtcIlbcfix_DecoderFree(dec_state_); -} - -bool AudioDecoderIlbcImpl::HasDecodePlc() const { - return true; -} - -int AudioDecoderIlbcImpl::DecodeInternal(const uint8_t* encoded, - size_t encoded_len, - int sample_rate_hz, - int16_t* decoded, - SpeechType* speech_type) { - RTC_DCHECK_EQ(sample_rate_hz, 8000); - int16_t temp_type = 1; // Default is speech. - int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, encoded_len, decoded, - &temp_type); - *speech_type = ConvertSpeechType(temp_type); - return ret; -} - -size_t AudioDecoderIlbcImpl::DecodePlc(size_t num_frames, int16_t* decoded) { - return WebRtcIlbcfix_NetEqPlc(dec_state_, decoded, num_frames); -} - -void AudioDecoderIlbcImpl::Reset() { - WebRtcIlbcfix_Decoderinit30Ms(dec_state_); -} - -std::vector AudioDecoderIlbcImpl::ParsePayload( - rtc::Buffer&& payload, - uint32_t timestamp) { - std::vector results; - size_t bytes_per_frame; - int timestamps_per_frame; - if (payload.size() >= 950) { - RTC_LOG(LS_WARNING) - << "AudioDecoderIlbcImpl::ParsePayload: Payload too large"; - return results; - } - if (payload.size() % 38 == 0) { - // 20 ms frames. - bytes_per_frame = 38; - timestamps_per_frame = 160; - } else if (payload.size() % 50 == 0) { - // 30 ms frames. - bytes_per_frame = 50; - timestamps_per_frame = 240; - } else { - RTC_LOG(LS_WARNING) - << "AudioDecoderIlbcImpl::ParsePayload: Invalid payload"; - return results; - } - - RTC_DCHECK_EQ(0, payload.size() % bytes_per_frame); - if (payload.size() == bytes_per_frame) { - std::unique_ptr frame( - new LegacyEncodedAudioFrame(this, std::move(payload))); - results.emplace_back(timestamp, 0, std::move(frame)); - } else { - size_t byte_offset; - uint32_t timestamp_offset; - for (byte_offset = 0, timestamp_offset = 0; byte_offset < payload.size(); - byte_offset += bytes_per_frame, - timestamp_offset += timestamps_per_frame) { - std::unique_ptr frame(new LegacyEncodedAudioFrame( - this, rtc::Buffer(payload.data() + byte_offset, bytes_per_frame))); - results.emplace_back(timestamp + timestamp_offset, 0, std::move(frame)); - } - } - - return results; -} - -int AudioDecoderIlbcImpl::SampleRateHz() const { - return 8000; -} - -size_t AudioDecoderIlbcImpl::Channels() const { - return 1; -} - -} // namespace webrtc diff --git a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h deleted file mode 100644 index 46ba755148..0000000000 --- a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ - -#include -#include - -#include - -#include "api/audio_codecs/audio_decoder.h" -#include "rtc_base/buffer.h" - -typedef struct iLBC_decinst_t_ IlbcDecoderInstance; - -namespace webrtc { - -class AudioDecoderIlbcImpl final : public AudioDecoder { - public: - AudioDecoderIlbcImpl(); - ~AudioDecoderIlbcImpl() override; - - AudioDecoderIlbcImpl(const AudioDecoderIlbcImpl&) = delete; - AudioDecoderIlbcImpl& operator=(const AudioDecoderIlbcImpl&) = delete; - - bool HasDecodePlc() const override; - size_t DecodePlc(size_t num_frames, int16_t* decoded) override; - void Reset() override; - std::vector ParsePayload(rtc::Buffer&& payload, - uint32_t timestamp) override; - int SampleRateHz() const override; - size_t Channels() const override; - - protected: - int DecodeInternal(const uint8_t* encoded, - size_t encoded_len, - int sample_rate_hz, - int16_t* decoded, - SpeechType* speech_type) override; - - private: - IlbcDecoderInstance* dec_state_; -}; - -} // namespace webrtc -#endif // MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc deleted file mode 100644 index afe3affd54..0000000000 --- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/ilbc.h" -#include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" - -namespace webrtc { - -namespace { - -const int kSampleRateHz = 8000; - -int GetIlbcBitrate(int ptime) { - switch (ptime) { - case 20: - case 40: - // 38 bytes per frame of 20 ms => 15200 bits/s. - return 15200; - case 30: - case 60: - // 50 bytes per frame of 30 ms => (approx) 13333 bits/s. - return 13333; - default: - RTC_CHECK_NOTREACHED(); - } -} - -} // namespace - -AudioEncoderIlbcImpl::AudioEncoderIlbcImpl(const AudioEncoderIlbcConfig& config, - int payload_type) - : frame_size_ms_(config.frame_size_ms), - payload_type_(payload_type), - num_10ms_frames_per_packet_( - static_cast(config.frame_size_ms / 10)), - encoder_(nullptr) { - RTC_CHECK(config.IsOk()); - Reset(); -} - -AudioEncoderIlbcImpl::~AudioEncoderIlbcImpl() { - RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_)); -} - -int AudioEncoderIlbcImpl::SampleRateHz() const { - return kSampleRateHz; -} - -size_t AudioEncoderIlbcImpl::NumChannels() const { - return 1; -} - -size_t AudioEncoderIlbcImpl::Num10MsFramesInNextPacket() const { - return num_10ms_frames_per_packet_; -} - -size_t AudioEncoderIlbcImpl::Max10MsFramesInAPacket() const { - return num_10ms_frames_per_packet_; -} - -int AudioEncoderIlbcImpl::GetTargetBitrate() const { - return GetIlbcBitrate(rtc::dchecked_cast(num_10ms_frames_per_packet_) * - 10); -} - -AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl( - uint32_t rtp_timestamp, - rtc::ArrayView audio, - rtc::Buffer* encoded) { - // Save timestamp if starting a new packet. - if (num_10ms_frames_buffered_ == 0) - first_timestamp_in_buffer_ = rtp_timestamp; - - // Buffer input. - std::copy(audio.cbegin(), audio.cend(), - input_buffer_ + kSampleRateHz / 100 * num_10ms_frames_buffered_); - - // If we don't yet have enough buffered input for a whole packet, we're done - // for now. - if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) { - return EncodedInfo(); - } - - // Encode buffered input. - RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_); - num_10ms_frames_buffered_ = 0; - size_t encoded_bytes = encoded->AppendData( - RequiredOutputSizeBytes(), [&](rtc::ArrayView encoded) { - const int r = WebRtcIlbcfix_Encode( - encoder_, input_buffer_, - kSampleRateHz / 100 * num_10ms_frames_per_packet_, encoded.data()); - RTC_CHECK_GE(r, 0); - - return static_cast(r); - }); - - RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes()); - - EncodedInfo info; - info.encoded_bytes = encoded_bytes; - info.encoded_timestamp = first_timestamp_in_buffer_; - info.payload_type = payload_type_; - info.encoder_type = CodecType::kIlbc; - return info; -} - -void AudioEncoderIlbcImpl::Reset() { - if (encoder_) - RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_)); - RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); - const int encoder_frame_size_ms = - frame_size_ms_ > 30 ? frame_size_ms_ / 2 : frame_size_ms_; - RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms)); - num_10ms_frames_buffered_ = 0; -} - -std::optional> -AudioEncoderIlbcImpl::GetFrameLengthRange() const { - return {{TimeDelta::Millis(num_10ms_frames_per_packet_ * 10), - TimeDelta::Millis(num_10ms_frames_per_packet_ * 10)}}; -} - -size_t AudioEncoderIlbcImpl::RequiredOutputSizeBytes() const { - switch (num_10ms_frames_per_packet_) { - case 2: - return 38; - case 3: - return 50; - case 4: - return 2 * 38; - case 6: - return 2 * 50; - default: - RTC_CHECK_NOTREACHED(); - } -} - -} // namespace webrtc diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h deleted file mode 100644 index 31c20473d8..0000000000 --- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ - -#include -#include - -#include -#include - -#include "api/audio_codecs/audio_encoder.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" -#include "api/units/time_delta.h" -#include "modules/audio_coding/codecs/ilbc/ilbc.h" - -namespace webrtc { - -class AudioEncoderIlbcImpl final : public AudioEncoder { - public: - AudioEncoderIlbcImpl(const AudioEncoderIlbcConfig& config, int payload_type); - ~AudioEncoderIlbcImpl() override; - - AudioEncoderIlbcImpl(const AudioEncoderIlbcImpl&) = delete; - AudioEncoderIlbcImpl& operator=(const AudioEncoderIlbcImpl&) = delete; - - int SampleRateHz() const override; - size_t NumChannels() const override; - size_t Num10MsFramesInNextPacket() const override; - size_t Max10MsFramesInAPacket() const override; - int GetTargetBitrate() const override; - EncodedInfo EncodeImpl(uint32_t rtp_timestamp, - rtc::ArrayView audio, - rtc::Buffer* encoded) override; - void Reset() override; - std::optional> GetFrameLengthRange() - const override; - - private: - size_t RequiredOutputSizeBytes() const; - - static constexpr size_t kMaxSamplesPerPacket = 480; - const int frame_size_ms_; - const int payload_type_; - const size_t num_10ms_frames_per_packet_; - size_t num_10ms_frames_buffered_; - uint32_t first_timestamp_in_buffer_; - int16_t input_buffer_[kMaxSamplesPerPacket]; - IlbcEncoderInstance* encoder_; -}; - -} // namespace webrtc -#endif // MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ diff --git a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c deleted file mode 100644 index c915a2f9f0..0000000000 --- a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AugmentedCbCorr.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/augmented_cb_corr.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_AugmentedCbCorr( - int16_t *target, /* (i) Target vector */ - int16_t *buffer, /* (i) Memory buffer */ - int16_t *interpSamples, /* (i) buffer with - interpolated samples */ - int32_t *crossDot, /* (o) The cross correlation between - the target and the Augmented - vector */ - size_t low, /* (i) Lag to start from (typically - 20) */ - size_t high, /* (i) Lag to end at (typically 39) */ - int scale) /* (i) Scale factor to use for - the crossDot */ -{ - size_t lagcount; - size_t ilow; - int16_t *targetPtr; - int32_t *crossDotPtr; - int16_t *iSPtr=interpSamples; - - /* Calculate the correlation between the target and the - interpolated codebook. The correlation is calculated in - 3 sections with the interpolated part in the middle */ - crossDotPtr=crossDot; - for (lagcount=low; lagcount<=high; lagcount++) { - - ilow = lagcount - 4; - - /* Compute dot product for the first (lagcount-4) samples */ - (*crossDotPtr) = WebRtcSpl_DotProductWithScale(target, buffer-lagcount, ilow, scale); - - /* Compute dot product on the interpolated samples */ - (*crossDotPtr) += WebRtcSpl_DotProductWithScale(target+ilow, iSPtr, 4, scale); - targetPtr = target + lagcount; - iSPtr += lagcount-ilow; - - /* Compute dot product for the remaining samples */ - (*crossDotPtr) += WebRtcSpl_DotProductWithScale(targetPtr, buffer-lagcount, SUBL-lagcount, scale); - crossDotPtr++; - } -} diff --git a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h deleted file mode 100644 index 2e9612e51a..0000000000 --- a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AugmentedCbCorr.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Calculate correlation between target and Augmented codebooks - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AugmentedCbCorr( - int16_t* target, /* (i) Target vector */ - int16_t* buffer, /* (i) Memory buffer */ - int16_t* interpSamples, /* (i) buffer with - interpolated samples */ - int32_t* crossDot, /* (o) The cross correlation between - the target and the Augmented - vector */ - size_t low, /* (i) Lag to start from (typically - 20) */ - size_t high, /* (i) Lag to end at (typically 39 */ - int scale); /* (i) Scale factor to use for the crossDot */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/bw_expand.c b/modules/audio_coding/codecs/ilbc/bw_expand.c deleted file mode 100644 index 1a9b882adf..0000000000 --- a/modules/audio_coding/codecs/ilbc/bw_expand.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_BwExpand.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/bw_expand.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * lpc bandwidth expansion - *---------------------------------------------------------------*/ - -/* The output is in the same domain as the input */ -void WebRtcIlbcfix_BwExpand( - int16_t *out, /* (o) the bandwidth expanded lpc coefficients */ - int16_t *in, /* (i) the lpc coefficients before bandwidth - expansion */ - int16_t *coef, /* (i) the bandwidth expansion factor Q15 */ - int16_t length /* (i) the length of lpc coefficient vectors */ - ) { - int i; - - out[0] = in[0]; - for (i = 1; i < length; i++) { - /* out[i] = coef[i] * in[i] with rounding. - in[] and out[] are in Q12 and coef[] is in Q15 - */ - out[i] = (int16_t)((coef[i] * in[i] + 16384) >> 15); - } -} diff --git a/modules/audio_coding/codecs/ilbc/bw_expand.h b/modules/audio_coding/codecs/ilbc/bw_expand.h deleted file mode 100644 index 022c113dda..0000000000 --- a/modules/audio_coding/codecs/ilbc/bw_expand.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_BwExpand.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ - -#include -#include - -/*----------------------------------------------------------------* - * lpc bandwidth expansion - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_BwExpand( - int16_t* out, /* (o) the bandwidth expanded lpc coefficients */ - int16_t* in, /* (i) the lpc coefficients before bandwidth - expansion */ - int16_t* coef, /* (i) the bandwidth expansion factor Q15 */ - int16_t length /* (i) the length of lpc coefficient vectors */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_construct.c b/modules/audio_coding/codecs/ilbc/cb_construct.c deleted file mode 100644 index 1e9a7040c7..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_construct.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbConstruct.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_construct.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/gain_dequant.h" -#include "modules/audio_coding/codecs/ilbc/get_cd_vec.h" -#include "rtc_base/sanitizer.h" - -// An arithmetic operation that is allowed to overflow. (It's still undefined -// behavior, so not a good idea; this just makes UBSan ignore the violation, so -// that our old code can continue to do what it's always been doing.) -static inline int32_t RTC_NO_SANITIZE("signed-integer-overflow") - OverflowingAddS32S32ToS32(int32_t a, int32_t b) { - return a + b; -} - -/*----------------------------------------------------------------* - * Construct decoded vector from codebook and gains. - *---------------------------------------------------------------*/ - -bool WebRtcIlbcfix_CbConstruct( - int16_t* decvector, /* (o) Decoded vector */ - const int16_t* index, /* (i) Codebook indices */ - const int16_t* gain_index, /* (i) Gain quantization indices */ - int16_t* mem, /* (i) Buffer for codevector construction */ - size_t lMem, /* (i) Length of buffer */ - size_t veclen) { /* (i) Length of vector */ - size_t j; - int16_t gain[CB_NSTAGES]; - /* Stack based */ - int16_t cbvec0[SUBL]; - int16_t cbvec1[SUBL]; - int16_t cbvec2[SUBL]; - int32_t a32; - int16_t *gainPtr; - - /* gain de-quantization */ - - gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0); - gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1); - gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2); - - /* codebook vector construction and construction of total vector */ - - /* Stack based */ - if (!WebRtcIlbcfix_GetCbVec(cbvec0, mem, (size_t)index[0], lMem, veclen)) - return false; // Failure. - if (!WebRtcIlbcfix_GetCbVec(cbvec1, mem, (size_t)index[1], lMem, veclen)) - return false; // Failure. - if (!WebRtcIlbcfix_GetCbVec(cbvec2, mem, (size_t)index[2], lMem, veclen)) - return false; // Failure. - - gainPtr = &gain[0]; - for (j=0;j> 14); - } - - return true; // Success. -} diff --git a/modules/audio_coding/codecs/ilbc/cb_construct.h b/modules/audio_coding/codecs/ilbc/cb_construct.h deleted file mode 100644 index 8f7c663164..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_construct.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbConstruct.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ - -#include -#include -#include - -#include "absl/base/attributes.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Construct decoded vector from codebook and gains. - *---------------------------------------------------------------*/ - -// Returns true on success, false on failure. -ABSL_MUST_USE_RESULT -bool WebRtcIlbcfix_CbConstruct( - int16_t* decvector, /* (o) Decoded vector */ - const int16_t* index, /* (i) Codebook indices */ - const int16_t* gain_index, /* (i) Gain quantization indices */ - int16_t* mem, /* (i) Buffer for codevector construction */ - size_t lMem, /* (i) Length of buffer */ - size_t veclen /* (i) Length of vector */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy.c b/modules/audio_coding/codecs/ilbc/cb_mem_energy.c deleted file mode 100644 index 21e4197607..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergy.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy.h" - -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Function WebRtcIlbcfix_CbMemEnergy computes the energy of all - * the vectors in the codebook memory that will be used in the - * following search for the best match. - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbMemEnergy( - size_t range, - int16_t *CB, /* (i) The CB memory (1:st section) */ - int16_t *filteredCB, /* (i) The filtered CB memory (2:nd section) */ - size_t lMem, /* (i) Length of the CB memory */ - size_t lTarget, /* (i) Length of the target vector */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ - ) { - int16_t *ppi, *ppo, *pp; - int32_t energy, tmp32; - - /* Compute the energy and store it in a vector. Also the - * corresponding shift values are stored. The energy values - * are reused in all three stages. */ - - /* Calculate the energy in the first block of 'lTarget' sampels. */ - ppi = CB+lMem-lTarget-1; - ppo = CB+lMem-1; - - pp=CB+lMem-lTarget; - energy = WebRtcSpl_DotProductWithScale( pp, pp, lTarget, scale); - - /* Normalize the energy and store the number of shifts */ - energyShifts[0] = (int16_t)WebRtcSpl_NormW32(energy); - tmp32 = energy << energyShifts[0]; - energyW16[0] = (int16_t)(tmp32 >> 16); - - /* Compute the energy of the rest of the cb memory - * by step wise adding and subtracting the next - * sample and the last sample respectively. */ - WebRtcIlbcfix_CbMemEnergyCalc(energy, range, ppi, ppo, energyW16, energyShifts, scale, 0); - - /* Next, precompute the energy values for the filtered cb section */ - energy=0; - pp=filteredCB+lMem-lTarget; - - energy = WebRtcSpl_DotProductWithScale( pp, pp, lTarget, scale); - - /* Normalize the energy and store the number of shifts */ - energyShifts[base_size] = (int16_t)WebRtcSpl_NormW32(energy); - tmp32 = energy << energyShifts[base_size]; - energyW16[base_size] = (int16_t)(tmp32 >> 16); - - ppi = filteredCB + lMem - 1 - lTarget; - ppo = filteredCB + lMem - 1; - - WebRtcIlbcfix_CbMemEnergyCalc(energy, range, ppi, ppo, energyW16, energyShifts, scale, base_size); -} diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy.h deleted file mode 100644 index 15dc884f2a..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergy.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ - -#include -#include - -void WebRtcIlbcfix_CbMemEnergy( - size_t range, - int16_t* CB, /* (i) The CB memory (1:st section) */ - int16_t* filteredCB, /* (i) The filtered CB memory (2:nd section) */ - size_t lMem, /* (i) Length of the CB memory */ - size_t lTarget, /* (i) Length of the target vector */ - int16_t* energyW16, /* (o) Energy in the CB vectors */ - int16_t* energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c deleted file mode 100644 index 0619bbe422..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyAugmentation.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_CbMemEnergyAugmentation( - int16_t *interpSamples, /* (i) The interpolated samples */ - int16_t *CBmem, /* (i) The CB memory */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size, /* (i) Index to where energy values should be stored */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts /* (o) Shift value of the energy */ - ){ - int32_t energy, tmp32; - int16_t *ppe, *pp, *interpSamplesPtr; - int16_t *CBmemPtr; - size_t lagcount; - int16_t *enPtr=&energyW16[base_size-20]; - int16_t *enShPtr=&energyShifts[base_size-20]; - int32_t nrjRecursive; - - CBmemPtr = CBmem+147; - interpSamplesPtr = interpSamples; - - /* Compute the energy for the first (low-5) noninterpolated samples */ - nrjRecursive = WebRtcSpl_DotProductWithScale( CBmemPtr-19, CBmemPtr-19, 15, scale); - ppe = CBmemPtr - 20; - - for (lagcount=20; lagcount<=39; lagcount++) { - - /* Update the energy recursively to save complexity */ - nrjRecursive += (*ppe * *ppe) >> scale; - ppe--; - energy = nrjRecursive; - - /* interpolation */ - energy += WebRtcSpl_DotProductWithScale(interpSamplesPtr, interpSamplesPtr, 4, scale); - interpSamplesPtr += 4; - - /* Compute energy for the remaining samples */ - pp = CBmemPtr - lagcount; - energy += WebRtcSpl_DotProductWithScale(pp, pp, SUBL-lagcount, scale); - - /* Normalize the energy and store the number of shifts */ - (*enShPtr) = (int16_t)WebRtcSpl_NormW32(energy); - tmp32 = energy << *enShPtr; - *enPtr = (int16_t)(tmp32 >> 16); - enShPtr++; - enPtr++; - } -} diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h deleted file mode 100644 index c489ab54f9..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyAugmentation.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ - -#include -#include - -void WebRtcIlbcfix_CbMemEnergyAugmentation( - int16_t* interpSamples, /* (i) The interpolated samples */ - int16_t* CBmem, /* (i) The CB memory */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size, /* (i) Index to where energy values should be stored */ - int16_t* energyW16, /* (o) Energy in the CB vectors */ - int16_t* energyShifts /* (o) Shift value of the energy */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c deleted file mode 100644 index 58c0c5fe6d..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyCalc.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/* Compute the energy of the rest of the cb memory - * by step wise adding and subtracting the next - * sample and the last sample respectively */ -void WebRtcIlbcfix_CbMemEnergyCalc( - int32_t energy, /* (i) input start energy */ - size_t range, /* (i) number of iterations */ - int16_t *ppi, /* (i) input pointer 1 */ - int16_t *ppo, /* (i) input pointer 2 */ - int16_t *energyW16, /* (o) Energy in the CB vectors */ - int16_t *energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ - ) -{ - size_t j; - int16_t shft; - int32_t tmp; - int16_t *eSh_ptr; - int16_t *eW16_ptr; - - - eSh_ptr = &energyShifts[1+base_size]; - eW16_ptr = &energyW16[1+base_size]; - - for (j = 0; j + 1 < range; j++) { - - /* Calculate next energy by a +/- - operation on the edge samples */ - tmp = (*ppi) * (*ppi) - (*ppo) * (*ppo); - energy += tmp >> scale; - energy = WEBRTC_SPL_MAX(energy, 0); - - ppi--; - ppo--; - - /* Normalize the energy into a int16_t and store - the number of shifts */ - - shft = (int16_t)WebRtcSpl_NormW32(energy); - *eSh_ptr++ = shft; - - tmp = energy << shft; - *eW16_ptr++ = (int16_t)(tmp >> 16); - } -} diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h deleted file mode 100644 index 4b3703182e..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyCalc.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ - -#include -#include - -void WebRtcIlbcfix_CbMemEnergyCalc( - int32_t energy, /* (i) input start energy */ - size_t range, /* (i) number of iterations */ - int16_t* ppi, /* (i) input pointer 1 */ - int16_t* ppo, /* (i) input pointer 2 */ - int16_t* energyW16, /* (o) Energy in the CB vectors */ - int16_t* energyShifts, /* (o) Shift value of the energy */ - int scale, /* (i) The scaling of all energy values */ - size_t base_size /* (i) Index to where energy values should be stored */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_search.c b/modules/audio_coding/codecs/ilbc/cb_search.c deleted file mode 100644 index 24b5292354..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_search.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearch.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_search.h" - -#include "modules/audio_coding/codecs/ilbc/augmented_cb_corr.h" -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy.h" -#include "modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h" -#include "modules/audio_coding/codecs/ilbc/cb_search_core.h" -#include "modules/audio_coding/codecs/ilbc/cb_update_best_index.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/create_augmented_vec.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/energy_inverse.h" -#include "modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h" -#include "modules/audio_coding/codecs/ilbc/gain_quant.h" -#include "modules/audio_coding/codecs/ilbc/interpolate_samples.h" - -/*----------------------------------------------------------------* - * Search routine for codebook encoding and gain quantization. - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbSearch( - IlbcEncoder *iLBCenc_inst, - /* (i) the encoder state structure */ - int16_t *index, /* (o) Codebook indices */ - int16_t *gain_index, /* (o) Gain quantization indices */ - int16_t *intarget, /* (i) Target vector for encoding */ - int16_t *decResidual,/* (i) Decoded residual for codebook construction */ - size_t lMem, /* (i) Length of buffer */ - size_t lTarget, /* (i) Length of vector */ - int16_t *weightDenum,/* (i) weighting filter coefficients in Q12 */ - size_t block /* (i) the subblock number */ - ) { - size_t i, range; - int16_t ii, j, stage; - int16_t *pp; - int16_t tmp; - int scale; - int16_t bits, temp1, temp2; - size_t base_size; - int32_t codedEner, targetEner; - int16_t gains[CB_NSTAGES+1]; - int16_t *cb_vecPtr; - size_t indexOffset, sInd, eInd; - int32_t CritMax=0; - int16_t shTotMax=WEBRTC_SPL_WORD16_MIN; - size_t bestIndex=0; - int16_t bestGain=0; - size_t indexNew; - int16_t CritNewSh; - int32_t CritNew; - int32_t *cDotPtr; - size_t noOfZeros; - int16_t *gainPtr; - int32_t t32, tmpW32; - int16_t *WebRtcIlbcfix_kGainSq5_ptr; - /* Stack based */ - int16_t CBbuf[CB_MEML+LPC_FILTERORDER+CB_HALFFILTERLEN]; - int32_t cDot[128]; - int32_t Crit[128]; - int16_t targetVec[SUBL+LPC_FILTERORDER]; - int16_t cbvectors[CB_MEML + 1]; /* Adding one extra position for - Coverity warnings. */ - int16_t codedVec[SUBL]; - int16_t interpSamples[20*4]; - int16_t interpSamplesFilt[20*4]; - int16_t energyW16[CB_EXPAND*128]; - int16_t energyShifts[CB_EXPAND*128]; - int16_t *inverseEnergy=energyW16; /* Reuse memory */ - int16_t *inverseEnergyShifts=energyShifts; /* Reuse memory */ - int16_t *buf = &CBbuf[LPC_FILTERORDER]; - int16_t *target = &targetVec[LPC_FILTERORDER]; - int16_t *aug_vec = (int16_t*)cDot; /* length [SUBL], reuse memory */ - - /* Determine size of codebook sections */ - - base_size=lMem-lTarget+1; - if (lTarget==SUBL) { - base_size=lMem-19; - } - - /* weighting of the CB memory */ - noOfZeros=lMem-WebRtcIlbcfix_kFilterRange[block]; - WebRtcSpl_MemSetW16(&buf[-LPC_FILTERORDER], 0, noOfZeros+LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - decResidual+noOfZeros, buf+noOfZeros, - weightDenum, LPC_FILTERORDER+1, WebRtcIlbcfix_kFilterRange[block]); - - /* weighting of the target vector */ - WEBRTC_SPL_MEMCPY_W16(&target[-LPC_FILTERORDER], buf+noOfZeros+WebRtcIlbcfix_kFilterRange[block]-LPC_FILTERORDER, LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - intarget, target, - weightDenum, LPC_FILTERORDER+1, lTarget); - - /* Store target, towards the end codedVec is calculated as - the initial target minus the remaining target */ - WEBRTC_SPL_MEMCPY_W16(codedVec, target, lTarget); - - /* Find the highest absolute value to calculate proper - vector scale factor (so that it uses 12 bits) */ - temp1 = WebRtcSpl_MaxAbsValueW16(buf, lMem); - temp2 = WebRtcSpl_MaxAbsValueW16(target, lTarget); - - if ((temp1>0)&&(temp2>0)) { - temp1 = WEBRTC_SPL_MAX(temp1, temp2); - scale = WebRtcSpl_GetSizeInBits((uint32_t)(temp1 * temp1)); - } else { - /* temp1 or temp2 is negative (maximum was -32768) */ - scale = 30; - } - - /* Scale to so that a mul-add 40 times does not overflow */ - scale = scale - 25; - scale = WEBRTC_SPL_MAX(0, scale); - - /* Compute energy of the original target */ - targetEner = WebRtcSpl_DotProductWithScale(target, target, lTarget, scale); - - /* Prepare search over one more codebook section. This section - is created by filtering the original buffer with a filter. */ - WebRtcIlbcfix_FilteredCbVecs(cbvectors, buf, lMem, WebRtcIlbcfix_kFilterRange[block]); - - range = WebRtcIlbcfix_kSearchRange[block][0]; - - if(lTarget == SUBL) { - /* Create the interpolated samples and store them for use in all stages */ - - /* First section, non-filtered half of the cb */ - WebRtcIlbcfix_InterpolateSamples(interpSamples, buf, lMem); - - /* Second section, filtered half of the cb */ - WebRtcIlbcfix_InterpolateSamples(interpSamplesFilt, cbvectors, lMem); - - /* Compute the CB vectors' energies for the first cb section (non-filtered) */ - WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamples, buf, - scale, 20, energyW16, energyShifts); - - /* Compute the CB vectors' energies for the second cb section (filtered cb) */ - WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors, scale, - base_size + 20, energyW16, - energyShifts); - - /* Compute the CB vectors' energies and store them in the vector - * energyW16. Also the corresponding shift values are stored. The - * energy values are used in all three stages. */ - WebRtcIlbcfix_CbMemEnergy(range, buf, cbvectors, lMem, - lTarget, energyW16+20, energyShifts+20, scale, base_size); - - } else { - /* Compute the CB vectors' energies and store them in the vector - * energyW16. Also the corresponding shift values are stored. The - * energy values are used in all three stages. */ - WebRtcIlbcfix_CbMemEnergy(range, buf, cbvectors, lMem, - lTarget, energyW16, energyShifts, scale, base_size); - - /* Set the energy positions 58-63 and 122-127 to zero - (otherwise they are uninitialized) */ - WebRtcSpl_MemSetW16(energyW16+range, 0, (base_size-range)); - WebRtcSpl_MemSetW16(energyW16+range+base_size, 0, (base_size-range)); - } - - /* Calculate Inverse Energy (energyW16 is already normalized - and will contain the inverse energy in Q29 after this call */ - WebRtcIlbcfix_EnergyInverse(energyW16, base_size*CB_EXPAND); - - /* The gain value computed in the previous stage is used - * as an upper limit to what the next stage gain value - * is allowed to be. In stage 0, 16384 (1.0 in Q14) is used as - * the upper limit. */ - gains[0] = 16384; - - for (stage=0; stage> 1) > bestIndex) ? - 0 : (bestIndex - (CB_RESRANGE >> 1)); - eInd=sInd+CB_RESRANGE; - if (eInd>=range) { - eInd=range-1; - sInd=eInd-CB_RESRANGE; - } - - range = WebRtcIlbcfix_kSearchRange[block][stage]; - - if (lTarget==SUBL) { - i=sInd; - if (sInd<20) { - WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors + lMem, - interpSamplesFilt, cDot, sInd + 20, - WEBRTC_SPL_MIN(39, (eInd + 20)), scale); - i=20; - cDotPtr = &cDot[20 - sInd]; - } else { - cDotPtr = cDot; - } - - cb_vecPtr = cbvectors+lMem-20-i; - - /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, - eInd - i + 1, scale, -1); - - } else { - cDotPtr = cDot; - cb_vecPtr = cbvectors+lMem-lTarget-sInd; - - /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, - eInd - sInd + 1, scale, -1); - - } - - /* Adjust the search range for the augmented vectors */ - indexOffset=base_size+sInd; - - /* Search for best index in this part of the vector */ - WebRtcIlbcfix_CbSearchCore( - cDot, eInd-sInd+1, stage, inverseEnergy+indexOffset, - inverseEnergyShifts+indexOffset, Crit, - &indexNew, &CritNew, &CritNewSh); - - /* Update the global best index and the corresponding gain */ - WebRtcIlbcfix_CbUpdateBestIndex( - CritNew, CritNewSh, indexNew+indexOffset, cDot[indexNew], - inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset], - &CritMax, &shTotMax, &bestIndex, &bestGain); - - index[stage] = (int16_t)bestIndex; - - - bestGain = WebRtcIlbcfix_GainQuant(bestGain, - (int16_t)WEBRTC_SPL_ABS_W16(gains[stage]), stage, &gain_index[stage]); - - /* Extract the best (according to measure) codebook vector - Also adjust the index, so that the augmented vectors are last. - Above these vectors were first... - */ - - if(lTarget==(STATE_LEN-iLBCenc_inst->state_short_len)) { - - if((size_t)index[stage]=20) { - /* Adjust index and extract vector */ - index[stage]-=20; - pp=buf+lMem-lTarget-index[stage]; - } else { - /* Adjust index and extract vector */ - index[stage]+=(int16_t)(base_size-20); - - WebRtcIlbcfix_CreateAugmentedVec(index[stage]-base_size+40, - buf+lMem, aug_vec); - pp = aug_vec; - - } - } else { - - if ((index[stage] - base_size) >= 20) { - /* Adjust index and extract vector */ - index[stage]-=20; - pp=cbvectors+lMem-lTarget- - index[stage]+base_size; - } else { - /* Adjust index and extract vector */ - index[stage]+=(int16_t)(base_size-20); - WebRtcIlbcfix_CreateAugmentedVec(index[stage]-2*base_size+40, - cbvectors+lMem, aug_vec); - pp = aug_vec; - } - } - } - - /* Subtract the best codebook vector, according - to measure, from the target vector */ - - WebRtcSpl_AddAffineVectorToVector(target, pp, (int16_t)(-bestGain), - (int32_t)8192, (int16_t)14, lTarget); - - /* record quantized gain */ - gains[stage+1] = bestGain; - - } /* end of Main Loop. for (stage=0;... */ - - /* Calculte the coded vector (original target - what's left) */ - for (i=0;i> 14); - - targetEner = (int16_t)WEBRTC_SPL_SHIFT_W32(targetEner, -bits) * tmp; - - tmpW32 = ((int32_t)(gains[1]-1))<<1; - - /* Pointer to the table that contains - gain_sq5TblFIX * gain_sq5TblFIX in Q14 */ - gainPtr=(int16_t*)WebRtcIlbcfix_kGainSq5Sq+gain_index[0]; - temp1 = (int16_t)WEBRTC_SPL_SHIFT_W32(codedEner, -bits); - - WebRtcIlbcfix_kGainSq5_ptr = (int16_t*)&WebRtcIlbcfix_kGainSq5[j]; - - /* targetEner and codedEner are in Q(-2*scale) */ - for (ii=gain_index[0];ii<32;ii++) { - - /* Change the index if - (codedEnergy*gainTbl[i]*gainTbl[i])<(targetEn*gain[0]*gain[0]) AND - gainTbl[i] < 2*gain[0] - */ - - t32 = temp1 * *gainPtr; - t32 = t32 - targetEner; - if (t32 < 0) { - if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) { - j=ii; - WebRtcIlbcfix_kGainSq5_ptr = (int16_t*)&WebRtcIlbcfix_kGainSq5[ii]; - } - } - gainPtr++; - } - gain_index[0]=j; - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/cb_search.h b/modules/audio_coding/codecs/ilbc/cb_search.h deleted file mode 100644 index 11856649e7..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_search.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearch.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_CbSearch( - IlbcEncoder* iLBCenc_inst, - /* (i) the encoder state structure */ - int16_t* index, /* (o) Codebook indices */ - int16_t* gain_index, /* (o) Gain quantization indices */ - int16_t* intarget, /* (i) Target vector for encoding */ - int16_t* decResidual, /* (i) Decoded residual for codebook construction */ - size_t lMem, /* (i) Length of buffer */ - size_t lTarget, /* (i) Length of vector */ - int16_t* weightDenum, /* (i) weighting filter coefficients in Q12 */ - size_t block /* (i) the subblock number */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_search_core.c b/modules/audio_coding/codecs/ilbc/cb_search_core.c deleted file mode 100644 index a75e5b0ab8..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_search_core.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearchCore.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_search_core.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_CbSearchCore( - int32_t *cDot, /* (i) Cross Correlation */ - size_t range, /* (i) Search range */ - int16_t stage, /* (i) Stage of this search */ - int16_t *inverseEnergy, /* (i) Inversed energy */ - int16_t *inverseEnergyShift, /* (i) Shifts of inversed energy - with the offset 2*16-29 */ - int32_t *Crit, /* (o) The criteria */ - size_t *bestIndex, /* (o) Index that corresponds to - maximum criteria (in this - vector) */ - int32_t *bestCrit, /* (o) Value of critera for the - chosen index */ - int16_t *bestCritSh) /* (o) The domain of the chosen - criteria */ -{ - int32_t maxW32, tmp32; - int16_t max, sh, tmp16; - size_t i; - int32_t *cDotPtr; - int16_t cDotSqW16; - int16_t *inverseEnergyPtr; - int32_t *critPtr; - int16_t *inverseEnergyShiftPtr; - - /* Don't allow negative values for stage 0 */ - if (stage==0) { - cDotPtr=cDot; - for (i=0;i> 16); - cDotSqW16 = (int16_t)(((int32_t)(tmp16)*(tmp16))>>16); - - /* Calculate the criteria (cDot*cDot/energy) */ - *critPtr = cDotSqW16 * *inverseEnergyPtr; - - /* Extract the maximum shift value under the constraint - that the criteria is not zero */ - if ((*critPtr)!=0) { - max = WEBRTC_SPL_MAX((*inverseEnergyShiftPtr), max); - } - - inverseEnergyPtr++; - inverseEnergyShiftPtr++; - critPtr++; - cDotPtr++; - } - - /* If no max shifts still at initialization value, set shift to zero */ - if (max==WEBRTC_SPL_WORD16_MIN) { - max = 0; - } - - /* Modify the criterias, so that all of them use the same Q domain */ - critPtr=Crit; - inverseEnergyShiftPtr=inverseEnergyShift; - for (i=0;i31) */ - tmp16 = WEBRTC_SPL_MIN(16, max-(*inverseEnergyShiftPtr)); - - (*critPtr)=WEBRTC_SPL_SHIFT_W32((*critPtr),-tmp16); - critPtr++; - inverseEnergyShiftPtr++; - } - - /* Find the index of the best value */ - *bestIndex = WebRtcSpl_MaxIndexW32(Crit, range); - *bestCrit = Crit[*bestIndex]; - - /* Calculate total shifts of this criteria */ - *bestCritSh = 32 - 2*sh + max; - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/cb_search_core.h b/modules/audio_coding/codecs/ilbc/cb_search_core.h deleted file mode 100644 index 5a3b13e446..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_search_core.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearchCore.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ - -#include -#include - -void WebRtcIlbcfix_CbSearchCore( - int32_t* cDot, /* (i) Cross Correlation */ - size_t range, /* (i) Search range */ - int16_t stage, /* (i) Stage of this search */ - int16_t* inverseEnergy, /* (i) Inversed energy */ - int16_t* inverseEnergyShift, /* (i) Shifts of inversed energy - with the offset 2*16-29 */ - int32_t* Crit, /* (o) The criteria */ - size_t* bestIndex, /* (o) Index that corresponds to - maximum criteria (in this - vector) */ - int32_t* bestCrit, /* (o) Value of critera for the - chosen index */ - int16_t* bestCritSh); /* (o) The domain of the chosen - criteria */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/cb_update_best_index.c b/modules/audio_coding/codecs/ilbc/cb_update_best_index.c deleted file mode 100644 index d6fa4d93d4..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_update_best_index.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbUpdateBestIndex.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/cb_update_best_index.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_CbUpdateBestIndex( - int32_t CritNew, /* (i) New Potentially best Criteria */ - int16_t CritNewSh, /* (i) Shift value of above Criteria */ - size_t IndexNew, /* (i) Index of new Criteria */ - int32_t cDotNew, /* (i) Cross dot of new index */ - int16_t invEnergyNew, /* (i) Inversed energy new index */ - int16_t energyShiftNew, /* (i) Energy shifts of new index */ - int32_t *CritMax, /* (i/o) Maximum Criteria (so far) */ - int16_t *shTotMax, /* (i/o) Shifts of maximum criteria */ - size_t *bestIndex, /* (i/o) Index that corresponds to - maximum criteria */ - int16_t *bestGain) /* (i/o) Gain in Q14 that corresponds - to maximum criteria */ -{ - int16_t shOld, shNew, tmp16; - int16_t scaleTmp; - int32_t gainW32; - - /* Normalize the new and old Criteria to the same domain */ - if (CritNewSh>(*shTotMax)) { - shOld=WEBRTC_SPL_MIN(31,CritNewSh-(*shTotMax)); - shNew=0; - } else { - shOld=0; - shNew=WEBRTC_SPL_MIN(31,(*shTotMax)-CritNewSh); - } - - /* Compare the two criterias. If the new one is better, - calculate the gain and store this index as the new best one - */ - - if ((CritNew >> shNew) > (*CritMax >> shOld)) { - - tmp16 = (int16_t)WebRtcSpl_NormW32(cDotNew); - tmp16 = 16 - tmp16; - - /* Calculate the gain in Q14 - Compensate for inverseEnergyshift in Q29 and that the energy - value was stored in a int16_t (shifted down 16 steps) - => 29-14+16 = 31 */ - - scaleTmp = -energyShiftNew-tmp16+31; - scaleTmp = WEBRTC_SPL_MIN(31, scaleTmp); - - gainW32 = ((int16_t)WEBRTC_SPL_SHIFT_W32(cDotNew, -tmp16) * invEnergyNew) >> - scaleTmp; - - /* Check if criteria satisfies Gain criteria (max 1.3) - if it is larger set the gain to 1.3 - (slightly different from FLP version) - */ - if (gainW32>21299) { - *bestGain=21299; - } else if (gainW32<-21299) { - *bestGain=-21299; - } else { - *bestGain=(int16_t)gainW32; - } - - *CritMax=CritNew; - *shTotMax=CritNewSh; - *bestIndex = IndexNew; - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h b/modules/audio_coding/codecs/ilbc/cb_update_best_index.h deleted file mode 100644 index 1a95d531e9..0000000000 --- a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbUpdateBestIndex.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ - -#include -#include - -void WebRtcIlbcfix_CbUpdateBestIndex( - int32_t CritNew, /* (i) New Potentially best Criteria */ - int16_t CritNewSh, /* (i) Shift value of above Criteria */ - size_t IndexNew, /* (i) Index of new Criteria */ - int32_t cDotNew, /* (i) Cross dot of new index */ - int16_t invEnergyNew, /* (i) Inversed energy new index */ - int16_t energyShiftNew, /* (i) Energy shifts of new index */ - int32_t* CritMax, /* (i/o) Maximum Criteria (so far) */ - int16_t* shTotMax, /* (i/o) Shifts of maximum criteria */ - size_t* bestIndex, /* (i/o) Index that corresponds to - maximum criteria */ - int16_t* bestGain); /* (i/o) Gain in Q14 that corresponds - to maximum criteria */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/chebyshev.c b/modules/audio_coding/codecs/ilbc/chebyshev.c deleted file mode 100644 index b4eee66219..0000000000 --- a/modules/audio_coding/codecs/ilbc/chebyshev.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Chebyshev.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/chebyshev.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*------------------------------------------------------------------* - * Calculate the Chevyshev polynomial series - * F(w) = 2*exp(-j5w)*C(x) - * C(x) = (T_0(x) + f(1)T_1(x) + ... + f(4)T_1(x) + f(5)/2) - * T_i(x) is the i:th order Chebyshev polynomial - *------------------------------------------------------------------*/ - -int16_t WebRtcIlbcfix_Chebyshev( - /* (o) Result of C(x) */ - int16_t x, /* (i) Value to the Chevyshev polynomial */ - int16_t *f /* (i) The coefficients in the polynomial */ - ) { - int16_t b1_high, b1_low; /* Use the high, low format to increase the accuracy */ - int32_t b2; - int32_t tmp1W32; - int32_t tmp2W32; - int i; - - b2 = (int32_t)0x1000000; /* b2 = 1.0 (Q23) */ - /* Calculate b1 = 2*x + f[1] */ - tmp1W32 = (x << 10) + (f[1] << 14); - - for (i = 2; i < 5; i++) { - tmp2W32 = tmp1W32; - - /* Split b1 (in tmp1W32) into a high and low part */ - b1_high = (int16_t)(tmp1W32 >> 16); - b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1); - - /* Calculate 2*x*b1-b2+f[i] */ - tmp1W32 = ((b1_high * x + ((b1_low * x) >> 15)) << 2) - b2 + (f[i] << 14); - - /* Update b2 for next round */ - b2 = tmp2W32; - } - - /* Split b1 (in tmp1W32) into a high and low part */ - b1_high = (int16_t)(tmp1W32 >> 16); - b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1); - - /* tmp1W32 = x*b1 - b2 + f[i]/2 */ - tmp1W32 = ((b1_high * x) << 1) + (((b1_low * x) >> 15) << 1) - - b2 + (f[i] << 13); - - /* Handle overflows and set to maximum or minimum int16_t instead */ - if (tmp1W32>((int32_t)33553408)) { - return(WEBRTC_SPL_WORD16_MAX); - } else if (tmp1W32<((int32_t)-33554432)) { - return(WEBRTC_SPL_WORD16_MIN); - } else { - return (int16_t)(tmp1W32 >> 10); - } -} diff --git a/modules/audio_coding/codecs/ilbc/chebyshev.h b/modules/audio_coding/codecs/ilbc/chebyshev.h deleted file mode 100644 index 8ba82927b8..0000000000 --- a/modules/audio_coding/codecs/ilbc/chebyshev.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Chebyshev.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ - -#include -#include - -/*------------------------------------------------------------------* - * Calculate the Chevyshev polynomial series - * F(w) = 2*exp(-j5w)*C(x) - * C(x) = (T_0(x) + f(1)T_1(x) + ... + f(4)T_1(x) + f(5)/2) - * T_i(x) is the i:th order Chebyshev polynomial - *------------------------------------------------------------------*/ - -int16_t WebRtcIlbcfix_Chebyshev( - /* (o) Result of C(x) */ - int16_t x, /* (i) Value to the Chevyshev polynomial */ - int16_t* f /* (i) The coefficients in the polynomial */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/comp_corr.c b/modules/audio_coding/codecs/ilbc/comp_corr.c deleted file mode 100644 index 452bc78e3b..0000000000 --- a/modules/audio_coding/codecs/ilbc/comp_corr.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CompCorr.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/comp_corr.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Compute cross correlation and pitch gain for pitch prediction - * of last subframe at given lag. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CompCorr( - int32_t *corr, /* (o) cross correlation */ - int32_t *ener, /* (o) energy */ - int16_t *buffer, /* (i) signal buffer */ - size_t lag, /* (i) pitch lag */ - size_t bLen, /* (i) length of buffer */ - size_t sRange, /* (i) correlation search length */ - int16_t scale /* (i) number of rightshifts to use */ - ){ - int16_t *w16ptr; - - w16ptr=&buffer[bLen-sRange-lag]; - - /* Calculate correlation and energy */ - (*corr)=WebRtcSpl_DotProductWithScale(&buffer[bLen-sRange], w16ptr, sRange, scale); - (*ener)=WebRtcSpl_DotProductWithScale(w16ptr, w16ptr, sRange, scale); - - /* For zero energy set the energy to 0 in order to avoid potential - problems for coming divisions */ - if (*ener == 0) { - *corr = 0; - *ener = 1; - } -} diff --git a/modules/audio_coding/codecs/ilbc/comp_corr.h b/modules/audio_coding/codecs/ilbc/comp_corr.h deleted file mode 100644 index d9df9a78f8..0000000000 --- a/modules/audio_coding/codecs/ilbc/comp_corr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CompCorr.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Compute cross correlation and pitch gain for pitch prediction - * of last subframe at given lag. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CompCorr(int32_t* corr, /* (o) cross correlation */ - int32_t* ener, /* (o) energy */ - int16_t* buffer, /* (i) signal buffer */ - size_t lag, /* (i) pitch lag */ - size_t bLen, /* (i) length of buffer */ - size_t sRange, /* (i) correlation search length */ - int16_t scale /* (i) number of rightshifts to use */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/complexityMeasures.m b/modules/audio_coding/codecs/ilbc/complexityMeasures.m deleted file mode 100644 index 4bda83622f..0000000000 --- a/modules/audio_coding/codecs/ilbc/complexityMeasures.m +++ /dev/null @@ -1,57 +0,0 @@ -% % Copyright(c) 2011 The WebRTC project authors.All Rights Reserved.% - % Use of this source code is governed by a BSD - - - style license % that can be found in the LICENSE file in the root of the source - % tree.An additional intellectual property rights grant can be found - % in the file PATENTS.All contributing project authors may - % be found in the AUTHORS file in the root of the source tree.% - - clear; -pack; -% -% Enter the path to YOUR executable and remember to define the perprocessor -% variable PRINT_MIPS te get the instructions printed to the screen. -% -command = '!iLBCtest.exe 30 speechAndBGnoise.pcm out1.bit out1.pcm tlm10_30ms.dat'; -cout=' > st.txt'; %saves to matlab variable 'st' -eval(strcat(command,cout)); -if(length(cout)>3) - load st.txt -else - disp('No cout file to load') -end - -% initialize vector to zero -index = find(st(1:end,1)==-1); -indexnonzero = find(st(1:end,1)>0); -frames = length(index)-indexnonzero(1)+1; -start = indexnonzero(1) - 1; -functionOrder=max(st(:,2)); -new=zeros(frames,functionOrder); - -for i = 1:frames, - for j = index(start-1+i)+1:(index(start+i)-1), - new(i,st(j,2)) = new(i,st(j,2)) + st(j,1); - end -end - -result=zeros(functionOrder,3); -for i=1:functionOrder - nonzeroelements = find(new(1:end,i)>0); - result(i,1)=i; - - % Compute each function's mean complexity - % result(i,2)=(sum(new(nonzeroelements,i))/(length(nonzeroelements)*0.03))/1000000; - - % Compute each function's maximum complexity in encoding - % and decoding respectively and then add it together: - % result(i,3)=(max(new(1:end,i))/0.03)/1000000; - 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; -end - -result - -% Compute maximum complexity for a single frame (enc/dec separately and together) -maxEncComplexityInAFrame = (max(sum(new(1:size(new,1)/2,:),2))/0.03)/1000000 -maxDecComplexityInAFrame = (max(sum(new(size(new,1)/2+1:end,:),2))/0.03)/1000000 -totalComplexity = maxEncComplexityInAFrame + maxDecComplexityInAFrame diff --git a/modules/audio_coding/codecs/ilbc/constants.c b/modules/audio_coding/codecs/ilbc/constants.c deleted file mode 100644 index 22f2acb330..0000000000 --- a/modules/audio_coding/codecs/ilbc/constants.c +++ /dev/null @@ -1,667 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - constants.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/constants.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/* HP Filters {b[0] b[1] b[2] -a[1] -a[2]} */ - -const int16_t WebRtcIlbcfix_kHpInCoefs[5] = {3798, -7596, 3798, 7807, -3733}; -const int16_t WebRtcIlbcfix_kHpOutCoefs[5] = {3849, -7699, 3849, 7918, -3833}; - -/* Window in Q11 to window the energies of the 5 choises (3 for 20ms) in the choise for - the 80 sample start state -*/ -const int16_t WebRtcIlbcfix_kStartSequenceEnrgWin[NSUB_MAX-1]= { - 1638, 1843, 2048, 1843, 1638 -}; - -/* LP Filter coeffs used for downsampling */ -const int16_t WebRtcIlbcfix_kLpFiltCoefs[FILTERORDER_DS_PLUS1]= { - -273, 512, 1297, 1696, 1297, 512, -273 -}; - -/* Constants used in the LPC calculations */ - -/* Hanning LPC window (in Q15) */ -const int16_t WebRtcIlbcfix_kLpcWin[BLOCKL_MAX] = { - 6, 22, 50, 89, 139, 200, 272, 355, 449, 554, 669, 795, - 932, 1079, 1237, 1405, 1583, 1771, 1969, 2177, 2395, 2622, 2858, 3104, - 3359, 3622, 3894, 4175, 4464, 4761, 5066, 5379, 5699, 6026, 6361, 6702, - 7050, 7404, 7764, 8130, 8502, 8879, 9262, 9649, 10040, 10436, 10836, 11240, - 11647, 12058, 12471, 12887, 13306, 13726, 14148, 14572, 14997, 15423, 15850, 16277, - 16704, 17131, 17558, 17983, 18408, 18831, 19252, 19672, 20089, 20504, 20916, 21325, - 21730, 22132, 22530, 22924, 23314, 23698, 24078, 24452, 24821, 25185, 25542, 25893, - 26238, 26575, 26906, 27230, 27547, 27855, 28156, 28450, 28734, 29011, 29279, 29538, - 29788, 30029, 30261, 30483, 30696, 30899, 31092, 31275, 31448, 31611, 31764, 31906, - 32037, 32158, 32268, 32367, 32456, 32533, 32600, 32655, 32700, 32733, 32755, 32767, - 32767, 32755, 32733, 32700, 32655, 32600, 32533, 32456, 32367, 32268, 32158, 32037, - 31906, 31764, 31611, 31448, 31275, 31092, 30899, 30696, 30483, 30261, 30029, 29788, - 29538, 29279, 29011, 28734, 28450, 28156, 27855, 27547, 27230, 26906, 26575, 26238, - 25893, 25542, 25185, 24821, 24452, 24078, 23698, 23314, 22924, 22530, 22132, 21730, - 21325, 20916, 20504, 20089, 19672, 19252, 18831, 18408, 17983, 17558, 17131, 16704, - 16277, 15850, 15423, 14997, 14572, 14148, 13726, 13306, 12887, 12471, 12058, 11647, - 11240, 10836, 10436, 10040, 9649, 9262, 8879, 8502, 8130, 7764, 7404, 7050, - 6702, 6361, 6026, 5699, 5379, 5066, 4761, 4464, 4175, 3894, 3622, 3359, - 3104, 2858, 2622, 2395, 2177, 1969, 1771, 1583, 1405, 1237, 1079, 932, - 795, 669, 554, 449, 355, 272, 200, 139, 89, 50, 22, 6 -}; - -/* Asymmetric LPC window (in Q15)*/ -const int16_t WebRtcIlbcfix_kLpcAsymWin[BLOCKL_MAX] = { - 2, 7, 15, 27, 42, 60, 81, 106, 135, 166, 201, 239, - 280, 325, 373, 424, 478, 536, 597, 661, 728, 798, 872, 949, - 1028, 1111, 1197, 1287, 1379, 1474, 1572, 1674, 1778, 1885, 1995, 2108, - 2224, 2343, 2465, 2589, 2717, 2847, 2980, 3115, 3254, 3395, 3538, 3684, - 3833, 3984, 4138, 4295, 4453, 4615, 4778, 4944, 5112, 5283, 5456, 5631, - 5808, 5987, 6169, 6352, 6538, 6725, 6915, 7106, 7300, 7495, 7692, 7891, - 8091, 8293, 8497, 8702, 8909, 9118, 9328, 9539, 9752, 9966, 10182, 10398, - 10616, 10835, 11055, 11277, 11499, 11722, 11947, 12172, 12398, 12625, 12852, 13080, - 13309, 13539, 13769, 14000, 14231, 14463, 14695, 14927, 15160, 15393, 15626, 15859, - 16092, 16326, 16559, 16792, 17026, 17259, 17492, 17725, 17957, 18189, 18421, 18653, - 18884, 19114, 19344, 19573, 19802, 20030, 20257, 20483, 20709, 20934, 21157, 21380, - 21602, 21823, 22042, 22261, 22478, 22694, 22909, 23123, 23335, 23545, 23755, 23962, - 24168, 24373, 24576, 24777, 24977, 25175, 25371, 25565, 25758, 25948, 26137, 26323, - 26508, 26690, 26871, 27049, 27225, 27399, 27571, 27740, 27907, 28072, 28234, 28394, - 28552, 28707, 28860, 29010, 29157, 29302, 29444, 29584, 29721, 29855, 29987, 30115, - 30241, 30364, 30485, 30602, 30717, 30828, 30937, 31043, 31145, 31245, 31342, 31436, - 31526, 31614, 31699, 31780, 31858, 31933, 32005, 32074, 32140, 32202, 32261, 32317, - 32370, 32420, 32466, 32509, 32549, 32585, 32618, 32648, 32675, 32698, 32718, 32734, - 32748, 32758, 32764, 32767, 32767, 32667, 32365, 31863, 31164, 30274, 29197, 27939, - 26510, 24917, 23170, 21281, 19261, 17121, 14876, 12540, 10126, 7650, 5126, 2571 -}; - -/* Lag window for LPC (Q31) */ -const int32_t WebRtcIlbcfix_kLpcLagWin[LPC_FILTERORDER + 1]={ - 2147483647, 2144885453, 2137754373, 2125918626, 2109459810, - 2088483140, 2063130336, 2033564590, 1999977009, 1962580174, - 1921610283}; - -/* WebRtcIlbcfix_kLpcChirpSyntDenum vector in Q15 corresponding - * floating point vector {1 0.9025 0.9025^2 0.9025^3 ...} - */ -const int16_t WebRtcIlbcfix_kLpcChirpSyntDenum[LPC_FILTERORDER + 1] = { - 32767, 29573, 26690, 24087, - 21739, 19619, 17707, 15980, - 14422, 13016, 11747}; - -/* WebRtcIlbcfix_kLpcChirpWeightDenum in Q15 corresponding to - * floating point vector {1 0.4222 0.4222^2... } - */ -const int16_t WebRtcIlbcfix_kLpcChirpWeightDenum[LPC_FILTERORDER + 1] = { - 32767, 13835, 5841, 2466, 1041, 440, - 186, 78, 33, 14, 6}; - -/* LSF quantization Q13 domain */ -const int16_t WebRtcIlbcfix_kLsfCb[64 * 3 + 128 * 3 + 128 * 4] = { - 1273, 2238, 3696, - 3199, 5309, 8209, - 3606, 5671, 7829, - 2815, 5262, 8778, - 2608, 4027, 5493, - 1582, 3076, 5945, - 2983, 4181, 5396, - 2437, 4322, 6902, - 1861, 2998, 4613, - 2007, 3250, 5214, - 1388, 2459, 4262, - 2563, 3805, 5269, - 2036, 3522, 5129, - 1935, 4025, 6694, - 2744, 5121, 7338, - 2810, 4248, 5723, - 3054, 5405, 7745, - 1449, 2593, 4763, - 3411, 5128, 6596, - 2484, 4659, 7496, - 1668, 2879, 4818, - 1812, 3072, 5036, - 1638, 2649, 3900, - 2464, 3550, 4644, - 1853, 2900, 4158, - 2458, 4163, 5830, - 2556, 4036, 6254, - 2703, 4432, 6519, - 3062, 4953, 7609, - 1725, 3703, 6187, - 2221, 3877, 5427, - 2339, 3579, 5197, - 2021, 4633, 7037, - 2216, 3328, 4535, - 2961, 4739, 6667, - 2807, 3955, 5099, - 2788, 4501, 6088, - 1642, 2755, 4431, - 3341, 5282, 7333, - 2414, 3726, 5727, - 1582, 2822, 5269, - 2259, 3447, 4905, - 3117, 4986, 7054, - 1825, 3491, 5542, - 3338, 5736, 8627, - 1789, 3090, 5488, - 2566, 3720, 4923, - 2846, 4682, 7161, - 1950, 3321, 5976, - 1834, 3383, 6734, - 3238, 4769, 6094, - 2031, 3978, 5903, - 1877, 4068, 7436, - 2131, 4644, 8296, - 2764, 5010, 8013, - 2194, 3667, 6302, - 2053, 3127, 4342, - 3523, 6595, 10010, - 3134, 4457, 5748, - 3142, 5819, 9414, - 2223, 4334, 6353, - 2022, 3224, 4822, - 2186, 3458, 5544, - 2552, 4757, 6870, - 10905, 12917, 14578, - 9503, 11485, 14485, - 9518, 12494, 14052, - 6222, 7487, 9174, - 7759, 9186, 10506, - 8315, 12755, 14786, - 9609, 11486, 13866, - 8909, 12077, 13643, - 7369, 9054, 11520, - 9408, 12163, 14715, - 6436, 9911, 12843, - 7109, 9556, 11884, - 7557, 10075, 11640, - 6482, 9202, 11547, - 6463, 7914, 10980, - 8611, 10427, 12752, - 7101, 9676, 12606, - 7428, 11252, 13172, - 10197, 12955, 15842, - 7487, 10955, 12613, - 5575, 7858, 13621, - 7268, 11719, 14752, - 7476, 11744, 13795, - 7049, 8686, 11922, - 8234, 11314, 13983, - 6560, 11173, 14984, - 6405, 9211, 12337, - 8222, 12054, 13801, - 8039, 10728, 13255, - 10066, 12733, 14389, - 6016, 7338, 10040, - 6896, 8648, 10234, - 7538, 9170, 12175, - 7327, 12608, 14983, - 10516, 12643, 15223, - 5538, 7644, 12213, - 6728, 12221, 14253, - 7563, 9377, 12948, - 8661, 11023, 13401, - 7280, 8806, 11085, - 7723, 9793, 12333, - 12225, 14648, 16709, - 8768, 13389, 15245, - 10267, 12197, 13812, - 5301, 7078, 11484, - 7100, 10280, 11906, - 8716, 12555, 14183, - 9567, 12464, 15434, - 7832, 12305, 14300, - 7608, 10556, 12121, - 8913, 11311, 12868, - 7414, 9722, 11239, - 8666, 11641, 13250, - 9079, 10752, 12300, - 8024, 11608, 13306, - 10453, 13607, 16449, - 8135, 9573, 10909, - 6375, 7741, 10125, - 10025, 12217, 14874, - 6985, 11063, 14109, - 9296, 13051, 14642, - 8613, 10975, 12542, - 6583, 10414, 13534, - 6191, 9368, 13430, - 5742, 6859, 9260, - 7723, 9813, 13679, - 8137, 11291, 12833, - 6562, 8973, 10641, - 6062, 8462, 11335, - 6928, 8784, 12647, - 7501, 8784, 10031, - 8372, 10045, 12135, - 8191, 9864, 12746, - 5917, 7487, 10979, - 5516, 6848, 10318, - 6819, 9899, 11421, - 7882, 12912, 15670, - 9558, 11230, 12753, - 7752, 9327, 11472, - 8479, 9980, 11358, - 11418, 14072, 16386, - 7968, 10330, 14423, - 8423, 10555, 12162, - 6337, 10306, 14391, - 8850, 10879, 14276, - 6750, 11885, 15710, - 7037, 8328, 9764, - 6914, 9266, 13476, - 9746, 13949, 15519, - 11032, 14444, 16925, - 8032, 10271, 11810, - 10962, 13451, 15833, - 10021, 11667, 13324, - 6273, 8226, 12936, - 8543, 10397, 13496, - 7936, 10302, 12745, - 6769, 8138, 10446, - 6081, 7786, 11719, - 8637, 11795, 14975, - 8790, 10336, 11812, - 7040, 8490, 10771, - 7338, 10381, 13153, - 6598, 7888, 9358, - 6518, 8237, 12030, - 9055, 10763, 12983, - 6490, 10009, 12007, - 9589, 12023, 13632, - 6867, 9447, 10995, - 7930, 9816, 11397, - 10241, 13300, 14939, - 5830, 8670, 12387, - 9870, 11915, 14247, - 9318, 11647, 13272, - 6721, 10836, 12929, - 6543, 8233, 9944, - 8034, 10854, 12394, - 9112, 11787, 14218, - 9302, 11114, 13400, - 9022, 11366, 13816, - 6962, 10461, 12480, - 11288, 13333, 15222, - 7249, 8974, 10547, - 10566, 12336, 14390, - 6697, 11339, 13521, - 11851, 13944, 15826, - 6847, 8381, 11349, - 7509, 9331, 10939, - 8029, 9618, 11909, - 13973, 17644, 19647, 22474, - 14722, 16522, 20035, 22134, - 16305, 18179, 21106, 23048, - 15150, 17948, 21394, 23225, - 13582, 15191, 17687, 22333, - 11778, 15546, 18458, 21753, - 16619, 18410, 20827, 23559, - 14229, 15746, 17907, 22474, - 12465, 15327, 20700, 22831, - 15085, 16799, 20182, 23410, - 13026, 16935, 19890, 22892, - 14310, 16854, 19007, 22944, - 14210, 15897, 18891, 23154, - 14633, 18059, 20132, 22899, - 15246, 17781, 19780, 22640, - 16396, 18904, 20912, 23035, - 14618, 17401, 19510, 21672, - 15473, 17497, 19813, 23439, - 18851, 20736, 22323, 23864, - 15055, 16804, 18530, 20916, - 16490, 18196, 19990, 21939, - 11711, 15223, 21154, 23312, - 13294, 15546, 19393, 21472, - 12956, 16060, 20610, 22417, - 11628, 15843, 19617, 22501, - 14106, 16872, 19839, 22689, - 15655, 18192, 20161, 22452, - 12953, 15244, 20619, 23549, - 15322, 17193, 19926, 21762, - 16873, 18676, 20444, 22359, - 14874, 17871, 20083, 21959, - 11534, 14486, 19194, 21857, - 17766, 19617, 21338, 23178, - 13404, 15284, 19080, 23136, - 15392, 17527, 19470, 21953, - 14462, 16153, 17985, 21192, - 17734, 19750, 21903, 23783, - 16973, 19096, 21675, 23815, - 16597, 18936, 21257, 23461, - 15966, 17865, 20602, 22920, - 15416, 17456, 20301, 22972, - 18335, 20093, 21732, 23497, - 15548, 17217, 20679, 23594, - 15208, 16995, 20816, 22870, - 13890, 18015, 20531, 22468, - 13211, 15377, 19951, 22388, - 12852, 14635, 17978, 22680, - 16002, 17732, 20373, 23544, - 11373, 14134, 19534, 22707, - 17329, 19151, 21241, 23462, - 15612, 17296, 19362, 22850, - 15422, 19104, 21285, 23164, - 13792, 17111, 19349, 21370, - 15352, 17876, 20776, 22667, - 15253, 16961, 18921, 22123, - 14108, 17264, 20294, 23246, - 15785, 17897, 20010, 21822, - 17399, 19147, 20915, 22753, - 13010, 15659, 18127, 20840, - 16826, 19422, 22218, 24084, - 18108, 20641, 22695, 24237, - 18018, 20273, 22268, 23920, - 16057, 17821, 21365, 23665, - 16005, 17901, 19892, 23016, - 13232, 16683, 21107, 23221, - 13280, 16615, 19915, 21829, - 14950, 18575, 20599, 22511, - 16337, 18261, 20277, 23216, - 14306, 16477, 21203, 23158, - 12803, 17498, 20248, 22014, - 14327, 17068, 20160, 22006, - 14402, 17461, 21599, 23688, - 16968, 18834, 20896, 23055, - 15070, 17157, 20451, 22315, - 15419, 17107, 21601, 23946, - 16039, 17639, 19533, 21424, - 16326, 19261, 21745, 23673, - 16489, 18534, 21658, 23782, - 16594, 18471, 20549, 22807, - 18973, 21212, 22890, 24278, - 14264, 18674, 21123, 23071, - 15117, 16841, 19239, 23118, - 13762, 15782, 20478, 23230, - 14111, 15949, 20058, 22354, - 14990, 16738, 21139, 23492, - 13735, 16971, 19026, 22158, - 14676, 17314, 20232, 22807, - 16196, 18146, 20459, 22339, - 14747, 17258, 19315, 22437, - 14973, 17778, 20692, 23367, - 15715, 17472, 20385, 22349, - 15702, 18228, 20829, 23410, - 14428, 16188, 20541, 23630, - 16824, 19394, 21365, 23246, - 13069, 16392, 18900, 21121, - 12047, 16640, 19463, 21689, - 14757, 17433, 19659, 23125, - 15185, 16930, 19900, 22540, - 16026, 17725, 19618, 22399, - 16086, 18643, 21179, 23472, - 15462, 17248, 19102, 21196, - 17368, 20016, 22396, 24096, - 12340, 14475, 19665, 23362, - 13636, 16229, 19462, 22728, - 14096, 16211, 19591, 21635, - 12152, 14867, 19943, 22301, - 14492, 17503, 21002, 22728, - 14834, 16788, 19447, 21411, - 14650, 16433, 19326, 22308, - 14624, 16328, 19659, 23204, - 13888, 16572, 20665, 22488, - 12977, 16102, 18841, 22246, - 15523, 18431, 21757, 23738, - 14095, 16349, 18837, 20947, - 13266, 17809, 21088, 22839, - 15427, 18190, 20270, 23143, - 11859, 16753, 20935, 22486, - 12310, 17667, 21736, 23319, - 14021, 15926, 18702, 22002, - 12286, 15299, 19178, 21126, - 15703, 17491, 21039, 23151, - 12272, 14018, 18213, 22570, - 14817, 16364, 18485, 22598, - 17109, 19683, 21851, 23677, - 12657, 14903, 19039, 22061, - 14713, 16487, 20527, 22814, - 14635, 16726, 18763, 21715, - 15878, 18550, 20718, 22906 -}; - -const int16_t WebRtcIlbcfix_kLsfDimCb[LSF_NSPLIT] = {3, 3, 4}; -const int16_t WebRtcIlbcfix_kLsfSizeCb[LSF_NSPLIT] = {64,128,128}; - -const int16_t WebRtcIlbcfix_kLsfMean[LPC_FILTERORDER] = { - 2308, 3652, 5434, 7885, - 10255, 12559, 15160, 17513, - 20328, 22752}; - -const int16_t WebRtcIlbcfix_kLspMean[LPC_FILTERORDER] = { - 31476, 29565, 25819, 18725, 10276, - 1236, -9049, -17600, -25884, -30618 -}; - -/* Q14 */ -const int16_t WebRtcIlbcfix_kLsfWeight20ms[4] = {12288, 8192, 4096, 0}; -const int16_t WebRtcIlbcfix_kLsfWeight30ms[6] = {8192, 16384, 10923, 5461, 0, 0}; - -/* - cos(x) in Q15 - WebRtcIlbcfix_kCos[i] = cos(pi*i/64.0) - used in WebRtcIlbcfix_Lsp2Lsf() -*/ - -const int16_t WebRtcIlbcfix_kCos[64] = { - 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853, - 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279, - 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010, - 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608, - 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039, - -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006, - -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622, - -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729 -}; - -/* - Derivative in Q19, used to interpolate between the - WebRtcIlbcfix_kCos[] values to get a more exact y = cos(x) -*/ -const int16_t WebRtcIlbcfix_kCosDerivative[64] = { - -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261, - -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744, - -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526, - -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726, - -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009, - -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637, - -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428, - -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632}; - -/* - Table in Q15, used for a2lsf conversion - WebRtcIlbcfix_kCosGrid[i] = cos((2*pi*i)/(float)(2*COS_GRID_POINTS)); -*/ - -const int16_t WebRtcIlbcfix_kCosGrid[COS_GRID_POINTS + 1] = { - 32760, 32723, 32588, 32364, 32051, 31651, 31164, 30591, - 29935, 29196, 28377, 27481, 26509, 25465, 24351, 23170, - 21926, 20621, 19260, 17846, 16384, 14876, 13327, 11743, - 10125, 8480, 6812, 5126, 3425, 1714, 0, -1714, -3425, - -5126, -6812, -8480, -10125, -11743, -13327, -14876, - -16384, -17846, -19260, -20621, -21926, -23170, -24351, - -25465, -26509, -27481, -28377, -29196, -29935, -30591, - -31164, -31651, -32051, -32364, -32588, -32723, -32760 -}; - -/* - Derivative of y = acos(x) in Q12 - used in WebRtcIlbcfix_Lsp2Lsf() -*/ - -const int16_t WebRtcIlbcfix_kAcosDerivative[64] = { - -26887, -8812, -5323, -3813, -2979, -2444, -2081, -1811, - -1608, -1450, -1322, -1219, -1132, -1059, -998, -946, - -901, -861, -827, -797, -772, -750, -730, -713, - -699, -687, -677, -668, -662, -657, -654, -652, - -652, -654, -657, -662, -668, -677, -687, -699, - -713, -730, -750, -772, -797, -827, -861, -901, - -946, -998, -1059, -1132, -1219, -1322, -1450, -1608, - -1811, -2081, -2444, -2979, -3813, -5323, -8812, -26887 -}; - - -/* Tables for quantization of start state */ - -/* State quantization tables */ -const int16_t WebRtcIlbcfix_kStateSq3[8] = { /* Values in Q13 */ - -30473, -17838, -9257, -2537, - 3639, 10893, 19958, 32636 -}; - -/* This table defines the limits for the selection of the freqg - less or equal than value 0 => index = 0 - less or equal than value k => index = k -*/ -const int32_t WebRtcIlbcfix_kChooseFrgQuant[64] = { - 118, 163, 222, 305, 425, 604, - 851, 1174, 1617, 2222, 3080, 4191, - 5525, 7215, 9193, 11540, 14397, 17604, - 21204, 25209, 29863, 35720, 42531, 50375, - 59162, 68845, 80108, 93754, 110326, 129488, - 150654, 174328, 201962, 233195, 267843, 308239, - 354503, 405988, 464251, 531550, 608652, 697516, - 802526, 928793, 1080145, 1258120, 1481106, 1760881, - 2111111, 2546619, 3078825, 3748642, 4563142, 5573115, - 6887601, 8582108, 10797296, 14014513, 18625760, 25529599, - 37302935, 58819185, 109782723, WEBRTC_SPL_WORD32_MAX -}; - -const int16_t WebRtcIlbcfix_kScale[64] = { - /* Values in Q16 */ - 29485, 25003, 21345, 18316, 15578, 13128, 10973, 9310, 7955, - 6762, 5789, 4877, 4255, 3699, 3258, 2904, 2595, 2328, - 2123, 1932, 1785, 1631, 1493, 1370, 1260, 1167, 1083, - /* Values in Q21 */ - 32081, 29611, 27262, 25229, 23432, 21803, 20226, 18883, 17609, - 16408, 15311, 14327, 13390, 12513, 11693, 10919, 10163, 9435, - 8739, 8100, 7424, 6813, 6192, 5648, 5122, 4639, 4207, 3798, - 3404, 3048, 2706, 2348, 2036, 1713, 1393, 1087, 747 -}; - -/*frgq in fixpoint, but already computed like this: - for(i=0; i<64; i++){ - a = (pow(10,frgq[i])/4.5); - WebRtcIlbcfix_kFrgQuantMod[i] = round(a); - } - - Value 0 :36 in Q8 - 37:58 in Q5 - 59:63 in Q3 -*/ -const int16_t WebRtcIlbcfix_kFrgQuantMod[64] = { - /* First 37 values in Q8 */ - 569, 671, 786, 916, 1077, 1278, - 1529, 1802, 2109, 2481, 2898, 3440, - 3943, 4535, 5149, 5778, 6464, 7208, - 7904, 8682, 9397, 10285, 11240, 12246, - 13313, 14382, 15492, 16735, 18131, 19693, - 21280, 22912, 24624, 26544, 28432, 30488, - 32720, - /* 22 values in Q5 */ - 4383, 4684, 5012, 5363, 5739, 6146, - 6603, 7113, 7679, 8285, 9040, 9850, - 10838, 11882, 13103, 14467, 15950, 17669, - 19712, 22016, 24800, 28576, - /* 5 values in Q3 */ - 8240, 9792, 12040, 15440, 22472 -}; - -/* Constants for codebook search and creation */ - -/* Expansion filter to get additional cb section. - * Q12 and reversed compared to flp - */ -const int16_t WebRtcIlbcfix_kCbFiltersRev[CB_FILTERLEN]={ - -140, 446, -755, 3302, 2922, -590, 343, -138}; - -/* Weighting coefficients for short lags. - * [0.2 0.4 0.6 0.8] in Q15 */ -const int16_t WebRtcIlbcfix_kAlpha[4]={ - 6554, 13107, 19661, 26214}; - -/* Ranges for search and filters at different subframes */ - -const size_t WebRtcIlbcfix_kSearchRange[5][CB_NSTAGES]={ - {58,58,58}, {108,44,44}, {108,108,108}, {108,108,108}, {108,108,108}}; - -const size_t WebRtcIlbcfix_kFilterRange[5]={63, 85, 125, 147, 147}; - -/* Gain Quantization for the codebook gains of the 3 stages */ - -/* Q14 (one extra value (max int16_t) to simplify for the search) */ -const int16_t WebRtcIlbcfix_kGainSq3[9]={ - -16384, -10813, -5407, 0, 4096, 8192, - 12288, 16384, 32767}; - -/* Q14 (one extra value (max int16_t) to simplify for the search) */ -const int16_t WebRtcIlbcfix_kGainSq4[17]={ - -17203, -14746, -12288, -9830, -7373, -4915, - -2458, 0, 2458, 4915, 7373, 9830, - 12288, 14746, 17203, 19661, 32767}; - -/* Q14 (one extra value (max int16_t) to simplify for the search) */ -const int16_t WebRtcIlbcfix_kGainSq5[33]={ - 614, 1229, 1843, 2458, 3072, 3686, - 4301, 4915, 5530, 6144, 6758, 7373, - 7987, 8602, 9216, 9830, 10445, 11059, - 11674, 12288, 12902, 13517, 14131, 14746, - 15360, 15974, 16589, 17203, 17818, 18432, - 19046, 19661, 32767}; - -/* Q14 gain_sq5Tbl squared in Q14 */ -const int16_t WebRtcIlbcfix_kGainSq5Sq[32] = { - 23, 92, 207, 368, 576, 829, - 1129, 1474, 1866, 2304, 2787, 3317, - 3893, 4516, 5184, 5897, 6658, 7464, - 8318, 9216, 10160, 11151, 12187, 13271, - 14400, 15574, 16796, 18062, 19377, 20736, - 22140, 23593 -}; - -const int16_t* const WebRtcIlbcfix_kGain[3] = -{WebRtcIlbcfix_kGainSq5, WebRtcIlbcfix_kGainSq4, WebRtcIlbcfix_kGainSq3}; - - -/* Tables for the Enhancer, using upsamling factor 4 (ENH_UPS0 = 4) */ - -const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1]={ - {0, 0, 0, 4096, 0, 0, 0}, - {64, -315, 1181, 3531, -436, 77, -64}, - {97, -509, 2464, 2464, -509, 97, -97}, - {77, -436, 3531, 1181, -315, 64, -77} -}; - -const int16_t WebRtcIlbcfix_kEnhWt[3] = { - 4800, 16384, 27968 /* Q16 */ -}; - -const size_t WebRtcIlbcfix_kEnhPlocs[ENH_NBLOCKS_TOT] = { - 160, 480, 800, 1120, 1440, 1760, 2080, 2400 /* Q(-2) */ -}; - -/* PLC table */ - -const int16_t WebRtcIlbcfix_kPlcPerSqr[6] = { /* Grid points for square of periodiciy in Q15 */ - 839, 1343, 2048, 2998, 4247, 5849 -}; - -const int16_t WebRtcIlbcfix_kPlcPitchFact[6] = { /* Value of y=(x^4-0.4)/(0.7-0.4) in grid points in Q15 */ - 0, 5462, 10922, 16384, 21846, 27306 -}; - -const int16_t WebRtcIlbcfix_kPlcPfSlope[6] = { /* Slope of y=(x^4-0.4)/(0.7-0.4) in Q11 */ - 26667, 18729, 13653, 10258, 7901, 6214 -}; diff --git a/modules/audio_coding/codecs/ilbc/constants.h b/modules/audio_coding/codecs/ilbc/constants.h deleted file mode 100644 index a8645c00db..0000000000 --- a/modules/audio_coding/codecs/ilbc/constants.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - constants.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/* high pass filters */ - -extern const int16_t WebRtcIlbcfix_kHpInCoefs[]; -extern const int16_t WebRtcIlbcfix_kHpOutCoefs[]; - -/* Window for start state decision */ -extern const int16_t WebRtcIlbcfix_kStartSequenceEnrgWin[]; - -/* low pass filter used for downsampling */ -extern const int16_t WebRtcIlbcfix_kLpFiltCoefs[]; - -/* LPC analysis and quantization */ - -extern const int16_t WebRtcIlbcfix_kLpcWin[]; -extern const int16_t WebRtcIlbcfix_kLpcAsymWin[]; -extern const int32_t WebRtcIlbcfix_kLpcLagWin[]; -extern const int16_t WebRtcIlbcfix_kLpcChirpSyntDenum[]; -extern const int16_t WebRtcIlbcfix_kLpcChirpWeightDenum[]; -extern const int16_t WebRtcIlbcfix_kLsfDimCb[]; -extern const int16_t WebRtcIlbcfix_kLsfSizeCb[]; -extern const int16_t WebRtcIlbcfix_kLsfCb[]; -extern const int16_t WebRtcIlbcfix_kLsfWeight20ms[]; -extern const int16_t WebRtcIlbcfix_kLsfWeight30ms[]; -extern const int16_t WebRtcIlbcfix_kLsfMean[]; -extern const int16_t WebRtcIlbcfix_kLspMean[]; -extern const int16_t WebRtcIlbcfix_kCos[]; -extern const int16_t WebRtcIlbcfix_kCosDerivative[]; -extern const int16_t WebRtcIlbcfix_kCosGrid[]; -extern const int16_t WebRtcIlbcfix_kAcosDerivative[]; - -/* state quantization tables */ - -extern const int16_t WebRtcIlbcfix_kStateSq3[]; -extern const int32_t WebRtcIlbcfix_kChooseFrgQuant[]; -extern const int16_t WebRtcIlbcfix_kScale[]; -extern const int16_t WebRtcIlbcfix_kFrgQuantMod[]; - -/* Ranges for search and filters at different subframes */ - -extern const size_t WebRtcIlbcfix_kSearchRange[5][CB_NSTAGES]; -extern const size_t WebRtcIlbcfix_kFilterRange[]; - -/* gain quantization tables */ - -extern const int16_t WebRtcIlbcfix_kGainSq3[]; -extern const int16_t WebRtcIlbcfix_kGainSq4[]; -extern const int16_t WebRtcIlbcfix_kGainSq5[]; -extern const int16_t WebRtcIlbcfix_kGainSq5Sq[]; -extern const int16_t* const WebRtcIlbcfix_kGain[]; - -/* adaptive codebook definitions */ - -extern const int16_t WebRtcIlbcfix_kCbFiltersRev[]; -extern const int16_t WebRtcIlbcfix_kAlpha[]; - -/* enhancer definitions */ - -extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0] - [ENH_FLO_MULT2_PLUS1]; -extern const int16_t WebRtcIlbcfix_kEnhWt[]; -extern const size_t WebRtcIlbcfix_kEnhPlocs[]; - -/* PLC tables */ - -extern const int16_t WebRtcIlbcfix_kPlcPerSqr[]; -extern const int16_t WebRtcIlbcfix_kPlcPitchFact[]; -extern const int16_t WebRtcIlbcfix_kPlcPfSlope[]; - -#endif diff --git a/modules/audio_coding/codecs/ilbc/create_augmented_vec.c b/modules/audio_coding/codecs/ilbc/create_augmented_vec.c deleted file mode 100644 index 7e21faee6c..0000000000 --- a/modules/audio_coding/codecs/ilbc/create_augmented_vec.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CreateAugmentedVec.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/create_augmented_vec.h" - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "rtc_base/sanitizer.h" - -/*----------------------------------------------------------------* - * Recreate a specific codebook vector from the augmented part. - * - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CreateAugmentedVec( - size_t index, /* (i) Index for the augmented vector to be - created */ - const int16_t* buffer, /* (i) Pointer to the end of the codebook memory - that is used for creation of the augmented - codebook */ - int16_t* cbVec) { /* (o) The constructed codebook vector */ - size_t ilow; - const int16_t *ppo, *ppi; - int16_t cbVecTmp[4]; - /* Interpolation starts 4 elements before cbVec+index, but must not start - outside `cbVec`; clamping interp_len to stay within `cbVec`. - */ - size_t interp_len = WEBRTC_SPL_MIN(index, 4); - - rtc_MsanCheckInitialized(buffer - index - interp_len, sizeof(buffer[0]), - index + interp_len); - - ilow = index - interp_len; - - /* copy the first noninterpolated part */ - ppo = buffer-index; - WEBRTC_SPL_MEMCPY_W16(cbVec, ppo, index); - - /* interpolation */ - ppo = buffer - interp_len; - ppi = buffer - index - interp_len; - - /* perform cbVec[ilow+k] = ((ppi[k]*alphaTbl[k])>>15) + - ((ppo[k]*alphaTbl[interp_len-1-k])>>15); - for k = 0..interp_len-1 - */ - WebRtcSpl_ElementwiseVectorMult(&cbVec[ilow], ppi, WebRtcIlbcfix_kAlpha, - interp_len, 15); - WebRtcSpl_ReverseOrderMultArrayElements( - cbVecTmp, ppo, &WebRtcIlbcfix_kAlpha[interp_len - 1], interp_len, 15); - WebRtcSpl_AddVectorsAndShift(&cbVec[ilow], &cbVec[ilow], cbVecTmp, interp_len, - 0); - - /* copy the second noninterpolated part */ - ppo = buffer - index; - /* `tempbuff2` is declared in WebRtcIlbcfix_GetCbVec and is SUBL+5 elements - long. `buffer` points one element past the end of that vector, i.e., at - tempbuff2+SUBL+5. Since ppo=buffer-index, we cannot read any more than - `index` elements from `ppo`. - - `cbVec` is declared to be SUBL elements long in WebRtcIlbcfix_CbConstruct. - Therefore, we can only write SUBL-index elements to cbVec+index. - - These two conditions limit the number of elements to copy. - */ - WEBRTC_SPL_MEMCPY_W16(cbVec+index, ppo, WEBRTC_SPL_MIN(SUBL-index, index)); -} diff --git a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h b/modules/audio_coding/codecs/ilbc/create_augmented_vec.h deleted file mode 100644 index 5bed469a12..0000000000 --- a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CreateAugmentedVec.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Recreate a specific codebook vector from the augmented part. - * - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CreateAugmentedVec( - size_t index, /* (i) Index for the augmented vector to be - created */ - const int16_t* buffer, /* (i) Pointer to the end of the codebook memory - that is used for creation of the augmented - codebook */ - int16_t* cbVec); /* (o) The construced codebook vector */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/decode.c b/modules/audio_coding/codecs/ilbc/decode.c deleted file mode 100644 index d7621d5b65..0000000000 --- a/modules/audio_coding/codecs/ilbc/decode.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Decode.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/decode.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/decode_residual.h" -#include "modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/do_plc.h" -#include "modules/audio_coding/codecs/ilbc/enhancer_interface.h" -#include "modules/audio_coding/codecs/ilbc/hp_output.h" -#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h" -#include "modules/audio_coding/codecs/ilbc/init_decode.h" -#include "modules/audio_coding/codecs/ilbc/lsf_check.h" -#include "modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h" -#include "modules/audio_coding/codecs/ilbc/unpack_bits.h" -#include "modules/audio_coding/codecs/ilbc/xcorr_coef.h" -#include "rtc_base/system/arch.h" - -#ifndef WEBRTC_ARCH_BIG_ENDIAN -#include "modules/audio_coding/codecs/ilbc/swap_bytes.h" -#endif - -/*----------------------------------------------------------------* - * main decoder function - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_DecodeImpl( - int16_t *decblock, /* (o) decoded signal block */ - const uint16_t *bytes, /* (i) encoded signal bits */ - IlbcDecoder *iLBCdec_inst, /* (i/o) the decoder state - structure */ - int16_t mode /* (i) 0: bad packet, PLC, - 1: normal */ - ) { - const int old_mode = iLBCdec_inst->mode; - const int old_use_enhancer = iLBCdec_inst->use_enhancer; - - size_t i; - int16_t order_plus_one; - - int16_t last_bit; - int16_t *data; - /* Stack based */ - int16_t decresidual[BLOCKL_MAX]; - int16_t PLCresidual[BLOCKL_MAX + LPC_FILTERORDER]; - int16_t syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)]; - int16_t PLClpc[LPC_FILTERORDER + 1]; -#ifndef WEBRTC_ARCH_BIG_ENDIAN - uint16_t swapped[NO_OF_WORDS_30MS]; -#endif - iLBC_bits *iLBCbits_inst = (iLBC_bits*)PLCresidual; - - /* Reuse some buffers that are non overlapping in order to save stack memory */ - data = &PLCresidual[LPC_FILTERORDER]; - - if (mode) { /* the data are good */ - - /* decode data */ - - /* Unpacketize bits into parameters */ - -#ifndef WEBRTC_ARCH_BIG_ENDIAN - WebRtcIlbcfix_SwapBytes(bytes, iLBCdec_inst->no_of_words, swapped); - last_bit = WebRtcIlbcfix_UnpackBits(swapped, iLBCbits_inst, iLBCdec_inst->mode); -#else - last_bit = WebRtcIlbcfix_UnpackBits(bytes, iLBCbits_inst, iLBCdec_inst->mode); -#endif - - /* Check for bit errors */ - if (iLBCbits_inst->startIdx<1) - mode = 0; - if ((iLBCdec_inst->mode==20) && (iLBCbits_inst->startIdx>3)) - mode = 0; - if ((iLBCdec_inst->mode==30) && (iLBCbits_inst->startIdx>5)) - mode = 0; - if (last_bit==1) - mode = 0; - - if (mode) { /* No bit errors was detected, continue decoding */ - /* Stack based */ - int16_t lsfdeq[LPC_FILTERORDER*LPC_N_MAX]; - int16_t weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - - /* adjust index */ - WebRtcIlbcfix_IndexConvDec(iLBCbits_inst->cb_index); - - /* decode the lsf */ - WebRtcIlbcfix_SimpleLsfDeQ(lsfdeq, (int16_t*)(iLBCbits_inst->lsf), iLBCdec_inst->lpc_n); - WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCdec_inst->lpc_n); - WebRtcIlbcfix_DecoderInterpolateLsp(syntdenum, weightdenum, - lsfdeq, LPC_FILTERORDER, iLBCdec_inst); - - /* Decode the residual using the cb and gain indexes */ - if (!WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, - decresidual, syntdenum)) - goto error; - - /* preparing the plc for a future loss! */ - WebRtcIlbcfix_DoThePlc( - PLCresidual, PLClpc, 0, decresidual, - syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1), - iLBCdec_inst->last_lag, iLBCdec_inst); - - /* Use the output from doThePLC */ - WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); - } - - } - - if (mode == 0) { - /* the data is bad (either a PLC call - * was made or a bit error was detected) - */ - - /* packet loss conceal */ - - WebRtcIlbcfix_DoThePlc(PLCresidual, PLClpc, 1, decresidual, syntdenum, - iLBCdec_inst->last_lag, iLBCdec_inst); - - WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); - - order_plus_one = LPC_FILTERORDER + 1; - - for (i = 0; i < iLBCdec_inst->nsub; i++) { - WEBRTC_SPL_MEMCPY_W16(syntdenum+(i*order_plus_one), - PLClpc, order_plus_one); - } - } - - if ((*iLBCdec_inst).use_enhancer == 1) { /* Enhancer activated */ - - /* Update the filter and filter coefficients if there was a packet loss */ - if (iLBCdec_inst->prev_enh_pl==2) { - for (i=0;insub;i++) { - WEBRTC_SPL_MEMCPY_W16(&(iLBCdec_inst->old_syntdenum[i*(LPC_FILTERORDER+1)]), - syntdenum, (LPC_FILTERORDER+1)); - } - } - - /* post filtering */ - (*iLBCdec_inst).last_lag = - WebRtcIlbcfix_EnhancerInterface(data, decresidual, iLBCdec_inst); - - /* synthesis filtering */ - - /* Set up the filter state */ - WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER); - - if (iLBCdec_inst->mode==20) { - /* Enhancer has 40 samples delay */ - i=0; - WebRtcSpl_FilterARFastQ12( - data, data, - iLBCdec_inst->old_syntdenum + (i+iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - - for (i=1; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum+(i-1)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - - } else if (iLBCdec_inst->mode==30) { - /* Enhancer has 80 samples delay */ - for (i=0; i < 2; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - iLBCdec_inst->old_syntdenum + (i+4)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - for (i=2; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum+(i-2)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - } - - /* Save the filter state */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - - } else { /* Enhancer not activated */ - size_t lag; - - /* Find last lag (since the enhancer is not called to give this info) */ - lag = 20; - if (iLBCdec_inst->mode==20) { - lag = WebRtcIlbcfix_XcorrCoef( - &decresidual[iLBCdec_inst->blockl-60], - &decresidual[iLBCdec_inst->blockl-60-lag], - 60, - 80, lag, -1); - } else { - lag = WebRtcIlbcfix_XcorrCoef( - &decresidual[iLBCdec_inst->blockl-ENH_BLOCKL], - &decresidual[iLBCdec_inst->blockl-ENH_BLOCKL-lag], - ENH_BLOCKL, - 100, lag, -1); - } - - /* Store lag (it is needed if next packet is lost) */ - (*iLBCdec_inst).last_lag = lag; - - /* copy data and run synthesis filter */ - WEBRTC_SPL_MEMCPY_W16(data, decresidual, iLBCdec_inst->blockl); - - /* Set up the filter state */ - WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER); - - for (i=0; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum + i*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - - /* Save the filter state */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - } - - WEBRTC_SPL_MEMCPY_W16(decblock,data,iLBCdec_inst->blockl); - - /* High pass filter the signal (with upscaling a factor 2 and saturation) */ - WebRtcIlbcfix_HpOutput(decblock, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - iLBCdec_inst->blockl); - - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->old_syntdenum, - syntdenum, iLBCdec_inst->nsub*(LPC_FILTERORDER+1)); - - iLBCdec_inst->prev_enh_pl=0; - - if (mode==0) { /* PLC was used */ - iLBCdec_inst->prev_enh_pl=1; - } - - return 0; // Success. - -error: - // The decoder got sick from eating that data. Reset it and return. - WebRtcIlbcfix_InitDecode(iLBCdec_inst, old_mode, old_use_enhancer); - return -1; // Error -} diff --git a/modules/audio_coding/codecs/ilbc/decode.h b/modules/audio_coding/codecs/ilbc/decode.h deleted file mode 100644 index a7d2910115..0000000000 --- a/modules/audio_coding/codecs/ilbc/decode.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Decode.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ - -#include - -#include "absl/base/attributes.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * main decoder function - *---------------------------------------------------------------*/ - -// Returns 0 on success, -1 on error. -ABSL_MUST_USE_RESULT -int WebRtcIlbcfix_DecodeImpl( - int16_t* decblock, /* (o) decoded signal block */ - const uint16_t* bytes, /* (i) encoded signal bits */ - IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state - structure */ - int16_t mode /* (i) 0: bad packet, PLC, - 1: normal */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/decode_residual.c b/modules/audio_coding/codecs/ilbc/decode_residual.c deleted file mode 100644 index a9668e2889..0000000000 --- a/modules/audio_coding/codecs/ilbc/decode_residual.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecodeResidual.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/decode_residual.h" - -#include - -#include "modules/audio_coding/codecs/ilbc/cb_construct.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/do_plc.h" -#include "modules/audio_coding/codecs/ilbc/enhancer_interface.h" -#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h" -#include "modules/audio_coding/codecs/ilbc/lsf_check.h" -#include "modules/audio_coding/codecs/ilbc/state_construct.h" -#include "modules/audio_coding/codecs/ilbc/xcorr_coef.h" - -/*----------------------------------------------------------------* - * frame residual decoder function (subrutine to iLBC_decode) - *---------------------------------------------------------------*/ - -bool WebRtcIlbcfix_DecodeResidual( - IlbcDecoder *iLBCdec_inst, - /* (i/o) the decoder state structure */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used - for the decoding */ - int16_t *decresidual, /* (o) decoded residual frame */ - int16_t *syntdenum /* (i) the decoded synthesis filter - coefficients */ - ) { - size_t meml_gotten, diff, start_pos; - size_t subcount, subframe; - int16_t *reverseDecresidual = iLBCdec_inst->enh_buf; /* Reversed decoded data, used for decoding backwards in time (reuse memory in state) */ - int16_t *memVec = iLBCdec_inst->prevResidual; /* Memory for codebook and filter state (reuse memory in state) */ - int16_t *mem = &memVec[CB_HALFFILTERLEN]; /* Memory for codebook */ - - diff = STATE_LEN - iLBCdec_inst->state_short_len; - - if (iLBC_encbits->state_first == 1) { - start_pos = (iLBC_encbits->startIdx-1)*SUBL; - } else { - start_pos = (iLBC_encbits->startIdx-1)*SUBL + diff; - } - - /* decode scalar part of start state */ - - WebRtcIlbcfix_StateConstruct(iLBC_encbits->idxForMax, - iLBC_encbits->idxVec, &syntdenum[(iLBC_encbits->startIdx-1)*(LPC_FILTERORDER+1)], - &decresidual[start_pos], iLBCdec_inst->state_short_len - ); - - if (iLBC_encbits->state_first) { /* put adaptive part in the end */ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - iLBCdec_inst->state_short_len); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCdec_inst->state_short_len, decresidual+start_pos, - iLBCdec_inst->state_short_len); - - /* construct decoded vector */ - - if (!WebRtcIlbcfix_CbConstruct( - &decresidual[start_pos + iLBCdec_inst->state_short_len], - iLBC_encbits->cb_index, iLBC_encbits->gain_index, - mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, diff)) - return false; // Error. - - } - else {/* put adaptive part in the beginning */ - - /* setup memory */ - - meml_gotten = iLBCdec_inst->state_short_len; - WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, - decresidual+start_pos, meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); - - /* construct decoded vector */ - - if (!WebRtcIlbcfix_CbConstruct(reverseDecresidual, iLBC_encbits->cb_index, - iLBC_encbits->gain_index, - mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, - diff)) - return false; // Error. - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], - reverseDecresidual, diff); - } - - /* counter for predicted subframes */ - - subcount=1; - - /* forward prediction of subframes */ - - if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) { - - /* setup memory */ - WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, - decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN); - - /* loop over subframes to encode */ - - size_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1; - for (subframe=0; subframestartIdx + 1 + subframe) * SUBL], - iLBC_encbits->cb_index + subcount * CB_NSTAGES, - iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, - SUBL)) - return false; // Error; - - /* update memory */ - memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], SUBL); - - subcount++; - } - - } - - /* backward prediction of subframes */ - - if (iLBC_encbits->startIdx > 1) { - - /* setup memory */ - - meml_gotten = SUBL*(iLBCdec_inst->nsub+1-iLBC_encbits->startIdx); - if( meml_gotten > CB_MEML ) { - meml_gotten=CB_MEML; - } - - WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, - decresidual+(iLBC_encbits->startIdx-1)*SUBL, meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); - - /* loop over subframes to decode */ - - size_t Nback = iLBC_encbits->startIdx - 1; - for (subframe=0; subframecb_index + subcount * CB_NSTAGES, - iLBC_encbits->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, - SUBL)) - return false; // Error. - - /* update memory */ - memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &reverseDecresidual[subframe*SUBL], SUBL); - - subcount++; - } - - /* get decoded residual from reversed vector */ - WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, - reverseDecresidual, SUBL*Nback); - } - - return true; // Success. -} diff --git a/modules/audio_coding/codecs/ilbc/decode_residual.h b/modules/audio_coding/codecs/ilbc/decode_residual.h deleted file mode 100644 index d079577661..0000000000 --- a/modules/audio_coding/codecs/ilbc/decode_residual.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecodeResidual.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ - -#include -#include -#include - -#include "absl/base/attributes.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * frame residual decoder function (subrutine to iLBC_decode) - *---------------------------------------------------------------*/ - -// Returns true on success, false on failure. In case of failure, the decoder -// state may be corrupted and needs resetting. -ABSL_MUST_USE_RESULT -bool WebRtcIlbcfix_DecodeResidual( - IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state structure */ - iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits, which are used - for the decoding */ - int16_t* decresidual, /* (o) decoded residual frame */ - int16_t* syntdenum /* (i) the decoded synthesis filter - coefficients */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c deleted file mode 100644 index d96bb9b2e9..0000000000 --- a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecoderInterpolateLsp.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h" - -#include "modules/audio_coding/codecs/ilbc/bw_expand.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h" - -/*----------------------------------------------------------------* - * obtain synthesis and weighting filters form lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecoderInterpolateLsp( - int16_t *syntdenum, /* (o) synthesis filter coefficients */ - int16_t *weightdenum, /* (o) weighting denumerator - coefficients */ - int16_t *lsfdeq, /* (i) dequantized lsf coefficients */ - int16_t length, /* (i) length of lsf coefficient vector */ - IlbcDecoder *iLBCdec_inst - /* (i) the decoder state structure */ - ){ - size_t i; - int pos, lp_length; - int16_t lp[LPC_FILTERORDER + 1], *lsfdeq2; - - lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (iLBCdec_inst->mode==30) { - /* subframe 1: Interpolation between old and first LSF */ - - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, (*iLBCdec_inst).lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight30ms[0], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum, lp, (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); - - /* subframes 2 to 6: interpolation between first and last LSF */ - - pos = lp_length; - for (i = 1; i < 6; i++) { - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, lsfdeq, lsfdeq2, - WebRtcIlbcfix_kLsfWeight30ms[i], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, - (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); - pos += lp_length; - } - } else { /* iLBCdec_inst->mode=20 */ - /* subframes 1 to 4: interpolation between old and new LSF */ - pos = 0; - for (i = 0; i < iLBCdec_inst->nsub; i++) { - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, iLBCdec_inst->lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight20ms[i], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum+pos,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, - (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, (int16_t)lp_length); - pos += lp_length; - } - } - - /* update memory */ - - if (iLBCdec_inst->mode==30) { - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq2, length); - } else { - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq, length); - } -} diff --git a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h deleted file mode 100644 index 40510007a9..0000000000 --- a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecoderInterpolateLsp.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * obtain synthesis and weighting filters form lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecoderInterpolateLsp( - int16_t* syntdenum, /* (o) synthesis filter coefficients */ - int16_t* weightdenum, /* (o) weighting denumerator - coefficients */ - int16_t* lsfdeq, /* (i) dequantized lsf coefficients */ - int16_t length, /* (i) length of lsf coefficient vector */ - IlbcDecoder* iLBCdec_inst - /* (i) the decoder state structure */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/defines.h b/modules/audio_coding/codecs/ilbc/defines.h deleted file mode 100644 index 64135c4887..0000000000 --- a/modules/audio_coding/codecs/ilbc/defines.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - define.h - -******************************************************************/ -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_ - -#include -#include - -#include "common_audio/signal_processing/include/signal_processing_library.h" - -/* general codec settings */ - -#define FS 8000 -#define BLOCKL_20MS 160 -#define BLOCKL_30MS 240 -#define BLOCKL_MAX 240 -#define NSUB_20MS 4 -#define NSUB_30MS 6 -#define NSUB_MAX 6 -#define NASUB_20MS 2 -#define NASUB_30MS 4 -#define NASUB_MAX 4 -#define SUBL 40 -#define STATE_LEN 80 -#define STATE_SHORT_LEN_30MS 58 -#define STATE_SHORT_LEN_20MS 57 - -/* LPC settings */ - -#define LPC_FILTERORDER 10 -#define LPC_LOOKBACK 60 -#define LPC_N_20MS 1 -#define LPC_N_30MS 2 -#define LPC_N_MAX 2 -#define LPC_ASYMDIFF 20 -#define LSF_NSPLIT 3 -#define LSF_NUMBER_OF_STEPS 4 -#define LPC_HALFORDER 5 -#define COS_GRID_POINTS 60 - -/* cb settings */ - -#define CB_NSTAGES 3 -#define CB_EXPAND 2 -#define CB_MEML 147 -#define CB_FILTERLEN (2 * 4) -#define CB_HALFFILTERLEN 4 -#define CB_RESRANGE 34 -#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */ -#define CB_MAXGAIN_FIXQ14 21299 - -/* enhancer */ - -#define ENH_BLOCKL 80 /* block length */ -#define ENH_BLOCKL_HALF (ENH_BLOCKL / 2) -#define ENH_HL \ - 3 /* 2*ENH_HL+1 is number blocks \ - in said second \ - sequence */ -#define ENH_SLOP \ - 2 /* max difference estimated and \ - correct pitch period */ -#define ENH_PLOCSL \ - 8 /* pitch-estimates and \ - pitch-locations buffer \ - length */ -#define ENH_OVERHANG 2 -#define ENH_UPS0 4 /* upsampling rate */ -#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ -#define ENH_FLO_MULT2_PLUS1 7 -#define ENH_VECTL (ENH_BLOCKL + 2 * ENH_FL0) -#define ENH_CORRDIM (2 * ENH_SLOP + 1) -#define ENH_NBLOCKS (BLOCKL / ENH_BLOCKL) -#define ENH_NBLOCKS_EXTRA 5 -#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ -#define ENH_BUFL (ENH_NBLOCKS_TOT) * ENH_BLOCKL -#define ENH_BUFL_FILTEROVERHEAD 3 -#define ENH_A0 819 /* Q14 */ -#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ -#define ENH_A0DIV2 26843546 /* Q30 */ - -/* PLC */ - -/* Down sampling */ - -#define FILTERORDER_DS_PLUS1 7 -#define DELAY_DS 3 -#define FACTOR_DS 2 - -/* bit stream defs */ - -#define NO_OF_BYTES_20MS 38 -#define NO_OF_BYTES_30MS 50 -#define NO_OF_WORDS_20MS 19 -#define NO_OF_WORDS_30MS 25 -#define STATE_BITS 3 -#define BYTE_LEN 8 -#define ULP_CLASSES 3 - -/* help parameters */ - -#define TWO_PI_FIX 25736 /* Q12 */ - -/* Constants for codebook search and creation */ - -#define ST_MEM_L_TBL 85 -#define MEM_LF_TBL 147 - -/* Struct for the bits */ -typedef struct iLBC_bits_t_ { - int16_t lsf[LSF_NSPLIT * LPC_N_MAX]; - int16_t cb_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values - contains extra CB index */ - int16_t gain_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values - contains extra CB gain */ - size_t idxForMax; - int16_t state_first; - int16_t idxVec[STATE_SHORT_LEN_30MS]; - int16_t firstbits; - size_t startIdx; -} iLBC_bits; - -/* type definition encoder instance */ -typedef struct IlbcEncoder_ { - /* flag for frame size mode */ - int16_t mode; - - /* basic parameters for different frame sizes */ - size_t blockl; - size_t nsub; - int16_t nasub; - size_t no_of_bytes, no_of_words; - int16_t lpc_n; - size_t state_short_len; - - /* analysis filter state */ - int16_t anaMem[LPC_FILTERORDER]; - - /* Fix-point old lsf parameters for interpolation */ - int16_t lsfold[LPC_FILTERORDER]; - int16_t lsfdeqold[LPC_FILTERORDER]; - - /* signal buffer for LP analysis */ - int16_t lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX]; - - /* state of input HP filter */ - int16_t hpimemx[2]; - int16_t hpimemy[4]; - -#ifdef SPLIT_10MS - int16_t weightdenumbuf[66]; - int16_t past_samples[160]; - uint16_t bytes[25]; - int16_t section; - int16_t Nfor_flag; - int16_t Nback_flag; - int16_t start_pos; - size_t diff; -#endif - -} IlbcEncoder; - -/* type definition decoder instance */ -typedef struct IlbcDecoder_ { - /* flag for frame size mode */ - int16_t mode; - - /* basic parameters for different frame sizes */ - size_t blockl; - size_t nsub; - int16_t nasub; - size_t no_of_bytes, no_of_words; - int16_t lpc_n; - size_t state_short_len; - - /* synthesis filter state */ - int16_t syntMem[LPC_FILTERORDER]; - - /* old LSF for interpolation */ - int16_t lsfdeqold[LPC_FILTERORDER]; - - /* pitch lag estimated in enhancer and used in PLC */ - size_t last_lag; - - /* PLC state information */ - int consPLICount, prev_enh_pl; - int16_t perSquare; - - int16_t prevScale, prevPLI; - size_t prevLag; - int16_t prevLpc[LPC_FILTERORDER + 1]; - int16_t prevResidual[NSUB_MAX * SUBL]; - int16_t seed; - - /* previous synthesis filter parameters */ - - int16_t old_syntdenum[(LPC_FILTERORDER + 1) * NSUB_MAX]; - - /* state of output HP filter */ - int16_t hpimemx[2]; - int16_t hpimemy[4]; - - /* enhancer state information */ - int use_enhancer; - int16_t enh_buf[ENH_BUFL + ENH_BUFL_FILTEROVERHEAD]; - size_t enh_period[ENH_NBLOCKS_TOT]; - -} IlbcDecoder; - -#endif diff --git a/modules/audio_coding/codecs/ilbc/do_plc.c b/modules/audio_coding/codecs/ilbc/do_plc.c deleted file mode 100644 index 9ca6ca48e9..0000000000 --- a/modules/audio_coding/codecs/ilbc/do_plc.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DoThePlc.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/do_plc.h" - -#include "modules/audio_coding/codecs/ilbc/bw_expand.h" -#include "modules/audio_coding/codecs/ilbc/comp_corr.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Packet loss concealment routine. Conceals a residual signal - * and LP parameters. If no packet loss, update state. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DoThePlc( - int16_t *PLCresidual, /* (o) concealed residual */ - int16_t *PLClpc, /* (o) concealed LP parameters */ - int16_t PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - int16_t *decresidual, /* (i) decoded residual */ - int16_t *lpc, /* (i) decoded LPC (only used for no PL) */ - size_t inlag, /* (i) pitch lag */ - IlbcDecoder *iLBCdec_inst - /* (i/o) decoder instance */ - ){ - size_t i; - int32_t cross, ener, cross_comp, ener_comp = 0; - int32_t measure, maxMeasure, energy; - int32_t noise_energy_threshold_30dB; - int16_t max, crossSquareMax, crossSquare; - size_t j, lag, randlag; - int16_t tmp1, tmp2; - int16_t shift1, shift2, shift3, shiftMax; - int16_t scale3; - size_t corrLen; - int32_t tmpW32, tmp2W32; - int16_t use_gain; - int16_t tot_gain; - int16_t max_perSquare; - int16_t scale1, scale2; - int16_t totscale; - int32_t nom; - int16_t denom; - int16_t pitchfact; - size_t use_lag; - int ind; - int16_t randvec[BLOCKL_MAX]; - - /* Packet Loss */ - if (PLI == 1) { - - (*iLBCdec_inst).consPLICount += 1; - - /* if previous frame not lost, - determine pitch pred. gain */ - - if (iLBCdec_inst->prevPLI != 1) { - - /* Maximum 60 samples are correlated, preserve as high accuracy - as possible without getting overflow */ - max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual, - iLBCdec_inst->blockl); - scale3 = (WebRtcSpl_GetSizeInBits(max)<<1) - 25; - if (scale3 < 0) { - scale3 = 0; - } - - /* Store scale for use when interpolating between the - * concealment and the received packet */ - iLBCdec_inst->prevScale = scale3; - - /* Search around the previous lag +/-3 to find the - best pitch period */ - lag = inlag - 3; - - /* Guard against getting outside the frame */ - corrLen = (size_t)WEBRTC_SPL_MIN(60, iLBCdec_inst->blockl-(inlag+3)); - - WebRtcIlbcfix_CompCorr( &cross, &ener, - iLBCdec_inst->prevResidual, lag, iLBCdec_inst->blockl, corrLen, scale3); - - /* Normalize and store cross^2 and the number of shifts */ - shiftMax = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross))-15; - crossSquareMax = (int16_t)(( - (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax) * - (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax)) >> 15); - - for (j=inlag-2;j<=inlag+3;j++) { - WebRtcIlbcfix_CompCorr( &cross_comp, &ener_comp, - iLBCdec_inst->prevResidual, j, iLBCdec_inst->blockl, corrLen, scale3); - - /* Use the criteria (corr*corr)/energy to compare if - this lag is better or not. To avoid the division, - do a cross multiplication */ - shift1 = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross_comp))-15; - crossSquare = (int16_t)(( - (int16_t)WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1) * - (int16_t)WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1)) >> 15); - - shift2 = WebRtcSpl_GetSizeInBits(ener)-15; - measure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener, -shift2) * crossSquare; - - shift3 = WebRtcSpl_GetSizeInBits(ener_comp)-15; - maxMeasure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3) * - crossSquareMax; - - /* Calculate shift value, so that the two measures can - be put in the same Q domain */ - if(2 * shiftMax + shift3 > 2 * shift1 + shift2) { - tmp1 = - WEBRTC_SPL_MIN(31, 2 * shiftMax + shift3 - 2 * shift1 - shift2); - tmp2 = 0; - } else { - tmp1 = 0; - tmp2 = - WEBRTC_SPL_MIN(31, 2 * shift1 + shift2 - 2 * shiftMax - shift3); - } - - if ((measure>>tmp1) > (maxMeasure>>tmp2)) { - /* New lag is better => record lag, measure and domain */ - lag = j; - crossSquareMax = crossSquare; - cross = cross_comp; - shiftMax = shift1; - ener = ener_comp; - } - } - - /* Calculate the periodicity for the lag with the maximum correlation. - - Definition of the periodicity: - abs(corr(vec1, vec2))/(sqrt(energy(vec1))*sqrt(energy(vec2))) - - Work in the Square domain to simplify the calculations - max_perSquare is less than 1 (in Q15) - */ - tmp2W32=WebRtcSpl_DotProductWithScale(&iLBCdec_inst->prevResidual[iLBCdec_inst->blockl-corrLen], - &iLBCdec_inst->prevResidual[iLBCdec_inst->blockl-corrLen], - corrLen, scale3); - - if ((tmp2W32>0)&&(ener_comp>0)) { - /* norm energies to int16_t, compute the product of the energies and - use the upper int16_t as the denominator */ - - scale1=(int16_t)WebRtcSpl_NormW32(tmp2W32)-16; - tmp1=(int16_t)WEBRTC_SPL_SHIFT_W32(tmp2W32, scale1); - - scale2=(int16_t)WebRtcSpl_NormW32(ener)-16; - tmp2=(int16_t)WEBRTC_SPL_SHIFT_W32(ener, scale2); - denom = (int16_t)((tmp1 * tmp2) >> 16); /* in Q(scale1+scale2-16) */ - - /* Square the cross correlation and norm it such that max_perSquare - will be in Q15 after the division */ - - totscale = scale1+scale2-1; - tmp1 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, (totscale>>1)); - tmp2 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, totscale-(totscale>>1)); - - nom = tmp1 * tmp2; - max_perSquare = (int16_t)WebRtcSpl_DivW32W16(nom, denom); - - } else { - max_perSquare = 0; - } - } - - /* previous frame lost, use recorded lag and gain */ - - else { - lag = iLBCdec_inst->prevLag; - max_perSquare = iLBCdec_inst->perSquare; - } - - /* Attenuate signal and scale down pitch pred gain if - several frames lost consecutively */ - - use_gain = 32767; /* 1.0 in Q15 */ - - if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>320) { - use_gain = 29491; /* 0.9 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>640) { - use_gain = 22938; /* 0.7 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>960) { - use_gain = 16384; /* 0.5 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>1280) { - use_gain = 0; /* 0.0 in Q15 */ - } - - /* Compute mixing factor of picth repeatition and noise: - for max_per>0.7 set periodicity to 1.0 - 0.47868) { /* periodicity > 0.7 (0.7^4=0.2401 in Q15) */ - pitchfact = 32767; - } else if (max_perSquare>839) { /* 0.4 < periodicity < 0.7 (0.4^4=0.0256 in Q15) */ - /* find best index and interpolate from that */ - ind = 5; - while ((max_perSquare0)) { - ind--; - } - /* pitch fact is approximated by first order */ - tmpW32 = (int32_t)WebRtcIlbcfix_kPlcPitchFact[ind] + - ((WebRtcIlbcfix_kPlcPfSlope[ind] * - (max_perSquare - WebRtcIlbcfix_kPlcPerSqr[ind])) >> 11); - - pitchfact = (int16_t)WEBRTC_SPL_MIN(tmpW32, 32767); /* guard against overflow */ - - } else { /* periodicity < 0.4 */ - pitchfact = 0; - } - - /* avoid repetition of same pitch cycle (buzzyness) */ - use_lag = lag; - if (lag<80) { - use_lag = 2*lag; - } - - /* compute concealed residual */ - noise_energy_threshold_30dB = (int32_t)iLBCdec_inst->blockl * 900; - energy = 0; - for (i=0; iblockl; i++) { - - /* noise component - 52 < randlagFIX < 117 */ - iLBCdec_inst->seed = (int16_t)(iLBCdec_inst->seed * 31821 + 13849); - randlag = 53 + (iLBCdec_inst->seed & 63); - if (randlag > i) { - randvec[i] = - iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - randlag]; - } else { - randvec[i] = iLBCdec_inst->prevResidual[i - randlag]; - } - - /* pitch repeatition component */ - if (use_lag > i) { - PLCresidual[i] = - iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - use_lag]; - } else { - PLCresidual[i] = PLCresidual[i - use_lag]; - } - - /* Attinuate total gain for each 10 ms */ - if (i<80) { - tot_gain=use_gain; - } else if (i<160) { - tot_gain = (int16_t)((31130 * use_gain) >> 15); /* 0.95*use_gain */ - } else { - tot_gain = (int16_t)((29491 * use_gain) >> 15); /* 0.9*use_gain */ - } - - - /* mix noise and pitch repeatition */ - PLCresidual[i] = (int16_t)((tot_gain * - ((pitchfact * PLCresidual[i] + (32767 - pitchfact) * randvec[i] + - 16384) >> 15)) >> 15); - - /* Compute energy until threshold for noise energy is reached */ - if (energy < noise_energy_threshold_30dB) { - energy += PLCresidual[i] * PLCresidual[i]; - } - } - - /* less than 30 dB, use only noise */ - if (energy < noise_energy_threshold_30dB) { - for (i=0; iblockl; i++) { - PLCresidual[i] = randvec[i]; - } - } - - /* use the old LPC */ - WEBRTC_SPL_MEMCPY_W16(PLClpc, (*iLBCdec_inst).prevLpc, LPC_FILTERORDER+1); - - /* Update state in case there are multiple frame losses */ - iLBCdec_inst->prevLag = lag; - iLBCdec_inst->perSquare = max_perSquare; - } - - /* no packet loss, copy input */ - - else { - WEBRTC_SPL_MEMCPY_W16(PLCresidual, decresidual, iLBCdec_inst->blockl); - WEBRTC_SPL_MEMCPY_W16(PLClpc, lpc, (LPC_FILTERORDER+1)); - iLBCdec_inst->consPLICount = 0; - } - - /* update state */ - iLBCdec_inst->prevPLI = PLI; - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevLpc, PLClpc, (LPC_FILTERORDER+1)); - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevResidual, PLCresidual, iLBCdec_inst->blockl); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/do_plc.h b/modules/audio_coding/codecs/ilbc/do_plc.h deleted file mode 100644 index 5e3bcc6d3c..0000000000 --- a/modules/audio_coding/codecs/ilbc/do_plc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DoThePlc.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Packet loss concealment routine. Conceals a residual signal - * and LP parameters. If no packet loss, update state. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DoThePlc( - int16_t* PLCresidual, /* (o) concealed residual */ - int16_t* PLClpc, /* (o) concealed LP parameters */ - int16_t PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - int16_t* decresidual, /* (i) decoded residual */ - int16_t* lpc, /* (i) decoded LPC (only used for no PL) */ - size_t inlag, /* (i) pitch lag */ - IlbcDecoder* iLBCdec_inst - /* (i/o) decoder instance */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/encode.c b/modules/audio_coding/codecs/ilbc/encode.c deleted file mode 100644 index 8e536221cd..0000000000 --- a/modules/audio_coding/codecs/ilbc/encode.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Encode.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/encode.h" - -#include - -#include "modules/audio_coding/codecs/ilbc/cb_construct.h" -#include "modules/audio_coding/codecs/ilbc/cb_search.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/frame_classify.h" -#include "modules/audio_coding/codecs/ilbc/hp_input.h" -#include "modules/audio_coding/codecs/ilbc/index_conv_enc.h" -#include "modules/audio_coding/codecs/ilbc/lpc_encode.h" -#include "modules/audio_coding/codecs/ilbc/pack_bits.h" -#include "modules/audio_coding/codecs/ilbc/state_construct.h" -#include "modules/audio_coding/codecs/ilbc/state_search.h" -#include "rtc_base/checks.h" -#include "rtc_base/system/arch.h" - -#ifdef SPLIT_10MS -#include "modules/audio_coding/codecs/ilbc/unpack_bits.h" -#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h" -#endif - -#ifndef WEBRTC_ARCH_BIG_ENDIAN -#include "modules/audio_coding/codecs/ilbc/swap_bytes.h" -#endif - -/*----------------------------------------------------------------* - * main encoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EncodeImpl( - uint16_t *bytes, /* (o) encoded data bits iLBC */ - const int16_t *block, /* (i) speech vector to encode */ - IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder - state */ - ){ - size_t n, meml_gotten, Nfor; - size_t diff, start_pos; - size_t index; - size_t subcount, subframe; - size_t start_count, end_count; - int16_t *residual; - int32_t en1, en2; - int16_t scale, max; - int16_t *syntdenum; - int16_t *decresidual; - int16_t *reverseResidual; - int16_t *reverseDecresidual; - /* Stack based */ - int16_t weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - int16_t dataVec[BLOCKL_MAX + LPC_FILTERORDER]; - int16_t memVec[CB_MEML+CB_FILTERLEN]; - int16_t bitsMemory[sizeof(iLBC_bits)/sizeof(int16_t)]; - iLBC_bits *iLBCbits_inst = (iLBC_bits*)bitsMemory; - - -#ifdef SPLIT_10MS - int16_t *weightdenumbuf = iLBCenc_inst->weightdenumbuf; - int16_t last_bit; -#endif - - int16_t *data = &dataVec[LPC_FILTERORDER]; - int16_t *mem = &memVec[CB_HALFFILTERLEN]; - - /* Reuse som buffers to save stack memory */ - residual = &iLBCenc_inst->lpc_buffer[LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl]; - syntdenum = mem; /* syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX] and mem are used non overlapping in the code */ - decresidual = residual; /* Already encoded residual is overwritten by the decoded version */ - reverseResidual = data; /* data and reverseResidual are used non overlapping in the code */ - reverseDecresidual = reverseResidual; /* Already encoded residual is overwritten by the decoded version */ - -#ifdef SPLIT_10MS - - WebRtcSpl_MemSetW16 ( (int16_t *) iLBCbits_inst, 0, - sizeof(iLBC_bits) / sizeof(int16_t) ); - - start_pos = iLBCenc_inst->start_pos; - diff = iLBCenc_inst->diff; - - if (iLBCenc_inst->section != 0){ - WEBRTC_SPL_MEMCPY_W16 (weightdenum, weightdenumbuf, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - /* Un-Packetize the frame into parameters */ - last_bit = WebRtcIlbcfix_UnpackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - if (last_bit) - return; - /* adjust index */ - WebRtcIlbcfix_IndexConvDec (iLBCbits_inst->cb_index); - - if (iLBCenc_inst->section == 1){ - /* Save first 80 samples of a 160/240 sample frame for 20/30msec */ - WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples, block, 80); - } - else{ // iLBCenc_inst->section == 2 AND mode = 30ms - /* Save second 80 samples of a 240 sample frame for 30msec */ - WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples + 80, block, 80); - } - } - else{ // iLBCenc_inst->section == 0 - /* form a complete frame of 160/240 for 20msec/30msec mode */ - WEBRTC_SPL_MEMCPY_W16 (data + (iLBCenc_inst->mode * 8) - 80, block, 80); - WEBRTC_SPL_MEMCPY_W16 (data, iLBCenc_inst->past_samples, - (iLBCenc_inst->mode * 8) - 80); - iLBCenc_inst->Nfor_flag = 0; - iLBCenc_inst->Nback_flag = 0; -#else - /* copy input block to data*/ - WEBRTC_SPL_MEMCPY_W16(data,block,iLBCenc_inst->blockl); -#endif - - /* high pass filtering of input signal and scale down the residual (*0.5) */ - WebRtcIlbcfix_HpInput(data, (int16_t*)WebRtcIlbcfix_kHpInCoefs, - iLBCenc_inst->hpimemy, iLBCenc_inst->hpimemx, - iLBCenc_inst->blockl); - - /* LPC of hp filtered input data */ - WebRtcIlbcfix_LpcEncode(syntdenum, weightdenum, iLBCbits_inst->lsf, data, - iLBCenc_inst); - - /* Set up state */ - WEBRTC_SPL_MEMCPY_W16(dataVec, iLBCenc_inst->anaMem, LPC_FILTERORDER); - - /* inverse filter to get residual */ - for (n=0; nnsub; n++ ) { - WebRtcSpl_FilterMAFastQ12( - &data[n*SUBL], &residual[n*SUBL], - &syntdenum[n*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, SUBL); - } - - /* Copy the state for next frame */ - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->anaMem, &data[iLBCenc_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - - /* find state location */ - - iLBCbits_inst->startIdx = WebRtcIlbcfix_FrameClassify(iLBCenc_inst,residual); - - /* check if state should be in first or last part of the - two subframes */ - - index = (iLBCbits_inst->startIdx-1)*SUBL; - max=WebRtcSpl_MaxAbsValueW16(&residual[index], 2*SUBL); - scale = WebRtcSpl_GetSizeInBits((uint32_t)(max * max)); - - /* Scale to maximum 25 bits so that the MAC won't cause overflow */ - scale = scale - 25; - if(scale < 0) { - scale = 0; - } - - diff = STATE_LEN - iLBCenc_inst->state_short_len; - en1=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], - iLBCenc_inst->state_short_len, scale); - index += diff; - en2=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], - iLBCenc_inst->state_short_len, scale); - if (en1 > en2) { - iLBCbits_inst->state_first = 1; - start_pos = (iLBCbits_inst->startIdx-1)*SUBL; - } else { - iLBCbits_inst->state_first = 0; - start_pos = (iLBCbits_inst->startIdx-1)*SUBL + diff; - } - - /* scalar quantization of state */ - - WebRtcIlbcfix_StateSearch(iLBCenc_inst, iLBCbits_inst, &residual[start_pos], - &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)]); - - WebRtcIlbcfix_StateConstruct(iLBCbits_inst->idxForMax, iLBCbits_inst->idxVec, - &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - &decresidual[start_pos], iLBCenc_inst->state_short_len - ); - - /* predictive quantization in state */ - - if (iLBCbits_inst->state_first) { /* put adaptive part in the end */ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - iLBCenc_inst->state_short_len); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCenc_inst->state_short_len, - decresidual+start_pos, iLBCenc_inst->state_short_len); - - /* encode subframes */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - &residual[start_pos+iLBCenc_inst->state_short_len], - mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, - &weightdenum[iLBCbits_inst->startIdx*(LPC_FILTERORDER+1)], 0); - - /* construct decoded vector */ - - RTC_CHECK(WebRtcIlbcfix_CbConstruct( - &decresidual[start_pos + iLBCenc_inst->state_short_len], - iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - mem + CB_MEML - ST_MEM_L_TBL, ST_MEM_L_TBL, diff)); - - } - else { /* put adaptive part in the beginning */ - - /* create reversed vectors for prediction */ - - WebRtcSpl_MemCpyReversedOrder(&reverseResidual[diff-1], - &residual[(iLBCbits_inst->startIdx+1)*SUBL-STATE_LEN], diff); - - /* setup memory */ - - meml_gotten = iLBCenc_inst->state_short_len; - WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[start_pos], meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - iLBCenc_inst->state_short_len); - - /* encode subframes */ - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - reverseResidual, mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, - &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - 0); - - /* construct decoded vector */ - RTC_CHECK(WebRtcIlbcfix_CbConstruct( - reverseDecresidual, iLBCbits_inst->cb_index, - iLBCbits_inst->gain_index, mem + CB_MEML - ST_MEM_L_TBL, - ST_MEM_L_TBL, diff)); - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], reverseDecresidual, diff); - } - -#ifdef SPLIT_10MS - iLBCenc_inst->start_pos = start_pos; - iLBCenc_inst->diff = diff; - iLBCenc_inst->section++; - /* adjust index */ - WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); - /* Packetize the parameters into the frame */ - WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - return; - } -#endif - - /* forward prediction of subframes */ - - Nfor = iLBCenc_inst->nsub-iLBCbits_inst->startIdx-1; - - /* counter for predicted subframes */ -#ifdef SPLIT_10MS - if (iLBCenc_inst->mode == 20) - { - subcount = 1; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - subcount = 1; - } - if (iLBCenc_inst->section == 2) - { - subcount = 3; - } - } -#else - subcount=1; -#endif - - if( Nfor > 0 ){ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, - decresidual+(iLBCbits_inst->startIdx-1)*SUBL, STATE_LEN); - -#ifdef SPLIT_10MS - if (iLBCenc_inst->Nfor_flag > 0) - { - for (subframe = 0; subframe < WEBRTC_SPL_MIN (Nfor, 2); subframe++) - { - /* update memory */ - WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); - WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, - &decresidual[(iLBCbits_inst->startIdx + 1 + - subframe) * SUBL], SUBL); - } - } - - iLBCenc_inst->Nfor_flag++; - - if (iLBCenc_inst->mode == 20) - { - start_count = 0; - end_count = Nfor; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - start_count = 0; - end_count = WEBRTC_SPL_MIN (Nfor, (size_t)2); - } - if (iLBCenc_inst->section == 2) - { - start_count = WEBRTC_SPL_MIN (Nfor, (size_t)2); - end_count = Nfor; - } - } -#else - start_count = 0; - end_count = Nfor; -#endif - - /* loop over subframes to encode */ - - for (subframe = start_count; subframe < end_count; subframe++){ - - /* encode subframe */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, - &residual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], - mem, MEM_LF_TBL, SUBL, - &weightdenum[(iLBCbits_inst->startIdx+1+subframe)*(LPC_FILTERORDER+1)], - subcount); - - /* construct decoded vector */ - RTC_CHECK(WebRtcIlbcfix_CbConstruct( - &decresidual[(iLBCbits_inst->startIdx + 1 + subframe) * SUBL], - iLBCbits_inst->cb_index + subcount * CB_NSTAGES, - iLBCbits_inst->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, - SUBL)); - - /* update memory */ - - memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &decresidual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], SUBL); - - subcount++; - } - } - -#ifdef SPLIT_10MS - if ((iLBCenc_inst->section == 1) && - (iLBCenc_inst->mode == 30) && (Nfor > 0) && (end_count == 2)) - { - iLBCenc_inst->section++; - /* adjust index */ - WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); - /* Packetize the parameters into the frame */ - WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - return; - } -#endif - - /* backward prediction of subframes */ - - if (iLBCbits_inst->startIdx > 1) { - - /* create reverse order vectors - (The decresidual does not need to be copied since it is - contained in the same vector as the residual) - */ - - size_t Nback = iLBCbits_inst->startIdx - 1; - WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nback*SUBL); - - /* setup memory */ - - meml_gotten = SUBL*(iLBCenc_inst->nsub+1-iLBCbits_inst->startIdx); - if( meml_gotten > CB_MEML ) { - meml_gotten=CB_MEML; - } - - WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[Nback*SUBL], meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, CB_MEML - meml_gotten); - -#ifdef SPLIT_10MS - if (iLBCenc_inst->Nback_flag > 0) - { - for (subframe = 0; subframe < WEBRTC_SPL_MAX (2 - Nfor, 0); subframe++) - { - /* update memory */ - WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); - WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, - &reverseDecresidual[subframe * SUBL], SUBL); - } - } - - iLBCenc_inst->Nback_flag++; - - - if (iLBCenc_inst->mode == 20) - { - start_count = 0; - end_count = Nback; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - start_count = 0; - end_count = (Nfor >= 2) ? 0 : (2 - NFor); - } - if (iLBCenc_inst->section == 2) - { - start_count = (Nfor >= 2) ? 0 : (2 - NFor); - end_count = Nback; - } - } -#else - start_count = 0; - end_count = Nback; -#endif - - /* loop over subframes to encode */ - - for (subframe = start_count; subframe < end_count; subframe++){ - - /* encode subframe */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &reverseResidual[subframe*SUBL], - mem, MEM_LF_TBL, SUBL, - &weightdenum[(iLBCbits_inst->startIdx-2-subframe)*(LPC_FILTERORDER+1)], - subcount); - - /* construct decoded vector */ - RTC_CHECK(WebRtcIlbcfix_CbConstruct( - &reverseDecresidual[subframe * SUBL], - iLBCbits_inst->cb_index + subcount * CB_NSTAGES, - iLBCbits_inst->gain_index + subcount * CB_NSTAGES, mem, MEM_LF_TBL, - SUBL)); - - /* update memory */ - memmove(mem, mem + SUBL, (CB_MEML - SUBL) * sizeof(*mem)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &reverseDecresidual[subframe*SUBL], SUBL); - - subcount++; - - } - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[SUBL*Nback-1], reverseDecresidual, SUBL*Nback); - } - /* end encoding part */ - - /* adjust index */ - - WebRtcIlbcfix_IndexConvEnc(iLBCbits_inst->cb_index); - - /* Packetize the parameters into the frame */ - -#ifdef SPLIT_10MS - if( (iLBCenc_inst->mode==30) && (iLBCenc_inst->section==1) ){ - WebRtcIlbcfix_PackBits(iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - } - else{ - WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); - } -#else - WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); -#endif - -#ifndef WEBRTC_ARCH_BIG_ENDIAN - /* Swap bytes for LITTLE ENDIAN since the packbits() - function assumes BIG_ENDIAN machine */ -#ifdef SPLIT_10MS - if (( (iLBCenc_inst->section == 1) && (iLBCenc_inst->mode == 20) ) || - ( (iLBCenc_inst->section == 2) && (iLBCenc_inst->mode == 30) )){ - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); - } -#else - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); -#endif -#endif - -#ifdef SPLIT_10MS - if (subcount == (iLBCenc_inst->nsub - 1)) - { - iLBCenc_inst->section = 0; - } - else - { - iLBCenc_inst->section++; - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - } -#endif - -} diff --git a/modules/audio_coding/codecs/ilbc/encode.h b/modules/audio_coding/codecs/ilbc/encode.h deleted file mode 100644 index 5290420bbf..0000000000 --- a/modules/audio_coding/codecs/ilbc/encode.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Encode.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * main encoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EncodeImpl( - uint16_t* bytes, /* (o) encoded data bits iLBC */ - const int16_t* block, /* (i) speech vector to encode */ - IlbcEncoder* iLBCenc_inst /* (i/o) the general encoder - state */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/energy_inverse.c b/modules/audio_coding/codecs/ilbc/energy_inverse.c deleted file mode 100644 index 7f00254aea..0000000000 --- a/modules/audio_coding/codecs/ilbc/energy_inverse.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnergyInverse.c - -******************************************************************/ - -/* Inverses the in vector in into Q29 domain */ - -#include "modules/audio_coding/codecs/ilbc/energy_inverse.h" - -void WebRtcIlbcfix_EnergyInverse( - int16_t *energy, /* (i/o) Energy and inverse - energy (in Q29) */ - size_t noOfEnergies) /* (i) The length of the energy - vector */ -{ - int32_t Nom=(int32_t)0x1FFFFFFF; - int16_t *energyPtr; - size_t i; - - /* Set the minimum energy value to 16384 to avoid overflow */ - energyPtr=energy; - for (i=0; i -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/* Inverses the in vector in into Q29 domain */ - -void WebRtcIlbcfix_EnergyInverse( - int16_t* - energy, /* (i/o) Energy and inverse - energy (in Q29) */ - size_t noOfEnergies); /* (i) The length of the energy - vector */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/enh_upsample.c b/modules/audio_coding/codecs/ilbc/enh_upsample.c deleted file mode 100644 index cd3d0a4db1..0000000000 --- a/modules/audio_coding/codecs/ilbc/enh_upsample.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhUpsample.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/enh_upsample.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * upsample finite array assuming zeros outside bounds - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EnhUpsample( - int32_t *useq1, /* (o) upsampled output sequence */ - int16_t *seq1 /* (i) unupsampled sequence */ - ){ - int j; - int32_t *pu1, *pu11; - int16_t *ps, *w16tmp; - const int16_t *pp; - - /* filtering: filter overhangs left side of sequence */ - pu1=useq1; - for (j=0;j -#include - -/*----------------------------------------------------------------* - * perform enhancement on idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Enhancer( - int16_t* odata, /* (o) smoothed block, dimension blockl */ - int16_t* idata, /* (i) data buffer used for enhancing */ - size_t idatal, /* (i) dimension idata */ - size_t centerStartPos, /* (i) first sample current block within idata */ - size_t* period, /* (i) pitch period array (pitch bward-in time) */ - const size_t* plocs, /* (i) locations where period array values valid */ - size_t periodl /* (i) dimension of period and plocs */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/modules/audio_coding/codecs/ilbc/enhancer_interface.c deleted file mode 100644 index ca23e19ae3..0000000000 --- a/modules/audio_coding/codecs/ilbc/enhancer_interface.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhancerInterface.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/enhancer_interface.h" - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/enhancer.h" -#include "modules/audio_coding/codecs/ilbc/hp_output.h" -#include "modules/audio_coding/codecs/ilbc/xcorr_coef.h" - - - -/*----------------------------------------------------------------* - * interface for enhancer - *---------------------------------------------------------------*/ - -size_t // (o) Estimated lag in end of in[] - WebRtcIlbcfix_EnhancerInterface( - int16_t* out, // (o) enhanced signal - const int16_t* in, // (i) unenhanced signal - IlbcDecoder* iLBCdec_inst) { // (i) buffers etc - size_t iblock; - size_t lag=20, tlag=20; - size_t inLen=iLBCdec_inst->blockl+120; - int16_t scale, scale1; - size_t plc_blockl; - int16_t *enh_buf; - size_t *enh_period; - int32_t tmp1, tmp2, max; - size_t new_blocks; - int16_t *enh_bufPtr1; - size_t i; - size_t k; - int16_t EnChange; - int16_t SqrtEnChange; - int16_t inc; - int16_t win; - int16_t *tmpW16ptr; - size_t startPos; - int16_t *plc_pred; - const int16_t *target, *regressor; - int16_t max16; - int shifts; - int32_t ener; - int16_t enerSh; - int16_t corrSh; - size_t ind; - int16_t sh; - size_t start, stop; - /* Stack based */ - int16_t totsh[3]; - int16_t downsampled[(BLOCKL_MAX+120)>>1]; /* length 180 */ - int32_t corr32[50]; - int32_t corrmax[3]; - int16_t corr16[3]; - int16_t en16[3]; - size_t lagmax[3]; - - plc_pred = downsampled; /* Reuse memory since plc_pred[ENH_BLOCKL] and - downsampled are non overlapping */ - enh_buf=iLBCdec_inst->enh_buf; - enh_period=iLBCdec_inst->enh_period; - - /* Copy in the new data into the enhancer buffer */ - memmove(enh_buf, &enh_buf[iLBCdec_inst->blockl], - (ENH_BUFL - iLBCdec_inst->blockl) * sizeof(*enh_buf)); - - WEBRTC_SPL_MEMCPY_W16(&enh_buf[ENH_BUFL-iLBCdec_inst->blockl], in, - iLBCdec_inst->blockl); - - /* Set variables that are dependent on frame size */ - if (iLBCdec_inst->mode==30) { - plc_blockl=ENH_BLOCKL; - new_blocks=3; - startPos=320; /* Start position for enhancement - (640-new_blocks*ENH_BLOCKL-80) */ - } else { - plc_blockl=40; - new_blocks=2; - startPos=440; /* Start position for enhancement - (640-new_blocks*ENH_BLOCKL-40) */ - } - - /* Update the pitch prediction for each enhancer block, move the old ones */ - memmove(enh_period, &enh_period[new_blocks], - (ENH_NBLOCKS_TOT - new_blocks) * sizeof(*enh_period)); - - WebRtcSpl_DownsampleFast( - enh_buf+ENH_BUFL-inLen, /* Input samples */ - inLen + ENH_BUFL_FILTEROVERHEAD, - downsampled, - inLen / 2, - (int16_t*)WebRtcIlbcfix_kLpFiltCoefs, /* Coefficients in Q12 */ - FILTERORDER_DS_PLUS1, /* Length of filter (order-1) */ - FACTOR_DS, - DELAY_DS); - - /* Estimate the pitch in the down sampled domain. */ - for(iblock = 0; iblock> 16); - en16[i] = (int16_t)WEBRTC_SPL_SHIFT_W32(ener, enerSh); - totsh[i] = enerSh - 2 * corrSh; - } - - /* Compare lagmax[0..3] for the (corr^2)/ener criteria */ - ind = 0; - for (i=1; i<3; i++) { - if (totsh[ind] > totsh[i]) { - sh = WEBRTC_SPL_MIN(31, totsh[ind]-totsh[i]); - if (corr16[ind] * en16[i] < (corr16[i] * en16[ind]) >> sh) { - ind = i; - } - } else { - sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]); - if ((corr16[ind] * en16[i]) >> sh < corr16[i] * en16[ind]) { - ind = i; - } - } - } - - lag = lagmax[ind] + 10; - - /* Store the estimated lag in the non-downsampled domain */ - enh_period[ENH_NBLOCKS_TOT - new_blocks + iblock] = lag * 8; - - /* Store the estimated lag for backward PLC */ - if (iLBCdec_inst->prev_enh_pl==1) { - if (!iblock) { - tlag = lag * 2; - } - } else { - if (iblock==1) { - tlag = lag * 2; - } - } - - lag *= 2; - } - - if ((iLBCdec_inst->prev_enh_pl==1)||(iLBCdec_inst->prev_enh_pl==2)) { - - /* Calculate the best lag of the new frame - This is used to interpolate backwards and mix with the PLC'd data - */ - - /* references */ - target=in; - regressor=in+tlag-1; - - /* scaling */ - // Note that this is not abs-max, so we will take the absolute value below. - max16 = WebRtcSpl_MaxAbsElementW16(regressor, plc_blockl + 3 - 1); - const int16_t max_target = - WebRtcSpl_MaxAbsElementW16(target, plc_blockl + 3 - 1); - const int64_t max_val = plc_blockl * abs(max16 * max_target); - const int32_t factor = max_val >> 31; - shifts = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor); - - /* compute cross correlation */ - WebRtcSpl_CrossCorrelation(corr32, target, regressor, plc_blockl, 3, shifts, - 1); - - /* find lag */ - lag=WebRtcSpl_MaxIndexW32(corr32, 3); - lag+=tlag-1; - - /* Copy the backward PLC to plc_pred */ - - if (iLBCdec_inst->prev_enh_pl==1) { - if (lag>plc_blockl) { - WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-plc_blockl], plc_blockl); - } else { - WEBRTC_SPL_MEMCPY_W16(&plc_pred[plc_blockl-lag], in, lag); - WEBRTC_SPL_MEMCPY_W16( - plc_pred, &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl+lag], - (plc_blockl-lag)); - } - } else { - size_t pos; - - pos = plc_blockl; - - while (lagprev_enh_pl==1) { - /* limit energy change - if energy in backward PLC is more than 4 times higher than the forward - PLC, then reduce the energy in the backward PLC vector: - sample 1...len-16 set energy of the to 4 times forward PLC - sample len-15..len interpolate between 4 times fw PLC and bw PLC energy - - Note: Compared to floating point code there is a slight change, - the window is 16 samples long instead of 10 samples to simplify the - calculations - */ - - max=WebRtcSpl_MaxAbsValueW16( - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], plc_blockl); - max16=WebRtcSpl_MaxAbsValueW16(plc_pred, plc_blockl); - max = WEBRTC_SPL_MAX(max, max16); - scale=22-(int16_t)WebRtcSpl_NormW32(max); - scale=WEBRTC_SPL_MAX(scale,0); - - tmp2 = WebRtcSpl_DotProductWithScale( - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], - plc_blockl, scale); - tmp1 = WebRtcSpl_DotProductWithScale(plc_pred, plc_pred, - plc_blockl, scale); - - /* Check the energy difference */ - if ((tmp1>0)&&((tmp1>>2)>tmp2)) { - /* EnChange is now guaranteed to be <0.5 - Calculate EnChange=tmp2/tmp1 in Q16 - */ - - scale1=(int16_t)WebRtcSpl_NormW32(tmp1); - tmp1=WEBRTC_SPL_SHIFT_W32(tmp1, (scale1-16)); /* using 15 bits */ - - tmp2=WEBRTC_SPL_SHIFT_W32(tmp2, (scale1)); - EnChange = (int16_t)WebRtcSpl_DivW32W16(tmp2, - (int16_t)tmp1); - - /* Calculate the Sqrt of the energy in Q15 ((14+16)/2) */ - SqrtEnChange = (int16_t)WebRtcSpl_SqrtFloor(EnChange << 14); - - - /* Multiply first part of vector with 2*SqrtEnChange */ - WebRtcSpl_ScaleVector(plc_pred, plc_pred, SqrtEnChange, plc_blockl-16, - 14); - - /* Calculate increase parameter for window part (16 last samples) */ - /* (1-2*SqrtEnChange)/16 in Q15 */ - inc = 2048 - (SqrtEnChange >> 3); - - win=0; - tmpW16ptr=&plc_pred[plc_blockl-16]; - - for (i=16;i>0;i--) { - *tmpW16ptr = (int16_t)( - (*tmpW16ptr * (SqrtEnChange + (win >> 1))) >> 14); - /* multiply by (2.0*SqrtEnChange+win) */ - - win += inc; - tmpW16ptr++; - } - } - - /* Make the linear interpolation between the forward PLC'd data - and the backward PLC'd data (from the new frame) - */ - - if (plc_blockl==40) { - inc=400; /* 1/41 in Q14 */ - } else { /* plc_blockl==80 */ - inc=202; /* 1/81 in Q14 */ - } - win=0; - enh_bufPtr1=&enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl]; - for (i=0; i> 14); - *enh_bufPtr1 += (int16_t)( - ((16384 - win) * plc_pred[plc_blockl - 1 - i]) >> 14); - enh_bufPtr1--; - } - } else { - int16_t *synt = &downsampled[LPC_FILTERORDER]; - - enh_bufPtr1=&enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl]; - WEBRTC_SPL_MEMCPY_W16(enh_bufPtr1, plc_pred, plc_blockl); - - /* Clear fileter memory */ - WebRtcSpl_MemSetW16(iLBCdec_inst->syntMem, 0, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemy, 0, 4); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); - - /* Initialize filter memory by filtering through 2 lags */ - WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], iLBCdec_inst->syntMem, - LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - enh_bufPtr1, - synt, - &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, lag); - - WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], - LPC_FILTERORDER); - WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - lag); - WebRtcSpl_FilterARFastQ12( - enh_bufPtr1, synt, - &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, lag); - - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], - LPC_FILTERORDER); - WebRtcIlbcfix_HpOutput(synt, (int16_t*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - lag); - } - } - - - /* Perform enhancement block by block */ - - for (iblock = 0; iblock -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * interface for enhancer - *---------------------------------------------------------------*/ - -size_t // (o) Estimated lag in end of in[] -WebRtcIlbcfix_EnhancerInterface(int16_t* out, // (o) enhanced signal - const int16_t* in, // (i) unenhanced signal - IlbcDecoder* iLBCdec_inst); // (i) buffers etc - -#endif diff --git a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c deleted file mode 100644 index 6b4f30c96b..0000000000 --- a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FilteredCbVecs.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Construct an additional codebook vector by filtering the - * initial codebook buffer. This vector is then used to expand - * the codebook with an additional section. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_FilteredCbVecs( - int16_t *cbvectors, /* (o) Codebook vector for the higher section */ - int16_t *CBmem, /* (i) Codebook memory that is filtered to create a - second CB section */ - size_t lMem, /* (i) Length of codebook memory */ - size_t samples /* (i) Number of samples to filter */ - ) { - - /* Set up the memory, start with zero state */ - WebRtcSpl_MemSetW16(CBmem+lMem, 0, CB_HALFFILTERLEN); - WebRtcSpl_MemSetW16(CBmem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN); - WebRtcSpl_MemSetW16(cbvectors, 0, lMem-samples); - - /* Filter to obtain the filtered CB memory */ - - WebRtcSpl_FilterMAFastQ12( - CBmem+CB_HALFFILTERLEN+lMem-samples, cbvectors+lMem-samples, - (int16_t*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, samples); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h deleted file mode 100644 index d0f5f1a4ed..0000000000 --- a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FilteredCbVecs.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Construct an additional codebook vector by filtering the - * initial codebook buffer. This vector is then used to expand - * the codebook with an additional section. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_FilteredCbVecs( - int16_t* cbvectors, /* (o) Codebook vector for the higher section */ - int16_t* CBmem, /* (i) Codebook memory that is filtered to create a - second CB section */ - size_t lMem, /* (i) Length of codebook memory */ - size_t samples /* (i) Number of samples to filter */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/frame_classify.c b/modules/audio_coding/codecs/ilbc/frame_classify.c deleted file mode 100644 index c1084b1645..0000000000 --- a/modules/audio_coding/codecs/ilbc/frame_classify.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FrameClassify.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/frame_classify.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Classification of subframes to localize start state - *---------------------------------------------------------------*/ - -size_t WebRtcIlbcfix_FrameClassify( - /* (o) Index to the max-energy sub frame */ - IlbcEncoder *iLBCenc_inst, - /* (i/o) the encoder state structure */ - int16_t *residualFIX /* (i) lpc residual signal */ - ){ - int16_t max, scale; - int32_t ssqEn[NSUB_MAX-1]; - int16_t *ssqPtr; - int32_t *seqEnPtr; - int32_t maxW32; - int16_t scale1; - size_t pos; - size_t n; - - /* - Calculate the energy of each of the 80 sample blocks - in the draft the 4 first and last samples are windowed with 1/5...4/5 - and 4/5...1/5 respectively. To simplify for the fixpoint we have changed - this to 0 0 1 1 and 1 1 0 0 - */ - - max = WebRtcSpl_MaxAbsValueW16(residualFIX, iLBCenc_inst->blockl); - scale = WebRtcSpl_GetSizeInBits((uint32_t)(max * max)); - - /* Scale to maximum 24 bits so that it won't overflow for 76 samples */ - scale = scale-24; - scale1 = WEBRTC_SPL_MAX(0, scale); - - /* Calculate energies */ - ssqPtr=residualFIX + 2; - seqEnPtr=ssqEn; - for (n=(iLBCenc_inst->nsub-1); n>0; n--) { - (*seqEnPtr) = WebRtcSpl_DotProductWithScale(ssqPtr, ssqPtr, 76, scale1); - ssqPtr += 40; - seqEnPtr++; - } - - /* Scale to maximum 20 bits in order to allow for the 11 bit window */ - maxW32 = WebRtcSpl_MaxValueW32(ssqEn, iLBCenc_inst->nsub - 1); - scale = WebRtcSpl_GetSizeInBits(maxW32) - 20; - scale1 = WEBRTC_SPL_MAX(0, scale); - - /* Window each 80 block with the ssqEn_winTbl window to give higher probability for - the blocks in the middle - */ - seqEnPtr=ssqEn; - if (iLBCenc_inst->mode==20) { - ssqPtr=(int16_t*)WebRtcIlbcfix_kStartSequenceEnrgWin+1; - } else { - ssqPtr=(int16_t*)WebRtcIlbcfix_kStartSequenceEnrgWin; - } - for (n=(iLBCenc_inst->nsub-1); n>0; n--) { - (*seqEnPtr)=WEBRTC_SPL_MUL(((*seqEnPtr)>>scale1), (*ssqPtr)); - seqEnPtr++; - ssqPtr++; - } - - /* Extract the best choise of start state */ - pos = WebRtcSpl_MaxIndexW32(ssqEn, iLBCenc_inst->nsub - 1) + 1; - - return(pos); -} diff --git a/modules/audio_coding/codecs/ilbc/frame_classify.h b/modules/audio_coding/codecs/ilbc/frame_classify.h deleted file mode 100644 index dee67cc5f9..0000000000 --- a/modules/audio_coding/codecs/ilbc/frame_classify.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FrameClassify.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -size_t WebRtcIlbcfix_FrameClassify( - /* (o) Index to the max-energy sub frame */ - IlbcEncoder* iLBCenc_inst, - /* (i/o) the encoder state structure */ - int16_t* residualFIX /* (i) lpc residual signal */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/gain_dequant.c b/modules/audio_coding/codecs/ilbc/gain_dequant.c deleted file mode 100644 index 1357dece33..0000000000 --- a/modules/audio_coding/codecs/ilbc/gain_dequant.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainDequant.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/gain_dequant.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * decoder for quantized gains in the gain-shape coding of - * residual - *---------------------------------------------------------------*/ - -int16_t WebRtcIlbcfix_GainDequant( - /* (o) quantized gain value (Q14) */ - int16_t index, /* (i) quantization index */ - int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ - int16_t stage /* (i) The stage of the search */ - ){ - int16_t scale; - const int16_t *gain; - - /* obtain correct scale factor */ - - scale=WEBRTC_SPL_ABS_W16(maxIn); - scale = WEBRTC_SPL_MAX(1638, scale); /* if lower than 0.1, set it to 0.1 */ - - /* select the quantization table and return the decoded value */ - gain = WebRtcIlbcfix_kGain[stage]; - - return (int16_t)((scale * gain[index] + 8192) >> 14); -} diff --git a/modules/audio_coding/codecs/ilbc/gain_dequant.h b/modules/audio_coding/codecs/ilbc/gain_dequant.h deleted file mode 100644 index b5e6cef97b..0000000000 --- a/modules/audio_coding/codecs/ilbc/gain_dequant.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainDequant.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ - -#include - -/*----------------------------------------------------------------* - * decoder for quantized gains in the gain-shape coding of - * residual - *---------------------------------------------------------------*/ - -int16_t WebRtcIlbcfix_GainDequant( - /* (o) quantized gain value (Q14) */ - int16_t index, /* (i) quantization index */ - int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ - int16_t stage /* (i) The stage of the search */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/gain_quant.c b/modules/audio_coding/codecs/ilbc/gain_quant.c deleted file mode 100644 index 9a6d49d51a..0000000000 --- a/modules/audio_coding/codecs/ilbc/gain_quant.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainQuant.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/gain_quant.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * quantizer for the gain in the gain-shape coding of residual - *---------------------------------------------------------------*/ - -int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ - int16_t gain, /* (i) gain value Q14 */ - int16_t maxIn, /* (i) maximum of gain value Q14 */ - int16_t stage, /* (i) The stage of the search */ - int16_t *index /* (o) quantization index */ - ) { - - int16_t scale, cblen; - int32_t gainW32, measure1, measure2; - const int16_t *cbPtr, *cb; - int loc, noMoves, noChecks, i; - - /* ensure a lower bound (0.1) on the scaling factor */ - - scale = WEBRTC_SPL_MAX(1638, maxIn); - - /* select the quantization table and calculate - the length of the table and the number of - steps in the binary search that are needed */ - cb = WebRtcIlbcfix_kGain[stage]; - cblen = 32>>stage; - noChecks = 4-stage; - - /* Multiply the gain with 2^14 to make the comparison - easier and with higher precision */ - gainW32 = gain << 14; - - /* Do a binary search, starting in the middle of the CB - loc - defines the current position in the table - noMoves - defines the number of steps to move in the CB in order - to get next CB location - */ - - loc = cblen>>1; - noMoves = loc; - cbPtr = cb + loc; /* Centre of CB */ - - for (i=noChecks;i>0;i--) { - noMoves>>=1; - measure1 = scale * *cbPtr; - - /* Move up if gain is larger, otherwise move down in table */ - measure1 = measure1 - gainW32; - - if (0>measure1) { - cbPtr+=noMoves; - loc+=noMoves; - } else { - cbPtr-=noMoves; - loc-=noMoves; - } - } - - /* Check which value is the closest one: loc-1, loc or loc+1 */ - - measure1 = scale * *cbPtr; - if (gainW32>measure1) { - /* Check against value above loc */ - measure2 = scale * cbPtr[1]; - if ((measure2-gainW32)<(gainW32-measure1)) { - loc+=1; - } - } else { - /* Check against value below loc */ - measure2 = scale * cbPtr[-1]; - if ((gainW32-measure2)<=(measure1-gainW32)) { - loc-=1; - } - } - - /* Guard against getting outside the table. The calculation above can give a location - which is one above the maximum value (in very rare cases) */ - loc=WEBRTC_SPL_MIN(loc, (cblen-1)); - *index=loc; - - /* Calculate and return the quantized gain value (in Q14) */ - return (int16_t)((scale * cb[loc] + 8192) >> 14); -} diff --git a/modules/audio_coding/codecs/ilbc/gain_quant.h b/modules/audio_coding/codecs/ilbc/gain_quant.h deleted file mode 100644 index fab9718a75..0000000000 --- a/modules/audio_coding/codecs/ilbc/gain_quant.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainQuant.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ - -#include - -/*----------------------------------------------------------------* - * quantizer for the gain in the gain-shape coding of residual - *---------------------------------------------------------------*/ - -int16_t -WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ - int16_t gain, /* (i) gain value Q14 */ - int16_t maxIn, /* (i) maximum of gain value Q14 */ - int16_t stage, /* (i) The stage of the search */ - int16_t* index /* (o) quantization index */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/get_cd_vec.c b/modules/audio_coding/codecs/ilbc/get_cd_vec.c deleted file mode 100644 index e9cd2008e0..0000000000 --- a/modules/audio_coding/codecs/ilbc/get_cd_vec.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetCbVec.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/get_cd_vec.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/create_augmented_vec.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Construct codebook vector for given index. - *---------------------------------------------------------------*/ - -bool WebRtcIlbcfix_GetCbVec( - int16_t *cbvec, /* (o) Constructed codebook vector */ - int16_t *mem, /* (i) Codebook buffer */ - size_t index, /* (i) Codebook index */ - size_t lMem, /* (i) Length of codebook buffer */ - size_t cbveclen /* (i) Codebook vector length */ - ){ - size_t k, base_size; - size_t lag; - /* Stack based */ - int16_t tempbuff2[SUBL+5]; - - /* Determine size of codebook sections */ - - base_size=lMem-cbveclen+1; - - if (cbveclen==SUBL) { - base_size += cbveclen / 2; - } - - /* No filter -> First codebook section */ - - if (index -#include -#include - -#include "absl/base/attributes.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -// Returns true on success, false on failure. In case of failure, the decoder -// state may be corrupted and needs resetting. -ABSL_MUST_USE_RESULT -bool WebRtcIlbcfix_GetCbVec( - int16_t* cbvec, /* (o) Constructed codebook vector */ - int16_t* mem, /* (i) Codebook buffer */ - size_t index, /* (i) Codebook index */ - size_t lMem, /* (i) Length of codebook buffer */ - size_t cbveclen /* (i) Codebook vector length */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/get_lsp_poly.c b/modules/audio_coding/codecs/ilbc/get_lsp_poly.c deleted file mode 100644 index e0fb21caf0..0000000000 --- a/modules/audio_coding/codecs/ilbc/get_lsp_poly.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetLspPoly.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Construct the polynomials F1(z) and F2(z) from the LSP - * (Computations are done in Q24) - * - * The expansion is performed using the following recursion: - * - * f[0] = 1; - * tmp = -2.0 * lsp[0]; - * f[1] = tmp; - * for (i=2; i<=5; i++) { - * b = -2.0 * lsp[2*i-2]; - * f[i] = tmp*f[i-1] + 2.0*f[i-2]; - * for (j=i; j>=2; j--) { - * f[j] = f[j] + tmp*f[j-1] + f[j-2]; - * } - * f[i] = f[i] + tmp; - * } - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetLspPoly( - int16_t *lsp, /* (i) LSP in Q15 */ - int32_t *f) /* (o) polonymial in Q24 */ -{ - int32_t tmpW32; - int i, j; - int16_t high, low; - int16_t *lspPtr; - int32_t *fPtr; - - lspPtr = lsp; - fPtr = f; - /* f[0] = 1.0 (Q24) */ - (*fPtr) = (int32_t)16777216; - fPtr++; - - (*fPtr) = WEBRTC_SPL_MUL((*lspPtr), -1024); - fPtr++; - lspPtr+=2; - - for(i=2; i<=5; i++) - { - (*fPtr) = fPtr[-2]; - - for(j=i; j>1; j--) - { - /* Compute f[j] = f[j] + tmp*f[j-1] + f[j-2]; */ - high = (int16_t)(fPtr[-1] >> 16); - low = (int16_t)((fPtr[-1] & 0xffff) >> 1); - - tmpW32 = 4 * high * *lspPtr + 4 * ((low * *lspPtr) >> 15); - - (*fPtr) += fPtr[-2]; - (*fPtr) -= tmpW32; - fPtr--; - } - *fPtr -= *lspPtr * (1 << 10); - - fPtr+=i; - lspPtr+=2; - } - return; -} diff --git a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h b/modules/audio_coding/codecs/ilbc/get_lsp_poly.h deleted file mode 100644 index 70c9c4d4b4..0000000000 --- a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetLspPoly.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ - -#include - -/*----------------------------------------------------------------* - * Construct the polynomials F1(z) and F2(z) from the LSP - * (Computations are done in Q24) - * - * The expansion is performed using the following recursion: - * - * f[0] = 1; - * tmp = -2.0 * lsp[0]; - * f[1] = tmp; - * for (i=2; i<=5; i++) { - * b = -2.0 * lsp[2*i-2]; - * f[i] = tmp*f[i-1] + 2.0*f[i-2]; - * for (j=i; j>=2; j--) { - * f[j] = f[j] + tmp*f[j-1] + f[j-2]; - * } - * f[i] = f[i] + tmp; - * } - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetLspPoly(int16_t* lsp, /* (i) LSP in Q15 */ - int32_t* f); /* (o) polonymial in Q24 */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/get_sync_seq.c b/modules/audio_coding/codecs/ilbc/get_sync_seq.c deleted file mode 100644 index 68a569a40a..0000000000 --- a/modules/audio_coding/codecs/ilbc/get_sync_seq.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetSyncSeq.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/get_sync_seq.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/nearest_neighbor.h" -#include "modules/audio_coding/codecs/ilbc/refiner.h" - -/*----------------------------------------------------------------* - * get the pitch-synchronous sample sequence - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetSyncSeq( - int16_t *idata, /* (i) original data */ - size_t idatal, /* (i) dimension of data */ - size_t centerStartPos, /* (i) where current block starts */ - size_t *period, /* (i) rough-pitch-period array (Q-2) */ - const size_t *plocs, /* (i) where periods of period array are taken (Q-2) */ - size_t periodl, /* (i) dimension period array */ - size_t hl, /* (i) 2*hl+1 is the number of sequences */ - int16_t *surround /* (i/o) The contribution from this sequence - summed with earlier contributions */ - ){ - size_t i, centerEndPos, q; - /* Stack based */ - size_t lagBlock[2 * ENH_HL + 1]; - size_t blockStartPos[2 * ENH_HL + 1]; /* The position to search around (Q2) */ - size_t plocs2[ENH_PLOCSL]; - - centerEndPos = centerStartPos + ENH_BLOCKL - 1; - - /* present (find predicted lag from this position) */ - - WebRtcIlbcfix_NearestNeighbor(lagBlock + hl, - plocs, - 2 * (centerStartPos + centerEndPos), - periodl); - - blockStartPos[hl] = 4 * centerStartPos; - - /* past (find predicted position and perform a refined - search to find the best sequence) */ - - for (q = hl; q > 0; q--) { - size_t qq = q - 1; - size_t period_q = period[lagBlock[q]]; - /* Stop if this sequence would be outside the buffer; that means all - further-past sequences would also be outside the buffer. */ - if (blockStartPos[q] < period_q + (4 * ENH_OVERHANG)) - break; - blockStartPos[qq] = blockStartPos[q] - period_q; - - size_t value = blockStartPos[qq] + 4 * ENH_BLOCKL_HALF; - value = (value > period_q) ? (value - period_q) : 0; - WebRtcIlbcfix_NearestNeighbor(lagBlock + qq, plocs, value, periodl); - - /* Find the best possible sequence in the 4 times upsampled - domain around blockStartPos+q */ - WebRtcIlbcfix_Refiner(blockStartPos + qq, idata, idatal, centerStartPos, - blockStartPos[qq], surround, - WebRtcIlbcfix_kEnhWt[qq]); - } - - /* future (find predicted position and perform a refined - search to find the best sequence) */ - - for (i = 0; i < periodl; i++) { - plocs2[i] = plocs[i] - period[i]; - } - - for (q = hl + 1; q <= (2 * hl); q++) { - - WebRtcIlbcfix_NearestNeighbor( - lagBlock + q, - plocs2, - blockStartPos[q - 1] + 4 * ENH_BLOCKL_HALF, - periodl); - - blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]]; - - if (blockStartPos[q] + 4 * (ENH_BLOCKL + ENH_OVERHANG) < 4 * idatal) { - - /* Find the best possible sequence in the 4 times upsampled - domain around blockStartPos+q */ - WebRtcIlbcfix_Refiner(blockStartPos + q, idata, idatal, centerStartPos, - blockStartPos[q], surround, - WebRtcIlbcfix_kEnhWt[2 * hl - q]); - - } else { - /* Don't add anything since this sequence would - be outside the buffer */ - } - } -} diff --git a/modules/audio_coding/codecs/ilbc/get_sync_seq.h b/modules/audio_coding/codecs/ilbc/get_sync_seq.h deleted file mode 100644 index 87030e568f..0000000000 --- a/modules/audio_coding/codecs/ilbc/get_sync_seq.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetSyncSeq.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ - -#include -#include - -/*----------------------------------------------------------------* - * get the pitch-synchronous sample sequence - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetSyncSeq( - int16_t* idata, /* (i) original data */ - size_t idatal, /* (i) dimension of data */ - size_t centerStartPos, /* (i) where current block starts */ - size_t* period, /* (i) rough-pitch-period array (Q-2) */ - const size_t* plocs, /* (i) where periods of period array are taken (Q-2) */ - size_t periodl, /* (i) dimension period array */ - size_t hl, /* (i) 2*hl+1 is the number of sequences */ - int16_t* surround /* (i/o) The contribution from this sequence - summed with earlier contributions */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/hp_input.c b/modules/audio_coding/codecs/ilbc/hp_input.c deleted file mode 100644 index be582f2e23..0000000000 --- a/modules/audio_coding/codecs/ilbc/hp_input.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpInput.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/hp_input.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * high-pass filter of input with *0.5 and saturation - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_HpInput( - int16_t *signal, /* (i/o) signal vector */ - int16_t *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */ - size_t len) /* (i) Number of samples to filter */ -{ - size_t i; - int32_t tmpW32; - int32_t tmpW32b; - - for (i=0; i>15); - tmpW32 += y[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */ - tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */ - tmpW32 = (tmpW32<<1); - - tmpW32 += signal[i] * ba[0]; /* b[0]*x[0] */ - tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */ - tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */ - - /* Update state (input part) */ - x[1] = x[0]; - x[0] = signal[i]; - - /* Rounding in Q(12+1), i.e. add 2^12 */ - tmpW32b = tmpW32 + 4096; - - /* Saturate (to 2^28) so that the HP filtered signal does not overflow */ - tmpW32b = WEBRTC_SPL_SAT((int32_t)268435455, tmpW32b, (int32_t)-268435456); - - /* Convert back to Q0 and multiply with 0.5 */ - signal[i] = (int16_t)(tmpW32b >> 13); - - /* Update state (filtered part) */ - y[2] = y[0]; - y[3] = y[1]; - - /* upshift tmpW32 by 3 with saturation */ - if (tmpW32>268435455) { - tmpW32 = WEBRTC_SPL_WORD32_MAX; - } else if (tmpW32<-268435456) { - tmpW32 = WEBRTC_SPL_WORD32_MIN; - } else { - tmpW32 <<= 3; - } - - y[0] = (int16_t)(tmpW32 >> 16); - y[1] = (int16_t)((tmpW32 - (y[0] << 16)) >> 1); - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/hp_input.h b/modules/audio_coding/codecs/ilbc/hp_input.h deleted file mode 100644 index 9143d8efed..0000000000 --- a/modules/audio_coding/codecs/ilbc/hp_input.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpInput.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ - -#include -#include - -// clang-format off -// Bad job here. https://bugs.llvm.org/show_bug.cgi?id=34274 -void WebRtcIlbcfix_HpInput( - int16_t* signal, /* (i/o) signal vector */ - int16_t* ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} - a[0] is assumed to be 1.0 */ - int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ - size_t len); /* (i) Number of samples to filter */ -// clang-format on - -#endif diff --git a/modules/audio_coding/codecs/ilbc/hp_output.c b/modules/audio_coding/codecs/ilbc/hp_output.c deleted file mode 100644 index cc5f6dcd37..0000000000 --- a/modules/audio_coding/codecs/ilbc/hp_output.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpOutput.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/hp_output.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * high-pass filter of output and *2 with saturation - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_HpOutput( - int16_t *signal, /* (i/o) signal vector */ - int16_t *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */ - size_t len) /* (i) Number of samples to filter */ -{ - size_t i; - int32_t tmpW32; - int32_t tmpW32b; - - for (i=0; i>15); - tmpW32 += y[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */ - tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */ - tmpW32 *= 2; - - tmpW32 += signal[i] * ba[0]; /* b[0]*x[0] */ - tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */ - tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */ - - /* Update state (input part) */ - x[1] = x[0]; - x[0] = signal[i]; - - /* Rounding in Q(12-1), i.e. add 2^10 */ - tmpW32b = tmpW32 + 1024; - - /* Saturate (to 2^26) so that the HP filtered signal does not overflow */ - tmpW32b = WEBRTC_SPL_SAT((int32_t)67108863, tmpW32b, (int32_t)-67108864); - - /* Convert back to Q0 and multiply with 2 */ - signal[i] = (int16_t)(tmpW32b >> 11); - - /* Update state (filtered part) */ - y[2] = y[0]; - y[3] = y[1]; - - /* upshift tmpW32 by 3 with saturation */ - if (tmpW32>268435455) { - tmpW32 = WEBRTC_SPL_WORD32_MAX; - } else if (tmpW32<-268435456) { - tmpW32 = WEBRTC_SPL_WORD32_MIN; - } else { - tmpW32 *= 8; - } - - y[0] = (int16_t)(tmpW32 >> 16); - y[1] = (int16_t)((tmpW32 & 0xffff) >> 1); - - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/hp_output.h b/modules/audio_coding/codecs/ilbc/hp_output.h deleted file mode 100644 index 6d1bd3cd88..0000000000 --- a/modules/audio_coding/codecs/ilbc/hp_output.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpOutput.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ - -#include -#include - -// clang-format off -// Bad job here. https://bugs.llvm.org/show_bug.cgi?id=34274 -void WebRtcIlbcfix_HpOutput( - int16_t* signal, /* (i/o) signal vector */ - int16_t* ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */ - size_t len); /* (i) Number of samples to filter */ -// clang-format on - -#endif diff --git a/modules/audio_coding/codecs/ilbc/ilbc.c b/modules/audio_coding/codecs/ilbc/ilbc.c deleted file mode 100644 index ba6c3e46c3..0000000000 --- a/modules/audio_coding/codecs/ilbc/ilbc.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBCInterface.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/ilbc.h" - -#include - -#include "modules/audio_coding/codecs/ilbc/decode.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/encode.h" -#include "modules/audio_coding/codecs/ilbc/init_decode.h" -#include "modules/audio_coding/codecs/ilbc/init_encode.h" -#include "rtc_base/checks.h" - -int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst, - int16_t* ILBCENC_inst_Addr, - int16_t* size) { - *iLBC_encinst=(IlbcEncoderInstance*)ILBCENC_inst_Addr; - *size=sizeof(IlbcEncoder)/sizeof(int16_t); - if (*iLBC_encinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst, - int16_t* ILBCDEC_inst_Addr, - int16_t* size) { - *iLBC_decinst=(IlbcDecoderInstance*)ILBCDEC_inst_Addr; - *size=sizeof(IlbcDecoder)/sizeof(int16_t); - if (*iLBC_decinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst) { - *iLBC_encinst=(IlbcEncoderInstance*)malloc(sizeof(IlbcEncoder)); - if (*iLBC_encinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst) { - *iLBC_decinst=(IlbcDecoderInstance*)malloc(sizeof(IlbcDecoder)); - if (*iLBC_decinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst) { - free(iLBC_encinst); - return(0); -} - -int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst) { - free(iLBC_decinst); - return(0); -} - -int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst, - int16_t mode) { - if ((mode==20)||(mode==30)) { - WebRtcIlbcfix_InitEncode((IlbcEncoder*) iLBCenc_inst, mode); - return(0); - } else { - return(-1); - } -} - -int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, - const int16_t* speechIn, - size_t len, - uint8_t* encoded) { - size_t pos = 0; - size_t encpos = 0; - - if ((len != ((IlbcEncoder*)iLBCenc_inst)->blockl) && -#ifdef SPLIT_10MS - (len != 80) && -#endif - (len != 2*((IlbcEncoder*)iLBCenc_inst)->blockl) && - (len != 3*((IlbcEncoder*)iLBCenc_inst)->blockl)) - { - /* A maximum of 3 frames/packet is allowed */ - return(-1); - } else { - - /* call encoder */ - while (possection == 0) -#else - pos += ((IlbcEncoder*)iLBCenc_inst)->blockl; -#endif - encpos += ((IlbcEncoder*)iLBCenc_inst)->no_of_words; - } - return (int)(encpos*2); - } -} - -int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, - int16_t mode) { - if ((mode==20)||(mode==30)) { - WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, mode, 1); - return(0); - } else { - return(-1); - } -} -void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst) { - WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 20, 1); -} -void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst) { - WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 30, 1); -} - - -int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType) -{ - size_t i=0; - /* Allow for automatic switching between the frame sizes - (although you do get some discontinuity) */ - if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - /* Test if the mode has changed */ - if (((IlbcDecoder*)iLBCdec_inst)->mode==20) { - if ((len==NO_OF_BYTES_30MS)|| - (len==2*NO_OF_BYTES_30MS)|| - (len==3*NO_OF_BYTES_30MS)) { - WebRtcIlbcfix_InitDecode( - ((IlbcDecoder*)iLBCdec_inst), 30, - ((IlbcDecoder*)iLBCdec_inst)->use_enhancer); - } else { - /* Unsupported frame length */ - return(-1); - } - } else { - if ((len==NO_OF_BYTES_20MS)|| - (len==2*NO_OF_BYTES_20MS)|| - (len==3*NO_OF_BYTES_20MS)) { - WebRtcIlbcfix_InitDecode( - ((IlbcDecoder*)iLBCdec_inst), 20, - ((IlbcDecoder*)iLBCdec_inst)->use_enhancer); - } else { - /* Unsupported frame length */ - return(-1); - } - } - } - - while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)blockl], - (const uint16_t*)&encoded - [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], - (IlbcDecoder*)iLBCdec_inst, 1) == -1) - return -1; - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); -} - -int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType) -{ - size_t i=0; - if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - return(-1); - } - - while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)blockl], - (const uint16_t*)&encoded - [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], - (IlbcDecoder*)iLBCdec_inst, 1)) - return -1; - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); -} - -int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType) -{ - size_t i=0; - if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - return(-1); - } - - while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)blockl], - (const uint16_t*)&encoded - [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], - (IlbcDecoder*)iLBCdec_inst, 1)) - return -1; - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); -} - -size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, - int16_t* decoded, - size_t noOfLostFrames) { - size_t i; - uint16_t dummy; - - for (i=0;iblockl], &dummy, - (IlbcDecoder*)iLBCdec_inst, 0); - RTC_CHECK_EQ(result, 0); - } - return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl); -} - -size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, - int16_t* decoded, - size_t noOfLostFrames) { - /* Two input parameters not used, but needed for function pointers in NetEQ */ - (void)(decoded = NULL); - (void)(noOfLostFrames = 0); - - WebRtcSpl_MemSetW16(((IlbcDecoder*)iLBCdec_inst)->enh_buf, 0, ENH_BUFL); - ((IlbcDecoder*)iLBCdec_inst)->prev_enh_pl = 2; - - return (0); -} - -void WebRtcIlbcfix_version(char *version) -{ - strcpy((char*)version, "1.1.1"); -} diff --git a/modules/audio_coding/codecs/ilbc/ilbc.h b/modules/audio_coding/codecs/ilbc/ilbc.h deleted file mode 100644 index de8cfde111..0000000000 --- a/modules/audio_coding/codecs/ilbc/ilbc.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * ilbc.h - * - * This header file contains all of the API's for iLBC. - * - */ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_ - -#include -#include - -/* - * Solution to support multiple instances - * Customer has to cast instance to proper type - */ - -typedef struct iLBC_encinst_t_ IlbcEncoderInstance; - -typedef struct iLBC_decinst_t_ IlbcDecoderInstance; - -/* - * Comfort noise constants - */ - -#define ILBC_SPEECH 1 -#define ILBC_CNG 2 - -#ifdef __cplusplus -extern "C" { -#endif - -/**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions assigns the encoder/decoder instance to the specified - * memory location - * - * Input: - * - XXX_xxxinst : Pointer to created instance that should be - * assigned - * - ILBCXXX_inst_Addr : Pointer to the desired memory space - * - size : The size that this structure occupies (in Word16) - * - * Return value : 0 - Ok - * -1 - Error - */ - -int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst, - int16_t* ILBCENC_inst_Addr, - int16_t* size); -int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst, - int16_t* ILBCDEC_inst_Addr, - int16_t* size); - -/**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions create a instance to the specified structure - * - * Input: - * - XXX_inst : Pointer to created instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - -int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance** iLBC_encinst); -int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance** iLBC_decinst); - -/**************************************************************************** - * WebRtcIlbcfix_XxxFree(...) - * - * These functions frees the dynamic memory of a specified instance - * - * Input: - * - XXX_inst : Pointer to created instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ - -int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance* iLBC_encinst); -int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance* iLBC_decinst); - -/**************************************************************************** - * WebRtcIlbcfix_EncoderInit(...) - * - * This function initializes a iLBC instance - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should receive - * be initialized - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ - -int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst, - int16_t frameLen); - -/**************************************************************************** - * WebRtcIlbcfix_Encode(...) - * - * This function encodes one iLBC frame. Input speech length has be a - * multiple of the frame length. - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should encode - * a package - * - speechIn : Input speech vector - * - len : Samples in speechIn (160, 240, 320 or 480) - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - -int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, - const int16_t* speechIn, - size_t len, - uint8_t* encoded); - -/**************************************************************************** - * WebRtcIlbcfix_DecoderInit(...) - * - * This function initializes a iLBC instance with either 20 or 30 ms frames - * Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's - * not needed to specify the frame length with a variable. - * - * Input: - * - IlbcDecoderInstance : iLBC decoder instance - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ - -int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, - int16_t frameLen); -void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst); -void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst); - -/**************************************************************************** - * WebRtcIlbcfix_Decode(...) - * - * This function decodes a packet with iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet). - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should decode - * a packet - * - encoded : Encoded iLBC frame(s) - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ - -int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); -int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); -int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, - const uint8_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); - -/**************************************************************************** - * WebRtcIlbcfix_DecodePlc(...) - * - * This function conducts PLC for iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples. - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should perform - * a PLC - * - noOfLostFrames : Number of PLC frames to produce - * - * Output: - * - decoded : The "decoded" vector - * - * Return value : Samples in decoded PLC vector - */ - -size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, - int16_t* decoded, - size_t noOfLostFrames); - -/**************************************************************************** - * WebRtcIlbcfix_NetEqPlc(...) - * - * This function updates the decoder when a packet loss has occured, but it - * does not produce any PLC data. Function can be used if another PLC method - * is used (i.e NetEq). - * - * Input: - * - iLBCdec_inst : iLBC instance that should be updated - * - noOfLostFrames : Number of lost frames - * - * Output: - * - decoded : The "decoded" vector (nothing in this case) - * - * Return value : Samples in decoded PLC vector - */ - -size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, - int16_t* decoded, - size_t noOfLostFrames); - -/**************************************************************************** - * WebRtcIlbcfix_version(...) - * - * This function returns the version number of iLBC - * - * Output: - * - version : Version number of iLBC (maximum 20 char) - */ - -void WebRtcIlbcfix_version(char* version); - -#ifdef __cplusplus -} -#endif - -#endif // MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_ diff --git a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc b/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc deleted file mode 100644 index 6660dae6a9..0000000000 --- a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" -#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" -#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" -#include "test/gtest.h" - -namespace webrtc { - -// TODO(bugs.webrtc.org/345525069): Either fix/enable or remove iLBC. -#if defined(__has_feature) && __has_feature(undefined_behavior_sanitizer) -TEST(IlbcTest, DISABLED_BadPacket) { -#else -TEST(IlbcTest, BadPacket) { -#endif - // Get a good packet. - AudioEncoderIlbcConfig config; - config.frame_size_ms = 20; // We need 20 ms rather than the default 30 ms; - // otherwise, all possible values of cb_index[2] - // are valid. - AudioEncoderIlbcImpl encoder(config, 102); - std::vector samples(encoder.SampleRateHz() / 100, 4711); - rtc::Buffer packet; - int num_10ms_chunks = 0; - while (packet.size() == 0) { - encoder.Encode(0, samples, &packet); - num_10ms_chunks += 1; - } - - // Break the packet by setting all bits of the unsigned 7-bit number - // cb_index[2] to 1, giving it a value of 127. For a 20 ms packet, this is - // too large. - EXPECT_EQ(38u, packet.size()); - rtc::Buffer bad_packet(packet.data(), packet.size()); - bad_packet[29] |= 0x3f; // Bits 1-6. - bad_packet[30] |= 0x80; // Bit 0. - - // Decode the bad packet. We expect the decoder to respond by returning -1. - AudioDecoderIlbcImpl decoder; - std::vector decoded_samples(num_10ms_chunks * samples.size()); - AudioDecoder::SpeechType speech_type; - EXPECT_EQ(-1, decoder.Decode(bad_packet.data(), bad_packet.size(), - encoder.SampleRateHz(), - sizeof(int16_t) * decoded_samples.size(), - decoded_samples.data(), &speech_type)); - - // Decode the good packet. This should work, because the failed decoding - // should not have left the decoder in a broken state. - EXPECT_EQ(static_cast(decoded_samples.size()), - decoder.Decode(packet.data(), packet.size(), encoder.SampleRateHz(), - sizeof(int16_t) * decoded_samples.size(), - decoded_samples.data(), &speech_type)); -} - -class SplitIlbcTest : public ::testing::TestWithParam > { - protected: - virtual void SetUp() { - const std::pair parameters = GetParam(); - num_frames_ = parameters.first; - frame_length_ms_ = parameters.second; - frame_length_bytes_ = (frame_length_ms_ == 20) ? 38 : 50; - } - size_t num_frames_; - int frame_length_ms_; - size_t frame_length_bytes_; -}; - -TEST_P(SplitIlbcTest, NumFrames) { - AudioDecoderIlbcImpl decoder; - const size_t frame_length_samples = frame_length_ms_ * 8; - const auto generate_payload = [](size_t payload_length_bytes) { - rtc::Buffer payload(payload_length_bytes); - // Fill payload with increasing integers {0, 1, 2, ...}. - for (size_t i = 0; i < payload.size(); ++i) { - payload[i] = static_cast(i); - } - return payload; - }; - - const auto results = decoder.ParsePayload( - generate_payload(frame_length_bytes_ * num_frames_), 0); - EXPECT_EQ(num_frames_, results.size()); - - size_t frame_num = 0; - uint8_t payload_value = 0; - for (const auto& result : results) { - EXPECT_EQ(frame_length_samples * frame_num, result.timestamp); - const LegacyEncodedAudioFrame* frame = - static_cast(result.frame.get()); - const rtc::Buffer& payload = frame->payload(); - EXPECT_EQ(frame_length_bytes_, payload.size()); - for (size_t i = 0; i < payload.size(); ++i, ++payload_value) { - EXPECT_EQ(payload_value, payload[i]); - } - ++frame_num; - } -} - -// Test 1 through 5 frames of 20 and 30 ms size. -// Also test the maximum number of frames in one packet for 20 and 30 ms. -// The maximum is defined by the largest payload length that can be uniquely -// resolved to a frame size of either 38 bytes (20 ms) or 50 bytes (30 ms). -INSTANTIATE_TEST_SUITE_P( - IlbcTest, - SplitIlbcTest, - ::testing::Values(std::pair(1, 20), // 1 frame, 20 ms. - std::pair(2, 20), // 2 frames, 20 ms. - std::pair(3, 20), // And so on. - std::pair(4, 20), - std::pair(5, 20), - std::pair(24, 20), - std::pair(1, 30), - std::pair(2, 30), - std::pair(3, 30), - std::pair(4, 30), - std::pair(5, 30), - std::pair(18, 30))); - -// Test too large payload size. -TEST(IlbcTest, SplitTooLargePayload) { - AudioDecoderIlbcImpl decoder; - constexpr size_t kPayloadLengthBytes = 950; - const auto results = - decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0); - EXPECT_TRUE(results.empty()); -} - -// Payload not an integer number of frames. -TEST(IlbcTest, SplitUnevenPayload) { - AudioDecoderIlbcImpl decoder; - constexpr size_t kPayloadLengthBytes = 39; // Not an even number of frames. - const auto results = - decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0); - EXPECT_TRUE(results.empty()); -} - -} // namespace webrtc diff --git a/modules/audio_coding/codecs/ilbc/index_conv_dec.c b/modules/audio_coding/codecs/ilbc/index_conv_dec.c deleted file mode 100644 index d78f81a897..0000000000 --- a/modules/audio_coding/codecs/ilbc/index_conv_dec.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvDec.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_IndexConvDec( - int16_t *index /* (i/o) Codebook indexes */ - ){ - int k; - - for (k=4;k<6;k++) { - /* Readjust the second and third codebook index for the first 40 sample - so that they look the same as the first (in terms of lag) - */ - if ((index[k]>=44)&&(index[k]<108)) { - index[k]+=64; - } else if ((index[k]>=108)&&(index[k]<128)) { - index[k]+=128; - } else { - /* ERROR */ - } - } -} diff --git a/modules/audio_coding/codecs/ilbc/index_conv_dec.h b/modules/audio_coding/codecs/ilbc/index_conv_dec.h deleted file mode 100644 index 4d3f733355..0000000000 --- a/modules/audio_coding/codecs/ilbc/index_conv_dec.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvDec.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_IndexConvDec(int16_t* index /* (i/o) Codebook indexes */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/index_conv_enc.c b/modules/audio_coding/codecs/ilbc/index_conv_enc.c deleted file mode 100644 index 83144150b4..0000000000 --- a/modules/audio_coding/codecs/ilbc/index_conv_enc.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - IiLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvEnc.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/index_conv_enc.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Convert the codebook indexes to make the search easier - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_IndexConvEnc( - int16_t *index /* (i/o) Codebook indexes */ - ){ - int k; - - for (k=4;k<6;k++) { - /* Readjust the second and third codebook index so that it is - packetized into 7 bits (before it was put in lag-wise the same - way as for the first codebook which uses 8 bits) - */ - if ((index[k]>=108)&&(index[k]<172)) { - index[k]-=64; - } else if (index[k]>=236) { - index[k]-=128; - } else { - /* ERROR */ - } - } -} diff --git a/modules/audio_coding/codecs/ilbc/index_conv_enc.h b/modules/audio_coding/codecs/ilbc/index_conv_enc.h deleted file mode 100644 index 0172ac416b..0000000000 --- a/modules/audio_coding/codecs/ilbc/index_conv_enc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvEnc.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ - -#include - -/*----------------------------------------------------------------* - * Convert the codebook indexes to make the search easier - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_IndexConvEnc(int16_t* index /* (i/o) Codebook indexes */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/init_decode.c b/modules/audio_coding/codecs/ilbc/init_decode.c deleted file mode 100644 index 3eb41e33b0..0000000000 --- a/modules/audio_coding/codecs/ilbc/init_decode.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitDecode.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/init_decode.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Initiation of decoder instance. - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */ - IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */ - int16_t mode, /* (i) frame size mode */ - int use_enhancer) { /* (i) 1: use enhancer, 0: no enhancer */ - int i; - - iLBCdec_inst->mode = mode; - - /* Set all the variables that are dependent on the frame size mode */ - if (mode==30) { - iLBCdec_inst->blockl = BLOCKL_30MS; - iLBCdec_inst->nsub = NSUB_30MS; - iLBCdec_inst->nasub = NASUB_30MS; - iLBCdec_inst->lpc_n = LPC_N_30MS; - iLBCdec_inst->no_of_bytes = NO_OF_BYTES_30MS; - iLBCdec_inst->no_of_words = NO_OF_WORDS_30MS; - iLBCdec_inst->state_short_len=STATE_SHORT_LEN_30MS; - } - else if (mode==20) { - iLBCdec_inst->blockl = BLOCKL_20MS; - iLBCdec_inst->nsub = NSUB_20MS; - iLBCdec_inst->nasub = NASUB_20MS; - iLBCdec_inst->lpc_n = LPC_N_20MS; - iLBCdec_inst->no_of_bytes = NO_OF_BYTES_20MS; - iLBCdec_inst->no_of_words = NO_OF_WORDS_20MS; - iLBCdec_inst->state_short_len=STATE_SHORT_LEN_20MS; - } - else { - return(-1); - } - - /* Reset all the previous LSF to mean LSF */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - - /* Clear the synthesis filter memory */ - WebRtcSpl_MemSetW16(iLBCdec_inst->syntMem, 0, LPC_FILTERORDER); - - /* Set the old synthesis filter to {1.0 0.0 ... 0.0} */ - WebRtcSpl_MemSetW16(iLBCdec_inst->old_syntdenum, 0, ((LPC_FILTERORDER + 1)*NSUB_MAX)); - for (i=0; iold_syntdenum[i*(LPC_FILTERORDER+1)] = 4096; - } - - /* Clear the variables that are used for the PLC */ - iLBCdec_inst->last_lag = 20; - iLBCdec_inst->consPLICount = 0; - iLBCdec_inst->prevPLI = 0; - iLBCdec_inst->perSquare = 0; - iLBCdec_inst->prevLag = 120; - iLBCdec_inst->prevLpc[0] = 4096; - WebRtcSpl_MemSetW16(iLBCdec_inst->prevLpc+1, 0, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCdec_inst->prevResidual, 0, BLOCKL_MAX); - - /* Initialize the seed for the random number generator */ - iLBCdec_inst->seed = 777; - - /* Set the filter state of the HP filter to 0 */ - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemy, 0, 4); - - /* Set the variables that are used in the ehnahcer */ - iLBCdec_inst->use_enhancer = use_enhancer; - WebRtcSpl_MemSetW16(iLBCdec_inst->enh_buf, 0, (ENH_BUFL+ENH_BUFL_FILTEROVERHEAD)); - for (i=0;ienh_period[i]=160; /* Q(-4) */ - } - - iLBCdec_inst->prev_enh_pl = 0; - - return (int)(iLBCdec_inst->blockl); -} diff --git a/modules/audio_coding/codecs/ilbc/init_decode.h b/modules/audio_coding/codecs/ilbc/init_decode.h deleted file mode 100644 index 92f9ad68e7..0000000000 --- a/modules/audio_coding/codecs/ilbc/init_decode.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitDecode.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ - -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Initiation of decoder instance. - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_InitDecode(/* (o) Number of decoded samples */ - IlbcDecoder* - iLBCdec_inst, /* (i/o) Decoder instance */ - int16_t mode, /* (i) frame size mode */ - int use_enhancer /* (i) 1 to use enhancer - 0 to run without enhancer */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/init_encode.c b/modules/audio_coding/codecs/ilbc/init_encode.c deleted file mode 100644 index aa858e94bb..0000000000 --- a/modules/audio_coding/codecs/ilbc/init_encode.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitEncode.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/init_encode.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Initiation of encoder instance. - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */ - IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */ - int16_t mode) { /* (i) frame size mode */ - iLBCenc_inst->mode = mode; - - /* Set all the variables that are dependent on the frame size mode */ - if (mode==30) { - iLBCenc_inst->blockl = BLOCKL_30MS; - iLBCenc_inst->nsub = NSUB_30MS; - iLBCenc_inst->nasub = NASUB_30MS; - iLBCenc_inst->lpc_n = LPC_N_30MS; - iLBCenc_inst->no_of_bytes = NO_OF_BYTES_30MS; - iLBCenc_inst->no_of_words = NO_OF_WORDS_30MS; - iLBCenc_inst->state_short_len=STATE_SHORT_LEN_30MS; - } - else if (mode==20) { - iLBCenc_inst->blockl = BLOCKL_20MS; - iLBCenc_inst->nsub = NSUB_20MS; - iLBCenc_inst->nasub = NASUB_20MS; - iLBCenc_inst->lpc_n = LPC_N_20MS; - iLBCenc_inst->no_of_bytes = NO_OF_BYTES_20MS; - iLBCenc_inst->no_of_words = NO_OF_WORDS_20MS; - iLBCenc_inst->state_short_len=STATE_SHORT_LEN_20MS; - } - else { - return(-1); - } - - /* Clear the buffers and set the previous LSF and LSP to the mean value */ - WebRtcSpl_MemSetW16(iLBCenc_inst->anaMem, 0, LPC_FILTERORDER); - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCenc_inst->lpc_buffer, 0, LPC_LOOKBACK + BLOCKL_MAX); - - /* Set the filter state of the HP filter to 0 */ - WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemx, 0, 2); - WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemy, 0, 4); - -#ifdef SPLIT_10MS - /*Zeroing the past samples for 10msec Split*/ - WebRtcSpl_MemSetW16(iLBCenc_inst->past_samples,0,160); - iLBCenc_inst->section = 0; -#endif - - return (int)(iLBCenc_inst->no_of_bytes); -} diff --git a/modules/audio_coding/codecs/ilbc/init_encode.h b/modules/audio_coding/codecs/ilbc/init_encode.h deleted file mode 100644 index 4a233fb946..0000000000 --- a/modules/audio_coding/codecs/ilbc/init_encode.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitEncode.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ - -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * Initiation of encoder instance. - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_InitEncode(/* (o) Number of bytes encoded */ - IlbcEncoder* - iLBCenc_inst, /* (i/o) Encoder instance */ - int16_t mode /* (i) frame size mode */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/interpolate.c b/modules/audio_coding/codecs/ilbc/interpolate.c deleted file mode 100644 index 17ed244bd4..0000000000 --- a/modules/audio_coding/codecs/ilbc/interpolate.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Interpolate.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/interpolate.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * interpolation between vectors - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Interpolate( - int16_t *out, /* (o) output vector */ - int16_t *in1, /* (i) first input vector */ - int16_t *in2, /* (i) second input vector */ - int16_t coef, /* (i) weight coefficient in Q14 */ - int16_t length) /* (i) number of sample is vectors */ -{ - int i; - int16_t invcoef; - - /* - Performs the operation out[i] = in[i]*coef + (1-coef)*in2[i] (with rounding) - */ - - invcoef = 16384 - coef; /* 16384 = 1.0 (Q14)*/ - for (i = 0; i < length; i++) { - out[i] = (int16_t)((coef * in1[i] + invcoef * in2[i] + 8192) >> 14); - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/interpolate.h b/modules/audio_coding/codecs/ilbc/interpolate.h deleted file mode 100644 index 892082b75c..0000000000 --- a/modules/audio_coding/codecs/ilbc/interpolate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Interpolate.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ - -#include - -/*----------------------------------------------------------------* - * interpolation between vectors - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Interpolate( - int16_t* out, /* (o) output vector */ - int16_t* in1, /* (i) first input vector */ - int16_t* in2, /* (i) second input vector */ - int16_t coef, /* (i) weight coefficient in Q14 */ - int16_t length); /* (i) number of sample is vectors */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/interpolate_samples.c b/modules/audio_coding/codecs/ilbc/interpolate_samples.c deleted file mode 100644 index 6dddd6fb86..0000000000 --- a/modules/audio_coding/codecs/ilbc/interpolate_samples.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InterpolateSamples.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/interpolate_samples.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -void WebRtcIlbcfix_InterpolateSamples( - int16_t *interpSamples, /* (o) The interpolated samples */ - int16_t *CBmem, /* (i) The CB memory */ - size_t lMem /* (i) Length of the CB memory */ - ) { - int16_t *ppi, *ppo, i, j, temp1, temp2; - int16_t *tmpPtr; - - /* Calculate the 20 vectors of interpolated samples (4 samples each) - that are used in the codebooks for lag 20 to 39 */ - tmpPtr = interpSamples; - for (j=0; j<20; j++) { - temp1 = 0; - temp2 = 3; - ppo = CBmem+lMem-4; - ppi = CBmem+lMem-j-24; - for (i=0; i<4; i++) { - - *tmpPtr++ = (int16_t)((WebRtcIlbcfix_kAlpha[temp2] * *ppo) >> 15) + - (int16_t)((WebRtcIlbcfix_kAlpha[temp1] * *ppi) >> 15); - - ppo++; - ppi++; - temp1++; - temp2--; - } - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/interpolate_samples.h b/modules/audio_coding/codecs/ilbc/interpolate_samples.h deleted file mode 100644 index f4fa97d477..0000000000 --- a/modules/audio_coding/codecs/ilbc/interpolate_samples.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InterpolateSamples.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Construct the interpolated samples for the Augmented CB - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_InterpolateSamples( - int16_t* interpSamples, /* (o) The interpolated samples */ - int16_t* CBmem, /* (i) The CB memory */ - size_t lMem /* (i) Length of the CB memory */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lpc_encode.c b/modules/audio_coding/codecs/ilbc/lpc_encode.c deleted file mode 100644 index 89f6d29724..0000000000 --- a/modules/audio_coding/codecs/ilbc/lpc_encode.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LpcEncode.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lpc_encode.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/lsf_check.h" -#include "modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h" -#include "modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h" -#include "modules/audio_coding/codecs/ilbc/simple_lsf_quant.h" - -/*----------------------------------------------------------------* - * lpc encoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LpcEncode( - int16_t *syntdenum, /* (i/o) synthesis filter coefficients - before/after encoding */ - int16_t *weightdenum, /* (i/o) weighting denumerator coefficients - before/after encoding */ - int16_t *lsf_index, /* (o) lsf quantization index */ - int16_t *data, /* (i) Speech to do LPC analysis on */ - IlbcEncoder *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - /* Stack based */ - int16_t lsf[LPC_FILTERORDER * LPC_N_MAX]; - int16_t lsfdeq[LPC_FILTERORDER * LPC_N_MAX]; - - /* Calculate LSF's from the input speech */ - WebRtcIlbcfix_SimpleLpcAnalysis(lsf, data, iLBCenc_inst); - - /* Quantize the LSF's */ - WebRtcIlbcfix_SimpleLsfQ(lsfdeq, lsf_index, lsf, iLBCenc_inst->lpc_n); - - /* Stableize the LSF's if needed */ - WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCenc_inst->lpc_n); - - /* Calculate the synthesis and weighting filter coefficients from - the optimal LSF and the dequantized LSF */ - WebRtcIlbcfix_SimpleInterpolateLsf(syntdenum, weightdenum, - lsf, lsfdeq, iLBCenc_inst->lsfold, - iLBCenc_inst->lsfdeqold, LPC_FILTERORDER, iLBCenc_inst); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/lpc_encode.h b/modules/audio_coding/codecs/ilbc/lpc_encode.h deleted file mode 100644 index ca050b02cc..0000000000 --- a/modules/audio_coding/codecs/ilbc/lpc_encode.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LpcEncode.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * lpc encoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LpcEncode( - int16_t* syntdenum, /* (i/o) synthesis filter coefficients - before/after encoding */ - int16_t* weightdenum, /* (i/o) weighting denumerator coefficients - before/after encoding */ - int16_t* lsf_index, /* (o) lsf quantization index */ - int16_t* data, /* (i) Speech to do LPC analysis on */ - IlbcEncoder* iLBCenc_inst - /* (i/o) the encoder state structure */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_check.c b/modules/audio_coding/codecs/ilbc/lsf_check.c deleted file mode 100644 index 9f0e19a2d9..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_check.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfCheck.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsf_check.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * check for stability of lsf coefficients - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_LsfCheck( - int16_t *lsf, /* LSF parameters */ - int dim, /* dimension of LSF */ - int NoAn) /* No of analysis per frame */ -{ - int k,n,m, Nit=2, change=0,pos; - const int16_t eps=319; /* 0.039 in Q13 (50 Hz)*/ - const int16_t eps2=160; /* eps/2.0 in Q13;*/ - const int16_t maxlsf=25723; /* 3.14; (4000 Hz)*/ - const int16_t minlsf=82; /* 0.01; (0 Hz)*/ - - /* LSF separation check*/ - for (n=0;nmaxlsf) { - lsf[pos]=maxlsf; - change=1; - } - } - } - } - - return change; -} diff --git a/modules/audio_coding/codecs/ilbc/lsf_check.h b/modules/audio_coding/codecs/ilbc/lsf_check.h deleted file mode 100644 index 9ba90a31e6..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_check.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfCheck.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ - -#include - -/*----------------------------------------------------------------* - * check for stability of lsf coefficients - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_LsfCheck(int16_t* lsf, /* LSF parameters */ - int dim, /* dimension of LSF */ - int NoAn); /* No of analysis per frame */ - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c deleted file mode 100644 index 04de5e7e6c..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LspInterpolate2PolyDec.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/interpolate.h" -#include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" - -/*----------------------------------------------------------------* - * interpolation of lsf coefficients for the decoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LspInterpolate2PolyDec( - int16_t *a, /* (o) lpc coefficients Q12 */ - int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ - int16_t coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - int16_t length /* (i) length of coefficient vectors */ - ){ - int16_t lsftmp[LPC_FILTERORDER]; - - /* interpolate LSF */ - WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); - - /* Compute the filter coefficients from the LSF */ - WebRtcIlbcfix_Lsf2Poly(a, lsftmp); -} diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h deleted file mode 100644 index a0ccfa96ac..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LspInterpolate2PolyDec.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ - -#include - -/*----------------------------------------------------------------* - * interpolation of lsf coefficients for the decoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LspInterpolate2PolyDec( - int16_t* a, /* (o) lpc coefficients Q12 */ - int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ - int16_t coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - int16_t length /* (i) length of coefficient vectors */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c deleted file mode 100644 index 618821216c..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfInterpolate2PloyEnc.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/interpolate.h" -#include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" - -/*----------------------------------------------------------------* - * lsf interpolator and conversion from lsf to a coefficients - * (subrutine to SimpleInterpolateLSF) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LsfInterpolate2PloyEnc( - int16_t *a, /* (o) lpc coefficients Q12 */ - int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */ - int16_t coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - int16_t length /* (i) length of coefficient vectors */ - ) { - /* Stack based */ - int16_t lsftmp[LPC_FILTERORDER]; - - /* interpolate LSF */ - WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); - - /* Compute the filter coefficients from the LSF */ - WebRtcIlbcfix_Lsf2Poly(a, lsftmp); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h deleted file mode 100644 index 08d1e8325a..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfInterpolate2PloyEnc.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ - -#include - -/*----------------------------------------------------------------* - * lsf interpolator and conversion from lsf to a coefficients - * (subrutine to SimpleInterpolateLSF) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LsfInterpolate2PloyEnc( - int16_t* a, /* (o) lpc coefficients Q12 */ - int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */ - int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */ - int16_t coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - int16_t length /* (i) length of coefficient vectors */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c deleted file mode 100644 index ee8292f394..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Lsp.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsf_to_lsp.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * conversion from lsf to lsp coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Lsp( - int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */ - int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */ - int16_t m /* (i) number of coefficients */ - ) { - int16_t i, k; - int16_t diff; /* difference, which is used for the - linear approximation (Q8) */ - int16_t freq; /* normalized frequency in Q15 (0..1) */ - int32_t tmpW32; - - for(i=0; i> 15); - /* 20861: 1.0/(2.0*PI) in Q17 */ - /* - Upper 8 bits give the index k and - Lower 8 bits give the difference, which needs - to be approximated linearly - */ - k = freq >> 8; - diff = (freq&0x00ff); - - /* Guard against getting outside table */ - - if (k>63) { - k = 63; - } - - /* Calculate linear approximation */ - tmpW32 = WebRtcIlbcfix_kCosDerivative[k] * diff; - lsp[i] = WebRtcIlbcfix_kCos[k] + (int16_t)(tmpW32 >> 12); - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h deleted file mode 100644 index fccc3c2b1c..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Lsp.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ - -#include - -/*----------------------------------------------------------------* - * conversion from lsf to lsp coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Lsp( - int16_t* lsf, /* (i) lsf in Q13 values between 0 and pi */ - int16_t* lsp, /* (o) lsp in Q15 values between -1 and 1 */ - int16_t m /* (i) number of coefficients */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_poly.c b/modules/audio_coding/codecs/ilbc/lsf_to_poly.c deleted file mode 100644 index 8ca91d82f8..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_to_poly.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Poly.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsf_to_poly.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/get_lsp_poly.h" -#include "modules/audio_coding/codecs/ilbc/lsf_to_lsp.h" - -void WebRtcIlbcfix_Lsf2Poly( - int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */ - int16_t *lsf /* (i) line spectral frequencies in Q13 */ - ) { - int32_t f[2][6]; /* f[0][] and f[1][] corresponds to - F1(z) and F2(z) respectivly */ - int32_t *f1ptr, *f2ptr; - int16_t *a1ptr, *a2ptr; - int32_t tmpW32; - int16_t lsp[10]; - int i; - - /* Convert lsf to lsp */ - WebRtcIlbcfix_Lsf2Lsp(lsf, lsp, LPC_FILTERORDER); - - /* Get F1(z) and F2(z) from the lsp */ - f1ptr=f[0]; - f2ptr=f[1]; - WebRtcIlbcfix_GetLspPoly(&lsp[0],f1ptr); - WebRtcIlbcfix_GetLspPoly(&lsp[1],f2ptr); - - /* for i = 5 down to 1 - Compute f1[i] += f1[i-1]; - and f2[i] += f2[i-1]; - */ - f1ptr=&f[0][5]; - f2ptr=&f[1][5]; - for (i=5; i>0; i--) - { - (*f1ptr) += (*(f1ptr-1)); - (*f2ptr) -= (*(f2ptr-1)); - f1ptr--; - f2ptr--; - } - - /* Get the A(z) coefficients - a[0] = 1.0 - for i = 1 to 5 - a[i] = (f1[i] + f2[i] + round)>>13; - for i = 1 to 5 - a[11-i] = (f1[i] - f2[i] + round)>>13; - */ - a[0]=4096; - a1ptr=&a[1]; - a2ptr=&a[10]; - f1ptr=&f[0][1]; - f2ptr=&f[1][1]; - for (i=5; i>0; i--) - { - tmpW32 = (*f1ptr) + (*f2ptr); - *a1ptr = (int16_t)((tmpW32 + 4096) >> 13); - - tmpW32 = (*f1ptr) - (*f2ptr); - *a2ptr = (int16_t)((tmpW32 + 4096) >> 13); - - a1ptr++; - a2ptr--; - f1ptr++; - f2ptr++; - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h b/modules/audio_coding/codecs/ilbc/lsf_to_poly.h deleted file mode 100644 index 06f292f038..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Poly.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ - -#include - -/*----------------------------------------------------------------* - * Convert from LSF coefficients to A coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Poly( - int16_t* a, /* (o) predictor coefficients (order = 10) in Q12 */ - int16_t* lsf /* (i) line spectral frequencies in Q13 */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c deleted file mode 100644 index 227f4d45b4..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsp2Lsf.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/lsp_to_lsf.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * conversion from LSP coefficients to LSF coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsp2Lsf( - int16_t *lsp, /* (i) lsp vector -1...+1 in Q15 */ - int16_t *lsf, /* (o) Lsf vector 0...Pi in Q13 - (ordered, so that lsf[i]=0; i--) - { - /* - locate value in the table, which is just above lsp[i], - basically an approximation to acos(x) - */ - while( (((int32_t)(*cosTblPtr)-(*lspPtr)) < 0)&&(k>0) ) - { - k-=1; - cosTblPtr--; - } - - /* Calculate diff, which is used in the linear approximation of acos(x) */ - diff = (*lspPtr)-(*cosTblPtr); - - /* - The linear approximation of acos(lsp[i]) : - acos(lsp[i])= k*512 + (WebRtcIlbcfix_kAcosDerivative[ind]*offset >> 11) - */ - - /* tmp (linear offset) in Q16 */ - tmp = (int16_t)((WebRtcIlbcfix_kAcosDerivative[k] * diff) >> 11); - - /* freq in Q16 */ - freq = (k << 9) + tmp; - - /* lsf = freq*2*pi */ - (*lsfPtr) = (int16_t)(((int32_t)freq*25736)>>15); - - lsfPtr--; - lspPtr--; - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h deleted file mode 100644 index a0dfb8e8eb..0000000000 --- a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsp2Lsf.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ - -#include - -/*----------------------------------------------------------------* - * conversion from LSP coefficients to LSF coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsp2Lsf( - int16_t* lsp, /* (i) lsp vector -1...+1 in Q15 */ - int16_t* lsf, /* (o) Lsf vector 0...Pi in Q13 - (ordered, so that lsf[i] -#include - -/*----------------------------------------------------------------* - * compute cross correlation between sequences - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_MyCorr(int32_t* corr, /* (o) correlation of seq1 and seq2 */ - const int16_t* seq1, /* (i) first sequence */ - size_t dim1, /* (i) dimension first seq1 */ - const int16_t* seq2, /* (i) second sequence */ - size_t dim2 /* (i) dimension seq2 */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/nearest_neighbor.c b/modules/audio_coding/codecs/ilbc/nearest_neighbor.c deleted file mode 100644 index 1ecdd96d5a..0000000000 --- a/modules/audio_coding/codecs/ilbc/nearest_neighbor.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_NearestNeighbor.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/nearest_neighbor.h" - -void WebRtcIlbcfix_NearestNeighbor(size_t* index, - const size_t* array, - size_t value, - size_t arlength) { - size_t i; - size_t min_diff = (size_t)-1; - for (i = 0; i < arlength; i++) { - const size_t diff = - (array[i] < value) ? (value - array[i]) : (array[i] - value); - if (diff < min_diff) { - *index = i; - min_diff = diff; - } - } -} diff --git a/modules/audio_coding/codecs/ilbc/nearest_neighbor.h b/modules/audio_coding/codecs/ilbc/nearest_neighbor.h deleted file mode 100644 index 6db30b3e15..0000000000 --- a/modules/audio_coding/codecs/ilbc/nearest_neighbor.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_NearestNeighbor.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Find index in array such that the array element with said - * index is the element of said array closest to "value" - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_NearestNeighbor( - size_t* index, /* (o) index of array element closest to value */ - const size_t* array, /* (i) data array (Q2) */ - size_t value, /* (i) value (Q2) */ - size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/pack_bits.c b/modules/audio_coding/codecs/ilbc/pack_bits.c deleted file mode 100644 index dd44eb8fb6..0000000000 --- a/modules/audio_coding/codecs/ilbc/pack_bits.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_PackBits.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/pack_bits.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_PackBits( - uint16_t *bitstream, /* (o) The packetized bitstream */ - iLBC_bits *enc_bits, /* (i) Encoded bits */ - int16_t mode /* (i) Codec mode (20 or 30) */ - ){ - uint16_t *bitstreamPtr; - int i, k; - int16_t *tmpPtr; - - bitstreamPtr=bitstream; - - /* Class 1 bits of ULP */ - /* First int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->lsf[0])<<10; /* Bit 0..5 */ - (*bitstreamPtr) |= (enc_bits->lsf[1])<<3; /* Bit 6..12 */ - (*bitstreamPtr) |= (enc_bits->lsf[2]&0x70)>>4; /* Bit 13..15 */ - bitstreamPtr++; - /* Second int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->lsf[2]&0xF)<<12; /* Bit 0..3 */ - - if (mode==20) { - (*bitstreamPtr) |= (enc_bits->startIdx)<<10; /* Bit 4..5 */ - (*bitstreamPtr) |= (enc_bits->state_first)<<9; /* Bit 6 */ - (*bitstreamPtr) |= (enc_bits->idxForMax)<<3; /* Bit 7..12 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[0])&0x70)>>4; /* Bit 13..15 */ - bitstreamPtr++; - /* Third int16_t */ - (*bitstreamPtr) = ((enc_bits->cb_index[0])&0xE)<<12; /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x18)<<8; /* Bit 3..4 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x8)<<7; /* Bit 5 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0xFE)<<2; /* Bit 6..12 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[3])&0x10)>>2; /* Bit 13 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x8)>>2; /* Bit 14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x10)>>4; /* Bit 15 */ - } else { /* mode==30 */ - (*bitstreamPtr) |= (enc_bits->lsf[3])<<6; /* Bit 4..9 */ - (*bitstreamPtr) |= (enc_bits->lsf[4]&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* Third int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->lsf[4]&0x1)<<15; /* Bit 0 */ - (*bitstreamPtr) |= (enc_bits->lsf[5])<<8; /* Bit 1..7 */ - (*bitstreamPtr) |= (enc_bits->startIdx)<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= (enc_bits->state_first)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->idxForMax)&0x3C)>>2; /* Bit 12..15 */ - bitstreamPtr++; - /* 4:th int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->idxForMax&0x3)<<14; /* Bit 0..1 */ - (*bitstreamPtr) |= (enc_bits->cb_index[0]&0x78)<<7; /* Bit 2..5 */ - (*bitstreamPtr) |= (enc_bits->gain_index[0]&0x10)<<5; /* Bit 6 */ - (*bitstreamPtr) |= (enc_bits->gain_index[1]&0x8)<<5; /* Bit 7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[3]&0xFC); /* Bit 8..13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0x10)>>3; /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x8)>>3; /* Bit 15 */ - } - /* Class 2 bits of ULP */ - /* 4:th to 6:th int16_t for 20 ms case - 5:th to 7:th int16_t for 30 ms case */ - bitstreamPtr++; - tmpPtr=enc_bits->idxVec; - for (k=0; k<3; k++) { - (*bitstreamPtr) = 0; - for (i=15; i>=0; i--) { - (*bitstreamPtr) |= ((uint16_t)((*tmpPtr)&0x4)>>2)<6; i--) { - (*bitstreamPtr) |= ((uint16_t)((*tmpPtr)&0x4)>>2)<gain_index[1]&0x4)<<4; /* Bit 9 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0xC)<<2; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x4)<<1; /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[6]&0x8)>>1; /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[7]&0xC)>>2; /* Bit 14..15 */ - - } else { /* mode==30 */ - /* 8:th int16_t */ - (*bitstreamPtr) = 0; - for (i=15; i>5; i--) { - (*bitstreamPtr) |= ((uint16_t)((*tmpPtr)&0x4)>>2)<cb_index[0]&0x6)<<3; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[0]&0x8); /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[1]&0x4); /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->cb_index[3]&0x2); /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->cb_index[6]&0x80)>>7; /* Bit 15 */ - bitstreamPtr++; - /* 9:th int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->cb_index[6]&0x7E)<<9;/* Bit 0..5 */ - (*bitstreamPtr) |= (enc_bits->cb_index[9]&0xFE)<<2; /* Bit 6..12 */ - (*bitstreamPtr) |= (enc_bits->cb_index[12]&0xE0)>>5; /* Bit 13..15 */ - bitstreamPtr++; - /* 10:th int16_t */ - (*bitstreamPtr) = ((uint16_t)enc_bits->cb_index[12]&0x1E)<<11;/* Bit 0..3 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0xC)<<8; /* Bit 4..5 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x6)<<7; /* Bit 6..7 */ - (*bitstreamPtr) |= (enc_bits->gain_index[6]&0x18)<<3; /* Bit 8..9 */ - (*bitstreamPtr) |= (enc_bits->gain_index[7]&0xC)<<2; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[9]&0x10)>>1; /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[10]&0x8)>>1; /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[12]&0x10)>>3; /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->gain_index[13]&0x8)>>3; /* Bit 15 */ - } - bitstreamPtr++; - /* Class 3 bits of ULP */ - /* 8:th to 14:th int16_t for 20 ms case - 11:th to 17:th int16_t for 30 ms case */ - tmpPtr=enc_bits->idxVec; - for (k=0; k<7; k++) { - (*bitstreamPtr) = 0; - for (i=14; i>=0; i-=2) { - (*bitstreamPtr) |= ((uint16_t)((*tmpPtr)&0x3))<idxVec[56])&0x3))<<14;/* Bit 0..1 */ - (*bitstreamPtr) |= (((enc_bits->cb_index[0])&1))<<13; /* Bit 2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[1]))<<6; /* Bit 3..9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[2])&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* 16:th int16_t */ - (*bitstreamPtr) = ((uint16_t)((enc_bits->cb_index[2])&0x1))<<15; - /* Bit 0 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x7)<<12; /* Bit 1..3 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x3)<<10; /* Bit 4..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[2]))<<7; /* Bit 6..8 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0x1)<<6; /* Bit 9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[4])&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* 17:th int16_t */ - (*bitstreamPtr) = ((uint16_t)((enc_bits->cb_index[4])&0x1))<<15; - /* Bit 0 */ - (*bitstreamPtr) |= (enc_bits->cb_index[5])<<8; /* Bit 1..7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[6]); /* Bit 8..15 */ - bitstreamPtr++; - /* 18:th int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[7]))<<8; /* Bit 0..7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[8]); /* Bit 8..15 */ - bitstreamPtr++; - /* 19:th int16_t */ - (*bitstreamPtr) = ((uint16_t)((enc_bits->gain_index[3])&0x3))<<14; - /* Bit 0..1 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x3)<<12; /* Bit 2..3 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[5]))<<9; /* Bit 4..6 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x7)<<6; /* Bit 7..9 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[7])&0x3)<<4; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[8])<<1; /* Bit 12..14 */ - } else { /* mode==30 */ - /* 18:th int16_t */ - (*bitstreamPtr) = ((uint16_t)((enc_bits->idxVec[56])&0x3))<<14;/* Bit 0..1 */ - (*bitstreamPtr) |= (((enc_bits->idxVec[57])&0x3))<<12; /* Bit 2..3 */ - (*bitstreamPtr) |= (((enc_bits->cb_index[0])&1))<<11; /* Bit 4 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[1]))<<4; /* Bit 5..11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[2])&0x78)>>3; /* Bit 12..15 */ - bitstreamPtr++; - /* 19:th int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[2])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x7)<<10; /* Bit 3..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x3)<<8; /* Bit 6..7 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[2])&0x7)<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0x1)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[4])&0x78)>>3; /* Bit 12..15 */ - bitstreamPtr++; - /* 20:th int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[4])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[5]))<<6; /* Bit 3..9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[6])&0x1)<<5; /* Bit 10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[7])&0xF8)>>3; /* Bit 11..15 */ - bitstreamPtr++; - /* 21:st int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[7])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[8]))<<5; /* Bit 3..10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[9])&0x1)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[10])&0xF0)>>4; /* Bit 12..15 */ - bitstreamPtr++; - /* 22:nd int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[10])&0xF)<<12; - /* Bit 0..3 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[11]))<<4; /* Bit 4..11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[12])&0x1)<<3; /* Bit 12 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[13])&0xE0)>>5; /* Bit 13..15 */ - bitstreamPtr++; - /* 23:rd int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->cb_index[13])&0x1F)<<11; - /* Bit 0..4 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[14]))<<3; /* Bit 5..12 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[3])&0x3)<<1; /* Bit 13..14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x1); /* Bit 15 */ - bitstreamPtr++; - /* 24:rd int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->gain_index[5]))<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x7)<<10; /* Bit 3..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[7])&0x3)<<8; /* Bit 6..7 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[8]))<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[9])&0xF)<<1; /* Bit 11..14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[10])&0x4)>>2; /* Bit 15 */ - bitstreamPtr++; - /* 25:rd int16_t */ - (*bitstreamPtr) = ((uint16_t)(enc_bits->gain_index[10])&0x3)<<14; - /* Bit 0..1 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[11]))<<11; /* Bit 2..4 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[12])&0xF)<<7; /* Bit 5..8 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[13])&0x7)<<4; /* Bit 9..11 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[14]))<<1; /* Bit 12..14 */ - } - /* Last bit is automatically zero */ - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/pack_bits.h b/modules/audio_coding/codecs/ilbc/pack_bits.h deleted file mode 100644 index d2ebeeeda9..0000000000 --- a/modules/audio_coding/codecs/ilbc/pack_bits.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_PackBits.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_PackBits( - uint16_t* bitstream, /* (o) The packetized bitstream */ - iLBC_bits* enc_bits, /* (i) Encoded bits */ - int16_t mode /* (i) Codec mode (20 or 30) */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsf.c b/modules/audio_coding/codecs/ilbc/poly_to_lsf.c deleted file mode 100644 index 7192eaab49..0000000000 --- a/modules/audio_coding/codecs/ilbc/poly_to_lsf.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsf.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/poly_to_lsf.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/lsp_to_lsf.h" -#include "modules/audio_coding/codecs/ilbc/poly_to_lsp.h" - -void WebRtcIlbcfix_Poly2Lsf( - int16_t *lsf, /* (o) lsf coefficients (Q13) */ - int16_t *a /* (i) A coefficients (Q12) */ - ) { - int16_t lsp[10]; - WebRtcIlbcfix_Poly2Lsp(a, lsp, (int16_t*)WebRtcIlbcfix_kLspMean); - WebRtcIlbcfix_Lsp2Lsf(lsp, lsf, 10); -} diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsf.h b/modules/audio_coding/codecs/ilbc/poly_to_lsf.h deleted file mode 100644 index d10f84126e..0000000000 --- a/modules/audio_coding/codecs/ilbc/poly_to_lsf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsf.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ - -#include - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsf(int16_t* lsf, /* (o) lsf coefficients (Q13) */ - int16_t* a /* (i) A coefficients (Q12) */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsp.c b/modules/audio_coding/codecs/ilbc/poly_to_lsp.c deleted file mode 100644 index ad0ecd70ab..0000000000 --- a/modules/audio_coding/codecs/ilbc/poly_to_lsp.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsp.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/poly_to_lsp.h" - -#include "modules/audio_coding/codecs/ilbc/chebyshev.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsp coefficients - * function is only for 10:th order LPC - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsp( - int16_t *a, /* (o) A coefficients in Q12 */ - int16_t *lsp, /* (i) LSP coefficients in Q15 */ - int16_t *old_lsp /* (i) old LSP coefficients that are used if the new - coefficients turn out to be unstable */ - ) { - int16_t f[2][6]; /* f[0][] represents f1 and f[1][] represents f2 */ - int16_t *a_i_ptr, *a_10mi_ptr; - int16_t *f1ptr, *f2ptr; - int32_t tmpW32; - int16_t x, y, xlow, ylow, xmid, ymid, xhigh, yhigh, xint; - int16_t shifts, sign; - int i, j; - int foundFreqs; - int fi_select; - - /* - Calculate the two polynomials f1(z) and f2(z) - (the sum and the diff polynomial) - f1[0] = f2[0] = 1.0; - f1[i+1] = a[i+1] + a[10-i] - f1[i]; - f2[i+1] = a[i+1] - a[10-i] - f1[i]; - */ - - a_i_ptr = a + 1; - a_10mi_ptr = a + 10; - f1ptr = f[0]; - f2ptr = f[1]; - (*f1ptr) = 1024; /* 1.0 in Q10 */ - (*f2ptr) = 1024; /* 1.0 in Q10 */ - for (i = 0; i < 5; i++) { - *(f1ptr + 1) = - (int16_t)((((int32_t)(*a_i_ptr) + *a_10mi_ptr) >> 2) - *f1ptr); - *(f2ptr + 1) = - (int16_t)((((int32_t)(*a_i_ptr) - *a_10mi_ptr) >> 2) + *f2ptr); - a_i_ptr++; - a_10mi_ptr--; - f1ptr++; - f2ptr++; - } - - /* - find the LSPs using the Chebychev pol. evaluation - */ - - fi_select = 0; /* selector between f1 and f2, start with f1 */ - - foundFreqs = 0; - - xlow = WebRtcIlbcfix_kCosGrid[0]; - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - - /* - Iterate until all the 10 LSP's have been found or - all the grid points have been tried. If the 10 LSP's can - not be found, set the LSP vector to previous LSP - */ - - for (j = 1; j < COS_GRID_POINTS && foundFreqs < 10; j++) { - xhigh = xlow; - yhigh = ylow; - xlow = WebRtcIlbcfix_kCosGrid[j]; - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - - if (ylow * yhigh <= 0) { - /* Run 4 times to reduce the interval */ - for (i = 0; i < 4; i++) { - /* xmid =(xlow + xhigh)/2 */ - xmid = (xlow >> 1) + (xhigh >> 1); - ymid = WebRtcIlbcfix_Chebyshev(xmid, f[fi_select]); - - if (ylow * ymid <= 0) { - yhigh = ymid; - xhigh = xmid; - } else { - ylow = ymid; - xlow = xmid; - } - } - - /* - Calculater xint by linear interpolation: - xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow); - */ - - x = xhigh - xlow; - y = yhigh - ylow; - - if (y == 0) { - xint = xlow; - } else { - sign = y; - y = WEBRTC_SPL_ABS_W16(y); - shifts = (int16_t)WebRtcSpl_NormW32(y)-16; - y <<= shifts; - y = (int16_t)WebRtcSpl_DivW32W16(536838144, y); /* 1/(yhigh-ylow) */ - - tmpW32 = (x * y) >> (19 - shifts); - - /* y=(xhigh-xlow)/(yhigh-ylow) */ - y = (int16_t)(tmpW32&0xFFFF); - - if (sign < 0) { - y = -y; - } - /* tmpW32 = ylow*(xhigh-xlow)/(yhigh-ylow) */ - tmpW32 = (ylow * y) >> 10; - xint = xlow-(int16_t)(tmpW32&0xFFFF); - } - - /* Store the calculated lsp */ - lsp[foundFreqs] = (int16_t)xint; - foundFreqs++; - - /* if needed, set xlow and ylow for next recursion */ - if (foundFreqs<10) { - xlow = xint; - /* Swap between f1 and f2 (f[0][] and f[1][]) */ - fi_select = ((fi_select+1)&0x1); - - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - } - } - } - - /* Check if M roots found, if not then use the old LSP */ - if (foundFreqs < 10) { - WEBRTC_SPL_MEMCPY_W16(lsp, old_lsp, 10); - } - return; -} diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsp.h b/modules/audio_coding/codecs/ilbc/poly_to_lsp.h deleted file mode 100644 index d95173689a..0000000000 --- a/modules/audio_coding/codecs/ilbc/poly_to_lsp.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsp.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ - -#include - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsp coefficients - * function is only for 10:th order LPC - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsp( - int16_t* a, /* (o) A coefficients in Q12 */ - int16_t* lsp, /* (i) LSP coefficients in Q15 */ - int16_t* old_lsp /* (i) old LSP coefficients that are used if the new - coefficients turn out to be unstable */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/refiner.c b/modules/audio_coding/codecs/ilbc/refiner.c deleted file mode 100644 index 5bdab7a4b0..0000000000 --- a/modules/audio_coding/codecs/ilbc/refiner.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Refiner.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/refiner.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/enh_upsample.h" -#include "modules/audio_coding/codecs/ilbc/my_corr.h" - -/*----------------------------------------------------------------* - * find segment starting near idata+estSegPos that has highest - * correlation with idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a - * resolution of ENH_UPSO times the original of the original - * sampling rate - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Refiner( - size_t *updStartPos, /* (o) updated start point (Q-2) */ - int16_t *idata, /* (i) original data buffer */ - size_t idatal, /* (i) dimension of idata */ - size_t centerStartPos, /* (i) beginning center segment */ - size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ - int16_t *surround, /* (i/o) The contribution from this sequence - summed with earlier contributions */ - int16_t gain /* (i) Gain to use for this sequence */ - ){ - size_t estSegPosRounded, searchSegStartPos, searchSegEndPos, corrdim; - size_t tloc, tloc2, i; - - int32_t maxtemp, scalefact; - int16_t *filtStatePtr, *polyPtr; - /* Stack based */ - int16_t filt[7]; - int32_t corrVecUps[ENH_CORRDIM*ENH_UPS0]; - int32_t corrVecTemp[ENH_CORRDIM]; - int16_t vect[ENH_VECTL]; - int16_t corrVec[ENH_CORRDIM]; - - /* defining array bounds */ - - estSegPosRounded = (estSegPos - 2) >> 2; - - searchSegStartPos = - (estSegPosRounded < ENH_SLOP) ? 0 : (estSegPosRounded - ENH_SLOP); - - searchSegEndPos = estSegPosRounded + ENH_SLOP; - if ((searchSegEndPos + ENH_BLOCKL) >= idatal) { - searchSegEndPos = idatal - ENH_BLOCKL - 1; - } - - corrdim = searchSegEndPos + 1 - searchSegStartPos; - - /* compute upsampled correlation and find - location of max */ - - WebRtcIlbcfix_MyCorr(corrVecTemp, idata + searchSegStartPos, - corrdim + ENH_BLOCKL - 1, idata + centerStartPos, - ENH_BLOCKL); - - /* Calculate the rescaling factor for the correlation in order to - put the correlation in a int16_t vector instead */ - maxtemp = WebRtcSpl_MaxAbsValueW32(corrVecTemp, corrdim); - - scalefact = WebRtcSpl_GetSizeInBits(maxtemp) - 15; - - if (scalefact > 0) { - for (i = 0; i < corrdim; i++) { - corrVec[i] = (int16_t)(corrVecTemp[i] >> scalefact); - } - } else { - for (i = 0; i < corrdim; i++) { - corrVec[i] = (int16_t)corrVecTemp[i]; - } - } - /* In order to guarantee that all values are initialized */ - for (i = corrdim; i < ENH_CORRDIM; i++) { - corrVec[i] = 0; - } - - /* Upsample the correlation */ - WebRtcIlbcfix_EnhUpsample(corrVecUps, corrVec); - - /* Find maximum */ - tloc = WebRtcSpl_MaxIndexW32(corrVecUps, ENH_UPS0 * corrdim); - - /* make vector can be upsampled without ever running outside - bounds */ - *updStartPos = searchSegStartPos * 4 + tloc + 4; - - tloc2 = (tloc + 3) >> 2; - - /* initialize the vector to be filtered, stuff with zeros - when data is outside idata buffer */ - if (ENH_FL0 > (searchSegStartPos + tloc2)) { - const size_t st = ENH_FL0 - searchSegStartPos - tloc2; - WebRtcSpl_MemSetW16(vect, 0, st); - WEBRTC_SPL_MEMCPY_W16(&vect[st], idata, ENH_VECTL - st); - } else { - const size_t st = searchSegStartPos + tloc2 - ENH_FL0; - if ((st + ENH_VECTL) > idatal) { - const size_t en = st + ENH_VECTL - idatal; - WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL - en); - WebRtcSpl_MemSetW16(&vect[ENH_VECTL - en], 0, en); - } else { - WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); - } - } - - /* compute the segment (this is actually a convolution) */ - filtStatePtr = filt + 6; - polyPtr = (int16_t*)WebRtcIlbcfix_kEnhPolyPhaser[tloc2 * ENH_UPS0 - tloc]; - for (i = 0; i < 7; i++) { - *filtStatePtr-- = *polyPtr++; - } - - WebRtcSpl_FilterMAFastQ12(&vect[6], vect, filt, ENH_FLO_MULT2_PLUS1, - ENH_BLOCKL); - - /* Add the contribution from this vector (scaled with gain) to the total - surround vector */ - WebRtcSpl_AddAffineVectorToVector(surround, vect, gain, 32768, 16, - ENH_BLOCKL); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/refiner.h b/modules/audio_coding/codecs/ilbc/refiner.h deleted file mode 100644 index 29be89e35a..0000000000 --- a/modules/audio_coding/codecs/ilbc/refiner.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Refiner.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ - -#include -#include - -/*----------------------------------------------------------------* - * find segment starting near idata+estSegPos that has highest - * correlation with idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a - * resolution of ENH_UPSO times the original of the original - * sampling rate - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Refiner( - size_t* updStartPos, /* (o) updated start point (Q-2) */ - int16_t* idata, /* (i) original data buffer */ - size_t idatal, /* (i) dimension of idata */ - size_t centerStartPos, /* (i) beginning center segment */ - size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ - int16_t* surround, /* (i/o) The contribution from this sequence - summed with earlier contributions */ - int16_t gain /* (i) Gain to use for this sequence */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c b/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c deleted file mode 100644 index 7343530a5e..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleInterpolateLsf.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h" - -#include "modules/audio_coding/codecs/ilbc/bw_expand.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h" - -/*----------------------------------------------------------------* - * lsf interpolator (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleInterpolateLsf( - int16_t *syntdenum, /* (o) the synthesis filter denominator - resulting from the quantized - interpolated lsf Q12 */ - int16_t *weightdenum, /* (o) the weighting filter denominator - resulting from the unquantized - interpolated lsf Q12 */ - int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */ - int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ - int16_t *lsfold, /* (i) the unquantized lsf coefficients of - the previous signal frame Q13 */ - int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the - previous signal frame Q13 */ - int16_t length, /* (i) should equate FILTERORDER */ - IlbcEncoder *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - size_t i; - int pos, lp_length; - - int16_t *lsf2, *lsfdeq2; - /* Stack based */ - int16_t lp[LPC_FILTERORDER + 1]; - - lsf2 = lsf + length; - lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (iLBCenc_inst->mode==30) { - /* subframe 1: Interpolation between old and first set of - lsf coefficients */ - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight30ms[0], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, - WebRtcIlbcfix_kLsfWeight30ms[0], - length); - WebRtcIlbcfix_BwExpand(weightdenum, lp, - (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (int16_t)lp_length); - - /* subframe 2 to 6: Interpolation between first and second - set of lsf coefficients */ - - pos = lp_length; - for (i = 1; i < iLBCenc_inst->nsub; i++) { - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2, - WebRtcIlbcfix_kLsfWeight30ms[i], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2, - WebRtcIlbcfix_kLsfWeight30ms[i], - length); - WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, - (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (int16_t)lp_length); - - pos += lp_length; - } - - /* update memory */ - - WEBRTC_SPL_MEMCPY_W16(lsfold, lsf2, length); - WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq2, length); - - } else { /* iLBCenc_inst->mode==20 */ - pos = 0; - for (i = 0; i < iLBCenc_inst->nsub; i++) { - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight20ms[i], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, - WebRtcIlbcfix_kLsfWeight20ms[i], - length); - WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, - (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (int16_t)lp_length); - - pos += lp_length; - } - - /* update memory */ - - WEBRTC_SPL_MEMCPY_W16(lsfold, lsf, length); - WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq, length); - - } - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h b/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h deleted file mode 100644 index 7e7e10e62a..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleInterpolateLsf.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ - -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * lsf interpolator (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleInterpolateLsf( - int16_t* syntdenum, /* (o) the synthesis filter denominator - resulting from the quantized - interpolated lsf Q12 */ - int16_t* weightdenum, /* (o) the weighting filter denominator - resulting from the unquantized - interpolated lsf Q12 */ - int16_t* lsf, /* (i) the unquantized lsf coefficients Q13 */ - int16_t* lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ - int16_t* lsfold, /* (i) the unquantized lsf coefficients of - the previous signal frame Q13 */ - int16_t* lsfdeqold, /* (i) the dequantized lsf coefficients of the - previous signal frame Q13 */ - int16_t length, /* (i) should equate FILTERORDER */ - IlbcEncoder* iLBCenc_inst - /* (i/o) the encoder state structure */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c b/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c deleted file mode 100644 index fdc4553d95..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLpcAnalysis.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h" - -#include "modules/audio_coding/codecs/ilbc/bw_expand.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/poly_to_lsf.h" -#include "modules/audio_coding/codecs/ilbc/window32_w32.h" - -/*----------------------------------------------------------------* - * lpc analysis (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLpcAnalysis( - int16_t *lsf, /* (o) lsf coefficients */ - int16_t *data, /* (i) new block of speech */ - IlbcEncoder *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - int k; - int scale; - size_t is; - int16_t stability; - /* Stack based */ - int16_t A[LPC_FILTERORDER + 1]; - int32_t R[LPC_FILTERORDER + 1]; - int16_t windowedData[BLOCKL_MAX]; - int16_t rc[LPC_FILTERORDER]; - - is=LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl; - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lpc_buffer+is,data,iLBCenc_inst->blockl); - - /* No lookahead, last window is asymmetric */ - - for (k = 0; k < iLBCenc_inst->lpc_n; k++) { - - is = LPC_LOOKBACK; - - if (k < (iLBCenc_inst->lpc_n - 1)) { - - /* Hanning table WebRtcIlbcfix_kLpcWin[] is in Q15-domain so the output is right-shifted 15 */ - WebRtcSpl_ElementwiseVectorMult(windowedData, iLBCenc_inst->lpc_buffer, WebRtcIlbcfix_kLpcWin, BLOCKL_MAX, 15); - } else { - - /* Hanning table WebRtcIlbcfix_kLpcAsymWin[] is in Q15-domain so the output is right-shifted 15 */ - WebRtcSpl_ElementwiseVectorMult(windowedData, iLBCenc_inst->lpc_buffer+is, WebRtcIlbcfix_kLpcAsymWin, BLOCKL_MAX, 15); - } - - /* Compute autocorrelation */ - WebRtcSpl_AutoCorrelation(windowedData, BLOCKL_MAX, LPC_FILTERORDER, R, &scale); - - /* Window autocorrelation vector */ - WebRtcIlbcfix_Window32W32(R, R, WebRtcIlbcfix_kLpcLagWin, LPC_FILTERORDER + 1 ); - - /* Calculate the A coefficients from the Autocorrelation using Levinson Durbin algorithm */ - stability=WebRtcSpl_LevinsonDurbin(R, A, rc, LPC_FILTERORDER); - - /* - Set the filter to {1.0, 0.0, 0.0,...} if filter from Levinson Durbin algorithm is unstable - This should basically never happen... - */ - if (stability!=1) { - A[0]=4096; - WebRtcSpl_MemSetW16(&A[1], 0, LPC_FILTERORDER); - } - - /* Bandwidth expand the filter coefficients */ - WebRtcIlbcfix_BwExpand(A, A, (int16_t*)WebRtcIlbcfix_kLpcChirpSyntDenum, LPC_FILTERORDER+1); - - /* Convert from A to LSF representation */ - WebRtcIlbcfix_Poly2Lsf(lsf + k*LPC_FILTERORDER, A); - } - - is=LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl; - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lpc_buffer, - iLBCenc_inst->lpc_buffer+LPC_LOOKBACK+BLOCKL_MAX-is, is); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h b/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h deleted file mode 100644 index 90e0c4a3ba..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLpcAnalysis.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ - -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * lpc analysis (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLpcAnalysis( - int16_t* lsf, /* (o) lsf coefficients */ - int16_t* data, /* (i) new block of speech */ - IlbcEncoder* iLBCenc_inst - /* (i/o) the encoder state structure */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c deleted file mode 100644 index e7494ceb59..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfDeQ.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * obtain dequantized lsf coefficients from quantization index - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfDeQ( - int16_t *lsfdeq, /* (o) dequantized lsf coefficients */ - int16_t *index, /* (i) quantization index */ - int16_t lpc_n /* (i) number of LPCs */ - ){ - int i, j, pos, cb_pos; - - /* decode first LSF */ - - pos = 0; - cb_pos = 0; - for (i = 0; i < LSF_NSPLIT; i++) { - for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { - lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + j + index[i] * - WebRtcIlbcfix_kLsfDimCb[i]]; - } - pos += WebRtcIlbcfix_kLsfDimCb[i]; - cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i]; - } - - if (lpc_n>1) { - /* decode last LSF */ - pos = 0; - cb_pos = 0; - for (i = 0; i < LSF_NSPLIT; i++) { - for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { - lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[ - cb_pos + index[LSF_NSPLIT + i] * WebRtcIlbcfix_kLsfDimCb[i] + j]; - } - pos += WebRtcIlbcfix_kLsfDimCb[i]; - cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i]; - } - } - return; -} diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h deleted file mode 100644 index 00b126af7e..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfDeQ.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ - -#include - -/*----------------------------------------------------------------* - * obtain dequantized lsf coefficients from quantization index - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfDeQ( - int16_t* lsfdeq, /* (o) dequantized lsf coefficients */ - int16_t* index, /* (i) quantization index */ - int16_t lpc_n /* (i) number of LPCs */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c b/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c deleted file mode 100644 index 1291d1442e..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfQ.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/simple_lsf_quant.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/split_vq.h" - -/*----------------------------------------------------------------* - * lsf quantizer (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfQ( - int16_t *lsfdeq, /* (o) dequantized lsf coefficients - (dimension FILTERORDER) Q13 */ - int16_t *index, /* (o) quantization index */ - int16_t *lsf, /* (i) the lsf coefficient vector to be - quantized (dimension FILTERORDER) Q13 */ - int16_t lpc_n /* (i) number of lsf sets to quantize */ - ){ - - /* Quantize first LSF with memoryless split VQ */ - WebRtcIlbcfix_SplitVq( lsfdeq, index, lsf, - (int16_t*)WebRtcIlbcfix_kLsfCb, (int16_t*)WebRtcIlbcfix_kLsfDimCb, (int16_t*)WebRtcIlbcfix_kLsfSizeCb); - - if (lpc_n==2) { - /* Quantize second LSF with memoryless split VQ */ - WebRtcIlbcfix_SplitVq( lsfdeq + LPC_FILTERORDER, index + LSF_NSPLIT, - lsf + LPC_FILTERORDER, (int16_t*)WebRtcIlbcfix_kLsfCb, - (int16_t*)WebRtcIlbcfix_kLsfDimCb, (int16_t*)WebRtcIlbcfix_kLsfSizeCb); - } - return; -} diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h b/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h deleted file mode 100644 index 38dcdfa59d..0000000000 --- a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfQ.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ - -#include - -/*----------------------------------------------------------------* - * lsf quantizer (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfQ( - int16_t* lsfdeq, /* (o) dequantized lsf coefficients - (dimension FILTERORDER) Q13 */ - int16_t* index, /* (o) quantization index */ - int16_t* lsf, /* (i) the lsf coefficient vector to be - quantized (dimension FILTERORDER) Q13 */ - int16_t lpc_n /* (i) number of lsf sets to quantize */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/smooth.c b/modules/audio_coding/codecs/ilbc/smooth.c deleted file mode 100644 index 631b2f432a..0000000000 --- a/modules/audio_coding/codecs/ilbc/smooth.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/smooth.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/smooth_out_data.h" - -/*----------------------------------------------------------------* - * find the smoothed output data - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Smooth( - int16_t *odata, /* (o) smoothed output */ - int16_t *current, /* (i) the un enhanced residual for - this block */ - int16_t *surround /* (i) The approximation from the - surrounding sequences */ - ) { - int16_t scale, scale1, scale2; - int16_t A, B, C, denomW16; - int32_t B_W32, denom, num; - int32_t errs; - int32_t w00,w10,w11, endiff, crit; - int32_t w00prim, w10prim, w11_div_w00; - int16_t w11prim; - int16_t bitsw00, bitsw10, bitsw11; - int32_t w11w00, w10w10, w00w00; - uint32_t max1, max2, max12; - - /* compute some inner products (ensure no overflow by first calculating proper scale factor) */ - - w00 = w10 = w11 = 0; - - // Calculate a right shift that will let us sum ENH_BLOCKL pairwise products - // of values from the two sequences without overflowing an int32_t. (The +1 - // in max1 and max2 are because WebRtcSpl_MaxAbsValueW16 will return 2**15 - - // 1 if the input array contains -2**15.) - max1 = WebRtcSpl_MaxAbsValueW16(current, ENH_BLOCKL) + 1; - max2 = WebRtcSpl_MaxAbsValueW16(surround, ENH_BLOCKL) + 1; - max12 = WEBRTC_SPL_MAX(max1, max2); - scale = (64 - 31) - - WebRtcSpl_CountLeadingZeros64((max12 * max12) * (uint64_t)ENH_BLOCKL); - scale=WEBRTC_SPL_MAX(0, scale); - - w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale); - w11=WebRtcSpl_DotProductWithScale(surround,surround,ENH_BLOCKL,scale); - w10=WebRtcSpl_DotProductWithScale(surround,current,ENH_BLOCKL,scale); - - if (w00<0) w00 = WEBRTC_SPL_WORD32_MAX; - if (w11<0) w11 = WEBRTC_SPL_WORD32_MAX; - - /* Rescale w00 and w11 to w00prim and w11prim, so that w00prim/w11prim - is in Q16 */ - - bitsw00 = WebRtcSpl_GetSizeInBits(w00); - bitsw11 = WebRtcSpl_GetSizeInBits(w11); - bitsw10 = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(w10)); - scale1 = 31 - bitsw00; - scale2 = 15 - bitsw11; - - if (scale2>(scale1-16)) { - scale2 = scale1 - 16; - } else { - scale1 = scale2 + 16; - } - - w00prim = w00 << scale1; - w11prim = (int16_t) WEBRTC_SPL_SHIFT_W32(w11, scale2); - - /* Perform C = sqrt(w11/w00) (C is in Q11 since (16+6)/2=11) */ - if (w11prim>64) { - endiff = WebRtcSpl_DivW32W16(w00prim, w11prim) << 6; - C = (int16_t)WebRtcSpl_SqrtFloor(endiff); /* C is in Q11 */ - } else { - C = 1; - } - - /* first try enhancement without power-constraint */ - - errs = WebRtcIlbcfix_Smooth_odata(odata, current, surround, C); - - - - /* if constraint violated by first try, add constraint */ - - if ( (6-scale+scale1) > 31) { - crit=0; - } else { - /* crit = 0.05 * w00 (Result in Q-6) */ - crit = WEBRTC_SPL_SHIFT_W32( - WEBRTC_SPL_MUL(ENH_A0, w00prim >> 14), - -(6-scale+scale1)); - } - - if (errs > crit) { - - if( w00 < 1) { - w00=1; - } - - /* Calculate w11*w00, w10*w10 and w00*w00 in the same Q domain */ - - scale1 = bitsw00-15; - scale2 = bitsw11-15; - - if (scale2>scale1) { - scale = scale2; - } else { - scale = scale1; - } - - w11w00 = (int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale) * - (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale); - - w10w10 = (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale) * - (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale); - - w00w00 = (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale) * - (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale); - - /* Calculate (w11*w00-w10*w10)/(w00*w00) in Q16 */ - if (w00w00>65536) { - endiff = (w11w00-w10w10); - endiff = WEBRTC_SPL_MAX(0, endiff); - /* denom is in Q16 */ - denom = WebRtcSpl_DivW32W16(endiff, (int16_t)(w00w00 >> 16)); - } else { - denom = 65536; - } - - if( denom > 7){ /* eliminates numerical problems - for if smooth */ - - scale=WebRtcSpl_GetSizeInBits(denom)-15; - - if (scale>0) { - /* denomW16 is in Q(16+scale) */ - denomW16 = (int16_t)(denom >> scale); - - /* num in Q(34-scale) */ - num = ENH_A0_MINUS_A0A0DIV4 >> scale; - } else { - /* denomW16 is in Q16 */ - denomW16=(int16_t)denom; - - /* num in Q34 */ - num=ENH_A0_MINUS_A0A0DIV4; - } - - /* A sqrt( (ENH_A0-(ENH_A0^2)/4)*(w00*w00)/(w11*w00 + w10*w10) ) in Q9 */ - A = (int16_t)WebRtcSpl_SqrtFloor(WebRtcSpl_DivW32W16(num, denomW16)); - - /* B_W32 is in Q30 ( B = 1 - ENH_A0/2 - A * w10/w00 ) */ - scale1 = 31-bitsw10; - scale2 = 21-scale1; - w10prim = w10 == 0 ? 0 : w10 * (1 << scale1); - w00prim = WEBRTC_SPL_SHIFT_W32(w00, -scale2); - scale = bitsw00-scale2-15; - - if (scale>0) { - w10prim >>= scale; - w00prim >>= scale; - } - - if ((w00prim>0)&&(w10prim>0)) { - w11_div_w00=WebRtcSpl_DivW32W16(w10prim, (int16_t)w00prim); - - if (WebRtcSpl_GetSizeInBits(w11_div_w00)+WebRtcSpl_GetSizeInBits(A)>31) { - B_W32 = 0; - } else { - B_W32 = (int32_t)1073741824 - (int32_t)ENH_A0DIV2 - - WEBRTC_SPL_MUL(A, w11_div_w00); - } - B = (int16_t)(B_W32 >> 16); /* B in Q14. */ - } else { - /* No smoothing */ - A = 0; - B = 16384; /* 1 in Q14 */ - } - } - else{ /* essentially no difference between cycles; - smoothing not needed */ - - A = 0; - B = 16384; /* 1 in Q14 */ - } - - /* create smoothed sequence */ - - WebRtcSpl_ScaleAndAddVectors(surround, A, 9, - current, B, 14, - odata, ENH_BLOCKL); - } - return; -} diff --git a/modules/audio_coding/codecs/ilbc/smooth.h b/modules/audio_coding/codecs/ilbc/smooth.h deleted file mode 100644 index 12da5cdea5..0000000000 --- a/modules/audio_coding/codecs/ilbc/smooth.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ - -#include - -/*----------------------------------------------------------------* - * find the smoothed output data - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Smooth(int16_t* odata, /* (o) smoothed output */ - int16_t* current, /* (i) the un enhanced residual for - this block */ - int16_t* surround /* (i) The approximation from the - surrounding sequences */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/smooth_out_data.c b/modules/audio_coding/codecs/ilbc/smooth_out_data.c deleted file mode 100644 index 9f952bfb93..0000000000 --- a/modules/audio_coding/codecs/ilbc/smooth_out_data.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth_odata.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/smooth_out_data.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "rtc_base/sanitizer.h" - -// An s32 + s32 -> s32 addition that's allowed to overflow. (It's still -// undefined behavior, so not a good idea; this just makes UBSan ignore the -// violation, so that our old code can continue to do what it's always been -// doing.) -static inline int32_t RTC_NO_SANITIZE("signed-integer-overflow") - OverflowingAdd_S32_S32_To_S32(int32_t a, int32_t b) { - return a + b; -} - -int32_t WebRtcIlbcfix_Smooth_odata( - int16_t *odata, - int16_t *psseq, - int16_t *surround, - int16_t C) -{ - int i; - - int16_t err; - int32_t errs; - - for(i=0;i<80;i++) { - odata[i]= (int16_t)((C * surround[i] + 1024) >> 11); - } - - errs=0; - for(i=0;i<80;i++) { - err = (psseq[i] - odata[i]) >> 3; - errs = OverflowingAdd_S32_S32_To_S32(errs, err * err); // errs in Q-6 - } - - return errs; -} diff --git a/modules/audio_coding/codecs/ilbc/smooth_out_data.h b/modules/audio_coding/codecs/ilbc/smooth_out_data.h deleted file mode 100644 index 318e7b04a2..0000000000 --- a/modules/audio_coding/codecs/ilbc/smooth_out_data.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth_odata.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ - -#include - -/*----------------------------------------------------------------* - * help function to WebRtcIlbcfix_Smooth() - *---------------------------------------------------------------*/ - -int32_t WebRtcIlbcfix_Smooth_odata(int16_t* odata, - int16_t* psseq, - int16_t* surround, - int16_t C); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/sort_sq.c b/modules/audio_coding/codecs/ilbc/sort_sq.c deleted file mode 100644 index c3a24750f0..0000000000 --- a/modules/audio_coding/codecs/ilbc/sort_sq.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SortSq.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/sort_sq.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * scalar quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SortSq( - int16_t *xq, /* (o) the quantized value */ - int16_t *index, /* (o) the quantization index */ - int16_t x, /* (i) the value to quantize */ - const int16_t *cb, /* (i) the quantization codebook */ - int16_t cb_size /* (i) the size of the quantization codebook */ - ){ - int i; - - if (x <= cb[0]) { - *index = 0; - *xq = cb[0]; - } else { - i = 0; - while ((x > cb[i]) && (i < (cb_size-1))) { - i++; - } - - if (x > (((int32_t)cb[i] + cb[i - 1] + 1) >> 1)) { - *index = i; - *xq = cb[i]; - } else { - *index = i - 1; - *xq = cb[i - 1]; - } - } -} diff --git a/modules/audio_coding/codecs/ilbc/sort_sq.h b/modules/audio_coding/codecs/ilbc/sort_sq.h deleted file mode 100644 index a40661fb80..0000000000 --- a/modules/audio_coding/codecs/ilbc/sort_sq.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SortSq.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ - -#include - -/*----------------------------------------------------------------* - * scalar quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SortSq( - int16_t* xq, /* (o) the quantized value */ - int16_t* index, /* (o) the quantization index */ - int16_t x, /* (i) the value to quantize */ - const int16_t* cb, /* (i) the quantization codebook */ - int16_t cb_size /* (i) the size of the quantization codebook */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/split_vq.c b/modules/audio_coding/codecs/ilbc/split_vq.c deleted file mode 100644 index c1f04d2287..0000000000 --- a/modules/audio_coding/codecs/ilbc/split_vq.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SplitVq.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/split_vq.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/vq3.h" -#include "modules/audio_coding/codecs/ilbc/vq4.h" - -/*----------------------------------------------------------------* - * split vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SplitVq( - int16_t *qX, /* (o) the quantized vector in Q13 */ - int16_t *index, /* (o) a vector of indexes for all vector - codebooks in the split */ - int16_t *X, /* (i) the vector to quantize */ - int16_t *CB, /* (i) the quantizer codebook in Q13 */ - int16_t *dim, /* (i) the dimension of X and qX */ - int16_t *cbsize /* (i) the number of vectors in the codebook */ - ) { - - int16_t *qXPtr, *indexPtr, *CBPtr, *XPtr; - - /* Quantize X with the 3 vectror quantization tables */ - - qXPtr=qX; - indexPtr=index; - CBPtr=CB; - XPtr=X; - WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[0]); - - qXPtr+=3; - indexPtr+=1; - CBPtr+=(dim[0]*cbsize[0]); - XPtr+=3; - WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[1]); - - qXPtr+=3; - indexPtr+=1; - CBPtr+=(dim[1]*cbsize[1]); - XPtr+=3; - WebRtcIlbcfix_Vq4(qXPtr, indexPtr, CBPtr, XPtr, cbsize[2]); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/split_vq.h b/modules/audio_coding/codecs/ilbc/split_vq.h deleted file mode 100644 index 79d3cd12ee..0000000000 --- a/modules/audio_coding/codecs/ilbc/split_vq.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SplitVq.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ - -#include - -/*----------------------------------------------------------------* - * split vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SplitVq( - int16_t* qX, /* (o) the quantized vector in Q13 */ - int16_t* index, /* (o) a vector of indexes for all vector - codebooks in the split */ - int16_t* X, /* (i) the vector to quantize */ - int16_t* CB, /* (i) the quantizer codebook in Q13 */ - int16_t* dim, /* (i) the dimension of X and qX */ - int16_t* cbsize /* (i) the number of vectors in the codebook */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/state_construct.c b/modules/audio_coding/codecs/ilbc/state_construct.c deleted file mode 100644 index c58086c03b..0000000000 --- a/modules/audio_coding/codecs/ilbc/state_construct.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateConstruct.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/state_construct.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * decoding of the start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateConstruct( - size_t idxForMax, /* (i) 6-bit index for the quantization of - max amplitude */ - int16_t *idxVec, /* (i) vector of quantization indexes */ - int16_t *syntDenum, /* (i) synthesis filter denumerator */ - int16_t *Out_fix, /* (o) the decoded state vector */ - size_t len /* (i) length of a state vector */ - ) { - size_t k; - int16_t maxVal; - int16_t *tmp1, *tmp2, *tmp3; - /* Stack based */ - int16_t numerator[1+LPC_FILTERORDER]; - int16_t sampleValVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - int16_t sampleMaVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - int16_t *sampleVal = &sampleValVec[LPC_FILTERORDER]; - int16_t *sampleMa = &sampleMaVec[LPC_FILTERORDER]; - int16_t *sampleAr = &sampleValVec[LPC_FILTERORDER]; - - /* initialization of coefficients */ - - for (k=0; k> - 22); - tmp1++; - tmp2--; - } - } else if (idxForMax<59) { - for(k=0; k> - 19); - tmp1++; - tmp2--; - } - } else { - for(k=0; k> - 17); - tmp1++; - tmp2--; - } - } - - /* Set the rest of the data to zero */ - WebRtcSpl_MemSetW16(&sampleVal[len], 0, len); - - /* circular convolution with all-pass filter */ - - /* Set the state to zero */ - WebRtcSpl_MemSetW16(sampleValVec, 0, (LPC_FILTERORDER)); - - /* Run MA filter + AR filter */ - WebRtcSpl_FilterMAFastQ12( - sampleVal, sampleMa, - numerator, LPC_FILTERORDER+1, len + LPC_FILTERORDER); - WebRtcSpl_MemSetW16(&sampleMa[len + LPC_FILTERORDER], 0, (len - LPC_FILTERORDER)); - WebRtcSpl_FilterARFastQ12( - sampleMa, sampleAr, - syntDenum, LPC_FILTERORDER+1, 2 * len); - - tmp1 = &sampleAr[len-1]; - tmp2 = &sampleAr[2*len-1]; - tmp3 = Out_fix; - for(k=0;k -#include - -/*----------------------------------------------------------------* - * Generate the start state from the quantized indexes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateConstruct( - size_t idxForMax, /* (i) 6-bit index for the quantization of - max amplitude */ - int16_t* idxVec, /* (i) vector of quantization indexes */ - int16_t* syntDenum, /* (i) synthesis filter denumerator */ - int16_t* Out_fix, /* (o) the decoded state vector */ - size_t len /* (i) length of a state vector */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/state_search.c b/modules/audio_coding/codecs/ilbc/state_search.c deleted file mode 100644 index 7227ac9d45..0000000000 --- a/modules/audio_coding/codecs/ilbc/state_search.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateSearch.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/state_search.h" - -#include "modules/audio_coding/codecs/ilbc/abs_quant.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * encoding of start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateSearch( - IlbcEncoder *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits,/* (i/o) Encoded bits (output idxForMax - and idxVec, input state_first) */ - int16_t *residual, /* (i) target residual vector */ - int16_t *syntDenum, /* (i) lpc synthesis filter */ - int16_t *weightDenum /* (i) weighting filter denuminator */ - ) { - size_t k, index; - int16_t maxVal; - int16_t scale, shift; - int32_t maxValsq; - int16_t scaleRes; - int16_t max; - int i; - /* Stack based */ - int16_t numerator[1+LPC_FILTERORDER]; - int16_t residualLongVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - int16_t sampleMa[2*STATE_SHORT_LEN_30MS]; - int16_t *residualLong = &residualLongVec[LPC_FILTERORDER]; - int16_t *sampleAr = residualLong; - - /* Scale to maximum 12 bits to avoid saturation in circular convolution filter */ - max = WebRtcSpl_MaxAbsValueW16(residual, iLBCenc_inst->state_short_len); - scaleRes = WebRtcSpl_GetSizeInBits(max)-12; - scaleRes = WEBRTC_SPL_MAX(0, scaleRes); - /* Set up the filter coefficients for the circular convolution */ - for (i=0; i>scaleRes); - } - - /* Copy the residual to a temporary buffer that we can filter - * and set the remaining samples to zero. - */ - WEBRTC_SPL_MEMCPY_W16(residualLong, residual, iLBCenc_inst->state_short_len); - WebRtcSpl_MemSetW16(residualLong + iLBCenc_inst->state_short_len, 0, iLBCenc_inst->state_short_len); - - /* Run the Zero-Pole filter (Ciurcular convolution) */ - WebRtcSpl_MemSetW16(residualLongVec, 0, LPC_FILTERORDER); - WebRtcSpl_FilterMAFastQ12(residualLong, sampleMa, numerator, - LPC_FILTERORDER + 1, - iLBCenc_inst->state_short_len + LPC_FILTERORDER); - WebRtcSpl_MemSetW16(&sampleMa[iLBCenc_inst->state_short_len + LPC_FILTERORDER], 0, iLBCenc_inst->state_short_len - LPC_FILTERORDER); - - WebRtcSpl_FilterARFastQ12( - sampleMa, sampleAr, - syntDenum, LPC_FILTERORDER+1, 2 * iLBCenc_inst->state_short_len); - - for(k=0;kstate_short_len;k++){ - sampleAr[k] += sampleAr[k+iLBCenc_inst->state_short_len]; - } - - /* Find maximum absolute value in the vector */ - maxVal=WebRtcSpl_MaxAbsValueW16(sampleAr, iLBCenc_inst->state_short_len); - - /* Find the best index */ - - if ((((int32_t)maxVal)<=WebRtcIlbcfix_kChooseFrgQuant[i]) { - index=i+1; - } else { - i=63; - } - } - iLBC_encbits->idxForMax=index; - - /* Rescale the vector before quantization */ - scale=WebRtcIlbcfix_kScale[index]; - - if (index<27) { /* scale table is in Q16, fout[] is in Q(-1) and we want the result to be in Q11 */ - shift=4; - } else { /* scale table is in Q21, fout[] is in Q(-1) and we want the result to be in Q11 */ - shift=9; - } - - /* Set up vectors for AbsQuant and rescale it with the scale factor */ - WebRtcSpl_ScaleVectorWithSat(sampleAr, sampleAr, scale, - iLBCenc_inst->state_short_len, (int16_t)(shift-scaleRes)); - - /* Quantize the values in fout[] */ - WebRtcIlbcfix_AbsQuant(iLBCenc_inst, iLBC_encbits, sampleAr, weightDenum); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/state_search.h b/modules/audio_coding/codecs/ilbc/state_search.h deleted file mode 100644 index 7a215e43d3..0000000000 --- a/modules/audio_coding/codecs/ilbc/state_search.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateSearch.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ - -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * encoding of start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateSearch( - IlbcEncoder* iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (output idxForMax - and idxVec, input state_first) */ - int16_t* residual, /* (i) target residual vector */ - int16_t* syntDenum, /* (i) lpc synthesis filter */ - int16_t* weightDenum /* (i) weighting filter denuminator */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/swap_bytes.c b/modules/audio_coding/codecs/ilbc/swap_bytes.c deleted file mode 100644 index bbafc1a2ed..0000000000 --- a/modules/audio_coding/codecs/ilbc/swap_bytes.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SwapBytes.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/swap_bytes.h" - -/*----------------------------------------------------------------* - * Swap bytes (to simplify operations on Little Endian machines) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SwapBytes( - const uint16_t* input, /* (i) the sequence to swap */ - size_t wordLength, /* (i) number or uint16_t to swap */ - uint16_t* output /* (o) the swapped sequence */ - ) { - size_t k; - for (k = wordLength; k > 0; k--) { - *output++ = (*input >> 8)|(*input << 8); - input++; - } -} diff --git a/modules/audio_coding/codecs/ilbc/swap_bytes.h b/modules/audio_coding/codecs/ilbc/swap_bytes.h deleted file mode 100644 index 2e517743ce..0000000000 --- a/modules/audio_coding/codecs/ilbc/swap_bytes.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SwapBytes.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ - -#include -#include - -/*----------------------------------------------------------------* - * Swap bytes (to simplify operations on Little Endian machines) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SwapBytes( - const uint16_t* input, /* (i) the sequence to swap */ - size_t wordLength, /* (i) number or uint16_t to swap */ - uint16_t* output /* (o) the swapped sequence */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/test/empty.cc b/modules/audio_coding/codecs/ilbc/test/empty.cc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/audio_coding/codecs/ilbc/test/iLBC_test.c b/modules/audio_coding/codecs/ilbc/test/iLBC_test.c deleted file mode 100644 index e0ca075eda..0000000000 --- a/modules/audio_coding/codecs/ilbc/test/iLBC_test.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBC_test.c - -******************************************************************/ - -#include -#include -#include -#include "modules/audio_coding/codecs/ilbc/ilbc.h" - -/*---------------------------------------------------------------* - * Main program to test iLBC encoding and decoding - * - * Usage: - * exefile_name.exe - * - * : Input file, speech for encoder (16-bit pcm file) - * : Bit stream output from the encoder - * : Output file, decoded speech (16-bit pcm file) - * : Bit error file, optional (16-bit) - * 1 - Packet received correctly - * 0 - Packet Lost - * - *--------------------------------------------------------------*/ - -#define BLOCKL_MAX 240 -#define ILBCNOOFWORDS_MAX 25 - - -int main(int argc, char* argv[]) -{ - - FILE *ifileid,*efileid,*ofileid, *cfileid; - int16_t data[BLOCKL_MAX]; - uint8_t encoded_data[2 * ILBCNOOFWORDS_MAX]; - int16_t decoded_data[BLOCKL_MAX]; - int len_int, mode; - short pli; - int blockcount = 0; - size_t frameLen, len, len_i16s; - int16_t speechType; - IlbcEncoderInstance *Enc_Inst; - IlbcDecoderInstance *Dec_Inst; - -#ifdef __ILBC_WITH_40BITACC - /* Doublecheck that long long exists */ - if (sizeof(long)>=sizeof(long long)) { - fprintf(stderr, "40-bit simulation is not be supported on this platform\n"); - exit(0); - } -#endif - - /* get arguments and open files */ - - if ((argc!=5) && (argc!=6)) { - fprintf(stderr, - "\n*-----------------------------------------------*\n"); - fprintf(stderr, - " %s <20,30> input encoded decoded (channel)\n\n", - argv[0]); - fprintf(stderr, - " mode : Frame size for the encoding/decoding\n"); - fprintf(stderr, - " 20 - 20 ms\n"); - fprintf(stderr, - " 30 - 30 ms\n"); - fprintf(stderr, - " input : Speech for encoder (16-bit pcm file)\n"); - fprintf(stderr, - " encoded : Encoded bit stream\n"); - fprintf(stderr, - " decoded : Decoded speech (16-bit pcm file)\n"); - fprintf(stderr, - " channel : Packet loss pattern, optional (16-bit)\n"); - fprintf(stderr, - " 1 - Packet received correctly\n"); - fprintf(stderr, - " 0 - Packet Lost\n"); - fprintf(stderr, - "*-----------------------------------------------*\n\n"); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", - argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open encoded file file %s\n", - argv[3]); exit(1);} - if ( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open decoded file %s\n", - argv[4]); exit(1);} - if (argc==6) { - if( (cfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr, "Cannot open channel file %s\n", - argv[5]); - exit(1); - } - } else { - cfileid=NULL; - } - - /* print info */ - - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBC test program *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr,"\nMode : %2d ms\n", mode); - fprintf(stderr,"Input file : %s\n", argv[2]); - fprintf(stderr,"Encoded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n", argv[4]); - if (argc==6) { - fprintf(stderr,"Channel file : %s\n", argv[5]); - } - fprintf(stderr,"\n"); - - /* Create structs */ - WebRtcIlbcfix_EncoderCreate(&Enc_Inst); - WebRtcIlbcfix_DecoderCreate(&Dec_Inst); - - - /* Initialization */ - - WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); - frameLen = (size_t)(mode*8); - - /* loop over input blocks */ - - while (fread(data,sizeof(int16_t),frameLen,ifileid) == frameLen) { - - blockcount++; - - /* encoding */ - - fprintf(stderr, "--- Encoding block %i --- ",blockcount); - len_int = WebRtcIlbcfix_Encode(Enc_Inst, data, frameLen, encoded_data); - if (len_int < 0) { - fprintf(stderr, "Error encoding\n"); - exit(0); - } - len = (size_t)len_int; - fprintf(stderr, "\r"); - - /* write byte file */ - - len_i16s = (len + 1) / sizeof(int16_t); - if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) { - return -1; - } - - /* get channel data if provided */ - if (argc==6) { - if (fread(&pli, sizeof(int16_t), 1, cfileid)) { - if ((pli!=0)&&(pli!=1)) { - fprintf(stderr, "Error in channel file\n"); - exit(0); - } - if (pli==0) { - /* Packet loss -> remove info from frame */ - memset(encoded_data, 0, - sizeof(int16_t)*ILBCNOOFWORDS_MAX); - } - } else { - fprintf(stderr, "Error. Channel file too short\n"); - exit(0); - } - } else { - pli=1; - } - - /* decoding */ - - fprintf(stderr, "--- Decoding block %i --- ",blockcount); - if (pli==1) { - len_int=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, - len, decoded_data,&speechType); - if (len_int < 0) { - fprintf(stderr, "Error decoding\n"); - exit(0); - } - len = (size_t)len_int; - } else { - len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1); - } - fprintf(stderr, "\r"); - - /* write output file */ - - if (fwrite(decoded_data, sizeof(int16_t), len, ofileid) != len) { - return -1; - } - } - - /* close files */ - - fclose(ifileid); fclose(efileid); fclose(ofileid); - if (argc==6) { - fclose(cfileid); - } - - /* Free structs */ - WebRtcIlbcfix_EncoderFree(Enc_Inst); - WebRtcIlbcfix_DecoderFree(Dec_Inst); - - - printf("\nDone with simulation\n\n"); - - return(0); -} diff --git a/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c b/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c deleted file mode 100644 index 132f3bdb37..0000000000 --- a/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - -iLBC Speech Coder ANSI-C Source Code - -iLBC_test.c - -******************************************************************/ - -#include -#include -#include -#include -#include -#include "modules/audio_coding/codecs/ilbc/ilbc.h" - -//#define JUNK_DATA -#ifdef JUNK_DATA -#define SEED_FILE "randseed.txt" -#endif - - -/*----------------------------------------------------------------* -* Main program to test iLBC encoding and decoding -* -* Usage: -* exefile_name.exe -* -*---------------------------------------------------------------*/ - -int main(int argc, char* argv[]) -{ - FILE *ifileid,*efileid,*ofileid, *chfileid; - short encoded_data[55], data[240], speechType; - int len_int, mode; - short pli; - size_t len, readlen; - int blockcount = 0; - - IlbcEncoderInstance *Enc_Inst; - IlbcDecoderInstance *Dec_Inst; -#ifdef JUNK_DATA - size_t i; - FILE *seedfile; - unsigned int random_seed = (unsigned int) time(NULL);//1196764538 -#endif - - /* Create structs */ - WebRtcIlbcfix_EncoderCreate(&Enc_Inst); - WebRtcIlbcfix_DecoderCreate(&Dec_Inst); - - /* get arguments and open files */ - - if (argc != 6 ) { - fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n", - argv[0]); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open channelfile file %s\n", - argv[3]); exit(3);} - if( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open output file %s\n", - argv[4]); exit(3);} - if ( (chfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr,"Cannot open channel file file %s\n", argv[5]); - exit(2); - } - /* print info */ - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBCtest *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); -#ifdef SPLIT_10MS - fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode); -#else - fprintf(stderr,"\nMode : %2d ms\n", mode); -#endif - fprintf(stderr,"\nInput file : %s\n", argv[2]); - fprintf(stderr,"Coded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n\n", argv[4]); - fprintf(stderr,"Channel file : %s\n\n", argv[5]); - -#ifdef JUNK_DATA - srand(random_seed); - - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "%u\n", random_seed); - fclose(seedfile); - } -#endif - - /* Initialization */ - WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); - - /* loop over input blocks */ -#ifdef SPLIT_10MS - readlen = 80; -#else - readlen = (size_t)(mode << 3); -#endif - while(fread(data, sizeof(short), readlen, ifileid) == readlen) { - blockcount++; - - /* encoding */ - fprintf(stderr, "--- Encoding block %i --- ",blockcount); - len_int=WebRtcIlbcfix_Encode(Enc_Inst, data, readlen, encoded_data); - if (len_int < 0) { - fprintf(stderr, "Error encoding\n"); - exit(0); - } - len = (size_t)len_int; - fprintf(stderr, "\r"); - -#ifdef JUNK_DATA - for ( i = 0; i < len; i++) { - encoded_data[i] = (short) (encoded_data[i] + (short) rand()); - } -#endif - /* write byte file */ - if(len != 0){ //len may be 0 in 10ms split case - fwrite(encoded_data,1,len,efileid); - - /* get channel data if provided */ - if (argc==6) { - if (fread(&pli, sizeof(int16_t), 1, chfileid)) { - if ((pli!=0)&&(pli!=1)) { - fprintf(stderr, "Error in channel file\n"); - exit(0); - } - if (pli==0) { - /* Packet loss -> remove info from frame */ - memset(encoded_data, 0, sizeof(int16_t)*25); - } - } else { - fprintf(stderr, "Error. Channel file too short\n"); - exit(0); - } - } else { - pli=1; - } - - /* decoding */ - fprintf(stderr, "--- Decoding block %i --- ",blockcount); - if (pli==1) { - len_int = WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, - &speechType); - if (len_int < 0) { - fprintf(stderr, "Error decoding\n"); - exit(0); - } - len = (size_t)len_int; - } else { - len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1); - } - fprintf(stderr, "\r"); - - /* write output file */ - fwrite(data,sizeof(short),len,ofileid); - } - } - -#ifdef JUNK_DATA - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "ok\n\n"); - fclose(seedfile); - } -#endif - - /* free structs */ - WebRtcIlbcfix_EncoderFree(Enc_Inst); - WebRtcIlbcfix_DecoderFree(Dec_Inst); - - /* close files */ - fclose(ifileid); - fclose(efileid); - fclose(ofileid); - - return 0; -} diff --git a/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c b/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c deleted file mode 100644 index a62a42edf6..0000000000 --- a/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBC_test.c - -******************************************************************/ - -#include -#include -#include -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" -#include "modules/audio_coding/codecs/ilbc/nit_encode.h" -#include "modules/audio_coding/codecs/ilbc/encode.h" -#include "modules/audio_coding/codecs/ilbc/init_decode.h" -#include "modules/audio_coding/codecs/ilbc/decode.h" -#include "modules/audio_coding/codecs/ilbc/constants.h" -#include "modules/audio_coding/codecs/ilbc/ilbc.h" - -#define ILBCNOOFWORDS_MAX (NO_OF_BYTES_30MS)/2 - -/* Runtime statistics */ -#include -/* #define CLOCKS_PER_SEC 1000 */ - -/*----------------------------------------------------------------* - * Encoder interface function - *---------------------------------------------------------------*/ - -short encode( /* (o) Number of bytes encoded */ - IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */ - int16_t *encoded_data, /* (o) The encoded bytes */ - int16_t *data /* (i) The signal block to encode */ - ){ - - /* do the actual encoding */ - WebRtcIlbcfix_Encode((uint16_t *)encoded_data, data, iLBCenc_inst); - - return (iLBCenc_inst->no_of_bytes); -} - -/*----------------------------------------------------------------* - * Decoder interface function - *---------------------------------------------------------------*/ - -short decode( /* (o) Number of decoded samples */ - IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */ - short *decoded_data, /* (o) Decoded signal block */ - short *encoded_data, /* (i) Encoded bytes */ - short mode /* (i) 0=PL, 1=Normal */ - ){ - - /* check if mode is valid */ - - if (mode<0 || mode>1) { - printf("\nERROR - Wrong mode - 0, 1 allowed\n"); exit(3);} - - /* do actual decoding of block */ - - WebRtcIlbcfix_Decode(decoded_data, (uint16_t *)encoded_data, - iLBCdec_inst, mode); - - return (iLBCdec_inst->blockl); -} - -/*----------------------------------------------------------------* - * Main program to test iLBC encoding and decoding - * - * Usage: - * exefile_name.exe - * - *---------------------------------------------------------------*/ - -#define MAXFRAMES 10000 -#define MAXFILELEN (BLOCKL_MAX*MAXFRAMES) - -int main(int argc, char* argv[]) -{ - - /* Runtime statistics */ - - float starttime1, starttime2; - float runtime1, runtime2; - float outtime; - - FILE *ifileid,*efileid,*ofileid, *chfileid; - short *inputdata, *encodeddata, *decodeddata; - short *channeldata; - int blockcount = 0, noOfBlocks=0, i, noOfLostBlocks=0; - short mode; - IlbcEncoder Enc_Inst; - IlbcDecoder Dec_Inst; - - short frameLen; - short count; -#ifdef SPLIT_10MS - short size; -#endif - - inputdata=(short*) malloc(MAXFILELEN*sizeof(short)); - if (inputdata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - exit(0); - } - encodeddata=(short*) malloc(ILBCNOOFWORDS_MAX*MAXFRAMES*sizeof(short)); - if (encodeddata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - exit(0); - } - decodeddata=(short*) malloc(MAXFILELEN*sizeof(short)); - if (decodeddata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - free(encodeddata); - exit(0); - } - channeldata=(short*) malloc(MAXFRAMES*sizeof(short)); - if (channeldata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - free(encodeddata); - free(decodeddata); - exit(0); - } - - /* get arguments and open files */ - - if (argc != 6 ) { - fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n", - argv[0]); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open channelfile file %s\n", - argv[3]); exit(3);} - if( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open output file %s\n", - argv[4]); exit(3);} - if ( (chfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr,"Cannot open channel file file %s\n", argv[5]); - exit(2);} - - - /* print info */ -#ifndef PRINT_MIPS - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBCtest *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); -#ifdef SPLIT_10MS - fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode); -#else - fprintf(stderr,"\nMode : %2d ms\n", mode); -#endif - fprintf(stderr,"\nInput file : %s\n", argv[2]); - fprintf(stderr,"Coded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n\n", argv[4]); - fprintf(stderr,"Channel file : %s\n\n", argv[5]); -#endif - - /* Initialization */ - - WebRtcIlbcfix_EncoderInit(&Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(&Dec_Inst, mode, 1); - - /* extract the input file and channel file */ - -#ifdef SPLIT_10MS - frameLen = (mode==20)? 80:160; - fread(Enc_Inst.past_samples, sizeof(short), frameLen, ifileid); - Enc_Inst.section = 0; - - while( fread(&inputdata[noOfBlocks*80], sizeof(short), - 80, ifileid) == 80 ) { - noOfBlocks++; - } - - noOfBlocks += frameLen/80; - frameLen = 80; -#else - frameLen = Enc_Inst.blockl; - - while( fread(&inputdata[noOfBlocks*Enc_Inst.blockl],sizeof(short), - Enc_Inst.blockl,ifileid)==(uint16_t)Enc_Inst.blockl){ - noOfBlocks++; - } -#endif - - - while ((fread(&channeldata[blockcount],sizeof(short), 1,chfileid)==1) - && ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) )) { - blockcount++; - } - - if ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) ) { - fprintf(stderr,"Channel file %s is too short\n", argv[4]); - free(inputdata); - free(encodeddata); - free(decodeddata); - free(channeldata); - exit(0); - } - - count=0; - - /* Runtime statistics */ - - starttime1 = clock()/(float)CLOCKS_PER_SEC; - - /* Encoding loop */ -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - -#ifdef SPLIT_10MS - /* "Enc_Inst.section != 0" is to make sure we run through full - lengths of all vectors for 10ms split mode. - */ - // while( (count < noOfBlocks) || (Enc_Inst.section != 0) ) { - while( count < blockcount * (Enc_Inst.blockl/frameLen) ) { - - encode(&Enc_Inst, &encodeddata[Enc_Inst.no_of_words * - (count/(Enc_Inst.nsub/2))], - &inputdata[frameLen * count] ); -#else - while (count < noOfBlocks) { - encode( &Enc_Inst, &encodeddata[Enc_Inst.no_of_words * count], - &inputdata[frameLen * count] ); -#endif - -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - - count++; - } - - count=0; - - /* Runtime statistics */ - - starttime2=clock()/(float)CLOCKS_PER_SEC; - runtime1 = (float)(starttime2-starttime1); - - /* Decoding loop */ - - while (count < blockcount) { - if (channeldata[count]==1) { - /* Normal decoding */ - decode(&Dec_Inst, &decodeddata[count * Dec_Inst.blockl], - &encodeddata[Dec_Inst.no_of_words * count], 1); - } else if (channeldata[count]==0) { - /* PLC */ - short emptydata[ILBCNOOFWORDS_MAX]; - memset(emptydata, 0, Dec_Inst.no_of_words*sizeof(short)); - decode(&Dec_Inst, &decodeddata[count*Dec_Inst.blockl], - emptydata, 0); - noOfLostBlocks++; - } else { - printf("Error in channel file (values have to be either 1 or 0)\n"); - exit(0); - } -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - - count++; - } - - /* Runtime statistics */ - - runtime2 = (float)(clock()/(float)CLOCKS_PER_SEC-starttime2); - - outtime = (float)((float)blockcount* - (float)mode/1000.0); - -#ifndef PRINT_MIPS - printf("\nLength of speech file: %.1f s\n", outtime); - printf("Lost frames : %.1f%%\n\n", 100*(float)noOfLostBlocks/(float)blockcount); - - printf("Time to run iLBC_encode+iLBC_decode:"); - printf(" %.1f s (%.1f%% of realtime)\n", runtime1+runtime2, - (100*(runtime1+runtime2)/outtime)); - - printf("Time in iLBC_encode :"); - printf(" %.1f s (%.1f%% of total runtime)\n", - runtime1, 100.0*runtime1/(runtime1+runtime2)); - - printf("Time in iLBC_decode :"); - printf(" %.1f s (%.1f%% of total runtime)\n\n", - runtime2, 100.0*runtime2/(runtime1+runtime2)); -#endif - - /* Write data to files */ - for (i=0; ilsf[0] = (*bitstreamPtr)>>10; /* Bit 0..5 */ - enc_bits->lsf[1] = ((*bitstreamPtr)>>3)&0x7F; /* Bit 6..12 */ - enc_bits->lsf[2] = ((*bitstreamPtr)&0x7)<<4; /* Bit 13..15 */ - bitstreamPtr++; - /* Second int16_t */ - enc_bits->lsf[2] |= ((*bitstreamPtr)>>12)&0xF; /* Bit 0..3 */ - - if (mode==20) { - enc_bits->startIdx = ((*bitstreamPtr)>>10)&0x3; /* Bit 4..5 */ - enc_bits->state_first = ((*bitstreamPtr)>>9)&0x1; /* Bit 6 */ - enc_bits->idxForMax = ((*bitstreamPtr)>>3)&0x3F; /* Bit 7..12 */ - enc_bits->cb_index[0] = ((*bitstreamPtr)&0x7)<<4; /* Bit 13..15 */ - bitstreamPtr++; - /* Third int16_t */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>12)&0xE; /* Bit 0..2 */ - enc_bits->gain_index[0] = ((*bitstreamPtr)>>8)&0x18; /* Bit 3..4 */ - enc_bits->gain_index[1] = ((*bitstreamPtr)>>7)&0x8; /* Bit 5 */ - enc_bits->cb_index[3] = ((*bitstreamPtr)>>2)&0xFE; /* Bit 6..12 */ - enc_bits->gain_index[3] = ((*bitstreamPtr)<<2)&0x10; /* Bit 13 */ - enc_bits->gain_index[4] = ((*bitstreamPtr)<<2)&0x8; /* Bit 14 */ - enc_bits->gain_index[6] = ((*bitstreamPtr)<<4)&0x10; /* Bit 15 */ - } else { /* mode==30 */ - enc_bits->lsf[3] = ((*bitstreamPtr)>>6)&0x3F; /* Bit 4..9 */ - enc_bits->lsf[4] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* Third int16_t */ - enc_bits->lsf[4] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->lsf[5] = ((*bitstreamPtr)>>8)&0x7F; /* Bit 1..7 */ - enc_bits->startIdx = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->state_first = ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->idxForMax = ((*bitstreamPtr)<<2)&0x3C; /* Bit 12..15 */ - bitstreamPtr++; - /* 4:th int16_t */ - enc_bits->idxForMax |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->cb_index[0] = ((*bitstreamPtr)>>7)&0x78; /* Bit 2..5 */ - enc_bits->gain_index[0] = ((*bitstreamPtr)>>5)&0x10; /* Bit 6 */ - enc_bits->gain_index[1] = ((*bitstreamPtr)>>5)&0x8; /* Bit 7 */ - enc_bits->cb_index[3] = ((*bitstreamPtr))&0xFC; /* Bit 8..13 */ - enc_bits->gain_index[3] = ((*bitstreamPtr)<<3)&0x10; /* Bit 14 */ - enc_bits->gain_index[4] = ((*bitstreamPtr)<<3)&0x8; /* Bit 15 */ - } - /* Class 2 bits of ULP */ - /* 4:th to 6:th int16_t for 20 ms case - 5:th to 7:th int16_t for 30 ms case */ - bitstreamPtr++; - tmpPtr=enc_bits->idxVec; - for (k=0; k<3; k++) { - for (i=15; i>=0; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 7:th int16_t */ - for (i=15; i>6; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>4)&0x4; /* Bit 9 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>2)&0xC; /* Bit 10..11 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>1)&0x4; /* Bit 12 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)<<1)&0x8; /* Bit 13 */ - enc_bits->gain_index[7] = ((*bitstreamPtr)<<2)&0xC; /* Bit 14..15 */ - - } else { /* mode==30 */ - /* 8:th int16_t */ - for (i=15; i>5; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>3)&0x6; /* Bit 10..11 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr))&0x8; /* Bit 12 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr))&0x4; /* Bit 13 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr))&0x2; /* Bit 14 */ - enc_bits->cb_index[6] = ((*bitstreamPtr)<<7)&0x80; /* Bit 15 */ - bitstreamPtr++; - /* 9:th int16_t */ - enc_bits->cb_index[6] |= ((*bitstreamPtr)>>9)&0x7E; /* Bit 0..5 */ - enc_bits->cb_index[9] = ((*bitstreamPtr)>>2)&0xFE; /* Bit 6..12 */ - enc_bits->cb_index[12] = ((*bitstreamPtr)<<5)&0xE0; /* Bit 13..15 */ - bitstreamPtr++; - /* 10:th int16_t */ - enc_bits->cb_index[12] |= ((*bitstreamPtr)>>11)&0x1E;/* Bit 0..3 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>8)&0xC; /* Bit 4..5 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>7)&0x6; /* Bit 6..7 */ - enc_bits->gain_index[6] = ((*bitstreamPtr)>>3)&0x18; /* Bit 8..9 */ - enc_bits->gain_index[7] = ((*bitstreamPtr)>>2)&0xC; /* Bit 10..11 */ - enc_bits->gain_index[9] = ((*bitstreamPtr)<<1)&0x10; /* Bit 12 */ - enc_bits->gain_index[10] = ((*bitstreamPtr)<<1)&0x8; /* Bit 13 */ - enc_bits->gain_index[12] = ((*bitstreamPtr)<<3)&0x10; /* Bit 14 */ - enc_bits->gain_index[13] = ((*bitstreamPtr)<<3)&0x8; /* Bit 15 */ - } - bitstreamPtr++; - /* Class 3 bits of ULP */ - /* 8:th to 14:th int16_t for 20 ms case - 11:th to 17:th int16_t for 30 ms case */ - tmpPtr=enc_bits->idxVec; - for (k=0; k<7; k++) { - for (i=14; i>=0; i-=2) { - (*tmpPtr) |= ((*bitstreamPtr)>>i)&0x3; /* Bit 15-i..14-i*/ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 15:th int16_t */ - enc_bits->idxVec[56] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>13)&0x1; /* Bit 2 */ - enc_bits->cb_index[1] = ((*bitstreamPtr)>>6)&0x7F; /* Bit 3..9 */ - enc_bits->cb_index[2] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* 16:th int16_t */ - enc_bits->cb_index[2] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr)>>12)&0x7; /* Bit 1..3 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>10)&0x3; /* Bit 4..5 */ - enc_bits->gain_index[2] = ((*bitstreamPtr)>>7)&0x7; /* Bit 6..8 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr)>>6)&0x1; /* Bit 9 */ - enc_bits->cb_index[4] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* 17:th int16_t */ - enc_bits->cb_index[4] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->cb_index[5] = ((*bitstreamPtr)>>8)&0x7F; /* Bit 1..7 */ - enc_bits->cb_index[6] = ((*bitstreamPtr))&0xFF; /* Bit 8..15 */ - bitstreamPtr++; - /* 18:th int16_t */ - enc_bits->cb_index[7] = (*bitstreamPtr)>>8; /* Bit 0..7 */ - enc_bits->cb_index[8] = (*bitstreamPtr)&0xFF; /* Bit 8..15 */ - bitstreamPtr++; - /* 19:th int16_t */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>12)&0x3; /* Bit 2..3 */ - enc_bits->gain_index[5] = ((*bitstreamPtr)>>9)&0x7; /* Bit 4..6 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)>>6)&0x7; /* Bit 7..9 */ - enc_bits->gain_index[7] |= ((*bitstreamPtr)>>4)&0x3; /* Bit 10..11 */ - enc_bits->gain_index[8] = ((*bitstreamPtr)>>1)&0x7; /* Bit 12..14 */ - } else { /* mode==30 */ - /* 18:th int16_t */ - enc_bits->idxVec[56] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->idxVec[57] |= ((*bitstreamPtr)>>12)&0x3; /* Bit 2..3 */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>11)&1; /* Bit 4 */ - enc_bits->cb_index[1] = ((*bitstreamPtr)>>4)&0x7F; /* Bit 5..11 */ - enc_bits->cb_index[2] = ((*bitstreamPtr)<<3)&0x78; /* Bit 12..15 */ - bitstreamPtr++; - /* 19:th int16_t */ - enc_bits->cb_index[2] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr)>>10)&0x7; /* Bit 3..5 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>8)&0x3; /* Bit 6..7 */ - enc_bits->gain_index[2] = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->cb_index[4] = ((*bitstreamPtr)<<3)&0x78; /* Bit 12..15 */ - bitstreamPtr++; - /* 20:th int16_t */ - enc_bits->cb_index[4] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->cb_index[5] = ((*bitstreamPtr)>>6)&0x7F; /* Bit 3..9 */ - enc_bits->cb_index[6] |= ((*bitstreamPtr)>>5)&0x1; /* Bit 10 */ - enc_bits->cb_index[7] = ((*bitstreamPtr)<<3)&0xF8; /* Bit 11..15 */ - bitstreamPtr++; - /* 21:st int16_t */ - enc_bits->cb_index[7] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->cb_index[8] = ((*bitstreamPtr)>>5)&0xFF; /* Bit 3..10 */ - enc_bits->cb_index[9] |= ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->cb_index[10] = ((*bitstreamPtr)<<4)&0xF0; /* Bit 12..15 */ - bitstreamPtr++; - /* 22:nd int16_t */ - enc_bits->cb_index[10] |= ((*bitstreamPtr)>>12)&0xF; /* Bit 0..3 */ - enc_bits->cb_index[11] = ((*bitstreamPtr)>>4)&0xFF; /* Bit 4..11 */ - enc_bits->cb_index[12] |= ((*bitstreamPtr)>>3)&0x1; /* Bit 12 */ - enc_bits->cb_index[13] = ((*bitstreamPtr)<<5)&0xE0; /* Bit 13..15 */ - bitstreamPtr++; - /* 23:rd int16_t */ - enc_bits->cb_index[13] |= ((*bitstreamPtr)>>11)&0x1F;/* Bit 0..4 */ - enc_bits->cb_index[14] = ((*bitstreamPtr)>>3)&0xFF; /* Bit 5..12 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>1)&0x3; /* Bit 13..14 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)&0x1); /* Bit 15 */ - bitstreamPtr++; - /* 24:rd int16_t */ - enc_bits->gain_index[5] = ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)>>10)&0x7; /* Bit 3..5 */ - enc_bits->gain_index[7] |= ((*bitstreamPtr)>>8)&0x3; /* Bit 6..7 */ - enc_bits->gain_index[8] = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->gain_index[9] |= ((*bitstreamPtr)>>1)&0xF; /* Bit 11..14 */ - enc_bits->gain_index[10] |= ((*bitstreamPtr)<<2)&0x4; /* Bit 15 */ - bitstreamPtr++; - /* 25:rd int16_t */ - enc_bits->gain_index[10] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->gain_index[11] = ((*bitstreamPtr)>>11)&0x7; /* Bit 2..4 */ - enc_bits->gain_index[12] |= ((*bitstreamPtr)>>7)&0xF; /* Bit 5..8 */ - enc_bits->gain_index[13] |= ((*bitstreamPtr)>>4)&0x7; /* Bit 9..11 */ - enc_bits->gain_index[14] = ((*bitstreamPtr)>>1)&0x7; /* Bit 12..14 */ - } - /* Last bit should be zero, otherwise it's an "empty" frame */ - if (((*bitstreamPtr)&0x1) == 1) { - return(1); - } else { - return(0); - } -} diff --git a/modules/audio_coding/codecs/ilbc/unpack_bits.h b/modules/audio_coding/codecs/ilbc/unpack_bits.h deleted file mode 100644 index 1ef5e1a7db..0000000000 --- a/modules/audio_coding/codecs/ilbc/unpack_bits.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_UnpackBits.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ - -#include - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -int16_t -WebRtcIlbcfix_UnpackBits(/* (o) "Empty" frame indicator */ - const uint16_t* - bitstream, /* (i) The packatized bitstream */ - iLBC_bits* - enc_bits, /* (o) Paramerers from bitstream */ - int16_t mode /* (i) Codec mode (20 or 30) */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/vq3.c b/modules/audio_coding/codecs/ilbc/vq3.c deleted file mode 100644 index d9375fb995..0000000000 --- a/modules/audio_coding/codecs/ilbc/vq3.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq3.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/vq3.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" - -/*----------------------------------------------------------------* - * vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq3( - int16_t *Xq, /* quantized vector (Q13) */ - int16_t *index, - int16_t *CB, /* codebook in Q13 */ - int16_t *X, /* vector to quantize (Q13) */ - int16_t n_cb - ){ - int16_t i, j; - int16_t pos, minindex=0; - int16_t tmp; - int32_t dist, mindist; - - pos = 0; - mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ - - /* Find the codebook with the lowest square distance */ - for (j = 0; j < n_cb; j++) { - tmp = X[0] - CB[pos]; - dist = tmp * tmp; - for (i = 1; i < 3; i++) { - tmp = X[i] - CB[pos + i]; - dist += tmp * tmp; - } - - if (dist < mindist) { - mindist = dist; - minindex = j; - } - pos += 3; - } - - /* Store the quantized codebook and the index */ - for (i = 0; i < 3; i++) { - Xq[i] = CB[minindex*3 + i]; - } - *index = minindex; - -} diff --git a/modules/audio_coding/codecs/ilbc/vq3.h b/modules/audio_coding/codecs/ilbc/vq3.h deleted file mode 100644 index 33d06b8ad0..0000000000 --- a/modules/audio_coding/codecs/ilbc/vq3.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq3.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ - -#include - -/*----------------------------------------------------------------* - * Vector quantization of order 3 (based on MSE) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq3( - int16_t* Xq, /* (o) the quantized vector (Q13) */ - int16_t* index, /* (o) the quantization index */ - int16_t* CB, /* (i) the vector quantization codebook (Q13) */ - int16_t* X, /* (i) the vector to quantize (Q13) */ - int16_t n_cb /* (i) the number of vectors in the codebook */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/vq4.c b/modules/audio_coding/codecs/ilbc/vq4.c deleted file mode 100644 index c9a65aec2a..0000000000 --- a/modules/audio_coding/codecs/ilbc/vq4.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq4.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/vq4.h" - -#include "modules/audio_coding/codecs/ilbc/constants.h" - -/*----------------------------------------------------------------* - * vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq4( - int16_t *Xq, /* quantized vector (Q13) */ - int16_t *index, - int16_t *CB, /* codebook in Q13 */ - int16_t *X, /* vector to quantize (Q13) */ - int16_t n_cb - ){ - int16_t i, j; - int16_t pos, minindex=0; - int16_t tmp; - int32_t dist, mindist; - - pos = 0; - mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ - - /* Find the codebook with the lowest square distance */ - for (j = 0; j < n_cb; j++) { - tmp = X[0] - CB[pos]; - dist = tmp * tmp; - for (i = 1; i < 4; i++) { - tmp = X[i] - CB[pos + i]; - dist += tmp * tmp; - } - - if (dist < mindist) { - mindist = dist; - minindex = j; - } - pos += 4; - } - - /* Store the quantized codebook and the index */ - for (i = 0; i < 4; i++) { - Xq[i] = CB[minindex*4 + i]; - } - *index = minindex; -} diff --git a/modules/audio_coding/codecs/ilbc/vq4.h b/modules/audio_coding/codecs/ilbc/vq4.h deleted file mode 100644 index 0337368bcb..0000000000 --- a/modules/audio_coding/codecs/ilbc/vq4.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq4.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ - -#include - -/*----------------------------------------------------------------* - * Vector quantization of order 4 (based on MSE) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq4( - int16_t* Xq, /* (o) the quantized vector (Q13) */ - int16_t* index, /* (o) the quantization index */ - int16_t* CB, /* (i) the vector quantization codebook (Q13) */ - int16_t* X, /* (i) the vector to quantize (Q13) */ - int16_t n_cb /* (i) the number of vectors in the codebook */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/window32_w32.c b/modules/audio_coding/codecs/ilbc/window32_w32.c deleted file mode 100644 index e82d167220..0000000000 --- a/modules/audio_coding/codecs/ilbc/window32_w32.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Window32W32.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/window32_w32.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * window multiplication - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Window32W32( - int32_t *z, /* Output */ - int32_t *x, /* Input (same domain as Output)*/ - const int32_t *y, /* Q31 Window */ - size_t N /* length to process */ - ) { - size_t i; - int16_t x_low, x_hi, y_low, y_hi; - int16_t left_shifts; - int32_t temp; - - left_shifts = (int16_t)WebRtcSpl_NormW32(x[0]); - WebRtcSpl_VectorBitShiftW32(x, N, x, (int16_t)(-left_shifts)); - - - /* The double precision numbers use a special representation: - * w32 = hi<<16 + lo<<1 - */ - for (i = 0; i < N; i++) { - /* Extract higher bytes */ - x_hi = (int16_t)(x[i] >> 16); - y_hi = (int16_t)(y[i] >> 16); - - /* Extract lower bytes, defined as (w32 - hi<<16)>>1 */ - x_low = (int16_t)((x[i] - (x_hi << 16)) >> 1); - - y_low = (int16_t)((y[i] - (y_hi << 16)) >> 1); - - /* Calculate z by a 32 bit multiplication using both low and high from x and y */ - temp = ((x_hi * y_hi) << 1) + ((x_hi * y_low) >> 14); - - z[i] = temp + ((x_low * y_hi) >> 14); - } - - WebRtcSpl_VectorBitShiftW32(z, N, z, left_shifts); - - return; -} diff --git a/modules/audio_coding/codecs/ilbc/window32_w32.h b/modules/audio_coding/codecs/ilbc/window32_w32.h deleted file mode 100644 index 93bb72e998..0000000000 --- a/modules/audio_coding/codecs/ilbc/window32_w32.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Window32W32.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ - -#include -#include - -/*----------------------------------------------------------------* - * window multiplication - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Window32W32(int32_t* z, /* Output */ - int32_t* x, /* Input (same domain as Output)*/ - const int32_t* y, /* Q31 Window */ - size_t N /* length to process */ -); - -#endif diff --git a/modules/audio_coding/codecs/ilbc/xcorr_coef.c b/modules/audio_coding/codecs/ilbc/xcorr_coef.c deleted file mode 100644 index 9dc880b37e..0000000000 --- a/modules/audio_coding/codecs/ilbc/xcorr_coef.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_XcorrCoef.c - -******************************************************************/ - -#include "modules/audio_coding/codecs/ilbc/xcorr_coef.h" - -#include "modules/audio_coding/codecs/ilbc/defines.h" - -/*----------------------------------------------------------------* - * cross correlation which finds the optimal lag for the - * crossCorr*crossCorr/(energy) criteria - *---------------------------------------------------------------*/ - -size_t WebRtcIlbcfix_XcorrCoef( - int16_t *target, /* (i) first array */ - int16_t *regressor, /* (i) second array */ - size_t subl, /* (i) dimension arrays */ - size_t searchLen, /* (i) the search lenght */ - size_t offset, /* (i) samples offset between arrays */ - int16_t step /* (i) +1 or -1 */ - ){ - size_t k; - size_t maxlag; - int16_t pos; - int16_t max; - int16_t crossCorrScale, Energyscale; - int16_t crossCorrSqMod, crossCorrSqMod_Max; - int32_t crossCorr, Energy; - int16_t crossCorrmod, EnergyMod, EnergyMod_Max; - int16_t *tp, *rp; - int16_t *rp_beg, *rp_end; - int16_t totscale, totscale_max; - int16_t scalediff; - int32_t newCrit, maxCrit; - int shifts; - - /* Initializations, to make sure that the first one is selected */ - crossCorrSqMod_Max=0; - EnergyMod_Max=WEBRTC_SPL_WORD16_MAX; - totscale_max=-500; - maxlag=0; - pos=0; - - /* Find scale value and start position */ - if (step==1) { - max=WebRtcSpl_MaxAbsValueW16(regressor, subl + searchLen - 1); - rp_beg = regressor; - rp_end = regressor + subl; - } else { /* step==-1 */ - max = WebRtcSpl_MaxAbsValueW16(regressor - searchLen, subl + searchLen - 1); - rp_beg = regressor - 1; - rp_end = regressor + subl - 1; - } - - /* Introduce a scale factor on the Energy in int32_t in - order to make sure that the calculation does not - overflow */ - - if (max>5000) { - shifts=2; - } else { - shifts=0; - } - - /* Calculate the first energy, then do a +/- to get the other energies */ - Energy=WebRtcSpl_DotProductWithScale(regressor, regressor, subl, shifts); - - for (k=0;k0)&&(crossCorr>0)) { - - /* Put cross correlation and energy on 16 bit word */ - crossCorrScale=(int16_t)WebRtcSpl_NormW32(crossCorr)-16; - crossCorrmod=(int16_t)WEBRTC_SPL_SHIFT_W32(crossCorr, crossCorrScale); - Energyscale=(int16_t)WebRtcSpl_NormW32(Energy)-16; - EnergyMod=(int16_t)WEBRTC_SPL_SHIFT_W32(Energy, Energyscale); - - /* Square cross correlation and store upper int16_t */ - crossCorrSqMod = (int16_t)((crossCorrmod * crossCorrmod) >> 16); - - /* Calculate the total number of (dynamic) right shifts that have - been performed on (crossCorr*crossCorr)/energy - */ - totscale=Energyscale-(crossCorrScale<<1); - - /* Calculate the shift difference in order to be able to compare the two - (crossCorr*crossCorr)/energy in the same domain - */ - scalediff=totscale-totscale_max; - scalediff=WEBRTC_SPL_MIN(scalediff,31); - scalediff=WEBRTC_SPL_MAX(scalediff,-31); - - /* Compute the cross multiplication between the old best criteria - and the new one to be able to compare them without using a - division */ - - if (scalediff<0) { - newCrit = ((int32_t)crossCorrSqMod*EnergyMod_Max)>>(-scalediff); - maxCrit = ((int32_t)crossCorrSqMod_Max*EnergyMod); - } else { - newCrit = ((int32_t)crossCorrSqMod*EnergyMod_Max); - maxCrit = ((int32_t)crossCorrSqMod_Max*EnergyMod)>>scalediff; - } - - /* Store the new lag value if the new criteria is larger - than previous largest criteria */ - - if (newCrit > maxCrit) { - crossCorrSqMod_Max = crossCorrSqMod; - EnergyMod_Max = EnergyMod; - totscale_max = totscale; - maxlag = k; - } - } - pos+=step; - - /* Do a +/- to get the next energy */ - Energy += step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts); - rp_beg+=step; - rp_end+=step; - } - - return(maxlag+offset); -} diff --git a/modules/audio_coding/codecs/ilbc/xcorr_coef.h b/modules/audio_coding/codecs/ilbc/xcorr_coef.h deleted file mode 100644 index 3fcce25147..0000000000 --- a/modules/audio_coding/codecs/ilbc/xcorr_coef.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_XcorrCoef.h - -******************************************************************/ - -#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ -#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ - -#include -#include - -/*----------------------------------------------------------------* - * cross correlation which finds the optimal lag for the - * crossCorr*crossCorr/(energy) criteria - *---------------------------------------------------------------*/ - -size_t WebRtcIlbcfix_XcorrCoef( - int16_t* target, /* (i) first array */ - int16_t* regressor, /* (i) second array */ - size_t subl, /* (i) dimension arrays */ - size_t searchLen, /* (i) the search lenght */ - size_t offset, /* (i) samples offset between arrays */ - int16_t step /* (i) +1 or -1 */ -); - -#endif diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc index ddcf0201f9..269f83e6f6 100644 --- a/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -21,8 +21,6 @@ #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" #include "modules/audio_coding/codecs/g722/audio_decoder_g722.h" #include "modules/audio_coding/codecs/g722/audio_encoder_g722.h" -#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" -#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" @@ -313,40 +311,6 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest { } }; -class AudioDecoderIlbcTest : public AudioDecoderTest { - protected: - AudioDecoderIlbcTest() : AudioDecoderTest() { - codec_input_rate_hz_ = 8000; - frame_size_ = 240; - data_length_ = 10 * frame_size_; - decoder_ = new AudioDecoderIlbcImpl; - RTC_DCHECK(decoder_); - AudioEncoderIlbcConfig config; - config.frame_size_ms = 30; - audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_)); - } - - // Overload the default test since iLBC's function WebRtcIlbcfix_NetEqPlc does - // not return any data. It simply resets a few states and returns 0. - void DecodePlcTest() { - InitEncoder(); - std::unique_ptr input(new int16_t[frame_size_]); - ASSERT_TRUE( - input_audio_.Read(frame_size_, codec_input_rate_hz_, input.get())); - rtc::Buffer encoded; - size_t enc_len = EncodeFrame(input.get(), frame_size_, &encoded); - AudioDecoder::SpeechType speech_type; - decoder_->Reset(); - std::unique_ptr output(new int16_t[frame_size_ * channels_]); - size_t dec_len = decoder_->Decode( - encoded.data(), enc_len, codec_input_rate_hz_, - frame_size_ * channels_ * sizeof(int16_t), output.get(), &speech_type); - EXPECT_EQ(frame_size_, dec_len); - // Simply call DecodePlc and verify that we get 0 as return value. - EXPECT_EQ(0U, decoder_->DecodePlc(1, output.get())); - } -}; - class AudioDecoderG722Test : public AudioDecoderTest { protected: AudioDecoderG722Test() : AudioDecoderTest() { @@ -460,25 +424,6 @@ TEST_F(AudioDecoderPcm16BTest, SetTargetBitrate) { codec_input_rate_hz_ * 16); } -// TODO(bugs.webrtc.org/345525069): Either fix/enable or remove iLBC. -#if defined(__has_feature) && __has_feature(undefined_behavior_sanitizer) -TEST_F(AudioDecoderIlbcTest, DISABLED_EncodeDecode) { -#else -TEST_F(AudioDecoderIlbcTest, EncodeDecode) { -#endif - int tolerance = 6808; - double mse = 2.13e6; - int delay = 80; // Delay from input to output. - EncodeDecodeTest(500, tolerance, mse, delay); - ReInitTest(); - EXPECT_TRUE(decoder_->HasDecodePlc()); - DecodePlcTest(); -} - -TEST_F(AudioDecoderIlbcTest, SetTargetBitrate) { - TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 13333); -} - // TODO(bugs.webrtc.org/345525069): Either fix/enable or remove G722. #if defined(__has_feature) && __has_feature(undefined_behavior_sanitizer) TEST_F(AudioDecoderG722Test, DISABLED_EncodeDecode) { diff --git a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc deleted file mode 100644 index 1004141f16..0000000000 --- a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include "absl/flags/flag.h" -#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" -#include "modules/audio_coding/neteq/tools/neteq_quality_test.h" -#include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" -#include "test/testsupport/file_utils.h" - -ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds)."); - -using ::testing::InitGoogleTest; - -namespace webrtc { -namespace test { -namespace { -static const int kInputSampleRateKhz = 8; -static const int kOutputSampleRateKhz = 8; -} // namespace - -class NetEqIlbcQualityTest : public NetEqQualityTest { - protected: - NetEqIlbcQualityTest() - : NetEqQualityTest(absl::GetFlag(FLAGS_frame_size_ms), - kInputSampleRateKhz, - kOutputSampleRateKhz, - SdpAudioFormat("ilbc", 8000, 1)) { - // Flag validation - RTC_CHECK(absl::GetFlag(FLAGS_frame_size_ms) == 20 || - absl::GetFlag(FLAGS_frame_size_ms) == 30 || - absl::GetFlag(FLAGS_frame_size_ms) == 40 || - absl::GetFlag(FLAGS_frame_size_ms) == 60) - << "Invalid frame size, should be 20, 30, 40, or 60 ms."; - } - - void SetUp() override { - ASSERT_EQ(1u, channels_) << "iLBC supports only mono audio."; - AudioEncoderIlbcConfig config; - config.frame_size_ms = absl::GetFlag(FLAGS_frame_size_ms); - encoder_.reset(new AudioEncoderIlbcImpl(config, 102)); - NetEqQualityTest::SetUp(); - } - - int EncodeBlock(int16_t* in_data, - size_t block_size_samples, - rtc::Buffer* payload, - size_t max_bytes) override { - const size_t kFrameSizeSamples = 80; // Samples per 10 ms. - size_t encoded_samples = 0; - uint32_t dummy_timestamp = 0; - AudioEncoder::EncodedInfo info; - do { - info = encoder_->Encode(dummy_timestamp, - rtc::ArrayView( - in_data + encoded_samples, kFrameSizeSamples), - payload); - encoded_samples += kFrameSizeSamples; - } while (info.encoded_bytes == 0); - return rtc::checked_cast(info.encoded_bytes); - } - - private: - std::unique_ptr encoder_; -}; - -TEST_F(NetEqIlbcQualityTest, Test) { - Simulate(); -} - -} // namespace test -} // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc index b46e30fe05..c5707e155a 100644 --- a/modules/audio_coding/neteq/tools/rtp_encode.cc +++ b/modules/audio_coding/neteq/tools/rtp_encode.cc @@ -28,7 +28,6 @@ #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/g711/audio_encoder_g711.h" #include "api/audio_codecs/g722/audio_encoder_g722.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment_factory.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" @@ -74,7 +73,6 @@ enum class CodecType { kPcm16b16, kPcm16b32, kPcm16b48, - kIlbc, }; struct CodecTypeAndInfo { @@ -96,8 +94,7 @@ const std::map& CodecList() { {"pcm16b_8", {CodecType::kPcm16b8, 93, false}}, {"pcm16b_16", {CodecType::kPcm16b16, 94, false}}, {"pcm16b_32", {CodecType::kPcm16b32, 95, false}}, - {"pcm16b_48", {CodecType::kPcm16b48, 96, false}}, - {"ilbc", {CodecType::kIlbc, 102, false}}}; + {"pcm16b_48", {CodecType::kPcm16b48, 96, false}}}; return *codec_list; } @@ -235,11 +232,6 @@ std::unique_ptr CreateEncoder(CodecType codec_type, return AudioEncoderL16::MakeAudioEncoder(Pcm16bConfig(codec_type), payload_type); } - - case CodecType::kIlbc: { - return AudioEncoderIlbc::MakeAudioEncoder( - GetCodecConfig(), payload_type); - } } RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc index 9d3d72ca65..3be24d6ac2 100644 --- a/modules/audio_coding/test/TestVADDTX.cc +++ b/modules/audio_coding/test/TestVADDTX.cc @@ -16,8 +16,6 @@ #include "absl/strings/string_view.h" #include "api/audio_codecs/audio_decoder_factory_template.h" #include "api/audio_codecs/audio_encoder_factory_template.h" -#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" -#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment_factory.h" @@ -69,10 +67,8 @@ void MonitoringAudioPacketizationCallback::GetStatistics(uint32_t* counter) { TestVadDtx::TestVadDtx() : env_(CreateEnvironment()), - encoder_factory_( - CreateAudioEncoderFactory()), - decoder_factory_( - CreateAudioDecoderFactory()), + encoder_factory_(CreateAudioEncoderFactory()), + decoder_factory_(CreateAudioDecoderFactory()), acm_send_(AudioCodingModule::Create()), neteq_(DefaultNetEqFactory().Create(env_, NetEq::Config(), @@ -182,10 +178,6 @@ void TestVadDtx::Run(absl::string_view in_filename, TestWebRtcVadDtx::TestWebRtcVadDtx() : output_file_num_(0) {} void TestWebRtcVadDtx::Perform() { -// TODO(bugs.webrtc.org/345525069): Either fix/enable or remove iLBC. -#if defined(__has_feature) && !__has_feature(undefined_behavior_sanitizer) - RunTestCases({"ILBC", 8000, 1}); -#endif RunTestCases({"opus", 48000, 2}); } diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index e692bdbed8..9fc2405bab 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -320,14 +320,6 @@ webrtc_fuzzer_test("audio_decoder_g722_fuzzer") { ] } -webrtc_fuzzer_test("audio_decoder_ilbc_fuzzer") { - sources = [ "audio_decoder_ilbc_fuzzer.cc" ] - deps = [ - ":audio_decoder_fuzzer", - "../../modules/audio_coding:ilbc", - ] -} - webrtc_fuzzer_test("audio_decoder_opus_fuzzer") { sources = [ "audio_decoder_opus_fuzzer.cc" ] deps = [ @@ -758,7 +750,6 @@ group("fuzzers") { ":agc_fuzzer", ":audio_decoder_fuzzer", ":audio_decoder_g722_fuzzer", - ":audio_decoder_ilbc_fuzzer", ":audio_decoder_multiopus_fuzzer", ":audio_decoder_opus_fuzzer", ":audio_decoder_opus_redundant_fuzzer", diff --git a/test/fuzzers/audio_decoder_ilbc_fuzzer.cc b/test/fuzzers/audio_decoder_ilbc_fuzzer.cc deleted file mode 100644 index 8548645c63..0000000000 --- a/test/fuzzers/audio_decoder_ilbc_fuzzer.cc +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" -#include "test/fuzzers/audio_decoder_fuzzer.h" - -namespace webrtc { -void FuzzOneInput(const uint8_t* data, size_t size) { - if (size > 10000) { - return; - } - AudioDecoderIlbcImpl dec; - static const int kSampleRateHz = 8000; - static const size_t kAllocatedOuputSizeSamples = kSampleRateHz / 10; - int16_t output[kAllocatedOuputSizeSamples]; - FuzzAudioDecoder(DecoderFunctionType::kNormalDecode, data, size, &dec, - kSampleRateHz, sizeof(output), output); -} -} // namespace webrtc diff --git a/webrtc.gni b/webrtc.gni index fe5e6a0d71..c8da32a8d6 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -99,9 +99,6 @@ declare_args() { # TLS-TURN server. In return disabling this saves around 100kb in the binary. rtc_builtin_ssl_root_certificates = true - # Include the iLBC audio codec? - rtc_include_ilbc = true - # Disable this to avoid building the Opus audio codec. rtc_include_opus = true