32 #define ASF_INDEXED_INTERVAL 10000000
33 #define ASF_INDEX_BLOCK (1<<9)
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\
41 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
42 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
44 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
47 #define ASF_PPI_PROPERTY_FLAGS (\
48 ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
49 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
50 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
51 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
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 + \
161 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
163 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD (\
165 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
166 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
167 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
168 ASF_PAYLOAD_REPLICATED_DATA_LENGTH \
171 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS (\
173 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
174 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
175 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
176 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
177 ASF_PAYLOAD_LENGTH_FIELD_SIZE \
180 #define SINGLE_PAYLOAD_DATA_LENGTH (\
182 PACKET_HEADER_MIN_SIZE - \
183 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
186 #define MULTI_PAYLOAD_CONSTANT (\
188 PACKET_HEADER_MIN_SIZE - \
190 2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
202 int packet_size_left;
209 uint64_t data_offset;
227 #define PREROLL_TIME 3100
231 assert(
sizeof(*g) == 16);
278 length = payload_length + 8;
292 t = ti * INT64_C(10000000);
293 t += INT64_C(116444736000000000);
303 int header_size, n,
extra_size, extra_size2, wav_extra_size, file_time;
307 int64_t header_offset, cur_pos, hpos;
320 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
386 if (metadata_count) {
411 extra_size = 18 + wav_extra_size;
417 extra_size = 0x33 + wav_extra_size;
443 if (wavsize != extra_size) {
495 desc =
"Windows Media Audio V8";
528 header_size = cur_pos - header_offset;
530 header_size += 8 + 30 + 50;
532 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
534 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
537 header_size -= 8 + 30 + 50;
539 header_size += 24 + 6;
540 avio_seek(pb, header_offset - 14, SEEK_SET);
599 unsigned int sendtime,
653 int packet_hdr_size, packet_filled_size;
670 assert(packet_hdr_size <= asf->packet_size_left);
687 int64_t presentation_time,
714 avio_wl32(pb, (uint32_t) presentation_time);
732 int m_obj_offset, payload_len, frag_len1;
735 while (m_obj_offset < m_obj_size) {
736 payload_len = m_obj_size - m_obj_offset;
759 if (payload_len > frag_len1)
760 payload_len = frag_len1;
761 else if (payload_len == (frag_len1 - 1))
762 payload_len = frag_len1 - 2;
777 m_obj_offset += payload_len;
789 uint32_t packet_number, uint16_t packet_count)
821 uint32_t packet_number;
845 uint16_t packet_count = asf->
nb_packets - packet_number;
846 update_index(s, start_sec, packet_number, packet_count);
860 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count);
865 for(i=0; i<count; i++) {
876 int64_t file_size,data_size;
907 .mime_type =
"video/x-ms-asf",
908 .extensions =
"asf,wmv,wma",
922 #if CONFIG_ASF_STREAM_MUXER
924 .
name =
"asf_stream",
926 .mime_type =
"video/x-ms-asf",
927 .extensions =
"asf,wmv,wma",
939 #endif //CONFIG_ASF_STREAM_MUXER