Allow NetEQ to use real packet durations.
This is a copy of http://review.webrtc.org/864014/
This adds a FuncDurationEst to each codec instance which estimates
the duration of a packet given the packet contents and the duration
of the previous packet. By default, this simply returns the
duration of the previous packet (which is what is currently assumed
to be the duration of all future packets). This patch also provides
an initial implementation of this function for G.711 which returns
the actual number of samples in the packet.
BUG=issue1015
Review URL: https://webrtc-codereview.appspot.com/935016
git-svn-id: http://webrtc.googlecode.com/svn/trunk@3129 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq/signal_mcu.c b/webrtc/modules/audio_coding/neteq/signal_mcu.c
index 2cccf1a..e51d5f2 100644
--- a/webrtc/modules/audio_coding/neteq/signal_mcu.c
+++ b/webrtc/modules/audio_coding/neteq/signal_mcu.c
@@ -32,6 +32,27 @@
/*
+ * Update the frame size, if we can.
+ */
+static int WebRtcNetEQ_UpdatePackSizeSamples(MCUInst_t* inst, int buffer_pos,
+ int payload_type,
+ int pack_size_samples) {
+ if (buffer_pos >= 0) {
+ int codec_pos;
+ codec_pos = WebRtcNetEQ_DbGetCodec(&inst->codec_DB_inst, payload_type);
+ if (codec_pos >= 0) {
+ codec_pos = inst->codec_DB_inst.position[codec_pos];
+ if (codec_pos >= 0) {
+ return WebRtcNetEQ_PacketBufferGetPacketSize(
+ &inst->PacketBuffer_inst, buffer_pos,
+ &inst->codec_DB_inst, codec_pos, pack_size_samples);
+ }
+ }
+ }
+ return pack_size_samples;
+}
+
+/*
* Signals the MCU that DSP status data is available.
*/
int WebRtcNetEQ_SignalMcu(MCUInst_t *inst)
@@ -223,7 +244,8 @@
}
/* Check packet buffer */
- w32_bufsize = WebRtcNetEQ_PacketBufferGetSize(&inst->PacketBuffer_inst);
+ w32_bufsize = WebRtcNetEQ_PacketBufferGetSize(&inst->PacketBuffer_inst,
+ &inst->codec_DB_inst);
if (dspInfo.lastMode == MODE_SUCCESS_ACCELERATE || dspInfo.lastMode
== MODE_LOWEN_ACCELERATE || dspInfo.lastMode == MODE_SUCCESS_PREEMPTIVE
@@ -254,6 +276,10 @@
}
#endif
+ /* Update the frame size, if we can. */
+ inst->PacketBuffer_inst.packSizeSamples =
+ WebRtcNetEQ_UpdatePackSizeSamples(inst, i_bufferpos, payloadType,
+ inst->PacketBuffer_inst.packSizeSamples);
/* Update statistics and make decision */
uw16_instr = WebRtcNetEQ_BufstatsDecision(&inst->BufferStat_inst,
inst->PacketBuffer_inst.packSizeSamples, w32_bufsize, dspInfo.playedOutTS,
@@ -350,7 +376,9 @@
}
/* Set the packet size by guessing */
- inst->PacketBuffer_inst.packSizeSamples = inst->timestampsPerCall * 3;
+ inst->PacketBuffer_inst.packSizeSamples =
+ WebRtcNetEQ_UpdatePackSizeSamples(inst, i_bufferpos, payloadType,
+ inst->timestampsPerCall * 3);
WebRtcNetEQ_ResetAutomode(&(inst->BufferStat_inst.Automode_inst),
inst->PacketBuffer_inst.maxInsertPositions);
@@ -695,7 +723,10 @@
}
prevSeqNo = inst->PacketBuffer_inst.seqNumber[i_bufferpos];
}
-
+ /* Update the frame size, if we can. */
+ inst->PacketBuffer_inst.packSizeSamples =
+ WebRtcNetEQ_UpdatePackSizeSamples(inst, i_bufferpos,
+ payloadType, inst->PacketBuffer_inst.packSizeSamples);
}
while ((totalTS < wantedNoOfTimeStamps) && (nextSeqNoAvail == 1));
}