Commit Graph

48 Commits

Author SHA1 Message Date
Andreas Rheinhardt 8068f2fcf3 avformat/id3v2: Don't reverse the order of id3v2 APICs
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>
2021-04-18 02:24:44 +02:00
Andreas Rheinhardt 37140ebd87 avformat/id3v2: Remove unnecessary indirection
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>
2020-05-25 07:06:44 +02:00
Andreas Rheinhardt f08853b284 avformat/id3v2: Avoid allocations for ID3v2ExtraMeta
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>
2020-05-25 06:56:57 +02:00
Richard Shaffer 8a4cc0a256 avformat: add option to parse/store ID3 PRIV tags in metadata.
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>
2018-01-24 04:01:01 +01:00
Lukas Stabe 1fd80106be avformat: fix id3 chapters
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>
2017-10-05 17:10:23 +02:00
James Almer 318778de9e Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'
* commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3':
  Mark some arrays that never change as const.

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 16:02:40 -03:00
Anton Khirnov fd9212f2ed Mark some arrays that never change as const. 2017-02-01 10:42:59 +01:00
Peter Ross 5331773cc3 ff_id3v2_read: add option to limit ID3 magic number search
Several chunked formats (AIFF, IFF,DSF) store ID3 metadata within an 'ID3 '
chunk tag. If such chunks are stored sequentially, it is possible for the
ID3v2 parser to confuse the chunk tag for the ID3 magic number. e.g.

[1st chunk tag ('ID3 ') | chunk size] [ID3 magic number | metadata ...]
[2nd chunk tag ('ID3 ') | chunk size] [ID3 magic number | metadata ...]

Fixes ticket #3530.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-19 04:25:01 +02:00
James Darnley 0de03fd6a1 lavf/id3v2enc: use metadata_header_padding
As with the change to flacenc this allows the user to control the amount
of padding they want added to the file.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-24 22:50:06 +01:00
Anssi Hannula 7fdf245ab9 avformat/id3v2: allow ID3 parsing without AVFormatContext
Add ff_id3v2_read_dict() for parsing without AVFormatContext, but
instead with AVIOContext and AVDictionary.

AVFormatContext is still used for logging, if available.

Chapter parsing is the only non-logging functionality that actually
needs AVFormatContext, and AFAICS it should be modified to write the
data to ID3v2ExtraMeta first, from where it can be implanted to
AVFormatContext by a separate function (like it is done with
read_apic() and ff_id3v2_parse_apic()). That is outside the scope of
this patch, though.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2013-12-31 05:15:19 +02:00
Anssi Hannula 53765ae33b avformat/id3v2: parse ID3 Private frames as extra metadata
They are used in HLS.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2013-12-31 03:18:53 +02:00
Michael Niedermayer 2653e12520 Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'
* commit '1afddbe59e96af75f1c07605afc95615569f388f':
  avpacket: use AVBuffer to allow refcounting the packets.

Conflicts:
	libavcodec/avpacket.c
	libavcodec/utils.c
	libavdevice/v4l2.c
	libavformat/avidec.c
	libavformat/flacdec.c
	libavformat/id3v2.c
	libavformat/matroskaenc.c
	libavformat/mux.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-08 19:12:03 +01:00
Anton Khirnov 1afddbe59e avpacket: use AVBuffer to allow refcounting the packets.
This will allow us to avoid copying the packets in many cases.

This breaks ABI.
2013-03-08 07:33:45 +01:00
Michael Niedermayer 7a72695c05 Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	doc/examples/muxing.c
	ffmpeg.c
	ffprobe.c
	ffserver.c
	libavcodec/8svx.c
	libavcodec/avcodec.h
	libavcodec/dnxhd_parser.c
	libavcodec/dvdsubdec.c
	libavcodec/error_resilience.c
	libavcodec/h263dec.c
	libavcodec/libvorbisenc.c
	libavcodec/mjpeg_parser.c
	libavcodec/mjpegenc.c
	libavcodec/mpeg12.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pcm.c
	libavcodec/r210dec.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/version.h
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/v4l2.c
	libavformat/asfdec.c
	libavformat/asfenc.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/caf.c
	libavformat/electronicarts.c
	libavformat/flacdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/framecrcenc.c
	libavformat/img2.c
	libavformat/img2dec.c
	libavformat/img2enc.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/matroska.c
	libavformat/matroskadec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/movenc.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegts.c
	libavformat/mxf.c
	libavformat/mxfdec.c
	libavformat/mxfenc.c
	libavformat/nsvdec.c
	libavformat/nut.c
	libavformat/oggenc.c
	libavformat/pmpdec.c
	libavformat/rawdec.c
	libavformat/rawenc.c
	libavformat/riff.c
	libavformat/sdp.c
	libavformat/utils.c
	libavformat/vocenc.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 22:45:46 +02:00
