当前位置:网站首页>ffmpeg enumeration decoders, encoders analysis
ffmpeg enumeration decoders, encoders analysis
2022-08-05 03:19:00 【hjjdebug】
ffmpeg 枚举decoders, encoders 分析
$ffmpeg -decoders
调用 print_codecs(0);
$ffmpeg -encoders
调用 print_codecs(1);
$ffmpeg -codecs
调用 show_codecs() Document a list of similarities.
下面对 print_codecs ()进行代码分析.
第一步, 获取所有codecs 描述符
const AVCodecDescriptor **codecs;
unsigned i, nb_codecs = get_codecs_sorted(&codecs);
怎样获取codecs Pointer to the descriptor pointer?
原来codec_descriptors[] is a large array.codec A descriptor is a structure.
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;
All this function does is organize the descriptor pointers into an array. 采用了2Sub-scanning principle,
Got the number the first time, Then pointer memory is allocated,The second pass fills in the addresses.
第二步,由id可以获得对应的codec指针.
codec Lists also define a large array.
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;
}
when you implement onecodec 时,It may be enough to implement the required few functional interfaces.
列出codec 列表,Also just enumerate eachcodec,Its capabilities are printed,名称,long name only.
found after analysis,概念比较简单,It's just a data organization.
边栏推荐
- 2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
- Programmer's Tanabata Romantic Moment
- The Tanabata copywriting you want has been sorted out for you!
- 冰蝎V4.0攻击来袭,安全狗产品可全面检测
- Summary of domestic environments supported by SuperMap
- 运维监控系统之Open-Falcon
- 引领数字医学高地,中山医院探索打造未来医院“新范式”
- public static <T> List<T> asList(T... a) 原型是怎么回事?
- QT language file production
- 链表的简单描述及代码的简单实现
猜你喜欢
Step by step how to perform data risk assessment
How to Add Category-Specific Widgets in WordPress
Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
The Tanabata copywriting you want has been sorted out for you!
Is your data safe in this hyperconnected world?
How Jin Cang database correctness verification platform installation file
21天学习挑战赛(2)图解设备树的使用
Why did they choose to fall in love with AI?
After the large pixel panorama is completed, what are the promotion methods?
The usage of try...catch and finally in js
随机推荐
队列题目:最近的请求次数
Cybersecurity and the Metaverse: Identifying Weak Links
21 Days Learning Challenge (2) Use of Graphical Device Trees
Linux下常见的开源数据库,你知道几个?
Solve the problem of port occupancy Port xxxx was already in use
21天学习挑战赛(2)图解设备树的使用
Physical backup issues caused by soft links
rpc-remote procedure call demo
private封装
J9 Digital Currency: What is the creator economy of web3?
人人都在说的数据中台,你需要关注的核心特点是什么?
How Jin Cang database correctness verification platform installation file
Thinking (88): Use protobuf custom options for multi-version management of data
Likou - preorder traversal, inorder traversal, postorder traversal of binary tree
The linear table lookup
【Daily Training】1403. Minimum Subsequence in Non-Increasing Order
今年七夕,「情蔬」比礼物更有爱
2022.8.4-----leetcode.1403
How to sort multiple fields and multiple values in sql statement
Object.defineProperty monitors data changes in real time and updates the page