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 "libavutil/avassert.h"
23 #include "libavutil/dict.h"
24 #include "libavutil/mathematics.h"
25 #include "libavutil/opt.h"
26 #include "avformat.h"
27 #include "avlanguage.h"
28 #include "avio_internal.h"
29 #include "internal.h"
30 #include "riff.h"
31 #include "asf.h"
32 
33 #define ASF_INDEXED_INTERVAL 10000000
34 #define ASF_INDEX_BLOCK (1<<9)
35 #define ASF_PAYLOADS_PER_PACKET 63
36 
37 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
38 #define ASF_PACKET_ERROR_CORRECTION_FLAGS \
39  (ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \
40  ASF_PACKET_ERROR_CORRECTION_DATA_SIZE)
41 
42 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0)
43 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1
44 #else
45 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0
46 #endif
47 
48 #define ASF_PPI_PROPERTY_FLAGS \
49  (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \
50  ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \
51  ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \
52  ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE)
53 
54 #define ASF_PPI_LENGTH_TYPE_FLAGS 0
55 
56 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD
57 
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
60 #endif
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
63 #endif
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
66 #endif
67 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE
68 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0
69 #endif
70 
71 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
72 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1
73 #endif
74 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
75 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2
76 #endif
77 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE))
78 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4
79 #endif
80 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE
81 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0
82 #endif
83 
84 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
85 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1
86 #endif
87 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
88 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2
89 #endif
90 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE))
91 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4
92 #endif
93 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE
94 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0
95 #endif
96 
97 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
98 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1
99 #endif
100 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
101 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2
102 #endif
103 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE))
104 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4
105 #endif
106 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE
107 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0
108 #endif
109 
110 #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))
111 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1
112 #endif
113 #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))
114 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2
115 #endif
116 #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))
117 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4
118 #endif
119 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE
120 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0
121 #endif
122 
123 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
124 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1
125 #endif
126 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
127 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2
128 #endif
129 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE))
130 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4
131 #endif
132 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE
133 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0
134 #endif
135 
136 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
137 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1
138 #endif
139 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE))
140 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2
141 #endif
142 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE
143 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0
144 #endif
145 
146 #define PACKET_HEADER_MIN_SIZE \
147  (ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \
148  ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \
149  1 + /* Length Type Flags */ \
150  1 + /* Property Flags */ \
151  ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \
152  ASF_PPI_SEQUENCE_FIELD_SIZE + \
153  ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \
154  4 + /* Send Time Field */ \
155  2) /* Duration Field */
156 
157 // Replicated Data shall be at least 8 bytes long.
158 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08
159 
160 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \
161  (1 + /* Stream Number */ \
162  ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
163  ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
164  ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
165  ASF_PAYLOAD_REPLICATED_DATA_LENGTH)
166 
167 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
168  (1 + /* Stream Number */ \
169  ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \
170  ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \
171  ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \
172  ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \
173  ASF_PAYLOAD_LENGTH_FIELD_SIZE)
174 
175 #define SINGLE_PAYLOAD_HEADERS \
176  (PACKET_HEADER_MIN_SIZE + \
177  PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD)
178 
179 #define MULTI_PAYLOAD_HEADERS \
180  (PACKET_HEADER_MIN_SIZE + \
181  1 + /* Payload Flags */ \
182  2 * PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS)
183 
184 #define DATA_HEADER_SIZE 50
185 
186 #define PACKET_SIZE_MAX 65536
187 #define PACKET_SIZE_MIN 100
188 
189 typedef struct ASFPayload {
190  uint8_t type;
191  uint16_t size;
192 } ASFPayload;
193 
194 typedef struct ASFStream {
195  int num;
196  unsigned char seq;
197  /* use for reading */
198  AVPacket pkt;
199  int frag_offset;
200  int packet_obj_size;
201  int timestamp;
202  int64_t duration;
203  int skip_to_key;
204  int pkt_clean;
205 
206  int ds_span; /* descrambling */
207  int ds_packet_size;
208  int ds_chunk_size;
209 
210  int64_t packet_pos;
211 
212  uint16_t stream_language_index;
213 
214  int palette_changed;
215  uint32_t palette[256];
216 
217  int payload_ext_ct;
218  ASFPayload payload[8];
219 } ASFStream;
220 
221 typedef struct ASFContext {
223  uint32_t seqno;
225  ASFStream streams[128]; ///< it's max number and it's not that big
226  const char *languages[128];
228  int64_t creation_time;
229  /* non-streamed additional info */
230  uint64_t nb_packets; ///< how many packets are there in the file, invalid if broadcasting
231  int64_t duration; ///< in 100ns units
232  /* packet filling */
233  unsigned char multi_payloads_present;
234  int packet_size_left;
237  unsigned int packet_nb_payloads;
240  /* only for reading */
241  uint64_t data_offset; ///< beginning of the first data packet
242 
245  uint16_t maximum_packet;
250  int end_sec;
252 } ASFContext;
253 
254 static const AVCodecTag codec_asf_bmp_tags[] = {
255  { AV_CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
256  { AV_CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
257  { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
258  { AV_CODEC_ID_NONE, 0 },
259 };
260 
261 static const AVCodecTag *const asf_codec_tags[] = {
263 };
264 
265 #define PREROLL_TIME 3100
266 
267 static void put_str16(AVIOContext *s, const char *tag)
268 {
269  int len;
270  uint8_t *pb;
271  AVIOContext *dyn_buf;
272  if (avio_open_dyn_buf(&dyn_buf) < 0)
273  return;
274 
275  avio_put_str16le(dyn_buf, tag);
276  len = avio_close_dyn_buf(dyn_buf, &pb);
277  avio_wl16(s, len);
278  avio_write(s, pb, len);
279  av_freep(&pb);
280 }
281 
282 static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
283 {
284  int64_t pos;
285 
286  pos = avio_tell(pb);
287  ff_put_guid(pb, g);
288  avio_wl64(pb, 24);
289  return pos;
290 }
291 
292 /* update header size */
293 static void end_header(AVIOContext *pb, int64_t pos)
294 {
295  int64_t pos1;
296 
297  pos1 = avio_tell(pb);
298  avio_seek(pb, pos + 16, SEEK_SET);
299  avio_wl64(pb, pos1 - pos);
300  avio_seek(pb, pos1, SEEK_SET);
301 }
302 
303 /* write an asf chunk (only used in streaming case) */
304 static void put_chunk(AVFormatContext *s, int type,
305  int payload_length, int flags)
306 {
307  ASFContext *asf = s->priv_data;
308  AVIOContext *pb = s->pb;
309  int length;
310 
311  length = payload_length + 8;
312  avio_wl16(pb, type);
313  avio_wl16(pb, length); // size
314  avio_wl32(pb, asf->seqno); // sequence number
315  avio_wl16(pb, flags); // unknown bytes
316  avio_wl16(pb, length); // size_confirm
317  asf->seqno++;
318 }
319 
320 /* convert from av time to windows time */
321 static int64_t unix_to_file_time(int64_t ti)
322 {
323  int64_t t;
324 
325  t = ti * INT64_C(10);
326  t += INT64_C(116444736000000000);
327  return t;
328 }
329 
330 static int32_t get_send_time(ASFContext *asf, int64_t pres_time, uint64_t *offset)
331 {
332  int32_t send_time = 0;
334  for (int i = 0; i < asf->next_start_sec; i++) {
335  if (pres_time <= asf->index_ptr[i].send_time)
336  break;
337  send_time = asf->index_ptr[i].send_time;
338  *offset = asf->index_ptr[i].offset;
339  }
340 
341  return send_time / 10000;
342 }
343 
345 {
346  ASFContext *asf = s->priv_data;
347  AVIOContext *pb = s->pb;
348  AVRational scale = {1, 10000000};
349  int64_t hpos = put_header(pb, &ff_asf_marker_header);
350 
351  ff_put_guid(pb, &ff_asf_reserved_4);// ASF spec mandates this reserved value
352  avio_wl32(pb, s->nb_chapters); // markers count
353  avio_wl16(pb, 0); // ASF spec mandates 0 for this
354  avio_wl16(pb, 0); // name length 0, no name given
355 
356  for (unsigned i = 0; i < s->nb_chapters; i++) {
357  AVChapter *c = s->chapters[i];
358  AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
359  int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
360  uint64_t offset;
361  int32_t send_time = get_send_time(asf, pres_time, &offset);
362  int len = 0, ret;
363  uint8_t *buf;
364  AVIOContext *dyn_buf;
365  if (t) {
366  if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
367  return ret;
368  avio_put_str16le(dyn_buf, t->value);
369  len = avio_close_dyn_buf(dyn_buf, &buf);
370  }
371  avio_wl64(pb, offset); // offset of the packet with send_time
372  avio_wl64(pb, pres_time + PREROLL_TIME * 10000); // presentation time
373  avio_wl16(pb, 12 + len); // entry length
374  avio_wl32(pb, send_time); // send time
375  avio_wl32(pb, 0); // flags, should be 0
376  avio_wl32(pb, len / 2); // marker desc length in WCHARS!
377  if (t) {
378  avio_write(pb, buf, len); // marker desc
379  av_freep(&buf);
380  }
381  }
382  end_header(pb, hpos);
383  return 0;
384 }
385 
386 /* write the header (used two times if non streamed) */
387 static int asf_write_header1(AVFormatContext *s, int64_t file_size,
388  int64_t data_chunk_size)
389 {
390  ASFContext *asf = s->priv_data;
391  AVIOContext *pb = s->pb;
392  AVDictionaryEntry *tags[5];
393  int header_size, extra_size, extra_size2, wav_extra_size;
394  int has_title, has_aspect_ratio = 0;
395  int metadata_count;
396  int64_t header_offset, cur_pos, hpos;
397  int bit_rate;
398  int64_t duration;
399  int audio_language_counts[128] = { 0 };
400 
402 
403  tags[0] = av_dict_get(s->metadata, "title", NULL, 0);
404  tags[1] = av_dict_get(s->metadata, "author", NULL, 0);
405  tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
406  tags[3] = av_dict_get(s->metadata, "comment", NULL, 0);
407  tags[4] = av_dict_get(s->metadata, "rating", NULL, 0);
408 
409  duration = asf->duration + PREROLL_TIME * 10000;
410  has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
411 
412  if (!file_size) {
413  if (ff_parse_creation_time_metadata(s, &asf->creation_time, 0) != 0)
414  av_dict_set(&s->metadata, "creation_time", NULL, 0);
415  }
416 
417  metadata_count = av_dict_count(s->metadata);
418 
419  bit_rate = 0;
420  for (unsigned n = 0; n < s->nb_streams; n++) {
421  AVStream *const st = s->streams[n];
422  AVCodecParameters *const par = st->codecpar;
423  AVDictionaryEntry *entry;
424 
425  avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
426 
427  bit_rate += par->bit_rate;
428  if ( par->codec_type == AVMEDIA_TYPE_VIDEO
429  && par->sample_aspect_ratio.num > 0
430  && par->sample_aspect_ratio.den > 0)
431  has_aspect_ratio++;
432 
433  entry = av_dict_get(s->streams[n]->metadata, "language", NULL, 0);
434  if (entry) {
435  const char *iso6391lang = ff_convert_lang_to(entry->value, AV_LANG_ISO639_1);
436  if (iso6391lang) {
437  int i;
438  for (i = 0; i < asf->nb_languages; i++) {
439  if (!strcmp(asf->languages[i], iso6391lang)) {
440  asf->streams[n].stream_language_index = i;
441  break;
442  }
443  }
444  if (i >= asf->nb_languages) {
445  asf->languages[asf->nb_languages] = iso6391lang;
447  asf->nb_languages++;
448  }
449  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
450  audio_language_counts[asf->streams[n].stream_language_index]++;
451  }
452  } else {
453  asf->streams[n].stream_language_index = 128;
454  }
455  }
456 
457  if (asf->is_streamed) {
458  put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */
459  }
460 
462  avio_wl64(pb, -1); /* header length, will be patched after */
463  avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
464  avio_w8(pb, 1); /* ??? */
465  avio_w8(pb, 2); /* ??? */
466 
467  /* file header */
468  header_offset = avio_tell(pb);
469  hpos = put_header(pb, &ff_asf_file_header);
471  avio_wl64(pb, file_size);
473  avio_wl64(pb, asf->nb_packets); /* number of packets */
474  avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
475  avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
476  avio_wl64(pb, PREROLL_TIME); /* start time stamp */
477  avio_wl32(pb, (asf->is_streamed || !(pb->seekable & AVIO_SEEKABLE_NORMAL)) ? 3 : 2); /* ??? */
478  avio_wl32(pb, s->packet_size); /* packet size */
479  avio_wl32(pb, s->packet_size); /* packet size */
480  avio_wl32(pb, bit_rate ? bit_rate : -1); /* Maximum data rate in bps */
481  end_header(pb, hpos);
482 
483  /* header_extension */
484  hpos = put_header(pb, &ff_asf_head1_guid);
486  avio_wl16(pb, 6);
487  avio_wl32(pb, 0); /* length, to be filled later */
488  if (asf->nb_languages) {
489  int64_t hpos2;
490  int nb_audio_languages = 0;
491 
492  hpos2 = put_header(pb, &ff_asf_language_guid);
493  avio_wl16(pb, asf->nb_languages);
494  for (int i = 0; i < asf->nb_languages; i++) {
495  avio_w8(pb, 6);
496  avio_put_str16le(pb, asf->languages[i]);
497  }
498  end_header(pb, hpos2);
499 
500  for (int i = 0; i < asf->nb_languages; i++)
501  if (audio_language_counts[i])
502  nb_audio_languages++;
503 
504  if (nb_audio_languages > 1) {
507  avio_wl16(pb, nb_audio_languages);
508  for (int i = 0; i < asf->nb_languages; i++) {
509  if (audio_language_counts[i]) {
510  avio_wl16(pb, audio_language_counts[i]);
511  for (unsigned n = 0; n < s->nb_streams; n++)
512  if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
513  avio_wl16(pb, n + 1);
514  }
515  }
516  end_header(pb, hpos2);
517  }
518 
519  for (unsigned n = 0; n < s->nb_streams; n++) {
520  int64_t es_pos;
521  if (asf->streams[n].stream_language_index > 127)
522  continue;
524  avio_wl64(pb, 0); /* start time */
525  avio_wl64(pb, 0); /* end time */
526  avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* data bitrate bps */
527  avio_wl32(pb, 5000); /* buffer size ms */
528  avio_wl32(pb, 0); /* initial buffer fullness */
529  avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* peak data bitrate */
530  avio_wl32(pb, 5000); /* maximum buffer size ms */
531  avio_wl32(pb, 0); /* max initial buffer fullness */
532  avio_wl32(pb, 0); /* max object size */
533  avio_wl32(pb, (!asf->is_streamed && (pb->seekable & AVIO_SEEKABLE_NORMAL)) << 1); /* flags - seekable */
534  avio_wl16(pb, n + 1); /* stream number */
535  avio_wl16(pb, asf->streams[n].stream_language_index); /* language id index */
536  avio_wl64(pb, 0); /* avg time per frame */
537  avio_wl16(pb, 0); /* stream name count */
538  avio_wl16(pb, 0); /* payload extension system count */
539  end_header(pb, es_pos);
540  }
541  }
542  if (has_aspect_ratio) {
543  int64_t hpos2;
544  hpos2 = put_header(pb, &ff_asf_metadata_header);
545  avio_wl16(pb, 2 * has_aspect_ratio);
546  for (unsigned n = 0; n < s->nb_streams; n++) {
547  AVCodecParameters *const par = s->streams[n]->codecpar;
548  if ( par->codec_type == AVMEDIA_TYPE_VIDEO
549  && par->sample_aspect_ratio.num > 0
550  && par->sample_aspect_ratio.den > 0) {
551  AVRational sar = par->sample_aspect_ratio;
552  avio_wl16(pb, 0);
553  // the stream number is set like this below
554  avio_wl16(pb, n + 1);
555  avio_wl16(pb, 26); // name_len
556  avio_wl16(pb, 3); // value_type
557  avio_wl32(pb, 4); // value_len
558  avio_put_str16le(pb, "AspectRatioX");
559  avio_wl32(pb, sar.num);
560  avio_wl16(pb, 0);
561  // the stream number is set like this below
562  avio_wl16(pb, n + 1);
563  avio_wl16(pb, 26); // name_len
564  avio_wl16(pb, 3); // value_type
565  avio_wl32(pb, 4); // value_len
566  avio_put_str16le(pb, "AspectRatioY");
567  avio_wl32(pb, sar.den);
568  }
569  }
570  end_header(pb, hpos2);
571  }
572  {
573  int64_t pos1;
574  pos1 = avio_tell(pb);
575  avio_seek(pb, hpos + 42, SEEK_SET);
576  avio_wl32(pb, pos1 - hpos - 46);
577  avio_seek(pb, pos1, SEEK_SET);
578  }
579  end_header(pb, hpos);
580 
581  /* title and other info */
582  if (has_title) {
583  int len, ret;
584  uint8_t *buf;
585  AVIOContext *dyn_buf;
586 
587  if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
588  return ret;
589 
590  hpos = put_header(pb, &ff_asf_comment_header);
591 
592  for (size_t n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
593  len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
594  avio_wl16(pb, len);
595  }
596  len = avio_close_dyn_buf(dyn_buf, &buf);
597  avio_write(pb, buf, len);
598  av_freep(&buf);
599  end_header(pb, hpos);
600  }
601  if (metadata_count) {
604  avio_wl16(pb, metadata_count);
605  while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
606  put_str16(pb, tag->key);
607  avio_wl16(pb, 0);
608  put_str16(pb, tag->value);
609  }
610  end_header(pb, hpos);
611  }
612  /* chapters using ASF markers */
613  if (!asf->is_streamed && s->nb_chapters) {
614  int ret;
615  if ((ret = asf_write_markers(s)) < 0)
616  return ret;
617  }
618  /* stream headers */
619  for (unsigned n = 0; n < s->nb_streams; n++) {
620  AVCodecParameters *const par = s->streams[n]->codecpar;
621  int64_t es_pos;
622  // ASFStream *stream = &asf->streams[n];
623 
624  asf->streams[n].num = n + 1;
625  asf->streams[n].seq = 1;
626 
627  switch (par->codec_type) {
628  case AVMEDIA_TYPE_AUDIO:
629  wav_extra_size = 0;
630  extra_size = 18 + wav_extra_size;
631  extra_size2 = 8;
632  break;
633  default:
634  case AVMEDIA_TYPE_VIDEO:
635  wav_extra_size = par->extradata_size;
636  extra_size = 0x33 + wav_extra_size;
637  extra_size2 = 0;
638  break;
639  }
640 
641  hpos = put_header(pb, &ff_asf_stream_header);
642  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
645  } else {
648  }
649  avio_wl64(pb, 0); /* ??? */
650  es_pos = avio_tell(pb);
651  avio_wl32(pb, extra_size); /* wav header len */
652  avio_wl32(pb, extra_size2); /* additional data len */
653  avio_wl16(pb, n + 1); /* stream number */
654  avio_wl32(pb, 0); /* ??? */
655 
656  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
657  /* WAVEFORMATEX header */
659 
660  if (wavsize < 0)
661  return -1;
662  if (wavsize != extra_size) {
663  cur_pos = avio_tell(pb);
664  avio_seek(pb, es_pos, SEEK_SET);
665  avio_wl32(pb, wavsize); /* wav header len */
666  avio_seek(pb, cur_pos, SEEK_SET);
667  }
668  /* ERROR Correction */
669  avio_w8(pb, 0x01);
670  if (par->codec_id == AV_CODEC_ID_ADPCM_G726 || !par->block_align) {
671  avio_wl16(pb, 0x0190);
672  avio_wl16(pb, 0x0190);
673  } else {
674  avio_wl16(pb, par->block_align);
675  avio_wl16(pb, par->block_align);
676  }
677  avio_wl16(pb, 0x01);
678  avio_w8(pb, 0x00);
679  } else {
680  avio_wl32(pb, par->width);
681  avio_wl32(pb, par->height);
682  avio_w8(pb, 2); /* ??? */
683  avio_wl16(pb, 40 + par->extradata_size); /* size */
684 
685  /* BITMAPINFOHEADER header */
686  ff_put_bmp_header(pb, par, 1, 0, 0);
687  }
688  end_header(pb, hpos);
689  }
690 
691  /* media comments */
692 
695  avio_wl32(pb, s->nb_streams);
696  for (unsigned n = 0; n < s->nb_streams; n++) {
697  AVCodecParameters *const par = s->streams[n]->codecpar;
698  const AVCodecDescriptor *const codec_desc = avcodec_descriptor_get(par->codec_id);
699  const char *desc;
700 
701  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
702  avio_wl16(pb, 2);
703  else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
704  avio_wl16(pb, 1);
705  else
706  avio_wl16(pb, -1);
707 
708  if (par->codec_id == AV_CODEC_ID_WMAV2)
709  desc = "Windows Media Audio V8";
710  else
711  desc = codec_desc ? codec_desc->name : NULL;
712 
713  if (desc) {
714  AVIOContext *dyn_buf;
715  uint8_t *buf;
716  int len, ret;
717 
718  if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
719  return ret;
720 
721  avio_put_str16le(dyn_buf, desc);
722  len = avio_close_dyn_buf(dyn_buf, &buf);
723  avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
724 
725  avio_write(pb, buf, len);
726  av_freep(&buf);
727  } else
728  avio_wl16(pb, 0);
729 
730  avio_wl16(pb, 0); /* no parameters */
731 
732  /* id */
733  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
734  avio_wl16(pb, 2);
735  avio_wl16(pb, par->codec_tag);
736  } else {
737  avio_wl16(pb, 4);
738  avio_wl32(pb, par->codec_tag);
739  }
740  if (!par->codec_tag)
741  return -1;
742  }
743  end_header(pb, hpos);
744 
745  /* patch the header size fields */
746 
747  cur_pos = avio_tell(pb);
748  header_size = cur_pos - header_offset;
749  if (asf->is_streamed) {
750  header_size += 8 + 30 + DATA_HEADER_SIZE;
751 
752  avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
753  avio_wl16(pb, header_size);
754  avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
755  avio_wl16(pb, header_size);
756 
757  header_size -= 8 + 30 + DATA_HEADER_SIZE;
758  }
759  header_size += 24 + 6;
760  avio_seek(pb, header_offset - 14, SEEK_SET);
761  avio_wl64(pb, header_size);
762  avio_seek(pb, cur_pos, SEEK_SET);
763 
764  /* movie chunk, followed by packets of packet_size */
765  asf->data_offset = cur_pos;
767  avio_wl64(pb, data_chunk_size);
769  avio_wl64(pb, asf->nb_packets); /* nb packets */
770  avio_w8(pb, 1); /* ??? */
771  avio_w8(pb, 1); /* ??? */
772  return 0;
773 }
774 
776 {
777  ASFContext *asf = s->priv_data;
778 
779  s->packet_size = asf->packet_size;
780  s->max_interleave_delta = 0;
781  asf->nb_packets = 0;
782 
783  if (s->nb_streams > 127) {
784  av_log(s, AV_LOG_ERROR, "ASF can only handle 127 streams\n");
785  return AVERROR(EINVAL);
786  }
787 
788  asf->index_ptr = av_malloc(sizeof(ASFIndex) * ASF_INDEX_BLOCK);
789  if (!asf->index_ptr)
790  return AVERROR(ENOMEM);
792  asf->maximum_packet = 0;
793 
794  /* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
795  * data_size - asf->data_offset at the moment this function is done.
796  * It is needed to use asf as a streamable format. */
797  if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
798  //av_free(asf);
799  av_freep(&asf->index_ptr);
800  return -1;
801  }
802 
803  asf->packet_nb_payloads = 0;
804  asf->packet_timestamp_start = -1;
805  asf->packet_timestamp_end = -1;
806  ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
807  NULL, NULL, NULL, NULL);
808 
809  if (s->avoid_negative_ts < 0)
810  s->avoid_negative_ts = 1;
811 
812  return 0;
813 }
814 
816 {
817  ASFContext *asf = s->priv_data;
818 
819  asf->is_streamed = 1;
820 
821  return asf_write_header(s);
822 }
823 
825  unsigned sendtime, unsigned duration,
826  int nb_payloads, int padsize)
827 {
828  ASFContext *asf = s->priv_data;
829  AVIOContext *pb = s->pb;
830  int ppi_size;
831  int64_t start = avio_tell(pb);
832 
833  int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
834 
835  padsize -= PACKET_HEADER_MIN_SIZE;
836  if (asf->multi_payloads_present)
837  padsize--;
838  av_assert0(padsize >= 0);
839 
841  for (int i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++)
842  avio_w8(pb, 0x0);
843 
844  if (asf->multi_payloads_present)
845  iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT;
846 
847  if (padsize > 0) {
848  if (padsize < 256)
849  iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE;
850  else
851  iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD;
852  }
853  avio_w8(pb, iLengthTypeFlags);
854 
856 
857  if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD)
858  avio_wl16(pb, padsize - 2);
859  if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE)
860  avio_w8(pb, padsize - 1);
861 
862  avio_wl32(pb, sendtime);
863  avio_wl16(pb, duration);
864  if (asf->multi_payloads_present)
865  avio_w8(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
866 
867  ppi_size = avio_tell(pb) - start;
868 
869  return ppi_size;
870 }
871 
873 {
874  ASFContext *asf = s->priv_data;
875  int packet_hdr_size, packet_filled_size;
876 
878 
879  if (asf->is_streamed)
880  put_chunk(s, 0x4424, s->packet_size, 0);
881 
882  packet_hdr_size = put_payload_parsing_info(s,
885  asf->packet_nb_payloads,
886  asf->packet_size_left);
887 
888  packet_filled_size = asf->packet_size - asf->packet_size_left;
889  av_assert0(packet_hdr_size <= asf->packet_size_left);
890  memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
891 
892  avio_write(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
893 
895 
896  asf->nb_packets++;
897  asf->packet_nb_payloads = 0;
898  asf->packet_timestamp_start = -1;
899  asf->packet_timestamp_end = -1;
900  ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1,
901  NULL, NULL, NULL, NULL);
902 }
903 
905  int64_t presentation_time, int m_obj_size,
906  int m_obj_offset, int payload_len, int flags)
907 {
908  ASFContext *asf = s->priv_data;
909  AVIOContext *const pb = &asf->pb.pub;
910  int val;
911 
912  val = stream->num;
913  if (flags & AV_PKT_FLAG_KEY)
915  avio_w8(pb, val);
916 
917  avio_w8(pb, stream->seq); // Media object number
918  avio_wl32(pb, m_obj_offset); // Offset Into Media Object
919 
920  // Replicated Data shall be at least 8 bytes long.
921  // The first 4 bytes of data shall contain the
922  // Size of the Media Object that the payload belongs to.
923  // The next 4 bytes of data shall contain the
924  // Presentation Time for the media object that the payload belongs to.
926 
927  avio_wl32(pb, m_obj_size); // Replicated Data - Media Object Size
928  avio_wl32(pb, (uint32_t) presentation_time); // Replicated Data - Presentation Time
929 
930  if (asf->multi_payloads_present) {
931  avio_wl16(pb, payload_len); // payload length
932  }
933 }
934 
935 static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst,
936  int64_t timestamp, const uint8_t *buf,
937  int m_obj_size, int flags)
938 {
939  ASFContext *asf = s->priv_data;
940  int m_obj_offset, payload_len, frag_len1;
941 
942  m_obj_offset = 0;
943  while (m_obj_offset < m_obj_size) {
944  payload_len = m_obj_size - m_obj_offset;
945  if (asf->packet_timestamp_start == -1) {
946  const int multi_payload_constant = (asf->packet_size - MULTI_PAYLOAD_HEADERS);
947  asf->multi_payloads_present = (payload_len < multi_payload_constant);
948 
949  asf->packet_size_left = asf->packet_size;
950  if (asf->multi_payloads_present) {
951  frag_len1 = multi_payload_constant - 1;
952  } else {
953  frag_len1 = asf->packet_size - SINGLE_PAYLOAD_HEADERS;
954  }
955  asf->packet_timestamp_start = timestamp;
956  } else {
957  // multi payloads
958  frag_len1 = asf->packet_size_left -
961 
962  if (frag_len1 < payload_len &&
964  flush_packet(s);
965  continue;
966  }
967  if (asf->packet_timestamp_start > INT64_MAX - UINT16_MAX ||
968  timestamp > asf->packet_timestamp_start + UINT16_MAX) {
969  flush_packet(s);
970  continue;
971  }
972  }
973  if (frag_len1 > 0) {
974  if (payload_len > frag_len1)
975  payload_len = frag_len1;
976  else if (payload_len == (frag_len1 - 1))
977  payload_len = frag_len1 - 2; // additional byte need to put padding length
978 
979  put_payload_header(s, stream, timestamp + PREROLL_TIME,
980  m_obj_size, m_obj_offset, payload_len, flags);
981  avio_write(&asf->pb.pub, buf, payload_len);
982 
983  if (asf->multi_payloads_present)
985  else
987  asf->packet_timestamp_end = timestamp;
988 
989  asf->packet_nb_payloads++;
990  } else {
991  payload_len = 0;
992  }
993  m_obj_offset += payload_len;
994  buf += payload_len;
995 
996  if (!asf->multi_payloads_present)
997  flush_packet(s);
999  flush_packet(s);
1001  flush_packet(s);
1002  }
1003  stream->seq++;
1004 }
1005 
1006 static int update_index(AVFormatContext *s, int start_sec,
1007  uint32_t packet_number, uint16_t packet_count,
1008  uint64_t packet_offset)
1009 {
1010  ASFContext *asf = s->priv_data;
1011 
1012  if (start_sec > asf->next_start_sec) {
1013  if (!asf->next_start_sec) {
1014  asf->next_packet_number = packet_number;
1015  asf->next_packet_count = packet_count;
1016  asf->next_packet_offset = packet_offset;
1017  }
1018 
1019  if (start_sec > asf->nb_index_memory_alloc) {
1020  int err;
1021  asf->nb_index_memory_alloc = (start_sec + ASF_INDEX_BLOCK) & ~(ASF_INDEX_BLOCK - 1);
1022  if ((err = av_reallocp_array(&asf->index_ptr,
1023  asf->nb_index_memory_alloc,
1024  sizeof(*asf->index_ptr))) < 0) {
1025  asf->nb_index_memory_alloc = 0;
1026  return err;
1027  }
1028  }
1029  for (int i = asf->next_start_sec; i < start_sec; i++) {
1032  asf->index_ptr[i].send_time = asf->next_start_sec * INT64_C(10000000);
1033  asf->index_ptr[i].offset = asf->next_packet_offset;
1034 
1035  }
1036  }
1037  asf->maximum_packet = FFMAX(asf->maximum_packet, packet_count);
1038  asf->next_packet_number = packet_number;
1039  asf->next_packet_count = packet_count;
1040  asf->next_packet_offset = packet_offset;
1041  asf->next_start_sec = start_sec;
1042 
1043  return 0;
1044 }
1045 
1047 {
1048  ASFContext *asf = s->priv_data;
1049  AVIOContext *pb = s->pb;
1050  ASFStream *stream;
1051  AVCodecParameters *par;
1052  uint32_t packet_number;
1053  int64_t pts;
1054  int start_sec;
1055  int flags = pkt->flags;
1056  int ret;
1057  uint64_t offset = avio_tell(pb);
1058 
1059  par = s->streams[pkt->stream_index]->codecpar;
1060  stream = &asf->streams[pkt->stream_index];
1061 
1062  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
1063  flags &= ~AV_PKT_FLAG_KEY;
1064 
1065  pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
1067  if ( pts < - PREROLL_TIME
1068  || pts > (INT_MAX-3)/10000LL * ASF_INDEXED_INTERVAL - PREROLL_TIME) {
1069  av_log(s, AV_LOG_ERROR, "input pts %"PRId64" is invalid\n", pts);
1070  return AVERROR(EINVAL);
1071  }
1072  pts *= 10000;
1073  asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);
1074 
1075  packet_number = asf->nb_packets;
1076  put_frame(s, stream, s->streams[pkt->stream_index],
1077  pkt->dts, pkt->data, pkt->size, flags);
1078 
1079  start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)
1081 
1082  /* check index */
1083  if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {
1084  uint16_t packet_count = asf->nb_packets - packet_number;
1085  ret = update_index(s, start_sec, packet_number, packet_count, offset);
1086  if (ret < 0)
1087  return ret;
1088  }
1089  asf->end_sec = start_sec;
1090 
1091  return 0;
1092 }
1093 
1095  uint16_t max, uint32_t count)
1096 {
1097  AVIOContext *pb = s->pb;
1098 
1100  avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2) * count);
1103  avio_wl32(pb, max);
1104  avio_wl32(pb, count);
1105  for (uint32_t i = 0; i < count; i++) {
1106  avio_wl32(pb, index[i].packet_number);
1107  avio_wl16(pb, index[i].packet_count);
1108  }
1109 
1110  return 0;
1111 }
1112 
1114 {
1115  ASFContext *asf = s->priv_data;
1116  int64_t file_size, data_size;
1117  int ret;
1118 
1119  /* flush the current packet */
1120  if (asf->pb.pub.buf_ptr > asf->pb.pub.buffer)
1121  flush_packet(s);
1122 
1123  /* write index */
1124  data_size = avio_tell(s->pb);
1125  if (!asf->is_streamed && asf->next_start_sec) {
1126  if ((ret = update_index(s, asf->end_sec + 1, 0, 0, 0)) < 0)
1127  return ret;
1129  }
1130 
1131  if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
1132  put_chunk(s, 0x4524, 0, 0); /* end of stream */
1133  } else {
1134  /* rewrite an updated header */
1135  file_size = avio_tell(s->pb);
1136  avio_seek(s->pb, 0, SEEK_SET);
1137  asf_write_header1(s, file_size, data_size - asf->data_offset);
1138  }
1139 
1140  av_freep(&asf->index_ptr);
1141  return 0;
1142 }
1143 
1144 static const AVOption asf_options[] = {
1145  { "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 },
1146  { NULL },
1147 };
1148 
1149 static const AVClass asf_muxer_class = {
1150  .class_name = "ASF (stream) muxer",
1151  .item_name = av_default_item_name,
1152  .option = asf_options,
1153  .version = LIBAVUTIL_VERSION_INT,
1154 };
1155 
1156 #if CONFIG_ASF_MUXER
1157 const AVOutputFormat ff_asf_muxer = {
1158  .name = "asf",
1159  .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"),
1160  .mime_type = "video/x-ms-asf",
1161  .extensions = "asf,wmv,wma",
1162  .priv_data_size = sizeof(ASFContext),
1163  .audio_codec = AV_CODEC_ID_WMAV2,
1164  .video_codec = AV_CODEC_ID_MSMPEG4V3,
1169  .codec_tag = asf_codec_tags,
1170  .priv_class = &asf_muxer_class,
1171 };
1172 #endif /* CONFIG_ASF_MUXER */
1173 
1174 #if CONFIG_ASF_STREAM_MUXER
1176  .name = "asf_stream",
1177  .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"),
1178  .mime_type = "video/x-ms-asf",
1179  .extensions = "asf,wmv,wma",
1180  .priv_data_size = sizeof(ASFContext),
1181  .audio_codec = AV_CODEC_ID_WMAV2,
1182  .video_codec = AV_CODEC_ID_MSMPEG4V3,
1187  .codec_tag = asf_codec_tags,
1188  .priv_class = &asf_muxer_class,
1189 };
1190 #endif /* CONFIG_ASF_STREAM_MUXER */
ASFContext::packet_size
int packet_size
Definition: asfenc.c:251
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:33
AVOutputFormat::name
const char * name
Definition: avformat.h:496
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:56
PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
#define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD
Definition: asfenc.c:160
ASFIndex
Definition: asf.h:65
asf_write_markers
static int asf_write_markers(AVFormatContext *s)
Definition: asfenc.c:344
asf_muxer_class
static const AVClass asf_muxer_class
Definition: asfenc.c:1149
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
ASFContext::next_start_sec
int next_start_sec
Definition: asfenc.c:249
av_dict_count
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
Definition: dict.c:35
ff_asf_stream_muxer
const AVOutputFormat ff_asf_stream_muxer
codec_asf_bmp_tags
static const AVCodecTag codec_asf_bmp_tags[]
Definition: asfenc.c:254
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:216
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
avlanguage.h
ff_asf_extended_stream_properties_object
const ff_asf_guid ff_asf_extended_stream_properties_object
Definition: asf.c:142
ASFStream::palette_changed
int palette_changed
Definition: asfdec_f.c:66
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:62
ASFContext::duration
int64_t duration
in 100ns units
Definition: asfenc.c:231
index
fg index
Definition: ffmpeg_filter.c:168
AVPacket::data
uint8_t * data
Definition: packet.h:373
AVOption
AVOption.
Definition: opt.h:247
ASFStream::skip_to_key
int skip_to_key
Definition: asfdec_f.c:55
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: utils.c:1810
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:68
ff_asf_video_stream
const ff_asf_guid ff_asf_video_stream
Definition: asf.c:49
ff_asf_simple_index_header
const ff_asf_guid ff_asf_simple_index_header
Definition: asf.c:92
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:439
ff_codec_wav_tags
const AVCodecTag ff_codec_wav_tags[]
Definition: riff.c:509
put_chunk
static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags)
Definition: asfenc.c:304
AV_CODEC_ID_WMAV2
@ AV_CODEC_ID_WMAV2
Definition: codec_id.h:430
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
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:238
ff_asf_stream_header
const ff_asf_guid ff_asf_stream_header
Definition: asf.c:33
ASFContext::seqno
uint32_t seqno
Definition: asfenc.c:223
ff_asf_codec_comment_header
const ff_asf_guid ff_asf_codec_comment_header
Definition: asf.c:69
ASFContext::data_offset
uint64_t data_offset
beginning of the first data packet
Definition: asfdec_f.c:84
ASFContext::av_class
AVClass * av_class
Definition: asfenc.c:222
FFIOContext
Definition: avio_internal.h:29
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:425
ASFContext::nb_index_memory_alloc
uint32_t nb_index_memory_alloc
Definition: asfenc.c:244
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:451
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:475
asf_write_packet
static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: asfenc.c:1046
ff_asf_mutex_language
const ff_asf_guid ff_asf_mutex_language
Definition: asf.c:150
ASFContext::languages
const char * languages[128]
Definition: asfenc.c:226
ASFContext::streams
ASFStream streams[128]
it's max number and it's not that big
Definition: asfdec_f.c:76
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:486
ASF_PACKET_ERROR_CORRECTION_FLAGS
#define ASF_PACKET_ERROR_CORRECTION_FLAGS
Definition: asfenc.c:38
AVChapter
Definition: avformat.h:1056
val
static double val(void *priv, double ch)
Definition: aeval.c:76
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
ff_asf_group_mutual_exclusion_object
const ff_asf_guid ff_asf_group_mutual_exclusion_object
Definition: asf.c:146
ASF_PAYLOAD_REPLICATED_DATA_LENGTH
#define ASF_PAYLOAD_REPLICATED_DATA_LENGTH
Definition: asfenc.c:158
pts
static int64_t pts
Definition: transcode_aac.c:653
AVRational::num
int num
Numerator.
Definition: rational.h:59
put_str16
static void put_str16(AVIOContext *s, const char *tag)
Definition: asfenc.c:267
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1444
ASFContext::end_sec
int end_sec
Definition: asfenc.c:250
ASFContext::next_packet_number
uint32_t next_packet_number
Definition: asfenc.c:246
avassert.h
ASFStream::pkt_clean
int pkt_clean
Definition: asfdec_f.c:56
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:235
AVCodecTag
Definition: internal.h:50
duration
int64_t duration
Definition: movenc.c:64
MULTI_PAYLOAD_HEADERS
#define MULTI_PAYLOAD_HEADERS
Definition: asfenc.c:179
PACKET_SIZE_MIN
#define PACKET_SIZE_MIN
Definition: asfenc.c:187
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:40
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1399
ASFStream::duration
int64_t duration
Definition: asfdec_f.c:54
AV_CODEC_ID_ADPCM_G726
@ AV_CODEC_ID_ADPCM_G726
Definition: codec_id.h:363
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:257
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:277
ASFContext::maximum_packet
uint16_t maximum_packet
Definition: asfenc.c:245
ASFContext::packet_timestamp_end
int64_t packet_timestamp_end
Definition: asfenc.c:236
ff_asf_data_header
const ff_asf_guid ff_asf_data_header
Definition: asf.c:76
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition: codec_par.h:136
g
const char * g
Definition: vf_curves.c:117
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE
Definition: asfenc.c:37
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:141
ASF_PAYLOAD_FLAGS
#define ASF_PAYLOAD_FLAGS
Definition: asfenc.c:56
asf_write_header
static int asf_write_header(AVFormatContext *s)
Definition: asfenc.c:775
ASFStream::timestamp
int timestamp
Definition: asfdec_f.c:53
ASF_PAYLOADS_PER_PACKET
#define ASF_PAYLOADS_PER_PACKET
Definition: asfenc.c:35
ASFIndex::send_time
uint64_t send_time
Definition: asf.h:68
AVFormatContext
Format I/O context.
Definition: avformat.h:1097
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:992
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ASFStream::ds_packet_size
int ds_packet_size
Definition: asfdec_f.c:59
NULL
#define NULL
Definition: coverity.c:32
ff_asf_guid
uint8_t ff_asf_guid[16]
Definition: riff.h:95
ff_asf_audio_conceal_spread
const ff_asf_guid ff_asf_audio_conceal_spread
Definition: asf.c:45
ff_put_wav_header
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags)
Write WAVEFORMAT header structure.
Definition: riffenc.c:55
ASFPayload::size
uint16_t size
Definition: asfdec_f.c:43
ff_asf_header
const ff_asf_guid ff_asf_header
Definition: asf.c:25
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
ASFStream::seq
unsigned char seq
Definition: asfdec_f.c:48
ff_asf_metadata_conv
const AVMetadataConv ff_asf_metadata_conv[]
Definition: asf.c:155
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ASFContext::pb
FFIOContext pb
Definition: asfenc.c:239
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
put_payload_parsing_info
static int put_payload_parsing_info(AVFormatContext *s, unsigned sendtime, unsigned duration, int nb_payloads, int padsize)
Definition: asfenc.c:824
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:196
ASFContext::nb_packets
uint64_t nb_packets
how many packets are there in the file, invalid if broadcasting
Definition: asfdec_o.c:96
ASFContext::packet_size_left
int packet_size_left
Definition: asfdec_f.c:82
ff_asf_head1_guid
const ff_asf_guid ff_asf_head1_guid
Definition: asf.c:80
asf_codec_tags
static const AVCodecTag *const asf_codec_tags[]
Definition: asfenc.c:261
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:904
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
ASFStream::packet_pos
int64_t packet_pos
Definition: asfdec_f.c:62
ASFStream::ds_chunk_size
int ds_chunk_size
Definition: asfdec_f.c:60
ASFIndex::packet_number
uint32_t packet_number
Definition: asf.h:66
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVPacket::size
int size
Definition: packet.h:374
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:117
AVIOContext::seekable
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:262
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:736
ASFContext::packet_size
uint32_t packet_size
Definition: asfdec_o.c:97
ASF_INDEX_BLOCK
#define ASF_INDEX_BLOCK
Definition: asfenc.c:34
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
ASFPayload::type
uint8_t type
Definition: asfdec_f.c:42
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
ASFStream::ds_span
int ds_span
Definition: asfdec_f.c:58
ASFContext::is_streamed
int is_streamed
Definition: asfenc.c:224
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:218
asf_write_header1
static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size)
Definition: asfenc.c:387
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
Definition: mem.c:232
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:371
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:379
ASFStream::pkt
AVPacket pkt
Definition: asfdec_f.c:50
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:731
ASF_PPI_LENGTH_TYPE_FLAGS
#define ASF_PPI_LENGTH_TYPE_FLAGS
Definition: asfenc.c:54
ASFIndex::offset
uint64_t offset
Definition: asf.h:69
i
int i
Definition: input.c:406
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:466
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
AVOutputFormat
Definition: avformat.h:495
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
avio_internal.h
ff_asf_reserved_4
const ff_asf_guid ff_asf_reserved_4
Definition: asf.c:116
AVCodecParameters::height
int height
Definition: codec_par.h:127
ASFContext::creation_time
int64_t creation_time
Definition: asfenc.c:228
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:177
ASFStream::stream_language_index
uint16_t stream_language_index
Definition: asfdec_f.c:64
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:80
ASFStream::frag_offset
int frag_offset
Definition: asfdec_f.c:51
ff_metadata_conv
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:26
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:321
PREROLL_TIME
#define PREROLL_TIME
Definition: asfenc.c:265
ASFStream::payload
ASFPayload payload[8]
Definition: asfdec_f.c:70
len
int len
Definition: vorbis_enc_data.h:426
ff_asf_extended_content_header
const ff_asf_guid ff_asf_extended_content_header
Definition: asf.c:88
DATA_HEADER_SIZE
#define DATA_HEADER_SIZE
Definition: asfenc.c:184
put_header
static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
Definition: asfenc.c:282
ASFContext::packet_nb_payloads
unsigned int packet_nb_payloads
Definition: asfenc.c:237
tag
uint32_t tag
Definition: movenc.c:1597
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:845
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
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_stream
const ff_asf_guid ff_asf_audio_stream
Definition: asf.c:41
PACKET_SIZE_MAX
#define PACKET_SIZE_MAX
Definition: asfenc.c:186
ASFStream::packet_obj_size
int packet_obj_size
Definition: asfdec_f.c:52
ASFContext::nb_languages
int nb_languages
Definition: asfenc.c:227
ASFContext::multi_payloads_present
unsigned char multi_payloads_present
Definition: asfenc.c:233
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
dict.h
asf_options
static const AVOption asf_options[]
Definition: asfenc.c:1144
asf.h
get_send_time
static int32_t get_send_time(ASFContext *asf, int64_t pres_time, uint64_t *offset)
Definition: asfenc.c:330
ASFContext::next_packet_offset
uint64_t next_packet_offset
Definition: asfenc.c:248
asf_write_trailer
static int asf_write_trailer(AVFormatContext *s)
Definition: asfenc.c:1113
ff_codec_bmp_tags
const AVCodecTag ff_codec_bmp_tags[]
Definition: riff.c:34
ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT
#define ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT
Definition: asf.h:136
ff_asf_comment_header
const ff_asf_guid ff_asf_comment_header
Definition: asf.c:65
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
flush_packet
static void flush_packet(AVFormatContext *s)
Definition: asfenc.c:872
ff_put_guid
void ff_put_guid(AVIOContext *s, const ff_asf_guid *g)
Definition: riffenc.c:357
AVRational::den
int den
Denominator.
Definition: rational.h:60
PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
#define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS
Definition: asfenc.c:167
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
end_header
static void end_header(AVIOContext *pb, int64_t pos)
Definition: asfenc.c:293
ASFContext::duration
int duration
Definition: asfdec_o.c:99
ASFStream::num
int num
Definition: asfdec_f.c:47
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:1006
ff_asf_language_guid
const ff_asf_guid ff_asf_language_guid
Definition: asf.c:126
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: utils.c:1146
AVPacket::stream_index
int stream_index
Definition: packet.h:375
SINGLE_PAYLOAD_HEADERS
#define SINGLE_PAYLOAD_HEADERS
Definition: asfenc.c:175
ff_asf_file_header
const ff_asf_guid ff_asf_file_header
Definition: asf.c:29
ff_asf_metadata_header
const ff_asf_guid ff_asf_metadata_header
Definition: asf.c:104
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ASFContext
Definition: asfdec_f.c:73
ff_asf_head2_guid
const ff_asf_guid ff_asf_head2_guid
Definition: asf.c:84
AVIOContext::buffer
unsigned char * buffer
Start of the buffer.
Definition: avio.h:226
ASFStream::palette
uint32_t palette[256]
Definition: asfdec_f.c:67
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:935
AVDictionaryEntry
Definition: dict.h:79
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
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:70
riff.h
PACKET_HEADER_MIN_SIZE
#define PACKET_HEADER_MIN_SIZE
Definition: asfenc.c:146
ff_asf_my_guid
const ff_asf_guid ff_asf_my_guid
Definition: asf.c:122
ASFIndex::packet_count
uint16_t packet_count
Definition: asf.h:67
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:46
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ff_asf_marker_header
const ff_asf_guid ff_asf_marker_header
Definition: asf.c:112
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_CODEC_ID_MSMPEG4V3
@ AV_CODEC_ID_MSMPEG4V3
Definition: codec_id.h:66
asf_write_stream_header
static int asf_write_stream_header(AVFormatContext *s)
Definition: asfenc.c:815
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:3514
AVDictionaryEntry::value
char * value
Definition: dict.h:81
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:347
ff_asf_video_conceal_none
const ff_asf_guid ff_asf_video_conceal_none
Definition: asf.c:57
ASFContext::next_packet_count
uint16_t next_packet_count
Definition: asfenc.c:247
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:228
int
int
Definition: ffmpeg_filter.c:156
ASFContext::index_ptr
ASFIndex * index_ptr
Definition: asfenc.c:243
ASFPayload
Definition: asfdec_f.c:41
ff_asf_codec_comment1_header
const ff_asf_guid ff_asf_codec_comment1_header
Definition: asf.c:72
ff_asf_muxer
const AVOutputFormat ff_asf_muxer
ASFStream::payload_ext_ct
int payload_ext_ct
Definition: asfdec_f.c:69
ASF_PPI_PROPERTY_FLAGS
#define ASF_PPI_PROPERTY_FLAGS
Definition: asfenc.c:48
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:146
asf_write_index
static int asf_write_index(AVFormatContext *s, const ASFIndex *index, uint16_t max, uint32_t count)
Definition: asfenc.c:1094