]> git.sesse.net Git - ffmpeg/blob - libavformat/avformat.h
Currently, the replacement which is used if inet_aton isn't available,
[ffmpeg] / libavformat / avformat.h
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVFORMAT_AVFORMAT_H
22 #define AVFORMAT_AVFORMAT_H
23
24 #define LIBAVFORMAT_VERSION_MAJOR 52
25 #define LIBAVFORMAT_VERSION_MINOR 46
26 #define LIBAVFORMAT_VERSION_MICRO  0
27
28 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
29                                                LIBAVFORMAT_VERSION_MINOR, \
30                                                LIBAVFORMAT_VERSION_MICRO)
31 #define LIBAVFORMAT_VERSION     AV_VERSION(LIBAVFORMAT_VERSION_MAJOR,   \
32                                            LIBAVFORMAT_VERSION_MINOR,   \
33                                            LIBAVFORMAT_VERSION_MICRO)
34 #define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
35
36 #define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
37
38 /**
39  * Returns the LIBAVFORMAT_VERSION_INT constant.
40  */
41 unsigned avformat_version(void);
42
43 /**
44  * Returns the libavformat build-time configuration.
45  */
46 const char *avformat_configuration(void);
47
48 /**
49  * Returns the libavformat license.
50  */
51 const char *avformat_license(void);
52
53 #include <time.h>
54 #include <stdio.h>  /* FILE */
55 #include "libavcodec/avcodec.h"
56
57 #include "avio.h"
58
59 struct AVFormatContext;
60
61
62 /*
63  * Public Metadata API.
64  * The metadata API allows libavformat to export metadata tags to a client
65  * application using a sequence of key/value pairs.
66  * Important concepts to keep in mind:
67  * 1. Keys are unique; there can never be 2 tags with the same key. This is
68  *    also meant semantically, i.e., a demuxer should not knowingly produce
69  *    several keys that are literally different but semantically identical.
70  *    E.g., key=Author5, key=Author6. In this example, all authors must be
71  *    placed in the same tag.
72  * 2. Metadata is flat, not hierarchical; there are no subtags. If you
73  *    want to store, e.g., the email address of the child of producer Alice
74  *    and actor Bob, that could have key=alice_and_bobs_childs_email_address.
75  * 3. A tag whose value is localized for a particular language is appended
76  *    with a dash character ('-') and the ISO 639-2/B 3-letter language code.
77  *    For example: Author-ger=Michael, Author-eng=Mike
78  *    The original/default language is in the unqualified "Author" tag.
79  *    A demuxer should set a default if it sets any translated tag.
80  */
81
82 #define AV_METADATA_MATCH_CASE      1
83 #define AV_METADATA_IGNORE_SUFFIX   2
84 #define AV_METADATA_DONT_STRDUP_KEY 4
85 #define AV_METADATA_DONT_STRDUP_VAL 8
86
87 typedef struct {
88     char *key;
89     char *value;
90 }AVMetadataTag;
91
92 typedef struct AVMetadata AVMetadata;
93 typedef struct AVMetadataConv AVMetadataConv;
94
95 /**
96  * Gets a metadata element with matching key.
97  * @param prev Set to the previous matching element to find the next.
98  * @param flags Allows case as well as suffix-insensitive comparisons.
99  * @return Found tag or NULL, changing key or value leads to undefined behavior.
100  */
101 AVMetadataTag *
102 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
103
104 #if LIBAVFORMAT_VERSION_MAJOR == 52
105 /**
106  * Sets the given tag in m, overwriting an existing tag.
107  * @param key tag key to add to m (will be av_strduped)
108  * @param value tag value to add to m (will be av_strduped)
109  * @return >= 0 on success otherwise an error code <0
110  */
111 int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
112 #endif
113
114 /**
115  * Sets the given tag in m, overwriting an existing tag.
116  * @param key tag key to add to m (will be av_strduped depending on flags)
117  * @param value tag value to add to m (will be av_strduped depending on flags)
118  * @return >= 0 on success otherwise an error code <0
119  */
120 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
121
122 /**
123  * Converts all the metadata sets from ctx according to the source and
124  * destination conversion tables.
125  * @param d_conv destination tags format conversion table
126  * @param s_conv source tags format conversion table
127  */
128 void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
129                                                   const AVMetadataConv *s_conv);
130
131 /**
132  * Frees all the memory allocated for an AVMetadata struct.
133  */
134 void av_metadata_free(AVMetadata **m);
135
136
137 /* packet functions */
138
139
140 /**
141  * Allocates and reads the payload of a packet and initializes its
142  * fields with default values.
143  *
144  * @param pkt packet
145  * @param size desired payload size
146  * @return >0 (read size) if OK, AVERROR_xxx otherwise
147  */
148 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
149
150
151 /*************************************************/
152 /* fractional numbers for exact pts handling */
153
154 /**
155  * The exact value of the fractional number is: 'val + num / den'.
156  * num is assumed to be 0 <= num < den.
157  */
158 typedef struct AVFrac {
159     int64_t val, num, den;
160 } AVFrac;
161
162 /*************************************************/
163 /* input/output formats */
164
165 struct AVCodecTag;
166
167 /** This structure contains the data a format has to probe a file. */
168 typedef struct AVProbeData {
169     const char *filename;
170     unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
171     int buf_size;       /**< Size of buf except extra allocated bytes */
172 } AVProbeData;
173
174 #define AVPROBE_SCORE_MAX 100               ///< maximum score, half of that is used for file-extension-based detection
175 #define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
176
177 typedef struct AVFormatParameters {
178     AVRational time_base;
179     int sample_rate;
180     int channels;
181     int width;
182     int height;
183     enum PixelFormat pix_fmt;
184     int channel; /**< Used to select DV channel. */
185     const char *standard; /**< TV standard, NTSC, PAL, SECAM */
186     unsigned int mpeg2ts_raw:1;  /**< Force raw MPEG-2 transport stream output, if possible. */
187     unsigned int mpeg2ts_compute_pcr:1; /**< Compute exact PCR for each transport
188                                             stream packet (only meaningful if
189                                             mpeg2ts_raw is TRUE). */
190     unsigned int initial_pause:1;       /**< Do not begin to play the stream
191                                             immediately (RTSP only). */
192     unsigned int prealloced_context:1;
193 #if LIBAVFORMAT_VERSION_INT < (53<<16)
194     enum CodecID video_codec_id;
195     enum CodecID audio_codec_id;
196 #endif
197 } AVFormatParameters;
198
199 //! Demuxer will use url_fopen, no opened file should be provided by the caller.
200 #define AVFMT_NOFILE        0x0001
201 #define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
202 #define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
203 #define AVFMT_RAWPICTURE    0x0020 /**< Format wants AVPicture structure for
204                                       raw picture data. */
205 #define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
206 #define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
207 #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
208 #define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. */
209 #define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
210
211 typedef struct AVOutputFormat {
212     const char *name;
213     /**
214      * Descriptive name for the format, meant to be more human-readable
215      * than name. You should use the NULL_IF_CONFIG_SMALL() macro
216      * to define it.
217      */
218     const char *long_name;
219     const char *mime_type;
220     const char *extensions; /**< comma-separated filename extensions */
221     /** size of private data so that it can be allocated in the wrapper */
222     int priv_data_size;
223     /* output support */
224     enum CodecID audio_codec; /**< default audio codec */
225     enum CodecID video_codec; /**< default video codec */
226     int (*write_header)(struct AVFormatContext *);
227     int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
228     int (*write_trailer)(struct AVFormatContext *);
229     /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
230     int flags;
231     /** Currently only used to set pixel format if not YUV420P. */
232     int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
233     int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
234                              AVPacket *in, int flush);
235
236     /**
237      * List of supported codec_id-codec_tag pairs, ordered by "better
238      * choice first". The arrays are all terminated by CODEC_ID_NONE.
239      */
240     const struct AVCodecTag * const *codec_tag;
241
242     enum CodecID subtitle_codec; /**< default subtitle codec */
243
244     const AVMetadataConv *metadata_conv;
245
246     /* private fields */
247     struct AVOutputFormat *next;
248 } AVOutputFormat;
249
250 typedef struct AVInputFormat {
251     const char *name;
252     /**
253      * Descriptive name for the format, meant to be more human-readable
254      * than name. You should use the NULL_IF_CONFIG_SMALL() macro
255      * to define it.
256      */
257     const char *long_name;
258     /** Size of private data so that it can be allocated in the wrapper. */
259     int priv_data_size;
260     /**
261      * Tell if a given file has a chance of being parsed as this format.
262      * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
263      * big so you do not have to check for that unless you need more.
264      */
265     int (*read_probe)(AVProbeData *);
266     /** Read the format header and initialize the AVFormatContext
267        structure. Return 0 if OK. 'ap' if non-NULL contains
268        additional parameters. Only used in raw format right
269        now. 'av_new_stream' should be called to create new streams.  */
270     int (*read_header)(struct AVFormatContext *,
271                        AVFormatParameters *ap);
272     /** Read one packet and put it in 'pkt'. pts and flags are also
273        set. 'av_new_stream' can be called only if the flag
274        AVFMTCTX_NOHEADER is used.
275        @return 0 on success, < 0 on error.
276                When returning an error, pkt must not have been allocated
277                or must be freed before returning */
278     int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
279     /** Close the stream. The AVFormatContext and AVStreams are not
280        freed by this function */
281     int (*read_close)(struct AVFormatContext *);
282
283 #if LIBAVFORMAT_VERSION_MAJOR < 53
284     /**
285      * Seek to a given timestamp relative to the frames in
286      * stream component stream_index.
287      * @param stream_index Must not be -1.
288      * @param flags Selects which direction should be preferred if no exact
289      *              match is available.
290      * @return >= 0 on success (but not necessarily the new offset)
291      */
292     int (*read_seek)(struct AVFormatContext *,
293                      int stream_index, int64_t timestamp, int flags);
294 #endif
295     /**
296      * Gets the next timestamp in stream[stream_index].time_base units.
297      * @return the timestamp or AV_NOPTS_VALUE if an error occurred
298      */
299     int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
300                               int64_t *pos, int64_t pos_limit);
301     /** Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER. */
302     int flags;
303     /** If extensions are defined, then no probe is done. You should
304        usually not use extension format guessing because it is not
305        reliable enough */
306     const char *extensions;
307     /** General purpose read-only value that the format can use. */
308     int value;
309
310     /** Starts/resumes playing - only meaningful if using a network-based format
311        (RTSP). */
312     int (*read_play)(struct AVFormatContext *);
313
314     /** Pauses playing - only meaningful if using a network-based format
315        (RTSP). */
316     int (*read_pause)(struct AVFormatContext *);
317
318     const struct AVCodecTag * const *codec_tag;
319
320     /**
321      * Seeks to timestamp ts.
322      * Seeking will be done so that the point from which all active streams
323      * can be presented successfully will be closest to ts and within min/max_ts.
324      * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
325      */
326     int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
327
328     const AVMetadataConv *metadata_conv;
329
330     /* private fields */
331     struct AVInputFormat *next;
332 } AVInputFormat;
333
334 enum AVStreamParseType {
335     AVSTREAM_PARSE_NONE,
336     AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
337     AVSTREAM_PARSE_HEADERS,    /**< Only parse headers, do not repack. */
338     AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
339 };
340
341 typedef struct AVIndexEntry {
342     int64_t pos;
343     int64_t timestamp;
344 #define AVINDEX_KEYFRAME 0x0001
345     int flags:2;
346     int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
347     int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
348 } AVIndexEntry;
349
350 #define AV_DISPOSITION_DEFAULT   0x0001
351 #define AV_DISPOSITION_DUB       0x0002
352 #define AV_DISPOSITION_ORIGINAL  0x0004
353 #define AV_DISPOSITION_COMMENT   0x0008
354 #define AV_DISPOSITION_LYRICS    0x0010
355 #define AV_DISPOSITION_KARAOKE   0x0020
356
357 /**
358  * Stream structure.
359  * New fields can be added to the end with minor version bumps.
360  * Removal, reordering and changes to existing fields require a major
361  * version bump.
362  * sizeof(AVStream) must not be used outside libav*.
363  */
364 typedef struct AVStream {
365     int index;    /**< stream index in AVFormatContext */
366     int id;       /**< format-specific stream ID */
367     AVCodecContext *codec; /**< codec context */
368     /**
369      * Real base framerate of the stream.
370      * This is the lowest framerate with which all timestamps can be
371      * represented accurately (it is the least common multiple of all
372      * framerates in the stream). Note, this value is just a guess!
373      * For example, if the time base is 1/90000 and all frames have either
374      * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
375      */
376     AVRational r_frame_rate;
377     void *priv_data;
378
379     /* internal data used in av_find_stream_info() */
380     int64_t first_dts;
381     /** encoding: pts generation when outputting stream */
382     struct AVFrac pts;
383
384     /**
385      * This is the fundamental unit of time (in seconds) in terms
386      * of which frame timestamps are represented. For fixed-fps content,
387      * time base should be 1/framerate and timestamp increments should be 1.
388      */
389     AVRational time_base;
390     int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
391     /* ffmpeg.c private use */
392     int stream_copy; /**< If set, just copy stream. */
393     enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
394     //FIXME move stuff to a flags field?
395     /** Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
396      * MN: dunno if that is the right place for it */
397     float quality;
398     /**
399      * Decoding: pts of the first frame of the stream, in stream time base.
400      * Only set this if you are absolutely 100% sure that the value you set
401      * it to really is the pts of the first frame.
402      * This may be undefined (AV_NOPTS_VALUE).
403      * @note The ASF header does NOT contain a correct start_time the ASF
404      * demuxer must NOT set this.
405      */
406     int64_t start_time;
407     /**
408      * Decoding: duration of the stream, in stream time base.
409      * If a source file does not specify a duration, but does specify
410      * a bitrate, this value will be estimated from bitrate and file size.
411      */
412     int64_t duration;
413
414 #if LIBAVFORMAT_VERSION_INT < (53<<16)
415     char language[4]; /** ISO 639-2/B 3-letter language code (empty string if undefined) */
416 #endif
417
418     /* av_read_frame() support */
419     enum AVStreamParseType need_parsing;
420     struct AVCodecParserContext *parser;
421
422     int64_t cur_dts;
423     int last_IP_duration;
424     int64_t last_IP_pts;
425     /* av_seek_frame() support */
426     AVIndexEntry *index_entries; /**< Only used if the format does not
427                                     support seeking natively. */
428     int nb_index_entries;
429     unsigned int index_entries_allocated_size;
430
431     int64_t nb_frames;                 ///< number of frames in this stream if known or 0
432
433 #if LIBAVFORMAT_VERSION_INT < (53<<16)
434     int64_t unused[4+1];
435
436     char *filename; /**< source filename of the stream */
437 #endif
438
439     int disposition; /**< AV_DISPOSITION_* bit field */
440
441     AVProbeData probe_data;
442 #define MAX_REORDER_DELAY 16
443     int64_t pts_buffer[MAX_REORDER_DELAY+1];
444
445     /**
446      * sample aspect ratio (0 if unknown)
447      * - encoding: Set by user.
448      * - decoding: Set by libavformat.
449      */
450     AVRational sample_aspect_ratio;
451
452     AVMetadata *metadata;
453
454     /* av_read_frame() support */
455     const uint8_t *cur_ptr;
456     int cur_len;
457     AVPacket cur_pkt;
458
459     // Timestamp generation support:
460     /**
461      * Timestamp corresponding to the last dts sync point.
462      *
463      * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
464      * a DTS is received from the underlying container. Otherwise set to
465      * AV_NOPTS_VALUE by default.
466      */
467     int64_t reference_dts;
468
469     /**
470      * Number of packets to buffer for codec probing
471      * NOT PART OF PUBLIC API
472      */
473 #define MAX_PROBE_PACKETS 2500
474     int probe_packets;
475
476     /**
477      * last packet in packet_buffer for this stream when muxing.
478      * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav*
479      */
480     struct AVPacketList *last_in_packet_buffer;
481
482     /**
483      * Average framerate
484      */
485     AVRational avg_frame_rate;
486 } AVStream;
487
488 #define AV_PROGRAM_RUNNING 1
489
490 /**
491  * New fields can be added to the end with minor version bumps.
492  * Removal, reordering and changes to existing fields require a major
493  * version bump.
494  * sizeof(AVProgram) must not be used outside libav*.
495  */
496 typedef struct AVProgram {
497     int            id;
498 #if LIBAVFORMAT_VERSION_INT < (53<<16)
499     char           *provider_name; ///< network name for DVB streams
500     char           *name;          ///< service name for DVB streams
501 #endif
502     int            flags;
503     enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
504     unsigned int   *stream_index;
505     unsigned int   nb_stream_indexes;
506     AVMetadata *metadata;
507 } AVProgram;
508
509 #define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
510                                          (streams are added dynamically) */
511
512 typedef struct AVChapter {
513     int id;                 ///< unique ID to identify the chapter
514     AVRational time_base;   ///< time base in which the start/end timestamps are specified
515     int64_t start, end;     ///< chapter start/end time in time_base units
516 #if LIBAVFORMAT_VERSION_INT < (53<<16)
517     char *title;            ///< chapter title
518 #endif
519     AVMetadata *metadata;
520 } AVChapter;
521
522 #define MAX_STREAMS 20
523
524 /**
525  * Format I/O context.
526  * New fields can be added to the end with minor version bumps.
527  * Removal, reordering and changes to existing fields require a major
528  * version bump.
529  * sizeof(AVFormatContext) must not be used outside libav*.
530  */
531 typedef struct AVFormatContext {
532     const AVClass *av_class; /**< Set by avformat_alloc_context. */
533     /* Can only be iformat or oformat, not both at the same time. */
534     struct AVInputFormat *iformat;
535     struct AVOutputFormat *oformat;
536     void *priv_data;
537     ByteIOContext *pb;
538     unsigned int nb_streams;
539     AVStream *streams[MAX_STREAMS];
540     char filename[1024]; /**< input or output filename */
541     /* stream info */
542     int64_t timestamp;
543 #if LIBAVFORMAT_VERSION_INT < (53<<16)
544     char title[512];
545     char author[512];
546     char copyright[512];
547     char comment[512];
548     char album[512];
549     int year;  /**< ID3 year, 0 if none */
550     int track; /**< track number, 0 if none */
551     char genre[32]; /**< ID3 genre */
552 #endif
553
554     int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
555     /* private data for pts handling (do not modify directly). */
556     /** This buffer is only needed when packets were already buffered but
557        not decoded, for example to get the codec parameters in MPEG
558        streams. */
559     struct AVPacketList *packet_buffer;
560
561     /** Decoding: position of the first frame of the component, in
562        AV_TIME_BASE fractional seconds. NEVER set this value directly:
563        It is deduced from the AVStream values.  */
564     int64_t start_time;
565     /** Decoding: duration of the stream, in AV_TIME_BASE fractional
566        seconds. NEVER set this value directly: it is deduced from the
567        AVStream values.  */
568     int64_t duration;
569     /** decoding: total file size, 0 if unknown */
570     int64_t file_size;
571     /** Decoding: total stream bitrate in bit/s, 0 if not
572        available. Never set it directly if the file_size and the
573        duration are known as FFmpeg can compute it automatically. */
574     int bit_rate;
575
576     /* av_read_frame() support */
577     AVStream *cur_st;
578 #if LIBAVFORMAT_VERSION_INT < (53<<16)
579     const uint8_t *cur_ptr_deprecated;
580     int cur_len_deprecated;
581     AVPacket cur_pkt_deprecated;
582 #endif
583
584     /* av_seek_frame() support */
585     int64_t data_offset; /** offset of the first packet */
586     int index_built;
587
588     int mux_rate;
589     unsigned int packet_size;
590     int preload;
591     int max_delay;
592
593 #define AVFMT_NOOUTPUTLOOP -1
594 #define AVFMT_INFINITEOUTPUTLOOP 0
595     /** number of times to loop output in formats that support it */
596     int loop_output;
597
598     int flags;
599 #define AVFMT_FLAG_GENPTS       0x0001 ///< Generate missing pts even if it requires parsing future frames.
600 #define AVFMT_FLAG_IGNIDX       0x0002 ///< Ignore index.
601 #define AVFMT_FLAG_NONBLOCK     0x0004 ///< Do not block when reading packets from input.
602
603     int loop_input;
604     /** decoding: size of data to probe; encoding: unused. */
605     unsigned int probesize;
606
607     /**
608      * Maximum time (in AV_TIME_BASE units) during which the input should
609      * be analyzed in av_find_stream_info().
610      */
611     int max_analyze_duration;
612
613     const uint8_t *key;
614     int keylen;
615
616     unsigned int nb_programs;
617     AVProgram **programs;
618
619     /**
620      * Forced video codec_id.
621      * Demuxing: Set by user.
622      */
623     enum CodecID video_codec_id;
624     /**
625      * Forced audio codec_id.
626      * Demuxing: Set by user.
627      */
628     enum CodecID audio_codec_id;
629     /**
630      * Forced subtitle codec_id.
631      * Demuxing: Set by user.
632      */
633     enum CodecID subtitle_codec_id;
634
635     /**
636      * Maximum amount of memory in bytes to use for the index of each stream.
637      * If the index exceeds this size, entries will be discarded as
638      * needed to maintain a smaller size. This can lead to slower or less
639      * accurate seeking (depends on demuxer).
640      * Demuxers for which a full in-memory index is mandatory will ignore
641      * this.
642      * muxing  : unused
643      * demuxing: set by user
644      */
645     unsigned int max_index_size;
646
647     /**
648      * Maximum amount of memory in bytes to use for buffering frames
649      * obtained from realtime capture devices.
650      */
651     unsigned int max_picture_buffer;
652
653     unsigned int nb_chapters;
654     AVChapter **chapters;
655
656     /**
657      * Flags to enable debugging.
658      */
659     int debug;
660 #define FF_FDEBUG_TS        0x0001
661
662     /**
663      * Raw packets from the demuxer, prior to parsing and decoding.
664      * This buffer is used for buffering packets until the codec can
665      * be identified, as parsing cannot be done without knowing the
666      * codec.
667      */
668     struct AVPacketList *raw_packet_buffer;
669     struct AVPacketList *raw_packet_buffer_end;
670
671     struct AVPacketList *packet_buffer_end;
672
673     AVMetadata *metadata;
674
675     /**
676      * Remaining size available for raw_packet_buffer, in bytes.
677      * NOT PART OF PUBLIC API
678      */
679 #define RAW_PACKET_BUFFER_SIZE 2500000
680     int raw_packet_buffer_remaining_size;
681 } AVFormatContext;
682
683 typedef struct AVPacketList {
684     AVPacket pkt;
685     struct AVPacketList *next;
686 } AVPacketList;
687
688 #if LIBAVFORMAT_VERSION_INT < (53<<16)
689 extern AVInputFormat *first_iformat;
690 extern AVOutputFormat *first_oformat;
691 #endif
692
693 /**
694  * If f is NULL, returns the first registered input format,
695  * if f is non-NULL, returns the next registered input format after f
696  * or NULL if f is the last one.
697  */
698 AVInputFormat  *av_iformat_next(AVInputFormat  *f);
699
700 /**
701  * If f is NULL, returns the first registered output format,
702  * if f is non-NULL, returns the next registered output format after f
703  * or NULL if f is the last one.
704  */
705 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
706
707 enum CodecID av_guess_image2_codec(const char *filename);
708
709 /* XXX: Use automatic init with either ELF sections or C file parser */
710 /* modules. */
711
712 /* utils.c */
713 void av_register_input_format(AVInputFormat *format);
714 void av_register_output_format(AVOutputFormat *format);
715 #if LIBAVFORMAT_VERSION_MAJOR < 53
716 attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
717                                     const char *filename,
718                                     const char *mime_type);
719
720 /**
721  * @deprecated Use av_guess_format() instead.
722  */
723 attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
724                                                   const char *filename,
725                                                   const char *mime_type);
726 #endif
727
728 /**
729  * Returns the output format in the list of registered output formats
730  * which best matches the provided parameters, or returns NULL if
731  * there is no match.
732  *
733  * @param short_name if non-NULL checks if short_name matches with the
734  * names of the registered formats
735  * @param filename if non-NULL checks if filename terminates with the
736  * extensions of the registered formats
737  * @param mime_type if non-NULL checks if mime_type matches with the
738  * MIME type of the registered formats
739  */
740 AVOutputFormat *av_guess_format(const char *short_name,
741                                 const char *filename,
742                                 const char *mime_type);
743
744 /**
745  * Guesses the codec ID based upon muxer and filename.
746  */
747 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
748                             const char *filename, const char *mime_type,
749                             enum CodecType type);
750
751 /**
752  * Sends a nice hexadecimal dump of a buffer to the specified file stream.
753  *
754  * @param f The file stream pointer where the dump should be sent to.
755  * @param buf buffer
756  * @param size buffer size
757  *
758  * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
759  */
760 void av_hex_dump(FILE *f, uint8_t *buf, int size);
761
762 /**
763  * Sends a nice hexadecimal dump of a buffer to the log.
764  *
765  * @param avcl A pointer to an arbitrary struct of which the first field is a
766  * pointer to an AVClass struct.
767  * @param level The importance level of the message, lower values signifying
768  * higher importance.
769  * @param buf buffer
770  * @param size buffer size
771  *
772  * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
773  */
774 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
775
776 /**
777  * Sends a nice dump of a packet to the specified file stream.
778  *
779  * @param f The file stream pointer where the dump should be sent to.
780  * @param pkt packet to dump
781  * @param dump_payload True if the payload must be displayed, too.
782  */
783 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
784
785 /**
786  * Sends a nice dump of a packet to the log.
787  *
788  * @param avcl A pointer to an arbitrary struct of which the first field is a
789  * pointer to an AVClass struct.
790  * @param level The importance level of the message, lower values signifying
791  * higher importance.
792  * @param pkt packet to dump
793  * @param dump_payload True if the payload must be displayed, too.
794  */
795 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
796
797 /**
798  * Initializes libavformat and registers all the muxers, demuxers and
799  * protocols. If you do not call this function, then you can select
800  * exactly which formats you want to support.
801  *
802  * @see av_register_input_format()
803  * @see av_register_output_format()
804  * @see av_register_protocol()
805  */
806 void av_register_all(void);
807
808 /** codec tag <-> codec id */
809 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
810 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
811
812 /* media file input */
813
814 /**
815  * Finds AVInputFormat based on the short name of the input format.
816  */
817 AVInputFormat *av_find_input_format(const char *short_name);
818
819 /**
820  * Guesses the file format.
821  *
822  * @param is_opened Whether the file is already opened; determines whether
823  *                  demuxers with or without AVFMT_NOFILE are probed.
824  */
825 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
826
827 /**
828  * Allocates all the structures needed to read an input stream.
829  *        This does not open the needed codecs for decoding the stream[s].
830  */
831 int av_open_input_stream(AVFormatContext **ic_ptr,
832                          ByteIOContext *pb, const char *filename,
833                          AVInputFormat *fmt, AVFormatParameters *ap);
834
835 /**
836  * Opens a media file as input. The codecs are not opened. Only the file
837  * header (if present) is read.
838  *
839  * @param ic_ptr The opened media file handle is put here.
840  * @param filename filename to open
841  * @param fmt If non-NULL, force the file format to use.
842  * @param buf_size optional buffer size (zero if default is OK)
843  * @param ap Additional parameters needed when opening the file
844  *           (NULL if default).
845  * @return 0 if OK, AVERROR_xxx otherwise
846  */
847 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
848                        AVInputFormat *fmt,
849                        int buf_size,
850                        AVFormatParameters *ap);
851
852 #if LIBAVFORMAT_VERSION_MAJOR < 53
853 /**
854  * @deprecated Use avformat_alloc_context() instead.
855  */
856 attribute_deprecated AVFormatContext *av_alloc_format_context(void);
857 #endif
858
859 /**
860  * Allocates an AVFormatContext.
861  * Can be freed with av_free() but do not forget to free everything you
862  * explicitly allocated as well!
863  */
864 AVFormatContext *avformat_alloc_context(void);
865
866 /**
867  * Reads packets of a media file to get stream information. This
868  * is useful for file formats with no headers such as MPEG. This
869  * function also computes the real framerate in case of MPEG-2 repeat
870  * frame mode.
871  * The logical file position is not changed by this function;
872  * examined packets may be buffered for later processing.
873  *
874  * @param ic media file handle
875  * @return >=0 if OK, AVERROR_xxx on error
876  * @todo Let the user decide somehow what information is needed so that
877  *       we do not waste time getting stuff the user does not need.
878  */
879 int av_find_stream_info(AVFormatContext *ic);
880
881 /**
882  * Reads a transport packet from a media file.
883  *
884  * This function is obsolete and should never be used.
885  * Use av_read_frame() instead.
886  *
887  * @param s media file handle
888  * @param pkt is filled
889  * @return 0 if OK, AVERROR_xxx on error
890  */
891 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
892
893 /**
894  * Returns the next frame of a stream.
895  *
896  * The returned packet is valid
897  * until the next av_read_frame() or until av_close_input_file() and
898  * must be freed with av_free_packet. For video, the packet contains
899  * exactly one frame. For audio, it contains an integer number of
900  * frames if each frame has a known fixed size (e.g. PCM or ADPCM
901  * data). If the audio frames have a variable size (e.g. MPEG audio),
902  * then it contains one frame.
903  *
904  * pkt->pts, pkt->dts and pkt->duration are always set to correct
905  * values in AVStream.time_base units (and guessed if the format cannot
906  * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
907  * has B-frames, so it is better to rely on pkt->dts if you do not
908  * decompress the payload.
909  *
910  * @return 0 if OK, < 0 on error or end of file
911  */
912 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
913
914 /**
915  * Seeks to the keyframe at timestamp.
916  * 'timestamp' in 'stream_index'.
917  * @param stream_index If stream_index is (-1), a default
918  * stream is selected, and timestamp is automatically converted
919  * from AV_TIME_BASE units to the stream specific time_base.
920  * @param timestamp Timestamp in AVStream.time_base units
921  *        or, if no stream is specified, in AV_TIME_BASE units.
922  * @param flags flags which select direction and seeking mode
923  * @return >= 0 on success
924  */
925 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
926                   int flags);
927
928 /**
929  * Seeks to timestamp ts.
930  * Seeking will be done so that the point from which all active streams
931  * can be presented successfully will be closest to ts and within min/max_ts.
932  * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
933  *
934  * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
935  * are the file position (this may not be supported by all demuxers).
936  * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
937  * in the stream with stream_index (this may not be supported by all demuxers).
938  * Otherwise all timestamps are in units of the stream selected by stream_index
939  * or if stream_index is -1, in AV_TIME_BASE units.
940  * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
941  * keyframes (this may not be supported by all demuxers).
942  *
943  * @param stream_index index of the stream which is used as time base reference
944  * @param min_ts smallest acceptable timestamp
945  * @param ts target timestamp
946  * @param max_ts largest acceptable timestamp
947  * @param flags flags
948  * @returns >=0 on success, error code otherwise
949  *
950  * @NOTE This is part of the new seek API which is still under construction.
951  *       Thus do not use this yet. It may change at any time, do not expect
952  *       ABI compatibility yet!
953  */
954 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
955
956 /**
957  * Starts playing a network-based stream (e.g. RTSP stream) at the
958  * current position.
959  */
960 int av_read_play(AVFormatContext *s);
961
962 /**
963  * Pauses a network-based stream (e.g. RTSP stream).
964  *
965  * Use av_read_play() to resume it.
966  */
967 int av_read_pause(AVFormatContext *s);
968
969 /**
970  * Frees a AVFormatContext allocated by av_open_input_stream.
971  * @param s context to free
972  */
973 void av_close_input_stream(AVFormatContext *s);
974
975 /**
976  * Closes a media file (but not its codecs).
977  *
978  * @param s media file handle
979  */
980 void av_close_input_file(AVFormatContext *s);
981
982 /**
983  * Adds a new stream to a media file.
984  *
985  * Can only be called in the read_header() function. If the flag
986  * AVFMTCTX_NOHEADER is in the format context, then new streams
987  * can be added in read_packet too.
988  *
989  * @param s media file handle
990  * @param id file-format-dependent stream ID
991  */
992 AVStream *av_new_stream(AVFormatContext *s, int id);
993 AVProgram *av_new_program(AVFormatContext *s, int id);
994
995 /**
996  * Adds a new chapter.
997  * This function is NOT part of the public API
998  * and should ONLY be used by demuxers.
999  *
1000  * @param s media file handle
1001  * @param id unique ID for this chapter
1002  * @param start chapter start time in time_base units
1003  * @param end chapter end time in time_base units
1004  * @param title chapter title
1005  *
1006  * @return AVChapter or NULL on error
1007  */
1008 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
1009                           int64_t start, int64_t end, const char *title);
1010
1011 /**
1012  * Sets the pts for a given stream.
1013  *
1014  * @param s stream
1015  * @param pts_wrap_bits number of bits effectively used by the pts
1016  *        (used for wrap control, 33 is the value for MPEG)
1017  * @param pts_num numerator to convert to seconds (MPEG: 1)
1018  * @param pts_den denominator to convert to seconds (MPEG: 90000)
1019  */
1020 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
1021                      unsigned int pts_num, unsigned int pts_den);
1022
1023 #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
1024 #define AVSEEK_FLAG_BYTE     2 ///< seeking based on position in bytes
1025 #define AVSEEK_FLAG_ANY      4 ///< seek to any frame, even non-keyframes
1026 #define AVSEEK_FLAG_FRAME    8 ///< seeking based on frame number
1027
1028 int av_find_default_stream_index(AVFormatContext *s);
1029
1030 /**
1031  * Gets the index for a specific timestamp.
1032  * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
1033  *                 to the timestamp which is <= the requested one, if backward
1034  *                 is 0, then it will be >=
1035  *              if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
1036  * @return < 0 if no such timestamp could be found
1037  */
1038 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1039
1040 /**
1041  * Ensures the index uses less memory than the maximum specified in
1042  * AVFormatContext.max_index_size by discarding entries if it grows
1043  * too large.
1044  * This function is not part of the public API and should only be called
1045  * by demuxers.
1046  */
1047 void ff_reduce_index(AVFormatContext *s, int stream_index);
1048
1049 /**
1050  * Adds an index entry into a sorted list. Updates the entry if the list
1051  * already contains it.
1052  *
1053  * @param timestamp timestamp in the time base of the given stream
1054  */
1055 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1056                        int size, int distance, int flags);
1057
1058 /**
1059  * Does a binary search using av_index_search_timestamp() and
1060  * AVCodec.read_timestamp().
1061  * This is not supposed to be called directly by a user application,
1062  * but by demuxers.
1063  * @param target_ts target timestamp in the time base of the given stream
1064  * @param stream_index stream number
1065  */
1066 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
1067                          int64_t target_ts, int flags);
1068
1069 /**
1070  * Updates cur_dts of all streams based on the given timestamp and AVStream.
1071  *
1072  * Stream ref_st unchanged, others set cur_dts in their native time base.
1073  * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
1074  * @param timestamp new dts expressed in time_base of param ref_st
1075  * @param ref_st reference stream giving time_base of param timestamp
1076  */
1077 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
1078
1079 /**
1080  * Does a binary search using read_timestamp().
1081  * This is not supposed to be called directly by a user application,
1082  * but by demuxers.
1083  * @param target_ts target timestamp in the time base of the given stream
1084  * @param stream_index stream number
1085  */
1086 int64_t av_gen_search(AVFormatContext *s, int stream_index,
1087                       int64_t target_ts, int64_t pos_min,
1088                       int64_t pos_max, int64_t pos_limit,
1089                       int64_t ts_min, int64_t ts_max,
1090                       int flags, int64_t *ts_ret,
1091                       int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
1092
1093 /** media file output */
1094 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1095
1096 /**
1097  * Allocates the stream private data and writes the stream header to an
1098  * output media file.
1099  *
1100  * @param s media file handle
1101  * @return 0 if OK, AVERROR_xxx on error
1102  */
1103 int av_write_header(AVFormatContext *s);
1104
1105 /**
1106  * Writes a packet to an output media file.
1107  *
1108  * The packet shall contain one audio or video frame.
1109  * The packet must be correctly interleaved according to the container
1110  * specification, if not then av_interleaved_write_frame must be used.
1111  *
1112  * @param s media file handle
1113  * @param pkt The packet, which contains the stream_index, buf/buf_size,
1114               dts/pts, ...
1115  * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
1116  */
1117 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
1118
1119 /**
1120  * Writes a packet to an output media file ensuring correct interleaving.
1121  *
1122  * The packet must contain one audio or video frame.
1123  * If the packets are already correctly interleaved, the application should
1124  * call av_write_frame() instead as it is slightly faster. It is also important
1125  * to keep in mind that completely non-interleaved input will need huge amounts
1126  * of memory to interleave with this, so it is preferable to interleave at the
1127  * demuxer level.
1128  *
1129  * @param s media file handle
1130  * @param pkt The packet, which contains the stream_index, buf/buf_size,
1131               dts/pts, ...
1132  * @return < 0 on error, = 0 if OK, 1 if end of stream wanted
1133  */
1134 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
1135
1136 /**
1137  * Interleaves a packet per dts in an output media file.
1138  *
1139  * Packets with pkt->destruct == av_destruct_packet will be freed inside this
1140  * function, so they cannot be used after it. Note that calling av_free_packet()
1141  * on them is still safe.
1142  *
1143  * @param s media file handle
1144  * @param out the interleaved packet will be output here
1145  * @param in the input packet
1146  * @param flush 1 if no further packets are available as input and all
1147  *              remaining packets should be output
1148  * @return 1 if a packet was output, 0 if no packet could be output,
1149  *         < 0 if an error occurred
1150  */
1151 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
1152                                  AVPacket *pkt, int flush);
1153
1154 /**
1155  * Writes the stream trailer to an output media file and frees the
1156  * file private data.
1157  *
1158  * May only be called after a successful call to av_write_header.
1159  *
1160  * @param s media file handle
1161  * @return 0 if OK, AVERROR_xxx on error
1162  */
1163 int av_write_trailer(AVFormatContext *s);
1164
1165 void dump_format(AVFormatContext *ic,
1166                  int index,
1167                  const char *url,
1168                  int is_output);
1169
1170 #if LIBAVFORMAT_VERSION_MAJOR < 53
1171 /**
1172  * Parses width and height out of string str.
1173  * @deprecated Use av_parse_video_frame_size instead.
1174  */
1175 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
1176                                           const char *str);
1177
1178 /**
1179  * Converts framerate from a string to a fraction.
1180  * @deprecated Use av_parse_video_frame_rate instead.
1181  */
1182 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
1183                                           const char *arg);
1184 #endif
1185
1186 /**
1187  * Parses datestr and returns a corresponding number of microseconds.
1188  * @param datestr String representing a date or a duration.
1189  * - If a date the syntax is:
1190  * @code
1191  *  [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
1192  * @endcode
1193  * Time is local time unless Z is appended, in which case it is
1194  * interpreted as UTC.
1195  * If the year-month-day part is not specified it takes the current
1196  * year-month-day.
1197  * Returns the number of microseconds since 1st of January, 1970 up to
1198  * the time of the parsed date or INT64_MIN if datestr cannot be
1199  * successfully parsed.
1200  * - If a duration the syntax is:
1201  * @code
1202  *  [-]HH[:MM[:SS[.m...]]]
1203  *  [-]S+[.m...]
1204  * @endcode
1205  * Returns the number of microseconds contained in a time interval
1206  * with the specified duration or INT64_MIN if datestr cannot be
1207  * successfully parsed.
1208  * @param duration Flag which tells how to interpret datestr, if
1209  * not zero datestr is interpreted as a duration, otherwise as a
1210  * date.
1211  */
1212 int64_t parse_date(const char *datestr, int duration);
1213
1214 /** Gets the current time in microseconds. */
1215 int64_t av_gettime(void);
1216
1217 /* ffm-specific for ffserver */
1218 #define FFM_PACKET_SIZE 4096
1219 int64_t ffm_read_write_index(int fd);
1220 int ffm_write_write_index(int fd, int64_t pos);
1221 void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
1222
1223 /**
1224  * Attempts to find a specific tag in a URL.
1225  *
1226  * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
1227  * Return 1 if found.
1228  */
1229 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1230
1231 /**
1232  * Returns in 'buf' the path with '%d' replaced by a number.
1233  *
1234  * Also handles the '%0nd' format where 'n' is the total number
1235  * of digits and '%%'.
1236  *
1237  * @param buf destination buffer
1238  * @param buf_size destination buffer size
1239  * @param path numbered sequence string
1240  * @param number frame number
1241  * @return 0 if OK, -1 on format error
1242  */
1243 int av_get_frame_filename(char *buf, int buf_size,
1244                           const char *path, int number);
1245
1246 /**
1247  * Checks whether filename actually is a numbered sequence generator.
1248  *
1249  * @param filename possible numbered sequence string
1250  * @return 1 if a valid numbered sequence string, 0 otherwise
1251  */
1252 int av_filename_number_test(const char *filename);
1253
1254 /**
1255  * Generates an SDP for an RTP session.
1256  *
1257  * @param ac array of AVFormatContexts describing the RTP streams. If the
1258  *           array is composed by only one context, such context can contain
1259  *           multiple AVStreams (one AVStream per RTP stream). Otherwise,
1260  *           all the contexts in the array (an AVCodecContext per RTP stream)
1261  *           must contain only one AVStream.
1262  * @param n_files number of AVCodecContexts contained in ac
1263  * @param buff buffer where the SDP will be stored (must be allocated by
1264  *             the caller)
1265  * @param size the size of the buffer
1266  * @return 0 if OK, AVERROR_xxx on error
1267  */
1268 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1269
1270 #ifdef HAVE_AV_CONFIG_H
1271
1272 void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
1273
1274 #ifdef __GNUC__
1275 #define dynarray_add(tab, nb_ptr, elem)\
1276 do {\
1277     __typeof__(tab) _tab = (tab);\
1278     __typeof__(elem) _elem = (elem);\
1279     (void)sizeof(**_tab == _elem); /* check that types are compatible */\
1280     ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
1281 } while(0)
1282 #else
1283 #define dynarray_add(tab, nb_ptr, elem)\
1284 do {\
1285     ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
1286 } while(0)
1287 #endif
1288
1289 time_t mktimegm(struct tm *tm);
1290 struct tm *brktimegm(time_t secs, struct tm *tm);
1291 const char *small_strptime(const char *p, const char *fmt,
1292                            struct tm *dt);
1293
1294 struct in_addr;
1295 int resolve_host(struct in_addr *sin_addr, const char *hostname);
1296
1297 void url_split(char *proto, int proto_size,
1298                char *authorization, int authorization_size,
1299                char *hostname, int hostname_size,
1300                int *port_ptr,
1301                char *path, int path_size,
1302                const char *url);
1303
1304 #if LIBAVFORMAT_VERSION_MAJOR < 53
1305 /**
1306  * @deprecated Use av_match_ext() instead.
1307  */
1308 attribute_deprecated int match_ext(const char *filename, const char *extensions);
1309 #endif
1310
1311 /**
1312  * Returns a positive value if the given filename has one of the given
1313  * extensions, 0 otherwise.
1314  *
1315  * @param extensions a comma-separated list of filename extensions
1316  */
1317 int av_match_ext(const char *filename, const char *extensions);
1318
1319 #endif /* HAVE_AV_CONFIG_H */
1320
1321 #endif /* AVFORMAT_AVFORMAT_H */