From 23032b40da7824886809f93baffddd03525e0c19 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 5 Dec 2012 21:48:45 -0500 Subject: 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 --- src/opus_decoder.c | 10 ++++++++-- 1 file 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) -- cgit v1.2.1