Commit b8351ea0 authored by Baptiste Coudurier's avatar Baptiste Coudurier

avformat/audiointerleave: pad last audio frame

parent 24b24e14
......@@ -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,
......
93367bc02b8997b84224e7eb359cae8a *./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
0087ea968d20cc9192456fcd4c00019e *./tests/data/lavf/lavf.mxf
0e6d7a2a2c99a2a168114698be4c645f *./tests/data/lavf/lavf.mxf
561721 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0xf21b1b48
./tests/data/lavf/lavf.mxf CRC=0x96ff1b48
7754550ff6fe5895555610f586a15fc5 *./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
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