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.

290 lines
8.7KB

  1. #define LIBAV_VERSION_INT 0x000406
  2. #define LIBAV_VERSION "0.4.6"
  3. #define LIBAV_BUILD 4601
  4. #include "avcodec.h"
  5. #include "avio.h"
  6. /* packet functions */
  7. typedef struct AVPacket {
  8. INT64 pts;
  9. UINT8 *data;
  10. int size;
  11. int stream_index;
  12. int flags;
  13. int duration;
  14. #define PKT_FLAG_KEY 0x0001
  15. #define PKT_FLAG_DROPPED_FRAME 0x0002
  16. } AVPacket;
  17. int av_new_packet(AVPacket *pkt, int size);
  18. void av_free_packet(AVPacket *pkt);
  19. /*************************************************/
  20. /* input/output formats */
  21. struct AVFormatContext;
  22. /* this structure contains the data a format has to probe a file */
  23. typedef struct AVProbeData {
  24. char *filename;
  25. unsigned char *buf;
  26. int buf_size;
  27. } AVProbeData;
  28. #define AVPROBE_SCORE_MAX 100
  29. typedef struct AVFormatParameters {
  30. int frame_rate;
  31. int sample_rate;
  32. int channels;
  33. int width;
  34. int height;
  35. enum PixelFormat pix_fmt;
  36. } AVFormatParameters;
  37. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  38. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  39. #define AVFMT_NOHEADER 0x0004 /* signal that no header is present
  40. (streams are added dynamically) */
  41. #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
  42. #define AVFMT_RGB24 0x0010 /* force RGB24 output for ppm (hack
  43. - need better api) */
  44. typedef struct AVOutputFormat {
  45. const char *name;
  46. const char *long_name;
  47. const char *mime_type;
  48. const char *extensions; /* comma separated extensions */
  49. /* size of private data so that it can be allocated in the wrapper */
  50. int priv_data_size;
  51. /* output support */
  52. enum CodecID audio_codec; /* default audio codec */
  53. enum CodecID video_codec; /* default video codec */
  54. int (*write_header)(struct AVFormatContext *);
  55. int (*write_packet)(struct AVFormatContext *,
  56. int stream_index,
  57. unsigned char *buf, int size, int force_pts);
  58. int (*write_trailer)(struct AVFormatContext *);
  59. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
  60. int flags;
  61. /* private fields */
  62. struct AVOutputFormat *next;
  63. } AVOutputFormat;
  64. typedef struct AVInputFormat {
  65. const char *name;
  66. const char *long_name;
  67. /* size of private data so that it can be allocated in the wrapper */
  68. int priv_data_size;
  69. /* tell if a given file has a chance of being parsing by this format */
  70. int (*read_probe)(AVProbeData *);
  71. /* read the format header and initialize the AVFormatContext
  72. structure. Return 0 if OK. 'ap' if non NULL contains
  73. additionnal paramters. Only used in raw format right
  74. now. 'av_new_stream' should be called to create new streams. */
  75. int (*read_header)(struct AVFormatContext *,
  76. AVFormatParameters *ap);
  77. /* read one packet and put it in 'pkt'. pts and flags are also
  78. set. 'av_new_stream' can be called only if the flag
  79. AVFMT_NOHEADER is used. */
  80. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  81. /* close the stream. The AVFormatContext and AVStreams are not
  82. freed by this function */
  83. int (*read_close)(struct AVFormatContext *);
  84. /* seek at or before a given pts (given in microsecond). The pts
  85. origin is defined by the stream */
  86. int (*read_seek)(struct AVFormatContext *, INT64 pts);
  87. /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
  88. int flags;
  89. /* if extensions are defined, then no probe is done. You should
  90. usually not use extension format guessing because it is not
  91. reliable enough */
  92. const char *extensions;
  93. /* general purpose read only value that the format can use */
  94. int value;
  95. /* private fields */
  96. struct AVInputFormat *next;
  97. } AVInputFormat;
  98. typedef struct AVStream {
  99. int index; /* stream index in AVFormatContext */
  100. int id; /* format specific stream id */
  101. AVCodecContext codec; /* codec context */
  102. int r_frame_rate; /* real frame rate of the stream */
  103. void *priv_data;
  104. /* internal data used in av_find_stream_info() */
  105. int codec_info_state;
  106. int codec_info_nb_repeat_frames;
  107. int codec_info_nb_real_frames;
  108. } AVStream;
  109. #define MAX_STREAMS 20
  110. /* format I/O context */
  111. typedef struct AVFormatContext {
  112. /* can only be iformat or oformat, not both at the same time */
  113. struct AVInputFormat *iformat;
  114. struct AVOutputFormat *oformat;
  115. void *priv_data;
  116. ByteIOContext pb;
  117. int nb_streams;
  118. AVStream *streams[MAX_STREAMS];
  119. char filename[1024]; /* input or output filename */
  120. /* stream info */
  121. char title[512];
  122. char author[512];
  123. char copyright[512];
  124. char comment[512];
  125. int flags; /* format specific flags */
  126. /* This buffer is only needed when packets were already buffered but
  127. not decoded, for example to get the codec parameters in mpeg
  128. streams */
  129. struct AVPacketList *packet_buffer;
  130. } AVFormatContext;
  131. typedef struct AVPacketList {
  132. AVPacket pkt;
  133. struct AVPacketList *next;
  134. } AVPacketList;
  135. extern AVInputFormat *first_iformat;
  136. extern AVOutputFormat *first_oformat;
  137. /* XXX: use automatic init with either ELF sections or C file parser */
  138. /* modules */
  139. /* mpeg.c */
  140. #define AVF_FLAG_VCD 0x00000001 /* VCD compatible MPEG-PS */
  141. int mpegps_init(void);
  142. /* mpegts.c */
  143. extern AVInputFormat mpegts_demux;
  144. int mpegts_init(void);
  145. /* rm.c */
  146. int rm_init(void);
  147. /* crc.c */
  148. int crc_init(void);
  149. /* img.c */
  150. int img_init(void);
  151. /* asf.c */
  152. int asf_init(void);
  153. /* avienc.c */
  154. int avienc_init(void);
  155. /* avidec.c */
  156. int avidec_init(void);
  157. /* swf.c */
  158. int swf_init(void);
  159. /* mov.c */
  160. int mov_init(void);
  161. /* jpeg.c */
  162. int jpeg_init(void);
  163. /* gif.c */
  164. int gif_init(void);
  165. /* au.c */
  166. int au_init(void);
  167. /* wav.c */
  168. int wav_init(void);
  169. /* raw.c */
  170. int raw_init(void);
  171. /* ffm.c */
  172. int ffm_init(void);
  173. /* utils.c */
  174. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  175. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  176. void av_register_input_format(AVInputFormat *format);
  177. void av_register_output_format(AVOutputFormat *format);
  178. AVOutputFormat *guess_format(const char *short_name,
  179. const char *filename, const char *mime_type);
  180. int strstart(const char *str, const char *val, const char **ptr);
  181. void pstrcpy(char *buf, int buf_size, const char *str);
  182. int match_ext(const char *filename, const char *extensions);
  183. void av_hex_dump(UINT8 *buf, int size);
  184. void register_all(void);
  185. INT64 gettime(void);
  186. typedef struct FifoBuffer {
  187. UINT8 *buffer;
  188. UINT8 *rptr, *wptr, *end;
  189. } FifoBuffer;
  190. int fifo_init(FifoBuffer *f, int size);
  191. void fifo_free(FifoBuffer *f);
  192. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  193. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  194. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  195. /* media file input */
  196. AVInputFormat *av_find_input_format(const char *short_name);
  197. int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
  198. AVInputFormat *fmt,
  199. int buf_size,
  200. AVFormatParameters *ap);
  201. #define AVERROR_UNKNOWN (-1) /* unknown error */
  202. #define AVERROR_IO (-2) /* i/o error */
  203. #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
  204. #define AVERROR_INVALIDDATA (-4) /* invalid data found */
  205. #define AVERROR_NOMEM (-5) /* not enough memory */
  206. #define AVERROR_NOFMT (-6) /* unknown format */
  207. int av_find_stream_info(AVFormatContext *ic);
  208. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  209. void av_close_input_file(AVFormatContext *s);
  210. AVStream *av_new_stream(AVFormatContext *s, int id);
  211. /* media file output */
  212. int av_write_header(AVFormatContext *s);
  213. int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
  214. int av_write_trailer(AVFormatContext *s);
  215. void dump_format(AVFormatContext *ic,
  216. int index,
  217. const char *url,
  218. int is_output);
  219. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  220. INT64 gettime(void);
  221. INT64 parse_date(const char *datestr, int duration);
  222. /* ffm specific for ffserver */
  223. #define FFM_PACKET_SIZE 4096
  224. offset_t ffm_read_write_index(int fd);
  225. void ffm_write_write_index(int fd, offset_t pos);
  226. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  227. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  228. int get_frame_filename(char *buf, int buf_size,
  229. const char *path, int number);
  230. int filename_number_test(const char *filename);
  231. /* grab specific */
  232. int video_grab_init(void);
  233. int audio_init(void);
  234. extern const char *v4l_device;
  235. extern const char *audio_device;