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.

232 lines
6.4KB

  1. #define LIBAV_VERSION_INT 0x000406
  2. #define LIBAV_VERSION "0.4.6"
  3. #define LIBAV_BUILD 4600
  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. /* output formats */
  21. struct AVFormatContext;
  22. struct AVFormatInputContext;
  23. typedef struct AVFormatParameters {
  24. int frame_rate;
  25. int sample_rate;
  26. int channels;
  27. int width;
  28. int height;
  29. enum PixelFormat pix_fmt;
  30. } AVFormatParameters;
  31. typedef struct AVFormat {
  32. const char *name;
  33. const char *long_name;
  34. const char *mime_type;
  35. const char *extensions; /* comma separated extensions */
  36. /* output support */
  37. enum CodecID audio_codec; /* default audio codec */
  38. enum CodecID video_codec; /* default video codec */
  39. int (*write_header)(struct AVFormatContext *);
  40. int (*write_packet)(struct AVFormatContext *,
  41. int stream_index,
  42. unsigned char *buf, int size, int force_pts);
  43. int (*write_trailer)(struct AVFormatContext *);
  44. /* optional input support */
  45. /* read the format header and initialize the AVFormatInputContext
  46. structure. Return 0 if OK. 'ap' if non NULL contains
  47. additionnal paramters. Only used in raw format right now */
  48. int (*read_header)(struct AVFormatContext *,
  49. AVFormatParameters *ap);
  50. /* read one packet and put it in 'pkt'. pts and flags are also set */
  51. int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
  52. /* close the stream. The AVFormatContext and AVStreams are not
  53. freed by this function */
  54. int (*read_close)(struct AVFormatContext *);
  55. /* seek at or before a given pts (given in microsecond). The pts
  56. origin is defined by the stream */
  57. int (*read_seek)(struct AVFormatContext *, INT64 pts);
  58. int flags;
  59. #define AVFMT_NOFILE 0x0001 /* no file should be opened */
  60. #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
  61. struct AVFormat *next;
  62. } AVFormat;
  63. typedef struct AVStream {
  64. int id; /* internal stream id */
  65. AVCodecContext codec; /* codec context */
  66. void *priv_data;
  67. } AVStream;
  68. #define MAX_STREAMS 20
  69. /* format I/O context */
  70. typedef struct AVFormatContext {
  71. struct AVFormat *format;
  72. void *priv_data;
  73. ByteIOContext pb;
  74. int nb_streams;
  75. AVStream *streams[MAX_STREAMS];
  76. char filename[1024]; /* input or output filename */
  77. /* stream info */
  78. char title[512];
  79. char author[512];
  80. char copyright[512];
  81. char comment[512];
  82. /* This buffer is only needed when packets were already buffered but
  83. not decoded, for example to get the codec parameters in mpeg
  84. streams */
  85. struct AVPacketList *packet_buffer;
  86. } AVFormatContext;
  87. typedef struct AVPacketList {
  88. AVPacket pkt;
  89. struct AVPacketList *next;
  90. } AVPacketList;
  91. extern AVFormat *first_format;
  92. /* rv10enc.c */
  93. extern AVFormat rm_format;
  94. /* mpegmux.c */
  95. extern AVFormat mpeg_mux_format;
  96. /* asfenc.c */
  97. extern AVFormat asf_format;
  98. /* avienc.c */
  99. extern AVFormat avi_format;
  100. /* mov.c */
  101. extern AVFormat mov_format;
  102. extern AVFormat mp4_format;
  103. /* jpegenc.c */
  104. extern AVFormat mpjpeg_format;
  105. extern AVFormat jpeg_format;
  106. extern AVFormat single_jpeg_format;
  107. /* swfenc.c */
  108. extern AVFormat swf_format;
  109. /* gif.c */
  110. extern AVFormat gif_format;
  111. /* au.c */
  112. extern AVFormat au_format;
  113. /* wav.c */
  114. extern AVFormat wav_format;
  115. /* img.c */
  116. extern AVFormat pgm_format;
  117. extern AVFormat ppm_format;
  118. extern AVFormat pgmyuv_format;
  119. extern AVFormat imgyuv_format;
  120. extern AVFormat pgmpipe_format;
  121. extern AVFormat pgmyuvpipe_format;
  122. extern AVFormat ppmpipe_format;
  123. /* raw.c */
  124. extern AVFormat mp2_format;
  125. extern AVFormat ac3_format;
  126. extern AVFormat h263_format;
  127. extern AVFormat mpeg1video_format;
  128. extern AVFormat mjpeg_format;
  129. extern AVFormat pcm_s16le_format;
  130. extern AVFormat pcm_s16be_format;
  131. extern AVFormat pcm_u16le_format;
  132. extern AVFormat pcm_u16be_format;
  133. extern AVFormat pcm_s8_format;
  134. extern AVFormat pcm_u8_format;
  135. extern AVFormat pcm_mulaw_format;
  136. extern AVFormat pcm_alaw_format;
  137. extern AVFormat rawvideo_format;
  138. /* ffm.c */
  139. extern AVFormat ffm_format;
  140. /* formats.c */
  141. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  142. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  143. void register_avformat(AVFormat *format);
  144. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  145. int strstart(const char *str, const char *val, const char **ptr);
  146. void nstrcpy(char *buf, int buf_size, const char *str);
  147. int match_ext(const char *filename, const char *extensions);
  148. void register_all(void);
  149. INT64 gettime(void);
  150. typedef struct FifoBuffer {
  151. UINT8 *buffer;
  152. UINT8 *rptr, *wptr, *end;
  153. } FifoBuffer;
  154. int fifo_init(FifoBuffer *f, int size);
  155. void fifo_free(FifoBuffer *f);
  156. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  157. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  158. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  159. AVFormatContext *av_open_input_file(const char *filename,
  160. const char *format_name,
  161. int buf_size,
  162. AVFormatParameters *ap);
  163. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  164. void av_close_input_file(AVFormatContext *s);
  165. int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
  166. void dump_format(AVFormatContext *ic,
  167. int index,
  168. const char *url,
  169. int is_output);
  170. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  171. INT64 gettime(void);
  172. INT64 parse_date(const char *datestr, int duration);
  173. /* ffm specific for ffserver */
  174. #define FFM_PACKET_SIZE 4096
  175. offset_t ffm_read_write_index(int fd);
  176. void ffm_write_write_index(int fd, offset_t pos);
  177. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  178. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  179. int get_frame_filename(char *buf, int buf_size,
  180. const char *path, int number);
  181. /* grab/output specific */
  182. extern AVFormat video_grab_device_format;
  183. extern AVFormat audio_device_format;
  184. extern const char *v4l_device;
  185. extern const char *audio_device;