58 printf(
"chapter=%u time_base=%d/%d start=%"PRId64
" end=%"PRId64
" title=%s",
60 title ? title->
value :
"(missing)");
79 int title_len = ambiguous ? 224 : 150;
84 int size, chap_pos = -1,
ret = 1;
86 memset(long_title,
'L', title_len);
87 long_title[title_len] = 0;
106 for (
int i = 0;
i + 10 <=
size;
i++) {
107 if (!memcmp(buf +
i,
"CHAP", 4)) {
109 printf(
"CHAP size bytes=%02x %02x %02x %02x\n",
110 buf[
i + 4], buf[
i + 5], buf[
i + 6], buf[
i + 7]);
126 if (chap_pos >= 0 && chap_pos + 10 + 256 + 45 + 27 <=
size) {
127 uint8_t ch1_copy[45];
128 memcpy(ch1_copy, buf + chap_pos + 10 + 256,
sizeof(ch1_copy));
129 memcpy(buf + chap_pos + 10 + 256,
"TPE1\x00\x00\x00\x00\x00\x00", 10);
130 memcpy(buf + chap_pos + 10 + 266,
"TALB\x00\x00\x00\x07\x00\x00\x03World", 17);
131 memcpy(buf + chap_pos + 10 + 283, ch1_copy,
sizeof(ch1_copy));
132 printf(
"empty next frame version=4\n");
135 memcpy(buf + chap_pos + 10 + 256, ch1_copy,
sizeof(ch1_copy));
136 memset(buf + chap_pos + 10 + 301, 0, 27);
138 buf[chap_pos + 6] = 0x01;
139 buf[chap_pos + 7] = 0x00;
140 printf(
"ambiguous plain CHAP version=4\n");
153 if (
version == 4 && chap_pos >= 0) {
155 buf[chap_pos + 6] = 0x00;
156 buf[chap_pos + 7] = 0xb6;
157 printf(
"non-synchsafe CHAP version=4\n");
161 memcpy(saved, buf + chap_pos + 10 + 0x36 + 4,
sizeof(saved));
162 memset(buf + chap_pos + 10 + 0x36 + 4, 0,
sizeof(saved));
163 printf(
"high-bit plain CHAP with fitting fake header version=4\n");
166 memcpy(buf + chap_pos + 10 + 0x36 + 4, saved,
sizeof(saved));
167 buf[chap_pos + 6] = 0x01;
168 buf[chap_pos + 7] = 0x36;
175 for (
int i = chap_pos + 10;
i + 33 <=
size;
i++) {
176 if (!memcmp(buf +
i,
"TIT2", 4)) {
177 uint8_t enc = buf[
i + 10];
178 memcpy(buf +
i,
"TPE1", 4);
182 memcpy(buf +
i + 22,
"TIT2\x00\x00", 6);
183 buf[
i + 28] =
version == 4 ? 0x01 : 0x00;
184 buf[
i + 29] =
version == 4 ? 0x02 : 0x82;
192 memcpy(buf +
i,
"TIT2", 4);
193 memset(buf +
i + 4, 0x7f, 4);
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
#define i(width, name, range_min, range_max)
__device__ int printf(const char *,...)
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.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
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.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *cur)
Create chapters for all CHAP tags found in the ID3v2 header.
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.
void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
Initialize the encoding context and write the header for a new ID3v2 tag.
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
Finalize an opened ID3v2 tag.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
#define ID3v2_HEADER_SIZE
int ff_id3v2_write_metadata(AVFormatContext *s, AVIOContext *pb, ID3v2EncContext *id3)
Convert and write all global metadata from s into an ID3v2 tag.
static int readback(const uint8_t *buf, int size)
static int roundtrip(int version, int ambiguous)
Memory handling functions.
int64_t end
chapter start/end time in time_base units
AVRational time_base
time base in which the start/end timestamps are specified
unsigned int nb_chapters
Number of chapters in AVChapter array.