summaryrefslogtreecommitdiff
path: root/libavformat/mp3dec.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/mp3dec: remove a call to avio_tell()Zhao Zhili2022-10-081-5/+4
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/mp3dec: avoid seek back and forthZhao Zhili2022-10-081-9/+7
| | | | | | | | | | avio_seek() is called inside check(). Seeking to 'off' then seeking to 'off + i' is unefficient, and it can loop 64 * 1024 times in the worst case. When probe a malformed file over HTTP, it looks like stucked forvever. ffio_ensure_seekback() doesn't solve the issue when the stream is seekable but slow. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/demux: Add new demux.h headerAndreas Rheinhardt2022-05-101-2/+1
| | | | | | And move those stuff already in demuxer-only files to it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Avoid allocation for AVStreamInternalAndreas Rheinhardt2021-09-171-8/+12
| | | | | | | | | | Do this by allocating AVStream together with the data that is currently in AVStreamInternal; or rather: Put AVStream at the beginning of a new structure called FFStream (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVStreamInternal altogether. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Avoid allocation for AVFormatInternalAndreas Rheinhardt2021-09-171-6/+8
| | | | | | | | | | | | | Do this by allocating AVFormatContext together with the data that is currently in AVFormatInternal; or rather: Put AVFormatContext at the beginning of a new structure called FFFormatContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVFormatInternal altogether. The biggest simplifications occured in avformat_alloc_context(), where one can now simply call avformat_free_context() in case of errors. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mp3dec: Simplify checking for no-metadataAndreas Rheinhardt2021-09-171-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mp3dec: Avoid calling avio_tell() multiple timesAndreas Rheinhardt2021-09-171-2/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-251-1/+1
| | | | | | | | | | | | | | Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/mp3dec: avoid avcodec.h dependencyAnton Khirnov2021-06-101-1/+1
|
* avformat/utils: make ff_update_cur_dts() sharedJames Almer2021-06-091-1/+1
| | | | | | libavdevice needs it. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: move AVStream.{parser,need_parsing} to AVStreamInternalJames Almer2021-05-071-1/+1
| | | | | | | Those are private fields, no reason to have them exposed in a public header. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavf: move AVStream.*index_entries* to AVStreamInternalAnton Khirnov2020-10-281-3/+3
| | | | | | | Those are private fields, no reason to have them exposed in a public header. Since there are some (semi-)public fields located after these, even though this section is supposed to be private, keep some dummy padding there until the next major bump to preserve ABI compatibility.
* lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternalAnton Khirnov2020-10-281-4/+4
| | | | | Those are private fields, no reason to have them exposed in a public header.
* Revert "lavf/mp3dec: don't adjust start time; packets are not adjusted."Michael Niedermayer2020-06-081-0/+4
| | | | | | | | | This causes regressions in end to end timestamps with mp3s and ffmpeg. The revert is to avoid this regression in the 4.3 release See: [FFmpeg-devel] [PATCH] Don't adjust start time for MP3 files; packets are not adjusted. This reverts commit 460132c9980f8a1f501a1f69477bca49e1641233.
* lavf/mp3dec: don't adjust start time; packets are not adjusted.Dale Curtis2020-05-271-4/+0
| | | | | | | | | | | | | | | | | | | | 7546ac2fee4 made it so that the start_time for mp3 files is adjusted for skip_samples. However, this appears incorrect because subsequent packet timestamps are not adjusted and skip_samples are applied by deleting data from a packet without changing the timestamp. E.g., we are told the start_time is ~25ms and we get a packet with a timestamp of 0 that has had the skip_samples discarded from it. As such rendering engines may incorrectly discard everything prior to the 25ms thinking that is where playback should officially start. Since the samples were deleted without adjusting timestamps though, the true start_time is still 0. Other formats like MP4 with edit lists will adjust both the start time and the timestamps of subsequent packets to avoid this issue. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/mp3dec: Count last partial frame in probe.Michael Niedermayer2020-02-281-3/+9
| | | | | | | | Fixes: regression Fixes: Ticket8511 Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: Check for occurances of headers within frames during probingLimin Wang2019-11-161-1/+9
| | | | | | | Fixes misdetection of zYLx.wav Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: Check that the frame fits within the probe bufferMichael Niedermayer2019-11-161-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: replace SAME_HEADER_MASK with MP3_MASKLimin Wang2019-11-111-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mp3 header bitstream syntax: header() { syncword 12bits bslsf id 1bit bslsf layer 2bit bslsf protection_bit 1bit bslsf bitrate_index 4bits bslsf sampling_frequency 2bits bslsf padding_bit 1bit bslsf private_bit 1bit bslsf mode 2bits bslsf mode_extension 2bits bslsf copyright 1bit bslsf original/home 1bit bslsf emphasis 2bits bslsf } if the header is masking with MP3_MASK(0xFFFE0CCF), below fields will be cleared: protection_bit, bitrate_index, sampling_freqency, mode with SAME_HEADER_MASK(0xFFFE0C00), extra below fields will be cleared which didn't make sense: mode_extension, copyright, original/home, emphasis As the MP3_MASK is good for same mp3 header masking and is defined in the header, so it's preferable to remove SAME_HEADER_MASK to keep the masking same. Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mp3dec: cosmeticsLimin Wang2019-11-111-20/+20
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf: Constify the probe function argument.Carl Eugen Hoyos2019-03-211-1/+1
| | | | | Reviewed-by: Lauri Kasanen Reviewed-by: Tomas Härdin
* 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>