Cache the subtype of each DecoderInfo to make the Is* checks quicker.
Addresses a regression in the NetEq performance test.
# Added NOTRY due to android_arm64_rel being swamped.
NOTRY=True
BUG=chromium:651426
Review-Url: https://codereview.webrtc.org/2383723002
Cr-Commit-Position: refs/heads/master@{#14495}
diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.h b/webrtc/modules/audio_coding/neteq/decoder_database.h
index 3624856..6fd7a39 100644
--- a/webrtc/modules/audio_coding/neteq/decoder_database.h
+++ b/webrtc/modules/audio_coding/neteq/decoder_database.h
@@ -65,13 +65,20 @@
const SdpAudioFormat& GetFormat() const { return audio_format_; }
// Returns true if the decoder's format is comfort noise.
- bool IsComfortNoise() const;
+ bool IsComfortNoise() const {
+ RTC_DCHECK_EQ(!!cng_decoder_, subtype_ == Subtype::kComfortNoise);
+ return subtype_ == Subtype::kComfortNoise;
+ }
// Returns true if the decoder's format is DTMF.
- bool IsDtmf() const;
+ bool IsDtmf() const {
+ return subtype_ == Subtype::kDtmf;
+ }
// Returns true if the decoder's format is RED.
- bool IsRed() const;
+ bool IsRed() const {
+ return subtype_ == Subtype::kRed;
+ }
// Returns true if the decoder's format is named |name|.
bool IsType(const char* name) const;
@@ -97,6 +104,17 @@
int sample_rate_hz;
};
const rtc::Optional<CngDecoder> cng_decoder_;
+
+ enum class Subtype : int8_t {
+ kNormal,
+ kComfortNoise,
+ kDtmf,
+ kRed
+ };
+
+ static Subtype SubtypeFromFormat(const SdpAudioFormat& format);
+
+ const Subtype subtype_;
};
// Maximum value for 8 bits, and an invalid RTP payload type (since it is