Anton Khirnov 36ef5369ee Replace all CODEC_ID_* with AV_CODEC_ID_* 2012-08-07 16:00:24 +02:00
Michael Niedermayer 79ae084e9b Merge remote-tracking branch 'qatar/master'
* qatar/master: (58 commits)
  amrnbdec: check frame size before decoding.
  cscd: use negative error values to indicate decode_init() failures.
  h264: prevent overreads in intra PCM decoding.
  FATE: do not decode audio in the nuv test.
  dxa: set audio stream time base using the sample rate
  psx-str: do not allow seeking by bytes
  asfdec: Do not set AVCodecContext.frame_size
  vqf: set packet parameters after av_new_packet()
  mpegaudiodec: use DSPUtil.butterflies_float().
  FATE: add mp3 test for sample that exhibited false overreads
  fate: add cdxl test for bit line plane arrangement
  vmnc: return error on decode_init() failure.
  libvorbis: add/update error messages
  libvorbis: use AVFifoBuffer for output packet buffer
  libvorbis: remove unneeded e_o_s check
  libvorbis: check return values for functions that can return errors
  libvorbis: use float input instead of s16
  libvorbis: do not flush libvorbis analysis if dsp state was not initialized
  libvorbis: use VBR by default, with default quality of 3
  libvorbis: fix use of minrate/maxrate AVOptions
  ...

Conflicts:
	Changelog
	doc/APIchanges
	libavcodec/avcodec.h
	libavcodec/dpxenc.c
	libavcodec/libvorbis.c
	libavcodec/vmnc.c
	libavformat/asfdec.c
	libavformat/id3v2enc.c
	libavformat/internal.h
	libavformat/mp3enc.c
	libavformat/utils.c
	libavformat/version.h
	libswscale/utils.c
	tests/fate/video.mak
	tests/ref/fate/nuv
	tests/ref/fate/prores-alpha
	tests/ref/lavf/ffm
	tests/ref/vsynth1/prores
	tests/ref/vsynth2/prores

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-01 03:17:11 +01:00
Anton Khirnov ba445f5557 id3v2enc: add a function for writing attached pictures.
Unused so far.
2012-02-29 14:31:17 +01:00
Anton Khirnov 411225aabc id3v2enc: split ff_id3v2_write().
This will allow writing the tag in several steps, needed for writing
attached pictures.
2012-02-29 14:26:14 +01:00
Anton Khirnov 393fd0d89e id3v2: remove unused ff_id3v2_read().
Rename ff_id3v2_read_all to ff_id3v2_read().
2012-02-29 14:19:42 +01:00
Anton Khirnov 079ea6ca5f lavf: export id3v2 attached pictures as streams. 2012-02-29 14:16:32 +01:00
Anton Khirnov a93b09cb45 id3v2: read attached pictures and export them in ID3v2ExtraMeta. 2012-02-29 14:14:48 +01:00
Michael Niedermayer 2b0cdb7364 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Move id3v2 tag writing to a separate file.
  swscale: add missing colons to x86 assembly yuv2planeX.
  g722: split decoder and encoder into separate files
  cosmetics: remove extra spaces before end-of-statement semi-colons
  vorbisdec: check output buffer size before writing output
  wavpack: calculate bpp using av_get_bytes_per_sample()
  ac3enc: Set max value for mode options correctly
  lavc: move get_b_cbp() from h263.h to mpeg4videoenc.c
  mpeg12: move closed_gop from MpegEncContext to Mpeg1Context
  mpeg12: move full_pel from MpegEncContext to Mpeg1Context
  mpeg12: move Mpeg1Context from mpeg12.c to mpeg12.h
  mpegvideo: remove some unused variables from MpegEncContext.

Conflicts:
	libavcodec/mpeg12.c
	libavformat/mp3enc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-24 01:01:21 +02:00
