Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc

Issue 1184313002: Add AudioEncoder::GetTargetBitrate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing GN compile Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index ed496186469e1a7ccc4d48858fc1635528f6680e..905a7152dd40dda0dc523207d34e0072165a4c00 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -60,7 +60,7 @@ int AudioEncoderPcm::NumChannels() const {
}
size_t AudioEncoderPcm::MaxEncodedBytes() const {
- return full_frame_samples_;
+ return full_frame_samples_ * BytesPerSample();
}
int AudioEncoderPcm::Num10MsFramesInNextPacket() const {
@@ -71,6 +71,10 @@ int AudioEncoderPcm::Max10MsFramesInAPacket() const {
return num_10ms_frames_per_packet_;
}
+int AudioEncoderPcm::GetTargetBitrate() const {
+ return 8 * BytesPerSample() * SampleRateHz() * NumChannels();
+}
+
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal(
uint32_t rtp_timestamp,
const int16_t* audio,
@@ -104,12 +108,20 @@ int16_t AudioEncoderPcmA::EncodeCall(const int16_t* audio,
return WebRtcG711_EncodeA(audio, static_cast<int16_t>(input_len), encoded);
}
+int AudioEncoderPcmA::BytesPerSample() const {
+ return 1;
+}
+
int16_t AudioEncoderPcmU::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
return WebRtcG711_EncodeU(audio, static_cast<int16_t>(input_len), encoded);
}
+int AudioEncoderPcmU::BytesPerSample() const {
+ return 1;
+}
+
namespace {
template <typename T>
typename T::Config CreateConfig(const CodecInst& codec_inst) {

Powered by Google App Engine
This is Rietveld 408576698