当前位置:网站首页>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,打印了其能力,名称,长名称而已.
分析以后发现,概念比较简单,属于数据组织而已。
边栏推荐
- IJCAI2022 | DictBert: Pre-trained Language Models with Contrastive Learning for Dictionary Description Knowledge Augmentation
- 数学-求和符号的性质
- Countdown to 2 days|Cloud native Meetup Guangzhou Station, waiting for you!
- Everyone in China said data, you need to focus on core characteristic is what?
- Likou - preorder traversal, inorder traversal, postorder traversal of binary tree
- One hundred - day plan -- -- DAY2 brush
- 语法基础(变量、输入输出、表达式与顺序语句)
- 链表的简单描述及代码的简单实现
- CPDA|How Operators Learn Data Analysis (SQL) from Negative Foundations
- QT MV\MVC结构
猜你喜欢
2022-08-04 The sixth group, hidden from spring, study notes
北斗三号短报文终端露天矿山高边坡监测方案
Dynamic management of massive service instances
How Jin Cang database correctness verification platform installation file
IJCAI2022 | DictBert: Pre-trained Language Models with Contrastive Learning for Dictionary Description Knowledge Augmentation
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
静态方法获取配置文件数据
A small tool to transfer files using QR code - QFileTrans 1.2.0.1
dmp(dump)转储文件
Flink 1.15.1 Cluster Construction (StandaloneSession)
随机推荐
虚拟内存原理与技术
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
【 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
QT MV\MVC structure
1667. 修复表中的名字
Data to enhance Mixup principle and code reading
(11) Metaclass
Open Source License Description LGPL
Syntax basics (variables, input and output, expressions and sequential statements)
Never put off till tomorrow what you can put - house lease management system based on the SSM
语法基础(变量、输入输出、表达式与顺序语句)
How to transfer a single node of Youxuan database to a cluster
金仓数据库如何验证安装文件平台正确性
Data storage practice based on left-order traversal
剑指Offer--找出数组中重复的数字(三种解法)
Solve the problem of port occupancy Port xxxx was already in use
Syntax basics (variables, input and output, expressions and sequential statements)
链表的简单描述及代码的简单实现
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
如何在WordPress中添加特定类别的小工具