You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1276 lines
44KB

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