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