Skip to content
Snippets Groups Projects
avcodec.h 35.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Fabrice Bellard's avatar
    Fabrice Bellard committed
        struct AVCodec *next;
    } AVCodec;
    
    
     * four components are given, that's all.
     * the last component is alpha
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    typedef struct AVPicture {
    
        uint8_t *data[4];
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    } AVPicture;
    
    extern AVCodec ac3_encoder;
    extern AVCodec mp2_encoder;
    
    extern AVCodec mp3lame_encoder;
    
    extern AVCodec oggvorbis_encoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec mpeg1video_encoder;
    extern AVCodec h263_encoder;
    extern AVCodec h263p_encoder;
    extern AVCodec rv10_encoder;
    extern AVCodec mjpeg_encoder;
    
    extern AVCodec mpeg4_encoder;
    
    extern AVCodec msmpeg4v1_encoder;
    extern AVCodec msmpeg4v2_encoder;
    extern AVCodec msmpeg4v3_encoder;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    extern AVCodec wmv1_encoder;
    extern AVCodec wmv2_encoder;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    extern AVCodec huffyuv_encoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    extern AVCodec h263_decoder;
    
    extern AVCodec mpeg4_decoder;
    
    extern AVCodec msmpeg4v1_decoder;
    extern AVCodec msmpeg4v2_decoder;
    extern AVCodec msmpeg4v3_decoder;
    
    extern AVCodec wmv1_decoder;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    extern AVCodec wmv2_decoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec mpeg_decoder;
    extern AVCodec h263i_decoder;
    extern AVCodec rv10_decoder;
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    extern AVCodec svq1_decoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec dvvideo_decoder;
    extern AVCodec dvaudio_decoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec wmav1_decoder;
    extern AVCodec wmav2_decoder;
    
    extern AVCodec mjpeg_decoder;
    
    extern AVCodec mjpegb_decoder;
    
    extern AVCodec mp2_decoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec mp3_decoder;
    
    extern AVCodec mace3_decoder;
    extern AVCodec mace6_decoder;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    extern AVCodec huffyuv_decoder;
    
    extern AVCodec oggvorbis_decoder;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    /* pcm codecs */
    #define PCM_CODEC(id, name) \
    extern AVCodec name ## _decoder; \
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
    PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
    PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
    PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
    PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
    PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
    PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
    PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
    
    
    /* adpcm codecs */
    
    PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
    PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
    PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    #undef PCM_CODEC
    
    /* dummy raw video codec */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec rawvideo_codec;
    
    /* the following codecs use external GPL libs */
    extern AVCodec ac3_decoder;
    
    /* resample.c */
    
    struct ReSampleContext;
    
    typedef struct ReSampleContext ReSampleContext;
    
    ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
                                         int output_rate, int input_rate);
    int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
    void audio_resample_close(ReSampleContext *s);
    
    /* YUV420 format is assumed ! */
    
    struct ImgReSampleContext;
    
    typedef struct ImgReSampleContext ImgReSampleContext;
    
    ImgReSampleContext *img_resample_init(int output_width, int output_height,
                                          int input_width, int input_height);
    
    
    ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
                                          int iwidth, int iheight,
                                          int topBand, int bottomBand,
                                          int leftBand, int rightBand);
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    void img_resample(ImgReSampleContext *s, 
                      AVPicture *output, AVPicture *input);
    
    void img_resample_close(ImgReSampleContext *s);
    
    
    int avpicture_fill(AVPicture *picture, uint8_t *ptr,
    
                       int pix_fmt, int width, int height);
    
    int avpicture_get_size(int pix_fmt, int width, int height);
    
    void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
    const char *avcodec_get_pix_fmt_name(int pix_fmt);
    
    
    /* convert among pixel formats */
    int img_convert(AVPicture *dst, int dst_pix_fmt,
                    AVPicture *src, int pix_fmt, 
                    int width, int height);
    
    /* deinterlace a picture */
    int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                              int pix_fmt, int width, int height);
    
    /* external high level API */
    
    extern AVCodec *first_avcodec;
    
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    /* returns LIBAVCODEC_VERSION_INT constant */
    
    unsigned avcodec_version(void);
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    /* returns LIBAVCODEC_BUILD constant */
    
    unsigned avcodec_build(void);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    void avcodec_init(void);
    
    
    void avcodec_set_bit_exact(void);
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    void register_avcodec(AVCodec *format);
    AVCodec *avcodec_find_encoder(enum CodecID id);
    
    AVCodec *avcodec_find_encoder_by_name(const char *name);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    AVCodec *avcodec_find_decoder(enum CodecID id);
    AVCodec *avcodec_find_decoder_by_name(const char *name);
    void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
    
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    void avcodec_get_context_defaults(AVCodecContext *s);
    
    Falk Hüffner's avatar
    Falk Hüffner committed
    AVCodecContext *avcodec_alloc_context(void);
    
    AVFrame *avcodec_alloc_frame(void);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    
    int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
    void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
    
    int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *frame_size_ptr,
    
                             uint8_t *buf, int buf_size);
    
    int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *got_picture_ptr,
    
                             uint8_t *buf, int buf_size);
    int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
    
                            uint8_t *buf, int buf_size);
    int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             const short *samples);
    
    int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
    
                             const AVFrame *pict);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    int avcodec_close(AVCodecContext *avctx);
    
    void avcodec_register_all(void);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    void avcodec_flush_buffers(AVCodecContext *avctx);
    
    
    /**
     * Interface for 0.5.0 version
     *
     * do not even think about it's usage for this moment
     */
    
    typedef struct {
        // compressed size used from given memory buffer
        int size;
        /// I/P/B frame type
        int frame_type;
    } avc_enc_result_t;
    
    /**
     * Commands
     * order can't be changed - once it was defined
     */
    typedef enum {
        // general commands
        AVC_OPEN_BY_NAME = 0xACA000,
        AVC_OPEN_BY_CODEC_ID,
        AVC_OPEN_BY_FOURCC,
        AVC_CLOSE,
    
        AVC_FLUSH,
        // pin - struct { uint8_t* src, uint_t src_size }
        // pout - struct { AVPicture* img, consumed_bytes,
        AVC_DECODE,
        // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
        // pout - uint_t used_from_dest_size
        AVC_ENCODE, 
    
        // query/get video commands
        AVC_GET_VERSION = 0xACB000,
        AVC_GET_WIDTH,
        AVC_GET_HEIGHT,
        AVC_GET_DELAY,
        AVC_GET_QUANT_TABLE,
        // ...
    
        // query/get audio commands
        AVC_GET_FRAME_SIZE = 0xABC000,
    
        // maybe define some simple structure which
        // might be passed to the user - but they can't
        // contain any codec specific parts and these
        // calls are usualy necessary only few times
    
        // set video commands
        AVC_SET_WIDTH = 0xACD000,
        AVC_SET_HEIGHT,
    
        // set video encoding commands
        AVC_SET_FRAME_RATE = 0xACD800,
        AVC_SET_QUALITY,
        AVC_SET_HURRY_UP,
    
        // set audio commands
        AVC_SET_SAMPLE_RATE = 0xACE000,
        AVC_SET_CHANNELS,
    
    } avc_cmd_t;
    
    /**
     * \param handle  allocated private structure by libavcodec
     *                for initialization pass NULL - will be returned pout
     *                user is supposed to know nothing about its structure
     * \param cmd     type of operation to be performed
     * \param pint    input parameter
     * \param pout    output parameter
     *
     * \returns  command status - eventually for query command it might return
     * integer resulting value
     */
    int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
    
    
    /* memory */
    
    void *av_malloc(unsigned int size);
    void *av_mallocz(unsigned int size);
    
    void *av_realloc(void *ptr, unsigned int size);
    
    void av_free(void *ptr);
    
    char *av_strdup(const char *s);
    
    void __av_freep(void **ptr);
    #define av_freep(p) __av_freep((void **)(p))
    
    void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
    
    /* for static data only */
    /* call av_free_static to release all staticaly allocated tables */
    
    void av_free_static(void);
    
    void *__av_mallocz_static(void** location, unsigned int size);
    #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
    
    #ifdef __cplusplus
    }
    #endif
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    #endif /* AVCODEC_H */