FFmpeg: AVCodec结构体解析

    点击查看代码
    
    typedef struct AVCodec {
        /**
         * 编解码器实现的名称。
         * 该名称是全局唯一的(但编码器和解码器可以共享名称)。
         * 这是从用户角度查找编解码器的主要方式。
         */
        const char *name;
        /**
         * 编解码器的描述性名称,比前面的名称更具可读性。
         * 您应该使用NULL_IF_CONFIG_SMALL()宏来定义它。
         */
        const char *long_name;
        enum AVMediaType type;//编解码器类型,视频,音频,或者字幕
        enum AVCodecID id;//全局唯一的编解码器ID
        /**
         * Codec capabilities.
         * see AV_CODEC_CAP_*
         */
        int capabilities;
        const AVRational *supported_framerates; ///支持帧率的数组,用于视频
        const enum AVPixelFormat *pix_fmts;     ///< 支持的像素格式数组,或者如果未知,则为NULL,数组以-1结尾。用于视频
        const int *supported_samplerates;       ///< 支持的音频采样率数组,或者如果未知,则为NULL,数组以0结尾。用于音频
        const enum AVSampleFormat *sample_fmts; ///<支持的采样数组,或者如果未知,则为NULL,数组以-1结尾。用于音频
        const uint64_t *channel_layouts;         ///< 支持声道数组,如果未知,则为NULL。 数组以0结尾,用于音频
        uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
        const AVClass *priv_class;              ///< 私有上下文的AVClass
        const AVProfile *profiles;              ///< 已识别配置文件的数组,或者如果未知,则为NULL,数组以{FF_PROFILE_UNKNOWN}结尾
    
        /*****************************************************************
         * 以下所有的字段都不是公共API,不可在libavcodec以外使用。以后新增字段都会放在上面。
         *****************************************************************
         */
        int priv_data_size;//私有数据大小
        struct AVCodec *next;
        /**
         * @name Frame-level threading support functions
         * @{
         */
        /**
         * 如果已定义,则在创建线程上下文时调用它们。
         * 如果编解码器在init()中分配可写表,请在此处重新分配它们。
         * priv_data将被设置为原件的副本。
         */
        int (*init_thread_copy)(AVCodecContext *);
        /**
         * Copy necessary context variables from a previous thread context to the current one.
         * If not defined, the next thread will start automatically; otherwise, the codec
         * must call ff_thread_finish_setup().
         *
         * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
         */
        int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
        /** @} */
    
        /**
         * 私有编解码器默认值。
         */
        const AVCodecDefault *defaults;
    
        /**
         * 初始化时从avcodec_register()调用的编解码器静态数据。
         */
        void (*init_static_data)(struct AVCodec *codec);
    
        int (*init)(AVCodecContext *);
        int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
                          const struct AVSubtitle *sub);
        /**
         * Encode data to an AVPacket.
         *
         * @param      avctx          codec context
         * @param      avpkt          output AVPacket (may contain a user-provided buffer)
         * @param[in]  frame          AVFrame containing the raw data to be encoded
         * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
         *                            non-empty packet was returned in avpkt.
         * @return 0 on success, negative error code on failure
         */
        int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
                       int *got_packet_ptr);
        int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
        int (*close)(AVCodecContext *);
        /**
         * Decode/encode API with decoupled packet/frame dataflow. The API is the
         * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except
         * that:
         * - never called if the codec is closed or the wrong type,
         * - AVPacket parameter change side data is applied right before calling
         *   AVCodec->send_packet,
         * - if AV_CODEC_CAP_DELAY is not set, drain packets or frames are never sent,
         * - only one drain packet is ever passed down (until the next flush()),
         * - a drain AVPacket is always NULL (no need to check for avpkt->size).
         */
        int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame);
        int (*send_packet)(AVCodecContext *avctx, const AVPacket *avpkt);
        int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame);
        int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt);
        /**
         * Flush buffers.
         * Will be called when seeking
         */
        void (*flush)(AVCodecContext *);
        /**
         * Internal codec capabilities.
         * See FF_CODEC_CAP_* in internal.h
         */
        int caps_internal;
    } AVCodec;
    
    posted @   相对维度  阅读(114)  评论(0编辑  收藏  举报
    相关博文:
    阅读排行:
    · 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
    · 地球OL攻略 —— 某应届生求职总结
    · 周边上新:园子的第一款马克杯温暖上架
    · 提示词工程——AI应用必不可少的技术
    · Open-Sora 2.0 重磅开源!
    点击右上角即可分享
    微信分享提示