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.

742 lines
23KB

  1. #ifndef AVFORMAT_H
  2. #define AVFORMAT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define LIBAVFORMAT_VERSION_INT ((50<<16)+(4<<8)+0)
  7. #define LIBAVFORMAT_VERSION 50.4.0
  8. #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
  9. #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
  10. #include <time.h>
  11. #include <stdio.h> /* FILE */
  12. #include "avcodec.h"
  13. #include "avio.h"
  14. /* packet functions */
  15. #ifndef MAXINT64
  16. #define MAXINT64 int64_t_C(0x7fffffffffffffff)
  17. #endif
  18. #ifndef MININT64
  19. #define MININT64 int64_t_C(0x8000000000000000)
  20. #endif
  21. typedef struct AVPacket {
  22. int64_t pts; ///< presentation time stamp in time_base units
  23. int64_t dts; ///< decompression time stamp in time_base units
  24. uint8_t *data;
  25. int size;
  26. int stream_index;
  27. int flags;
  28. int duration; ///< presentation duration in time_base units (0 if not available)
  29. void (*destruct)(struct AVPacket *);
  30. void *priv;
  31. int64_t pos; ///< byte position in stream, -1 if unknown
  32. } AVPacket;
  33. #define PKT_FLAG_KEY 0x0001
  34. void av_destruct_packet_nofree(AVPacket *pkt);
  35. void av_destruct_packet(AVPacket *pkt);
  36. /* initialize optional fields of a packet */
  37. static inline void av_init_packet(AVPacket *pkt)
  38. {
  39. pkt->pts = AV_NOPTS_VALUE;
  40. pkt->dts = AV_NOPTS_VALUE;
  41. pkt->pos = -1;
  42. pkt->duration = 0;
  43. pkt->flags = 0;
  44. pkt->stream_index = 0;
  45. pkt->destruct= av_destruct_packet_nofree;
  46. }
  47. int av_new_packet(AVPacket *pkt, int size);
  48. int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
  49. int av_dup_packet(AVPacket *pkt);
  50. /**
  51. * Free a packet
  52. *
  53. * @param pkt packet to free
  54. */
  55. static inline void av_free_packet(AVPacket *pkt)
  56. {
  57. if (pkt && pkt->destruct) {
  58. pkt->destruct(pkt);
  59. }
  60. }
  61. /*************************************************/
  62. /* fractional numbers for exact pts handling */
  63. /* the exact value of the fractional number is: 'val + num / den'. num
  64. is assumed to be such as 0 <= num < den */
  65. typedef struct AVFrac {
  66. int64_t val, num, den;
  67. } AVFrac;
  68. void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
  69. void av_frac_add(AVFrac *f, int64_t incr);
  70. void av_frac_set(AVFrac *f, int64_t val);
  71. /*************************************************/
  72. /* input/output formats */
  73. struct AVFormatContext;
  74. /* this structure contains the data a format has to probe a file */
  75. typedef struct AVProbeData {
  76. const char *filename;
  77. unsigned char *buf;
  78. int buf_size;
  79. } AVProbeData;
  80. #define AVPROBE_SCORE_MAX 100
  81. typedef struct AVFormatParameters {
  82. AVRational time_base;
  83. int sample_rate;
  84. int channels;
  85. int width;
  86. int height;
  87. enum PixelFormat pix_fmt;
  88. struct AVImageFormat *image_format;
  89. int channel; /* used to select dv channel */
  90. const char *device; /* video, audio or DV device */
  91. const char *standard; /* tv standard, NTSC, PAL, SECAM */
  92. int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
  93. int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
  94. stream packet (only meaningful if
  95. mpeg2ts_raw is TRUE */
  96. int initial_pause:1; /* do not begin to play the stream
  97. immediately (RTSP only) */
  98. enum CodecID video_codec_id;
  99. enum CodecID audio_codec_id;
  100. } AVFormatParameters;
  101. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  102. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  103. #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
  104. #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
  105. raw picture data */
  106. #define AVFMT_GLOBALHEADER 0x0040 /* format wants global header */
  107. typedef struct AVOutputFormat {
  108. const char *name;
  109. const char *long_name;
  110. const char *mime_type;
  111. const char *extensions; /* comma separated extensions */
  112. /* size of private data so that it can be allocated in the wrapper */
  113. int priv_data_size;
  114. /* output support */
  115. enum CodecID audio_codec; /* default audio codec */
  116. enum CodecID video_codec; /* default video codec */
  117. int (*write_header)(struct AVFormatContext *);
  118. int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
  119. int (*write_trailer)(struct AVFormatContext *);
  120. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
  121. int flags;
  122. /* currently only used to set pixel format if not YUV420P */
  123. int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
  124. int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
  125. /* private fields */
  126. struct AVOutputFormat *next;
  127. } AVOutputFormat;
  128. typedef struct AVInputFormat {
  129. const char *name;
  130. const char *long_name;
  131. /* size of private data so that it can be allocated in the wrapper */
  132. int priv_data_size;
  133. /* tell if a given file has a chance of being parsing by this format */
  134. int (*read_probe)(AVProbeData *);
  135. /* read the format header and initialize the AVFormatContext
  136. structure. Return 0 if OK. 'ap' if non NULL contains
  137. additionnal paramters. Only used in raw format right
  138. now. 'av_new_stream' should be called to create new streams. */
  139. int (*read_header)(struct AVFormatContext *,
  140. AVFormatParameters *ap);
  141. /* read one packet and put it in 'pkt'. pts and flags are also
  142. set. 'av_new_stream' can be called only if the flag
  143. AVFMTCTX_NOHEADER is used. */
  144. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  145. /* close the stream. The AVFormatContext and AVStreams are not
  146. freed by this function */
  147. int (*read_close)(struct AVFormatContext *);
  148. /**
  149. * seek to a given timestamp relative to the frames in
  150. * stream component stream_index
  151. * @param stream_index must not be -1
  152. * @param flags selects which direction should be preferred if no exact
  153. * match is available
  154. */
  155. int (*read_seek)(struct AVFormatContext *,
  156. int stream_index, int64_t timestamp, int flags);
  157. /**
  158. * gets the next timestamp in AV_TIME_BASE units.
  159. */
  160. int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
  161. int64_t *pos, int64_t pos_limit);
  162. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
  163. int flags;
  164. /* if extensions are defined, then no probe is done. You should
  165. usually not use extension format guessing because it is not
  166. reliable enough */
  167. const char *extensions;
  168. /* general purpose read only value that the format can use */
  169. int value;
  170. /* start/resume playing - only meaningful if using a network based format
  171. (RTSP) */
  172. int (*read_play)(struct AVFormatContext *);
  173. /* pause playing - only meaningful if using a network based format
  174. (RTSP) */
  175. int (*read_pause)(struct AVFormatContext *);
  176. /* private fields */
  177. struct AVInputFormat *next;
  178. } AVInputFormat;
  179. typedef struct AVIndexEntry {
  180. int64_t pos;
  181. int64_t timestamp;
  182. #define AVINDEX_KEYFRAME 0x0001
  183. int flags:2;
  184. int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
  185. int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
  186. } AVIndexEntry;
  187. typedef struct AVStream {
  188. int index; /* stream index in AVFormatContext */
  189. int id; /* format specific stream id */
  190. AVCodecContext *codec; /* codec context */
  191. /**
  192. * real base frame rate of the stream.
  193. * for example if the timebase is 1/90000 and all frames have either
  194. * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
  195. */
  196. AVRational r_frame_rate;
  197. void *priv_data;
  198. /* internal data used in av_find_stream_info() */
  199. int64_t codec_info_duration;
  200. int codec_info_nb_frames;
  201. /* encoding: PTS generation when outputing stream */
  202. AVFrac pts;
  203. /**
  204. * this is the fundamental unit of time (in seconds) in terms
  205. * of which frame timestamps are represented. for fixed-fps content,
  206. * timebase should be 1/framerate and timestamp increments should be
  207. * identically 1.
  208. */
  209. AVRational time_base;
  210. int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
  211. /* ffmpeg.c private use */
  212. int stream_copy; /* if TRUE, just copy stream */
  213. enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
  214. //FIXME move stuff to a flags field?
  215. /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
  216. * MN:dunno if thats the right place, for it */
  217. float quality;
  218. /* decoding: position of the first frame of the component, in
  219. AV_TIME_BASE fractional seconds. */
  220. int64_t start_time;
  221. /* decoding: duration of the stream, in AV_TIME_BASE fractional
  222. seconds. */
  223. int64_t duration;
  224. char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
  225. /* av_read_frame() support */
  226. int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
  227. struct AVCodecParserContext *parser;
  228. int64_t cur_dts;
  229. int last_IP_duration;
  230. int64_t last_IP_pts;
  231. /* av_seek_frame() support */
  232. AVIndexEntry *index_entries; /* only used if the format does not
  233. support seeking natively */
  234. int nb_index_entries;
  235. int index_entries_allocated_size;
  236. int64_t nb_frames; ///< number of frames in this stream if known or 0
  237. } AVStream;
  238. #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
  239. (streams are added dynamically) */
  240. #define MAX_STREAMS 20
  241. /* format I/O context */
  242. typedef struct AVFormatContext {
  243. const AVClass *av_class; /* set by av_alloc_format_context */
  244. /* can only be iformat or oformat, not both at the same time */
  245. struct AVInputFormat *iformat;
  246. struct AVOutputFormat *oformat;
  247. void *priv_data;
  248. ByteIOContext pb;
  249. int nb_streams;
  250. AVStream *streams[MAX_STREAMS];
  251. char filename[1024]; /* input or output filename */
  252. /* stream info */
  253. int64_t timestamp;
  254. char title[512];
  255. char author[512];
  256. char copyright[512];
  257. char comment[512];
  258. char album[512];
  259. int year; /* ID3 year, 0 if none */
  260. int track; /* track number, 0 if none */
  261. char genre[32]; /* ID3 genre */
  262. int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
  263. /* private data for pts handling (do not modify directly) */
  264. /* This buffer is only needed when packets were already buffered but
  265. not decoded, for example to get the codec parameters in mpeg
  266. streams */
  267. struct AVPacketList *packet_buffer;
  268. /* decoding: position of the first frame of the component, in
  269. AV_TIME_BASE fractional seconds. NEVER set this value directly:
  270. it is deduced from the AVStream values. */
  271. int64_t start_time;
  272. /* decoding: duration of the stream, in AV_TIME_BASE fractional
  273. seconds. NEVER set this value directly: it is deduced from the
  274. AVStream values. */
  275. int64_t duration;
  276. /* decoding: total file size. 0 if unknown */
  277. int64_t file_size;
  278. /* decoding: total stream bitrate in bit/s, 0 if not
  279. available. Never set it directly if the file_size and the
  280. duration are known as ffmpeg can compute it automatically. */
  281. int bit_rate;
  282. /* av_read_frame() support */
  283. AVStream *cur_st;
  284. const uint8_t *cur_ptr;
  285. int cur_len;
  286. AVPacket cur_pkt;
  287. /* av_seek_frame() support */
  288. int64_t data_offset; /* offset of the first packet */
  289. int index_built;
  290. int mux_rate;
  291. int packet_size;
  292. int preload;
  293. int max_delay;
  294. #define AVFMT_NOOUTPUTLOOP -1
  295. #define AVFMT_INFINITEOUTPUTLOOP 0
  296. /* number of times to loop output in formats that support it */
  297. int loop_output;
  298. int flags;
  299. #define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames
  300. } AVFormatContext;
  301. typedef struct AVPacketList {
  302. AVPacket pkt;
  303. struct AVPacketList *next;
  304. } AVPacketList;
  305. extern AVInputFormat *first_iformat;
  306. extern AVOutputFormat *first_oformat;
  307. /* still image support */
  308. struct AVInputImageContext;
  309. typedef struct AVInputImageContext AVInputImageContext;
  310. typedef struct AVImageInfo {
  311. enum PixelFormat pix_fmt; /* requested pixel format */
  312. int width; /* requested width */
  313. int height; /* requested height */
  314. int interleaved; /* image is interleaved (e.g. interleaved GIF) */
  315. AVPicture pict; /* returned allocated image */
  316. } AVImageInfo;
  317. /* AVImageFormat.flags field constants */
  318. #define AVIMAGE_INTERLEAVED 0x0001 /* image format support interleaved output */
  319. typedef struct AVImageFormat {
  320. const char *name;
  321. const char *extensions;
  322. /* tell if a given file has a chance of being parsing by this format */
  323. int (*img_probe)(AVProbeData *);
  324. /* read a whole image. 'alloc_cb' is called when the image size is
  325. known so that the caller can allocate the image. If 'allo_cb'
  326. returns non zero, then the parsing is aborted. Return '0' if
  327. OK. */
  328. int (*img_read)(ByteIOContext *,
  329. int (*alloc_cb)(void *, AVImageInfo *info), void *);
  330. /* write the image */
  331. int supported_pixel_formats; /* mask of supported formats for output */
  332. int (*img_write)(ByteIOContext *, AVImageInfo *);
  333. int flags;
  334. struct AVImageFormat *next;
  335. } AVImageFormat;
  336. void av_register_image_format(AVImageFormat *img_fmt);
  337. AVImageFormat *av_probe_image_format(AVProbeData *pd);
  338. AVImageFormat *guess_image_format(const char *filename);
  339. enum CodecID av_guess_image2_codec(const char *filename);
  340. int av_read_image(ByteIOContext *pb, const char *filename,
  341. AVImageFormat *fmt,
  342. int (*alloc_cb)(void *, AVImageInfo *info), void *opaque);
  343. int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img);
  344. extern AVImageFormat *first_image_format;
  345. extern AVImageFormat pnm_image_format;
  346. extern AVImageFormat pbm_image_format;
  347. extern AVImageFormat pgm_image_format;
  348. extern AVImageFormat ppm_image_format;
  349. extern AVImageFormat pam_image_format;
  350. extern AVImageFormat pgmyuv_image_format;
  351. extern AVImageFormat yuv_image_format;
  352. #ifdef CONFIG_ZLIB
  353. extern AVImageFormat png_image_format;
  354. #endif
  355. extern AVImageFormat jpeg_image_format;
  356. extern AVImageFormat gif_image_format;
  357. extern AVImageFormat sgi_image_format;
  358. /* XXX: use automatic init with either ELF sections or C file parser */
  359. /* modules */
  360. /* mpeg.c */
  361. extern AVInputFormat mpegps_demux;
  362. int mpegps_init(void);
  363. /* mpegts.c */
  364. extern AVInputFormat mpegts_demux;
  365. int mpegts_init(void);
  366. /* rm.c */
  367. int rm_init(void);
  368. /* crc.c */
  369. int crc_init(void);
  370. /* img.c */
  371. int img_init(void);
  372. /* img2.c */
  373. int img2_init(void);
  374. /* asf.c */
  375. int asf_init(void);
  376. /* avienc.c */
  377. int avienc_init(void);
  378. /* avidec.c */
  379. int avidec_init(void);
  380. /* swf.c */
  381. int swf_init(void);
  382. /* mov.c */
  383. int mov_init(void);
  384. /* movenc.c */
  385. int movenc_init(void);
  386. /* flvenc.c */
  387. int flvenc_init(void);
  388. /* flvdec.c */
  389. int flvdec_init(void);
  390. /* jpeg.c */
  391. int jpeg_init(void);
  392. /* gif.c */
  393. int gif_init(void);
  394. /* au.c */
  395. int au_init(void);
  396. /* amr.c */
  397. int amr_init(void);
  398. /* wav.c */
  399. int ff_wav_init(void);
  400. /* mmf.c */
  401. int ff_mmf_init(void);
  402. /* raw.c */
  403. int pcm_read_seek(AVFormatContext *s,
  404. int stream_index, int64_t timestamp, int flags);
  405. int raw_init(void);
  406. /* mp3.c */
  407. int mp3_init(void);
  408. /* yuv4mpeg.c */
  409. int yuv4mpeg_init(void);
  410. /* ogg2.c */
  411. int ogg_init(void);
  412. /* ogg.c */
  413. int libogg_init(void);
  414. /* dv.c */
  415. int ff_dv_init(void);
  416. /* ffm.c */
  417. int ffm_init(void);
  418. /* rtsp.c */
  419. extern AVInputFormat redir_demux;
  420. int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
  421. /* 4xm.c */
  422. int fourxm_init(void);
  423. /* psxstr.c */
  424. int str_init(void);
  425. /* idroq.c */
  426. int roq_init(void);
  427. /* ipmovie.c */
  428. int ipmovie_init(void);
  429. /* nut.c */
  430. int nut_init(void);
  431. /* wc3movie.c */
  432. int wc3_init(void);
  433. /* westwood.c */
  434. int westwood_init(void);
  435. /* segafilm.c */
  436. int film_init(void);
  437. /* idcin.c */
  438. int idcin_init(void);
  439. /* flic.c */
  440. int flic_init(void);
  441. /* sierravmd.c */
  442. int vmd_init(void);
  443. /* matroska.c */
  444. int matroska_init(void);
  445. /* sol.c */
  446. int sol_init(void);
  447. /* electronicarts.c */
  448. int ea_init(void);
  449. /* nsvdec.c */
  450. int nsvdec_init(void);
  451. /* daud.c */
  452. int daud_init(void);
  453. /* nuv.c */
  454. int nuv_init(void);
  455. /* aiff.c */
  456. int ff_aiff_init(void);
  457. /* voc.c */
  458. int voc_init(void);
  459. /* tta.c */
  460. int tta_init(void);
  461. /* adts.c */
  462. int ff_adts_init(void);
  463. /* mm.c */
  464. int mm_init(void);
  465. /* avs.c */
  466. int avs_init(void);
  467. /* smacker.c */
  468. int smacker_init(void);
  469. #include "rtp.h"
  470. #include "rtsp.h"
  471. /* yuv4mpeg.c */
  472. extern AVOutputFormat yuv4mpegpipe_oformat;
  473. /* utils.c */
  474. void av_register_input_format(AVInputFormat *format);
  475. void av_register_output_format(AVOutputFormat *format);
  476. AVOutputFormat *guess_stream_format(const char *short_name,
  477. const char *filename, const char *mime_type);
  478. AVOutputFormat *guess_format(const char *short_name,
  479. const char *filename, const char *mime_type);
  480. enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
  481. const char *filename, const char *mime_type, enum CodecType type);
  482. void av_hex_dump(FILE *f, uint8_t *buf, int size);
  483. void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  484. void av_register_all(void);
  485. typedef struct FifoBuffer {
  486. uint8_t *buffer;
  487. uint8_t *rptr, *wptr, *end;
  488. } FifoBuffer;
  489. int fifo_init(FifoBuffer *f, int size);
  490. void fifo_free(FifoBuffer *f);
  491. int fifo_size(FifoBuffer *f, uint8_t *rptr);
  492. int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
  493. void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
  494. int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr);
  495. void fifo_realloc(FifoBuffer *f, unsigned int size);
  496. /* media file input */
  497. AVInputFormat *av_find_input_format(const char *short_name);
  498. AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
  499. int av_open_input_stream(AVFormatContext **ic_ptr,
  500. ByteIOContext *pb, const char *filename,
  501. AVInputFormat *fmt, AVFormatParameters *ap);
  502. int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  503. AVInputFormat *fmt,
  504. int buf_size,
  505. AVFormatParameters *ap);
  506. /* no av_open for output, so applications will need this: */
  507. AVFormatContext *av_alloc_format_context(void);
  508. #define AVERROR_UNKNOWN (-1) /* unknown error */
  509. #define AVERROR_IO (-2) /* i/o error */
  510. #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
  511. #define AVERROR_INVALIDDATA (-4) /* invalid data found */
  512. #define AVERROR_NOMEM (-5) /* not enough memory */
  513. #define AVERROR_NOFMT (-6) /* unknown format */
  514. #define AVERROR_NOTSUPP (-7) /* operation not supported */
  515. int av_find_stream_info(AVFormatContext *ic);
  516. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  517. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  518. int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
  519. int av_read_play(AVFormatContext *s);
  520. int av_read_pause(AVFormatContext *s);
  521. void av_close_input_file(AVFormatContext *s);
  522. AVStream *av_new_stream(AVFormatContext *s, int id);
  523. void av_set_pts_info(AVStream *s, int pts_wrap_bits,
  524. int pts_num, int pts_den);
  525. #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
  526. #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
  527. #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes
  528. int av_find_default_stream_index(AVFormatContext *s);
  529. int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
  530. int av_add_index_entry(AVStream *st,
  531. int64_t pos, int64_t timestamp, int size, int distance, int flags);
  532. int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
  533. /* media file output */
  534. int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
  535. int av_write_header(AVFormatContext *s);
  536. int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  537. int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
  538. int av_write_trailer(AVFormatContext *s);
  539. void dump_format(AVFormatContext *ic,
  540. int index,
  541. const char *url,
  542. int is_output);
  543. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  544. int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
  545. int64_t parse_date(const char *datestr, int duration);
  546. int64_t av_gettime(void);
  547. /* ffm specific for ffserver */
  548. #define FFM_PACKET_SIZE 4096
  549. offset_t ffm_read_write_index(int fd);
  550. void ffm_write_write_index(int fd, offset_t pos);
  551. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  552. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  553. int get_frame_filename(char *buf, int buf_size,
  554. const char *path, int number);
  555. int filename_number_test(const char *filename);
  556. /* grab specific */
  557. int video_grab_init(void);
  558. int audio_init(void);
  559. /* DV1394 */
  560. int dv1394_init(void);
  561. int dc1394_init(void);
  562. #ifdef HAVE_AV_CONFIG_H
  563. #include "os_support.h"
  564. int strstart(const char *str, const char *val, const char **ptr);
  565. int stristart(const char *str, const char *val, const char **ptr);
  566. void pstrcpy(char *buf, int buf_size, const char *str);
  567. char *pstrcat(char *buf, int buf_size, const char *s);
  568. void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
  569. #ifdef __GNUC__
  570. #define dynarray_add(tab, nb_ptr, elem)\
  571. do {\
  572. typeof(tab) _tab = (tab);\
  573. typeof(elem) _elem = (elem);\
  574. (void)sizeof(**_tab == _elem); /* check that types are compatible */\
  575. __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
  576. } while(0)
  577. #else
  578. #define dynarray_add(tab, nb_ptr, elem)\
  579. do {\
  580. __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
  581. } while(0)
  582. #endif
  583. time_t mktimegm(struct tm *tm);
  584. struct tm *brktimegm(time_t secs, struct tm *tm);
  585. const char *small_strptime(const char *p, const char *fmt,
  586. struct tm *dt);
  587. struct in_addr;
  588. int resolve_host(struct in_addr *sin_addr, const char *hostname);
  589. void url_split(char *proto, int proto_size,
  590. char *authorization, int authorization_size,
  591. char *hostname, int hostname_size,
  592. int *port_ptr,
  593. char *path, int path_size,
  594. const char *url);
  595. int match_ext(const char *filename, const char *extensions);
  596. #endif /* HAVE_AV_CONFIG_H */
  597. #ifdef __cplusplus
  598. }
  599. #endif
  600. #endif /* AVFORMAT_H */