当前位置:网站首页>ffmpeg 枚举decoders, encoders 分析
ffmpeg 枚举decoders, encoders 分析
2022-08-05 03:08:00 【hjjdebug】
ffmpeg 枚举decoders, encoders 分析
$ffmpeg -decoders
调用 print_codecs(0);
$ffmpeg -encoders
调用 print_codecs(1);
$ffmpeg -codecs
调用 show_codecs() 跟单列出一种大同小异。
下面对 print_codecs ()进行代码分析。
第一步, 获取所有codecs 描述符
const AVCodecDescriptor **codecs;
unsigned i, nb_codecs = get_codecs_sorted(&codecs);
怎样获取codecs 描述符指针的指针?
原来codec_descriptors[] 是一个大大的数组。codec 描述符是一个结构。
static const AVCodecDescriptor codec_descriptors[] = {
/* video codecs */
{
.id = AV_CODEC_ID_MPEG1VIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "mpeg1video",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
},
{
.id = AV_CODEC_ID_MPEG2VIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "mpeg2video",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
},
{
.id = AV_CODEC_ID_H261,
.type = AVMEDIA_TYPE_VIDEO,
.name = "h261",
.long_name = NULL_IF_CONFIG_SMALL("H.261"),
.props = AV_CODEC_PROP_LOSSY,
},
... //忽略, 很多
};
typedef struct AVCodecDescriptor {
enum AVCodecID id;
enum AVMediaType type;
const char *name;
const char *long_name;
int props;
const char *const *mime_types;
const struct AVProfile *profiles;
} AVCodecDescriptor;
该函数要做的只是把描述符指针组织成一个数组而已. 采用了2次扫描原则,
第一遍获得了个数, 然后分配了指针内存,第二遍把各地址填充了进去。
第二步,由id可以获得对应的codec指针。
codec 列表也定义了一个大的数组。
static const AVCodec * const codec_list[] = {
&ff_a64multi_encoder,
&ff_a64multi5_encoder,
&ff_alias_pix_encoder,
&ff_amv_encoder,
&ff_apng_encoder,
&ff_asv1_encoder,
&ff_asv2_encoder,
&ff_avrp_encoder,
.... // 很多,180个encoder, 480个decoder
}
每种codec 是一种对象,其对应的类为:
type = const struct AVCodec {
const char *name;
const char *long_name;
enum AVMediaType type;
enum AVCodecID id;
int capabilities;
const AVRational *supported_framerates;
const enum AVPixelFormat *pix_fmts;
const int *supported_samplerates;
const enum AVSampleFormat *sample_fmts;
const uint64_t *channel_layouts;
uint8_t max_lowres;
const AVClass *priv_class;
const AVProfile *profiles;
const char *wrapper_name;
int priv_data_size;
struct AVCodec *next;
int (*update_thread_context)(struct AVCodecContext *, const struct AVCodecContext *);
const AVCodecDefault *defaults;
void (*init_static_data)(struct AVCodec *);
int (*init)(struct AVCodecContext *);
int (*encode_sub)(struct AVCodecContext *, uint8_t *, int, const struct AVSubtitle *);
int (*encode2)(struct AVCodecContext *, struct AVPacket *, const struct AVFrame *, int *);
int (*decode)(struct AVCodecContext *, void *, int *, struct AVPacket *);
int (*close)(struct AVCodecContext *);
int (*receive_packet)(struct AVCodecContext *, struct AVPacket *);
int (*receive_frame)(struct AVCodecContext *, struct AVFrame *);
void (*flush)(struct AVCodecContext *);
int caps_internal;
const char *bsfs;
const struct AVCodecHWConfigInternal * const *hw_configs;
const uint32_t *codec_tags;
}
当你实现一种codec 时,可能只要实现必需的几个函数接口就可以了。
列出codec 列表,也只是枚举各codec,打印了其能力,名称,长名称而已.
分析以后发现,概念比较简单,属于数据组织而已。
边栏推荐
- J9 Digital Currency: What is the creator economy of web3?
- 语法基础(变量、输入输出、表达式与顺序语句)
- Syntax basics (variables, input and output, expressions and sequential statements)
- A small tool to transfer files using QR code - QFileTrans 1.2.0.1
- Common open source databases under Linux, how many do you know?
- Physical backup issues caused by soft links
- 1873. 计算特殊奖金
- OpenGL 工作原理
- Lexicon - the maximum depth of a binary tree
- 龙蜥社区第二届理事大会圆满召开!理事换届选举、4 位特约顾问加入
猜你喜欢

The design idea of DMicro, the Go microservice development framework

21天学习挑战赛(2)图解设备树的使用

虚拟内存原理与技术

How OpenGL works

word分栏小记

QT MV\MVC结构

J9 Digital Currency: What is the creator economy of web3?

OpenGL 工作原理

QT语言文件制作

IJCAI2022 | DictBert: Pre-trained Language Models with Contrastive Learning for Dictionary Description Knowledge Augmentation
随机推荐
【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can
Open Source License Description LGPL
Details such as compiling pretreatment
How Jin Cang database correctness verification platform installation file
Distributed systems revisited: there will never be a perfect consistency scheme...
优炫数据库的单节点如何转集群
北斗三号短报文终端露天矿山高边坡监测方案
private package
.NET应用程序--Helloworld(C#)
private封装
The pit of std::string::find return value
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
用CH341A烧录外挂Flash (W25Q16JV)
静态方法获取配置文件数据
Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
人人都在说的数据中台,你需要关注的核心特点是什么?
mysql can't Execute, please solve it
虚拟内存原理与技术
Why did they choose to fall in love with AI?
AI+PROTAC | dx/tx completes $5 million seed round