45 while (*str && *str < 128) str++;
64 const uint32_t
tag,
const uint8_t
flags)
92 const uint32_t
tag,
const uint8_t
flags,
93 const char *lang,
const char *descr,
123 const uint32_t
tag,
const uint8_t
flags,
124 const char **strings,
int len,
136 for (
i = 0;
i <
len;
i++) {
159 const uint8_t
flags,
const char *
key,
178 char digits[] = {
data[0],
data[1], 0};
202 {.key =
"comment", .tag =
MKBETAG(
'C',
'O',
'M',
'M')},
203 {.key =
"lyrics", .tag =
MKBETAG(
'U',
'S',
'L',
'T')},
204 {.key =
NULL, .tag = 0}
217 const char *
key, *after_dash, *last_dash;
218 uint32_t
tag, ff_tag = 0;
219 char lang[4] =
"und";
222 if (strlen(t->
key) == 4)
228 key_len = strlen(
key);
235 if (strncmp(t->
key,
key, key_len) ||
236 (t->
key[key_len] !=
'\0' && t->
key[key_len] !=
'-'))
239 if (t->
key[key_len] ==
'\0')
244 after_dash = t->
key + key_len + 1;
245 last_dash = strrchr(after_dash,
'-');
246 const char *suffix =
NULL;
247 const char *middle =
NULL;
251 suffix = last_dash + 1;
259 const char *descr =
NULL;
261 memcpy(lang, suffix, 3);
265 descr, t->
value, enc);
272 size_t descr_len = last_dash - after_dash;
278 memcpy(lang, suffix, 3);
280 lang, descr, t->
value, enc);
285 lang, after_dash, t->
value, enc);
298 if (t->
key[0] !=
'T' || strlen(t->
key) != 4)
304 const char *strings[] = {t->
value};
316 char year[5] = {0}, day_month[5] = {0};
402 const char *strings[] = {t->
key, t->
value};
404 0, strings, 2, enc)) < 0)
417 if (
s->nb_chapters == 0)
426 for (
int i = 0;
i <
s->nb_chapters;
i++) {
432 MKBETAG(
'C',
'T',
'O',
'C'), 0);
442 int len, start, end, ret;
487 for (
i = 0;
i <
s->nb_chapters;
i++) {
502 const char *mimetype =
NULL, *
desc =
"";
505 int i,
type = 0, ret;
510 mimetype = mime->
str;
517 "write an attached picture.\n", st->
index);
549 MKBETAG(
'A',
'P',
'I',
'C'), 0);
557 if (padding_bytes < 0)
566 padding_bytes =
av_clip(padding_bytes, 10, 268435455 - id3->
len);
568 id3->
len += padding_bytes;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_wl16(AVIOContext *s, unsigned int val)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
void avio_w8(AVIOContext *s, int b)
void avio_wb32(AVIOContext *s, unsigned int val)
void avio_wb16(AVIOContext *s, unsigned int val)
int avio_put_str16le(AVIOContext *s, const char *str)
Convert an UTF-8 string to UTF-16LE and write it.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
void ffio_fill(AVIOContext *s, int b, int64_t count)
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC comment(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawComment *current)
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.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
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_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static av_const int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit.
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.
attribute_nonstring const char ff_id3v2_4_tags[][4]
ID3v2.4-only text information frames.
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....
const AVMetadataConv ff_id3v2_34_metadata_conv[]
attribute_nonstring const char ff_id3v2_3_tags[][4]
ID3v2.3-only text information frames.
const AVMetadataConv ff_id3v2_4_metadata_conv[]
const char *const ff_id3v2_picture_types[21]
const CodecMime ff_id3v2_mime_tags[]
#define ID3v2_PRIV_METADATA_PREFIX
@ ID3v2_ENCODING_UTF16BOM
#define ID3v2_HEADER_SIZE
void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
Initialize an ID3v2 tag.
static int id3v2_check_write_lang_descr_tag(ID3v2EncContext *id3, AVIOContext *pb, const AVDictionaryEntry *t, enum ID3v2Encoding enc)
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
Finalize an opened ID3v2 tag.
int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
Convert and write all global metadata from s into an ID3v2 tag.
static int is_valid_lang(const char *s)
int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
Write an attached picture from pkt into an ID3v2 tag.
static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const uint8_t flags, const char *key, const char *data)
Write a priv frame with owner and data.
static int write_metadata(AVIOContext *pb, AVDictionary **metadata, ID3v2EncContext *id3, int enc)
static int id3v2_check_write_tag(ID3v2EncContext *id3, AVIOContext *pb, const AVDictionaryEntry *t, const char table[][4], enum ID3v2Encoding enc)
static int id3v2_put_text_tag(ID3v2EncContext *id3, AVIOContext *avioc, const uint32_t tag, const uint8_t flags, const char **strings, int len, enum ID3v2Encoding enc)
Write a text frame with multiple text string according to encoding (only UTF-8 or UTF-16+BOM supporte...
static int string_is_ascii(const uint8_t *str)
static void id3v2_encode_string(AVIOContext *pb, const uint8_t *str, enum ID3v2Encoding enc)
static int id3v2_put_frame(ID3v2EncContext *id3, AVIOContext *avioc, AVIOContext *dyn_buf, const uint32_t tag, const uint8_t flags)
static void id3v2_3_metadata_split_date(AVDictionary **pm)
static int write_chapter(AVFormatContext *s, ID3v2EncContext *id3, int id, int enc)
static int write_ctoc(AVFormatContext *s, ID3v2EncContext *id3, int enc)
static const struct LangDescrTagMap id3v2_lang_descr_tags[]
static void id3v2_put_size(AVIOContext *pb, int size)
int ff_id3v2_write_simple(struct AVFormatContext *s, int id3v2_version, const char *magic)
Write an ID3v2 tag containing all global metadata from s.
static int id3v2_put_lang_descr_tag(ID3v2EncContext *id3, AVIOContext *avioc, const uint32_t tag, const uint8_t flags, const char *lang, const char *descr, const char *comment, enum ID3v2Encoding enc)
Write a frame containing lang, descr and text such as COMM and USLT according to encoding (only UTF-8...
#define MKBETAG(a, b, c, d)
Memory handling functions.
int ff_standardize_creation_time(AVFormatContext *s)
Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.
static const uint16_t table[]
#define FF_ARRAY_ELEMS(a)
int64_t end
chapter start/end time in time_base units
AVRational time_base
time base in which the start/end timestamps are specified
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int index
stream index in AVFormatContext
int64_t size_pos
offset of the tag total size
int len
size of the tag written so far
int version
ID3v2 minor version, either 3 or 4.