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.

206 lines
6.1KB

  1. #include "common.h"
  2. enum CodecID {
  3. CODEC_ID_NONE,
  4. CODEC_ID_MPEG1VIDEO,
  5. CODEC_ID_H263,
  6. CODEC_ID_RV10,
  7. CODEC_ID_MP2,
  8. CODEC_ID_AC3,
  9. CODEC_ID_MJPEG,
  10. CODEC_ID_MPEG4,
  11. CODEC_ID_PCM,
  12. CODEC_ID_RAWVIDEO,
  13. CODEC_ID_MSMPEG4,
  14. CODEC_ID_H263P,
  15. CODEC_ID_H263I,
  16. };
  17. enum CodecType {
  18. CODEC_TYPE_VIDEO,
  19. CODEC_TYPE_AUDIO,
  20. };
  21. enum PixelFormat {
  22. PIX_FMT_YUV420P,
  23. PIX_FMT_YUV422,
  24. PIX_FMT_RGB24,
  25. PIX_FMT_BGR24,
  26. PIX_FMT_YUV422P,
  27. PIX_FMT_YUV444P,
  28. };
  29. /* in bytes */
  30. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
  31. /* motion estimation type */
  32. extern int motion_estimation_method;
  33. #define ME_ZERO 0
  34. #define ME_FULL 1
  35. #define ME_LOG 2
  36. #define ME_PHODS 3
  37. /* encoding support */
  38. #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
  39. #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
  40. /* codec capabilities */
  41. /* decoder can use draw_horiz_band callback */
  42. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
  43. #define FRAME_RATE_BASE 10000
  44. typedef struct AVCodecContext {
  45. int bit_rate;
  46. int flags;
  47. int sub_id; /* some codecs needs additionnal format info. It is
  48. stored there */
  49. /* video only */
  50. int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
  51. int width, height;
  52. int gop_size; /* 0 = intra only */
  53. int pix_fmt; /* pixel format, see PIX_FMT_xxx */
  54. /* if non NULL, 'draw_horiz_band' is called by the libavcodec
  55. decoder to draw an horizontal band. It improve cache usage. Not
  56. all codecs can do that. You must check the codec capabilities
  57. before */
  58. void (*draw_horiz_band)(struct AVCodecContext *s,
  59. UINT8 **src_ptr, int linesize,
  60. int y, int width, int height);
  61. /* audio only */
  62. int sample_rate; /* samples per sec */
  63. int channels;
  64. /* the following data should not be initialized */
  65. int frame_size; /* in samples, initialized when calling 'init' */
  66. int frame_number; /* audio or video frame number */
  67. int key_frame; /* true if the previous compressed frame was
  68. a key frame (intra, or seekable) */
  69. int quality; /* quality of the previous encoded frame
  70. (between 1 (good) and 31 (bad)) */
  71. struct AVCodec *codec;
  72. void *priv_data;
  73. /* the following fields are ignored */
  74. void *opaque; /* can be used to carry app specific stuff */
  75. char codec_name[32];
  76. int codec_type; /* see CODEC_TYPE_xxx */
  77. int codec_id; /* see CODEC_ID_xxx */
  78. unsigned int codec_tag; /* codec tag, only used if unknown codec */
  79. } AVCodecContext;
  80. typedef struct AVCodec {
  81. char *name;
  82. int type;
  83. int id;
  84. int priv_data_size;
  85. int (*init)(AVCodecContext *);
  86. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  87. int (*close)(AVCodecContext *);
  88. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  89. UINT8 *buf, int buf_size);
  90. int capabilities;
  91. struct AVCodec *next;
  92. } AVCodec;
  93. /* three components are given, that's all */
  94. typedef struct AVPicture {
  95. UINT8 *data[3];
  96. int linesize[3];
  97. } AVPicture;
  98. extern AVCodec ac3_encoder;
  99. extern AVCodec mp2_encoder;
  100. extern AVCodec mpeg1video_encoder;
  101. extern AVCodec h263_encoder;
  102. extern AVCodec h263p_encoder;
  103. extern AVCodec rv10_encoder;
  104. extern AVCodec mjpeg_encoder;
  105. extern AVCodec mpeg4_encoder;
  106. extern AVCodec msmpeg4_encoder;
  107. extern AVCodec h263_decoder;
  108. extern AVCodec mpeg4_decoder;
  109. extern AVCodec msmpeg4_decoder;
  110. extern AVCodec mpeg_decoder;
  111. extern AVCodec h263i_decoder;
  112. extern AVCodec rv10_decoder;
  113. extern AVCodec mjpeg_decoder;
  114. /* dummy raw codecs */
  115. extern AVCodec pcm_codec;
  116. extern AVCodec rawvideo_codec;
  117. /* the following codecs use external GPL libs */
  118. extern AVCodec mp3_decoder;
  119. extern AVCodec ac3_decoder;
  120. /* resample.c */
  121. struct ReSampleContext;
  122. typedef struct ReSampleContext ReSampleContext;
  123. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  124. int output_rate, int input_rate);
  125. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  126. void audio_resample_close(ReSampleContext *s);
  127. /* YUV420 format is assumed ! */
  128. struct ImgReSampleContext;
  129. typedef struct ImgReSampleContext ImgReSampleContext;
  130. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  131. int input_width, int input_height);
  132. void img_resample(ImgReSampleContext *s,
  133. AVPicture *output, AVPicture *input);
  134. void img_resample_close(ImgReSampleContext *s);
  135. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  136. int pix_fmt, int width, int height);
  137. int avpicture_get_size(int pix_fmt, int width, int height);
  138. /* convert among pixel formats */
  139. int img_convert(AVPicture *dst, int dst_pix_fmt,
  140. AVPicture *src, int pix_fmt,
  141. int width, int height);
  142. /* deinterlace a picture */
  143. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  144. int pix_fmt, int width, int height);
  145. /* external high level API */
  146. extern AVCodec *first_avcodec;
  147. void avcodec_init(void);
  148. void register_avcodec(AVCodec *format);
  149. AVCodec *avcodec_find_encoder(enum CodecID id);
  150. AVCodec *avcodec_find_decoder(enum CodecID id);
  151. AVCodec *avcodec_find_decoder_by_name(const char *name);
  152. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  153. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  154. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  155. int *frame_size_ptr,
  156. UINT8 *buf, int buf_size);
  157. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  158. int *got_picture_ptr,
  159. UINT8 *buf, int buf_size);
  160. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  161. const short *samples);
  162. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  163. const AVPicture *pict);
  164. int avcodec_close(AVCodecContext *avctx);
  165. void avcodec_register_all(void);