Mercurial > libavformat.hg
changeset 4534:cb5bcf4bfe15 libavformat
check fifo size and realloc if needed
author | bcoudurier |
---|---|
date | Wed, 18 Feb 2009 04:42:31 +0000 |
parents | 23ec193c3e0a |
children | be04cfe425ed |
files | audiointerleave.c |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/audiointerleave.c Wed Feb 18 02:57:41 2009 +0000 +++ b/audiointerleave.c Wed Feb 18 04:42:31 2009 +0000 @@ -61,6 +61,7 @@ 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 @@ 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