static void register_all(void)
allformats.c (libavformat)
#include “libavformat/avformat.h”
void avcodec_register_all(void)
allcodecs.c (libavcodec)
#include “libavformat/ avcodec.h”
函数调用关系图如下图所示。av_register_all()调用了avcodec_register_all()。avcodec_register_all()注册了和编解码器有关的组件:硬件加速器,解码器,编码器,Parser,Bitstream Filter。av_register_all()除了调用avcodec_register_all()之外,还注册了复用器,解复用器,协议处理器。
该函数在所有基于ffmpeg的应用程序中几乎都是第一个被调用的。只有调用了该函数,才能使用复用器,编码器等
Ps: 此函数的目的就是将实实在在的组件(编解码器AVCodec 硬件加速器AVHWAccel 分析器 AVCodecParser 复用器AvInputFormat 解复用器AvOutputFormat 等 )注册到系统链表中 以备后续使用
下面列举几个实实在在的组件:
AVInputFormat ff_live_flv_demuxer = { .name = "live_flv", .long_name = NULL_IF_CONFIG_SMALL("live RTMP FLV (Flash Video)"), .priv_data_size = sizeof(FLVContext), .read_probe = live_flv_probe, .read_header = flv_read_header, .read_packet = flv_read_packet, .read_seek = flv_read_seek, .read_close = flv_read_close, .extensions = "flv", .priv_class = &live_flv_class, .flags = AVFMT_TS_DISCONT};
AVCodec ff_flv_encoder = {
.name = "flv",
.long_name = NULL_IF_CONFIG_SMALL("FLV / SorensonSpark / Sorenson H.263 (Flash Video)"),
.type =AVMEDIA_TYPE_VIDEO,
.id =AV_CODEC_ID_FLV1,
.priv_data_size = sizeof(MpegEncContext),
.init =ff_mpv_encode_init,
.encode2 =ff_mpv_encode_picture,
.close =ff_mpv_encode_end,
.pix_fmts = (const enumAVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE},
.priv_class = &flv_class,
};