首页 > 其他分享 >AVCodec(avcodec.h)

AVCodec(avcodec.h)

时间:2024-04-06 20:55:21浏览次数:22  
标签:const name int AVCodec supported array avcodec

AVCodec

AVCodec是存储编解码器信息的结构体。

 /**
 * AVCodec.
 */
typedef struct AVCodec {
    /**
     * Name of the codec implementation.
     * The name is globally unique among encoders and among decoders (but an
     * encoder and a decoder can share the same name).
     * This is the primary way to find a codec from the user perspective.
     */
    const char *name;
    /**
     * Descriptive name for the codec, meant to be more human readable than name.
     * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
     */
    const char *long_name;
    enum AVMediaType type;
    enum CodecID id;
    /**
     * Codec capabilities.
     * see CODEC_CAP_*
     */
    int capabilities;
    const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
    const enum PixelFormat *pix_fmts;       ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
    const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
    const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
    const uint64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
    uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
    const AVClass *priv_class;              ///< AVClass for the private context
    const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
 
    /*****************************************************************
     * No fields below this line are part of the public API. They
     * may not be used outside of libavcodec and can be changed and
     * removed at will.
     * New public fields should be added right above.
     *****************************************************************
     */
    int priv_data_size;
    struct AVCodec *next;
    /**
     * @name Frame-level threading support functions
     * @{
     */
    /**
     * If defined, called on thread contexts when they are created.
     * If the codec allocates writable tables in init(), re-allocate them here.
     * priv_data will be set to a copy of the original.
     */
    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);
    /** @} */
 
    /**
     * Private codec-specific defaults.
     */
    const AVCodecDefault *defaults;
 
    /**
     * Initialize codec static data, called from avcodec_register().
     */
    void (*init_static_data)(struct AVCodec *codec);
 
    int (*init)(AVCodecContext *);
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
    /**
     * 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 *);
    /**
     * Flush buffers.
     * Will be called when seeking
     */
    void (*flush)(AVCodecContext *);
} AVCodec;

下面说一下最主要的几个变量
const char *name:编解码器的名字,比较短
const char *long_name:编解码器的名字,全称,比较长
enum AVMediaType type:指明了类型,是视频,音频,还是字幕
enum AVCodecID id:ID,不重复
const AVRational * supported_framerates:支持的帧率(仅视频)
const enum AVPixelFormat * pix_fmts:支持的像素格式(仅视频)
const int *supported_samplerates:支持的采样率(仅音频)
const enum AVSampleFormat *sample_fmts:支持的采样格式(仅音频)

标签:const,name,int,AVCodec,supported,array,avcodec
From: https://www.cnblogs.com/doubleconquer/p/18063069

相关文章

  • AVCodec
    AVCodec是存储编解码信息的结构体。/***AVCodec.*/typedefstructAVCodec{/***Nameofthecodecimplementation.*Thenameisgloballyuniqueamongencodersandamongdecoders(butan*encoderandadecodercansharethesamename)......
  • AVCodecContext(avcodec.h)
    AVCodecContext(位于avcodec.h)AVCodecContext是包含变量较多的结构体(感觉差不多是变量最多的结构体).本文将会大概分析一下该结构体里面每个变量的含义和作用。/***mainexternalAPIstructure.*Newfieldscanbeaddedtotheendwithminorversionbumps.*Rem......
  • 详解avcodec_receive_packet 11
    详解avcodec_receive_packet在音视频处理中,avcodec_receive_packet是一个重要的函数,它负责接收编码器输出的数据包。在本篇文章中,我们将详细介绍avcodec_receive_packet函数的用法和参数,并说明其在音视频处理中的作用。函数介绍avcodec_receive_packet是FFmpeg中的一个函数,其定义如......
  • 详解avcodec_encode_video2 AVERROR(EAGAIN)
    详解avcodec_encode_video2AVERROR(EAGAIN)在视频编码过程中,可能会遇到错误码AVERROR(EAGAIN)。本篇技术博客将详细解释avcodec_encode_video2函数中的AVERROR(EAGAIN)错误码的含义,并讨论可能的原因和解决方案。什么是avcodec_encode_video2?avcodec_encode_video2是FFmpeg(一个流行......
  • 详解ffmpeg avcodec_encode_video2 函数报错
    详解ffmpegavcodec_encode_video2函数报错在使用FFmpeg进行视频编码时,开发者经常会使用avcodec_encode_video2函数来进行编码操作。然而,有时候会遇到该函数报错的情况,本文将详细解析这个问题及其可能的解决方法。问题描述当调用avcodec_encode_video2函数时,可能会出现以下错误信......
  • Python报错:pkg-config could not find libraries ['avformat', 'avcodec', 'av
    参考:https://github.com/PyAV-Org/PyAV/issues/238https://pyav.org/docs/6.1.2/installation.html#mac-os-x  =====================  报错信息:C:\Users\liuxue>pipinstallavCollectingavUsingcachedav-0.3.3.tar.gzInstallingcollectedpackages:avRunning......
  • Python报错:pkg-config could not find libraries ['avformat', 'avcodec', 'avdev
    参考:https://github.com/PyAV-Org/PyAV/issues/238https://pyav.org/docs/6.1.2/installation.html#mac-os-x  =====================  报错信息:C:\Users\liuxue>pipinstallavCollectingavUsingcachedav-0.3.3.tar.gzInstallingcollectedpackages:av......
  • 使用libavcodec将mp3音频文件解码为pcm音频采样数据【[mp3float @ 0x561c1ec49940] He
    一.打开和关闭输入文件和输出文件想要解决上面提到的问题,我们需要对mp3文件的格式有个大致了解,为了方便讲解,我这里画了个示意图:ID3V2包含了作者,作曲,专辑等信息,长度不固定,扩展了ID3V1的信息量。Frame一系列的帧,个数由文件大小和帧长决定ID3V1包含了作者,作曲,专......
  • libavcodec视频解码
    一.打开和关闭输入文件和输出文件//io_data.cppstaticFILE*input_file=nullptr;staticFILE*output_file=nullptr;int32_topen_input_output_files(constchar*input_name,constchar*output_name){if(strlen(input_name)==0||strlen(output_name)==0){......
  • 如何使用libavcodec将.yuv图像序列编码为.h264的视频码流?
    1.实现打开和关闭输入文件和输出文件的操作点击查看代码//io_data.cppstaticFILE*input_file=nullptr;staticFILE*output_file=nullptr;int32_topen_input_output_files(constchar*input_name,constchar*output_name){if(strlen(input_name)==0||strlen(ou......