34 #define ASF_INDEXED_INTERVAL 10000000
35 #define ASF_INDEX_BLOCK (1<<9)
37 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
38 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
39 (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
40 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
42 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
43 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
45 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
48 #define ASF_PPI_PROPERTY_FLAGS \
49 (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
50 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
51 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
52 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
54 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
56 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
58 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
59 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
61 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
62 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
64 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
65 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
67 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
68 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
71 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
72 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
74 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
75 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
77 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
78 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
80 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
81 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
84 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
85 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
87 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
88 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
90 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
91 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
93 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
94 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
97 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
98 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
100 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
101 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
103 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
104 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
106 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
107 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
110 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE))
111 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
113 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE))
114 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
116 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE))
117 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
119 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
120 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
123 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
124 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
126 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
127 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
129 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
130 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
132 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
133 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
136 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
137 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
139 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
140 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
142 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
143 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
146 #define PACKET_HEADER_MIN_SIZE \
147 (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
148 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
151 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
152 ASF_PPI_SEQUENCE_FIELD_SIZE + \
153 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
158 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
160 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
162 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
163 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
164 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
165 ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
167 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
169 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
170 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
171 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
172 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
173 ASF_PAYLOAD_LENGTH_FIELD_SIZE)
175 #define SINGLE_PAYLOAD_DATA_LENGTH \
177 PACKET_HEADER_MIN_SIZE - \
178 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
180 #define MULTI_PAYLOAD_CONSTANT \
182 PACKET_HEADER_MIN_SIZE - \
184 2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
195 int packet_size_left;
202 uint64_t data_offset;
220 #define PREROLL_TIME 3100
266 int payload_length,
int flags)
272 length = payload_length + 8;
286 t = ti * INT64_C(10000000);
287 t += INT64_C(116444736000000000);
293 int64_t data_chunk_size)
298 int header_size,
n,
extra_size, extra_size2, wav_extra_size, file_time;
302 int64_t header_offset, cur_pos, hpos;
315 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
381 if (metadata_count) {
405 extra_size = 18 + wav_extra_size;
411 extra_size = 0x33 + wav_extra_size;
437 if (wavsize != extra_size) {
489 desc =
"Windows Media Audio V8";
521 header_size = cur_pos - header_offset;
523 header_size += 8 + 30 + 50;
525 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
527 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
530 header_size -= 8 + 30 + 50;
532 header_size += 24 + 6;
533 avio_seek(pb, header_offset - 14, SEEK_SET);
573 NULL, NULL, NULL, NULL);
591 unsigned sendtime,
unsigned duration,
592 int nb_payloads,
int padsize)
641 int packet_hdr_size, packet_filled_size;
655 av_assert0(packet_hdr_size <= asf->packet_size_left);
666 NULL, NULL, NULL, NULL);
670 int64_t presentation_time,
int m_obj_size,
671 int m_obj_offset,
int payload_len,
int flags)
693 avio_wl32(pb, (uint32_t) presentation_time);
702 int m_obj_size,
int flags)
705 int m_obj_offset, payload_len, frag_len1;
708 while (m_obj_offset < m_obj_size) {
709 payload_len = m_obj_size - m_obj_offset;
726 if (frag_len1 < payload_len &&
733 if (payload_len > frag_len1)
734 payload_len = frag_len1;
735 else if (payload_len == (frag_len1 - 1))
736 payload_len = frag_len1 - 2;
739 m_obj_size, m_obj_offset, payload_len, flags);
752 m_obj_offset += payload_len;
764 uint32_t packet_number, uint16_t packet_count)
796 uint32_t packet_number;
821 uint16_t packet_count = asf->
nb_packets - packet_number;
822 update_index(s, start_sec, packet_number, packet_count);
830 uint16_t max, uint32_t
count)
836 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
841 for (i = 0; i <
count; i++) {
852 int64_t file_size, data_size;
883 .mime_type =
"video/x-ms-asf",
884 .extensions =
"asf,wmv,wma",
898 #if CONFIG_ASF_STREAM_MUXER
900 .
name =
"asf_stream",
902 .mime_type =
"video/x-ms-asf",
903 .extensions =
"asf,wmv,wma",