Mercurial > libavcodec.hg
annotate avcodec.h @ 92:1d3eb6cdc6b5 libavcodec
added pcm codecs
| author | glantau |
|---|---|
| date | Sun, 23 Sep 2001 17:16:51 +0000 |
| parents | cdd89f96cbe1 |
| children | 1e4a4af694d1 |
| rev | line source |
|---|---|
| 92 | 1 #ifndef AVCODEC_H |
| 2 #define AVCODEC_H | |
| 3 | |
| 0 | 4 #include "common.h" |
| 5 | |
| 6 enum CodecID { | |
| 7 CODEC_ID_NONE, | |
| 8 CODEC_ID_MPEG1VIDEO, | |
| 9 CODEC_ID_H263, | |
| 10 CODEC_ID_RV10, | |
| 11 CODEC_ID_MP2, | |
| 12 CODEC_ID_AC3, | |
| 13 CODEC_ID_MJPEG, | |
| 67 | 14 CODEC_ID_MPEG4, |
| 0 | 15 CODEC_ID_RAWVIDEO, |
| 16 CODEC_ID_MSMPEG4, | |
| 17 CODEC_ID_H263P, | |
| 18 CODEC_ID_H263I, | |
| 92 | 19 |
| 20 /* various pcm "codecs" */ | |
| 21 CODEC_ID_PCM_S16LE, | |
| 22 CODEC_ID_PCM_S16BE, | |
| 23 CODEC_ID_PCM_U16LE, | |
| 24 CODEC_ID_PCM_U16BE, | |
| 25 CODEC_ID_PCM_S8, | |
| 26 CODEC_ID_PCM_U8, | |
| 27 CODEC_ID_PCM_MULAW, | |
| 28 CODEC_ID_PCM_ALAW, | |
| 0 | 29 }; |
| 30 | |
| 31 enum CodecType { | |
| 32 CODEC_TYPE_VIDEO, | |
| 33 CODEC_TYPE_AUDIO, | |
| 34 }; | |
| 35 | |
| 36 enum PixelFormat { | |
| 37 PIX_FMT_YUV420P, | |
| 38 PIX_FMT_YUV422, | |
| 39 PIX_FMT_RGB24, | |
| 40 PIX_FMT_BGR24, | |
|
27
b8723ec6c80f
added 422P and 444P formats (need to patch ffmpeg.c so that it is handled in all the program)
glantau
parents:
24
diff
changeset
|
41 PIX_FMT_YUV422P, |
|
b8723ec6c80f
added 422P and 444P formats (need to patch ffmpeg.c so that it is handled in all the program)
glantau
parents:
24
diff
changeset
|
42 PIX_FMT_YUV444P, |
| 0 | 43 }; |
| 44 | |
| 92 | 45 /* currently unused, may be used if 24/32 bits samples ever supported */ |
| 46 enum SampleFormat { | |
| 47 SAMPLE_FMT_S16 = 0, /* signed 16 bits */ | |
| 48 }; | |
| 49 | |
| 0 | 50 /* in bytes */ |
| 51 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432 | |
| 52 | |
| 53 /* motion estimation type */ | |
| 54 extern int motion_estimation_method; | |
| 55 #define ME_ZERO 0 | |
| 56 #define ME_FULL 1 | |
| 57 #define ME_LOG 2 | |
| 58 #define ME_PHODS 3 | |
| 59 | |
| 60 /* encoding support */ | |
| 61 | |
| 62 #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */ | |
| 63 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */ | |
| 64 | |
| 67 | 65 /* codec capabilities */ |
| 66 | |
| 67 /* decoder can use draw_horiz_band callback */ | |
| 68 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 | |
| 69 | |
| 0 | 70 #define FRAME_RATE_BASE 10000 |
| 71 | |
| 72 typedef struct AVCodecContext { | |
| 73 int bit_rate; | |
| 74 int flags; | |
| 75 int sub_id; /* some codecs needs additionnal format info. It is | |
| 76 stored there */ | |
| 77 /* video only */ | |
| 78 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */ | |
| 79 int width, height; | |
| 80 int gop_size; /* 0 = intra only */ | |
| 81 int pix_fmt; /* pixel format, see PIX_FMT_xxx */ | |
| 67 | 82 |
| 83 /* if non NULL, 'draw_horiz_band' is called by the libavcodec | |
| 84 decoder to draw an horizontal band. It improve cache usage. Not | |
| 85 all codecs can do that. You must check the codec capabilities | |
| 86 before */ | |
| 87 void (*draw_horiz_band)(struct AVCodecContext *s, | |
| 88 UINT8 **src_ptr, int linesize, | |
| 89 int y, int width, int height); | |
| 90 | |
| 0 | 91 /* audio only */ |
| 92 int sample_rate; /* samples per sec */ | |
| 93 int channels; | |
| 92 | 94 int sample_fmt; /* sample format, currenly unused */ |
| 0 | 95 |
| 96 /* the following data should not be initialized */ | |
| 97 int frame_size; /* in samples, initialized when calling 'init' */ | |
| 98 int frame_number; /* audio or video frame number */ | |
| 99 int key_frame; /* true if the previous compressed frame was | |
| 100 a key frame (intra, or seekable) */ | |
| 101 int quality; /* quality of the previous encoded frame | |
| 102 (between 1 (good) and 31 (bad)) */ | |
| 103 struct AVCodec *codec; | |
| 104 void *priv_data; | |
| 105 | |
| 106 /* the following fields are ignored */ | |
| 67 | 107 void *opaque; /* can be used to carry app specific stuff */ |
| 0 | 108 char codec_name[32]; |
| 109 int codec_type; /* see CODEC_TYPE_xxx */ | |
| 110 int codec_id; /* see CODEC_ID_xxx */ | |
| 111 unsigned int codec_tag; /* codec tag, only used if unknown codec */ | |
| 112 } AVCodecContext; | |
| 113 | |
| 114 typedef struct AVCodec { | |
| 115 char *name; | |
| 116 int type; | |
| 117 int id; | |
| 118 int priv_data_size; | |
| 119 int (*init)(AVCodecContext *); | |
| 120 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data); | |
| 121 int (*close)(AVCodecContext *); | |
| 122 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, | |
| 123 UINT8 *buf, int buf_size); | |
| 67 | 124 int capabilities; |
| 0 | 125 struct AVCodec *next; |
| 126 } AVCodec; | |
| 127 | |
| 128 /* three components are given, that's all */ | |
| 129 typedef struct AVPicture { | |
| 130 UINT8 *data[3]; | |
| 131 int linesize[3]; | |
| 132 } AVPicture; | |
| 133 | |
| 134 extern AVCodec ac3_encoder; | |
| 135 extern AVCodec mp2_encoder; | |
| 136 extern AVCodec mpeg1video_encoder; | |
| 137 extern AVCodec h263_encoder; | |
| 138 extern AVCodec h263p_encoder; | |
| 139 extern AVCodec rv10_encoder; | |
| 140 extern AVCodec mjpeg_encoder; | |
| 67 | 141 extern AVCodec mpeg4_encoder; |
| 0 | 142 extern AVCodec msmpeg4_encoder; |
| 143 | |
| 144 extern AVCodec h263_decoder; | |
| 67 | 145 extern AVCodec mpeg4_decoder; |
| 0 | 146 extern AVCodec msmpeg4_decoder; |
| 147 extern AVCodec mpeg_decoder; | |
| 148 extern AVCodec h263i_decoder; | |
| 149 extern AVCodec rv10_decoder; | |
| 24 | 150 extern AVCodec mjpeg_decoder; |
| 92 | 151 extern AVCodec mp3_decoder; |
| 0 | 152 |
| 92 | 153 /* pcm codecs */ |
| 154 #define PCM_CODEC(id, name) \ | |
| 155 extern AVCodec name ## _decoder; \ | |
| 156 extern AVCodec name ## _encoder; | |
| 157 | |
| 158 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); | |
| 159 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); | |
| 160 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); | |
| 161 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be); | |
| 162 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8); | |
| 163 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8); | |
| 164 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw); | |
| 165 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw); | |
| 166 | |
| 167 #undef PCM_CODEC | |
| 168 | |
| 169 /* dummy raw video codec */ | |
| 0 | 170 extern AVCodec rawvideo_codec; |
| 171 | |
| 172 /* the following codecs use external GPL libs */ | |
| 173 extern AVCodec ac3_decoder; | |
| 174 | |
| 175 /* resample.c */ | |
| 176 | |
| 177 struct ReSampleContext; | |
| 178 | |
| 179 typedef struct ReSampleContext ReSampleContext; | |
| 180 | |
| 181 ReSampleContext *audio_resample_init(int output_channels, int input_channels, | |
| 182 int output_rate, int input_rate); | |
| 183 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); | |
| 184 void audio_resample_close(ReSampleContext *s); | |
| 185 | |
| 186 /* YUV420 format is assumed ! */ | |
| 187 | |
| 188 struct ImgReSampleContext; | |
| 189 | |
| 190 typedef struct ImgReSampleContext ImgReSampleContext; | |
| 191 | |
| 192 ImgReSampleContext *img_resample_init(int output_width, int output_height, | |
| 193 int input_width, int input_height); | |
| 194 void img_resample(ImgReSampleContext *s, | |
| 195 AVPicture *output, AVPicture *input); | |
| 196 | |
| 197 void img_resample_close(ImgReSampleContext *s); | |
| 198 | |
| 49 | 199 void avpicture_fill(AVPicture *picture, UINT8 *ptr, |
| 200 int pix_fmt, int width, int height); | |
| 201 int avpicture_get_size(int pix_fmt, int width, int height); | |
| 202 | |
| 203 /* convert among pixel formats */ | |
| 204 int img_convert(AVPicture *dst, int dst_pix_fmt, | |
| 205 AVPicture *src, int pix_fmt, | |
| 206 int width, int height); | |
| 207 | |
| 208 /* deinterlace a picture */ | |
| 209 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, | |
| 0 | 210 int pix_fmt, int width, int height); |
| 211 | |
| 212 /* external high level API */ | |
| 213 | |
| 214 extern AVCodec *first_avcodec; | |
| 215 | |
| 216 void avcodec_init(void); | |
| 217 | |
| 218 void register_avcodec(AVCodec *format); | |
| 219 AVCodec *avcodec_find_encoder(enum CodecID id); | |
| 220 AVCodec *avcodec_find_decoder(enum CodecID id); | |
| 221 AVCodec *avcodec_find_decoder_by_name(const char *name); | |
| 222 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); | |
| 223 | |
| 224 int avcodec_open(AVCodecContext *avctx, AVCodec *codec); | |
| 225 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, | |
| 226 int *frame_size_ptr, | |
| 227 UINT8 *buf, int buf_size); | |
| 228 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, | |
| 229 int *got_picture_ptr, | |
| 230 UINT8 *buf, int buf_size); | |
| 231 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
| 232 const short *samples); | |
| 233 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
| 234 const AVPicture *pict); | |
| 235 | |
| 236 int avcodec_close(AVCodecContext *avctx); | |
| 237 | |
| 238 void avcodec_register_all(void); | |
| 92 | 239 |
| 240 #endif /* AVCODEC_H */ |
