参考链接
- FFMPEG结构体分析:AVCodec_雷霄骅的博客-CSDN博客_avcodec
AVCodec
- AVCodec是存储编解码器信息的结构体
- 结构体的定义位于avcodec.h文件中
- 最主要的几个变量
- 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 uint64_t *channel_layouts:支持的声道数(仅音频)
- int priv_data_size:私有数据的大小
重点介绍
- AVMediaType位于avutil.h文件内
/*** @addtogroup lavu_media Media Type* @brief Media Type*/enum AVMediaType {AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATAAVMEDIA_TYPE_VIDEO,AVMEDIA_TYPE_AUDIO,AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuousAVMEDIA_TYPE_SUBTITLE,AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparseAVMEDIA_TYPE_NB
};
- AVCodecID位于codec_id.h文件内
/*** Identify the syntax and semantics of the bitstream.* The principle is roughly:* Two decoders with the same ID can decode the same streams.* Two encoders with the same ID can encode compatible streams.* There may be slight deviations from the principle due to implementation* details.** If you add a codec ID to this list, add it so that* 1. no value of an existing codec ID changes (that would break ABI),* 2. it is as close as possible to similar codecs** After adding new codec IDs, do not forget to add an entry to the codec* descriptor list and bump libavcodec minor version.*/
enum AVCodecID {AV_CODEC_ID_NONE,/* video codecs */AV_CODEC_ID_MPEG1VIDEO,AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decodingAV_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_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HLC,AV_CODEC_ID_PFM,AV_CODEC_ID_MOBICLIP,AV_CODEC_ID_PHOTOCD,AV_CODEC_ID_IPU,AV_CODEC_ID_ARGO,AV_CODEC_ID_CRI,AV_CODEC_ID_SIMBIOSIS_IMX,AV_CODEC_ID_SGA_VIDEO,AV_CODEC_ID_GEM,AV_CODEC_ID_VBN,AV_CODEC_ID_JPEGXL,AV_CODEC_ID_QOI,/* various PCM "codecs" */AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecsAV_CODEC_ID_PCM_S16LE = 0x10000,AV_CODEC_ID_PCM_S16BE,AV_CODEC_ID_PCM_U16LE,AV_CODEC_ID_PCM_U16BE,AV_CODEC_ID_PCM_S8,AV_CODEC_ID_PCM_U8,AV_CODEC_ID_PCM_MULAW,AV_CODEC_ID_PCM_ALAW,AV_CODEC_ID_PCM_S32LE,AV_CODEC_ID_PCM_S32BE,AV_CODEC_ID_PCM_U32LE,AV_CODEC_ID_PCM_U32BE,AV_CODEC_ID_PCM_S24LE,AV_CODEC_ID_PCM_S24BE,AV_CODEC_ID_PCM_U24LE,AV_CODEC_ID_PCM_U24BE,AV_CODEC_ID_PCM_S24DAUD,AV_CODEC_ID_PCM_ZORK,AV_CODEC_ID_PCM_S16LE_PLANAR,AV_CODEC_ID_PCM_DVD,AV_CODEC_ID_PCM_F32BE,AV_CODEC_ID_PCM_F32LE,AV_CODEC_ID_PCM_F64BE,AV_CODEC_ID_PCM_F64LE,AV_CODEC_ID_PCM_BLURAY,AV_CODEC_ID_PCM_LXF,AV_CODEC_ID_S302M,AV_CODEC_ID_PCM_S8_PLANAR,AV_CODEC_ID_PCM_S24LE_PLANAR,AV_CODEC_ID_PCM_S32LE_PLANAR,AV_CODEC_ID_PCM_S16BE_PLANAR,AV_CODEC_ID_PCM_S64LE,AV_CODEC_ID_PCM_S64BE,AV_CODEC_ID_PCM_F16LE,AV_CODEC_ID_PCM_F24LE,AV_CODEC_ID_PCM_VIDC,AV_CODE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ARGO,AV_CODEC_ID_ADPCM_IMA_SSI,AV_CODEC_ID_ADPCM_ZORK,AV_CODEC_ID_ADPCM_IMA_APM,AV_CODEC_ID_ADPCM_IMA_ALP,AV_CODEC_ID_ADPCM_IMA_MTF,AV_CODEC_ID_ADPCM_IMA_CUNNING,AV_CODEC_ID_ADPCM_IMA_MOFLEX,AV_CODEC_ID_ADPCM_IMA_ACORN,/* AMR */AV_CODEC_ID_AMR_NB = 0x12000,AV_CODEC_ID_AMR_WB,/* RealAudio codecs*/AV_CODEC_ID_RA_144 = 0x13000,AV_CODEC_ID_RA_288,/* various DPCM codecs */AV_CODEC_ID_ROQ_DPCM = 0x14000,AV_CODEC_ID_INTERPLAY_DPCM,AV_CODEC_ID_XAN_DPCM,AV_CODEC_ID_SOL_DPCM,AV_CODEC_ID_SDX2_DPCM,AV_CODEC_ID_GREMLIN_DPCM,AV_CODEC_ID_DERF_DPCM,/* audio codecs */AV_CODEC_ID_MP2 = 0x15000,AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3AV_CODEC_ID_AAC,AV_CODEC_ID_AC3,AV_CODEC_ID_DTS,AV_CODEC_ID_VORBIS,AV_CODEC_ID_DVAUDIO,AV_CODEC_ID_WMAV1,AV_CODEC_ID_WMAV2,AV_CODEC_ID_MACE3,AV_CODEC_ID_MACE6,AV_CODEC_ID_VMDAUDIO,AV_CODEC_ID_FLAC,AV_CODEC_ID_MP3ADU,AV_CODEC_ID_MP3ON4,AV_CODEC_ID_SHORTEN,AV_CODEC_ID_ALAC,AV_CODEC_ID_WESTWOOD_SND1,AV_CODEC_ID_GSM, ///< as in Berlin toast formatAV_CODEC_ID_QDM2,AV_CODEC_ID_COOK,AV_CODEC_ID_TRUESPEECH,AV_CODEC_ID_TTA,AV_CODEC_ID_SMACKAUDIO,AV_CODEC_ID_QCELP,AV_CODEC_ID_WAVPACK,AV_CODEC_ID_DSICINAUDIO,AV_CODEC_ID_IMC,AV_CODEC_ID_MUSEPAC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ID_DOLBY_E,AV_CODEC_ID_APTX,AV_CODEC_ID_APTX_HD,AV_CODEC_ID_SBC,AV_CODEC_ID_ATRAC9,AV_CODEC_ID_HCOM,AV_CODEC_ID_ACELP_KELVIN,AV_CODEC_ID_MPEGH_3D_AUDIO,AV_CODEC_ID_SIREN,AV_CODEC_ID_HCA,AV_CODEC_ID_FASTAUDIO,AV_CODEC_ID_MSNSIREN,AV_CODEC_ID_DFPWM,/* subtitle codecs */AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.AV_CODEC_ID_DVD_SUBTITLE = 0x17000,AV_CODEC_ID_DVB_SUBTITLE,AV_CODEC_ID_TEXT, ///< raw UTF-8 textAV_CODEC_ID_XSUB,AV_CODEC_ID_SSA,AV_CODEC_ID_MOV_TEXT,AV_CODEC_ID_HDMV_PGS_SUBTITLE,AV_CODEC_ID_DVB_TELETEXT,AV_CODEC_ID_SRT,AV_CODEC_ID_MICRODVD,AV_CODEC_ID_EIA_608,AV_CODEC_ID_JACOSUB,AV_CODEC_ID_SAMI,AV_CODEC_ID_REALTEXT,AV_CODEC_ID_STL,AV_CODEC_ID_SUBVIEWER1,AV_CODEC_ID_SUBVIEWER,AV_CODEC_ID_SUBRIP,AV_CODEC_ID_WEBVTT,AV_CODEC_ID_MPL2,AV_CODEC_ID_VPLAYER,AV_CODEC_ID_PJS,AV_CODEC_ID_ASS,AV_CODEC_ID_HDMV_TEXT_SUBTITLE,AV_CODEC_ID_TTML,AV_CODEC_ID_ARIB_CAPTION,/* other specific kind of codecs (generally used for attachments) */AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.AV_CODEC_ID_TTF = 0x18000,AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream.AV_CODEC_ID_EPG,AV_CODEC_ID_BINTEXT,AV_CODEC_ID_XBIN,AV_CODEC_ID_IDF,AV_CODEC_ID_OTF,AV_CODEC_ID_SMPTE_KLV,AV_CODEC_ID_DVD_NAV,AV_CODEC_ID_TIMED_ID3,AV_CODEC_ID_BIN_DATA,AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify itAV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS* stream (only used by libavformat) */AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems* stream (only used by libavformat) */AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
};
- AVCodecID 位于 codec_id.h文件内
/*** Identify the syntax and semantics of the bitstream.* The principle is roughly:* Two decoders with the same ID can decode the same streams.* Two encoders with the same ID can encode compatible streams.* There may be slight deviations from the principle due to implementation* details.** If you add a codec ID to this list, add it so that* 1. no value of an existing codec ID changes (that would break ABI),* 2. it is as close as possible to similar codecs** After adding new codec IDs, do not forget to add an entry to the codec* descriptor list and bump libavcodec minor version.*/
enum AVCodecID {AV_CODEC_ID_NONE,/* video codecs */AV_CODEC_ID_MPEG1VIDEO,AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decodingAV_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,AV_CODEC_ID_INDEO3,AV_CODEC_ID_VP3,AV_CODEC_ID_THEORA,AV_CODEC_ID_ASV1,AV_CODEC_ID_ASV2,AV_CODEC_ID_FFV1,AV_CODEC_ID_4XM,AV_CODEC_ID_VCR1,AV_CODEC_ID_CLJR,AV_CODEC_ID_MDEC,AV_CODEC_ID_ROQ,AV_CODEC_ID_INTERPLAY_VIDEO,AV_CODEC_ID_XAN_WC3,AV_CODEC_ID_XAN_WC4,AV_CODEC_ID_RPZA,AV_CODEC_ID_CINEPAK,AV_CODEC_ID_WS_VQA,AV_CODEC_ID_MSRLE,AV_CODEC_ID_MSVIDEO1,AV_CODEC_ID_IDCIN,AV_CODEC_ID_8BPS,AV_CODEC_ID_SMC,
此处省略 几百行
}
- AVPixelFormat位于pixfmt.h文件内
/*** Pixel format.** @note* AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA* color is put together as:* (A << 24) | (R << 16) | (G << 8) | B* This is stored as BGRA on little-endian CPU architectures and ARGB on* big-endian CPUs.** @note* If the resolution is not a multiple of the chroma subsampling factor* then the chroma plane resolution must be rounded up.** @par* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized* image data is stored in AVFrame.data[0]. The palette is transported in* AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is* formatted the same as in AV_PIX_FMT_RGB32 described above (i.e., it is* also endian-specific). Note also that the individual RGB32 palette* components stored in AVFrame.data[1] should be in the range 0..255.* This is important as many custom PAL8 video codecs that were designed* to run on the IBM VGA graphics adapter use 6-bit palette components.** @par* For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like* for pal8. This palette is filled in automatically by the function* allocating the picture.*/
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 CrAV_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 , 8bppAV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsbAV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsbAV_PIX_FMT_PAL8, ///< 8 bits with AV_PIX_FMT_RGB32 paletteAV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_rangeAV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting color_rangeAV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting color_rangeAV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bitsAV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bitsAV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swappedAV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endianAV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endianAV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_rangeAV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endianAV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endianAV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endianAV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endianAV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefinedAV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefinedAV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endianAV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endianAV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefinedAV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined/*** Hardware acceleration through VA-API, data[3] contains a* VASurfaceID.*/AV_PIX_FMT_VAAPI,AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endianAV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endianAV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endianAV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endianAV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endianAV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endianAV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointerAV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefinedAV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefinedAV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefinedAV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefinedAV_PIX_FMT_YA8, ///< 8 bits gray, 8 bits alphaAV_PIX_FMT_Y400A = AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8AV_PIX_FMT_GRAY8A= AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8
此处省略 几百行}
- AVSampleFormat 位于samplefmt.h文件中
/*** Audio sample formats** - The data described by the sample format is always in native-endian order.* Sample values can be expressed by native C types, hence the lack of a signed* 24-bit sample format even though it is a common raw audio data format.** - The floating-point formats are based on full volume being in the range* [-1.0, 1.0]. Any values outside this range are beyond full volume level.** - The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg* (such as AVFrame in libavcodec) is as follows:** @par* For planar sample formats, each audio channel is in a separate data plane,* and linesize is the buffer size, in bytes, for a single plane. All data* planes must be the same size. For packed sample formats, only the first data* plane is used, and samples for each channel are interleaved. In this case,* linesize is the buffer size, in bytes, for the 1 plane.**/
enum AVSampleFormat {AV_SAMPLE_FMT_NONE = -1,AV_SAMPLE_FMT_U8, ///< unsigned 8 bitsAV_SAMPLE_FMT_S16, ///< signed 16 bitsAV_SAMPLE_FMT_S32, ///< signed 32 bitsAV_SAMPLE_FMT_FLT, ///< floatAV_SAMPLE_FMT_DBL, ///< doubleAV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planarAV_SAMPLE_FMT_S16P, ///< signed 16 bits, planarAV_SAMPLE_FMT_S32P, ///< signed 32 bits, planarAV_SAMPLE_FMT_FLTP, ///< float, planarAV_SAMPLE_FMT_DBLP, ///< double, planarAV_SAMPLE_FMT_S64, ///< signed 64 bitsAV_SAMPLE_FMT_S64P, ///< signed 64 bits, planarAV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
};
- 每一个编解码器对应一个结构体
- H.264解码器的结构体如下所示(h264dec.c)
const FFCodec ff_h264_decoder = {.p.name = "h264",.p.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),.p.type = AVMEDIA_TYPE_VIDEO,.p.id = AV_CODEC_ID_H264,.priv_data_size = sizeof(H264Context),.init = h264_decode_init,.close = h264_decode_end,FF_CODEC_DECODE_CB(h264_decode_frame),.p.capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 |AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |AV_CODEC_CAP_FRAME_THREADS,.hw_configs = (const AVCodecHWConfigInternal *const []) {
#if CONFIG_H264_DXVA2_HWACCELHWACCEL_DXVA2(h264),
#endif
#if CONFIG_H264_D3D11VA_HWACCELHWACCEL_D3D11VA(h264),
#endif
#if CONFIG_H264_D3D11VA2_HWACCELHWACCEL_D3D11VA2(h264),
#endif
#if CONFIG_H264_NVDEC_HWACCELHWACCEL_NVDEC(h264),
#endif
#if CONFIG_H264_VAAPI_HWACCELHWACCEL_VAAPI(h264),
#endif
#if CONFIG_H264_VDPAU_HWACCELHWACCEL_VDPAU(h264),
#endif
#if CONFIG_H264_VIDEOTOOLBOX_HWACCELHWACCEL_VIDEOTOOLBOX(h264),
#endifNULL},.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING |FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,.flush = h264_decode_flush,.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),.update_thread_context_for_user = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context_for_user),.p.profiles = NULL_IF_CONFIG_SMALL(ff_h264_profiles),.p.priv_class = &h264_class,
};
- JPEG2000解码器结构体位于jpeg2000dec.c
const FFCodec ff_jpeg2000_decoder = {.p.name = "jpeg2000",.p.long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),.p.type = AVMEDIA_TYPE_VIDEO,.p.id = AV_CODEC_ID_JPEG2000,.p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_DR1,.priv_data_size = sizeof(Jpeg2000DecoderContext),.init = jpeg2000_decode_init,FF_CODEC_DECODE_CB(jpeg2000_decode_frame),.p.priv_class = &jpeg2000_class,.p.max_lowres = 5,.p.profiles = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles),.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
- 以下内容最新版 已经删除
下面简单介绍一下遍历ffmpeg中的解码器信息的方法(这些解码器以一个链表的形式存储):
1.注册所有编解码器:av_register_all();
2.声明一个AVCodec类型的指针,比如说AVCodec* first_c;
3.调用av_codec_next()函数,即可获得指向链表下一个解码器的指针,循环往复可以获得所有解码器的信息。注意,如果想要获得指向第一个解码器的指针,则需要将该函数的参数设置为NULL。
代码
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. //您应该使用 NULL_IF_CONFIG_SMALL() 宏来定义它*/const char *long_name;enum AVMediaType type;enum AVCodecID id;/*** Codec capabilities. //编解码器功能* see AV_CODEC_CAP_**/int capabilities;uint8_t max_lowres; ///< maximum value for lowres supported by the decoder //解码器支持的低分辨率最大值const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} //支持的帧率数组,如果有,则为 NULL,数组由 {0,0} 终止const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 //支持的像素格式数组,如果未知,则为 NULL,数组由 -1 终止const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 //支持的音频采样率数组,如果未知,则为 NULL,数组以 0 终止const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 //支持的样本格式数组,如果未知,则为 NULL,数组以 -1 终止
#if FF_API_OLD_CHANNEL_LAYOUT/*** @deprecated use ch_layouts instead //改用 ch_layouts*/attribute_deprecatedconst uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 //支持通道布局的数组,如果未知,则为 NULL。 数组以 0 结束
#endifconst AVClass *priv_class; ///< AVClass for the private context //私有上下文的 AVClassconst AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}///已识别配置文件的数组,如果未知,则为 NULL,数组由 {FF_PROFILE_UNKNOWN} 终止/*** Group name of the codec implementation. //编解码器实现的组名* This is a short symbolic name of the wrapper backing this codec. A* wrapper uses some kind of external implementation for the codec, such* as an external library, or a codec implementation provided by the OS or* the hardware.* 这是支持此编解码器的包装器的简短符号名称。包装器为编解码器使用某种外部实现,* 例如外部库,或者由操作系统或硬件提供的编解码器实现 ** If this field is NULL, this is a builtin, libavcodec native codec.* If non-NULL, this will be the suffix in AVCodec.name in most cases* (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>").* 如果此字段为 NULL,则这是一个内置的 libavcodec 本机编解码器* 如果非 NULL,在大多数情况下,这将是 AVCodec.name 中的后缀(通常 AVCodec.name * 的格式为“<codec_name>_<wrapper_name>”)*/const char *wrapper_name;/*** Array of supported channel layouts, terminated with a zeroed layout.* 支持的通道布局数组,以归零布局终止*/const AVChannelLayout *ch_layouts;
} AVCodec;