summaryrefslogtreecommitdiff
path: root/libavformat/mp3dec.c
Commit message (Collapse)AuthorAge
* avformat/mp3dec: improve junk skipping heuristicwm42015-10-20
| | | | | | | | | | | | | | | | | | | | | | Commit 2b3e9bbfb529e6bde238aeb511b55ebe461664c8 caused problems for a certain API user: https://code.google.com/p/chromium/issues/detail?id=537725 https://code.google.com/p/chromium/issues/detail?id=542032 The problem seems rather arbitrary, because if there's junk, anything can happen. In this case, the imperfect junk skipping just caused it to read different junk, from what I can see. We can improve the accuracy of junk detection by a lot by checking if 2 consecutive frames use the same configuration. While in theory it might be completely fine for the 1st frame to have a different format than the 2nd frame, it's exceedingly unlikely, and I can't think of a legitimate use-case. This is approximately the same mpg123 does for junk skipping. The set of compared header bits is the same as the libavcodec mp3 parser uses for similar purposes.
* avformat/mp3dec: Make MP3 seek fastAndy Wu2015-09-05
| | | | | | | | | | | | When AVFMT_FLAG_FAST_SEEK is specified, make MP3 seek operation as fast as possible. When no "-usetoc" is specified, the default operation is using TOC if available; otherwise, uses linear interpolation. This is useful when seeking a large MP3 file with no TOC available. One example is Podcast, many MP3 files are large, but no CBR/VBR tags. Most of them are actually CBR. Even in VBR cases, this option sacrifices the accuracy of playback time in exchange for responsiveness.
* avformat/mp3dec: Rename sync() function to avoid build failure on androidMichael Niedermayer2015-07-20
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: remove unused variableJames Almer2015-07-19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mp3dec: split position sync code outMichael Niedermayer2015-07-19
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: increase first_frames threshold for mp3,ac3Ganesh Ajjanagadde2015-07-18
| | | | | | | Fixes Ticket4723 Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'c1d647b15afa69fa70f999a9ddcb98346409fb4d'Michael Niedermayer2015-07-12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'c1d647b15afa69fa70f999a9ddcb98346409fb4d': mp3: Make the seek more robust Conflicts: libavformat/mp3dec.c Mostly not merged See: b6267901c466c482b2f1af3578b0a6d88265d144 and various later commits The bug is also not reproducable in FFmpeg Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * mp3: Make the seek more robustLuca Barbato2015-07-11
| | | | | | | | | | | | Try to parse up to 4 packets to find the closest packet. Reported-By: jan.schlueter@ofai.at
* | avformat/mp3dec: Remove the ID3v1 tag removial codeMichael Niedermayer2015-06-24
| | | | | | | | | | | | | | | | The code is simply broken, the read packets are not aligned to the mp3 frames, the file end or the id3 tag thus this simply cannot reliably find the ID3v1 tag to remove it Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Remove a few occurences of "long long" from the libraries.Carl Eugen Hoyos2015-06-13
| |
* | 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>