Michael Karcher 16ad77b357 Move id3v2 tag writing to a separate file.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-10-23 19:17:53 +02:00
Michael Niedermayer f97faf6751 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  id3v2: fix doxy comment - 'machine byte order' makes no sense on char arrays
  VC1: restore mistakenly removed code
  twinvq: check output buffer size before decoding
  twinvq: return an error when the packet size is too small
  lavf: export some forgotten symbols with non-av prefixes.
  swscale: update altivec yuv2planeX asm to new per-plane API.
  swscale: make yuv2yuvX_10_sse2/avx 8/9/16-bits aware.
  yuv2planeX10 SIMD
  swscale: decide whether to use yuv2plane1/X on a per-plane basis.
  swscale: reintroduce full precision in 16-bit output.
  Split up yuv2yuvX functions
  Split out yuv2yuv1 luma and chroma in order to make them generic DSP functions
  lavc: replace references to deprecated AVCodecContext.error_recognition to use AVCodecContext.err_recognition
  lavc: translate non-flag-based er options into flag-based ef options at codec open
  add -err_filter AVOptions to access flag-based error recognition
  h264_weight: initialize "height" function argument properly.
  presets: spelling error in libvpx 1080p50_60
  avplay: fix fullscreen behaviour with SDL 1.2.14 on Mac OS X

Conflicts:
	ffplay.c
	libavformat/libavformat.v
	libswscale/swscale.c
	libswscale/x86/swscale_template.c
	tests/ref/lavfi/pixfmts_scale

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-23 05:13:56 +02:00
Michael Karcher e71ebb1972 id3v2: fix doxy comment - 'machine byte order' makes no sense on char arrays
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-10-22 22:52:18 +02:00
Michael Niedermayer 91eb1b1525 Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
  prores: add FATE tests
  id3v2: reduce the scope of some non-globally-used symbols/structures
  id3v2: cosmetics: move some declarations before the places they are used
  shorten: remove the flush function.
  shn: do not allow seeking in the raw shn demuxer.
  avformat: add AVInputFormat flag AVFMT_NO_BYTE_SEEK.
  avformat: update AVInputFormat allowed flags
  avformat: don't unconditionally call ff_read_frame_flush() when trying to seek.
  truespeech: use sizeof() instead of hardcoded sizes
  truespeech: remove unneeded variable, 'consumed'
  truespeech: simplify truespeech_read_frame() by using get_bits()
  truespeech: decode directly to output buffer instead of a temp buffer
  truespeech: check to make sure channels == 1
  truespeech: check for large enough output buffer rather than truncating output
  truespeech: remove unneeded zero-size packet check.
  mlpdec: return meaningful error codes instead of -1
  mlpdec: remove unnecessary wrapper function
  mlpdec: only calculate output size once
  mlpdec: validate that the reported channel count matches the actual output channel count
  pcm: reduce pointer type casting
  ...

Conflicts:
	libavformat/avformat.h
	libavformat/id3v2.c
	libavformat/id3v2.h
	libavformat/utils.c
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-14 03:48:22 +02:00
Diego Biurrun c4a378855e id3v2: reduce the scope of some non-globally-used symbols/structures 2011-10-13 23:20:37 +02:00
Reimar Döffinger a1526cd78f id3v2: Fix some (function) pointer types.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-09-25 23:01:43 +02:00
Michael Niedermayer 3e1a7ae44a Merge remote-tracking branch 'qatar/master'
* qatar/master:
  swfdec: Add support for sample_rate_code 0 (5512 Hz)
  dct-test: factor out some common code and do whas was likely intended
  doc: library versions need to be bumped in version.h
  Revert "ffmpeg: get rid of useless AVInputStream.nb_streams."
  Remove some forgotten AVCodecContext.palctrl usage.
  lavc/utils: move avcodec_init() higher in the file.
  lavc: replace some deprecated FF_*_TYPE with AV_PICTURE_TYPE_*
  ac3dec: actually use drc_scale private option
  lavc: undeprecate AVPALETTE_SIZE and AVPALETTE_COUNT macros
  alsa: add missing header
  msmpeg4: remove leftover unused debug variable declaration
  Fix assert() calls that need updates after FF_COMMON_FRAME macro elimination.
  Fix av_dlog invocations with wrong or missing logging context.
  vf_yadif: add support to yuva420p
  vf_yadif: correct documentation on the parity parameter
  vf_yadif: copy buffer properties like aspect for second frame as well
  oma: support for encrypted files
  id3v2: add support for non-text and GEOB type tag frames
  des: add possibility to calculate DES-CBC-MAC with small buffer

