summaryrefslogtreecommitdiffstats
path: root/libavformat/mp3dec.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/mp3dec: require 90% of a file to be mp3 if only 1 mp3 frame is ↵Michael Niedermayer2018-05-201-1/+1
| | | | | | | | found in sequence This eliminates several low score detections of non mp3 files Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: Require 50% of the file to be mp3 frames in the ↵Michael Niedermayer2018-05-201-1/+1
| | | | | | | | maxframes>200 probing test This corrects several misdetections of large files Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: Require probing data to be 50% mp3 frames for low score ↵Michael Niedermayer2018-05-201-3/+7
| | | | | | | | | probing to succeed This massively reduces the detection of random data as low score mp3 It may improve security by making it harder to read non multimedia data Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: use FFABS to instead of absSteven Liu2017-11-201-2/+2
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/mp3dec: Fix definition of MIDDLE_BITSIngo Brückl2017-10-041-1/+1
| | | | | | | The number of bits from bit #m to #n is n - m plus 1. Signed-off-by: Ingo Brückl <ib@wupperonline.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'James Almer2017-03-211-1/+1
|\ | | | | | | | | | | | | * commit '83548fe894cdb455cc127f754d09905b6d23c173': lavf: fix usage of AVIOContext.seekable Merged-by: James Almer <jamrial@gmail.com>
| * mp3dec: read the initial/trailing padding from the LAME tagAnton Khirnov2016-07-151-2/+4
| |
| * Mark read-only tables as staticDiego Biurrun2016-05-051-1/+1
| |
* | avformat: Ignore ID3v2 tags if other tags are present e.g. vorbisPaul Arzelier2017-01-281-0/+3
| | | | | | | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mp3dec: fix msan warning when verifying mpa headerChris Cunningham2016-12-151-1/+2
| | | | | | | | | | | | | | | | MPEG Audio frame header must be 4 bytes. If we fail to read 4 bytes bail early to avoid Use-of-uninitialized-value msan error. Reference https://crbug.com/666874. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mp3dec: Increase probe score slightly when the whole data from ↵Michael Niedermayer2016-06-111-1/+6
| | | | | | | | | | | | | | | | begin to end is mp3 Improves score for 1000-frames-of-noise-encoded-with-lame.mp3 without file extension Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '9200514ad8717c63f82101dc394f4378854325bf'Derek Buitenhuis2016-04-101-3/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * lavf: replace AVStream.codec with AVStream.codecparAnton Khirnov2016-02-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, AVStream contains an embedded AVCodecContext instance, which is used by demuxers to export stream parameters to the caller and by muxers to receive stream parameters from the caller. It is also used internally as the codec context that is passed to parsers. In addition, it is also widely used by the callers as the decoding (when demuxer) or encoding (when muxing) context, though this has been officially discouraged since Libav 11. There are multiple important problems with this approach: - the fields in AVCodecContext are in general one of * stream parameters * codec options * codec state However, it's not clear which ones are which. It is consequently unclear which fields are a demuxer allowed to set or a muxer allowed to read. This leads to erratic behaviour depending on whether decoding or encoding is being performed or not (and whether it uses the AVStream embedded codec context). - various synchronization issues arising from the fact that the same context is used by several different APIs (muxers/demuxers, parsers, bitstream filters and encoders/decoders) simultaneously, with there being no clear rules for who can modify what and the different processes being typically delayed with respect to each other. - avformat_find_stream_info() making it necessary to support opening and closing a single codec context multiple times, thus complicating the semantics of freeing various allocated objects in the codec context. Those problems are resolved by replacing the AVStream embedded codec context with a newly added AVCodecParameters instance, which stores only the stream parameters exported by the demuxers or read by the muxers.
* | lavf/mp3dec: avoid printing useless message in default log levelMoritz Barsnick2016-03-081-1/+1
| | | | | | | | | | | | | | | | "Skipping 0 bytes of junk" is useless to the user, and essentially indicates a NOP. At 0 bytes, this message is now pushed back to the verbose log level. Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
* | lavf/mp3: Properly check return values of seeks and reads while reading the ↵Derek Buitenhuis2016-02-281-10/+39
| | | | | | | | | | | | | | | | | | header Fixes large amounts of seeking past EOF, which could be extremely slow over a network. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* | avformat/mp3dec: Remove unused variableMichael Niedermayer2016-01-011-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '72d658766e6ccf198317dffd6499c5e288847a1c'Hendrik Leppkes2016-01-011-11/+6
|\ \ | |/ | | | | | | | | | | * commit '72d658766e6ccf198317dffd6499c5e288847a1c': mp3dec: replace avpriv_mpa_decode_header with avpriv_mpegaudio_decode_header Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * mp3dec: replace avpriv_mpa_decode_header with avpriv_mpegaudio_decode_headerAnton Khirnov2015-12-121-11/+6
| | | | | | | | | | The latter does not require a full AVCodecContext and still provides all the functionality needed here.
* | Merge commit '955aec3c7c7be39b659197e1ec379a09f2b7c41c'Hendrik Leppkes2016-01-011-6/+5
|\ \ | |/ | | | | | | | | | | * commit '955aec3c7c7be39b659197e1ec379a09f2b7c41c': mpegaudiodecheader: check the header in avpriv_mpegaudio_decode_header Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * mpegaudiodecheader: check the header in avpriv_mpegaudio_decode_headerAnton Khirnov2015-12-121-5/+7
| | | | | | | | | | | | Almost all the places from which this function is called already check the header manually and in the two that don't (the mp3 muxer) the check should not cause any problems.
| * mp3: Forward seeking errorsLuca Barbato2015-07-131-1/+3
| | | | | | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | avformat: use AV_OPT_TYPE_BOOL in a bunch of placesClément Bœsch2015-12-041-1/+1
| |
* | avformat/mp3dec: prefer "fast_seek" to TOC seek for CBR files.Chris Cunningham2015-12-021-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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 <nfxjfg@googlemail.com>
* | avformat/mp3dec: improve junk skipping heuristicwm42015-10-201-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-051-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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-201-2/+2
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/mp3dec: remove unused variableJames Almer2015-07-191-1/+0
| | | | | | | | Signed-off-by: James Almer <jamrial@gmail.com>
* | avformat/mp3dec: split position sync code outMichael Niedermayer2015-07-191-37/+45
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat: increase first_frames threshold for mp3,ac3Ganesh Ajjanagadde2015-07-181-1/+1
| | | | | | | | | | | | | | Fixes Ticket4723 Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit 'c1d647b15afa69fa70f999a9ddcb98346409fb4d'Michael Niedermayer2015-07-121-9/+13
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-111-11/+65
| | | | | | | | | | | | 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-241-7/+0
| | | | | | | | | | | | | | | | 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-131-1/+1
| |
* | avformat/mp3dec: Ensure the buffer is large enough to avoid seeks from the ↵Michael Niedermayer2015-05-271-0/+2
| | | | | | | | | | | | first frame search Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3: skip junk at the beginning of mp3 fileswm42015-05-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-221-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: make generic index mode the defaultwm42015-04-221-1/+1
| | | | | | | | | | | | | | 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-221-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "-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-221-5/+2
| | | | | | | | | | | | | | | | | | | | 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-211-0/+6
| | | | | | | | | | | | | | | | 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-171-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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-151-0/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Revert "avformat/mp3dec: offset seek index to end of id3v2 tag"wm42015-04-151-5/+5
| | | | | | | | | | | | | | | | 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-151-0/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: offset seek index to end of id3v2 tagwm42015-03-311-5/+5
| | | | | | | | | | | | | | 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-111-2/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | * 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-111-2/+9
| | | | | | | | | | | | | | 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-261-0/+3
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mp3dec: properly allocate dummy AVCodecContextMichael Niedermayer2015-02-261-2/+3
| | | | | | | | | | | | | | Fixes (harmless) use of uninitialized variable Found-by: jamrial Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
OpenPOWER on IntegriCloud