33 #define ASF_INDEXED_INTERVAL 10000000
34 #define ASF_INDEX_BLOCK (1<<9)
36 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
37 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
38 (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
39 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)
53 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
55 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
57 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
58 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
60 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
61 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
63 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
64 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
66 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
67 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
70 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
71 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
73 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
74 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
76 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
77 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
79 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
80 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
83 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
84 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
86 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
87 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
89 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
90 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
92 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
93 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
96 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
97 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
99 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
100 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
102 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
103 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
105 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
106 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
109 #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))
110 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
112 #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))
113 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
115 #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))
116 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
118 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
119 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
122 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
123 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
125 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
126 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
128 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
129 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
131 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
132 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
135 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
136 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
138 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
139 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
141 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
142 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
145 #define PACKET_HEADER_MIN_SIZE \
146 (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
147 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
150 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
151 ASF_PPI_SEQUENCE_FIELD_SIZE + \
152 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
157 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
159 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
161 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
162 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
163 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
164 ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
166 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
168 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
169 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
170 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
171 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
172 ASF_PAYLOAD_LENGTH_FIELD_SIZE)
174 #define SINGLE_PAYLOAD_DATA_LENGTH \
176 PACKET_HEADER_MIN_SIZE - \
177 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
179 #define MULTI_PAYLOAD_CONSTANT \
181 PACKET_HEADER_MIN_SIZE - \
183 2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
194 int packet_size_left;
201 uint64_t data_offset;
219 #define PREROLL_TIME 3100
223 assert(
sizeof(*g) == 16);
265 int payload_length,
int flags)
271 length = payload_length + 8;
285 t = ti * INT64_C(10000000);
286 t += INT64_C(116444736000000000);
292 int64_t data_chunk_size)
297 int header_size, n,
extra_size, extra_size2, wav_extra_size, file_time;
301 int64_t header_offset, cur_pos, hpos;
314 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
380 if (metadata_count) {
404 extra_size = 18 + wav_extra_size;
410 extra_size = 0x33 + wav_extra_size;
436 if (wavsize != extra_size) {
488 desc =
"Windows Media Audio V8";
520 header_size = cur_pos - header_offset;
522 header_size += 8 + 30 + 50;
524 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
526 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
529 header_size -= 8 + 30 + 50;
531 header_size += 24 + 6;
532 avio_seek(pb, header_offset - 14, SEEK_SET);
590 unsigned sendtime,
unsigned duration,
591 int nb_payloads,
int padsize)
603 assert(padsize >= 0);
640 int packet_hdr_size, packet_filled_size;
654 assert(packet_hdr_size <= asf->packet_size_left);
669 int64_t presentation_time,
int m_obj_size,
670 int m_obj_offset,
int payload_len,
int flags)
692 avio_wl32(pb, (uint32_t) presentation_time);
700 int64_t timestamp,
const uint8_t *buf,
701 int m_obj_size,
int flags)
704 int m_obj_offset, payload_len, frag_len1;
707 while (m_obj_offset < m_obj_size) {
708 payload_len = m_obj_size - m_obj_offset;
725 if (frag_len1 < payload_len &&
732 if (payload_len > frag_len1)
733 payload_len = frag_len1;
734 else if (payload_len == (frag_len1 - 1))
735 payload_len = frag_len1 - 2;
738 m_obj_size, m_obj_offset, payload_len, flags);
751 m_obj_offset += payload_len;
763 uint32_t packet_number, uint16_t packet_count)
795 uint32_t packet_number;
820 uint16_t packet_count = asf->
nb_packets - packet_number;
821 update_index(s, start_sec, packet_number, packet_count);
829 uint16_t max, uint32_t count)
835 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
840 for (i = 0; i < count; i++) {
851 int64_t file_size, data_size;
882 .mime_type =
"video/x-ms-asf",
883 .extensions =
"asf,wmv,wma",
897 #if CONFIG_ASF_STREAM_MUXER
899 .
name =
"asf_stream",
901 .mime_type =
"video/x-ms-asf",
902 .extensions =
"asf,wmv,wma",