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
45KB

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