Bug-Id: 909
CC: [email protected]
---
libavcodec/opusdec.c | 46 ++++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index acae6e1..ad28521 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -447,6 +447,28 @@ finish:
return output_samples;
}
+static av_cold void opus_decode_flush(AVCodecContext *ctx)
+{
+ OpusContext *c = ctx->priv_data;
+ int i;
+
+ for (i = 0; i < c->nb_streams; i++) {
+ OpusStreamContext *s = &c->streams[i];
+
+ memset(&s->packet, 0, sizeof(s->packet));
+ s->delayed_samples = 0;
+
+ if (s->celt_delay)
+ av_audio_fifo_drain(s->celt_delay,
av_audio_fifo_size(s->celt_delay));
+ avresample_close(s->avr);
+
+ av_audio_fifo_drain(c->sync_buffers[i],
av_audio_fifo_size(c->sync_buffers[i]));
+
+ ff_silk_flush(s->silk);
+ ff_celt_flush(s->celt);
+ }
+}
+
static int opus_decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
@@ -539,11 +561,13 @@ static int opus_decode_packet(AVCodecContext *avctx, void
*data,
ret = ff_opus_parse_packet(&s->packet, buf, buf_size, i !=
c->nb_streams - 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet
header.\n");
+ opus_decode_flush(avctx);
return ret;
}
if (coded_samples != s->packet.frame_count *
s->packet.frame_duration) {
av_log(avctx, AV_LOG_ERROR,
"Mismatching coded sample count in substream %d.\n", i);
+ opus_decode_flush(avctx);
return AVERROR_INVALIDDATA;
}
@@ -600,28 +624,6 @@ static int opus_decode_packet(AVCodecContext *avctx, void
*data,
return avpkt->size;
}
-static av_cold void opus_decode_flush(AVCodecContext *ctx)
-{
- OpusContext *c = ctx->priv_data;
- int i;
-
- for (i = 0; i < c->nb_streams; i++) {
- OpusStreamContext *s = &c->streams[i];
-
- memset(&s->packet, 0, sizeof(s->packet));
- s->delayed_samples = 0;
-
- if (s->celt_delay)
- av_audio_fifo_drain(s->celt_delay,
av_audio_fifo_size(s->celt_delay));
- avresample_close(s->avr);
-
- av_audio_fifo_drain(c->sync_buffers[i],
av_audio_fifo_size(c->sync_buffers[i]));
-
- ff_silk_flush(s->silk);
- ff_celt_flush(s->celt);
- }
-}
-
static av_cold int opus_decode_close(AVCodecContext *avctx)
{
OpusContext *c = avctx->priv_data;
--
2.5.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel