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.

190 lines
5.5KB

  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_OPENDIVX,
  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. #define FRAME_RATE_BASE 10000
  41. typedef struct AVCodecContext {
  42. int bit_rate;
  43. int flags;
  44. int sub_id; /* some codecs needs additionnal format info. It is
  45. stored there */
  46. /* video only */
  47. int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
  48. int width, height;
  49. int gop_size; /* 0 = intra only */
  50. int pix_fmt; /* pixel format, see PIX_FMT_xxx */
  51. /* audio only */
  52. int sample_rate; /* samples per sec */
  53. int channels;
  54. /* the following data should not be initialized */
  55. int frame_size; /* in samples, initialized when calling 'init' */
  56. int frame_number; /* audio or video frame number */
  57. int key_frame; /* true if the previous compressed frame was
  58. a key frame (intra, or seekable) */
  59. int quality; /* quality of the previous encoded frame
  60. (between 1 (good) and 31 (bad)) */
  61. struct AVCodec *codec;
  62. void *priv_data;
  63. /* the following fields are ignored */
  64. char codec_name[32];
  65. int codec_type; /* see CODEC_TYPE_xxx */
  66. int codec_id; /* see CODEC_ID_xxx */
  67. unsigned int codec_tag; /* codec tag, only used if unknown codec */
  68. } AVCodecContext;
  69. typedef struct AVCodec {
  70. char *name;
  71. int type;
  72. int id;
  73. int priv_data_size;
  74. int (*init)(AVCodecContext *);
  75. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  76. int (*close)(AVCodecContext *);
  77. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  78. UINT8 *buf, int buf_size);
  79. struct AVCodec *next;
  80. } AVCodec;
  81. /* three components are given, that's all */
  82. typedef struct AVPicture {
  83. UINT8 *data[3];
  84. int linesize[3];
  85. } AVPicture;
  86. extern AVCodec ac3_encoder;
  87. extern AVCodec mp2_encoder;
  88. extern AVCodec mpeg1video_encoder;
  89. extern AVCodec h263_encoder;
  90. extern AVCodec h263p_encoder;
  91. extern AVCodec rv10_encoder;
  92. extern AVCodec mjpeg_encoder;
  93. extern AVCodec opendivx_encoder;
  94. extern AVCodec msmpeg4_encoder;
  95. extern AVCodec h263_decoder;
  96. extern AVCodec opendivx_decoder;
  97. extern AVCodec msmpeg4_decoder;
  98. extern AVCodec mpeg_decoder;
  99. extern AVCodec h263i_decoder;
  100. extern AVCodec rv10_decoder;
  101. extern AVCodec mjpeg_decoder;
  102. /* dummy raw codecs */
  103. extern AVCodec pcm_codec;
  104. extern AVCodec rawvideo_codec;
  105. /* the following codecs use external GPL libs */
  106. extern AVCodec mp3_decoder;
  107. extern AVCodec ac3_decoder;
  108. /* resample.c */
  109. struct ReSampleContext;
  110. typedef struct ReSampleContext ReSampleContext;
  111. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  112. int output_rate, int input_rate);
  113. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  114. void audio_resample_close(ReSampleContext *s);
  115. /* YUV420 format is assumed ! */
  116. struct ImgReSampleContext;
  117. typedef struct ImgReSampleContext ImgReSampleContext;
  118. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  119. int input_width, int input_height);
  120. void img_resample(ImgReSampleContext *s,
  121. AVPicture *output, AVPicture *input);
  122. void img_resample_close(ImgReSampleContext *s);
  123. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  124. int pix_fmt, int width, int height);
  125. int avpicture_get_size(int pix_fmt, int width, int height);
  126. /* convert among pixel formats */
  127. int img_convert(AVPicture *dst, int dst_pix_fmt,
  128. AVPicture *src, int pix_fmt,
  129. int width, int height);
  130. /* deinterlace a picture */
  131. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  132. int pix_fmt, int width, int height);
  133. /* external high level API */
  134. extern AVCodec *first_avcodec;
  135. void avcodec_init(void);
  136. void register_avcodec(AVCodec *format);
  137. AVCodec *avcodec_find_encoder(enum CodecID id);
  138. AVCodec *avcodec_find_decoder(enum CodecID id);
  139. AVCodec *avcodec_find_decoder_by_name(const char *name);
  140. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  141. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  142. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  143. int *frame_size_ptr,
  144. UINT8 *buf, int buf_size);
  145. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  146. int *got_picture_ptr,
  147. UINT8 *buf, int buf_size);
  148. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  149. const short *samples);
  150. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  151. const AVPicture *pict);
  152. int avcodec_close(AVCodecContext *avctx);
  153. void avcodec_register_all(void);