From d87fe2687fdc5b1cb9aaec957afadb56d207618f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 20 Sep 2014 13:48:05 +0200 Subject: avformat/mp3dec: fix gapless audio support The code already had skipping of initial padding, but discarding trailing frame padding was missing. This is somewhat questionable, because it will make the decoder discard any data after the declared file size in the LAME header. But note that skipping full frames at the end of the stream is required. Encoders actually create such files. Signed-off-by: Michael Niedermayer --- libavformat/mp3dec.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libavformat/mp3dec.c') diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 4872afc43c..639c78d405 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -219,6 +219,8 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, mp3->start_pad = v>>12; mp3-> end_pad = v&4095; st->skip_samples = mp3->start_pad + 528 + 1; + if (mp3->frames) + st->end_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf; if (!st->start_time) st->start_time = av_rescale_q(st->skip_samples, (AVRational){1, c->sample_rate}, -- cgit v1.2.3