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.

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