当前位置:网站首页>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,打印了其能力,名称,长名称而已.
分析以后发现,概念比较简单,属于数据组织而已。
边栏推荐
- Turn: Charles Handy: Who you are is more important than what you do
- Snapback - same tree
- 1667. 修复表中的名字
- Solve the problem of port occupancy Port xxxx was already in use
- Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors
- 论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
- Step by step how to perform data risk assessment
- 627. 变更性别
- 软链接引发的物理备份问题
- 【滤波跟踪】基于matlab无迹卡尔曼滤波惯性导航+DVL组合导航【含Matlab源码 2019期】
猜你喜欢

金仓数据库如何验证安装文件平台正确性

Use SuperMap iDesktopX data migration tool to migrate ArcGIS data

Compressed storage of special matrices

告白数字化转型时代,时速云镌刻价值新起点

论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕

Question about #sql shell#, how to solve it?

IJCAI2022 | DictBert: Pre-trained Language Models with Contrastive Learning for Dictionary Description Knowledge Augmentation

.NET Application -- Helloworld (C#)

通过模拟Vite一起深入其工作原理

2022-08-04 第六小组 瞒春 学习笔记
随机推荐
解决端口占用问题 Port xxxx was already in use
2022 High-level installation, maintenance, and removal of exam questions mock exam question bank and online mock exam
Physical backup issues caused by soft links
How to solve the error cannot update secondary snapshot during a parallel operation when the PostgreSQL database uses navicat to open the table structure?
Use @Mapper to query the partition status of oracle and report an error
Details such as compiling pretreatment
1873. 计算特殊奖金
AI + Small Nucleic Acid Drugs | Eleven Completes $22 Million Seed Round Financing
sql server 安装提示用户名不存在
Hash table lookup (hash table)
使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
2022-08-04 第六小组 瞒春 学习笔记
Everyone in China said data, you need to focus on core characteristic is what?
2022-08-04 The sixth group, hidden from spring, study notes
[Filter tracking] based on matlab unscented Kalman filter inertial navigation + DVL combined navigation [including Matlab source code 2019]
The Tanabata copywriting you want has been sorted out for you!
静态方法获取配置文件数据
.NET Application -- Helloworld (C#)
ASP.NET application--Hello World
[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)