当前位置:网站首页>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.
边栏推荐
- Cybersecurity and the Metaverse: Identifying Weak Links
- 2022-08-04 第六小组 瞒春 学习笔记
- The linear table lookup
- 引领数字医学高地,中山医院探索打造未来医院“新范式”
- 21天学习挑战赛(2)图解设备树的使用
- 1667. Fix names in tables
- 基于生长的棋盘格角点检测方法
- 冒泡排序与快速排序
- Object.defineProperty monitors data changes in real time and updates the page
- 使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
猜你喜欢
Matlab drawing 3
Leading the highland of digital medicine, Zhongshan Hospital explores to create a "new paradigm" for future hospitals
tree table lookup
引领数字医学高地,中山医院探索打造未来医院“新范式”
通过模拟Vite一起深入其工作原理
[Solved] Unity Coroutine coroutine is not executed effectively
Step by step how to perform data risk assessment
The Tanabata copywriting you want has been sorted out for you!
.NET应用程序--Helloworld(C#)
基于生长的棋盘格角点检测方法
随机推荐
The Tanabata copywriting you want has been sorted out for you!
告白数字化转型时代,时速云镌刻价值新起点
Chinese characters to Pinyin
.NET Application -- Helloworld (C#)
[Storage] Dawning Storage DS800-G35 ISCSI maps each LUN to the server
Object.defineProperty monitors data changes in real time and updates the page
shell脚本:for循环与while循环
AI+PROTAC | dx/tx completes $5 million seed round
如何在WordPress中添加特定类别的小工具
2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
Talking about data security governance and privacy computing
Solve the problem of port occupancy Port xxxx was already in use
AI + Small Nucleic Acid Drugs | Eleven Completes $22 Million Seed Round Financing
The usage of try...catch and finally in js
STM32 uses stm32cubemx LL library series tutorial
private package
【Daily Training】1403. Minimum Subsequence in Non-Increasing Order
Distributed systems revisited: there will never be a perfect consistency scheme...
冰蝎V4.0攻击来袭,安全狗产品可全面检测
Cybersecurity and the Metaverse: Identifying Weak Links