ffmpeg AVCodec结构体主要变量

其中AVCodec是存储编解码器信息的结构体
参考结构体理解:http://www.jianshu.com/p/d109e7ef9749

const char *name

:编解码器的名字,比较短

const char *long_name

:编解码器的名字,全称,比较长

enum AVMediaType type
enum AVMediaType {  
    AVMEDIA_TYPE_UNKNOWN = -1,  ///< Usually treated as AVMEDIA_TYPE_DATA  
    AVMEDIA_TYPE_VIDEO,  
    AVMEDIA_TYPE_AUDIO,  
    AVMEDIA_TYPE_DATA,          ///< Opaque data information usually continuous  
    AVMEDIA_TYPE_SUBTITLE,  
    AVMEDIA_TYPE_ATTACHMENT,    ///< Opaque data information usually sparse  
    AVMEDIA_TYPE_NB  
}; 

:指明了类型,是视频,音频,还是字幕

enum AVCodecID id
enum AVCodecID {  
    AV_CODEC_ID_NONE,  
  
    /* video codecs */  
    AV_CODEC_ID_MPEG1VIDEO,  
    AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding  
    AV_CODEC_ID_MPEG2VIDEO_XVMC,  
    AV_CODEC_ID_H261,  
    AV_CODEC_ID_H263,  
    AV_CODEC_ID_RV10,  
    AV_CODEC_ID_RV20,  
    AV_CODEC_ID_MJPEG,  
    AV_CODEC_ID_MJPEGB,  
    AV_CODEC_ID_LJPEG,  
    AV_CODEC_ID_SP5X,  
    AV_CODEC_ID_JPEGLS,  
    AV_CODEC_ID_MPEG4,  
    AV_CODEC_ID_RAWVIDEO,  
    AV_CODEC_ID_MSMPEG4V1,  
    AV_CODEC_ID_MSMPEG4V2,  
    AV_CODEC_ID_MSMPEG4V3,  
    AV_CODEC_ID_WMV1,  
    AV_CODEC_ID_WMV2,  
    AV_CODEC_ID_H263P,  
    AV_CODEC_ID_H263I,  
    AV_CODEC_ID_FLV1,  
    AV_CODEC_ID_SVQ1,  
    AV_CODEC_ID_SVQ3,  
    AV_CODEC_ID_DVVIDEO,  
    AV_CODEC_ID_HUFFYUV,  
    AV_CODEC_ID_CYUV,  
    AV_CODEC_ID_H264,  
    ...(代码太长,略)  
}  

:ID,不重复

const AVRational *supported_framerates

:支持的帧率(仅视频)

const enum AVPixelFormat *pix_fmts
enum AVPixelFormat {  
    AV_PIX_FMT_NONE = -1,  
    AV_PIX_FMT_YUV420P,   ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)  
    AV_PIX_FMT_YUYV422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr  
    AV_PIX_FMT_RGB24,     ///< packed RGB 8:8:8, 24bpp, RGBRGB...  
    AV_PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...  
    AV_PIX_FMT_YUV422P,   ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)  
    AV_PIX_FMT_YUV444P,   ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)  
    AV_PIX_FMT_YUV410P,   ///< planar YUV 4:1:0,  9bpp, (1 Cr & Cb sample per 4x4 Y samples)  
    AV_PIX_FMT_YUV411P,   ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)  
    AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp  
    AV_PIX_FMT_MONOWHITE, ///<        Y        ,  1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb  
    AV_PIX_FMT_MONOBLACK, ///<        Y        ,  1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb  
    AV_PIX_FMT_PAL8,      ///< 8 bit with PIX_FMT_RGB32 palette  
    AV_PIX_FMT_YUVJ420P,  ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range  
    AV_PIX_FMT_YUVJ422P,  ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range  
    AV_PIX_FMT_YUVJ444P,  ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range  
    AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing  
    AV_PIX_FMT_XVMC_MPEG2_IDCT,  
    ...(代码太长,略)  
} 

:支持的像素格式(仅视频)

const int *supported_samplerates

:支持的采样率(仅音频)

const enum AVSampleFormat *sample_fmts
enum AVSampleFormat {  
    AV_SAMPLE_FMT_NONE = -1,  
    AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits  
    AV_SAMPLE_FMT_S16,         ///< signed 16 bits  
    AV_SAMPLE_FMT_S32,         ///< signed 32 bits  
    AV_SAMPLE_FMT_FLT,         ///< float  
    AV_SAMPLE_FMT_DBL,         ///< double  
  
    AV_SAMPLE_FMT_U8P,         ///< unsigned 8 bits, planar  
    AV_SAMPLE_FMT_S16P,        ///< signed 16 bits, planar  
    AV_SAMPLE_FMT_S32P,        ///< signed 32 bits, planar  
    AV_SAMPLE_FMT_FLTP,        ///< float, planar  
    AV_SAMPLE_FMT_DBLP,        ///< double, planar  
  
    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically  
};  

:支持的采样格式(仅音频)

const uint64_t *channel_layouts

:支持的声道数(仅音频)

int priv_data_size

:私有数据的大小

举例解码器结构体:h264dec.c
参考链接:http://ffmpeg.org/doxygen/trunk/libavcodec_2h264dec_8c.html

{
    .name                  = "h264",
    .long_name             = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
    .type                  = AVMEDIA_TYPE_VIDEO,
    .id                    = AV_CODEC_ID_H264,
    .priv_data_size        = sizeof(H264Context),
    .init                  = h264_decode_init,
    .close                 = h264_decode_end,
    .decode                = h264_decode_frame,
    .capabilities          =  AV_CODEC_CAP_DR1 |
                             AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
                             AV_CODEC_CAP_FRAME_THREADS,
    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING,
    .flush                 = flush_dpb,
    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
    .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
    .profiles              = NULL_IF_CONFIG_SMALL(ff_h264_profiles),
    .priv_class            = &h264_class,
}
}

你可能感兴趣的:(ffmpeg AVCodec结构体主要变量)