1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/mp3dec: use the common mechanism for skipping samples

The mp2 seek test results change. Whether to skip samples if the file
had no LAME gapless tags was inconsistent. When seeking to the start
of the file, 529 samples were skipped, but when playing from start,
nothing was skipped. This commit changes the behavior on seek to skip
nothing.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
wm4 2015-04-22 12:24:37 +02:00 committed by Michael Niedermayer
parent 7dd8bf53bd
commit 066b92e91d
2 changed files with 6 additions and 9 deletions

View File

@ -228,13 +228,13 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
mp3->start_pad = v>>12; mp3->start_pad = v>>12;
mp3-> end_pad = v&4095; mp3-> end_pad = v&4095;
st->skip_samples = mp3->start_pad + 528 + 1; st->start_skip_samples = mp3->start_pad + 528 + 1;
if (mp3->frames) { if (mp3->frames) {
st->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf; st->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf;
st->last_discard_sample = mp3->frames * (int64_t)spf; st->last_discard_sample = mp3->frames * (int64_t)spf;
} }
if (!st->start_time) if (!st->start_time)
st->start_time = av_rescale_q(st->skip_samples, st->start_time = av_rescale_q(st->start_skip_samples,
(AVRational){1, c->sample_rate}, (AVRational){1, c->sample_rate},
st->time_base); st->time_base);
av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad); av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad);
@ -447,8 +447,6 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
ie = &st->index_entries[ret]; ie = &st->index_entries[ret];
} else { } else {
st->skip_samples = timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0;
return -1; return -1;
} }
@ -496,7 +494,6 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
} }
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;
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417
ret: 0 st:-1 flags:0 ts:-1.000000 ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 440 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417
ret: 0 st:-1 flags:1 ts: 1.894167 ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 1.880816 pts: 1.880816 pos: 30093 size: 418 ret: 0 st: 0 flags:1 dts: 1.880816 pts: 1.880816 pos: 30093 size: 418
ret: 0 st: 0 flags:0 ts: 0.788334 ret: 0 st: 0 flags:0 ts: 0.788334
@ -18,7 +18,7 @@ ret: 0 st: 0 flags:1 dts: 2.168163 pts: 2.168163 pos: 34690 size: 418
ret: 0 st:-1 flags:1 ts: 1.047503 ret: 0 st:-1 flags:1 ts: 1.047503
ret: 0 st: 0 flags:1 dts: 1.044898 pts: 1.044898 pos: 16718 size: 418 ret: 0 st: 0 flags:1 dts: 1.044898 pts: 1.044898 pos: 16718 size: 418
ret: 0 st: 0 flags:0 ts:-0.058330 ret: 0 st: 0 flags:0 ts:-0.058330
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 440 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417
ret: 0 st: 0 flags:1 ts: 2.835837 ret: 0 st: 0 flags:1 ts: 2.835837
ret: 0 st: 0 flags:1 dts: 2.821224 pts: 2.821224 pos: 45139 size: 418 ret: 0 st: 0 flags:1 dts: 2.821224 pts: 2.821224 pos: 45139 size: 418
ret: 0 st:-1 flags:0 ts: 1.730004 ret: 0 st:-1 flags:0 ts: 1.730004
@ -26,7 +26,7 @@ ret: 0 st: 0 flags:1 dts: 1.750204 pts: 1.750204 pos: 28003 size: 418
ret: 0 st:-1 flags:1 ts: 0.624171 ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.600816 pts: 0.600816 pos: 9613 size: 418 ret: 0 st: 0 flags:1 dts: 0.600816 pts: 0.600816 pos: 9613 size: 418
ret: 0 st: 0 flags:0 ts:-0.481662 ret: 0 st: 0 flags:0 ts:-0.481662
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 440 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417
ret: 0 st: 0 flags:1 ts: 2.412505 ret: 0 st: 0 flags:1 ts: 2.412505
ret: 0 st: 0 flags:1 dts: 2.403265 pts: 2.403265 pos: 38452 size: 418 ret: 0 st: 0 flags:1 dts: 2.403265 pts: 2.403265 pos: 38452 size: 418
ret: 0 st:-1 flags:0 ts: 1.306672 ret: 0 st:-1 flags:0 ts: 1.306672
@ -34,7 +34,7 @@ ret: 0 st: 0 flags:1 dts: 1.332245 pts: 1.332245 pos: 21315 size: 418
ret: 0 st:-1 flags:1 ts: 0.200839 ret: 0 st:-1 flags:1 ts: 0.200839
ret: 0 st: 0 flags:1 dts: 0.182857 pts: 0.182857 pos: 2925 size: 418 ret: 0 st: 0 flags:1 dts: 0.182857 pts: 0.182857 pos: 2925 size: 418
ret: 0 st: 0 flags:0 ts:-0.904994 ret: 0 st: 0 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 440 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 417
ret: 0 st: 0 flags:1 ts: 1.989173 ret: 0 st: 0 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 1.985306 pts: 1.985306 pos: 31764 size: 418 ret: 0 st: 0 flags:1 dts: 1.985306 pts: 1.985306 pos: 31764 size: 418
ret: 0 st:-1 flags:0 ts: 0.883340 ret: 0 st:-1 flags:0 ts: 0.883340