Commit 672ad6f5 authored by bcoudurier's avatar bcoudurier

check fifo size and realloc if needed

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17420 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent bd8850b3
...@@ -61,6 +61,7 @@ int ff_audio_interleave_init(AVFormatContext *s, ...@@ -61,6 +61,7 @@ int ff_audio_interleave_init(AVFormatContext *s,
aic->samples = aic->samples_per_frame; aic->samples = aic->samples_per_frame;
aic->time_base = time_base; aic->time_base = time_base;
aic->fifo_size = 100* *aic->samples;
av_fifo_init(&aic->fifo, 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 ...@@ -103,6 +104,12 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
AVStream *st = s->streams[pkt->stream_index]; AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data; AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == CODEC_TYPE_AUDIO) { 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); av_fifo_generic_write(&aic->fifo, pkt->data, pkt->size, NULL);
} else { } else {
// rewrite pts and dts to be decoded time line position // rewrite pts and dts to be decoded time line position
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment