35 #define ASF_INDEXED_INTERVAL 10000000
36 #define ASF_INDEX_BLOCK (1<<9)
37 #define ASF_PAYLOADS_PER_PACKET 63
39 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
40 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
41 (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
42 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
44 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
45 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
47 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
50 #define ASF_PPI_PROPERTY_FLAGS \
51 (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
52 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
53 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
54 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
56 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
58 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
60 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
61 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
63 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
64 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
66 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
67 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
69 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
70 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
73 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
74 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
76 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
77 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
79 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
80 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
82 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
83 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
86 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
87 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
89 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
90 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
92 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
93 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
95 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
96 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
99 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
100 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
102 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
103 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
105 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
106 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
108 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
109 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
112 #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))
113 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
115 #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))
116 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
118 #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))
119 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
121 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
122 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
125 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
126 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
128 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
129 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
131 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
132 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
134 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
135 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
138 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
139 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
141 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
142 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
144 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
145 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
148 #define PACKET_HEADER_MIN_SIZE \
149 (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
150 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
153 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
154 ASF_PPI_SEQUENCE_FIELD_SIZE + \
155 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
160 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
162 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
164 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
165 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
166 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
167 ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
169 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
171 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
172 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
173 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
174 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
175 ASF_PAYLOAD_LENGTH_FIELD_SIZE)
177 #define SINGLE_PAYLOAD_DATA_LENGTH \
179 PACKET_HEADER_MIN_SIZE - \
180 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
182 #define MULTI_PAYLOAD_CONSTANT \
184 PACKET_HEADER_MIN_SIZE - \
186 2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
188 #define DATA_HEADER_SIZE 50
199 int packet_size_left;
206 uint64_t data_offset;
225 #define PREROLL_TIME 3100
265 int payload_length,
int flags)
271 length = payload_length + 8;
285 t = ti * INT64_C(10000000);
286 t += INT64_C(116444736000000000);
296 if (pres_time <= asf->index_ptr[i].send_time)
302 return send_time / 10000;
350 int64_t data_chunk_size)
355 int header_size,
n, extra_size, extra_size2, wav_extra_size, file_time;
356 int has_title, has_aspect_ratio = 0;
359 int64_t header_offset, cur_pos, hpos;
372 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
419 if (has_aspect_ratio) {
421 avio_wl32(pb, 26 + has_aspect_ratio * 84);
474 if (metadata_count) {
503 extra_size = 18 + wav_extra_size;
509 extra_size = 0x33 + wav_extra_size;
535 if (wavsize != extra_size) {
584 desc =
"Windows Media Audio V8";
586 desc = codec_desc ? codec_desc->
name : NULL;
623 header_size = cur_pos - header_offset;
627 avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
629 avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
634 header_size += 24 + 6;
635 avio_seek(pb, header_offset - 14, SEEK_SET);
676 NULL, NULL, NULL, NULL);
694 unsigned sendtime,
unsigned duration,
695 int nb_payloads,
int padsize)
744 int packet_hdr_size, packet_filled_size;
758 av_assert0(packet_hdr_size <= asf->packet_size_left);
769 NULL, NULL, NULL, NULL);
773 int64_t presentation_time,
int m_obj_size,
774 int m_obj_offset,
int payload_len,
int flags)
796 avio_wl32(pb, (uint32_t) presentation_time);
805 int m_obj_size,
int flags)
808 int m_obj_offset, payload_len, frag_len1;
811 while (m_obj_offset < m_obj_size) {
812 payload_len = m_obj_size - m_obj_offset;
829 if (frag_len1 < payload_len &&
836 if (payload_len > frag_len1)
837 payload_len = frag_len1;
838 else if (payload_len == (frag_len1 - 1))
839 payload_len = frag_len1 - 2;
842 m_obj_size, m_obj_offset, payload_len, flags);
855 m_obj_offset += payload_len;
869 uint32_t packet_number, uint16_t packet_count,
870 uint64_t packet_offset)
916 uint32_t packet_number;
943 uint16_t packet_count = asf->
nb_packets - packet_number;
944 ret =
update_index(s, start_sec, packet_number, packet_count, offset);
954 uint16_t max, uint32_t
count)
960 avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
965 for (i = 0; i <
count; i++) {
976 int64_t file_size, data_size;
1005 #if CONFIG_ASF_MUXER
1009 .mime_type =
"video/x-ms-asf",
1010 .extensions =
"asf,wmv,wma",
1024 #if CONFIG_ASF_STREAM_MUXER
1026 .
name =
"asf_stream",
1028 .mime_type =
"video/x-ms-asf",
1029 .extensions =
"asf,wmv,wma",