Conflicts:
	ffmpeg.c
	libavcodec/dct-test.c
	libavformat/mpegts.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-09-21 21:25:43 +02:00
David Goldwich 7a019dffe5 id3v2: add support for non-text and GEOB type tag frames
This extends the ID3v2 parser to allow for reading of non-text (i.e.
other than T***) meta tag frames providing a ff_id3v2_read_all()
function. An additional data structure 'ID3v2ExtraMeta' is introduced
for these tags since AVDictionary is string oriented and unsuitable
for binary data.

A parser for tag frames of type GEOB is implemented, which is needed
to extract keyring information from encrypted OMA files. GEOB data
is parsed into 'ID3v2ExtraMetaGEOB' data structures.

The routine to decode characters from different encodings to UTF-8,
formerly part of the read_ttag() function, is moved to its own
function. Because some tag frames contain subparts of unknown length,
the function is now also able to read until a null character is found.
In addition, the function now takes care of allocating a buffer long
enough to hold the decoded characters.

Signed-off-by: David Goldwich <david.goldwich@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2011-09-21 08:28:21 +02:00
Mans Rullgard 2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Anton Khirnov fe01dd8d74 id3v2: split tables for various ID3v2 versions
This is needed for upcoming ID3v2.3 muxing support.

Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
(cherry picked from commit cb6bc57681)
2011-01-23 19:32:07 +01:00
Anton Khirnov cb6bc57681 id3v2: split tables for various ID3v2 versions
This is needed for upcoming ID3v2.3 muxing support.

Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
2011-01-22 02:06:10 +01:00
Anton Khirnov eeb0b893e3 id3v2: use an enum for encodings instead of magic numbers.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit d66eff3685)
2011-01-21 20:36:01 +01:00
Anton Khirnov b3158f7a42 id3v2: make ff_id3v2_parse static
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 46a2da7698)
2011-01-21 20:36:00 +01:00
Anton Khirnov d66eff3685 id3v2: use an enum for encodings instead of magic numbers.
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-21 18:42:10 +00:00
Anton Khirnov 46a2da7698 id3v2: make ff_id3v2_parse static
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-20 13:36:22 +00:00
Anton Khirnov 7a07d158bd id3v2: use a named constant instead of 0x02
Originally committed as revision 25902 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-12-07 07:52:50 +00:00
Diego Biurrun b8ab52e702 Fix Doxygen function parameter documentation syntax.
Originally committed as revision 23978 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-02 11:41:13 +00:00
Måns Rullgård 49bd8e4b84 Fix grammar errors in documentation
Originally committed as revision 23904 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-30 15:38:06 +00:00
Michael Karcher 3a1350e8d9 Generalize ID3v2 functions to support ID3v2-like ID headers with a
different magic in the header (mainly targeted to Sony's .oma/.aa3
format).

Patch by Michael Karcher, ffmpeg A mkarcher dialup fu-berlin de

Originally committed as revision 23583 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-11 13:44:57 +00:00
Måns Rullgård cf671d0543 Remove extraneous const keyword
Originally committed as revision 20263 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-10-17 14:07:28 +00:00
Anton Khirnov 078d89a2b0 MP3 muxer: Write all metadata.
Patch by Anton Khirnov <wyskas at gmail dot com>

Originally committed as revision 20170 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-10-05 16:06:00 +00:00
Anton Khirnov 6378b06208 Add id3v2 metadata conversion table and use it in mp3 muxer.
Patch by Anton Khirnov, wyskas gmail

Originally committed as revision 20073 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-09-29 07:05:03 +00:00
Patrick Dehne 50fcd5be36 Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
patch by Patrick Dehne, patrick mysonicweb com

Originally committed as revision 19224 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-06-19 14:03:35 +00:00
Patrick Dehne 7541118286 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
patch by Patrick Dehne, patrick mysonicweb com

Originally committed as revision 19155 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-06-11 15:26:57 +00:00
Alex Converse ac3ef4a41b Fix probing of files with ID3v2 tags. Discussed at
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-January/059302.html

Originally committed as revision 16688 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-01-19 21:54:06 +00:00
Alex Converse 2ea512a6c2 Factorise id3v2 header parsing from mp3.c to be shared
Patch by Alex Converse ( alex converse gmail com )

Originally committed as revision 16615 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-01-15 12:23:03 +00:00