summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-05 21:48:45 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-05 23:52:46 -0500
commit23032b40da7824886809f93baffddd03525e0c19 (patch)
tree0f3150906bc5695d562ac8674b35ac9a0009bf1c
parentbc482c406f3b8a12f776d318ff7dc0368cee9a13 (diff)
downloadopus-23032b40da7824886809f93baffddd03525e0c19.tar.gz
Fixes OPUS_GET_LAST_PACKET_DURATION
Calling PLC/FEC with a different size was not updating it Fixed a case of confusing indenting in the process of backporting. Conflicts: src/opus_decoder.c
-rw-r--r--src/opus_decoder.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 67158eaf..ad5f7470 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -721,6 +721,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
pcm += st->channels*ret;
pcm_count += ret;
} while (pcm_count < frame_size);
+ st->last_packet_duration = pcm_count;
return pcm_count;
} else if (len<0)
return OPUS_BAD_ARG;
@@ -736,14 +737,19 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
if (decode_fec)
{
+ int duration_copy;
int ret;
/* If no FEC can be present, run the PLC (recursive call) */
if (frame_size <= packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL);
/* Otherwise, run the PLC on everything except the size for which we might have FEC */
+ duration_copy = st->last_packet_duration;
ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL);
if (ret<0)
+ {
+ st->last_packet_duration = duration_copy;
return ret;
+ }
/* Complete with FEC */
st->mode = packet_mode;
st->bandwidth = packet_bandwidth;
@@ -753,8 +759,8 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
packet_frame_size, 1);
if (ret<0)
return ret;
- else
- return frame_size;
+ st->last_packet_duration = frame_size;
+ return frame_size;
}
tot_offset = 0;
if (count < 0)