summaryrefslogtreecommitdiff
path: root/libavformat/mp3dec.c
Commit message (Collapse)AuthorAge
* avformat/mp3dec: Ensure the buffer is large enough to avoid seeks from the ↵Michael Niedermayer2015-05-27
| | | | | | first frame search Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3: skip junk at the beginning of mp3 fileswm42015-05-27
| | | | | | | | | | | | | | | | | Apparently it can happen that a mp3 file has junk data between id3 tag and actual mp3 data. Skip this to avoid outputting nonsense timestamps. (Two packets had the same timestamps, because the mp3 parser failed to compute a frame duration.) In this case, the junk consisted of 1044 bytes of zero, which incidentally is the same size as normal mp3 frames in this stream. I suspect the mp3 was edited with some tool which wiped the Xing/LAME headers. Data near the end of the file suggests it was encoded with "LAME3.97", but the normal Xing/LAME headers are missing. So this could be "normal". mpg123 also attempts to skip at least 64KB of junk data by scanning for headers. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3: large id3 tags break concatenated file detectionwm42015-04-24
| | | | | | | | | | | | | | | | | | If the file size is much larger than what is indicated in the XING header, the demuxer assumes it's a concatenated file, and throws away the (presumably) incorrect duration information. Unfortunately, this also triggers if the id3 tags are very large (embedded pictures and such). Then the half-baked heuristic not only breaks the duration display, but also gapless audio. Fix it by subtracting the size of the headers (the check is off by some bytes, but that doesn't matter at all). Note that there could be an arbitrary amount of tags _after_ the mp3 data, but hopefully these are not too large to trigger the heuristic in practice. Also add a warning when this happens. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat: add AVFMT_FLAG_FASTSEEK, use it for mp3wm42015-04-22
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: make generic index mode the defaultwm42015-04-22
| | | | | | | It's the most useful mode, because it seeks accurately, and does not break features like gapless audio. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: allow enabling generic seek modewm42015-04-22
| | | | | | | | | | | | | | "-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>
* avformat/mp3dec: use the common mechanism for skipping sampleswm42015-04-22
| | | | | | | | | | 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>
* avformat/mp3dec: Adjust returned timestamp in the CBR seeking caseMichael Niedermayer2015-04-21
| | | | | | | | With this the returned timestamp should match the packet instead of the requested timestamp, which may lay between packets Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: fix gapless audio when seeking in CBR modewm42015-04-17
| | | | | | | | | | | | Removing a bunch of questionable hacks makes it work. These hacks apparently try to make concatenated mp3s with Lame headers seekable, which doesn't make too much sense anyway. The main change is that we trust the Xing header file size field now (the same field is used for seeking with Xing TOC). Note that a mp3 might contain an unknown number of unsupported additional tags, so we can't reliably compute this size manually. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: offset seek index to end of vbr headerswm42015-04-15
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Revert "avformat/mp3dec: offset seek index to end of id3v2 tag"wm42015-04-15
| | | | | | | | This reverts commit 8b76c0eb561b0313e2a27950fe9d2bc5e4780dd8. It was slightly incorrect; the next commit fixes it. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: Allow forcing the use of the xing TOC for CBR filesMichael Niedermayer2015-04-15
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/mp3dec: offset seek index to end of id3v2 tagwm42015-03-31
| | | | | | | The Xing index won't account for the id3 tag - it's relative to the headers. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit 'fe99c52fa99e44961a09cd1324aefd492b797fc8'Michael Niedermayer2015-03-11
|\ | | | | | | | | | | | | | | | | | | | | | | * commit 'fe99c52fa99e44961a09cd1324aefd492b797fc8': mp3: Properly use AVCodecContext API Conflicts: libavformat/mp3dec.c See: 6ad42b3e15478284321dd285acaf189a16590854 See: b851bc20c6931c084710e69f7eec30d8c1bdb68e Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3: Properly use AVCodecContext APIVittorio Giovara2015-03-11
| | | | | | | | | | | | | | Rather than having an unitialized context on the stack, allocate it with defaults and free it when unneeded. CC: libav-stable@libav.org
* | avformat/mp3dec: Check for avcodec_alloc_context3() failureMichael Niedermayer2015-02-26
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: properly allocate dummy AVCodecContextMichael Niedermayer2015-02-26
| | | | | | | | | | | | | | Fixes (harmless) use of uninitialized variable Found-by: jamrial Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '9deaec782810d098bca11c9332fab2d2f4c5fb78'Michael Niedermayer2015-02-11
|\| | | | | | | | | | | | | | | | | | | | | | | | | * commit '9deaec782810d098bca11c9332fab2d2f4c5fb78': lavf: move internal fields from public to internal context Conflicts: libavformat/avformat.h libavformat/internal.h libavformat/mux.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3: Tweak the probe scoresLuca Barbato2014-12-07
| | | | | | | | | | | | | | | | Having more than 10 consecutive frames decoded as mp3 should be considered a clear signal that the sample is mp3 and not mpegps. Reported-By: Florian Iragne <florian@iragne.fr> CC: libav-stable@libav.org
* | avformat/mp3dec: Name the dummy variable as what it is, to avoid confusionMichael Niedermayer2014-12-14
| | | | | | | | | | Found-by: nattyzs <nattyzs@163.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: avoid seeking to negative positionsMichael Niedermayer2014-11-18
| | | | | | | | | | | | Fixes Ticket4038 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: also accept Lavc as shortname to read delaysMichael Niedermayer2014-10-24
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '99143140dea12363af680d02e23cb42cfe191679'Michael Niedermayer2014-10-24
|\| | | | | | | | | | | | | | | | | | | | | * commit '99143140dea12363af680d02e23cb42cfe191679': mp3dec: fix reading the Xing tag Conflicts: libavformat/mp3dec.c See: 19ff479f694ddccc1fd1fa00eff94f96ca82671b Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3dec: fix reading the Xing tagAnton Khirnov2014-10-24
| | | | | | | | | | | | | | The quality scale field is only supposed to be present if the fourth bit is set. In practice, lame always sets it, but other tools might not. CC:libav-stable@libav.org
* | avformat/mp3dec: avoid early EOF with concatenated gapless mp3swm42014-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider a file created with something like: cat file1.mp3 file2.mp3 > result.mp3 Then if file2.mp3 has gapless information, result.mp3 would stop playing something in the middle. This happens because the gapless info directs the decoder to discard all samples after a certain position. To make matters worse, the gapless info of file2.mp3 will be used when playing the file1.mp3 part, because the gapless info is located at the end of the file. While handling concatenated gapless files correctly would be insane and a lot of effort (especially without scanning the whole file on opening), it's easy to prevent at least early EOF. Playback will happen to work, even if it's slightly broken. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: fix gapless audio supportwm42014-09-20
| | | | | | | | | | | | | | | | | | | | | | | | The code already had skipping of initial padding, but discarding trailing frame padding was missing. This is somewhat questionable, because it will make the decoder discard any data after the declared file size in the LAME header. But note that skipping full frames at the end of the stream is required. Encoders actually create such files. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: Improve seeking frame sync codeMichael Niedermayer2014-09-10
| | | | | | | | | | | | Fixes Ticket3884 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Ignore xing number of frames if the file is larger than indicated.Carl Eugen Hoyos2014-07-24
| | | | | | | | Fixes ticket #3777.
* | avformat/mp3dec: check the number of frames per buffer sizeMichael Niedermayer2014-05-12
| | | | | | | | | | | | Fixes misdetection of issue3327-libc-2.17.so Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '32d05934abc7427bb90380a4c1ab20a15fd7d821'Michael Niedermayer2014-04-18
|\| | | | | | | | | | | | | | | | | | | * commit '32d05934abc7427bb90380a4c1ab20a15fd7d821': mp3dec: decode more data from Info header Conflicts: libavformat/mp3dec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3dec: decode more data from Info headerAlessandro Ghedini2014-04-17
| | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | Merge commit 'fbd8e042107ec63e0ddf155588c59dcb76007641'Michael Niedermayer2014-04-17
|\| | | | | | | | | | | | | | | | | | | * commit 'fbd8e042107ec63e0ddf155588c59dcb76007641': mp3dec: move XING/Info and VBRI parsing into their own functions Conflicts: libavformat/mp3dec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3dec: move XING/Info and VBRI parsing into their own functionsAlessandro Ghedini2014-04-17
| | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | Merge commit '15c5a8d22d12d29a364ca2ab6438f1dee2fa08c7'Michael Niedermayer2014-03-24
|\| | | | | | | | | | | | | | | | | | | * commit '15c5a8d22d12d29a364ca2ab6438f1dee2fa08c7': mp3dec: export replaygain tags from ID3v2 Conflicts: Changelog Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3dec: export replaygain tags from ID3v2Anton Khirnov2014-03-24
| |
* | avformat/mp3dec: optimize mp3_seek() for dir < 0Michael Niedermayer2014-03-02
| | | | | | | | | | | | this minimizes the amount of protocol seeks and reading needed in that case Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: fix start time in light of initial skip samplesMichael Niedermayer2014-01-05
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: 4x faster probingMichael Niedermayer2013-11-09
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: perform seek resync in the correct directionMichael Niedermayer2013-10-25
| | | | | | | | | | | | | | Fixes seeking to the last frame in CBR files Fixes Ticket2773 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'c0779a67e85df856904ee6fab760c4233d4c2be5'Michael Niedermayer2013-09-12
|\| | | | | | | | | | | | | | | | | | | * commit 'c0779a67e85df856904ee6fab760c4233d4c2be5': mp3: add .mpa extension Conflicts: libavformat/mp3dec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mp3: add .mpa extensionVittorio Giovara2013-09-12
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | avformat/mp3dec: improve detection of mp3s with huge id3 tagsMichael Niedermayer2013-08-26
| | | | | | | | | | | | | | When a id3 tag is larger than the amount of space we will probe give it a score similar to what a .mp3 extension would have given it Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | mp3dec: make const tables static constMichael Niedermayer2013-08-05
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | mp3dec: detect CBR and use CBR axiom to seekMichael Niedermayer2013-07-08
| | | | | | | | | | | | | | This should also work reasonable with truncated and growing mp3s. Fixes Ticket2590 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: read TOC even if not all needed information is availableMichael Niedermayer2013-07-07
| | | | | | | | | | | | This fixes hyothetical bugs with parsing of elements after the TOC Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: read xing toc independant of usetoc, only skip filling ↵Michael Niedermayer2013-07-07
| | | | | | | | | | | | | | | | index if requested Fixes hypothetical parsing bug with -usetoc 0 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: Add usetoc option to allow dlsabling the use of the xing TOCMichael Niedermayer2013-07-06
| | | | | | | | | | | | | | The toc is inexact and not using it can thus make sense. Using it is faster though, thus the opposite can similarly makes sense Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'e0f8be6413b6a8d334d6052e610af32935c310af'Michael Niedermayer2013-05-05
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'e0f8be6413b6a8d334d6052e610af32935c310af': avformat: Add AVPROBE_SCORE_EXTENSION define and use where appropriate Conflicts: libavformat/ac3dec.c libavformat/avformat.h libavformat/avs.c libavformat/m4vdec.c libavformat/mov.c libavformat/mp3dec.c libavformat/mpeg.c libavformat/mpegvideodec.c libavformat/psxstr.c libavformat/pva.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avformat: Add AVPROBE_SCORE_EXTENSION define and use where appropriateDiego Biurrun2013-05-04
| |
* | Merge commit '505642f18276aed03278ac91b1f334ea888eac6a'Michael Niedermayer2013-04-19
|\| | | | | | | | | | | | | | | | | | | * commit '505642f18276aed03278ac91b1f334ea888eac6a': mp3dec: fallback to generic seeking when a TOC is not present Conflicts: libavformat/mp3dec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>