summaryrefslogtreecommitdiff
path: root/libavformat/id3v2.c
Commit message (Collapse)AuthorAge
* avformat/utils: Move avpriv_new_chapter to demux_utils.cAndreas Rheinhardt2022-05-10
| | | | | | | It is demuxer-only: Muxers deal only with chapters given to them; they don't create any of their own. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/id3v2: Add Grouping frame to id3v2.4 metadata tableWolfgang Müller2022-02-15
| | | | | | | | | | | | | | | | | The ID3v2.4.0 standard defines TIT1 as the "Content group description" tag [1]. This frame is usually referred to as the "Grouping" tag and in de-facto use under that name by Vorbis and APEv2 [2]. This commit introduces a mapping from "TIT1" to "grouping" in the id3v2.4 metadata conversion table. This will enable software to access it using that name. In particular, MPD will now read this tag correctly when using the ffmpeg decoder plugin. [1] https://id3.org/id3v2.4.0-frames (4.2.1) [2] https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#grouping-3 Signed-off-by: Wolfgang Müller <wolf@oriole.systems> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-25
| | | | | | | | | | | | | | 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>
* avformat/id3v2: Check end for overflow in id3v2_parse()Michael Niedermayer2021-04-23
| | | | | | | | Fixes: signed integer overflow: 9223372036840103978 + 67637280 cannot be represented in type 'long' Fixes: 33341/clusterfuzz-testcase-minimized-ffmpeg_dem_DSF_fuzzer-6408154041679872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Don't reverse the order of id3v2 APICsAndreas Rheinhardt2021-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When parsing ID3v2 tags, special (non-text) metadata is not applied directly and unconditionally; instead it is stored in a linked list in which elements are prepended. When traversing the list to add APICs (or private tags) at the end, the order is reversed. The same also happens for chapters and therefore the chapter parsing code already reverses the chapters. This commit changes this: By keeping pointers to both head and tail of the linked list one can preserve the order of the entries and remove the reordering code for chapters. Only the pointer to head will be exported: No current caller uses a nonempty list, so exporting both head and tail is unnecessary. This removes the functionality to combine the lists of special metadata read from different ID3v2 tags, but that doesn't make really much sense anyway (and would be trivial to implement if desired) and allows to remove the now unnecessary initializations performed by the callers. The FATE-reference for the id3v2-priv test had to be updated because the order of the tags read into the dict is reversed; for id3v2-priv-remux only the md5 and not the ffprobe output of the remuxed file changes because the order of the private tags has up until now been reversed twice. The references for the aiff/mp3 cover-art tests needed to be updated, because the order of the attached pics is reversed upon reading. It is still not correct, because the muxers write the pics in the order in which they arrive at the muxer instead of the order given by pkt->stream_index. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Add and use helper function to add attachment streamsAndreas Rheinhardt2021-04-01
| | | | | | | | | All instances of adding attached pictures to a stream or adding a stream and an attached packet to said stream have several things in common like setting the index and flags of the packet, setting the stream disposition etc. This commit therefore factors this out. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/id3v2: replace call to av_init_packet()James Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/id3v2: Check the return from avio_get_str()Michael Niedermayer2021-02-10
| | | | | | | | Fixes: out of array access Fixes: 29446/clusterfuzz-testcase-minimized-ffmpeg_dem_AAC_fuzzer-5096222622875648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Check against max compression ratio before allocationMichael Niedermayer2021-01-19
| | | | | | | | Fixes: Timeout (>10sec -> 12ms) Fixes: 27612/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_S24BE_fuzzer-6605893000757248 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Sanity check tlen before alloc and uncompressMichael Niedermayer2020-12-05
| | | | | | | | | Fixes: Timeout (>20sec -> 65ms) Fixes: 26896/clusterfuzz-testcase-minimized-ffmpeg_dem_DAUD_fuzzer-5691024049176576 Fixes: 27627/clusterfuzz-testcase-minimized-ffmpeg_dem_AEA_fuzzer-4907019324358656 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Remove unnecessary indirectionAndreas Rheinhardt2020-05-25
| | | | | | | | | ff_id3v2_parse_apic/chapters/priv/priv_dict all had a parameter extra_meta of type ID3v2ExtraMeta ** as if the functions wanted to make *extra_meta point to something else. But they don't, so just use an ID3v2ExtraMeta *. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/id3v2: Avoid allocations for ID3v2ExtraMetaAndreas Rheinhardt2020-05-25
| | | | | | | | | | | | Up until now, the ID3v2ExtraMeta structure (which is used when parsing ID3v2 tags containing attached pictures, chapters etc.) contained a pointer to separately allocated data that depended on the type of the tag. Yet the difference of the sizes of the largest and the smallest of these structures is fairly small, so that it is better to simply include a union of all the possible types of tag-dependent structures in ID3v2ExtraMeta. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/id3v2: Fix double-free on errorAndreas Rheinhardt2019-12-10
| | | | | | | | | | | | | ff_id3v2_parse_priv_dict() uses av_dict_set() with the flags AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL. In this case both key and value are freed on error (and owned by the destination dictionary on success), so that freeing them again on error is a double-free and therefore forbidden. But it nevertheless happened. Fixes CID 1452489 and 1452421. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Avoid av_strdup for key and value of dictAndreas Rheinhardt2019-11-13
| | | | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/id3v2: fail read_apic on EOF reading mimetypechcunningham2018-12-17
| | | | | | | | avio_read may return EOF, leaving the mimetype array unitialized. fail early when this occurs to avoid using the array in an unitialized state. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: use png header to get PNG signaturePaul B Mahol2018-12-14
|
* id3v2: fix unsynchronizationwm42018-02-04
| | | | | | | | | | | | | | | The ID3v2 "unsynchronization scheme" requires replacing any 0xFF 0x00 sequences with 0xFF. This has to be done on every byte of the source data, while the current code skipped a byte after a replacement. This meant 0xFF 0x00 0xFF 00 was translated to 0xFF 0xFF 0x00 instead of 0xFF 0xFF. It feels a bit messy to do this correctly with the avio use. But fortunately, this translation can be done in-place, so we can just do it in memory. Inspired by what taglib does. Also see 9ae80e6a9cefcab61e867256ba19ef78a4bfe0cb. (The sample file for that commit is gone, so it could not be retested.)
* avformat: add option to parse/store ID3 PRIV tags in metadata.Richard Shaffer2018-01-24
| | | | | | | | | | | | | | Enables getting access to ID3 PRIV tags from the command-line or metadata API when demuxing. The PRIV owner is stored as the metadata key prepended with "id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may contain arbitrary data, non-printable characters, including NULL bytes, are escaped as \xXX. Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3 PRIV tags into the output (assuming the format supports ID3). \xXX sequences in the value are un-escaped to their byte value. Signed-off-by: wm4 <nfxjfg@googlemail.com>
* avformat: fix id3 chaptersLukas Stabe2017-10-05
| | | | | | | | | | | These changes store id3 chapter data in ID3v2ExtraMeta and introduce ff_id3v2_parse_chapters to parse them into the format context if needed. Encoders using ff_id3v2_read, which previously parsed chapters into the format context automatically, were adjusted to call ff_id3v2_parse_chapters. Signed-off-by: wm4 <nfxjfg@googlemail.com>
* Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'James Almer2017-09-26
|\ | | | | | | | | | | | | * commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3': Mark some arrays that never change as const. Merged-by: James Almer <jamrial@gmail.com>
| * Mark some arrays that never change as const.Anton Khirnov2017-02-01
| |
| * srt: Adjust signedness of sscanf format stringsDiego Biurrun2016-10-28
| | | | | | | | Fixes several warnings from -Wformat.
* | avformat/id3v2: Use ffio_ensure_seekback() in id3v2_read_internal()Michael Niedermayer2017-05-19
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat: fix ID3v2 parser for v2.2 comment framesChris Moeller2017-01-28
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/id3v2: fix memleak with empty stringsMichael Niedermayer2016-08-11
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat/id3v2: Mark variable as unused to avoid "set but not used" warningMichael Niedermayer2016-08-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avformat: read id3v2 comment tagsChris Moeller2016-08-07
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '9200514ad8717c63f82101dc394f4378854325bf'Derek Buitenhuis2016-04-10
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'Michael Niedermayer2015-07-27
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '059a934806d61f7af9ab3fd9f74994b838ea5eba': lavc: Consistently prefix input buffer defines Conflicts: doc/examples/decoding_encoding.c libavcodec/4xm.c libavcodec/aac_adtstoasc_bsf.c libavcodec/aacdec.c libavcodec/aacenc.c libavcodec/ac3dec.h libavcodec/asvenc.c libavcodec/avcodec.h libavcodec/avpacket.c libavcodec/dvdec.c libavcodec/ffv1enc.c libavcodec/g2meet.c libavcodec/gif.c libavcodec/h264.c libavcodec/h264_mp4toannexb_bsf.c libavcodec/huffyuvdec.c libavcodec/huffyuvenc.c libavcodec/jpeglsenc.c libavcodec/libxvid.c libavcodec/mdec.c libavcodec/motionpixels.c libavcodec/mpeg4videodec.c libavcodec/mpegvideo.c libavcodec/noise_bsf.c libavcodec/nuv.c libavcodec/nvenc.c libavcodec/options.c libavcodec/parser.c libavcodec/pngenc.c libavcodec/proresenc_kostya.c libavcodec/qsvdec.c libavcodec/svq1enc.c libavcodec/tiffenc.c libavcodec/truemotion2.c libavcodec/utils.c libavcodec/utvideoenc.c libavcodec/vc1dec.c libavcodec/wmalosslessdec.c libavformat/adxdec.c libavformat/aiffdec.c libavformat/apc.c libavformat/apetag.c libavformat/avidec.c libavformat/bink.c libavformat/cafdec.c libavformat/flvdec.c libavformat/id3v2.c libavformat/isom.c libavformat/matroskadec.c libavformat/mov.c libavformat/mpc.c libavformat/mpc8.c libavformat/mpegts.c libavformat/mvi.c libavformat/mxfdec.c libavformat/mxg.c libavformat/nutdec.c libavformat/oggdec.c libavformat/oggparsecelt.c libavformat/oggparseflac.c libavformat/oggparseopus.c libavformat/oggparsespeex.c libavformat/omadec.c libavformat/rawdec.c libavformat/riffdec.c libavformat/rl2.c libavformat/rmdec.c libavformat/rtpdec_latm.c libavformat/rtpdec_mpeg4.c libavformat/rtpdec_qdm2.c libavformat/rtpdec_svq3.c libavformat/sierravmd.c libavformat/smacker.c libavformat/smush.c libavformat/spdifenc.c libavformat/takdec.c libavformat/tta.c libavformat/utils.c libavformat/vqf.c libavformat/westwood_vqa.c libavformat/xmv.c libavformat/xwma.c libavformat/yop.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * lavc: Consistently prefix input buffer definesVittorio Giovara2015-07-27
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | id3v2: strip trailing spaces from APIC tagwm42015-06-18
| | | | | | | | | | | | | | | | | | | | | | The APIC description must be unique, and some ID3v2 tag writers add spaces to write several APIC entries with the same description. The trailing spaces simply serve as a way to disambiguate the description. Do this so that API users do not have to special-case mp3 to fix this cosmetic issue. Requested-by: wm4 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/id3v2: detect PNG by header instead of mimeMichael Niedermayer2015-06-18
| | | | | | | | | | | | | | | | the mimetype for PNG can be set to jpeg Fixes 01\ -\ Cider\ Time.mp3 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | id3v2: catch avio_read errors in check_tagAndreas Cadhalpun2015-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since len is an unsigned int, the comparison is currently treated as unsigned and thus ignores all errors from avio_read. Thus cast len to int, which is unproblematic, because at that point len is between 0 and 4. This fixes 'Conditional jump or move depends on uninitialised value' valgrind warnings in is_tag. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '379e5603f4131e677ecf5ba79973dcd5603f28ea'Michael Niedermayer2015-05-10
|\| | | | | | | | | | | | | | | | | | | | | * commit '379e5603f4131e677ecf5ba79973dcd5603f28ea': id3v2: Do not export empty APIC description Conflicts: libavformat/id3v2.c See: b697b297b77f73c932307120e32c187d521d2ff7 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * id3v2: Do not export empty APIC descriptionwm42015-05-09
| | | | | | | | | | | | APIC tags always have a description. Tag writers obviously leave it empty if there is no description. In this case, libavformat would export "" as title. Do not set the title instead.
* | id3v2: do not export APIC description if emptywm42015-05-08
| | | | | | | | | | | | | | | | APIC tags always have a description. Tag writers obviously leave it empty if there is no description. In this case, libavformat would export "" as title. Do not set the title instead. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '8e32b1f0963d01d4f5d4803eb721f162e0d58d9a'Michael Niedermayer2015-02-25
|\| | | | | | | | | | | | | * commit '8e32b1f0963d01d4f5d4803eb721f162e0d58d9a': libavformat: Use ffio_free_dyn_buf where applicable Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * libavformat: Use ffio_free_dyn_buf where applicableMartin Storsjö2015-02-24
| | | | | | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* | avformat/id3v2: remove unused variableMichael Niedermayer2015-01-15
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '54bc15d5ebfd07fd468743ba29f709ea19e840b9'Michael Niedermayer2015-01-15
|\| | | | | | | | | | | | | | | | | | | | | * commit '54bc15d5ebfd07fd468743ba29f709ea19e840b9': id3v2: fix reading v2.2 attached pictures Conflicts: libavformat/id3v2.c See: 05c3c568dccd6c42fdf6eea891d08c71fe2ee772 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * id3v2: fix reading v2.2 attached picturesAnton Khirnov2015-01-14
| | | | | | | | | | In v2.2, the picture type is not a zero-terminated string, but has a constant size of 3 bytes.
* | Merge commit '932788be5af8dee062c77851b573ea47dd6d047a'Michael Niedermayer2015-01-15
|\| | | | | | | | | | | | | | | | | | | * commit '932788be5af8dee062c77851b573ea47dd6d047a': id3v2: add names to the parameters of ID3v2EMFunc.read Conflicts: libavformat/id3v2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * id3v2: add names to the parameters of ID3v2EMFunc.readAnton Khirnov2015-01-14
| | | | | | | | Some of them are not immediately obvious.
* | avformat/id3v2: Fix incompatible pointer type warningsMichael Niedermayer2015-01-15
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '8809c974a3fb51f96e498a5556a4a5bbacc581ce'Michael Niedermayer2015-01-15
|\| | | | | | | | | | | | | | | | | | | * commit '8809c974a3fb51f96e498a5556a4a5bbacc581ce': id3v2: constify the 'tag' parameter to special metadata parsing callback Conflicts: libavformat/id3v2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * id3v2: constify the 'tag' parameter to special metadata parsing callbackAnton Khirnov2015-01-14
| | | | | | | | Those functions should not ever modify it.
* | avformat/id3v2: support USLT tagswm42015-01-06
| | | | | | | | | | | | | | I think this turned out pretty terrible. There's no good way to add new custom tags that write to AVFormatContext->metadata. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/id3v2: Use av_freep() avoid leaving stale pointers in memoryMichael Niedermayer2014-12-20
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | id3v2: prefer TDRC for date over TDRL.Benoit Fouet2014-11-04
| | | | | | | | | | | | | | | | | | | | | | | | | | TDRL is what we used as a replacement of TYER, and, according to http://id3.org/id3v2.4.0-changes : TYER - Year This frame is replaced by the TDRC frame, 'Recording time' [F:4.2.5]. So change TDRL usages to TDRC. Fixes ticket #3694 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>