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) & (0x7f << 0)) >> 0) +
188 (((
size) & (0x7f << 8)) >> 1) +
189 (((
size) & (0x7f << 16)) >> 2) +
190 (((
size) & (0x7f << 24)) >> 3);
201 if ((buf[
len] <
'A' ||
252 uint8_t **
dst,
int *maxread)
257 int left = *maxread, dynsize;
279 if ((
left -= 2) < 0) {
304 while ((
left > 1) && ch) {
358 if (!(strcmp(
key,
"TCON") && strcmp(
key,
"TCO")) &&
359 (sscanf(
dst,
"(%d)", &genre) == 1 || sscanf(
dst,
"%d", &genre) == 1) &&
363 }
else if (!(strcmp(
key,
"TXXX") && strcmp(
key,
"TXX"))) {
385 const char *
key,
int taglen,
388 char *full_key =
NULL;
389 uint8_t *
dst, *descriptor =
NULL;
391 char language[4] = {0};
404 for (
char *p = language; *p; p++)
408 if (!strcmp(language,
"xxx") ||
411 !strcmp(language,
"und"))
412 memset(language, 0,
sizeof(language));
416 if (
decode_str(
s, pb, encoding, &descriptor, &taglen) < 0) {
427 if (descriptor && *descriptor) {
428#if FF_API_OLD_ID3V2_COMMENT
429 if (
s && (
s->flags & AVFMT_FLAG_LEGACY_ID3V2_COMM_KEYS) &&
430 !strcmp(
key,
"comment")) {
432 "Deprecated: COMM descriptor '%s' exported as metadata key. "
433 "This will be removed in a future version.\n", descriptor);
438 int descr_len = strlen((
char *)descriptor);
442 else if ((descr_len == 3 &&
445 (descr_len > 4 && descriptor[descr_len-4] ==
'-' &&
482 list->
head = new_elem;
483 list->
tail = new_elem;
532 if (!geob_data->
data) {
538 "Error reading GEOB frame, data truncated.\n");
546 new_extra->
tag =
"GEOB";
560 while (*str >=
'0' && *str <=
'9')
577 char date[17] = { 0 };
596 snprintf(date + 10,
sizeof(date) - 10,
615 size_t len = strlen(buf);
616 while (
len > 0 && buf[
len - 1] ==
' ')
624 char mimetype[64] = {0};
631 if (taglen <= 4 || (!isv34 && taglen <= 6))
645 int ret =
avio_get_str(pb, taglen, mimetype,
sizeof(mimetype));
646 if (ret < 0 || ret >= taglen)
666 "Unknown attached picture mimetype: %s, skipping.\n", mimetype);
684 "Error decoding attached picture description.\n");
693 new_extra->
tag =
"APIC";
748 if (taglen < 0 || taglen >
len)
760 new_extra->
tag =
"CHAP";
856 const char *reason =
NULL;
862 unsigned char *uncompressed_buffer =
NULL;
863 av_unused int uncompressed_buffer_size = 0;
864 const char *comm_frame;
866 if (end > INT64_MAX -
len - 10)
875 reason =
"compression";
895 unsync =
flags & 0x80;
897 if (isv34 &&
flags & 0x40) {
904 reason =
"invalid extended header length";
910 reason =
"extended header too long.";
915 while (
len >= taghdrlen) {
916 unsigned int tflags = 0;
941 else if (
check_tag(pb, cur + 2 + tlen, 4) != 1)
958 len -= taghdrlen + tlen;
984 if (tencr || (!CONFIG_ZLIB && tcomp)) {
991 type =
"encrypted and compressed";
996 }
else if (
tag[0] ==
'T' ||
997 !memcmp(
tag,
"USLT", 4) ||
998 !strcmp(
tag, comm_frame) ||
1003 if (unsync || tunsync || tcomp) {
1010 if (unsync || tunsync) {
1019 const uint8_t *
const buf_end = t + tlen;
1020 while (t != buf_end) {
1022 if (t != buf_end && t[-1] == 0xff && !t[0])
1028 pbx = &pb_local.
pub;
1039 if (dlen / 32768 > tlen)
1042 av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
1043 if (!uncompressed_buffer) {
1048 if (!(unsync || tunsync)) {
1057 err = uncompress(uncompressed_buffer, &dlen,
buffer, tlen);
1064 pbx = &pb_local.
pub;
1074 for (
unsigned i = 1;
i <= n;
i++)
1075 if (!(buf[
i] >= 0x20 && buf[
i] < 0x7f))
1089 else if (!memcmp(
tag,
"USLT", 4))
1091 else if (!strcmp(
tag, comm_frame))
1095 extra_func->
read(
s, pbx, tlen,
tag, extra_meta, isv34);
1096 }
else if (!
tag[0]) {
1132 *extra_metap =
NULL;
1156 len = ((buf[6] & 0x7f) << 21) |
1157 ((buf[7] & 0x7f) << 14) |
1158 ((buf[8] & 0x7f) << 7) |
1161 extra_metap ? &extra_meta :
NULL);
1165 }
while (found_header);
1171 *extra_metap = extra_meta.
head;
1206 for (cur = extra_meta; cur; cur = cur->
next) {
1211 if (strcmp(cur->
tag,
"APIC"))
1218 st =
s->streams[
s->nb_streams - 1];
1238 for (
unsigned i = 0; cur; cur = cur->
next) {
1242 if (strcmp(cur->
tag,
"CHAP"))
1263 for (cur = extra_meta; cur; cur = cur->
next) {
1264 if (!strcmp(cur->
tag,
"PRIV")) {
1267 char *escaped, *
key;
1277 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.
attribute_nonstring const char ff_id3v2_4_tags[][4]
ID3v2.4-only text information frames.
static AVDictionaryEntry * get_date_tag(AVDictionary *m, const char *tag)
static void free_apic(void *obj)
attribute_nonstring const char ff_id3v2_tags[][4]
A list of text information frames allowed in both ID3 v2.3 and v2.4 http://www.id3....
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.
const AVMetadataConv ff_id3v2_34_metadata_conv[]
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.
attribute_nonstring const char ff_id3v2_3_tags[][4]
ID3v2.3-only text information frames.
static void read_priv(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int isv34)
const AVMetadataConv ff_id3v2_4_metadata_conv[]
static const AVMetadataConv id3v2_2_metadata_conv[]
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
const char *const ff_id3v2_picture_types[21]
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 int is_number(const char *str)
static void read_chapter(AVFormatContext *s, AVIOContext *pb, int len, const char *ttag, ExtraMetaList *extra_meta, int isv34)
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 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.
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 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)
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 read_geobtag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int isv34)
Parse GEOB tag into a ID3v2ExtraMetaGEOB struct.
static void free_chapter(void *obj)
static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ExtraMetaList *extra_meta, int isv34)
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 CodecMime ff_id3v2_mime_tags[]
static int check_tag(AVIOContext *s, int offset, unsigned int len)
Return 1 if the tag of length len at the given offset is valid, 0 if not, -1 on error.
#define ID3v2_FLAG_COMPRESSION
#define ID3v2_FLAG_ENCRYPTION
#define ID3v2_PRIV_METADATA_PREFIX
#define ID3v2_FLAG_UNSYNCH
@ ID3v2_ENCODING_UTF16BOM
#define ID3v2_FLAG_DATALEN
#define ID3v2_HEADER_SIZE
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 isv34)
static void error(const char *err)