[FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode
-usetoc 2 now invokes the generic seek and indexing mode. This mode skips data until the seek target is reached, and this is exact. It also makes gapless audio actually work if a seek past the start of the file is involved. --- Strange option value. On the other hand, it will be made default, so this option will generally be used only to select the old seek modes. But in general, libavformat should probably have something to switch between slow/accurate and fast/inaccurate seeking. --- libavformat/mp3dec.c | 12 +--- tests/fate/gapless.mak | 5 +++-- tests/ref/fate/gapless-mp3 | 5 - tests/ref/fate/gapless-mp3-cbr | 5 + 4 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 tests/ref/fate/gapless-mp3 create mode 100644 tests/ref/fate/gapless-mp3-cbr diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 008cb23..8a4dfbd 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration { int i; MP3DecContext *mp3 = s-priv_data; -int fill_index = mp3-usetoc duration 0; +int fill_index = mp3-usetoc == 1 duration 0; if (!filesize !(filesize = avio_size(s-pb))) { @@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s) int ret; int i; +if (mp3-usetoc 0) +mp3-usetoc = 0; + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int64_t best_pos; int best_score; +if (mp3-usetoc == 2) +return -1; // generic index code + if ( mp3-is_cbr - (mp3-usetoc = 0 || !mp3-xing_toc) + (mp3-usetoc == 0 || !mp3-xing_toc) st-duration 0 mp3-header_filesize s-internal-data_offset mp3-frames) { @@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, } static const AVOption options[] = { -{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, +{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM}, { NULL }, }; diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak index a09dac6..6860d74 100644 --- a/tests/fate/gapless.mak +++ b/tests/fate/gapless.mak @@ -1,5 +1,6 @@ -FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-notoc -fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 -usetoc 1 +FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-cbr fate-gapless-mp3-notoc +fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 -usetoc 2 +fate-gapless-mp3-cbr: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 -usetoc 1 fate-gapless-mp3-notoc: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 -usetoc 0 FATE_GAPLESS = $(FATE_GAPLESS-yes) diff --git a/tests/ref/fate/gapless-mp3 b/tests/ref/fate/gapless-mp3 deleted file mode 100644 index 984ae84..000 --- a/tests/ref/fate/gapless-mp3 +++ /dev/null @@ -1,5 +0,0 @@ -d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3.out-1 -c96c3ae7bd3300fd2f4debac222de5b7 -3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3.out-2 -c96c3ae7bd3300fd2f4debac222de5b7 -70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3.out-3 diff --git a/tests/ref/fate/gapless-mp3-cbr b/tests/ref/fate/gapless-mp3-cbr new file mode 100644 index 000..7ecc328 --- /dev/null +++ b/tests/ref/fate/gapless-mp3-cbr @@ -0,0 +1,5 @@ +d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-cbr.out-1 +c96c3ae7bd3300fd2f4debac222de5b7 +3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-cbr.out-2 +c96c3ae7bd3300fd2f4debac222de5b7 +70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3-cbr.out-3 -- 2.1.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode
On Tue, Apr 21, 2015 at 09:33:52PM +0200, wm4 wrote: -usetoc 2 now invokes the generic seek and indexing mode. This mode skips data until the seek target is reached, and this is exact. It also makes gapless audio actually work if a seek past the start of the file is involved. --- Strange option value. On the other hand, it will be made default, so this option will generally be used only to select the old seek modes. But in general, libavformat should probably have something to switch between slow/accurate and fast/inaccurate seeking. --- libavformat/mp3dec.c | 12 +--- tests/fate/gapless.mak | 5 +++-- tests/ref/fate/gapless-mp3 | 5 - tests/ref/fate/gapless-mp3-cbr | 5 + 4 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 tests/ref/fate/gapless-mp3 create mode 100644 tests/ref/fate/gapless-mp3-cbr diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 008cb23..8a4dfbd 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration { int i; MP3DecContext *mp3 = s-priv_data; -int fill_index = mp3-usetoc duration 0; +int fill_index = mp3-usetoc == 1 duration 0; if (!filesize !(filesize = avio_size(s-pb))) { @@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s) int ret; int i; +if (mp3-usetoc 0) +mp3-usetoc = 0; + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int64_t best_pos; int best_score; +if (mp3-usetoc == 2) +return -1; // generic index code + if ( mp3-is_cbr - (mp3-usetoc = 0 || !mp3-xing_toc) + (mp3-usetoc == 0 || !mp3-xing_toc) st-duration 0 mp3-header_filesize s-internal-data_offset mp3-frames) { @@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, } static const AVOption options[] = { -{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, +{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM}, Can you use AV_OPT_TYPE_CONST for the different special values? (and document it) [...] -- Clément B. pgp_42L80KHgT.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode
On Tue, 21 Apr 2015 22:07:07 +0200 Clément Bœsch u...@pkh.me wrote: On Tue, Apr 21, 2015 at 09:33:52PM +0200, wm4 wrote: -usetoc 2 now invokes the generic seek and indexing mode. This mode skips data until the seek target is reached, and this is exact. It also makes gapless audio actually work if a seek past the start of the file is involved. --- Strange option value. On the other hand, it will be made default, so this option will generally be used only to select the old seek modes. But in general, libavformat should probably have something to switch between slow/accurate and fast/inaccurate seeking. --- libavformat/mp3dec.c | 12 +--- tests/fate/gapless.mak | 5 +++-- tests/ref/fate/gapless-mp3 | 5 - tests/ref/fate/gapless-mp3-cbr | 5 + 4 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 tests/ref/fate/gapless-mp3 create mode 100644 tests/ref/fate/gapless-mp3-cbr diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 008cb23..8a4dfbd 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration { int i; MP3DecContext *mp3 = s-priv_data; -int fill_index = mp3-usetoc duration 0; +int fill_index = mp3-usetoc == 1 duration 0; if (!filesize !(filesize = avio_size(s-pb))) { @@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s) int ret; int i; +if (mp3-usetoc 0) +mp3-usetoc = 0; + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int64_t best_pos; int best_score; +if (mp3-usetoc == 2) +return -1; // generic index code + if ( mp3-is_cbr - (mp3-usetoc = 0 || !mp3-xing_toc) + (mp3-usetoc == 0 || !mp3-xing_toc) st-duration 0 mp3-header_filesize s-internal-data_offset mp3-frames) { @@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, } static const AVOption options[] = { -{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, +{ usetoc, use table of contents, offsetof(MP3DecContext, usetoc), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM}, Can you use AV_OPT_TYPE_CONST for the different special values? (and document it) [...] I'm not sure if it's a good idea to set this in stone. I'd much rather have something similar to AVFMT_FLAG_IGNIDX, which can be checked by all demuxers. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel