summaryrefslogtreecommitdiff
path: root/libavformat/mp3dec.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2015-04-22 12:24:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-22 14:33:02 +0200
commitc3a73666ad1eee93e49f25efae30fda5556c228e (patch)
tree210978d23d2b348ed4a096c12c77f17f92a56d5c /libavformat/mp3dec.c
parent066b92e91d678f500c64c947d86cd8bf73ee6c61 (diff)
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. Change the fate-gapless-mp3 test to use the new mode, and move the old one to fate-gapless-mp3-toc (since the test forces use of the Xing TOC). The new mode has a different result for the seek - this result is actually correct. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mp3dec.c')
-rw-r--r--libavformat/mp3dec.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 008cb23c12..8a4dfbd7bb 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 },
};