Misc. small cleanups.
* Better param names * Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases. * Use arraysize() * Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers * reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead * Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition * Fix indenting * Use uint32_t for timestamps (matching how it's already a uint32_t in most places) * Spelling * RTC_CHECK_EQ(expected, actual) * Rewrap * Use .empty() * Be more pedantic about matching int/int32_t/ * Remove pointless consts on input parameters to functions * Add missing sanity checks All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first. BUG=none TEST=none Review URL: https://codereview.webrtc.org/1534193008 Cr-Commit-Position: refs/heads/master@{#11191}
This commit is contained in:
@ -137,15 +137,14 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
|
||||
uint8_t* encoded) {
|
||||
if (input_buffer_.empty())
|
||||
first_timestamp_in_buffer_ = rtp_timestamp;
|
||||
RTC_DCHECK_EQ(static_cast<size_t>(SamplesPer10msFrame()), audio.size());
|
||||
RTC_DCHECK_EQ(SamplesPer10msFrame(), audio.size());
|
||||
input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend());
|
||||
if (input_buffer_.size() <
|
||||
(static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame())) {
|
||||
(Num10msFramesPerPacket() * SamplesPer10msFrame())) {
|
||||
return EncodedInfo();
|
||||
}
|
||||
RTC_CHECK_EQ(
|
||||
input_buffer_.size(),
|
||||
static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame());
|
||||
RTC_CHECK_EQ(input_buffer_.size(),
|
||||
Num10msFramesPerPacket() * SamplesPer10msFrame());
|
||||
int status = WebRtcOpus_Encode(
|
||||
inst_, &input_buffer_[0],
|
||||
rtc::CheckedDivExact(input_buffer_.size(),
|
||||
@ -214,11 +213,11 @@ void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) {
|
||||
RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
|
||||
}
|
||||
|
||||
int AudioEncoderOpus::Num10msFramesPerPacket() const {
|
||||
return rtc::CheckedDivExact(config_.frame_size_ms, 10);
|
||||
size_t AudioEncoderOpus::Num10msFramesPerPacket() const {
|
||||
return static_cast<size_t>(rtc::CheckedDivExact(config_.frame_size_ms, 10));
|
||||
}
|
||||
|
||||
int AudioEncoderOpus::SamplesPer10msFrame() const {
|
||||
size_t AudioEncoderOpus::SamplesPer10msFrame() const {
|
||||
return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels;
|
||||
}
|
||||
|
||||
|
||||
@ -85,8 +85,8 @@ class AudioEncoderOpus final : public AudioEncoder {
|
||||
bool dtx_enabled() const { return config_.dtx_enabled; }
|
||||
|
||||
private:
|
||||
int Num10msFramesPerPacket() const;
|
||||
int SamplesPer10msFrame() const;
|
||||
size_t Num10msFramesPerPacket() const;
|
||||
size_t SamplesPer10msFrame() const;
|
||||
bool RecreateEncoderInstance(const Config& config);
|
||||
|
||||
Config config_;
|
||||
|
||||
@ -77,7 +77,7 @@ float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream,
|
||||
value = WebRtcOpus_Decode(opus_decoder_, bit_stream, encoded_bytes, out_data,
|
||||
&audio_type);
|
||||
clocks = clock() - clocks;
|
||||
EXPECT_EQ(output_length_sample_, value);
|
||||
EXPECT_EQ(output_length_sample_, static_cast<size_t>(value));
|
||||
return 1000.0 * clocks / CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user