31 #define ASF_INDEXED_INTERVAL 10000000
32 #define ASF_INDEX_BLOCK (1<<9)
33 #define ASF_PAYLOADS_PER_PACKET 63
35 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
36 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
37 (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
38 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
40 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
41 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
43 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
46 #define ASF_PPI_PROPERTY_FLAGS \
47 (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
48 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
49 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
50 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
52 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
54 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
56 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
57 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
59 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
60 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
62 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
63 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
65 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
66 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
69 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
70 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
72 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
73 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
75 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
76 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
78 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
79 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
82 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
83 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
85 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
86 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
88 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
89 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
91 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
92 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
95 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
96 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
98 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
99 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
101 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
102 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
104 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
105 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
108 #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))
109 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
111 #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))
112 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
114 #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))
115 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
117 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
118 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
121 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
122 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
124 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
125 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
127 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
128 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
130 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
131 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
134 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
135 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
137 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
138 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
140 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
141 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
144 #define PACKET_HEADER_MIN_SIZE \
145 (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
146 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
149 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
150 ASF_PPI_SEQUENCE_FIELD_SIZE + \
151 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
156 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
158 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
160 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
161 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
162 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
163 ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
165 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
167 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
168 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
169 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
170 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
171 ASF_PAYLOAD_LENGTH_FIELD_SIZE)
173 #define SINGLE_PAYLOAD_DATA_LENGTH \
175 PACKET_HEADER_MIN_SIZE - \
176 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
178 #define MULTI_PAYLOAD_CONSTANT \
180 PACKET_HEADER_MIN_SIZE - \
182 2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
184 #define DATA_HEADER_SIZE 50
221 #define PREROLL_TIME 3100
261 int payload_length,
int flags)
267 length = payload_length + 8;
281 t = ti * INT64_C(10000000);
282 t += INT64_C(116444736000000000);
292 if (pres_time <= asf->index_ptr[i].send_time)
298 return send_time / 10000;
346 int64_t data_chunk_size)
351 int header_size,
n, extra_size, extra_size2, wav_extra_size, file_time;
352 int has_title, has_aspect_ratio = 0;
355 int64_t header_offset, cur_pos, hpos;
368 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
415 if (has_aspect_ratio) {
417 avio_wl32(pb, 26 + has_aspect_ratio * 84);
470 if (metadata_count) {
499 extra_size = 18 + wav_extra_size;
505 extra_size = 0x33 + wav_extra_size;
531 if (wavsize != extra_size) {
580 desc =
"Windows Media Audio V8";
582 desc = codec_desc ? codec_desc->
name :
NULL;
619 header_size = cur_pos - header_offset;
623 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
625 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
630 header_size += 24 + 6;
631 avio_seek(pb, header_offset - 14, SEEK_SET);
690 unsigned sendtime,
unsigned duration,
691 int nb_payloads,
int padsize)
740 int packet_hdr_size, packet_filled_size;
754 av_assert0(packet_hdr_size <= asf->packet_size_left);
769 int64_t presentation_time,
int m_obj_size,
770 int m_obj_offset,
int payload_len,
int flags)
792 avio_wl32(pb, (uint32_t) presentation_time);
801 int m_obj_size,
int flags)
804 int m_obj_offset, payload_len, frag_len1;
807 while (m_obj_offset < m_obj_size) {
808 payload_len = m_obj_size - m_obj_offset;
825 if (frag_len1 < payload_len &&
832 if (payload_len > frag_len1)
833 payload_len = frag_len1;
834 else if (payload_len == (frag_len1 - 1))
835 payload_len = frag_len1 - 2;
838 m_obj_size, m_obj_offset, payload_len, flags);
851 m_obj_offset += payload_len;
865 uint32_t packet_number, uint16_t packet_count,
866 uint64_t packet_offset)
912 uint32_t packet_number;
939 uint16_t packet_count = asf->
nb_packets - packet_number;
940 ret =
update_index(s, start_sec, packet_number, packet_count, offset);
950 uint16_t max, uint32_t
count)
956 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
961 for (i = 0; i <
count; i++) {
972 int64_t file_size, data_size;
1001 #if CONFIG_ASF_MUXER
1005 .mime_type =
"video/x-ms-asf",
1006 .extensions =
"asf,wmv,wma",
1020 #if CONFIG_ASF_STREAM_MUXER
1022 .
name =
"asf_stream",
1024 .mime_type =
"video/x-ms-asf",
1025 .extensions =
"asf,wmv,wma",