FFmpeg
asfenc.c
Go to the documentation of this file.
1 /*
2  * ASF muxer
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "config_components.h"
23 
24 #include "libavutil/avassert.h"
25 #include "libavutil/dict.h"
26 #include "libavutil/mathematics.h"
27 #include "libavutil/opt.h"
28 #include "libavcodec/codec_desc.h"
29 #include "avformat.h"
30 #include "avlanguage.h"
31 #include "avio_internal.h"
32 #include "internal.h"
33 #include "mux.h"
34 #include "riff.h"
35 #include "asf.h"
36 
37 #define ASF_INDEXED_INTERVAL 10000000
38 #define ASF_INDEX_BLOCK (1<<9)
39 #define ASF_PAYLOADS_PER_PACKET 63
40 
41 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
42 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
43  (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
44  ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
45 
46 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
47 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
48 #else
49 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
50 #endif
51 
52 #define ASF_PPI_PROPERTY_FLAGS \
53  (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
54  ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
55  ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
56  ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
57 
58 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
59 
60 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
61 
62 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
63 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1
64 #endif
65 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
66 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2
67 #endif
68 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE))
69 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4
70 #endif
71 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
72 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
73 #endif
74 
75 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
76 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
77 #endif
78 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
79 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
80 #endif
81 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
82 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
83 #endif
84 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
85 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
86 #endif
87 
88 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
89 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
90 #endif
91 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
92 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
93 #endif
94 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
95 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
96 #endif
97 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
98 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
99 #endif
100 
101 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
102 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
103 #endif
104 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
105 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
106 #endif
107 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
108 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
109 #endif
110 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
111 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
112 #endif
113 
114 #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))
115 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
116 #endif
117 #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))
118 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
119 #endif
120 #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))
121 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
122 #endif
123 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
124 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
125 #endif
126 
127 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
128 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
129 #endif
130 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
131 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
132 #endif
133 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
134 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
135 #endif
136 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
137 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
138 #endif
139 
140 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
141 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
142 #endif
143 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
144 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
145 #endif
146 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
147 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
148 #endif
149 
150 #define PACKET_HEADER_MIN_SIZE \
151  (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
152  ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
153  1 + /* Length Type Flags */ \
154  1 + /* Property Flags */ \
155  ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
156  ASF_PPI_SEQUENCE_FIELD_SIZE + \
157  ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
158  4 + /* Send Time Field */ \
159  2) /* Duration Field */
160 
161 // Replicated Data shall be at least 8 bytes long.
162 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
163 
164 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
165  (1 + /* Stream Number */ \
166  ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
167  ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
168  ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
169  ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
170 
171 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
172  (1 + /* Stream Number */ \
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)
178 
179 #define SINGLE_PAYLOAD_HEADERS \
180  (PACKET_HEADER_MIN_SIZE + \
181  PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
182 
183 #define MULTI_PAYLOAD_HEADERS \
184  (PACKET_HEADER_MIN_SIZE + \
185  1 + /* Payload Flags */ \
186  2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
187 
188 #define DATA_HEADER_SIZE 50
189 
190 #define PACKET_SIZE_MAX 65536
191 #define PACKET_SIZE_MIN 100
192 
193 typedef struct ASFStream {
194  int num;
195  unsigned char seq;
196 
197  uint16_t stream_language_index;
198 } ASFStream;
199 
200 typedef struct ASFContext {
202  uint32_t seqno;
204  ASFStream streams[128]; ///< it's max number and it's not that big
205  const char *languages[128];
207  int64_t creation_time;
208  /* non-streamed additional info */
209  uint64_t nb_packets; ///< how many packets are there in the file, invalid if broadcasting
210  int64_t duration; ///< in 100ns units
211  /* packet filling */
212  unsigned char multi_payloads_present;
213  int packet_size_left;
216  unsigned int packet_nb_payloads;
219  /* only for reading */
220  uint64_t data_offset; ///< beginning of the first data packet
221 
224  uint16_t maximum_packet;
229  int end_sec;
231 } ASFContext;
232 
233 static const AVCodecTag codec_asf_bmp_tags[] = {
234  { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
235  { AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
236  { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
237  { AV_CODEC_ID_NONE, 0 },
238 };
239 
240 static const AVCodecTag *const asf_codec_tags[] = {
242 };
243 
244 #define PREROLL_TIME 3100
245 
246 static void put_str16(AVIOContext *s, AVIOContext *dyn_buf, const char *tag)
247 {
248  uint8_t *buf;
249  int len;
250 
251  avio_put_str16le(dyn_buf, tag);
252  len = avio_get_dyn_buf(dyn_buf, &buf);
253  avio_wl16(s, len);
254  avio_write(s, buf, len);
255  ffio_reset_dyn_buf(dyn_buf);
256 }
257 
258 static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
259 {
260  int64_t pos;
261 
262  pos = avio_tell(pb);
263  ff_put_guid(pb, g);
264  avio_wl64(pb, 24);
265  return pos;
266 }
267 
268 /* update header size */
269 static void end_header(AVIOContext *pb, int64_t pos)
270 {
271  int64_t pos1;
272 
273  pos1 = avio_tell(pb);
274  avio_seek(pb, pos + 16, SEEK_SET);
275  avio_wl64(pb, pos1 - pos);
276  avio_seek(pb, pos1, SEEK_SET);
277 }
278 
279 /* write an asf chunk (only used in streaming case) */
280 static void put_chunk(AVFormatContext *s, int type,
281  int payload_length, int flags)
282 {
283  ASFContext *asf = s->priv_data;
284  AVIOContext *pb = s->pb;
285  int length;
286 
287  length = payload_length + 8;
288  avio_wl16(pb, type);
289  avio_wl16(pb, length); // size
290  avio_wl32(pb, asf->seqno); // sequence number
291  avio_wl16(pb, flags); // unknown bytes
292  avio_wl16(pb, length); // size_confirm
293  asf->seqno++;
294 }
295 
296 /* convert from av time to windows time */
297 static int64_t unix_to_file_time(int64_t ti)
298 {
299  int64_t t;
300 
301  t = ti * INT64_C(10);
302  t += INT64_C(116444736000000000);
303  return t;
304 }
305 
306 static int32_t get_send_time(ASFContext *asf, int64_t pres_time, uint64_t *offset)
307 {
308  int32_t send_time = 0;
310  for (int i = 0; i < asf->next_start_sec; i++) {
311  if (pres_time <= asf->index_ptr[i].send_time)
312  break;
313  send_time = asf->index_ptr[i].send_time;
314  *offset = asf->index_ptr[i].offset;
315  }
316 
317  return send_time / 10000;
318 }
319 
321 {
322  ASFContext *asf = s->priv_data;
323  AVIOContext *pb = s->pb;
324  AVRational scale = {1, 10000000};
325  int64_t hpos = put_header(pb, &ff_asf_marker_header);
326 
327  ff_put_guid(pb, &ff_asf_reserved_4);// ASF spec mandates this reserved value
328  avio_wl32(pb, s->nb_chapters); // markers count
329  avio_wl16(pb, 0); // ASF spec mandates 0 for this
330  avio_wl16(pb, 0); // name length 0, no name given
331 
332  for (unsigned i = 0; i < s->nb_chapters; i++) {
333  AVChapter *c = s->chapters[i];
334  AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
335  int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
336  uint64_t offset;
337  int32_t send_time = get_send_time(asf, pres_time, &offset);
338  int len = 0;
339  uint8_t *buf;
340  if (t) {
341  avio_put_str16le(dyn_buf, t->value);
342  len = avio_get_dyn_buf(dyn_buf, &buf);
343  }
344  avio_wl64(pb, offset); // offset of the packet with send_time
345  avio_wl64(pb, pres_time + PREROLL_TIME * 10000); // presentation time
346  avio_wl16(pb, 12 + len); // entry length
347  avio_wl32(pb, send_time); // send time
348  avio_wl32(pb, 0); // flags, should be 0
349  avio_wl32(pb, len / 2); // marker desc length in WCHARS!
350  if (t) {
351  avio_write(pb, buf, len); // marker desc
352  ffio_reset_dyn_buf(dyn_buf);
353  }
354  }
355  end_header(pb, hpos);
356 }
357 
358 /* write the header (used two times if non streamed) */
359 static int asf_write_header1(AVFormatContext *s, int64_t file_size,
360  int64_t data_chunk_size)
361 {
362  ASFContext *asf = s->priv_data;
363  AVIOContext *pb = s->pb, *dyn_buf;
364  AVDictionaryEntry *tags[5];
365  int header_size, extra_size, extra_size2, wav_extra_size;
366  int has_title, has_aspect_ratio = 0;
367  int metadata_count;
368  int64_t header_offset, cur_pos, hpos;
369  int bit_rate, ret;
370  int64_t duration;
371  int audio_language_counts[128] = { 0 };
372 
374 
375  tags[0] = av_dict_get(s->metadata, "title", NULL, 0);
376  tags[1] = av_dict_get(s->metadata, "author", NULL, 0);
377  tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
378  tags[3] = av_dict_get(s->metadata, "comment", NULL, 0);
379  tags[4] = av_dict_get(s->metadata, "rating", NULL, 0);
380 
381  duration = asf->duration + PREROLL_TIME * 10000;
382  has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
383 
384  if (!file_size) {
385  if (ff_parse_creation_time_metadata(s, &asf->creation_time, 0) != 0)
386  av_dict_set(&s->metadata, "creation_time", NULL, 0);
387  }
388 
389  metadata_count = av_dict_count(s->metadata);
390 
391  bit_rate = 0;
392  for (unsigned n = 0; n < s->nb_streams; n++) {
393  AVStream *const st = s->streams[n];
394  AVCodecParameters *const par = st->codecpar;
395  AVDictionaryEntry *entry;
396 
397  avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
398 
399  bit_rate += par->bit_rate;
400  if ( par->codec_type == AVMEDIA_TYPE_VIDEO
401  && par->sample_aspect_ratio.num > 0
402  && par->sample_aspect_ratio.den > 0)
403  has_aspect_ratio++;
404 
405  entry = av_dict_get(s->streams[n]->metadata, "language", NULL, 0);
406  if (entry) {
407  const char *iso6391lang = ff_convert_lang_to(entry->value, AV_LANG_ISO639_1);
408  if (iso6391lang) {
409  int i;
410  for (i = 0; i < asf->nb_languages; i++) {
411  if (!strcmp(asf->languages[i], iso6391lang)) {
412  asf->streams[n].stream_language_index = i;
413  break;
414  }
415  }
416  if (i >= asf->nb_languages) {
417  asf->languages[asf->nb_languages] = iso6391lang;
419  asf->nb_languages++;
420  }
421  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
422  audio_language_counts[asf->streams[n].stream_language_index]++;
423  }
424  } else {
425  asf->streams[n].stream_language_index = 128;
426  }
427  }
428 
429  if (asf->is_streamed) {
430  put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */
431  }
432 
434  avio_wl64(pb, -1); /* header length, will be patched after */
435  avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
436  avio_w8(pb, 1); /* ??? */
437  avio_w8(pb, 2); /* ??? */
438 
439  /* file header */
440  header_offset = avio_tell(pb);
441  hpos = put_header(pb, &ff_asf_file_header);
443  avio_wl64(pb, file_size);
445  avio_wl64(pb, asf->nb_packets); /* number of packets */
446  avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
447  avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
448  avio_wl64(pb, PREROLL_TIME); /* start time stamp */
449  avio_wl32(pb, (asf->is_streamed || !(pb->seekable & AVIO_SEEKABLE_NORMAL)) ? 3 : 2); /* ??? */
450  avio_wl32(pb, s->packet_size); /* packet size */
451  avio_wl32(pb, s->packet_size); /* packet size */
452  avio_wl32(pb, bit_rate ? bit_rate : -1); /* Maximum data rate in bps */
453  end_header(pb, hpos);
454 
455  /* header_extension */
456  hpos = put_header(pb, &ff_asf_head1_guid);
458  avio_wl16(pb, 6);
459  avio_wl32(pb, 0); /* length, to be filled later */
460  if (asf->nb_languages) {
461  int64_t hpos2;
462  int nb_audio_languages = 0;
463 
464  hpos2 = put_header(pb, &ff_asf_language_guid);
465  avio_wl16(pb, asf->nb_languages);
466  for (int i = 0; i < asf->nb_languages; i++) {
467  avio_w8(pb, 6);
468  avio_put_str16le(pb, asf->languages[i]);
469  }
470  end_header(pb, hpos2);
471 
472  for (int i = 0; i < asf->nb_languages; i++)
473  if (audio_language_counts[i])
474  nb_audio_languages++;
475 
476  if (nb_audio_languages > 1) {
479  avio_wl16(pb, nb_audio_languages);
480  for (int i = 0; i < asf->nb_languages; i++) {
481  if (audio_language_counts[i]) {
482  avio_wl16(pb, audio_language_counts[i]);
483  for (unsigned n = 0; n < s->nb_streams; n++)
484  if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
485  avio_wl16(pb, n + 1);
486  }
487  }
488  end_header(pb, hpos2);
489  }
490 
491  for (unsigned n = 0; n < s->nb_streams; n++) {
492  int64_t es_pos;
493  if (asf->streams[n].stream_language_index > 127)
494  continue;
496  avio_wl64(pb, 0); /* start time */
497  avio_wl64(pb, 0); /* end time */
498  avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* data bitrate bps */
499  avio_wl32(pb, 5000); /* buffer size ms */
500  avio_wl32(pb, 0); /* initial buffer fullness */
501  avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* peak data bitrate */
502  avio_wl32(pb, 5000); /* maximum buffer size ms */
503  avio_wl32(pb, 0); /* max initial buffer fullness */
504  avio_wl32(pb, 0); /* max object size */
505  avio_wl32(pb, (!asf->is_streamed && (pb->seekable & AVIO_SEEKABLE_NORMAL)) << 1); /* flags - seekable */
506  avio_wl16(pb, n + 1); /* stream number */
507  avio_wl16(pb, asf->streams[n].stream_language_index); /* language id index */
508  avio_wl64(pb, 0); /* avg time per frame */
509  avio_wl16(pb, 0); /* stream name count */
510  avio_wl16(pb, 0); /* payload extension system count */
511  end_header(pb, es_pos);
512  }
513  }
514  if (has_aspect_ratio) {
515  int64_t hpos2;
516  hpos2 = put_header(pb, &ff_asf_metadata_header);
517  avio_wl16(pb, 2 * has_aspect_ratio);
518  for (unsigned n = 0; n < s->nb_streams; n++) {
519  AVCodecParameters *const par = s->streams[n]->codecpar;
520  if ( par->codec_type == AVMEDIA_TYPE_VIDEO
521  && par->sample_aspect_ratio.num > 0
522  && par->sample_aspect_ratio.den > 0) {
523  AVRational sar = par->sample_aspect_ratio;
524  avio_wl16(pb, 0);
525  // the stream number is set like this below
526  avio_wl16(pb, n + 1);
527  avio_wl16(pb, 26); // name_len
528  avio_wl16(pb, 3); // value_type
529  avio_wl32(pb, 4); // value_len
530  avio_put_str16le(pb, "AspectRatioX");
531  avio_wl32(pb, sar.num);
532  avio_wl16(pb, 0);
533  // the stream number is set like this below
534  avio_wl16(pb, n + 1);
535  avio_wl16(pb, 26); // name_len
536  avio_wl16(pb, 3); // value_type
537  avio_wl32(pb, 4); // value_len
538  avio_put_str16le(pb, "AspectRatioY");
539  avio_wl32(pb, sar.den);
540  }
541  }
542  end_header(pb, hpos2);
543  }
544  {
545  int64_t pos1;
546  pos1 = avio_tell(pb);
547  avio_seek(pb, hpos + 42, SEEK_SET);
548  avio_wl32(pb, pos1 - hpos - 46);
549  avio_seek(pb, pos1, SEEK_SET);
550  }
551  end_header(pb, hpos);
552 
553  if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
554  return ret;
555 
556  /* title and other info */
557  if (has_title) {
558  uint8_t *buf;
559  int len;
560 
561  hpos = put_header(pb, &ff_asf_comment_header);
562 
563  for (size_t n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
564  len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
565  avio_wl16(pb, len);
566  }
567  len = avio_get_dyn_buf(dyn_buf, &buf);
568  avio_write(pb, buf, len);
569  ffio_reset_dyn_buf(dyn_buf);
570  end_header(pb, hpos);
571  }
572  if (metadata_count) {
573  const AVDictionaryEntry *tag = NULL;
575  avio_wl16(pb, metadata_count);
576  while ((tag = av_dict_iterate(s->metadata, tag))) {
577  put_str16(pb, dyn_buf, tag->key);
578  avio_wl16(pb, 0);
579  put_str16(pb, dyn_buf, tag->value);
580  }
581  end_header(pb, hpos);
582  }
583  /* chapters using ASF markers */
584  if (!asf->is_streamed && s->nb_chapters) {
585  asf_write_markers(s, dyn_buf);
586  }
587  /* stream headers */
588  for (unsigned n = 0; n < s->nb_streams; n++) {
589  AVCodecParameters *const par = s->streams[n]->codecpar;
590  int64_t es_pos;
591  // ASFStream *stream = &asf->streams[n];
592 
593  asf->streams[n].num = n + 1;
594  asf->streams[n].seq = 1;
595 
596  switch (par->codec_type) {
597  case AVMEDIA_TYPE_AUDIO:
598  wav_extra_size = 0;
599  extra_size = 18 + wav_extra_size;
600  extra_size2 = 8;
601  break;
602  default:
603  case AVMEDIA_TYPE_VIDEO:
604  wav_extra_size = par->extradata_size;
605  extra_size = 0x33 + wav_extra_size;
606  extra_size2 = 0;
607  break;
608  }
609 
610  hpos = put_header(pb, &ff_asf_stream_header);
611  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
614  } else {
617  }
618  avio_wl64(pb, 0); /* ??? */
619  es_pos = avio_tell(pb);
620  avio_wl32(pb, extra_size); /* wav header len */
621  avio_wl32(pb, extra_size2); /* additional data len */
622  avio_wl16(pb, n + 1); /* stream number */
623  avio_wl32(pb, 0); /* ??? */
624 
625  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
626  /* WAVEFORMATEX header */
628 
629  if (wavsize < 0) {
630  ret = wavsize;
631  goto fail;
632  }
633  if (wavsize != extra_size) {
634  cur_pos = avio_tell(pb);
635  avio_seek(pb, es_pos, SEEK_SET);
636  avio_wl32(pb, wavsize); /* wav header len */
637  avio_seek(pb, cur_pos, SEEK_SET);
638  }
639  /* ERROR Correction */
640  avio_w8(pb, 0x01);
641  if (par->codec_id == AV_CODEC_ID_ADPCM_G726 || !par->block_align) {
642  avio_wl16(pb, 0x0190);
643  avio_wl16(pb, 0x0190);
644  } else {
645  avio_wl16(pb, par->block_align);
646  avio_wl16(pb, par->block_align);
647  }
648  avio_wl16(pb, 0x01);
649  avio_w8(pb, 0x00);
650  } else {
651  avio_wl32(pb, par->width);
652  avio_wl32(pb, par->height);
653  avio_w8(pb, 2); /* ??? */
654  avio_wl16(pb, 40 + par->extradata_size); /* size */
655 
656  /* BITMAPINFOHEADER header */
657  ff_put_bmp_header(pb, par, 1, 0, 0);
658  }
659  end_header(pb, hpos);
660  }
661 
662  /* media comments */
663 
666  avio_wl32(pb, s->nb_streams);
667  for (unsigned n = 0; n < s->nb_streams; n++) {
668  AVCodecParameters *const par = s->streams[n]->codecpar;
669  const AVCodecDescriptor *const codec_desc = avcodec_descriptor_get(par->codec_id);
670  const char *desc;
671 
672  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
673  avio_wl16(pb, 2);
674  else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
675  avio_wl16(pb, 1);
676  else
677  avio_wl16(pb, -1);
678 
679  if (par->codec_id == AV_CODEC_ID_WMAV2)
680  desc = "Windows Media Audio V8";
681  else
682  desc = codec_desc ? codec_desc->name : NULL;
683 
684  if (desc) {
685  uint8_t *buf;
686  int len;
687 
688  avio_put_str16le(dyn_buf, desc);
689  len = avio_get_dyn_buf(dyn_buf, &buf);
690  avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
691 
692  avio_write(pb, buf, len);
693  ffio_reset_dyn_buf(dyn_buf);
694  } else
695  avio_wl16(pb, 0);
696 
697  avio_wl16(pb, 0); /* no parameters */
698 
699  /* id */
700  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
701  avio_wl16(pb, 2);
702  avio_wl16(pb, par->codec_tag);
703  } else {
704  avio_wl16(pb, 4);
705  avio_wl32(pb, par->codec_tag);
706  }
707  if (!par->codec_tag) {
708  ret = AVERROR(EINVAL);
709  goto fail;
710  }
711  }
712  end_header(pb, hpos);
713 
714  /* patch the header size fields */
715 
716  cur_pos = avio_tell(pb);
717  header_size = cur_pos - header_offset;
718  if (asf->is_streamed) {
719  header_size += 8 + 30 + DATA_HEADER_SIZE;
720 
721  avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
722  avio_wl16(pb, header_size);
723  avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
724  avio_wl16(pb, header_size);
725 
726  header_size -= 8 + 30 + DATA_HEADER_SIZE;
727  }
728  header_size += 24 + 6;
729  avio_seek(pb, header_offset - 14, SEEK_SET);
730  avio_wl64(pb, header_size);
731  avio_seek(pb, cur_pos, SEEK_SET);
732 
733  /* movie chunk, followed by packets of packet_size */
734  asf->data_offset = cur_pos;
736  avio_wl64(pb, data_chunk_size);
738  avio_wl64(pb, asf->nb_packets); /* nb packets */
739  avio_w8(pb, 1); /* ??? */
740  avio_w8(pb, 1); /* ??? */
741  ret = 0;
742 fail:
743  ffio_free_dyn_buf(&dyn_buf);
744  return ret;
745 }
746 
748 {
749  ASFContext *asf = s->priv_data;
750  int ret;
751 
752  s->packet_size = asf->packet_size;
753  s->max_interleave_delta = 0;
754  asf->nb_packets = 0;
755 
756  if (s->nb_streams > 127) {
757  av_log(s, AV_LOG_ERROR, "ASF can only handle 127 streams\n");
758  return AVERROR(EINVAL);
759  }
760 
761  asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
762  if (!asf->index_ptr)
763  return AVERROR(ENOMEM);
765  asf->maximum_packet = 0;
766 
767  /* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
768  * data_size - asf->data_offset at the moment this function is done.
769  * It is needed to use asf as a streamable format. */
770  if ((ret = asf_write_header1(s, 0, DATA_HEADER_SIZE)) < 0)
771  return ret;
772 
773  asf->packet_nb_payloads = 0;
774  asf->packet_timestamp_start = -1;
775  asf->packet_timestamp_end = -1;
776  ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
777  NULL, NULL, NULL, NULL);
778 
779  if (s->avoid_negative_ts < 0)
780  s->avoid_negative_ts = 1;
781 
782  return 0;
783 }
784 
786 {
787  ASFContext *asf = s->priv_data;
788 
789  asf->is_streamed = 1;
790 
791  return asf_write_header(s);
792 }
793 
795  unsigned sendtime, unsigned duration,
796  int nb_payloads, int padsize)
797 {
798  ASFContext *asf = s->priv_data;
799  AVIOContext *pb = s->pb;
800  int ppi_size;
801  int64_t start = avio_tell(pb);
802 
803  int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
804 
805  padsize -= PACKET_HEADER_MIN_SIZE;
806  if (asf->multi_payloads_present)
807  padsize--;
808  av_assert0(padsize >= 0);
809 
812 
813  if (asf->multi_payloads_present)
814  iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT;
815 
816  if (padsize > 0) {
817  if (padsize < 256)
818  iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE;
819  else
820  iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD;
821  }
822  avio_w8(pb, iLengthTypeFlags);
823 
825 
826  if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD)
827  avio_wl16(pb, padsize - 2);
828  if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE)
829  avio_w8(pb, padsize - 1);
830 
831  avio_wl32(pb, sendtime);
832  avio_wl16(pb, duration);
833  if (asf->multi_payloads_present)
834  avio_w8(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
835 
836  ppi_size = avio_tell(pb) - start;
837 
838  return ppi_size;
839 }
840 
842 {
843  ASFContext *asf = s->priv_data;
844  int packet_hdr_size, packet_filled_size;
845 
847 
848  if (asf->is_streamed)
849  put_chunk(s, 0x4424, s->packet_size, 0);
850 
851  packet_hdr_size = put_payload_parsing_info(s,
854  asf->packet_nb_payloads,
855  asf->packet_size_left);
856 
857  packet_filled_size = asf->packet_size - asf->packet_size_left;
858  av_assert0(packet_hdr_size <= asf->packet_size_left);
859  memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
860 
861  avio_write(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
862 
864 
865  asf->nb_packets++;
866  asf->packet_nb_payloads = 0;
867  asf->packet_timestamp_start = -1;
868  asf->packet_timestamp_end = -1;
869  ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
870  NULL, NULL, NULL, NULL);
871 }
872 
874  int64_t presentation_time, int m_obj_size,
875  int m_obj_offset, int payload_len, int flags)
876 {
877  ASFContext *asf = s->priv_data;
878  AVIOContext *const pb = &asf->pb.pub;
879  int val;
880 
881  val = stream->num;
882  if (flags & AV_PKT_FLAG_KEY)
884  avio_w8(pb, val);
885 
886  avio_w8(pb, stream->seq); // Media object number
887  avio_wl32(pb, m_obj_offset); // Offset Into Media Object
888 
889  // Replicated Data shall be at least 8 bytes long.
890  // The first 4 bytes of data shall contain the
891  // Size of the Media Object that the payload belongs to.
892  // The next 4 bytes of data shall contain the
893  // Presentation Time for the media object that the payload belongs to.
895 
896  avio_wl32(pb, m_obj_size); // Replicated Data - Media Object Size
897  avio_wl32(pb, (uint32_t) presentation_time); // Replicated Data - Presentation Time
898 
899  if (asf->multi_payloads_present) {
900  avio_wl16(pb, payload_len); // payload length
901  }
902 }
903 
904 static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst,
905  int64_t timestamp, const uint8_t *buf,
906  int m_obj_size, int flags)
907 {
908  ASFContext *asf = s->priv_data;
909  int m_obj_offset, payload_len, frag_len1;
910 
911  m_obj_offset = 0;
912  while (m_obj_offset < m_obj_size) {
913  payload_len = m_obj_size - m_obj_offset;
914  if (asf->packet_timestamp_start == -1) {
915  const int multi_payload_constant = (asf->packet_size - MULTI_PAYLOAD_HEADERS);
916  asf->multi_payloads_present = (payload_len < multi_payload_constant);
917 
918  asf->packet_size_left = asf->packet_size;
919  if (asf->multi_payloads_present) {
920  frag_len1 = multi_payload_constant - 1;
921  } else {
922  frag_len1 = asf->packet_size - SINGLE_PAYLOAD_HEADERS;
923  }
924  asf->packet_timestamp_start = timestamp;
925  } else {
926  // multi payloads
927  frag_len1 = asf->packet_size_left -
930 
931  if (frag_len1 < payload_len &&
933  flush_packet(s);
934  continue;
935  }
936  if (asf->packet_timestamp_start > INT64_MAX - UINT16_MAX ||
937  timestamp > asf->packet_timestamp_start + UINT16_MAX) {
938  flush_packet(s);
939  continue;
940  }
941  }
942  if (frag_len1 > 0) {
943  if (payload_len > frag_len1)
944  payload_len = frag_len1;
945  else if (payload_len == (frag_len1 - 1))
946  payload_len = frag_len1 - 2; // additional byte need to put padding length
947 
948  put_payload_header(s, stream, timestamp + PREROLL_TIME,
949  m_obj_size, m_obj_offset, payload_len, flags);
950  avio_write(&asf->pb.pub, buf, payload_len);
951 
952  if (asf->multi_payloads_present)
954  else
956  asf->packet_timestamp_end = timestamp;
957 
958  asf->packet_nb_payloads++;
959  } else {
960  payload_len = 0;
961  }
962  m_obj_offset += payload_len;
963  buf += payload_len;
964 
965  if (!asf->multi_payloads_present)
966  flush_packet(s);
968  flush_packet(s);
970  flush_packet(s);
971  }
972  stream->seq++;
973 }
974 
975 static int update_index(AVFormatContext *s, int start_sec,
976  uint32_t packet_number, uint16_t packet_count,
977  uint64_t packet_offset)
978 {
979  ASFContext *asf = s->priv_data;
980 
981  if (start_sec > asf->next_start_sec) {
982  if (!asf->next_start_sec) {
983  asf->next_packet_number = packet_number;
984  asf->next_packet_count = packet_count;
985  asf->next_packet_offset = packet_offset;
986  }
987 
988  if (start_sec > asf->nb_index_memory_alloc) {
989  int err;
990  asf->nb_index_memory_alloc = (start_sec + ASF_INDEX_BLOCK) & ~(ASF_INDEX_BLOCK - 1);
991  if ((err = av_reallocp_array(&asf->index_ptr,
993  sizeof(*asf->index_ptr))) < 0) {
994  asf->nb_index_memory_alloc = 0;
995  return err;
996  }
997  }
998  for (int i = asf->next_start_sec; i < start_sec; i++) {
1001  asf->index_ptr[i].send_time = asf->next_start_sec * INT64_C(10000000);
1002  asf->index_ptr[i].offset = asf->next_packet_offset;
1003 
1004  }
1005  }
1006  asf->maximum_packet = FFMAX(asf->maximum_packet, packet_count);
1007  asf->next_packet_number = packet_number;
1008  asf->next_packet_count = packet_count;
1009  asf->next_packet_offset = packet_offset;
1010  asf->next_start_sec = start_sec;
1011 
1012  return 0;
1013 }
1014 
1016 {
1017  ASFContext *asf = s->priv_data;
1018  AVIOContext *pb = s->pb;
1019  ASFStream *stream;
1020  AVCodecParameters *par;
1021  uint32_t packet_number;
1022  int64_t pts;
1023  int start_sec;
1024  int flags = pkt->flags;
1025  int ret;
1026  uint64_t offset = avio_tell(pb);
1027 
1028  par = s->streams[pkt->stream_index]->codecpar;
1029  stream = &asf->streams[pkt->stream_index];
1030 
1031  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
1032  flags &= ~AV_PKT_FLAG_KEY;
1033 
1034  pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
1036  if ( pts < - PREROLL_TIME
1037  || pts > (INT_MAX-3)/10000LL * ASF_INDEXED_INTERVAL - PREROLL_TIME) {
1038  av_log(s, AV_LOG_ERROR, "input pts %"PRId64" is invalid\n", pts);
1039  return AVERROR(EINVAL);
1040  }
1041  pts *= 10000;
1042  asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);
1043 
1044  packet_number = asf->nb_packets;
1045  put_frame(s, stream, s->streams[pkt->stream_index],
1046  pkt->dts, pkt->data, pkt->size, flags);
1047 
1048  start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)
1050 
1051  /* check index */
1052  if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {
1053  uint16_t packet_count = asf->nb_packets - packet_number;
1054  ret = update_index(s, start_sec, packet_number, packet_count, offset);
1055  if (ret < 0)
1056  return ret;
1057  }
1058  asf->end_sec = start_sec;
1059 
1060  return 0;
1061 }
1062 
1064  uint16_t max, uint32_t count)
1065 {
1066  AVIOContext *pb = s->pb;
1067 
1069  avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
1072  avio_wl32(pb, max);
1073  avio_wl32(pb, count);
1074  for (uint32_t i = 0; i < count; i++) {
1075  avio_wl32(pb, index[i].packet_number);
1076  avio_wl16(pb, index[i].packet_count);
1077  }
1078 
1079  return 0;
1080 }
1081 
1083 {
1084  ASFContext *asf = s->priv_data;
1085  int64_t file_size, data_size;
1086  int ret;
1087 
1088  /* flush the current packet */
1089  if (asf->pb.pub.buf_ptr > asf->pb.pub.buffer)
1090  flush_packet(s);
1091 
1092  /* write index */
1093  data_size = avio_tell(s->pb);
1094  if (!asf->is_streamed && asf->next_start_sec) {
1095  if ((ret = update_index(s, asf->end_sec + 1, 0, 0, 0)) < 0)
1096  return ret;
1098  }
1099 
1100  if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
1101  put_chunk(s, 0x4524, 0, 0); /* end of stream */
1102  } else {
1103  /* rewrite an updated header */
1104  file_size = avio_tell(s->pb);
1105  avio_seek(s->pb, 0, SEEK_SET);
1106  asf_write_header1(s, file_size, data_size - asf->data_offset);
1107  }
1108 
1109  return 0;
1110 }
1111 
1113 {
1114  ASFContext *const asf = s->priv_data;
1115 
1116  av_freep(&asf->index_ptr);
1117 }
1118 
1119 static const AVOption asf_options[] = {
1120  { "packet_size", "Packet size", offsetof(ASFContext, packet_size), AV_OPT_TYPE_INT, {.i64 = 3200}, PACKET_SIZE_MIN, PACKET_SIZE_MAX, AV_OPT_FLAG_ENCODING_PARAM },
1121  { NULL },
1122 };
1123 
1124 static const AVClass asf_muxer_class = {
1125  .class_name = "ASF (stream) muxer",
1126  .item_name = av_default_item_name,
1127  .option = asf_options,
1128  .version = LIBAVUTIL_VERSION_INT,
1129 };
1130 
1131 #if CONFIG_ASF_MUXER
1132 const FFOutputFormat ff_asf_muxer = {
1133  .p.name = "asf",
1134  .p.long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"),
1135  .p.mime_type = "video/x-ms-asf",
1136  .p.extensions = "asf,wmv,wma",
1137  .p.audio_codec = AV_CODEC_ID_WMAV2,
1138  .p.video_codec = AV_CODEC_ID_MSMPEG4V3,
1139  .p.flags = AVFMT_GLOBALHEADER,
1140  .p.codec_tag = asf_codec_tags,
1141  .p.priv_class = &asf_muxer_class,
1142  .priv_data_size = sizeof(ASFContext),
1146  .deinit = asf_deinit,
1147 };
1148 #endif /* CONFIG_ASF_MUXER */
1149 
1150 #if CONFIG_ASF_STREAM_MUXER
1152  .p.name = "asf_stream",
1153  .p.long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"),
1154  .p.mime_type = "video/x-ms-asf",
1155  .p.extensions = "asf,wmv,wma",
1156  .priv_data_size = sizeof(ASFContext),
1157  .p.audio_codec = AV_CODEC_ID_WMAV2,
1158  .p.video_codec = AV_CODEC_ID_MSMPEG4V3,
1159  .write_header = asf_write_stream_header,
1160  .write_packet = asf_write_packet,
1161  .write_trailer = asf_write_trailer,
1162  .p.flags = AVFMT_GLOBALHEADER,
1163  .p.codec_tag = asf_codec_tags,
1164  .p.priv_class = &asf_muxer_class,
1165  .deinit = asf_deinit,
1166 };
1167 #endif /* CONFIG_ASF_STREAM_MUXER */
ASFContext::packet_size
int packet_size
Definition: asfenc.c:230
AV_LANG_ISO639_1
@ AV_LANG_ISO639_1
3-char terminological language codes as per ISO-IEC 639-2
Definition: avlanguage.h:30
ASF_INDEXED_INTERVAL
#define ASF_INDEXED_INTERVAL
Definition: asfenc.c:37
AVOutputFormat::name
const char * name
Definition: avformat.h:508
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:58
PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
#define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
Definition: asfenc.c:164
ASFIndex
Definition: asf.h:65
asf_muxer_class
static const AVClass asf_muxer_class
Definition: asfenc.c:1124
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:54
ASFContext::next_start_sec
int next_start_sec
Definition: asfenc.c:228
av_dict_count
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
Definition: dict.c:37
codec_asf_bmp_tags
static const AVCodecTag codec_asf_bmp_tags[]
Definition: asfenc.c:233
ff_put_bmp_header
void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int ignore_extradata, int rgb_frame_is_flipped)
Definition: riffenc.c:215
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
avlanguage.h
ff_asf_audio_stream
const ff_asf_guid ff_asf_audio_stream
Definition: asf_tags.c:39
ff_asf_simple_index_header
const ff_asf_guid ff_asf_simple_index_header
Definition: asf_tags.c:90
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
ff_metadata_conv
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:26
ASFContext::duration
int64_t duration
in 100ns units
Definition: asfenc.c:210
deinit
static void deinit(AVFormatContext *s)
Definition: chromaprint.c:50
AVPacket::data
uint8_t * data
Definition: packet.h:374
AVOption
AVOption.
Definition: opt.h:251
asf_deinit
static void asf_deinit(AVFormatContext *s)
Definition: asfenc.c:1112
ff_parse_creation_time_metadata
int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
Parse creation_time in AVFormatContext metadata if exists and warn if the parsing fails.
Definition: mux_utils.c:126
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:446
ff_codec_wav_tags
const AVCodecTag ff_codec_wav_tags[]
Definition: riff.c:513
put_chunk
static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags)
Definition: asfenc.c:280
AV_CODEC_ID_WMAV2
@ AV_CODEC_ID_WMAV2
Definition: codec_id.h:446
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:392
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:66
max
#define max(a, b)
Definition: cuda_runtime.h:33
mathematics.h
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ASFContext::packet_buf
uint8_t packet_buf[PACKET_SIZE_MAX]
Definition: asfenc.c:217
ASFContext::seqno
uint32_t seqno
Definition: asfenc.c:202
ASFContext::data_offset
uint64_t data_offset
beginning of the first data packet
Definition: asfdec_f.c:85
ASFContext::av_class
AVClass * av_class
Definition: asfenc.c:201
avio_get_dyn_buf
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1487
FFIOContext
Definition: avio_internal.h:29
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:429
ASFContext::nb_index_memory_alloc
uint32_t nb_index_memory_alloc
Definition: asfenc.c:223
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:34
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:458
avio_write_marker
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
Definition: aviobuf.c:482
asf_write_packet
static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: asfenc.c:1015
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:771
ASFContext::languages
const char * languages[128]
Definition: asfenc.c:205
ASFContext::streams
ASFStream streams[128]
it's max number and it's not that big
Definition: asfdec_f.c:77
fail
#define fail()
Definition: checkasm.h:134
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:500
ASF_PACKET_ERROR_CORRECTION_FLAGS
#define ASF_PACKET_ERROR_CORRECTION_FLAGS
Definition: asfenc.c:42
AVChapter
Definition: avformat.h:1063
val
static double val(void *priv, double ch)
Definition: aeval.c:77
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
ASF_PAYLOAD_REPLICATED_DATA_LENGTH
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH
Definition: asfenc.c:162
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
pts
static int64_t pts
Definition: transcode_aac.c:653
AVRational::num
int num
Numerator.
Definition: rational.h:59
ASFContext::end_sec
int end_sec
Definition: asfenc.c:229
ASFContext::next_packet_number
uint32_t next_packet_number
Definition: asfenc.c:225
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ASFContext::packet_timestamp_start
int64_t packet_timestamp_start
Definition: asfenc.c:214
AVCodecTag
Definition: internal.h:49
duration
int64_t duration
Definition: movenc.c:64
MULTI_PAYLOAD_HEADERS
#define MULTI_PAYLOAD_HEADERS
Definition: asfenc.c:183
PACKET_SIZE_MIN
#define PACKET_SIZE_MIN
Definition: asfenc.c:191
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1475
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:60
AV_CODEC_ID_ADPCM_G726
@ AV_CODEC_ID_ADPCM_G726
Definition: codec_id.h:376
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
ASFContext::maximum_packet
uint16_t maximum_packet
Definition: asfenc.c:224
ASFContext::packet_timestamp_end
int64_t packet_timestamp_end
Definition: asfenc.c:215
ff_asf_language_guid
const ff_asf_guid ff_asf_language_guid
Definition: asf_tags.c:124
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition: codec_par.h:138
g
const char * g
Definition: vf_curves.c:127
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:128
ff_asf_video_stream
const ff_asf_guid ff_asf_video_stream
Definition: asf_tags.c:47
ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
Definition: asfenc.c:41
ff_asf_mutex_language
const ff_asf_guid ff_asf_mutex_language
Definition: asf_tags.c:148
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
ASF_PAYLOAD_FLAGS
#define ASF_PAYLOAD_FLAGS
Definition: asfenc.c:60
ff_asf_codec_comment1_header
const ff_asf_guid ff_asf_codec_comment1_header
Definition: asf_tags.c:70
asf_write_header
static int asf_write_header(AVFormatContext *s)
Definition: asfenc.c:747
ASF_PAYLOADS_PER_PACKET
#define ASF_PAYLOADS_PER_PACKET
Definition: asfenc.c:39
ASFIndex::send_time
uint64_t send_time
Definition: asf.h:68
AVFormatContext
Format I/O context.
Definition: avformat.h:1104
put_str16
static void put_str16(AVIOContext *s, AVIOContext *dyn_buf, const char *tag)
Definition: asfenc.c:246
internal.h
ff_asf_extended_content_header
const ff_asf_guid ff_asf_extended_content_header
Definition: asf_tags.c:86
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:861
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
ff_asf_guid
uint8_t ff_asf_guid[16]
Definition: riff.h:95
ff_asf_muxer
const FFOutputFormat ff_asf_muxer
ff_put_wav_header
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
Definition: riffenc.c:54
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:101
ASFStream::seq
unsigned char seq
Definition: asfdec_f.c:49
ff_asf_metadata_conv
const AVMetadataConv ff_asf_metadata_conv[]
Definition: asf.c:27
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_asf_head1_guid
const ff_asf_guid ff_asf_head1_guid
Definition: asf_tags.c:78
ASFContext::pb
FFIOContext pb
Definition: asfenc.c:218
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
put_payload_parsing_info
static int put_payload_parsing_info(AVFormatContext *s, unsigned sendtime, unsigned duration, int nb_payloads, int padsize)
Definition: asfenc.c:794
FFOutputFormat
Definition: mux.h:30
ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE
#define ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE
Definition: asf.h:143
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:200
ff_asf_data_header
const ff_asf_guid ff_asf_data_header
Definition: asf_tags.c:74
ASFContext::nb_packets
uint64_t nb_packets
how many packets are there in the file, invalid if broadcasting
Definition: asfdec_o.c:96
ffio_fill
void ffio_fill(AVIOContext *s, int b, int64_t count)
Definition: aviobuf.c:208
ASFContext::packet_size_left
int packet_size_left
Definition: asfdec_f.c:83
ff_asf_extended_stream_properties_object
const ff_asf_guid ff_asf_extended_stream_properties_object
Definition: asf_tags.c:140
asf_codec_tags
static const AVCodecTag *const asf_codec_tags[]
Definition: asfenc.c:240
index
int index
Definition: gxfenc.c:89
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
put_payload_header
static void put_payload_header(AVFormatContext *s, ASFStream *stream, int64_t presentation_time, int m_obj_size, int m_obj_offset, int payload_len, int flags)
Definition: asfenc.c:873
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:80
ASFIndex::packet_number
uint32_t packet_number
Definition: asf.h:66
ff_asf_file_header
const ff_asf_guid ff_asf_file_header
Definition: asf_tags.c:27
ff_asf_video_conceal_none
const ff_asf_guid ff_asf_video_conceal_none
Definition: asf_tags.c:55
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
ffio_reset_dyn_buf
void ffio_reset_dyn_buf(AVIOContext *s)
Reset a dynamic buffer.
Definition: aviobuf.c:1509
AVPacket::size
int size
Definition: packet.h:375
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
AVIOContext::seekable
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:267
FFIOContext::pub
AVIOContext pub
Definition: avio_internal.h:30
ff_convert_lang_to
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
Definition: avlanguage.c:735
ASFContext::packet_size
uint32_t packet_size
Definition: asfdec_o.c:97
ASF_INDEX_BLOCK
#define ASF_INDEX_BLOCK
Definition: asfenc.c:38
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX
#define FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX
Tell ff_put_wav_header() to use WAVEFORMATEX even for PCM codecs.
Definition: riff.h:53
ASFContext::is_streamed
int is_streamed
Definition: asfenc.c:203
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:373
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:222
asf_write_header1
static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size)
Definition: asfenc.c:359
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
Definition: mem.c:223
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:378
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:380
ff_asf_reserved_4
const ff_asf_guid ff_asf_reserved_4
Definition: asf_tags.c:114
ASF_PPI_LENGTH_TYPE_FLAGS
#define ASF_PPI_LENGTH_TYPE_FLAGS
Definition: asfenc.c:58
ff_asf_comment_header
const ff_asf_guid ff_asf_comment_header
Definition: asf_tags.c:63
ASFIndex::offset
uint64_t offset
Definition: asf.h:69
ASF_PL_FLAG_KEY_FRAME
#define ASF_PL_FLAG_KEY_FRAME
Definition: asf.h:176
AVFMT_GLOBALHEADER
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:478
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:367
avio_internal.h
ff_asf_my_guid
const ff_asf_guid ff_asf_my_guid
Definition: asf_tags.c:120
ff_asf_codec_comment_header
const ff_asf_guid ff_asf_codec_comment_header
Definition: asf_tags.c:67
AVCodecParameters::height
int height
Definition: codec_par.h:129
ASFContext::creation_time
int64_t creation_time
Definition: asfenc.c:207
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:185
ASFStream::stream_language_index
uint16_t stream_language_index
Definition: asfdec_f.c:65
ffio_init_context
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Definition: aviobuf.c:81
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
unix_to_file_time
static int64_t unix_to_file_time(int64_t ti)
Definition: asfenc.c:297
PREROLL_TIME
#define PREROLL_TIME
Definition: asfenc.c:244
len
int len
Definition: vorbis_enc_data.h:426
ff_asf_head2_guid
const ff_asf_guid ff_asf_head2_guid
Definition: asf_tags.c:82
write_packet
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
Definition: ffmpeg_mux.c:61
DATA_HEADER_SIZE
#define DATA_HEADER_SIZE
Definition: asfenc.c:188
put_header
static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
Definition: asfenc.c:258
ASFContext::packet_nb_payloads
unsigned int packet_nb_payloads
Definition: asfenc.c:216
tag
uint32_t tag
Definition: movenc.c:1641
ffio_free_dyn_buf
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
Definition: aviobuf.c:1548
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:838
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:252
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
ff_asf_audio_conceal_spread
const ff_asf_guid ff_asf_audio_conceal_spread
Definition: asf_tags.c:43
PACKET_SIZE_MAX
#define PACKET_SIZE_MAX
Definition: asfenc.c:190
ASFContext::nb_languages
int nb_languages
Definition: asfenc.c:206
ASFContext::multi_payloads_present
unsigned char multi_payloads_present
Definition: asfenc.c:212
ff_asf_stream_header
const ff_asf_guid ff_asf_stream_header
Definition: asf_tags.c:31
pos
unsigned int pos
Definition: spdifenc.c:413
avformat.h
dict.h
asf_options
static const AVOption asf_options[]
Definition: asfenc.c:1119
asf.h
get_send_time
static int32_t get_send_time(ASFContext *asf, int64_t pres_time, uint64_t *offset)
Definition: asfenc.c:306
ASFContext::next_packet_offset
uint64_t next_packet_offset
Definition: asfenc.c:227
ff_asf_stream_muxer
const FFOutputFormat ff_asf_stream_muxer
asf_write_trailer
static int asf_write_trailer(AVFormatContext *s)
Definition: asfenc.c:1082
ff_codec_bmp_tags
const AVCodecTag ff_codec_bmp_tags[]
Definition: riff.c:36
ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT
#define ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT
Definition: asf.h:136
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:41
flush_packet
static void flush_packet(AVFormatContext *s)
Definition: asfenc.c:841
ff_put_guid
void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
Definition: riffenc.c:356
AVRational::den
int den
Denominator.
Definition: rational.h:60
PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
#define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
Definition: asfenc.c:171
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
asf_write_markers
static void asf_write_markers(AVFormatContext *s, AVIOContext *dyn_buf)
Definition: asfenc.c:320
end_header
static void end_header(AVIOContext *pb, int64_t pos)
Definition: asfenc.c:269
ASFContext::duration
int duration
Definition: asfdec_o.c:99
ASFStream::num
int num
Definition: asfdec_f.c:48
update_index
static int update_index(AVFormatContext *s, int start_sec, uint32_t packet_number, uint16_t packet_count, uint64_t packet_offset)
Definition: asfenc.c:975
AVPacket::stream_index
int stream_index
Definition: packet.h:376
SINGLE_PAYLOAD_HEADERS
#define SINGLE_PAYLOAD_HEADERS
Definition: asfenc.c:179
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ASFContext
Definition: asfdec_f.c:74
ff_asf_marker_header
const ff_asf_guid ff_asf_marker_header
Definition: asf_tags.c:110
ff_asf_group_mutual_exclusion_object
const ff_asf_guid ff_asf_group_mutual_exclusion_object
Definition: asf_tags.c:144
AVIOContext::buffer
unsigned char * buffer
Start of the buffer.
Definition: avio.h:231
put_frame
static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst, int64_t timestamp, const uint8_t *buf, int m_obj_size, int flags)
Definition: asfenc.c:904
AVDictionaryEntry
Definition: dict.h:89
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:62
AVPacket
This structure stores compressed data.
Definition: packet.h:351
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:86
riff.h
PACKET_HEADER_MIN_SIZE
#define PACKET_HEADER_MIN_SIZE
Definition: asfenc.c:150
ASFIndex::packet_count
uint16_t packet_count
Definition: asf.h:67
ff_asf_metadata_header
const ff_asf_guid ff_asf_metadata_header
Definition: asf_tags.c:102
avio_put_str16le
int avio_put_str16le(AVIOContext *s, const char *str)
Convert an UTF-8 string to UTF-16LE and write it.
int32_t
int32_t
Definition: audioconvert.c:56
ASFStream
Definition: asfdec_f.c:47
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:91
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_CODEC_ID_MSMPEG4V3
@ AV_CODEC_ID_MSMPEG4V3
Definition: codec_id.h:68
asf_write_stream_header
static int asf_write_stream_header(AVFormatContext *s)
Definition: asfenc.c:785
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3664
AVDictionaryEntry::value
char * value
Definition: dict.h:91
ff_asf_header
const ff_asf_guid ff_asf_header
Definition: asf_tags.c:23
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
ASFContext::next_packet_count
uint16_t next_packet_count
Definition: asfenc.c:226
ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD
#define ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD
Definition: asf.h:144
AVIOContext::buf_ptr
unsigned char * buf_ptr
Current position in the buffer.
Definition: avio.h:233
codec_desc.h
int
int
Definition: ffmpeg_filter.c:156
ASFContext::index_ptr
ASFIndex * index_ptr
Definition: asfenc.c:222
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:42
ASF_PPI_PROPERTY_FLAGS
#define ASF_PPI_PROPERTY_FLAGS
Definition: asfenc.c:52
AVIO_DATA_MARKER_FLUSH_POINT
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
Definition: avio.h:151
mux.h
asf_write_index
static int asf_write_index(AVFormatContext *s, const ASFIndex *index, uint16_t max, uint32_t count)
Definition: asfenc.c:1063