From 5e6ce28dabe002a6130f17b59c454bdee33088f7 Mon Sep 17 00:00:00 2001 From: Chris Cunningham Date: Tue, 1 Dec 2015 10:54:38 -0800 Subject: avformat/mp3dec: prefer "fast_seek" to TOC seek for CBR files. "Fast seek" uses linear interpolation to find the position of the requested seek time. For CBR this is more direct than using the mp3 TOC and bypassing the TOC avoids problems with TOC precision. (see https://crbug.com/545914#c13) For VBR, fast seek is not precise, so continue to prefer the TOC when available (the lesser of two evils). Also, some re-ordering of the logic in mp3_seek to simplify and give usetoc=1 precedence over fastseek flag. Signed-off-by: wm4 --- libavformat/seek-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libavformat/seek-test.c') diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c index 1926f2108d..bfd06db3bb 100644 --- a/libavformat/seek-test.c +++ b/libavformat/seek-test.c @@ -56,7 +56,7 @@ static void ts_str(char buffer[60], int64_t ts, AVRational base) int main(int argc, char **argv) { const char *filename; - AVFormatContext *ic = NULL; + AVFormatContext *ic = avformat_alloc_context(); int i, ret, stream_id; int j; int64_t timestamp; @@ -76,8 +76,10 @@ int main(int argc, char **argv) frame_count = atoi(argv[i+1]); } else if(!strcmp(argv[i], "-duration")){ duration = atoi(argv[i+1]); - } else if(!strcmp(argv[i], "-usetoc")) { - av_dict_set(&format_opts, "usetoc", argv[i+1], 0); + } else if(!strcmp(argv[i], "-fastseek")) { + if (atoi(argv[i+1])) { + ic->flags |= AVFMT_FLAG_FAST_SEEK; + } } else { argc = 1; } -- cgit v1.2.3