From fb075d558d6dbcda3392cfec05fdbe2cc06f9292 Mon Sep 17 00:00:00 2001 From: Minyue Li Date: Tue, 29 Oct 2019 21:38:15 +0100 Subject: [PATCH] Removing unused Opus wrapper API: WebRTCOpus_DecodePlc. Bug: None Change-Id: I5b613b4c13ec5f6ad13d8430043d006f6d83c11f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158671 Reviewed-by: Henrik Lundin Commit-Queue: Minyue Li Cr-Commit-Position: refs/heads/master@{#29664} --- .../audio_coding/codecs/opus/opus_fec_test.cc | 3 +- .../codecs/opus/opus_interface.cc | 50 +++++++++---------- .../audio_coding/codecs/opus/opus_interface.h | 18 ------- .../audio_coding/codecs/opus/opus_unittest.cc | 2 +- modules/audio_coding/test/opus_test.cc | 11 ++-- 5 files changed, 33 insertions(+), 51 deletions(-) diff --git a/modules/audio_coding/codecs/opus/opus_fec_test.cc b/modules/audio_coding/codecs/opus/opus_fec_test.cc index 1ab4d8650b..47e40c6ccc 100644 --- a/modules/audio_coding/codecs/opus/opus_fec_test.cc +++ b/modules/audio_coding/codecs/opus/opus_fec_test.cc @@ -154,7 +154,8 @@ void OpusFecTest::DecodeABlock(bool lost_previous, bool lost_current) { WebRtcOpus_DecodeFec(opus_decoder_, &bit_stream_[0], encoded_bytes_, &out_data_[0], &audio_type); } else { - value_1 = WebRtcOpus_DecodePlc(opus_decoder_, &out_data_[0], 1); + value_1 = + WebRtcOpus_Decode(opus_decoder_, NULL, 0, &out_data_[0], &audio_type); } EXPECT_EQ(static_cast(block_length_sample_), value_1); } diff --git a/modules/audio_coding/codecs/opus/opus_interface.cc b/modules/audio_coding/codecs/opus/opus_interface.cc index 45eab2b952..fc3d3ffddd 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.cc +++ b/modules/audio_coding/codecs/opus/opus_interface.cc @@ -514,6 +514,29 @@ static int DecodeNative(OpusDecInst* inst, return res; } +static int DecodePlc(OpusDecInst* inst, int16_t* decoded) { + int16_t audio_type = 0; + int decoded_samples; + int plc_samples; + + /* The number of samples we ask for is |number_of_lost_frames| times + * |prev_decoded_samples_|. Limit the number of samples to maximum + * |MaxFrameSizePerChannel()|. */ + plc_samples = inst->prev_decoded_samples; + const int max_samples_per_channel = + MaxFrameSizePerChannel(inst->sample_rate_hz); + plc_samples = plc_samples <= max_samples_per_channel + ? plc_samples + : max_samples_per_channel; + decoded_samples = + DecodeNative(inst, NULL, 0, plc_samples, decoded, &audio_type, 0); + if (decoded_samples < 0) { + return -1; + } + + return decoded_samples; +} + int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded, size_t encoded_bytes, @@ -523,7 +546,7 @@ int WebRtcOpus_Decode(OpusDecInst* inst, if (encoded_bytes == 0) { *audio_type = DetermineAudioType(inst, encoded_bytes); - decoded_samples = WebRtcOpus_DecodePlc(inst, decoded, 1); + decoded_samples = DecodePlc(inst, decoded); } else { decoded_samples = DecodeNative(inst, encoded, encoded_bytes, MaxFrameSizePerChannel(inst->sample_rate_hz), @@ -539,31 +562,6 @@ int WebRtcOpus_Decode(OpusDecInst* inst, return decoded_samples; } -int WebRtcOpus_DecodePlc(OpusDecInst* inst, - int16_t* decoded, - int number_of_lost_frames) { - int16_t audio_type = 0; - int decoded_samples; - int plc_samples; - - /* The number of samples we ask for is |number_of_lost_frames| times - * |prev_decoded_samples_|. Limit the number of samples to maximum - * |MaxFrameSizePerChannel()|. */ - plc_samples = number_of_lost_frames * inst->prev_decoded_samples; - const int max_samples_per_channel = - MaxFrameSizePerChannel(inst->sample_rate_hz); - plc_samples = plc_samples <= max_samples_per_channel - ? plc_samples - : max_samples_per_channel; - decoded_samples = - DecodeNative(inst, NULL, 0, plc_samples, decoded, &audio_type, 0); - if (decoded_samples < 0) { - return -1; - } - - return decoded_samples; -} - int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded, size_t encoded_bytes, diff --git a/modules/audio_coding/codecs/opus/opus_interface.h b/modules/audio_coding/codecs/opus/opus_interface.h index cf95a6912d..ef62e0d04d 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.h +++ b/modules/audio_coding/codecs/opus/opus_interface.h @@ -406,24 +406,6 @@ int WebRtcOpus_Decode(OpusDecInst* inst, int16_t* decoded, int16_t* audio_type); -/**************************************************************************** - * WebRtcOpus_DecodePlc(...) - * - * This function processes PLC for opus frame(s). - * Input: - * - inst : Decoder context - * - number_of_lost_frames : Number of PLC frames to produce - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ -int WebRtcOpus_DecodePlc(OpusDecInst* inst, - int16_t* decoded, - int number_of_lost_frames); - /**************************************************************************** * WebRtcOpus_DecodeFec(...) * diff --git a/modules/audio_coding/codecs/opus/opus_unittest.cc b/modules/audio_coding/codecs/opus/opus_unittest.cc index f0f2ef05d1..10897fb4b0 100644 --- a/modules/audio_coding/codecs/opus/opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_unittest.cc @@ -810,7 +810,7 @@ TEST_P(OpusTest, OpusDecodePlc) { // Call decoder PLC. int16_t* plc_buffer = new int16_t[decode_samples_per_channel * channels_]; EXPECT_EQ(decode_samples_per_channel, - WebRtcOpus_DecodePlc(opus_decoder_, plc_buffer, 1)); + WebRtcOpus_Decode(opus_decoder_, NULL, 0, plc_buffer, &audio_type)); // Free memory. delete[] plc_buffer; diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc index 7f0bdd2974..10644e270d 100644 --- a/modules/audio_coding/test/opus_test.cc +++ b/modules/audio_coding/test/opus_test.cc @@ -299,8 +299,9 @@ void OpusTest::Run(TestPackStereo* channel, opus_mono_decoder_, bitstream, bitstream_len_byte, &out_audio[decoded_samples * channels], &audio_type); } else { - decoded_samples += WebRtcOpus_DecodePlc( - opus_mono_decoder_, &out_audio[decoded_samples * channels], 1); + decoded_samples += WebRtcOpus_Decode( + opus_mono_decoder_, NULL, 0, + &out_audio[decoded_samples * channels], &audio_type); } } else { if (!lost_packet) { @@ -308,9 +309,9 @@ void OpusTest::Run(TestPackStereo* channel, opus_stereo_decoder_, bitstream, bitstream_len_byte, &out_audio[decoded_samples * channels], &audio_type); } else { - decoded_samples += - WebRtcOpus_DecodePlc(opus_stereo_decoder_, - &out_audio[decoded_samples * channels], 1); + decoded_samples += WebRtcOpus_Decode( + opus_stereo_decoder_, NULL, 0, + &out_audio[decoded_samples * channels], &audio_type); } }