Merge commit 'upstream-main' into master

Bug: 261600888
Test: none, build files to be updated in follow up cl
Change-Id: Ib520938290c6bbdee4a9f73b6419b6c947a96ec4
This commit is contained in:
Jorge E. Moreira
2022-12-06 16:34:41 -08:00
5393 changed files with 541103 additions and 211666 deletions

View File

@ -21,7 +21,6 @@ group("modules") {
"rtp_rtcp",
"utility",
"video_coding",
"video_processing",
]
if (rtc_desktop_capture_supported) {
@ -31,21 +30,12 @@ group("modules") {
rtc_source_set("module_api_public") {
sources = [ "include/module_common_types_public.h" ]
deps = [ "..:webrtc_common" ]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_library("module_api") {
rtc_source_set("module_api") {
visibility = [ "*" ]
sources = [
"include/module.h",
"include/module_common_types.cc",
"include/module_common_types.h",
]
deps = [
"../rtc_base:safe_conversions",
"../rtc_base/system:rtc_export",
]
sources = [ "include/module_common_types.h" ]
}
rtc_source_set("module_fec_api") {
@ -53,7 +43,7 @@ rtc_source_set("module_fec_api") {
sources = [ "include/module_fec_types.h" ]
}
if (rtc_include_tests) {
if (rtc_include_tests && !build_with_chromium) {
modules_tests_resources = [
"../resources/audio_coding/testfile16kHz.pcm",
"../resources/audio_coding/testfile32kHz.pcm",
@ -88,12 +78,14 @@ if (rtc_include_tests) {
data = modules_tests_resources
if (is_android) {
use_default_launcher = false
deps += [
# NOTE(brandtr): Including Java classes seems only to be possible from
# rtc_test targets. Therefore we include this target here, instead of
# in video_coding_modules_tests, where it is actually used.
"../sdk/android:libjingle_peerconnection_java",
"//testing/android/native_test:native_test_native_code",
"//sdk/android:native_test_jni_onload",
"//testing/android/native_test:native_test_support",
]
shard_timeout = 900
}
@ -127,6 +119,7 @@ if (rtc_include_tests) {
"../resources/audio_processing/agc/agc_with_circular_buffer.dat",
"../resources/audio_processing/output_data_fixed.pb",
"../resources/audio_processing/output_data_float.pb",
"../resources/audio_processing/output_data_float_avx2.pb",
"../resources/audio_processing/output_data_mac.pb",
"../resources/audio_processing/transient/ajm-macbook-1-spke16m.pcm",
"../resources/audio_processing/transient/audio16kHz.pcm",
@ -152,18 +145,28 @@ if (rtc_include_tests) {
"../resources/audio_processing/transient/wpd7.dat",
"../resources/deflicker_before_cif_short.yuv",
"../resources/far16_stereo.pcm",
"../resources/far176_stereo.pcm",
"../resources/far192_stereo.pcm",
"../resources/far22_stereo.pcm",
"../resources/far32_stereo.pcm",
"../resources/far44_stereo.pcm",
"../resources/far48_stereo.pcm",
"../resources/far88_stereo.pcm",
"../resources/far8_stereo.pcm",
"../resources/far96_stereo.pcm",
"../resources/foremanColorEnhanced_cif_short.yuv",
"../resources/foreman_cif.yuv",
"../resources/foreman_cif_short.yuv",
"../resources/near16_stereo.pcm",
"../resources/near176_stereo.pcm",
"../resources/near192_stereo.pcm",
"../resources/near22_stereo.pcm",
"../resources/near32_stereo.pcm",
"../resources/near44_stereo.pcm",
"../resources/near48_stereo.pcm",
"../resources/near88_stereo.pcm",
"../resources/near8_stereo.pcm",
"../resources/near96_stereo.pcm",
"../resources/ref03.aecdump",
"../resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_AST.bin",
"../resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_TOF.bin",
@ -226,7 +229,7 @@ if (rtc_include_tests) {
"rtp_rtcp:rtp_rtcp_unittests",
"utility:utility_unittests",
"video_coding:video_coding_unittests",
"video_processing:video_processing_unittests",
"video_coding/timing:timing_unittests",
]
if (rtc_desktop_capture_supported) {
@ -236,6 +239,7 @@ if (rtc_include_tests) {
data = modules_unittests_resources
if (is_android) {
use_default_launcher = false
deps += [
"../sdk/android:libjingle_peerconnection_java",
"//testing/android/native_test:native_test_support",

View File

@ -0,0 +1,43 @@
# Copyright (c) 2020 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")
rtc_library("async_audio_processing") {
sources = [
"async_audio_processing.cc",
"async_audio_processing.h",
]
public = [ "async_audio_processing.h" ]
deps = [
"../../api:scoped_refptr",
"../../api:sequence_checker",
"../../api/audio:audio_frame_api",
"../../api/audio:audio_frame_processor",
"../../api/task_queue:task_queue",
"../../rtc_base:checks",
"../../rtc_base:refcount",
"../../rtc_base:rtc_task_queue",
]
}
if (rtc_include_tests) {
rtc_library("async_audio_processing_test") {
testonly = true
sources = []
deps = [
":async_audio_processing",
"../../api/audio:audio_frame_api",
"../../rtc_base:checks",
]
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2020 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/async_audio_processing/async_audio_processing.h"
#include <utility>
#include "api/audio/audio_frame.h"
#include "api/task_queue/task_queue_factory.h"
#include "rtc_base/checks.h"
namespace webrtc {
AsyncAudioProcessing::Factory::~Factory() = default;
AsyncAudioProcessing::Factory::Factory(AudioFrameProcessor& frame_processor,
TaskQueueFactory& task_queue_factory)
: frame_processor_(frame_processor),
task_queue_factory_(task_queue_factory) {}
std::unique_ptr<AsyncAudioProcessing>
AsyncAudioProcessing::Factory::CreateAsyncAudioProcessing(
AudioFrameProcessor::OnAudioFrameCallback on_frame_processed_callback) {
return std::make_unique<AsyncAudioProcessing>(
frame_processor_, task_queue_factory_,
std::move(on_frame_processed_callback));
}
AsyncAudioProcessing::~AsyncAudioProcessing() {
frame_processor_.SetSink(nullptr);
}
AsyncAudioProcessing::AsyncAudioProcessing(
AudioFrameProcessor& frame_processor,
TaskQueueFactory& task_queue_factory,
AudioFrameProcessor::OnAudioFrameCallback on_frame_processed_callback)
: on_frame_processed_callback_(std::move(on_frame_processed_callback)),
frame_processor_(frame_processor),
task_queue_(task_queue_factory.CreateTaskQueue(
"AsyncAudioProcessing",
TaskQueueFactory::Priority::NORMAL)) {
frame_processor_.SetSink([this](std::unique_ptr<AudioFrame> frame) {
task_queue_.PostTask([this, frame = std::move(frame)]() mutable {
on_frame_processed_callback_(std::move(frame));
});
});
}
void AsyncAudioProcessing::Process(std::unique_ptr<AudioFrame> frame) {
task_queue_.PostTask([this, frame = std::move(frame)]() mutable {
frame_processor_.Process(std::move(frame));
});
}
} // namespace webrtc

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2020 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_ASYNC_AUDIO_PROCESSING_ASYNC_AUDIO_PROCESSING_H_
#define MODULES_ASYNC_AUDIO_PROCESSING_ASYNC_AUDIO_PROCESSING_H_
#include <memory>
#include "api/audio/audio_frame_processor.h"
#include "rtc_base/ref_count.h"
#include "rtc_base/task_queue.h"
namespace webrtc {
class AudioFrame;
class TaskQueueFactory;
// Helper class taking care of interactions with AudioFrameProcessor
// in asynchronous manner. Offloads AudioFrameProcessor::Process calls
// to a dedicated task queue. Makes sure that it's always safe for
// AudioFrameProcessor to pass processed frames back to its sink.
class AsyncAudioProcessing final {
public:
// Helper class passing AudioFrameProcessor and TaskQueueFactory into
// AsyncAudioProcessing constructor.
class Factory : public rtc::RefCountInterface {
public:
Factory(const Factory&) = delete;
Factory& operator=(const Factory&) = delete;
~Factory();
Factory(AudioFrameProcessor& frame_processor,
TaskQueueFactory& task_queue_factory);
std::unique_ptr<AsyncAudioProcessing> CreateAsyncAudioProcessing(
AudioFrameProcessor::OnAudioFrameCallback on_frame_processed_callback);
private:
AudioFrameProcessor& frame_processor_;
TaskQueueFactory& task_queue_factory_;
};
AsyncAudioProcessing(const AsyncAudioProcessing&) = delete;
AsyncAudioProcessing& operator=(const AsyncAudioProcessing&) = delete;
~AsyncAudioProcessing();
// Creates AsyncAudioProcessing which will pass audio frames to
// `frame_processor` on `task_queue_` and reply with processed frames passed
// into `on_frame_processed_callback`, which is posted back onto
// `task_queue_`. `task_queue_` is created using the provided
// `task_queue_factory`.
AsyncAudioProcessing(
AudioFrameProcessor& frame_processor,
TaskQueueFactory& task_queue_factory,
AudioFrameProcessor::OnAudioFrameCallback on_frame_processed_callback);
// Accepts `frame` for asynchronous processing. Thread-safe.
void Process(std::unique_ptr<AudioFrame> frame);
private:
AudioFrameProcessor::OnAudioFrameCallback on_frame_processed_callback_;
AudioFrameProcessor& frame_processor_;
rtc::TaskQueue task_queue_;
};
} // namespace webrtc
#endif // MODULES_ASYNC_AUDIO_PROCESSING_ASYNC_AUDIO_PROCESSING_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
henrik.lundin@webrtc.org
kwiberg@webrtc.org
minyue@webrtc.org
ivoc@webrtc.org
jakobi@webrtc.org

View File

@ -18,7 +18,6 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/scoped_refptr.h"
#include "rtc_base/constructor_magic.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
@ -45,6 +44,9 @@ class AcmReceiveTestOldApi {
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
virtual ~AcmReceiveTestOldApi();
AcmReceiveTestOldApi(const AcmReceiveTestOldApi&) = delete;
AcmReceiveTestOldApi& operator=(const AcmReceiveTestOldApi&) = delete;
// Registers the codecs with default parameters from ACM.
void RegisterDefaultCodecs();
@ -67,12 +69,10 @@ class AcmReceiveTestOldApi {
AudioSink* audio_sink_;
int output_freq_hz_;
NumOutputChannels exptected_output_channels_;
RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
};
// This test toggles the output frequency every |toggle_period_ms|. The test
// starts with |output_freq_hz_1|. Except for the toggling, it does the same
// This test toggles the output frequency every `toggle_period_ms`. The test
// starts with `output_freq_hz_1`. Except for the toggling, it does the same
// thing as AcmReceiveTestOldApi.
class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi {
public:

View File

@ -66,14 +66,14 @@ AcmReceiver::~AcmReceiver() = default;
int AcmReceiver::SetMinimumDelay(int delay_ms) {
if (neteq_->SetMinimumDelay(delay_ms))
return 0;
RTC_LOG(LERROR) << "AcmReceiver::SetExtraDelay " << delay_ms;
RTC_LOG(LS_ERROR) << "AcmReceiver::SetExtraDelay " << delay_ms;
return -1;
}
int AcmReceiver::SetMaximumDelay(int delay_ms) {
if (neteq_->SetMaximumDelay(delay_ms))
return 0;
RTC_LOG(LERROR) << "AcmReceiver::SetExtraDelay " << delay_ms;
RTC_LOG(LS_ERROR) << "AcmReceiver::SetExtraDelay " << delay_ms;
return -1;
}
@ -131,12 +131,12 @@ int AcmReceiver::InsertPacket(const RTPHeader& rtp_header,
/*num_channels=*/format->num_channels,
/*sdp_format=*/std::move(format->sdp_format)};
}
} // |mutex_| is released.
} // `mutex_` is released.
if (neteq_->InsertPacket(rtp_header, incoming_payload) < 0) {
RTC_LOG(LERROR) << "AcmReceiver::InsertPacket "
<< static_cast<int>(rtp_header.payloadType)
<< " Failed to insert packet";
RTC_LOG(LS_ERROR) << "AcmReceiver::InsertPacket "
<< static_cast<int>(rtp_header.payloadType)
<< " Failed to insert packet";
return -1;
}
return 0;
@ -146,20 +146,22 @@ int AcmReceiver::GetAudio(int desired_freq_hz,
AudioFrame* audio_frame,
bool* muted) {
RTC_DCHECK(muted);
// Accessing members, take the lock.
MutexLock lock(&mutex_);
if (neteq_->GetAudio(audio_frame, muted) != NetEq::kOK) {
RTC_LOG(LERROR) << "AcmReceiver::GetAudio - NetEq Failed.";
int current_sample_rate_hz = 0;
if (neteq_->GetAudio(audio_frame, muted, &current_sample_rate_hz) !=
NetEq::kOK) {
RTC_LOG(LS_ERROR) << "AcmReceiver::GetAudio - NetEq Failed.";
return -1;
}
const int current_sample_rate_hz = neteq_->last_output_sample_rate_hz();
RTC_DCHECK_NE(current_sample_rate_hz, 0);
// Update if resampling is required.
const bool need_resampling =
(desired_freq_hz != -1) && (current_sample_rate_hz != desired_freq_hz);
// Accessing members, take the lock.
MutexLock lock(&mutex_);
if (need_resampling && !resampled_last_output_frame_) {
// Prime the resampler with the last frame.
int16_t temp_output[AudioFrame::kMaxDataSizeSamples];
@ -168,14 +170,14 @@ int AcmReceiver::GetAudio(int desired_freq_hz,
audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples,
temp_output);
if (samples_per_channel_int < 0) {
RTC_LOG(LERROR) << "AcmReceiver::GetAudio - "
"Resampling last_audio_buffer_ failed.";
RTC_LOG(LS_ERROR) << "AcmReceiver::GetAudio - "
"Resampling last_audio_buffer_ failed.";
return -1;
}
}
// TODO(henrik.lundin) Glitches in the output may appear if the output rate
// from NetEq changes. See WebRTC issue 3923.
// TODO(bugs.webrtc.org/3923) Glitches in the output may appear if the output
// rate from NetEq changes.
if (need_resampling) {
// TODO(yujo): handle this more efficiently for muted frames.
int samples_per_channel_int = resampler_.Resample10Msec(
@ -183,7 +185,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz,
audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples,
audio_frame->mutable_data());
if (samples_per_channel_int < 0) {
RTC_LOG(LERROR)
RTC_LOG(LS_ERROR)
<< "AcmReceiver::GetAudio - Resampling audio_buffer_ failed.";
return -1;
}
@ -199,7 +201,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz,
// We might end up here ONLY if codec is changed.
}
// Store current audio in |last_audio_buffer_| for next time.
// Store current audio in `last_audio_buffer_` for next time.
memcpy(last_audio_buffer_.get(), audio_frame->data(),
sizeof(int16_t) * audio_frame->samples_per_channel_ *
audio_frame->num_channels_);
@ -244,26 +246,37 @@ absl::optional<std::pair<int, SdpAudioFormat>> AcmReceiver::LastDecoder()
return std::make_pair(last_decoder_->payload_type, last_decoder_->sdp_format);
}
void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) const {
void AcmReceiver::GetNetworkStatistics(
NetworkStatistics* acm_stat,
bool get_and_clear_legacy_stats /* = true */) const {
NetEqNetworkStatistics neteq_stat;
// NetEq function always returns zero, so we don't check the return value.
neteq_->NetworkStatistics(&neteq_stat);
if (get_and_clear_legacy_stats) {
// NetEq function always returns zero, so we don't check the return value.
neteq_->NetworkStatistics(&neteq_stat);
acm_stat->currentExpandRate = neteq_stat.expand_rate;
acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate;
acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate;
acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate;
acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate;
acm_stat->currentSecondaryDiscardedRate =
neteq_stat.secondary_discarded_rate;
acm_stat->meanWaitingTimeMs = neteq_stat.mean_waiting_time_ms;
acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms;
} else {
neteq_stat = neteq_->CurrentNetworkStatistics();
acm_stat->currentExpandRate = 0;
acm_stat->currentSpeechExpandRate = 0;
acm_stat->currentPreemptiveRate = 0;
acm_stat->currentAccelerateRate = 0;
acm_stat->currentSecondaryDecodedRate = 0;
acm_stat->currentSecondaryDiscardedRate = 0;
acm_stat->meanWaitingTimeMs = -1;
acm_stat->maxWaitingTimeMs = 1;
}
acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms;
acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false;
acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate;
acm_stat->currentExpandRate = neteq_stat.expand_rate;
acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate;
acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate;
acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate;
acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate;
acm_stat->currentSecondaryDiscardedRate = neteq_stat.secondary_discarded_rate;
acm_stat->addedSamples = neteq_stat.added_zero_samples;
acm_stat->meanWaitingTimeMs = neteq_stat.mean_waiting_time_ms;
acm_stat->medianWaitingTimeMs = neteq_stat.median_waiting_time_ms;
acm_stat->minWaitingTimeMs = neteq_stat.min_waiting_time_ms;
acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms;
NetEqLifetimeStatistics neteq_lifetime_stat = neteq_->GetLifetimeStatistics();
acm_stat->totalSamplesReceived = neteq_lifetime_stat.total_samples_received;
@ -274,6 +287,8 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) const {
acm_stat->jitterBufferDelayMs = neteq_lifetime_stat.jitter_buffer_delay_ms;
acm_stat->jitterBufferTargetDelayMs =
neteq_lifetime_stat.jitter_buffer_target_delay_ms;
acm_stat->jitterBufferMinimumDelayMs =
neteq_lifetime_stat.jitter_buffer_minimum_delay_ms;
acm_stat->jitterBufferEmittedCount =
neteq_lifetime_stat.jitter_buffer_emitted_count;
acm_stat->delayedPacketOutageSamples =
@ -289,6 +304,7 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) const {
neteq_lifetime_stat.removed_samples_for_acceleration;
acm_stat->fecPacketsReceived = neteq_lifetime_stat.fec_packets_received;
acm_stat->fecPacketsDiscarded = neteq_lifetime_stat.fec_packets_discarded;
acm_stat->packetsDiscarded = neteq_lifetime_stat.packets_discarded;
NetEqOperationsAndState neteq_operations_and_state =
neteq_->GetOperationsAndState();

View File

@ -138,7 +138,8 @@ class AcmReceiver {
// Output:
// - statistics : The current network statistics.
//
void GetNetworkStatistics(NetworkStatistics* statistics) const;
void GetNetworkStatistics(NetworkStatistics* statistics,
bool get_and_clear_legacy_stats = true) const;
//
// Flushes the NetEq packet and speech buffers.
@ -176,10 +177,10 @@ class AcmReceiver {
// enabled then the maximum NACK list size is modified accordingly.
//
// If the sequence number of last received packet is N, the sequence numbers
// of NACK list are in the range of [N - |max_nack_list_size|, N).
// of NACK list are in the range of [N - `max_nack_list_size`, N).
//
// |max_nack_list_size| should be positive (none zero) and less than or
// equal to |Nack::kNackListSizeLimit|. Otherwise, No change is applied and -1
// `max_nack_list_size` should be positive (none zero) and less than or
// equal to `Nack::kNackListSizeLimit`. Otherwise, No change is applied and -1
// is returned. 0 is returned at success.
//
int EnableNack(size_t max_nack_list_size);
@ -188,12 +189,12 @@ class AcmReceiver {
void DisableNack();
//
// Get a list of packets to be retransmitted. |round_trip_time_ms| is an
// Get a list of packets to be retransmitted. `round_trip_time_ms` is an
// estimate of the round-trip-time (in milliseconds). Missing packets which
// will be playout in a shorter time than the round-trip-time (with respect
// to the time this API is called) will not be included in the list.
//
// Negative |round_trip_time_ms| results is an error message and empty list
// Negative `round_trip_time_ms` results is an error message and empty list
// is returned.
//
std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const;

View File

@ -13,6 +13,7 @@
#include <algorithm> // std::min
#include <memory>
#include "absl/types/optional.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
@ -64,12 +65,14 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
const SdpAudioFormat& format,
const std::map<int, int> cng_payload_types = {}) {
// Create the speech encoder.
AudioCodecInfo info = encoder_factory_->QueryAudioEncoder(format).value();
absl::optional<AudioCodecInfo> info =
encoder_factory_->QueryAudioEncoder(format);
RTC_CHECK(info.has_value());
std::unique_ptr<AudioEncoder> enc =
encoder_factory_->MakeAudioEncoder(payload_type, format, absl::nullopt);
// If we have a compatible CN specification, stack a CNG on top.
auto it = cng_payload_types.find(info.sample_rate_hz);
auto it = cng_payload_types.find(info->sample_rate_hz);
if (it != cng_payload_types.end()) {
AudioEncoderCngConfig config;
config.speech_encoder = std::move(enc);
@ -81,7 +84,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
// Actually start using the new encoder.
acm_->SetEncoder(std::move(enc));
return info;
return *info;
}
int InsertOnePacketOfSilence(const AudioCodecInfo& info) {
@ -119,7 +122,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
rtp_header_,
rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
if (ret_val < 0) {
assert(false);
RTC_DCHECK_NOTREACHED();
return -1;
}
rtp_header_.sequenceNumber++;
@ -148,8 +151,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
#define MAYBE_SampleRate SampleRate
#endif
TEST_F(AcmReceiverTestOldApi, MAYBE_SampleRate) {
const std::map<int, SdpAudioFormat> codecs = {{0, {"ISAC", 16000, 1}},
{1, {"ISAC", 32000, 1}}};
const std::map<int, SdpAudioFormat> codecs = {{0, {"OPUS", 48000, 2}}};
receiver_->SetCodecs(codecs);
constexpr int kOutSampleRateHz = 8000; // Different than codec sample rate.
@ -232,15 +234,6 @@ TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFramePCMU) {
RunVerifyAudioFrame({"PCMU", 8000, 1});
}
#if defined(WEBRTC_ANDROID)
#define MAYBE_VerifyAudioFrameISAC DISABLED_VerifyAudioFrameISAC
#else
#define MAYBE_VerifyAudioFrameISAC VerifyAudioFrameISAC
#endif
TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFrameISAC) {
RunVerifyAudioFrame({"ISAC", 16000, 1});
}
#if defined(WEBRTC_ANDROID)
#define MAYBE_VerifyAudioFrameOpus DISABLED_VerifyAudioFrameOpus
#else
@ -310,12 +303,10 @@ TEST_F(AcmReceiverTestPostDecodeVadPassiveOldApi, MAYBE_PostdecodingVad) {
#else
#define MAYBE_LastAudioCodec LastAudioCodec
#endif
#if defined(WEBRTC_CODEC_ISAC)
#if defined(WEBRTC_CODEC_OPUS)
TEST_F(AcmReceiverTestOldApi, MAYBE_LastAudioCodec) {
const std::map<int, SdpAudioFormat> codecs = {{0, {"ISAC", 16000, 1}},
{1, {"PCMA", 8000, 1}},
{2, {"ISAC", 32000, 1}},
{3, {"L16", 32000, 1}}};
const std::map<int, SdpAudioFormat> codecs = {
{0, {"PCMU", 8000, 1}}, {1, {"PCMA", 8000, 1}}, {2, {"L16", 32000, 1}}};
const std::map<int, int> cng_payload_types = {
{8000, 100}, {16000, 101}, {32000, 102}};
{

View File

@ -10,7 +10,6 @@
#include "modules/audio_coding/acm2/acm_resampler.h"
#include <assert.h>
#include <string.h>
#include "rtc_base/logging.h"
@ -31,7 +30,7 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
size_t in_length = in_freq_hz * num_audio_channels / 100;
if (in_freq_hz == out_freq_hz) {
if (out_capacity_samples < in_length) {
assert(false);
RTC_DCHECK_NOTREACHED();
return -1;
}
memcpy(out_audio, in_audio, in_length * sizeof(int16_t));

View File

@ -10,11 +10,11 @@
#include "modules/audio_coding/acm2/acm_send_test.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "api/audio_codecs/audio_encoder.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
@ -51,14 +51,14 @@ AcmSendTestOldApi::AcmSendTestOldApi(InputAudioFile* audio_source,
input_frame_.sample_rate_hz_ = source_rate_hz_;
input_frame_.num_channels_ = 1;
input_frame_.samples_per_channel_ = input_block_size_samples_;
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
AudioFrame::kMaxDataSizeSamples);
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples);
acm_->RegisterTransportCallback(this);
}
AcmSendTestOldApi::~AcmSendTestOldApi() = default;
bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
bool AcmSendTestOldApi::RegisterCodec(absl::string_view payload_name,
int clockrate_hz,
int num_channels,
int payload_type,
@ -81,8 +81,8 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
codec_registered_ = true;
input_frame_.num_channels_ = num_channels;
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
AudioFrame::kMaxDataSizeSamples);
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples);
return codec_registered_;
}
@ -90,13 +90,13 @@ void AcmSendTestOldApi::RegisterExternalCodec(
std::unique_ptr<AudioEncoder> external_speech_encoder) {
input_frame_.num_channels_ = external_speech_encoder->NumChannels();
acm_->SetEncoder(std::move(external_speech_encoder));
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
AudioFrame::kMaxDataSizeSamples);
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
AudioFrame::kMaxDataSizeSamples);
codec_registered_ = true;
}
std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
assert(codec_registered_);
RTC_DCHECK(codec_registered_);
if (filter_.test(static_cast<size_t>(payload_type_))) {
// This payload type should be filtered out. Since the payload type is the
// same throughout the whole test run, no packet at all will be delivered.
@ -133,15 +133,16 @@ int32_t AcmSendTestOldApi::SendData(AudioFrameType frame_type,
payload_type_ = payload_type;
timestamp_ = timestamp;
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
assert(last_payload_vec_.size() == payload_len_bytes);
RTC_DCHECK_EQ(last_payload_vec_.size(), payload_len_bytes);
data_to_send_ = true;
return 0;
}
std::unique_ptr<Packet> AcmSendTestOldApi::CreatePacket() {
const size_t kRtpHeaderSize = 12;
size_t allocated_bytes = last_payload_vec_.size() + kRtpHeaderSize;
uint8_t* packet_memory = new uint8_t[allocated_bytes];
rtc::CopyOnWriteBuffer packet_buffer(last_payload_vec_.size() +
kRtpHeaderSize);
uint8_t* packet_memory = packet_buffer.MutableData();
// Populate the header bytes.
packet_memory[0] = 0x80;
packet_memory[1] = static_cast<uint8_t>(payload_type_);
@ -162,8 +163,8 @@ std::unique_ptr<Packet> AcmSendTestOldApi::CreatePacket() {
// Copy the payload data.
memcpy(packet_memory + kRtpHeaderSize, &last_payload_vec_[0],
last_payload_vec_.size());
std::unique_ptr<Packet> packet(
new Packet(packet_memory, allocated_bytes, clock_.TimeInMilliseconds()));
auto packet = std::make_unique<Packet>(std::move(packet_buffer),
clock_.TimeInMilliseconds());
RTC_DCHECK(packet);
RTC_DCHECK(packet->valid_header());
return packet;

View File

@ -14,10 +14,10 @@
#include <memory>
#include <vector>
#include "absl/strings/string_view.h"
#include "api/audio/audio_frame.h"
#include "modules/audio_coding/include/audio_coding_module.h"
#include "modules/audio_coding/neteq/tools/packet_source.h"
#include "rtc_base/constructor_magic.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
@ -35,8 +35,11 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
int test_duration_ms);
~AcmSendTestOldApi() override;
AcmSendTestOldApi(const AcmSendTestOldApi&) = delete;
AcmSendTestOldApi& operator=(const AcmSendTestOldApi&) = delete;
// Registers the send codec. Returns true on success, false otherwise.
bool RegisterCodec(const char* payload_name,
bool RegisterCodec(absl::string_view payload_name,
int sampling_freq_hz,
int channels,
int payload_type,
@ -81,8 +84,6 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
uint16_t sequence_number_;
std::vector<uint8_t> last_payload_vec_;
bool data_to_send_;
RTC_DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi);
};
} // namespace test

View File

@ -10,11 +10,11 @@
#include "modules/audio_coding/include/audio_coding_module.h"
#include <assert.h>
#include <algorithm>
#include <cstdint>
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "api/array_view.h"
#include "modules/audio_coding/acm2/acm_receiver.h"
#include "modules/audio_coding/acm2/acm_remixing.h"
@ -93,6 +93,8 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
ANAStats GetANAStats() const override;
int GetTargetBitrate() const override;
private:
struct InputData {
InputData() : buffer(kInitialInputDataBufferSize) {}
@ -111,7 +113,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
// the value has changed since the last time (and always for the first call).
class ChangeLogger {
public:
explicit ChangeLogger(const std::string& histogram_name)
explicit ChangeLogger(absl::string_view histogram_name)
: histogram_name_(histogram_name) {}
// Logs the new value if it is different from the last logged value, or if
// this is the first call.
@ -126,7 +128,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data)
RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
// TODO(bugs.webrtc.org/10739): change |absolute_capture_timestamp_ms| to
// TODO(bugs.webrtc.org/10739): change `absolute_capture_timestamp_ms` to
// int64_t when it always receives a valid value.
int Encode(const InputData& input_data,
absl::optional<int64_t> absolute_capture_timestamp_ms)
@ -134,7 +136,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
int InitializeReceiverSafe() RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
bool HaveValidEncoder(const char* caller_name) const
bool HaveValidEncoder(absl::string_view caller_name) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
// Preprocessing of input audio, including resampling and down-mixing if
@ -142,8 +144,8 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
//
// in_frame: input audio-frame
// ptr_out: pointer to output audio_frame. If no preprocessing is required
// |ptr_out| will be pointing to |in_frame|, otherwise pointing to
// |preprocess_frame_|.
// `ptr_out` will be pointing to `in_frame`, otherwise pointing to
// `preprocess_frame_`.
//
// Return value:
// -1: if encountering an error.
@ -153,7 +155,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
// Change required states after starting to receive the codec corresponding
// to |index|.
// to `index`.
int UpdateUponReceivingCodec(int index);
mutable Mutex acm_mutex_;
@ -230,7 +232,7 @@ int32_t AudioCodingModuleImpl::Encode(
const InputData& input_data,
absl::optional<int64_t> absolute_capture_timestamp_ms) {
// TODO(bugs.webrtc.org/10739): add dcheck that
// |audio_frame.absolute_capture_timestamp_ms()| always has a value.
// `audio_frame.absolute_capture_timestamp_ms()` always has a value.
AudioEncoder::EncodedInfo encoded_info;
uint8_t previous_pltype;
@ -334,7 +336,7 @@ int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
MutexLock lock(&acm_mutex_);
int r = Add10MsDataInternal(audio_frame, &input_data_);
// TODO(bugs.webrtc.org/10739): add dcheck that
// |audio_frame.absolute_capture_timestamp_ms()| always has a value.
// `audio_frame.absolute_capture_timestamp_ms()` always has a value.
return r < 0
? r
: Encode(input_data_, audio_frame.absolute_capture_timestamp_ms());
@ -343,13 +345,13 @@ int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
InputData* input_data) {
if (audio_frame.samples_per_channel_ == 0) {
assert(false);
RTC_DCHECK_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero";
return -1;
}
if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) {
assert(false);
RTC_DCHECK_NOTREACHED();
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid";
return -1;
}
@ -398,7 +400,7 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
// output data if needed.
ReMixFrame(*ptr_frame, current_num_channels, &input_data->buffer);
// For pushing data to primary, point the |ptr_audio| to correct buffer.
// For pushing data to primary, point the `ptr_audio` to correct buffer.
input_data->audio = input_data->buffer.data();
RTC_DCHECK_GE(input_data->buffer.size(),
input_data->length_per_channel * input_data->audio_channel);
@ -415,7 +417,7 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
// encoder is mono and input is stereo. In case of dual-streaming, both
// encoders has to be mono for down-mix to take place.
// |*ptr_out| will point to the pre-processed audio-frame. If no pre-processing
// is required, |*ptr_out| points to |in_frame|.
// is required, |*ptr_out| points to `in_frame`.
// TODO(yujo): Make this more efficient for muted frames.
int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
const AudioFrame** ptr_out) {
@ -588,7 +590,8 @@ int AudioCodingModuleImpl::GetNetworkStatistics(NetworkStatistics* statistics) {
return 0;
}
bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
bool AudioCodingModuleImpl::HaveValidEncoder(
absl::string_view caller_name) const {
if (!encoder_stack_) {
RTC_LOG(LS_ERROR) << caller_name << " failed: No send codec is registered.";
return false;
@ -604,6 +607,14 @@ ANAStats AudioCodingModuleImpl::GetANAStats() const {
return ANAStats();
}
int AudioCodingModuleImpl::GetTargetBitrate() const {
MutexLock lock(&acm_mutex_);
if (!encoder_stack_) {
return -1;
}
return encoder_stack_->GetTargetBitrate();
}
} // namespace
AudioCodingModule::Config::Config(

File diff suppressed because it is too large Load Diff

View File

@ -44,8 +44,8 @@ void CallStatistics::DecodedByNetEq(AudioFrame::SpeechType speech_type,
break;
}
case AudioFrame::kUndefined: {
// If the audio is decoded by NetEq, |kUndefined| is not an option.
RTC_NOTREACHED();
// If the audio is decoded by NetEq, `kUndefined` is not an option.
RTC_DCHECK_NOTREACHED();
}
}
}

View File

@ -36,8 +36,8 @@ class CallStatistics {
CallStatistics() {}
~CallStatistics() {}
// Call this method to indicate that NetEq engaged in decoding. |speech_type|
// is the audio-type according to NetEq, and |muted| indicates if the decoded
// Call this method to indicate that NetEq engaged in decoding. `speech_type`
// is the audio-type according to NetEq, and `muted` indicates if the decoded
// frame was produced in muted state.
void DecodedByNetEq(AudioFrame::SpeechType speech_type, bool muted);

View File

@ -20,11 +20,6 @@ if (rtc_opus_support_120ms_ptime) {
} else {
audio_codec_defines += [ "WEBRTC_OPUS_SUPPORT_120MS_PTIME=0" ]
}
if (current_cpu == "arm") {
audio_codec_defines += [ "WEBRTC_CODEC_ISACFX" ]
} else {
audio_codec_defines += [ "WEBRTC_CODEC_ISAC" ]
}
audio_coding_defines = audio_codec_defines
neteq_defines = audio_codec_defines

View File

@ -21,7 +21,6 @@
#include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -44,6 +43,9 @@ class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor {
~AudioNetworkAdaptorImpl() override;
AudioNetworkAdaptorImpl(const AudioNetworkAdaptorImpl&) = delete;
AudioNetworkAdaptorImpl& operator=(const AudioNetworkAdaptorImpl&) = delete;
void SetUplinkBandwidth(int uplink_bandwidth_bps) override;
void SetUplinkPacketLossFraction(float uplink_packet_loss_fraction) override;
@ -80,8 +82,6 @@ class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor {
absl::optional<AudioEncoderRuntimeConfig> prev_config_;
ANAStats stats_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioNetworkAdaptorImpl);
};
} // namespace webrtc

View File

@ -50,14 +50,9 @@ void BitrateController::UpdateNetworkMetrics(
}
void BitrateController::MakeDecision(AudioEncoderRuntimeConfig* config) {
// Decision on |bitrate_bps| should not have been made.
// Decision on `bitrate_bps` should not have been made.
RTC_DCHECK(!config->bitrate_bps);
if (target_audio_bitrate_bps_ && overhead_bytes_per_packet_) {
// Current implementation of BitrateController can only work when
// |metrics.target_audio_bitrate_bps| includes overhead is enabled. This is
// currently governed by the following field trial.
RTC_DCHECK(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead"));
if (config->frame_length_ms)
frame_length_ms_ = *config->frame_length_ms;
int offset = config->last_fl_change_increase

View File

@ -16,7 +16,6 @@
#include "absl/types/optional.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
namespace audio_network_adaptor {
@ -39,6 +38,9 @@ class BitrateController final : public Controller {
~BitrateController() override;
BitrateController(const BitrateController&) = delete;
BitrateController& operator=(const BitrateController&) = delete;
void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
@ -49,7 +51,6 @@ class BitrateController final : public Controller {
int frame_length_ms_;
absl::optional<int> target_audio_bitrate_bps_;
absl::optional<size_t> overhead_bytes_per_packet_;
RTC_DISALLOW_COPY_AND_ASSIGN(BitrateController);
};
} // namespace audio_network_adaptor

View File

@ -74,8 +74,6 @@ TEST(AnaBitrateControllerTest, OutputInitValueWhenOverheadUnknown) {
}
TEST(AnaBitrateControllerTest, ChangeBitrateOnTargetBitrateChanged) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
constexpr int kInitialFrameLengthMs = 20;
BitrateController controller(
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
@ -85,7 +83,7 @@ TEST(AnaBitrateControllerTest, ChangeBitrateOnTargetBitrateChanged) {
1000 /
kInitialFrameLengthMs;
// Frame length unchanged, bitrate changes in accordance with
// |metrics.target_audio_bitrate_bps| and |metrics.overhead_bytes_per_packet|.
// `metrics.target_audio_bitrate_bps` and `metrics.overhead_bytes_per_packet`.
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
CheckDecision(&controller, kInitialFrameLengthMs, kBitrateBps);
}
@ -98,8 +96,6 @@ TEST(AnaBitrateControllerTest, UpdateMultipleNetworkMetricsAtOnce) {
// BitrateController::UpdateNetworkMetrics(...) can handle multiple
// network updates at once. This is, however, not a common use case in current
// audio_network_adaptor_impl.cc.
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
constexpr int kInitialFrameLengthMs = 20;
BitrateController controller(
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
@ -116,8 +112,6 @@ TEST(AnaBitrateControllerTest, UpdateMultipleNetworkMetricsAtOnce) {
}
TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
constexpr int kInitialFrameLengthMs = 20;
BitrateController controller(
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
@ -131,8 +125,6 @@ TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) {
}
TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
constexpr int kInitialFrameLengthMs = 20;
BitrateController controller(
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
@ -155,8 +147,6 @@ TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) {
}
TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
constexpr int kInitialFrameLengthMs = 60;
BitrateController controller(
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
@ -179,8 +169,6 @@ TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) {
}
TEST(AnaBitrateControllerTest, BitrateNeverBecomesNegative) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
BitrateController controller(BitrateController::Config(32000, 20, 0, 0));
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kFrameLengthMs = 60;
@ -192,8 +180,6 @@ TEST(AnaBitrateControllerTest, BitrateNeverBecomesNegative) {
}
TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) {
test::ScopedFieldTrials override_field_trials(
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
BitrateController controller(BitrateController::Config(32000, 20, 0, 0));
// Start from an arbitrary overall bitrate.

View File

@ -28,7 +28,7 @@ ChannelController::Config::Config(size_t num_encoder_channels,
ChannelController::ChannelController(const Config& config)
: config_(config), channels_to_encode_(config_.intial_channels_to_encode) {
RTC_DCHECK_GT(config_.intial_channels_to_encode, 0lu);
// Currently, we require |intial_channels_to_encode| to be <= 2.
// Currently, we require `intial_channels_to_encode` to be <= 2.
RTC_DCHECK_LE(config_.intial_channels_to_encode, 2lu);
RTC_DCHECK_GE(config_.num_encoder_channels,
config_.intial_channels_to_encode);
@ -43,7 +43,7 @@ void ChannelController::UpdateNetworkMetrics(
}
void ChannelController::MakeDecision(AudioEncoderRuntimeConfig* config) {
// Decision on |num_channels| should not have been made.
// Decision on `num_channels` should not have been made.
RTC_DCHECK(!config->num_channels);
if (uplink_bandwidth_bps_) {

View File

@ -16,7 +16,6 @@
#include "absl/types/optional.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -41,6 +40,9 @@ class ChannelController final : public Controller {
~ChannelController() override;
ChannelController(const ChannelController&) = delete;
ChannelController& operator=(const ChannelController&) = delete;
void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
@ -49,7 +51,6 @@ class ChannelController final : public Controller {
const Config config_;
size_t channels_to_encode_;
absl::optional<int> uplink_bandwidth_bps_;
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelController);
};
} // namespace webrtc

View File

@ -5,6 +5,7 @@ package webrtc.audio_network_adaptor.config;
option optimize_for = LITE_RUNTIME;
option java_package = "org.webrtc.AudioNetworkAdaptor";
option java_outer_classname = "Config";
option objc_class_prefix = "WANA";
message FecController {
message Threshold {
@ -23,8 +24,8 @@ message FecController {
optional float high_bandwidth_packet_loss = 4;
}
// |fec_enabling_threshold| defines a curve, above which FEC should be
// enabled. |fec_disabling_threshold| defines a curve, under which FEC
// `fec_enabling_threshold` defines a curve, above which FEC should be
// enabled. `fec_disabling_threshold` defines a curve, under which FEC
// should be disabled. See below
//
// packet-loss ^ | |
@ -36,7 +37,7 @@ message FecController {
optional Threshold fec_enabling_threshold = 1;
optional Threshold fec_disabling_threshold = 2;
// |time_constant_ms| is the time constant for an exponential filter, which
// `time_constant_ms` is the time constant for an exponential filter, which
// is used for smoothing the packet loss fraction.
optional int32 time_constant_ms = 3;
}
@ -62,8 +63,8 @@ message FecControllerRplrBased {
optional float high_bandwidth_recoverable_packet_loss = 4;
}
// |fec_enabling_threshold| defines a curve, above which FEC should be
// enabled. |fec_disabling_threshold| defines a curve, under which FEC
// `fec_enabling_threshold` defines a curve, above which FEC should be
// enabled. `fec_disabling_threshold` defines a curve, under which FEC
// should be disabled. See below
//
// packet-loss ^ | |
@ -122,7 +123,7 @@ message FrameLengthControllerV2 {
// FrameLengthControllerV2 chooses the frame length by taking the target
// bitrate and subtracting the overhead bitrate to obtain the remaining
// bitrate for the payload. The chosen frame length is the shortest possible
// where the payload bitrate is more than |min_payload_bitrate_bps|.
// where the payload bitrate is more than `min_payload_bitrate_bps`.
optional int32 min_payload_bitrate_bps = 1;
// If true, uses the stable target bitrate to decide the frame length. This
@ -158,18 +159,18 @@ message BitrateController {
message Controller {
message ScoringPoint {
// |ScoringPoint| is a subspace of network condition. It is used for
// `ScoringPoint` is a subspace of network condition. It is used for
// comparing the significance of controllers.
optional int32 uplink_bandwidth_bps = 1;
optional float uplink_packet_loss_fraction = 2;
}
// The distance from |scoring_point| to a given network condition defines
// The distance from `scoring_point` to a given network condition defines
// the significance of this controller with respect that network condition.
// Shorter distance means higher significance. The significances of
// controllers determine their order in the processing pipeline. Controllers
// without |scoring_point| follow their default order in
// |ControllerManager::controllers|.
// without `scoring_point` follow their default order in
// `ControllerManager::controllers`.
optional ScoringPoint scoring_point = 1;
oneof controller {

View File

@ -15,6 +15,7 @@
#include <string>
#include <utility>
#include "absl/strings/string_view.h"
#include "modules/audio_coding/audio_network_adaptor/bitrate_controller.h"
#include "modules/audio_coding/audio_network_adaptor/channel_controller.h"
#include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h"
@ -219,7 +220,7 @@ ControllerManagerImpl::Config::Config(int min_reordering_time_ms,
ControllerManagerImpl::Config::~Config() = default;
std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
const std::string& config_string,
absl::string_view config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
@ -235,7 +236,7 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
}
std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
const std::string& config_string,
absl::string_view config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
@ -247,7 +248,8 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
DebugDumpWriter* debug_dump_writer) {
#if WEBRTC_ENABLE_PROTOBUF
audio_network_adaptor::config::ControllerManager controller_manager_config;
RTC_CHECK(controller_manager_config.ParseFromString(config_string));
RTC_CHECK(
controller_manager_config.ParseFromString(std::string(config_string)));
if (debug_dump_writer)
debug_dump_writer->DumpControllerManagerConfig(controller_manager_config,
rtc::TimeMillis());
@ -265,7 +267,7 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
break;
case audio_network_adaptor::config::Controller::kFecControllerRplrBased:
// FecControllerRplrBased has been removed and can't be used anymore.
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
continue;
case audio_network_adaptor::config::Controller::kFrameLengthController:
controller = CreateFrameLengthController(
@ -293,7 +295,7 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
encoder_frame_lengths_ms);
break;
default:
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
}
if (controller_config.has_scoring_point()) {
auto& scoring_point = controller_config.scoring_point();
@ -321,7 +323,7 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
}
#else
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return nullptr;
#endif // WEBRTC_ENABLE_PROTOBUF
}
@ -373,14 +375,14 @@ std::vector<Controller*> ControllerManagerImpl::GetSortedControllers(
config_.min_reordering_squared_distance)
return sorted_controllers_;
// Sort controllers according to the distances of |scoring_point| to the
// Sort controllers according to the distances of `scoring_point` to the
// scoring points of controllers.
//
// A controller that does not associate with any scoring point
// are treated as if
// 1) they are less important than any controller that has a scoring point,
// 2) they are equally important to any controller that has no scoring point,
// and their relative order will follow |default_sorted_controllers_|.
// and their relative order will follow `default_sorted_controllers_`.
std::vector<Controller*> sorted_controllers(default_sorted_controllers_);
std::stable_sort(
sorted_controllers.begin(), sorted_controllers.end(),
@ -430,7 +432,7 @@ float NormalizeUplinkBandwidth(int uplink_bandwidth_bps) {
}
float NormalizePacketLossFraction(float uplink_packet_loss_fraction) {
// |uplink_packet_loss_fraction| is seldom larger than 0.3, so we scale it up
// `uplink_packet_loss_fraction` is seldom larger than 0.3, so we scale it up
// by 3.3333f.
return std::min(uplink_packet_loss_fraction * 3.3333f, 1.0f);
}

View File

@ -16,8 +16,8 @@
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -47,7 +47,7 @@ class ControllerManagerImpl final : public ControllerManager {
};
static std::unique_ptr<ControllerManager> Create(
const std::string& config_string,
absl::string_view config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
@ -58,7 +58,7 @@ class ControllerManagerImpl final : public ControllerManager {
bool initial_dtx_enabled);
static std::unique_ptr<ControllerManager> Create(
const std::string& config_string,
absl::string_view config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
@ -80,6 +80,9 @@ class ControllerManagerImpl final : public ControllerManager {
~ControllerManagerImpl() override;
ControllerManagerImpl(const ControllerManagerImpl&) = delete;
ControllerManagerImpl& operator=(const ControllerManagerImpl&) = delete;
// Sort controllers based on their significance.
std::vector<Controller*> GetSortedControllers(
const Controller::NetworkMetrics& metrics) override;
@ -111,11 +114,9 @@ class ControllerManagerImpl final : public ControllerManager {
std::vector<Controller*> sorted_controllers_;
// |scoring_points_| saves the scoring points of various
// `scoring_points_` saves the scoring points of various
// controllers.
std::map<const Controller*, ScoringPoint> controller_scoring_points_;
RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl);
};
} // namespace webrtc

View File

@ -13,6 +13,7 @@
#include <string>
#include <utility>
#include "absl/strings/string_view.h"
#include "modules/audio_coding/audio_network_adaptor/mock/mock_controller.h"
#include "modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump_writer.h"
#include "rtc_base/fake_clock.h"
@ -43,7 +44,7 @@ constexpr int kMinReorderingTimeMs = 200;
constexpr int kFactor = 100;
constexpr float kMinReorderingSquareDistance = 1.0f / kFactor / kFactor;
// |kMinUplinkBandwidthBps| and |kMaxUplinkBandwidthBps| are copied from
// `kMinUplinkBandwidthBps` and `kMaxUplinkBandwidthBps` are copied from
// controller_manager.cc
constexpr int kMinUplinkBandwidthBps = 0;
constexpr int kMaxUplinkBandwidthBps = 120000;
@ -82,7 +83,7 @@ ControllerManagerStates CreateControllerManager() {
return states;
}
// |expected_order| contains the expected indices of all controllers in the
// `expected_order` contains the expected indices of all controllers in the
// vector of controllers returned by GetSortedControllers(). A negative index
// means that we do not care about its exact place, but we do check that it
// exists in the vector.
@ -112,8 +113,8 @@ void CheckControllersOrder(
TEST(ControllerManagerTest, GetControllersReturnAllControllers) {
auto states = CreateControllerManager();
auto check = states.controller_manager->GetControllers();
// Verify that controllers in |check| are one-to-one mapped to those in
// |mock_controllers_|.
// Verify that controllers in `check` are one-to-one mapped to those in
// `mock_controllers_`.
EXPECT_EQ(states.mock_controllers.size(), check.size());
for (auto& controller : check)
EXPECT_NE(states.mock_controllers.end(),
@ -123,7 +124,7 @@ TEST(ControllerManagerTest, GetControllersReturnAllControllers) {
TEST(ControllerManagerTest, ControllersInDefaultOrderOnEmptyNetworkMetrics) {
auto states = CreateControllerManager();
// |network_metrics| are empty, and the controllers are supposed to follow the
// `network_metrics` are empty, and the controllers are supposed to follow the
// default order.
CheckControllersOrder(&states, absl::nullopt, absl::nullopt, {0, 1, 2, 3});
}
@ -276,7 +277,7 @@ constexpr int kInitialFrameLengthMs = 60;
constexpr int kMinBitrateBps = 6000;
ControllerManagerStates CreateControllerManager(
const std::string& config_string) {
absl::string_view config_string) {
ControllerManagerStates states;
constexpr size_t kNumEncoderChannels = 2;
const std::vector<int> encoder_frame_lengths_ms = {20, 60};
@ -304,7 +305,7 @@ void CheckControllersOrder(const std::vector<Controller*>& controllers,
for (size_t i = 0; i < controllers.size(); ++i) {
AudioEncoderRuntimeConfig encoder_config;
// We check the order of |controllers| by judging their decisions.
// We check the order of `controllers` by judging their decisions.
controllers[i]->MakeDecision(&encoder_config);
// Since controllers are not provided with network metrics, they give the

View File

@ -21,7 +21,7 @@ message EncoderRuntimeConfig {
optional bool enable_fec = 4;
optional bool enable_dtx = 5;
// Some encoders can encode fewer channels than the actual input to make
// better use of the bandwidth. |num_channels| sets the number of channels
// better use of the bandwidth. `num_channels` sets the number of channels
// to encode.
optional uint32 num_channels = 6;
}

View File

@ -76,7 +76,7 @@ DebugDumpWriterImpl::DebugDumpWriterImpl(FILE* file_handle) {
dump_file_ = FileWrapper(file_handle);
RTC_CHECK(dump_file_.is_open());
#else
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
#endif
}

View File

@ -15,7 +15,6 @@
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/ignore_wundef.h"
#include "rtc_base/system/file_wrapper.h"
#if WEBRTC_ENABLE_PROTOBUF

View File

@ -33,7 +33,7 @@ void DtxController::UpdateNetworkMetrics(
}
void DtxController::MakeDecision(AudioEncoderRuntimeConfig* config) {
// Decision on |enable_dtx| should not have been made.
// Decision on `enable_dtx` should not have been made.
RTC_DCHECK(!config->enable_dtx);
if (uplink_bandwidth_bps_) {

View File

@ -14,7 +14,6 @@
#include "absl/types/optional.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -35,6 +34,9 @@ class DtxController final : public Controller {
~DtxController() override;
DtxController(const DtxController&) = delete;
DtxController& operator=(const DtxController&) = delete;
void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
@ -43,7 +45,6 @@ class DtxController final : public Controller {
const Config config_;
bool dtx_enabled_;
absl::optional<int> uplink_bandwidth_bps_;
RTC_DISALLOW_COPY_AND_ASSIGN(DtxController);
};
} // namespace webrtc

View File

@ -12,7 +12,6 @@
#define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_EVENT_LOG_WRITER_H_
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
class RtcEventLog;
@ -24,6 +23,10 @@ class EventLogWriter final {
float min_bitrate_change_fraction,
float min_packet_loss_change_fraction);
~EventLogWriter();
EventLogWriter(const EventLogWriter&) = delete;
EventLogWriter& operator=(const EventLogWriter&) = delete;
void MaybeLogEncoderConfig(const AudioEncoderRuntimeConfig& config);
private:
@ -34,7 +37,6 @@ class EventLogWriter final {
const float min_bitrate_change_fraction_;
const float min_packet_loss_change_fraction_;
AudioEncoderRuntimeConfig last_logged_config_;
RTC_DISALLOW_COPY_AND_ASSIGN(EventLogWriter);
};
} // namespace webrtc

View File

@ -26,7 +26,7 @@ class NullSmoothingFilter final : public SmoothingFilter {
absl::optional<float> GetAverage() override { return last_sample_; }
bool SetTimeConstantMs(int time_constant_ms) override {
RTC_NOTREACHED();
RTC_DCHECK_NOTREACHED();
return false;
}

View File

@ -18,15 +18,14 @@
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
class FecControllerPlrBased final : public Controller {
public:
struct Config {
// |fec_enabling_threshold| defines a curve, above which FEC should be
// enabled. |fec_disabling_threshold| defines a curve, under which FEC
// `fec_enabling_threshold` defines a curve, above which FEC should be
// enabled. `fec_disabling_threshold` defines a curve, under which FEC
// should be disabled. See below
//
// packet-loss ^ | |
@ -53,6 +52,9 @@ class FecControllerPlrBased final : public Controller {
~FecControllerPlrBased() override;
FecControllerPlrBased(const FecControllerPlrBased&) = delete;
FecControllerPlrBased& operator=(const FecControllerPlrBased&) = delete;
void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
@ -65,8 +67,6 @@ class FecControllerPlrBased final : public Controller {
bool fec_enabled_;
absl::optional<int> uplink_bandwidth_bps_;
const std::unique_ptr<SmoothingFilter> packet_loss_smoother_;
RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerPlrBased);
};
} // namespace webrtc

View File

@ -100,9 +100,9 @@ void UpdateNetworkMetrics(FecControllerPlrBasedTestStates* states,
}
}
// Checks that the FEC decision and |uplink_packet_loss_fraction| given by
// |states->controller->MakeDecision| matches |expected_enable_fec| and
// |expected_uplink_packet_loss_fraction|, respectively.
// Checks that the FEC decision and `uplink_packet_loss_fraction` given by
// `states->controller->MakeDecision` matches `expected_enable_fec` and
// `expected_uplink_packet_loss_fraction`, respectively.
void CheckDecision(FecControllerPlrBasedTestStates* states,
bool expected_enable_fec,
float expected_uplink_packet_loss_fraction) {
@ -221,7 +221,7 @@ TEST(FecControllerPlrBasedTest, MaintainFecOffForLowBandwidth) {
TEST(FecControllerPlrBasedTest, MaintainFecOffForVeryLowBandwidth) {
auto states = CreateFecControllerPlrBased(false);
// Below |kEnablingBandwidthLow|, no packet loss fraction can cause FEC to
// Below `kEnablingBandwidthLow`, no packet loss fraction can cause FEC to
// turn on.
UpdateNetworkMetrics(&states, kEnablingBandwidthLow - 1, 1.0);
CheckDecision(&states, false, 1.0);
@ -272,7 +272,7 @@ TEST(FecControllerPlrBasedTest, DisableFecForLowBandwidth) {
TEST(FecControllerPlrBasedTest, DisableFecForVeryLowBandwidth) {
auto states = CreateFecControllerPlrBased(true);
// Below |kEnablingBandwidthLow|, any packet loss fraction can cause FEC to
// Below `kEnablingBandwidthLow`, any packet loss fraction can cause FEC to
// turn off.
UpdateNetworkMetrics(&states, kDisablingBandwidthLow - 1, 1.0);
CheckDecision(&states, false, 1.0);

View File

@ -54,7 +54,7 @@ FrameLengthController::FrameLengthController(const Config& config)
frame_length_ms_ = std::find(config_.encoder_frame_lengths_ms.begin(),
config_.encoder_frame_lengths_ms.end(),
config_.initial_frame_length_ms);
// |encoder_frame_lengths_ms| must contain |initial_frame_length_ms|.
// `encoder_frame_lengths_ms` must contain `initial_frame_length_ms`.
RTC_DCHECK(frame_length_ms_ != config_.encoder_frame_lengths_ms.end());
}
@ -71,7 +71,7 @@ void FrameLengthController::UpdateNetworkMetrics(
}
void FrameLengthController::MakeDecision(AudioEncoderRuntimeConfig* config) {
// Decision on |frame_length_ms| should not have been made.
// Decision on `frame_length_ms` should not have been made.
RTC_DCHECK(!config->frame_length_ms);
if (FrameLengthIncreasingDecision(*config)) {
@ -99,12 +99,12 @@ bool FrameLengthController::Config::FrameLengthChange::operator<(
bool FrameLengthController::FrameLengthIncreasingDecision(
const AudioEncoderRuntimeConfig& config) {
// Increase frame length if
// 1. |uplink_bandwidth_bps| is known to be smaller or equal than
// |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the
// 1. `uplink_bandwidth_bps` is known to be smaller or equal than
// `min_encoder_bitrate_bps` plus `prevent_overuse_margin_bps` plus the
// current overhead rate OR all the following:
// 2. longer frame length is available AND
// 3. |uplink_bandwidth_bps| is known to be smaller than a threshold AND
// 4. |uplink_packet_loss_fraction| is known to be smaller than a threshold.
// 3. `uplink_bandwidth_bps` is known to be smaller than a threshold AND
// 4. `uplink_packet_loss_fraction` is known to be smaller than a threshold.
// Find next frame length to which a criterion is defined to shift from
// current frame length.
@ -156,12 +156,12 @@ bool FrameLengthController::FrameLengthDecreasingDecision(
const AudioEncoderRuntimeConfig& config) {
// Decrease frame length if
// 1. shorter frame length is available AND
// 2. |uplink_bandwidth_bps| is known to be bigger than
// |min_encoder_bitrate_bps| plus |prevent_overuse_margin_bps| plus the
// 2. `uplink_bandwidth_bps` is known to be bigger than
// `min_encoder_bitrate_bps` plus `prevent_overuse_margin_bps` plus the
// overhead which would be produced with the shorter frame length AND
// one or more of the followings:
// 3. |uplink_bandwidth_bps| is known to be larger than a threshold,
// 4. |uplink_packet_loss_fraction| is known to be larger than a threshold,
// 3. `uplink_bandwidth_bps` is known to be larger than a threshold,
// 4. `uplink_packet_loss_fraction` is known to be larger than a threshold,
// Find next frame length to which a criterion is defined to shift from
// current frame length.

View File

@ -19,7 +19,6 @@
#include "absl/types/optional.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -62,6 +61,9 @@ class FrameLengthController final : public Controller {
~FrameLengthController() override;
FrameLengthController(const FrameLengthController&) = delete;
FrameLengthController& operator=(const FrameLengthController&) = delete;
void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
@ -84,8 +86,6 @@ class FrameLengthController final : public Controller {
// True if the previous frame length decision was an increase, otherwise
// false.
bool prev_decision_increase_ = false;
RTC_DISALLOW_COPY_AND_ASSIGN(FrameLengthController);
};
} // namespace webrtc

View File

@ -184,8 +184,8 @@ TEST(FrameLengthControllerTest,
TEST(FrameLengthControllerTest, IncreaseTo40MsOnMultipleConditions) {
// Increase to 40ms frame length if
// 1. |uplink_bandwidth_bps| is known to be smaller than a threshold AND
// 2. |uplink_packet_loss_fraction| is known to be smaller than a threshold
// 1. `uplink_bandwidth_bps` is known to be smaller than a threshold AND
// 2. `uplink_packet_loss_fraction` is known to be smaller than a threshold
// AND
// 3. FEC is not decided or OFF.
auto controller = CreateController(CreateChangeCriteriaFor20msAnd40ms(),
@ -206,8 +206,8 @@ TEST(FrameLengthControllerTest, DecreaseTo40MsOnHighUplinkBandwidth) {
TEST(FrameLengthControllerTest, Maintain60MsOnMultipleConditions) {
// Maintain 60ms frame length if
// 1. |uplink_bandwidth_bps| is at medium level,
// 2. |uplink_packet_loss_fraction| is at medium,
// 1. `uplink_bandwidth_bps` is at medium level,
// 2. `uplink_packet_loss_fraction` is at medium,
// 3. FEC is not decided ON.
auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(),
kDefaultEncoderFrameLengthsMs, 60);
@ -218,8 +218,8 @@ TEST(FrameLengthControllerTest, Maintain60MsOnMultipleConditions) {
TEST(FrameLengthControllerTest, IncreaseTo60MsOnMultipleConditions) {
// Increase to 60ms frame length if
// 1. |uplink_bandwidth_bps| is known to be smaller than a threshold AND
// 2. |uplink_packet_loss_fraction| is known to be smaller than a threshold
// 1. `uplink_bandwidth_bps` is known to be smaller than a threshold AND
// 2. `uplink_packet_loss_fraction` is known to be smaller than a threshold
// AND
// 3. FEC is not decided or OFF.
auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(),
@ -365,8 +365,8 @@ TEST(FrameLengthControllerTest, From60MsTo120MsOnVeryLowUplinkBandwidth) {
TEST(FrameLengthControllerTest, From20MsTo120MsOnMultipleConditions) {
// Increase to 120ms frame length if
// 1. |uplink_bandwidth_bps| is known to be smaller than a threshold AND
// 2. |uplink_packet_loss_fraction| is known to be smaller than a threshold.
// 1. `uplink_bandwidth_bps` is known to be smaller than a threshold AND
// 2. `uplink_packet_loss_fraction` is known to be smaller than a threshold.
auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(),
kDefaultEncoderFrameLengthsMs, 20);
// It takes two steps for frame length to go from 20ms to 120ms.

View File

@ -32,7 +32,7 @@ struct AudioEncoderRuntimeConfig {
absl::optional<bool> enable_dtx;
// Some encoders can encode fewer channels than the actual input to make
// better use of the bandwidth. |num_channels| sets the number of channels
// better use of the bandwidth. `num_channels` sets the number of channels
// to encode.
absl::optional<size_t> num_channels;

View File

@ -24,124 +24,126 @@ import debug_dump_pb2
def GetNextMessageSize(file_to_parse):
data = file_to_parse.read(4)
if data == '':
return 0
return struct.unpack('<I', data)[0]
data = file_to_parse.read(4)
if data == '':
return 0
return struct.unpack('<I', data)[0]
def GetNextMessageFromFile(file_to_parse):
message_size = GetNextMessageSize(file_to_parse)
if message_size == 0:
return None
try:
event = debug_dump_pb2.Event()
event.ParseFromString(file_to_parse.read(message_size))
except IOError:
print 'Invalid message in file'
return None
return event
message_size = GetNextMessageSize(file_to_parse)
if message_size == 0:
return None
try:
event = debug_dump_pb2.Event()
event.ParseFromString(file_to_parse.read(message_size))
except IOError:
print 'Invalid message in file'
return None
return event
def InitMetrics():
metrics = {}
event = debug_dump_pb2.Event()
for metric in event.network_metrics.DESCRIPTOR.fields:
metrics[metric.name] = {'time': [], 'value': []}
return metrics
metrics = {}
event = debug_dump_pb2.Event()
for metric in event.network_metrics.DESCRIPTOR.fields:
metrics[metric.name] = {'time': [], 'value': []}
return metrics
def InitDecisions():
decisions = {}
event = debug_dump_pb2.Event()
for decision in event.encoder_runtime_config.DESCRIPTOR.fields:
decisions[decision.name] = {'time': [], 'value': []}
return decisions
decisions = {}
event = debug_dump_pb2.Event()
for decision in event.encoder_runtime_config.DESCRIPTOR.fields:
decisions[decision.name] = {'time': [], 'value': []}
return decisions
def ParseAnaDump(dump_file_to_parse):
with open(dump_file_to_parse, 'rb') as file_to_parse:
metrics = InitMetrics()
decisions = InitDecisions()
first_time_stamp = None
while True:
event = GetNextMessageFromFile(file_to_parse)
if event is None:
break
if first_time_stamp is None:
first_time_stamp = event.timestamp
if event.type == debug_dump_pb2.Event.ENCODER_RUNTIME_CONFIG:
for decision in event.encoder_runtime_config.DESCRIPTOR.fields:
if event.encoder_runtime_config.HasField(decision.name):
decisions[decision.name]['time'].append(event.timestamp -
first_time_stamp)
decisions[decision.name]['value'].append(
getattr(event.encoder_runtime_config, decision.name))
if event.type == debug_dump_pb2.Event.NETWORK_METRICS:
for metric in event.network_metrics.DESCRIPTOR.fields:
if event.network_metrics.HasField(metric.name):
metrics[metric.name]['time'].append(event.timestamp -
first_time_stamp)
metrics[metric.name]['value'].append(
getattr(event.network_metrics, metric.name))
return (metrics, decisions)
with open(dump_file_to_parse, 'rb') as file_to_parse:
metrics = InitMetrics()
decisions = InitDecisions()
first_time_stamp = None
while True:
event = GetNextMessageFromFile(file_to_parse)
if event is None:
break
if first_time_stamp is None:
first_time_stamp = event.timestamp
if event.type == debug_dump_pb2.Event.ENCODER_RUNTIME_CONFIG:
for decision in event.encoder_runtime_config.DESCRIPTOR.fields:
if event.encoder_runtime_config.HasField(decision.name):
decisions[decision.name]['time'].append(
event.timestamp - first_time_stamp)
decisions[decision.name]['value'].append(
getattr(event.encoder_runtime_config,
decision.name))
if event.type == debug_dump_pb2.Event.NETWORK_METRICS:
for metric in event.network_metrics.DESCRIPTOR.fields:
if event.network_metrics.HasField(metric.name):
metrics[metric.name]['time'].append(event.timestamp -
first_time_stamp)
metrics[metric.name]['value'].append(
getattr(event.network_metrics, metric.name))
return (metrics, decisions)
def main():
parser = OptionParser()
parser.add_option(
"-f", "--dump_file", dest="dump_file_to_parse", help="dump file to parse")
parser.add_option(
'-m',
'--metric_plot',
default=[],
type=str,
help='metric key (name of the metric) to plot',
dest='metric_keys',
action='append')
parser = OptionParser()
parser.add_option("-f",
"--dump_file",
dest="dump_file_to_parse",
help="dump file to parse")
parser.add_option('-m',
'--metric_plot',
default=[],
type=str,
help='metric key (name of the metric) to plot',
dest='metric_keys',
action='append')
parser.add_option(
'-d',
'--decision_plot',
default=[],
type=str,
help='decision key (name of the decision) to plot',
dest='decision_keys',
action='append')
parser.add_option('-d',
'--decision_plot',
default=[],
type=str,
help='decision key (name of the decision) to plot',
dest='decision_keys',
action='append')
options = parser.parse_args()[0]
if options.dump_file_to_parse is None:
print "No dump file to parse is set.\n"
parser.print_help()
exit()
(metrics, decisions) = ParseAnaDump(options.dump_file_to_parse)
metric_keys = options.metric_keys
decision_keys = options.decision_keys
plot_count = len(metric_keys) + len(decision_keys)
if plot_count == 0:
print "You have to set at least one metric or decision to plot.\n"
parser.print_help()
exit()
plots = []
if plot_count == 1:
f, mp_plot = plt.subplots()
plots.append(mp_plot)
else:
f, mp_plots = plt.subplots(plot_count, sharex=True)
plots.extend(mp_plots.tolist())
options = parser.parse_args()[0]
if options.dump_file_to_parse is None:
print "No dump file to parse is set.\n"
parser.print_help()
exit()
(metrics, decisions) = ParseAnaDump(options.dump_file_to_parse)
metric_keys = options.metric_keys
decision_keys = options.decision_keys
plot_count = len(metric_keys) + len(decision_keys)
if plot_count == 0:
print "You have to set at least one metric or decision to plot.\n"
parser.print_help()
exit()
plots = []
if plot_count == 1:
f, mp_plot = plt.subplots()
plots.append(mp_plot)
else:
f, mp_plots = plt.subplots(plot_count, sharex=True)
plots.extend(mp_plots.tolist())
for key in metric_keys:
plot = plots.pop()
plot.grid(True)
plot.set_title(key + " (metric)")
plot.plot(metrics[key]['time'], metrics[key]['value'])
for key in decision_keys:
plot = plots.pop()
plot.grid(True)
plot.set_title(key + " (decision)")
plot.plot(decisions[key]['time'], decisions[key]['value'])
f.subplots_adjust(hspace=0.3)
plt.show()
for key in metric_keys:
plot = plots.pop()
plot.grid(True)
plot.set_title(key + " (metric)")
plot.plot(metrics[key]['time'], metrics[key]['value'])
for key in decision_keys:
plot = plots.pop()
plot.grid(True)
plot.set_title(key + " (decision)")
plot.plot(decisions[key]['time'], decisions[key]['value'])
f.subplots_adjust(hspace=0.3)
plt.show()
if __name__ == "__main__":
main()
main()

View File

@ -75,38 +75,13 @@ TEST(AudioDecoderFactoryTest, CreateIlbc) {
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1), absl::nullopt));
}
TEST(AudioDecoderFactoryTest, CreateIsac) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
ASSERT_TRUE(adf);
// iSAC supports 16 kHz, 1 channel. The float implementation additionally
// supports 32 kHz, 1 channel.
EXPECT_FALSE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0), absl::nullopt));
EXPECT_TRUE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1), absl::nullopt));
EXPECT_FALSE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2), absl::nullopt));
EXPECT_FALSE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1), absl::nullopt));
EXPECT_FALSE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1), absl::nullopt));
#ifdef WEBRTC_ARCH_ARM
EXPECT_FALSE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), absl::nullopt));
#else
EXPECT_TRUE(
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), absl::nullopt));
#endif
}
TEST(AudioDecoderFactoryTest, CreateL16) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
ASSERT_TRUE(adf);
// L16 supports any clock rate, any number of channels.
// L16 supports any clock rate and any number of channels up to 24.
const int clockrates[] = {8000, 16000, 32000, 48000};
const int num_channels[] = {1, 2, 3, 4711};
const int num_channels[] = {1, 2, 3, 24};
for (int clockrate : clockrates) {
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0),
absl::nullopt));
@ -117,6 +92,31 @@ TEST(AudioDecoderFactoryTest, CreateL16) {
}
}
// Tests that using more channels than the maximum does not work
TEST(AudioDecoderFactoryTest, MaxNrOfChannels) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
std::vector<std::string> codecs = {
#ifdef WEBRTC_CODEC_OPUS
"opus",
#endif
#ifdef WEBRTC_CODEC_ILBC
"ilbc",
#endif
"pcmu",
"pcma",
"l16",
"G722",
"G711",
};
for (auto codec : codecs) {
EXPECT_FALSE(adf->MakeAudioDecoder(
SdpAudioFormat(codec, 32000, AudioDecoder::kMaxNumberOfChannels + 1),
absl::nullopt));
}
}
TEST(AudioDecoderFactoryTest, CreateG722) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
@ -150,7 +150,7 @@ TEST(AudioDecoderFactoryTest, CreateOpus) {
for (int hz : {8000, 16000, 32000, 48000}) {
for (int channels : {0, 1, 2, 3}) {
for (std::string stereo : {"XX", "0", "1", "2"}) {
std::map<std::string, std::string> params;
SdpAudioFormat::Parameters params;
if (stereo != "XX") {
params["stereo"] = stereo;
}

View File

@ -144,4 +144,35 @@ TEST(BuiltinAudioEncoderFactoryTest, SupportsTheExpectedFormats) {
ASSERT_THAT(supported_formats, ElementsAreArray(expected_formats));
}
// Tests that using more channels than the maximum does not work.
TEST(BuiltinAudioEncoderFactoryTest, MaxNrOfChannels) {
rtc::scoped_refptr<AudioEncoderFactory> aef =
CreateBuiltinAudioEncoderFactory();
std::vector<std::string> codecs = {
#ifdef WEBRTC_CODEC_OPUS
"opus",
#endif
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
"isac",
#endif
#ifdef WEBRTC_CODEC_ILBC
"ilbc",
#endif
"pcmu",
"pcma",
"l16",
"G722",
"G711",
};
for (auto codec : codecs) {
EXPECT_FALSE(aef->MakeAudioEncoder(
/*payload_type=*/111,
/*format=*/
SdpAudioFormat(codec, 32000, AudioEncoder::kMaxNumberOfChannels + 1),
/*codec_pair_id=*/absl::nullopt));
}
}
} // namespace webrtc

View File

@ -171,9 +171,8 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeImpl(
last_frame_active_ = true;
break;
}
case Vad::kError: {
FATAL(); // Fails only if fed invalid data.
break;
default: {
RTC_CHECK_NOTREACHED();
}
}

View File

@ -14,7 +14,6 @@
#include <vector>
#include "common_audio/vad/mock/mock_vad.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "test/gtest.h"
#include "test/mock_audio_encoder.h"
@ -50,6 +49,9 @@ class AudioEncoderCngTest : public ::testing::Test {
EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1));
}
AudioEncoderCngTest(const AudioEncoderCngTest&) = delete;
AudioEncoderCngTest& operator=(const AudioEncoderCngTest&) = delete;
void TearDown() override {
EXPECT_CALL(*mock_vad_, Die()).Times(1);
cng_.reset();
@ -92,8 +94,8 @@ class AudioEncoderCngTest : public ::testing::Test {
timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_);
}
// Expect |num_calls| calls to the encoder, all successful. The last call
// claims to have encoded |kMockReturnEncodedBytes| bytes, and all the
// Expect `num_calls` calls to the encoder, all successful. The last call
// claims to have encoded `kMockReturnEncodedBytes` bytes, and all the
// preceding ones 0 bytes.
void ExpectEncodeCalls(size_t num_calls) {
InSequence s;
@ -108,7 +110,7 @@ class AudioEncoderCngTest : public ::testing::Test {
}
// Verifies that the cng_ object waits until it has collected
// |blocks_per_frame| blocks of audio, and then dispatches all of them to
// `blocks_per_frame` blocks of audio, and then dispatches all of them to
// the underlying codec (speech or cng).
void CheckBlockGrouping(size_t blocks_per_frame, bool active_speech) {
EXPECT_CALL(*mock_encoder_, Num10MsFramesInNextPacket())
@ -169,7 +171,7 @@ class AudioEncoderCngTest : public ::testing::Test {
.WillOnce(Return(Vad::kPassive));
}
// With this call to Encode(), |mock_vad_| should be called according to the
// With this call to Encode(), `mock_vad_` should be called according to the
// above expectations.
Encode();
}
@ -201,15 +203,13 @@ class AudioEncoderCngTest : public ::testing::Test {
std::unique_ptr<AudioEncoder> cng_;
std::unique_ptr<MockAudioEncoder> mock_encoder_owner_;
MockAudioEncoder* mock_encoder_;
MockVad* mock_vad_; // Ownership is transferred to |cng_|.
MockVad* mock_vad_; // Ownership is transferred to `cng_`.
uint32_t timestamp_;
int16_t audio_[kMaxNumSamples];
size_t num_audio_samples_10ms_;
rtc::Buffer encoded_;
AudioEncoder::EncodedInfo encoded_info_;
int sample_rate_hz_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderCngTest);
};
TEST_F(AudioEncoderCngTest, CreateAndDestroy) {
@ -294,7 +294,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) {
for (size_t i = 0; i < 100; ++i) {
Encode();
// Check if it was time to call the cng encoder. This is done once every
// |kBlocksPerFrame| calls.
// `kBlocksPerFrame` calls.
if ((i + 1) % kBlocksPerFrame == 0) {
// Now check if a SID interval has elapsed.
if ((i % (sid_frame_interval_ms / 10)) < kBlocksPerFrame) {
@ -334,7 +334,7 @@ TEST_F(AudioEncoderCngTest, MixedActivePassive) {
EXPECT_TRUE(CheckMixedActivePassive(Vad::kPassive, Vad::kActive));
EXPECT_TRUE(encoded_info_.speech);
// All of the frame is passive speech. Expect no calls to |mock_encoder_|.
// All of the frame is passive speech. Expect no calls to `mock_encoder_`.
EXPECT_FALSE(CheckMixedActivePassive(Vad::kPassive, Vad::kPassive));
EXPECT_FALSE(encoded_info_.speech);
}
@ -442,7 +442,7 @@ class AudioEncoderCngDeathTest : public AudioEncoderCngTest {
}
// Override AudioEncoderCngTest::TearDown, since that one expects a call to
// the destructor of |mock_vad_|. In this case, that object is already
// the destructor of `mock_vad_`. In this case, that object is already
// deleted.
void TearDown() override { cng_.reset(); }

View File

@ -193,10 +193,10 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
WebRtcSpl_ScaleVector(excitation, excitation, dec_used_scale_factor_,
num_samples, 13);
/* |lpPoly| - Coefficients in Q12.
* |excitation| - Speech samples.
* |nst->dec_filtstate| - State preservation.
* |out_data| - Filtered speech samples. */
/* `lpPoly` - Coefficients in Q12.
* `excitation` - Speech samples.
* `nst->dec_filtstate` - State preservation.
* `out_data` - Filtered speech samples. */
WebRtcSpl_FilterAR(lpPoly, WEBRTC_CNG_MAX_LPC_ORDER + 1, excitation,
num_samples, dec_filtstate_, WEBRTC_CNG_MAX_LPC_ORDER,
dec_filtstateLow_, WEBRTC_CNG_MAX_LPC_ORDER,
@ -395,7 +395,7 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
}
namespace {
/* Values in |k| are Q15, and |a| Q12. */
/* Values in `k` are Q15, and `a` Q12. */
void WebRtcCng_K2a16(int16_t* k, int useOrder, int16_t* a) {
int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1];
int16_t* aptr;

View File

@ -33,13 +33,13 @@ class ComfortNoiseDecoder {
void Reset();
// Updates the CN state when a new SID packet arrives.
// |sid| is a view of the SID packet without the headers.
// `sid` is a view of the SID packet without the headers.
void UpdateSid(rtc::ArrayView<const uint8_t> sid);
// Generates comfort noise.
// |out_data| will be filled with samples - its size determines the number of
// samples generated. When |new_period| is true, CNG history will be reset
// before any audio is generated. Returns |false| if outData is too large -
// `out_data` will be filled with samples - its size determines the number of
// samples generated. When `new_period` is true, CNG history will be reset
// before any audio is generated. Returns `false` if outData is too large -
// currently 640 bytes (equalling 10ms at 64kHz).
// TODO(ossu): Specify better limits for the size of out_data. Either let it
// be unbounded or limit to 10ms in the current sample rate.
@ -61,9 +61,9 @@ class ComfortNoiseDecoder {
class ComfortNoiseEncoder {
public:
// Creates a comfort noise encoder.
// |fs| selects sample rate: 8000 for narrowband or 16000 for wideband.
// |interval| sets the interval at which to generate SID data (in ms).
// |quality| selects the number of refl. coeffs. Maximum allowed is 12.
// `fs` selects sample rate: 8000 for narrowband or 16000 for wideband.
// `interval` sets the interval at which to generate SID data (in ms).
// `quality` selects the number of refl. coeffs. Maximum allowed is 12.
ComfortNoiseEncoder(int fs, int interval, int quality);
~ComfortNoiseEncoder() = default;
@ -74,8 +74,8 @@ class ComfortNoiseEncoder {
// Parameters are set as during construction.
void Reset(int fs, int interval, int quality);
// Analyzes background noise from |speech| and appends coefficients to
// |output|. Returns the number of coefficients generated. If |force_sid| is
// Analyzes background noise from `speech` and appends coefficients to
// `output`. Returns the number of coefficients generated. If `force_sid` is
// true, a SID frame is forced and the internal sid interval counter is reset.
// Will fail if the input size is too large (> 640 samples, see
// ComfortNoiseDecoder::Generate).

View File

@ -40,8 +40,14 @@ int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
// Adjust the encoded length down to ensure the same number of samples in each
// channel.
const size_t encoded_len_adjusted =
PacketDuration(encoded, encoded_len) *
Channels(); // 1 byte per sample per channel
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type);
size_t ret =
WebRtcG711_DecodeU(encoded, encoded_len_adjusted, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return static_cast<int>(ret);
}
@ -75,8 +81,14 @@ int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
// Adjust the encoded length down to ensure the same number of samples in each
// channel.
const size_t encoded_len_adjusted =
PacketDuration(encoded, encoded_len) *
Channels(); // 1 byte per sample per channel
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type);
size_t ret =
WebRtcG711_DecodeA(encoded, encoded_len_adjusted, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return static_cast<int>(ret);
}

View File

@ -19,7 +19,6 @@
#include "api/audio_codecs/audio_decoder.h"
#include "rtc_base/buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -28,6 +27,10 @@ class AudioDecoderPcmU final : public AudioDecoder {
explicit AudioDecoderPcmU(size_t num_channels) : num_channels_(num_channels) {
RTC_DCHECK_GE(num_channels, 1);
}
AudioDecoderPcmU(const AudioDecoderPcmU&) = delete;
AudioDecoderPcmU& operator=(const AudioDecoderPcmU&) = delete;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp) override;
@ -44,7 +47,6 @@ class AudioDecoderPcmU final : public AudioDecoder {
private:
const size_t num_channels_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmU);
};
class AudioDecoderPcmA final : public AudioDecoder {
@ -52,6 +54,10 @@ class AudioDecoderPcmA final : public AudioDecoder {
explicit AudioDecoderPcmA(size_t num_channels) : num_channels_(num_channels) {
RTC_DCHECK_GE(num_channels, 1);
}
AudioDecoderPcmA(const AudioDecoderPcmA&) = delete;
AudioDecoderPcmA& operator=(const AudioDecoderPcmA&) = delete;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp) override;
@ -68,7 +74,6 @@ class AudioDecoderPcmA final : public AudioDecoder {
private:
const size_t num_channels_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmA);
};
} // namespace webrtc

View File

@ -17,7 +17,6 @@
#include "absl/types/optional.h"
#include "api/audio_codecs/audio_encoder.h"
#include "api/units/time_delta.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -83,6 +82,9 @@ class AudioEncoderPcmA final : public AudioEncoderPcm {
explicit AudioEncoderPcmA(const Config& config)
: AudioEncoderPcm(config, kSampleRateHz) {}
AudioEncoderPcmA(const AudioEncoderPcmA&) = delete;
AudioEncoderPcmA& operator=(const AudioEncoderPcmA&) = delete;
protected:
size_t EncodeCall(const int16_t* audio,
size_t input_len,
@ -94,7 +96,6 @@ class AudioEncoderPcmA final : public AudioEncoderPcm {
private:
static const int kSampleRateHz = 8000;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA);
};
class AudioEncoderPcmU final : public AudioEncoderPcm {
@ -106,6 +107,9 @@ class AudioEncoderPcmU final : public AudioEncoderPcm {
explicit AudioEncoderPcmU(const Config& config)
: AudioEncoderPcm(config, kSampleRateHz) {}
AudioEncoderPcmU(const AudioEncoderPcmU&) = delete;
AudioEncoderPcmU& operator=(const AudioEncoderPcmU&) = delete;
protected:
size_t EncodeCall(const int16_t* audio,
size_t input_len,
@ -117,7 +121,6 @@ class AudioEncoderPcmU final : public AudioEncoderPcm {
private:
static const int kSampleRateHz = 8000;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU);
};
} // namespace webrtc

View File

@ -11,6 +11,7 @@
#ifndef MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_
#define MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_
#include <stddef.h>
#include <stdint.h>
// Comfort noise constants

View File

@ -89,16 +89,22 @@ int AudioDecoderG722StereoImpl::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
// Adjust the encoded length down to ensure the same number of samples in each
// channel.
const size_t encoded_len_adjusted = PacketDuration(encoded, encoded_len) *
Channels() /
2; // 1/2 byte per sample per channel
int16_t temp_type = 1; // Default is speech.
// De-interleave the bit-stream into two separate payloads.
uint8_t* encoded_deinterleaved = new uint8_t[encoded_len];
SplitStereoPacket(encoded, encoded_len, encoded_deinterleaved);
uint8_t* encoded_deinterleaved = new uint8_t[encoded_len_adjusted];
SplitStereoPacket(encoded, encoded_len_adjusted, encoded_deinterleaved);
// Decode left and right.
size_t decoded_len = WebRtcG722_Decode(dec_state_left_, encoded_deinterleaved,
encoded_len / 2, decoded, &temp_type);
size_t decoded_len =
WebRtcG722_Decode(dec_state_left_, encoded_deinterleaved,
encoded_len_adjusted / 2, decoded, &temp_type);
size_t ret = WebRtcG722_Decode(
dec_state_right_, &encoded_deinterleaved[encoded_len / 2],
encoded_len / 2, &decoded[decoded_len], &temp_type);
dec_state_right_, &encoded_deinterleaved[encoded_len_adjusted / 2],
encoded_len_adjusted / 2, &decoded[decoded_len], &temp_type);
if (ret == decoded_len) {
ret += decoded_len; // Return total number of samples.
// Interleave output.
@ -114,6 +120,14 @@ int AudioDecoderG722StereoImpl::DecodeInternal(const uint8_t* encoded,
return static_cast<int>(ret);
}
int AudioDecoderG722StereoImpl::PacketDuration(const uint8_t* encoded,
size_t encoded_len) const {
// 1/2 encoded byte per sample per channel. Make sure the length represents
// an equal number of bytes per channel. Otherwise, we cannot de-interleave
// the encoded data later.
return static_cast<int>(2 * (encoded_len / Channels()));
}
int AudioDecoderG722StereoImpl::SampleRateHz() const {
return 16000;
}

View File

@ -12,7 +12,6 @@
#define MODULES_AUDIO_CODING_CODECS_G722_AUDIO_DECODER_G722_H_
#include "api/audio_codecs/audio_decoder.h"
#include "rtc_base/constructor_magic.h"
typedef struct WebRtcG722DecInst G722DecInst;
@ -22,6 +21,10 @@ class AudioDecoderG722Impl final : public AudioDecoder {
public:
AudioDecoderG722Impl();
~AudioDecoderG722Impl() override;
AudioDecoderG722Impl(const AudioDecoderG722Impl&) = delete;
AudioDecoderG722Impl& operator=(const AudioDecoderG722Impl&) = delete;
bool HasDecodePlc() const override;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
@ -39,17 +42,22 @@ class AudioDecoderG722Impl final : public AudioDecoder {
private:
G722DecInst* dec_state_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722Impl);
};
class AudioDecoderG722StereoImpl final : public AudioDecoder {
public:
AudioDecoderG722StereoImpl();
~AudioDecoderG722StereoImpl() override;
AudioDecoderG722StereoImpl(const AudioDecoderG722StereoImpl&) = delete;
AudioDecoderG722StereoImpl& operator=(const AudioDecoderG722StereoImpl&) =
delete;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp) override;
int SampleRateHz() const override;
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
size_t Channels() const override;
protected:
@ -60,18 +68,17 @@ class AudioDecoderG722StereoImpl final : public AudioDecoder {
SpeechType* speech_type) override;
private:
// Splits the stereo-interleaved payload in |encoded| into separate payloads
// Splits the stereo-interleaved payload in `encoded` into separate payloads
// for left and right channels. The separated payloads are written to
// |encoded_deinterleaved|, which must hold at least |encoded_len| samples.
// `encoded_deinterleaved`, which must hold at least `encoded_len` samples.
// The left channel starts at offset 0, while the right channel starts at
// offset encoded_len / 2 into |encoded_deinterleaved|.
// offset encoded_len / 2 into `encoded_deinterleaved`.
void SplitStereoPacket(const uint8_t* encoded,
size_t encoded_len,
uint8_t* encoded_deinterleaved);
G722DecInst* dec_state_left_;
G722DecInst* dec_state_right_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722StereoImpl);
};
} // namespace webrtc

View File

@ -20,7 +20,6 @@
#include "api/units/time_delta.h"
#include "modules/audio_coding/codecs/g722/g722_interface.h"
#include "rtc_base/buffer.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -29,6 +28,9 @@ class AudioEncoderG722Impl final : public AudioEncoder {
AudioEncoderG722Impl(const AudioEncoderG722Config& config, int payload_type);
~AudioEncoderG722Impl() override;
AudioEncoderG722Impl(const AudioEncoderG722Impl&) = delete;
AudioEncoderG722Impl& operator=(const AudioEncoderG722Impl&) = delete;
int SampleRateHz() const override;
size_t NumChannels() const override;
int RtpTimestampRateHz() const override;
@ -63,7 +65,6 @@ class AudioEncoderG722Impl final : public AudioEncoder {
uint32_t first_timestamp_in_buffer_;
const std::unique_ptr<EncoderState[]> encoders_;
rtc::Buffer interleave_buffer_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderG722Impl);
};
} // namespace webrtc

View File

@ -11,6 +11,7 @@
#ifndef MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
#define MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
#include <stddef.h>
#include <stdint.h>
/*

View File

@ -16,9 +16,11 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#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"
/*----------------------------------------------------------------*

View File

@ -19,6 +19,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -16,8 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.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"
#include "modules/audio_coding/codecs/ilbc/sort_sq.h"
void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN,

View File

@ -19,7 +19,8 @@
#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 "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*----------------------------------------------------------------*
* predictive noise shaping encoding of scaled start state

View File

@ -13,11 +13,11 @@
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "api/audio_codecs/audio_decoder.h"
#include "rtc_base/buffer.h"
#include "rtc_base/constructor_magic.h"
typedef struct iLBC_decinst_t_ IlbcDecoderInstance;
@ -27,6 +27,10 @@ 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;
@ -44,7 +48,6 @@ class AudioDecoderIlbcImpl final : public AudioDecoder {
private:
IlbcDecoderInstance* dec_state_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderIlbcImpl);
};
} // namespace webrtc

View File

@ -34,7 +34,7 @@ int GetIlbcBitrate(int ptime) {
// 50 bytes per frame of 30 ms => (approx) 13333 bits/s.
return 13333;
default:
FATAL();
RTC_CHECK_NOTREACHED();
}
}
@ -144,7 +144,7 @@ size_t AudioEncoderIlbcImpl::RequiredOutputSizeBytes() const {
case 6:
return 2 * 50;
default:
FATAL();
RTC_CHECK_NOTREACHED();
}
}

View File

@ -11,6 +11,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include "absl/types/optional.h"
@ -18,7 +21,6 @@
#include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h"
#include "api/units/time_delta.h"
#include "modules/audio_coding/codecs/ilbc/ilbc.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -27,6 +29,9 @@ class AudioEncoderIlbcImpl final : public AudioEncoder {
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;
@ -50,7 +55,6 @@ class AudioEncoderIlbcImpl final : public AudioEncoder {
uint32_t first_timestamp_in_buffer_;
int16_t input_buffer_[kMaxSamplesPerPacket];
IlbcEncoderInstance* encoder_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderIlbcImpl);
};
} // namespace webrtc

View File

@ -16,10 +16,11 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#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 */

View File

@ -19,7 +19,8 @@
#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 "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*----------------------------------------------------------------*
* Calculate correlation between target and Augmented codebooks

View File

@ -16,6 +16,8 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/bw_expand.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -19,7 +19,8 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*----------------------------------------------------------------*
* lpc bandwidth expansion

View File

@ -20,16 +20,18 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "absl/base/attributes.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "rtc_base/system/unused.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 */
@ -37,6 +39,6 @@ bool WebRtcIlbcfix_CbConstruct(
int16_t* mem, /* (i) Buffer for codevector construction */
size_t lMem, /* (i) Length of buffer */
size_t veclen /* (i) Length of vector */
) RTC_WARN_UNUSED_RESULT;
);
#endif

View File

@ -16,9 +16,11 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#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

View File

@ -19,6 +19,9 @@
#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 <stddef.h>
#include <stdint.h>
void WebRtcIlbcfix_CbMemEnergy(
size_t range,
int16_t* CB, /* (i) The CB memory (1:st section) */

View File

@ -16,8 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#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 */

View File

@ -19,6 +19,9 @@
#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 <stddef.h>
#include <stdint.h>
void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t* interpSamples, /* (i) The interpolated samples */
int16_t* CBmem, /* (i) The CB memory */

View File

@ -16,6 +16,8 @@
******************************************************************/
#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

View File

@ -19,6 +19,9 @@
#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 <stddef.h>
#include <stdint.h>
void WebRtcIlbcfix_CbMemEnergyCalc(
int32_t energy, /* (i) input start energy */
size_t range, /* (i) number of iterations */

View File

@ -16,18 +16,20 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/gain_quant.h"
#include "modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#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/interpolate_samples.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/energy_inverse.h"
#include "modules/audio_coding/codecs/ilbc/augmented_cb_corr.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.

View File

@ -19,6 +19,11 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_CbSearch(
IlbcEncoder* iLBCenc_inst,
/* (i) the encoder state structure */

View File

@ -16,8 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#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 */

View File

@ -19,7 +19,8 @@
#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 "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
void WebRtcIlbcfix_CbSearchCore(
int32_t* cDot, /* (i) Cross Correlation */

View File

@ -16,9 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.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/defines.h"
void WebRtcIlbcfix_CbUpdateBestIndex(
int32_t CritNew, /* (i) New Potentially best Criteria */

View File

@ -19,7 +19,8 @@
#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 "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
void WebRtcIlbcfix_CbUpdateBestIndex(
int32_t CritNew, /* (i) New Potentially best Criteria */

View File

@ -16,8 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#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

View File

@ -19,7 +19,8 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*------------------------------------------------------------------*
* Calculate the Chevyshev polynomial series

View File

@ -16,6 +16,8 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/comp_corr.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -19,7 +19,8 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*----------------------------------------------------------------*
* Compute cross correlation and pitch gain for pitch prediction

View File

@ -16,9 +16,10 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#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};

View File

@ -19,6 +19,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/* high pass filters */

View File

@ -16,10 +16,12 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#include "rtc_base/sanitizer.h"
#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.
@ -37,7 +39,7 @@ void WebRtcIlbcfix_CreateAugmentedVec(
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|.
outside `cbVec`; clamping interp_len to stay within `cbVec`.
*/
size_t interp_len = WEBRTC_SPL_MIN(index, 4);
@ -67,12 +69,12 @@ void WebRtcIlbcfix_CreateAugmentedVec(
/* 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` 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|.
`index` elements from `ppo`.
|cbVec| is declared to be SUBL elements long in WebRtcIlbcfix_CbConstruct.
`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.

View File

@ -19,7 +19,8 @@
#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 "modules/audio_coding/codecs/ilbc/defines.h"
#include <stddef.h>
#include <stdint.h>
/*----------------------------------------------------------------*
* Recreate a specific codebook vector from the augmented part.

View File

@ -16,22 +16,23 @@
******************************************************************/
// Defines WEBRTC_ARCH_BIG_ENDIAN, used below.
#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"
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h"
#include "modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h"
#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h"
#include "modules/audio_coding/codecs/ilbc/do_plc.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#include "modules/audio_coding/codecs/ilbc/enhancer_interface.h"
#include "modules/audio_coding/codecs/ilbc/xcorr_coef.h"
#include "modules/audio_coding/codecs/ilbc/lsf_check.h"
#include "modules/audio_coding/codecs/ilbc/decode_residual.h"
#include "modules/audio_coding/codecs/ilbc/unpack_bits.h"
#include "modules/audio_coding/codecs/ilbc/hp_output.h"
#include "modules/audio_coding/codecs/ilbc/init_decode.h"
#ifndef WEBRTC_ARCH_BIG_ENDIAN
#include "modules/audio_coding/codecs/ilbc/swap_bytes.h"
#endif

View File

@ -21,21 +21,22 @@
#include <stdint.h>
#include "absl/base/attributes.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "rtc_base/system/unused.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 */
) RTC_WARN_UNUSED_RESULT;
int16_t mode /* (i) 0: bad packet, PLC,
1: normal */
);
#endif

View File

@ -20,15 +20,15 @@
#include <string.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/state_construct.h"
#include "modules/audio_coding/codecs/ilbc/cb_construct.h"
#include "modules/audio_coding/codecs/ilbc/index_conv_dec.h"
#include "modules/audio_coding/codecs/ilbc/do_plc.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/xcorr_coef.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)

View File

@ -20,10 +20,11 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "absl/base/attributes.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "rtc_base/system/unused.h"
/*----------------------------------------------------------------*
* frame residual decoder function (subrutine to iLBC_decode)
@ -31,6 +32,7 @@
// 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
@ -38,6 +40,6 @@ bool WebRtcIlbcfix_DecodeResidual(
int16_t* decresidual, /* (o) decoded residual frame */
int16_t* syntdenum /* (i) the decoded synthesis filter
coefficients */
) RTC_WARN_UNUSED_RESULT;
);
#endif

View File

@ -16,10 +16,12 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h"
#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/defines.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

View File

@ -19,6 +19,9 @@
#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 <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -18,6 +18,7 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_
#include <stdint.h>
#include <string.h>
#include "common_audio/signal_processing/include/signal_processing_library.h"

View File

@ -16,10 +16,12 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#include "modules/audio_coding/codecs/ilbc/comp_corr.h"
#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

View File

@ -19,6 +19,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -16,28 +16,29 @@
******************************************************************/
#include "modules/audio_coding/codecs/ilbc/encode.h"
#include <string.h>
// Defines WEBRTC_ARCH_BIG_ENDIAN, used below.
#include "rtc_base/system/arch.h"
#include "modules/audio_coding/codecs/ilbc/defines.h"
#include "modules/audio_coding/codecs/ilbc/lpc_encode.h"
#include "modules/audio_coding/codecs/ilbc/frame_classify.h"
#include "modules/audio_coding/codecs/ilbc/state_search.h"
#include "modules/audio_coding/codecs/ilbc/state_construct.h"
#include "modules/audio_coding/codecs/ilbc/constants.h"
#include "modules/audio_coding/codecs/ilbc/cb_search.h"
#include "modules/audio_coding/codecs/ilbc/cb_construct.h"
#include "modules/audio_coding/codecs/ilbc/index_conv_enc.h"
#include "modules/audio_coding/codecs/ilbc/pack_bits.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

View File

@ -19,6 +19,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/*----------------------------------------------------------------*

View File

@ -19,6 +19,9 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENERGY_INVERSE_H_
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENERGY_INVERSE_H_
#include <stddef.h>
#include <stdint.h>
#include "modules/audio_coding/codecs/ilbc/defines.h"
/* Inverses the in vector in into Q29 domain */

Some files were not shown because too many files have changed in this diff Show More