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.

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