2011-10-10 0:22:22

来源:互联网 发布:中信建投mac版下载 编辑:程序博客网 时间:2024/06/05 20:12
2011-10-10 0:22:22 




4. 上面调用了avcodec_init函数:




void avcodec_init(void)
{
    static int initialized = 0;


     if (initialized != 0)
        return;
    initialized = 1;


    dsputil_static_init ();
}




av_cold void dsputil_static_init(void)
{
    int i;


     for(i=0;i<256;i++) ff_cropTbl[i + MAX_NEG_CROP] = i;
    for(i=0;i<MAX_NEG_CROP;i++) {
        ff_cropTbl[i] = 0;
        ff_cropTbl[i + MAX_NEG_CROP + 256] = 255;
    }


     for(i=0;i<512;i++) {
        ff_squareTbl[i] = (i - 256) * (i - 256);
    }


     for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
}






    REGISTER_MUXDEMUX (H264, h264);


    // 注册文件协议
    REGISTER_PROTOCOL (FILE, file);


注册mux和demux 






#define REGISTER_MUXER(X,x) { \
    extern AVOutputFormat x##_muxer; \
    if(CONFIG_##X##_MUXER) av_register_output_format(&x##_muxer); }


#define REGISTER_DEMUXER(X,x) { \
    extern AVInputFormat x##_demuxer; \
    if(CONFIG_##X##_DEMUXER) av_register_input_format(&x##_demuxer); }


#define REGISTER_MUXDEMUX(X,x) REGISTER_MUXER(X,x); REGISTER_DEMUXER(X,x)


#define REGISTER_PROTOCOL(X,x) { \
    extern URLProtocol x##_protocol; \
    if(CONFIG_##X##_PROTOCOL) av_register_protocol(&x##_protocol); }


    
    
    
    
URL协议结构:
typedef struct URLProtocol {
    const char *name;
    int (*url_open)(URLContext *h, const char *url, int flags);
    int (*url_read)(URLContext *h, unsigned char *buf, int size);
    int (*url_write)(URLContext *h, unsigned char *buf, int size);
    int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
    int (*url_close)(URLContext *h);
    struct URLProtocol *next;
    int (*url_read_pause)(URLContext *h, int pause);
    int64_t (*url_read_seek)(URLContext *h, int stream_index,
                             int64_t timestamp, int flags);
    int (*url_get_file_handle)(URLContext *h);
} URLProtocol;





原创粉丝点击