Commit ecf34e8f authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/mp3dec: Adjust returned timestamp in the CBR seeking case

With this the returned timestamp should match the packet instead of
the requested timestamp, which may lay between  packets
Reviewed-by: 's avatarwm4 <nfxjfg@googlemail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 30ba28fe
...@@ -489,6 +489,12 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, ...@@ -489,6 +489,12 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
ret = avio_seek(s->pb, best_pos, SEEK_SET); ret = avio_seek(s->pb, best_pos, SEEK_SET);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (mp3->is_cbr && ie == &ie1) {
int frame_duration = av_rescale(st->duration, 1, mp3->frames);
ie1.timestamp = frame_duration * av_rescale(best_pos - s->internal->data_offset, mp3->frames, mp3->header_filesize);
}
ff_update_cur_dts(s, st, ie->timestamp); ff_update_cur_dts(s, st, ie->timestamp);
st->skip_samples = ie->timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0; st->skip_samples = ie->timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0;
return 0; return 0;
......
...@@ -2,4 +2,4 @@ d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-notoc.out-1 ...@@ -2,4 +2,4 @@ d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-notoc.out-1
c96c3ae7bd3300fd2f4debac222de5b7 c96c3ae7bd3300fd2f4debac222de5b7
3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-notoc.out-2 3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-notoc.out-2
c96c3ae7bd3300fd2f4debac222de5b7 c96c3ae7bd3300fd2f4debac222de5b7
e82eaed507ce3f7f6199918159e1ddd7 *tests/data/fate/gapless-mp3-notoc.out-3 92e37f050ad4fc817730c8af17ee6d1b *tests/data/fate/gapless-mp3-notoc.out-3
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