35 #define ASF_INDEXED_INTERVAL 10000000
36 #define ASF_INDEX_BLOCK (1<<9)
38 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
39 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
40 (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
41 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
43 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
44 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
46 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
49 #define ASF_PPI_PROPERTY_FLAGS \
50 (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
51 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
52 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
53 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
55 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
57 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
59 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
60 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
62 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
63 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
65 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
66 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
68 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
69 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
72 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
73 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
75 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
76 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
78 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
79 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
81 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
82 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
85 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
86 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
88 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
89 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
91 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
92 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
94 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
95 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
98 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
99 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
101 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
102 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
104 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
105 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
107 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
108 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
111 #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))
112 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
114 #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))
115 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
117 #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))
118 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
120 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
121 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
124 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
125 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
127 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
128 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
130 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
131 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
133 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
134 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
137 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
138 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
140 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
141 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
143 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
144 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
147 #define PACKET_HEADER_MIN_SIZE \
148 (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
149 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
152 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
153 ASF_PPI_SEQUENCE_FIELD_SIZE + \
154 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
159 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
161 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
163 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
164 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
165 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
166 ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
168 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
170 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
171 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
172 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
173 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
174 ASF_PAYLOAD_LENGTH_FIELD_SIZE)
176 #define SINGLE_PAYLOAD_DATA_LENGTH \
178 PACKET_HEADER_MIN_SIZE - \
179 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
181 #define MULTI_PAYLOAD_CONSTANT \
183 PACKET_HEADER_MIN_SIZE - \
185 2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
187 #define DATA_HEADER_SIZE 50
198 int packet_size_left;
205 uint64_t data_offset;
224 #define PREROLL_TIME 3100
270 int payload_length,
int flags)
276 length = payload_length + 8;
290 t = ti * INT64_C(10000000);
291 t += INT64_C(116444736000000000);
301 if (pres_time <= asf->index_ptr[i].send_time)
307 return send_time / 10000;
355 int64_t data_chunk_size)
360 int header_size,
n,
extra_size, extra_size2, wav_extra_size, file_time;
364 int64_t header_offset, cur_pos, hpos;
377 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
443 if (metadata_count) {
472 extra_size = 18 + wav_extra_size;
478 extra_size = 0x33 + wav_extra_size;
504 if (wavsize != extra_size) {
556 desc =
"Windows Media Audio V8";
588 header_size = cur_pos - header_offset;
592 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
594 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
599 header_size += 24 + 6;
600 avio_seek(pb, header_offset - 14, SEEK_SET);
640 NULL, NULL, NULL, NULL);
658 unsigned sendtime,
unsigned duration,
659 int nb_payloads,
int padsize)
708 int packet_hdr_size, packet_filled_size;
722 av_assert0(packet_hdr_size <= asf->packet_size_left);
733 NULL, NULL, NULL, NULL);
737 int64_t presentation_time,
int m_obj_size,
738 int m_obj_offset,
int payload_len,
int flags)
760 avio_wl32(pb, (uint32_t) presentation_time);
769 int m_obj_size,
int flags)
772 int m_obj_offset, payload_len, frag_len1;
775 while (m_obj_offset < m_obj_size) {
776 payload_len = m_obj_size - m_obj_offset;
793 if (frag_len1 < payload_len &&
800 if (payload_len > frag_len1)
801 payload_len = frag_len1;
802 else if (payload_len == (frag_len1 - 1))
803 payload_len = frag_len1 - 2;
806 m_obj_size, m_obj_offset, payload_len, flags);
819 m_obj_offset += payload_len;
831 uint32_t packet_number, uint16_t packet_count,
832 uint64_t packet_offset)
878 uint32_t packet_number;
905 uint16_t packet_count = asf->
nb_packets - packet_number;
906 ret =
update_index(s, start_sec, packet_number, packet_count, offset);
916 uint16_t max, uint32_t
count)
922 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
927 for (i = 0; i <
count; i++) {
938 int64_t file_size, data_size;
971 .mime_type =
"video/x-ms-asf",
972 .extensions =
"asf,wmv,wma",
986 #if CONFIG_ASF_STREAM_MUXER
988 .
name =
"asf_stream",
990 .mime_type =
"video/x-ms-asf",
991 .extensions =
"asf,wmv,wma",