46 #define ASF_UNICODE 0x0
47 #define ASF_FLAG_BROADCAST 0x1
48 #define ASF_BYTE_ARRAY 0x1
49 #define ASF_TYPE_AUDIO 0x2
50 #define ASF_TYPE_VIDEO 0x1
51 #define ASF_STREAM_NUM 0x7F
52 #define ASF_MAX_STREAMS 128
53 #define BMP_HEADER_SIZE 40
54 #define ASF_NUM_OF_PAYLOADS 0x3F
55 #define ASF_ERROR_CORRECTION_LENGTH_TYPE 0x60
56 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
161 FFSWAP(
unsigned char, guid[0], guid[3]);
162 FFSWAP(
unsigned char, guid[1], guid[2]);
163 FFSWAP(
unsigned char, guid[4], guid[5]);
164 FFSWAP(
unsigned char, guid[6], guid[7]);
169 if (size < INT64_MAX - offset &&
avio_tell(pb) != offset + size)
180 if (size > INT64_MAX)
187 if (!(ret = strcmp(g->
name,
"Header Extension")))
209 while (ret + 1 < maxlen) {
213 PUT_UTF8(ch, tmp,
if (q - buf < buflen - 1) *q++ = tmp;)
225 int i, nb_markers, ret;
234 for (i = 0; i <
len; i++)
237 for (i = 0; i < nb_markers; i++) {
249 sizeof(name))) < len)
260 unsigned char *
ch, uint16_t buflen)
278 uint16_t buflen = 2 * val_len + 1;
292 if (val_len >
sizeof(buf)) {
296 if ((ret =
avio_read(pb, value, val_len)) < 0)
298 if (ret < 2 * val_len)
301 value[2 * val_len - 1] =
'\0';
302 snprintf(buf,
sizeof(buf),
"%s", value);
349 snprintf(buf,
sizeof(buf),
"%"PRIu64, value);
367 int ret,
type, picsize, desc_len;
371 if (len < 1 + 4 + 2 + 2) {
391 if (!strncmp(mime->
str, mimetype,
sizeof(mimetype))) {
403 if (picsize >= len) {
410 desc_len = (len - picsize) * 2 + 1;
463 if (id3v2_extra_meta) {
482 if (!strcmp(name,
"WM/Picture"))
484 else if (!strcmp(name,
"ID3"))
510 for (i = 0; i < nb_desc; i++) {
511 uint16_t name_len,
type, val_len;
567 if (!strcmp(name,
"AspectRatioX"))
583 for (i = 0; i < nb_recs; i++) {
584 uint16_t name_len, buflen,
type, val_len, st_num;
590 buflen = 2 * name_len + 1;
600 if (!strcmp(name,
"AspectRatioX") || !strcmp(name,
"AspectRatioY")) {
627 static const char *
const titles[] =
628 {
"Title",
"Author",
"Copyright",
"Description",
"Rate" };
629 uint16_t
len[5], buflen[5] = { 0 };
633 for (i = 0; i < 5; i++) {
636 buflen[i] = 2 * len[i] + 1;
639 for (i = 0; i < 5; i++) {
655 time_t creation_time;
667 creation_time /= 10000000;
669 creation_time -= 11644473600;
670 tm =
gmtime_r(&creation_time, &tmbuf);
672 if (!strftime(buf,
sizeof(buf),
"%Y-%m-%d %H:%M:%S", tm))
707 size_bmp =
FFMAX(size_asf, size_bmp);
731 uint32_t err_data_len, ts_data_len;
770 "Duplicate stream found, this stream will be ignored.\n");
790 asf_st->
pkt.data_size = 0;
833 if (rfc1766 && strlen(rfc1766) > 1) {
834 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
849 uint16_t nb_st_name, nb_pay_exts, st_num, lang_idx;
852 uint64_t
start_time, end_time, time_per_frame;
879 for (i = 0; i < nb_st_name; i++) {
887 for (i = 0; i < nb_pay_exts; i++) {
902 if (g && !(strcmp(g->
name,
"Stream Properties"))) {
920 for (i = 0; i < nb_langs; i++) {
955 asf->
state = PARSE_PACKET_HEADER;
962 "Number of Packets from File Properties Object is not equal to Total"
963 "Datapackets value! num of packets %"PRIu64
" total num %"PRIu64
".\n",
979 uint32_t pkt_num, nb_entries;
1002 for (i = 0; i < nb_entries; i++) {
1009 if (prev_pkt_num != pkt_num) {
1013 prev_pkt_num = pkt_num;
1023 {
"Data", { 0x75, 0xB2, 0x26, 0x36, 0x66, 0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C },
asf_read_data, 1 },
1024 {
"Simple Index", { 0x33, 0x00, 0x08, 0x90, 0xE5, 0xB1, 0x11, 0xCF, 0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB },
asf_read_simple_index, 1 },
1025 {
"Content Description", { 0x75, 0xB2, 0x26, 0x33, 0x66 ,0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C },
asf_read_content_desc, 1 },
1026 {
"Extended Content Description", { 0xD2, 0xD0, 0xA4, 0x40, 0xE3, 0x07, 0x11, 0xD2, 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5e, 0xA8, 0x50 },
asf_read_ext_content, 1 },
1027 {
"Stream Bitrate Properties", { 0x7B, 0xF8, 0x75, 0xCE, 0x46, 0x8D, 0x11, 0xD1, 0x8D, 0x82, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xB2 },
asf_read_unknown, 1 },
1028 {
"File Properties", { 0x8C, 0xAB, 0xDC, 0xA1, 0xA9, 0x47, 0x11, 0xCF, 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
asf_read_properties, 1 },
1029 {
"Header Extension", { 0x5F, 0xBF, 0x03, 0xB5, 0xA9, 0x2E, 0x11, 0xCF, 0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
asf_read_unknown, 0 },
1030 {
"Stream Properties", { 0xB7, 0xDC, 0x07, 0x91, 0xA9, 0xB7, 0x11, 0xCF, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
asf_read_stream_properties, 1 },
1031 {
"Codec List", { 0x86, 0xD1, 0x52, 0x40, 0x31, 0x1D, 0x11, 0xD0, 0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
asf_read_unknown, 1 },
1032 {
"Marker", { 0xF4, 0x87, 0xCD, 0x01, 0xA9, 0x51, 0x11, 0xCF, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
asf_read_marker, 1 },
1033 {
"Script Command", { 0x1E, 0xFB, 0x1A, 0x30, 0x0B, 0x62, 0x11, 0xD0, 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
asf_read_unknown, 1 },
1034 {
"Language List", { 0x7C, 0x43, 0x46, 0xa9, 0xef, 0xe0, 0x4B, 0xFC, 0xB2, 0x29, 0x39, 0x3e, 0xde, 0x41, 0x5c, 0x85 },
asf_read_language_list, 1},
1035 {
"Padding", { 0x18, 0x06, 0xD4, 0x74, 0xCA, 0xDF, 0x45, 0x09, 0xA4, 0xBA, 0x9A, 0xAB, 0xCB, 0x96, 0xAA, 0xE8 },
asf_read_unknown, 1 },
1036 {
"DRMv1 Header", { 0x22, 0x11, 0xB3, 0xFB, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E },
asf_read_unknown, 1 },
1037 {
"DRMv2 Header", { 0x29, 0x8A, 0xE6, 0x14, 0x26, 0x22, 0x4C, 0x17, 0xB9, 0x35, 0xDA, 0xE0, 0x7E, 0xE9, 0x28, 0x9c },
asf_read_unknown, 1 },
1038 {
"Index", { 0xD6, 0xE2, 0x29, 0xD3, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1039 {
"Media Object Index", { 0xFE, 0xB1, 0x03, 0xF8, 0x12, 0xAD, 0x4C, 0x64, 0x84, 0x0F, 0x2A, 0x1D, 0x2F, 0x7A, 0xD4, 0x8C },
asf_read_unknown, 1 },
1040 {
"Timecode Index", { 0x3C, 0xB7, 0x3F, 0xD0, 0x0C, 0x4A, 0x48, 0x03, 0x95, 0x3D, 0xED, 0xF7, 0xB6, 0x22, 0x8F, 0x0C },
asf_read_unknown, 0 },
1041 {
"Bitrate_Mutual_Exclusion", { 0xD6, 0xE2, 0x29, 0xDC, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1042 {
"Error Correction", { 0x75, 0xB2, 0x26, 0x35, 0x66, 0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C },
asf_read_unknown, 1 },
1043 {
"Content Branding", { 0x22, 0x11, 0xB3, 0xFA, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E },
asf_read_unknown, 1 },
1044 {
"Content Encryption", { 0x22, 0x11, 0xB3, 0xFB, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E },
asf_read_unknown, 1 },
1045 {
"Extended Content Encryption", { 0x29, 0x8A, 0xE6, 0x14, 0x26, 0x22, 0x4C, 0x17, 0xB9, 0x35, 0xDA, 0xE0, 0x7E, 0xE9, 0x28, 0x9C },
asf_read_unknown, 1 },
1046 {
"Digital Signature", { 0x22, 0x11, 0xB3, 0xFC, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E },
asf_read_unknown, 1 },
1047 {
"Extended Stream Properties", { 0x14, 0xE6, 0xA5, 0xCB, 0xC6, 0x72, 0x43, 0x32, 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A },
asf_read_ext_stream_properties, 1 },
1048 {
"Advanced Mutual Exclusion", { 0xA0, 0x86, 0x49, 0xCF, 0x47, 0x75, 0x46, 0x70, 0x8A, 0x16, 0x6E, 0x35, 0x35, 0x75, 0x66, 0xCD },
asf_read_unknown, 1 },
1049 {
"Group Mutual Exclusion", { 0xD1, 0x46, 0x5A, 0x40, 0x5A, 0x79, 0x43, 0x38, 0xB7, 0x1B, 0xE3, 0x6B, 0x8F, 0xD6, 0xC2, 0x49 },
asf_read_unknown, 1},
1050 {
"Stream Prioritization", { 0xD4, 0xFE, 0xD1, 0x5B, 0x88, 0xD3, 0x45, 0x4F, 0x81, 0xF0, 0xED, 0x5C, 0x45, 0x99, 0x9E, 0x24 },
asf_read_unknown, 1 },
1051 {
"Bandwidth Sharing Object", { 0xA6, 0x96, 0x09, 0xE6, 0x51, 0x7B, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 },
asf_read_unknown, 1 },
1052 {
"Metadata", { 0xC5, 0xF8, 0xCB, 0xEA, 0x5B, 0xAF, 0x48, 0x77, 0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA },
asf_read_metadata_obj, 1 },
1053 {
"Metadata Library", { 0x44, 0x23, 0x1C, 0x94, 0x94, 0x98, 0x49, 0xD1, 0xA1, 0x41, 0x1D, 0x13, 0x4E, 0x45, 0x70, 0x54 },
asf_read_metadata_obj, 1 },
1054 {
"Audio Spread", { 0xBF, 0xC3, 0xCD, 0x50, 0x61, 0x8F, 0x11, 0xCF, 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20 },
asf_read_unknown, 1 },
1055 {
"Index Parameters", { 0xD6, 0xE2, 0x29, 0xDF, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1056 {
"Content Encryption System Windows Media DRM Network Devices",
1057 { 0x7A, 0x07, 0x9B, 0xB6, 0xDA, 0XA4, 0x4e, 0x12, 0xA5, 0xCA, 0x91, 0xD3, 0x8D, 0xC1, 0x1A, 0x8D },
asf_read_unknown, 1 },
1058 {
"Mutex Language", { 0xD6, 0xE2, 0x2A, 0x00, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1059 {
"Mutex Bitrate", { 0xD6, 0xE2, 0x2A, 0x01, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1060 {
"Mutex Unknown", { 0xD6, 0xE2, 0x2A, 0x02, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE },
asf_read_unknown, 1 },
1061 {
"Bandwidth Sharing Exclusive", { 0xAF, 0x60, 0x60, 0xAA, 0x51, 0x97, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 },
asf_read_unknown, 1 },
1062 {
"Bandwidth Sharing Partial", { 0xAF, 0x60, 0x60, 0xAB, 0x51, 0x97, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 },
asf_read_unknown, 1 },
1063 {
"Payload Extension System Timecode", { 0x39, 0x95, 0x95, 0xEC, 0x86, 0x67, 0x4E, 0x2D, 0x8F, 0xDB, 0x98, 0x81, 0x4C, 0xE7, 0x6C, 0x1E },
asf_read_unknown, 1 },
1064 {
"Payload Extension System File Name", { 0xE1, 0x65, 0xEC, 0x0E, 0x19, 0xED, 0x45, 0xD7, 0xB4, 0xA7, 0x25, 0xCB, 0xD1, 0xE2, 0x8E, 0x9B },
asf_read_unknown, 1 },
1065 {
"Payload Extension System Content Type", { 0xD5, 0x90, 0xDC, 0x20, 0x07, 0xBC, 0x43, 0x6C, 0x9C, 0xF7, 0xF3, 0xBB, 0xFB, 0xF1, 0xA4, 0xDC },
asf_read_unknown, 1 },
1066 {
"Payload Extension System Pixel Aspect Ratio", { 0x1, 0x1E, 0xE5, 0x54, 0xF9, 0xEA, 0x4B, 0xC8, 0x82, 0x1A, 0x37, 0x6B, 0x74, 0xE4, 0xC4, 0xB8 },
asf_read_unknown, 1 },
1067 {
"Payload Extension System Sample Duration", { 0xC6, 0xBD, 0x94, 0x50, 0x86, 0x7F, 0x49, 0x07, 0x83, 0xA3, 0xC7, 0x79, 0x21, 0xB7, 0x33, 0xAD },
asf_read_unknown, 1 },
1068 {
"Payload Extension System Encryption Sample ID", { 0x66, 0x98, 0xB8, 0x4E, 0x0A, 0xFA, 0x43, 0x30, 0xAE, 0xB2, 0x1C, 0x0A, 0x98, 0xD7, 0xA4, 0x4D },
asf_read_unknown, 1 },
1069 {
"Payload Extension System Degradable JPEG", { 0x00, 0xE1, 0xAF, 0x06, 0x7B, 0xEC, 0x11, 0xD1, 0xA5, 0x82, 0x00, 0xC0, 0x4F, 0xC2, 0x9C, 0xFB },
asf_read_unknown, 1 },
1072 #define READ_LEN(flag, name, len) \
1074 if ((flag) == name ## IS_BYTE) \
1075 len = avio_r8(pb); \
1076 else if ((flag) == name ## IS_WORD) \
1077 len = avio_rl16(pb); \
1078 else if ((flag) == name ## IS_DWORD) \
1079 len = avio_rl32(pb); \
1129 "Position %"PRId64
" wrong, should be %"PRId64
"\n",
1186 asf->
state = READ_MULTI_SUB;
1197 "Error: invalid data packet size, pay_len %"PRIu16
", "
1198 "asf->packet_size %"PRIu32
", offset %"PRId64
".\n",
1205 "Error: invalid buffer size, pay_len %d, data size left %d.\n",
1212 if ((ret =
avio_read(pb, p, pay_len)) < 0)
1254 "Error: invalid data packet size, offset %"PRId64
".\n",
1284 uint32_t off_len, media_len;
1310 if (stream_num >> 7)
1313 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len);
1315 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len);
1317 ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->
rep_data_len);
1329 asf->
state = READ_SINGLE;
1362 unsigned char error_flags, len_flags, pay_flags;
1373 len_flags = error_flags;
1378 ASF_PPI_FLAG_SEQUENCE_FIELD_, seq);
1380 ASF_PPI_FLAG_PADDING_LENGTH_FIELD_, asf->
pad_len );
1398 int nchunks = pkt_len / chunk_len;
1400 int pos = 0, j, l, ret;
1406 while (asf_pkt->
data_size >= asf_st->
span * pkt_len + pos) {
1410 for (l = 0; l < pkt_len; l++) {
1414 for (j = 0; j < asf_st->
span; j++) {
1415 if ((pos + chunk_len) >= asf_pkt->
data_size)
1417 memcpy(pkt.
data + pos,
1418 p + (j * nchunks + l) * chunk_len,
1423 p += asf_st->
span * pkt_len;
1443 if (asf->
state == PARSE_PACKET_HEADER) {
1448 asf->
state = READ_SINGLE;
1450 asf->
state = READ_MULTI;
1454 asf->
state = PARSE_PACKET_HEADER;
1460 switch (asf->
state) {
1463 asf->
state = PARSE_PACKET_HEADER;
1465 case READ_MULTI_SUB:
1467 asf->
state = PARSE_PACKET_HEADER;
1475 asf->
state = READ_MULTI;
1479 asf->
state = PARSE_PACKET_HEADER;
1539 asf->
state = PARSE_PACKET_HEADER;
1578 int64_t *pos, int64_t pos_limit)
1581 int64_t pkt_pos = *pos, pkt_offset, dts =
AV_NOPTS_VALUE, data_end;
1593 pkt_offset = pkt_pos;
1598 int i, ret, st_found;
1619 if (stream_index == st->
index) {
1637 int64_t timestamp,
int flags)
1665 if (!(ret = memcmp(guid, g->
guid,
sizeof(g->
guid))))
1681 while (
avio_tell(pb) <= offset + size) {
1694 g2.
name =
"Unknown";
const ff_asf_guid ff_asf_header
static void swap_guid(ff_asf_guid guid)
static int asf_read_ext_stream_properties(AVFormatContext *s, const GUIDParseTable *g)
static int asf_read_close(AVFormatContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int asf_read_packet_header(AVFormatContext *s)
static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
#define ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE
static void align_position(AVIOContext *pb, int64_t offset, uint64_t size)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
uint64_t data_offset
beginning of the first data packet
static int asf_read_marker(AVFormatContext *s, const GUIDParseTable *g)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
#define ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
const ff_asf_guid ff_asf_command_stream
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static void get_id3_tag(AVFormatContext *s, int len)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *g)
static int asf_read_replicated_data(AVFormatContext *s, ASFPacket *asf_pkt)
ASFStreamData asf_sd[ASF_MAX_STREAMS]
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header. ...
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
static int asf_read_language_list(AVFormatContext *s, const GUIDParseTable *g)
Macro definitions for various function/variable attributes.
static const GUIDParseTable * find_guid(ff_asf_guid guid)
static int process_metadata(AVFormatContext *s, const uint8_t *name, uint16_t name_len, uint16_t val_len, uint16_t type, AVDictionary **met)
static int64_t start_time
static int asf_read_metadata_obj(AVFormatContext *s, const GUIDParseTable *g)
static int asf_read_generic_value(AVIOContext *pb, int type, uint64_t *value)
Opaque data information usually continuous.
const ff_asf_guid ff_asf_audio_stream
static int asf_store_aspect_ratio(AVFormatContext *s, uint8_t st_num, uint8_t *name, int type)
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
Create chapters for all CHAP tags found in the ID3v2 header.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static int asf_read_data(AVFormatContext *s, const GUIDParseTable *g)
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
static void reset_packet_state(AVFormatContext *s)
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
static int asf_read_content_desc(AVFormatContext *s, const GUIDParseTable *g)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define GET_UTF16(val, GET_16BIT, ERROR)
Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static int asf_probe(AVProbeData *pd)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
#define ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE
unsigned int avio_rl32(AVIOContext *s)
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
static int asf_read_ext_content(AVFormatContext *s, const GUIDParseTable *g)
enum AVMediaType codec_type
General type of the encoded data.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
enum ASFContext::@196 state
int ff_get_guid(AVIOContext *s, ff_asf_guid *g)
static const uint8_t offset[127][2]
AVRational avg_frame_rate
Average framerate.
static struct tm * gmtime_r(const time_t *clock, struct tm *result)
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
static int asf_deinterleave(AVFormatContext *s, ASFPacket *asf_pkt, int st_num)
#define ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
const CodecMime ff_id3v2_mime_tags[]
common internal API header
static int asf_read_multiple_payload(AVFormatContext *s, AVPacket *pkt, ASFPacket *asf_pkt)
#define ASF_FLAG_BROADCAST
static int asf_read_single_payload(AVFormatContext *s, ASFPacket *asf_pkt)
static int asf_read_payload(AVFormatContext *s, AVPacket *pkt)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static int asf_read_value(AVFormatContext *s, const uint8_t *name, uint16_t val_len, int type, AVDictionary **met)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const AVCodecTag ff_codec_bmp_tags[]
static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVInputFormat ff_asf_o_demuxer
GLsizei GLboolean const GLfloat * value
ASFStream * asf_st
currently decoded stream
static int get_asf_string(AVIOContext *pb, int maxlen, char *buf, int buflen)
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
#define ASF_ERROR_CORRECTION_LENGTH_TYPE
#define READ_LEN(flag, name, len)
const ff_asf_guid ff_asf_ext_stream_embed_stream_header
static void set_language(AVFormatContext *s, const char *rfc1766, AVDictionary **met)
static int64_t asf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
Usually treated as AVMEDIA_TYPE_DATA.
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
#define FF_ARRAY_ELEMS(a)
static int read_header(FFV1Context *f)
#define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define ASF_NUM_OF_PAYLOADS
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint32_t packet_size_internal
AVIOContext * pb
I/O context.
const ff_asf_guid ff_asf_video_stream
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static int asf_read_picture(AVFormatContext *s, int len)
int64_t first_packet_offset
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static const GUIDParseTable gdef[]
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
Rational number (pair of numerator and denominator).
#define ASF_PPI_MASK_SEQUENCE_FIELD_SIZE
This structure contains the data a format has to probe a file.
static int64_t pts
Global timestamp for the audio frames.
static void reset_packet(ASFPacket *asf_pkt)
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
uint64_t sub_header_offset
const ff_asf_guid ff_asf_jfif_media
#define ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE
common internal and external API header
static int asf_read_metadata(AVFormatContext *s, const char *title, uint16_t len, unsigned char *ch, uint16_t buflen)
uint64_t nb_packets
how many packets are there in the file, invalid if broadcasting
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
static int asf_read_subpayload(AVFormatContext *s, AVPacket *pkt, int is_header)
int disposition
AV_DISPOSITION_* bit field.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
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.
int(* read_object)(AVFormatContext *, const struct GUIDParseTable *)
#define ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size)
Read BITMAPINFOHEADER structure and set AVStream codec width, height and bits_per_encoded_sample fiel...
static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int eof_reached
true if eof reached
static int asf_set_metadata(AVFormatContext *s, const uint8_t *name, int type, AVDictionary **met)
void * priv_data
Format private data.
static AVStream * find_stream(AVFormatContext *s, uint16_t st_num)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
AVCodecParameters * codecpar
static int parse_video_info(AVIOContext *pb, AVStream *st)
const char *const ff_id3v2_picture_types[21]
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
#define FFSWAP(type, a, b)
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
uint16_t virtual_chunk_len
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int asf_read_header(AVFormatContext *s)
static int detect_unknown_subobject(AVFormatContext *s, int64_t offset, int64_t size)