diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2018-03-21 14:14:36 -0700 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2018-08-21 11:50:06 -0700 |
commit | b8351ea0c335f082cba069accc7a3ec68f470ac9 (patch) | |
tree | ec2c02ada4999e0147963b810c776297175d2c59 /libavformat/audiointerleave.c | |
parent | 24b24e14d64730ed90ae00744f091c74f30cff7a (diff) | |
download | ffmpeg-b8351ea0c335f082cba069accc7a3ec68f470ac9.tar.gz |
avformat/audiointerleave: pad last audio frame
Diffstat (limited to 'libavformat/audiointerleave.c')
-rw-r--r-- | libavformat/audiointerleave.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index 6d4954befe..dea5d99821 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -81,15 +81,19 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st = s->streams[stream_index]; AudioInterleaveContext *aic = st->priv_data; int ret; - int size = FFMIN(av_fifo_size(aic->fifo), *aic->samples * aic->sample_size); + int frame_size = *aic->samples * aic->sample_size; + int size = FFMIN(av_fifo_size(aic->fifo), frame_size); if (!size || (!flush && size == av_fifo_size(aic->fifo))) return 0; - ret = av_new_packet(pkt, size); + ret = av_new_packet(pkt, frame_size); if (ret < 0) return ret; av_fifo_generic_read(aic->fifo, pkt->data, size, NULL); + if (size < pkt->size) + memset(pkt->data + size, 0, pkt->size - size); + pkt->dts = pkt->pts = aic->dts; pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base); pkt->stream_index = stream_index; @@ -99,7 +103,7 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, if (!*aic->samples) aic->samples = aic->samples_per_frame; - return size; + return pkt->size; } int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush, |