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

Unified Diff: webrtc/modules/audio_coding/codecs/opus/opus_interface.c

Issue 1334303005: Returning correct duration estimate on Opus DTX packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fixing a silly mistake in unittest Created 5 years, 3 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/opus/opus_interface.c
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
index 4f6e22f77d021a7161f2977f8404c34af43208a3..2ac53736650907ca4d54cfb1e1ccc42646f1116a 100644
--- a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
+++ b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
@@ -359,6 +359,12 @@ int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
int WebRtcOpus_DurationEst(OpusDecInst* inst,
const uint8_t* payload,
size_t payload_length_bytes) {
+ if (payload_length_bytes == 0) {
+ // WebRtcOpus_Decode calls PLC when payload length is zero. So we return
+ // PLC duration correspondingly.
+ return WebRtcOpus_PlcDuration(inst);
+ }
+
int frames, samples;
frames = opus_packet_get_nb_frames(payload, (opus_int32)payload_length_bytes);
if (frames < 0) {
@@ -373,6 +379,15 @@ int WebRtcOpus_DurationEst(OpusDecInst* inst,
return samples;
}
+int WebRtcOpus_PlcDuration(OpusDecInst* inst) {
+ /* The number of samples we ask for is |number_of_lost_frames| times
+ * |prev_decoded_samples_|. Limit the number of samples to maximum
+ * |kWebRtcOpusMaxFrameSizePerChannel|. */
+ const int plc_samples = inst->prev_decoded_samples;
+ return (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel) ?
+ plc_samples : kWebRtcOpusMaxFrameSizePerChannel;
+}
+
int WebRtcOpus_FecDurationEst(const uint8_t* payload,
size_t payload_length_bytes) {
int samples;

Powered by Google App Engine
This is Rietveld 408576698