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.

237 lines
6.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. /* 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. int r_frame_rate; /* real frame rate of the stream */
  67. void *priv_data;
  68. } AVStream;
  69. #define MAX_STREAMS 20
  70. /* format I/O context */
  71. typedef struct AVFormatContext {
  72. struct AVFormat *format;
  73. void *priv_data;
  74. ByteIOContext pb;
  75. int nb_streams;
  76. AVStream *streams[MAX_STREAMS];
  77. char filename[1024]; /* input or output filename */
  78. /* stream info */
  79. char title[512];
  80. char author[512];
  81. char copyright[512];
  82. char comment[512];
  83. int flags; /* format specific flags */
  84. /* This buffer is only needed when packets were already buffered but
  85. not decoded, for example to get the codec parameters in mpeg
  86. streams */
  87. struct AVPacketList *packet_buffer;
  88. } AVFormatContext;
  89. typedef struct AVPacketList {
  90. AVPacket pkt;
  91. struct AVPacketList *next;
  92. } AVPacketList;
  93. extern AVFormat *first_format;
  94. /* rv10enc.c */
  95. extern AVFormat rm_format;
  96. /* mpegmux.c */
  97. #define AVF_FLAG_VCD 0x00000001 /* VCD compatible MPEG-PS */
  98. extern AVFormat mpeg_mux_format;
  99. /* asfenc.c */
  100. extern AVFormat asf_format;
  101. /* avienc.c */
  102. extern AVFormat avi_format;
  103. /* mov.c */
  104. extern AVFormat mov_format;
  105. extern AVFormat mp4_format;
  106. /* jpegenc.c */
  107. extern AVFormat mpjpeg_format;
  108. extern AVFormat jpeg_format;
  109. extern AVFormat single_jpeg_format;
  110. /* swfenc.c */
  111. extern AVFormat swf_format;
  112. /* gif.c */
  113. extern AVFormat gif_format;
  114. /* au.c */
  115. extern AVFormat au_format;
  116. /* wav.c */
  117. extern AVFormat wav_format;
  118. /* img.c */
  119. extern AVFormat pgm_format;
  120. extern AVFormat ppm_format;
  121. extern AVFormat pgmyuv_format;
  122. extern AVFormat imgyuv_format;
  123. extern AVFormat pgmpipe_format;
  124. extern AVFormat pgmyuvpipe_format;
  125. extern AVFormat ppmpipe_format;
  126. /* raw.c */
  127. extern AVFormat mp2_format;
  128. extern AVFormat ac3_format;
  129. extern AVFormat h263_format;
  130. extern AVFormat mpeg1video_format;
  131. extern AVFormat mjpeg_format;
  132. extern AVFormat pcm_s16le_format;
  133. extern AVFormat pcm_s16be_format;
  134. extern AVFormat pcm_u16le_format;
  135. extern AVFormat pcm_u16be_format;
  136. extern AVFormat pcm_s8_format;
  137. extern AVFormat pcm_u8_format;
  138. extern AVFormat pcm_mulaw_format;
  139. extern AVFormat pcm_alaw_format;
  140. extern AVFormat rawvideo_format;
  141. /* ffm.c */
  142. extern AVFormat ffm_format;
  143. /* formats.c */
  144. #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
  145. #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
  146. void register_avformat(AVFormat *format);
  147. AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
  148. int strstart(const char *str, const char *val, const char **ptr);
  149. void nstrcpy(char *buf, int buf_size, const char *str);
  150. /* This does what strncpy ought to do. */
  151. void strlcpy(char *dst, const char *src, int dst_size);
  152. int match_ext(const char *filename, const char *extensions);
  153. void register_all(void);
  154. INT64 gettime(void);
  155. typedef struct FifoBuffer {
  156. UINT8 *buffer;
  157. UINT8 *rptr, *wptr, *end;
  158. } FifoBuffer;
  159. int fifo_init(FifoBuffer *f, int size);
  160. void fifo_free(FifoBuffer *f);
  161. int fifo_size(FifoBuffer *f, UINT8 *rptr);
  162. int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
  163. void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
  164. AVFormatContext *av_open_input_file(const char *filename,
  165. const char *format_name,
  166. int buf_size,
  167. AVFormatParameters *ap);
  168. int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  169. void av_close_input_file(AVFormatContext *s);
  170. int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
  171. void dump_format(AVFormatContext *ic,
  172. int index,
  173. const char *url,
  174. int is_output);
  175. int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
  176. INT64 gettime(void);
  177. INT64 parse_date(const char *datestr, int duration);
  178. /* ffm specific for ffserver */
  179. #define FFM_PACKET_SIZE 4096
  180. offset_t ffm_read_write_index(int fd);
  181. void ffm_write_write_index(int fd, offset_t pos);
  182. void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
  183. int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
  184. int get_frame_filename(char *buf, int buf_size,
  185. const char *path, int number);
  186. /* grab/output specific */
  187. extern AVFormat video_grab_device_format;
  188. extern AVFormat audio_device_format;
  189. extern const char *v4l_device;
  190. extern const char *audio_device;