50 {
"COMM",
"comment" },
52 {
"TCOM",
"composer" },
54 {
"TCOP",
"copyright" },
55 {
"TENC",
"encoded_by" },
57 {
"TLAN",
"language" },
59 {
"TPE2",
"album_artist" },
60 {
"TPE3",
"performer" },
62 {
"TPUB",
"publisher" },
64 {
"TSSE",
"encoder" },
70 {
"TCMP",
"compilation" },
73 {
"TDEN",
"creation_time" },
74 {
"TSOA",
"album-sort" },
75 {
"TSOP",
"artist-sort" },
76 {
"TSOT",
"title-sort" },
77 {
"TSST",
"disc_subtitle" },
78 {
"TIT1",
"grouping" },
85 {
"TCP",
"compilation" },
87 {
"TEN",
"encoded_by" },
89 {
"TP2",
"album_artist" },
90 {
"TP3",
"performer" },
96 "TALB",
"TBPM",
"TCOM",
"TCON",
"TCOP",
"TDLY",
"TENC",
"TEXT",
97 "TFLT",
"TIT1",
"TIT2",
"TIT3",
"TKEY",
"TLAN",
"TLEN",
"TMED",
98 "TOAL",
"TOFN",
"TOLY",
"TOPE",
"TOWN",
"TPE1",
"TPE2",
"TPE3",
99 "TPE4",
"TPOS",
"TPUB",
"TRCK",
"TRSN",
"TRSO",
"TSRC",
"TSSE",
104 "TDEN",
"TDOR",
"TDRC",
"TDRL",
"TDTG",
"TIPL",
"TMCL",
"TMOO",
105 "TPRO",
"TSOA",
"TSOP",
"TSOT",
"TSST",
110 "TDAT",
"TIME",
"TORY",
"TRDA",
"TSIZ",
"TYER",
116 "32x32 pixels 'file icon'",
121 "Media (e.g. label side of CD)",
122 "Lead artist/lead performer/soloist",
127 "Lyricist/text writer",
128 "Recording Location",
130 "During performance",
131 "Movie/video screen capture",
132 "A bright coloured fish",
134 "Band/artist logotype",
135 "Publisher/Studio logotype",
154 return buf[0] == magic[0] &&
155 buf[1] == magic[1] &&
156 buf[2] == magic[2] &&
159 (buf[6] & 0x80) == 0 &&
160 (buf[7] & 0x80) == 0 &&
161 (buf[8] & 0x80) == 0 &&
162 (buf[9] & 0x80) == 0;
167 int len = ((buf[6] & 0x7f) << 21) +
168 ((buf[7] & 0x7f) << 14) +
169 ((buf[8] & 0x7f) << 7) +
187 return !(
size & ((0x80U << 0) |
195 return (((
size) & (0x7f << 0)) >> 0) +
196 (((
size) & (0x7f << 8)) >> 1) +
197 (((
size) & (0x7f << 16)) >> 2) +
198 (((
size) & (0x7f << 24)) >> 3);
209 if ((buf[
len] <
'A' ||
226 unsigned int nsize, nlen;
232 if (rem <
sizeof(
tag)) {
278 uint8_t **
dst,
int *maxread)
283 int left = *maxread, dynsize;
305 if ((
left -= 2) < 0) {
330 while ((
left > 1) && ch) {
384 if (!(strcmp(
key,
"TCON") && strcmp(
key,
"TCO")) &&
385 (sscanf(
dst,
"(%d)", &genre) == 1 || sscanf(
dst,
"%d", &genre) == 1) &&
389 }
else if (!(strcmp(
key,
"TXXX") && strcmp(
key,
"TXX"))) {
411 const char *
key,
int taglen,
414 char *full_key =
NULL;
415 uint8_t *
dst, *descriptor =
NULL;
417 char language[4] = {0};
430 for (
char *p = language; *p; p++)
434 if (!strcmp(language,
"xxx") ||
437 !strcmp(language,
"und"))
438 memset(language, 0,
sizeof(language));
442 if (
decode_str(
s, pb, encoding, &descriptor, &taglen) < 0) {
453 if (descriptor && *descriptor) {
454#if FF_API_OLD_ID3V2_COMMENT
455 if (
s && (
s->flags & AVFMT_FLAG_LEGACY_ID3V2_COMM_KEYS) &&
456 !strcmp(
key,
"comment")) {
458 "Deprecated: COMM descriptor '%s' exported as metadata key. "
459 "This will be removed in a future version.\n", descriptor);
464 int descr_len = strlen((
char *)descriptor);
468 else if ((descr_len == 3 &&
471 (descr_len > 4 && descriptor[descr_len-4] ==
'-' &&
506 list->tail->next = new_elem;
508 list->head = new_elem;
509 list->tail = new_elem;
558 if (!geob_data->
data) {
564 "Error reading GEOB frame, data truncated.\n");
572 new_extra->
tag =
"GEOB";
586 while (*str >=
'0' && *str <=
'9')
603 char date[17] = { 0 };
615 snprintf(date + 4,
sizeof(date) - 4,
"-%.2s-%.2s", t->
value + 2, t->
value);
622 snprintf(date + 10,
sizeof(date) - 10,
641 size_t len = strlen(buf);
642 while (
len > 0 && buf[
len - 1] ==
' ')
650 char mimetype[64] = {0};
657 if (taglen <= 4 || (
version == 2 && taglen <= 6))
692 "Unknown attached picture mimetype: %s, skipping.\n", mimetype);
710 "Error decoding attached picture description.\n");
719 new_extra->
tag =
"APIC";
781 if (tlen > (
unsigned)
len) {
783 "Invalid ID3v2 chapter subframe %.4s size %u, keeping the chapter\n",
791 if (consumed < 0 || consumed > tlen ||
800 new_extra->
tag =
"CHAP";
896 const char *reason =
NULL;
902 unsigned char *uncompressed_buffer =
NULL;
903 av_unused int uncompressed_buffer_size = 0;
904 const char *comm_frame;
906 if (end > INT64_MAX -
len - 10)
915 reason =
"compression";
935 unsync =
flags & 0x80;
937 if (isv34 &&
flags & 0x40) {
944 reason =
"invalid extended header length";
950 reason =
"extended header too long.";
955 while (
len >= taghdrlen) {
956 unsigned int tflags = 0;
973 unsigned int rem =
len - taghdrlen;
984 check_tag(pb, cur + 2 + ss_tlen, rem - ss_tlen) == 1)
986 else if (
check_tag(pb, cur + 2 + tlen, rem - tlen) != 1)
1003 len -= taghdrlen + tlen;
1029 if (tencr || (!CONFIG_ZLIB && tcomp)) {
1034 type =
"compressed";
1036 type =
"encrypted and compressed";
1041 }
else if (
tag[0] ==
'T' ||
1042 !memcmp(
tag,
"USLT", 4) ||
1043 !strcmp(
tag, comm_frame) ||
1048 if (unsync || tunsync || tcomp) {
1055 if (unsync || tunsync) {
1064 const uint8_t *
const buf_end = t + tlen;
1065 while (t != buf_end) {
1067 if (t != buf_end && t[-1] == 0xff && !t[0])
1073 pbx = &pb_local.
pub;
1084 if (dlen / 32768 > tlen)
1087 av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
1088 if (!uncompressed_buffer) {
1093 if (!(unsync || tunsync)) {
1102 err = uncompress(uncompressed_buffer, &dlen,
buffer, tlen);
1109 pbx = &pb_local.
pub;
1119 for (
unsigned i = 1;
i <= n;
i++)
1120 if (!(buf[
i] >= 0x20 && buf[
i] < 0x7f))
1134 else if (!memcmp(
tag,
"USLT", 4))
1136 else if (!strcmp(
tag, comm_frame))
1141 }
else if (!
tag[0]) {
1177 *extra_metap =
NULL;
1201 len = ((buf[6] & 0x7f) << 21) |
1202 ((buf[7] & 0x7f) << 14) |
1203 ((buf[8] & 0x7f) << 7) |
1206 extra_metap ? &extra_meta :
NULL);
1210 }
while (found_header);
1216 *extra_metap = extra_meta.
head;
1251 for (cur = extra_meta; cur; cur = cur->
next) {
1256 if (strcmp(cur->
tag,
"APIC"))
1263 st =
s->streams[
s->nb_streams - 1];
1283 for (
unsigned i = 0; cur; cur = cur->
next) {
1287 if (strcmp(cur->
tag,
"CHAP"))
1308 for (cur = extra_meta; cur; cur = cur->
next) {
1309 if (!strcmp(cur->
tag,
"PRIV")) {
1312 char *escaped, *
key;
1322 if (priv->
data[
i] < 32 || priv->
data[
i] > 126 || priv->
data[
i] ==
'\\') {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define attribute_nonstring
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_w8(AVIOContext *s, int b)
unsigned int avio_rb16(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
unsigned int avio_rb24(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
char * av_asprintf(const char *fmt,...)
static void BS_FUNC seek(BSCTX *bc, unsigned pos)
Seek to the given bit position.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define GET_UTF16(val, GET_16BIT, ERROR)
Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, AVBufferRef **buf, int size)
Add an attached pic to an AVStream.
static struct @111144215057303131116103221376075045141373005341 current
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
size_t static size_t av_strnlen(const char *s, size_t len)
Get the count of continuous non zero chars starting from the beginning.
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
static void read_lang_descr_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int taglen, AVDictionary **metadata)
Parse a lang descr tag such as COMM and USLT.
static AVDictionaryEntry * get_date_tag(AVDictionary *m, const char *tag)
static void free_apic(void *obj)
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
Read an ID3v2 tag, including supported extra metadata.
static unsigned int size_to_syncsafe(unsigned int size)
static void free_priv(void *obj)
static const ID3v2EMFunc id3v2_extra_meta_funcs[]
static void list_append(ID3v2ExtraMeta *new_elem, ExtraMetaList *list)
static const ID3v2EMFunc * get_extra_meta_func(const char *tag, int isv34)
Get the corresponding ID3v2EMFunc struct for a tag.
static const AVMetadataConv id3v2_2_metadata_conv[]
static int check_tag(AVIOContext *s, int64_t offset, unsigned int rem)
Return 1 if the candidate frame boundary at offset (with rem bytes left in the ID3v2 tag after it) is...
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
int ff_id3v2_match(const uint8_t *buf, const char *magic)
Detect ID3v2 Header.
static void rstrip_spaces(char *buf)
static unsigned int get_size(AVIOContext *s, int len)
static void merge_date(AVDictionary **m)
static void read_chapter(AVFormatContext *s, AVIOContext *pb, int len, const char *ttag, ExtraMetaList *extra_meta, int version)
static int is_number(const char *str)
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, AVDictionary **metadata, const char *key)
Parse a text tag.
static void read_geobtag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int version)
Parse GEOB tag into a ID3v2ExtraMetaGEOB struct.
static int is_tag(const char *buf, unsigned int len)
static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding, uint8_t **dst, int *maxread)
Decode characters to UTF-8 according to encoding type.
int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta *extra_meta)
Parse PRIV tags into a dictionary.
static void read_priv(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int version)
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int version)
static void free_geobtag(void *obj)
Free GEOB type extra metadata.
static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata, AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_metap, int64_t max_search_size)
static int is_syncsafe(unsigned int size)
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *cur)
Create chapters for all CHAP tags found in the ID3v2 header.
static void free_chapter(void *obj)
static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata, AVFormatContext *s, int len, uint8_t version, uint8_t flags, ExtraMetaList *extra_meta)
void ff_id3v2_read_dict(AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
const char ff_id3v2_3_tags[][4]
ID3v2.3-only text information frames.
#define ID3v2_FLAG_COMPRESSION
#define ID3v2_FLAG_ENCRYPTION
const AVMetadataConv ff_id3v2_34_metadata_conv[]
const char ff_id3v2_4_tags[][4]
ID3v2.4-only text information frames.
#define ID3v2_PRIV_METADATA_PREFIX
#define ID3v2_FLAG_UNSYNCH
const AVMetadataConv ff_id3v2_4_metadata_conv[]
const char *const ff_id3v2_picture_types[21]
@ ID3v2_ENCODING_UTF16BOM
#define ID3v2_FLAG_DATALEN
#define ID3v2_HEADER_SIZE
const char ff_id3v2_tags[][4]
A list of text information frames allowed in both ID3 v2.3 and v2.4 http://www.id3....
const CodecMime ff_id3v2_mime_tags[]
Macro definitions for various function/variable attributes.
Memory handling functions.
static void get(const uint8_t *pixels, int stride, int16_t *block)
#define FF_ARRAY_ELEMS(a)
uint8_t * data
The data buffer.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
void(* read)(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int version)
static void error(const char *err)