diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-18 04:42:31 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-18 04:42:31 +0000 |
commit | 50ced76f4b2f58306af99f000c5c7a26aa6938b5 (patch) | |
tree | c92e994dd990e0c2f91802468189cd00af80adcc | |
parent | ef33facdfe6400df858528ef3d196099f4f31c77 (diff) | |
download | ffmpeg-50ced76f4b2f58306af99f000c5c7a26aa6938b5.tar.gz |
check fifo size and realloc if needed
Originally committed as revision 17420 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/audiointerleave.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index 9434ed2688..d811f21357 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -61,6 +61,7 @@ int ff_audio_interleave_init(AVFormatContext *s, aic->samples = aic->samples_per_frame; aic->time_base = time_base; + aic->fifo_size = 100* *aic->samples; av_fifo_init(&aic->fifo, 100 * *aic->samples); } } @@ -103,6 +104,12 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt AVStream *st = s->streams[pkt->stream_index]; AudioInterleaveContext *aic = st->priv_data; if (st->codec->codec_type == CODEC_TYPE_AUDIO) { + unsigned new_size = av_fifo_size(&aic->fifo) + pkt->size; + if (new_size > aic->fifo_size) { + if (av_fifo_realloc2(&aic->fifo, new_size) < 0) + return -1; + aic->fifo_size = new_size; + } av_fifo_generic_write(&aic->fifo, pkt->data, pkt->size, NULL); } else { // rewrite pts and dts to be decoded time line position |