在做ffmpeg decode插件的时候,发现需要增加一个AVCodecHWConfigInternal数组,
//就是这个数组
static const AVCodecHWConfigInternal *efcodec_hw_configs[] = {
&(const AVCodecHWConfigInternal) {
.public= {
.pix_fmt = AV_PIX_FMT_EFCCODEC,
.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
.device_type = AV_HWDEVICE_TYPE_EFCODEC
},
.hwaccel = NULL,
},
NULL
};
#define EFCODEC_CLASS(NAME) \
static const AVClass efcodec_ ## NAME ## _dec_class = { \
.class_name = #NAME "_efcodec_decoder", \
.item_name = av_default_item_name, \
.option = options, \
.version = LIBAVUTIL_VERSION_INT, \
};
#define EFCODECDEC(NAME, LONGNAME, CODEC, bsf_name) \
EFCODEC_CLASS(NAME) \
const AVCodec ff_ ## NAME ## _efcodec_decoder = { \
.name = #NAME "_efcodec" , \
.long_name = NULL_IF_CONFIG_SMALL("EFCODEC DEC " LONGNAME " decoder wrapper"), \
.type = AVMEDIA_TYPE_VIDEO, \
.id = CODEC , \
.priv_data_size = sizeof(EFCodecDecContext_t), \
.priv_class = &efcodec_ ## NAME ## _dec_class, \
.init = efcodec_decode_init, \
.receive_frame = efcodec_receive_frame, \
.close = efcodec_decode_close, \
.bsfs = bsf_name, \
.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_EFCCODEC, AV_PIX_FMT_YUV420P, \
AV_PIX_FMT_NV12, AV_PIX_FMT_NV21, \
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB24P, \
AV_PIX_FMT_BGR24, AV_PIX_FMT_BGR24P, \
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P10LE,\
AV_PIX_FMT_P010, AV_PIX_FMT_P010LE, \
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10, AV_PIX_FMT_NONE }, \
.hw_configs = efcodec_hw_configs, \
.wrapper_name = "efcodec", \
}
一直不清楚这个结构是做干什么用的,后来看ffmpeg.c的时候发现,实在avcodec_get_hw_config()函数中使用:
const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
{
int i;
if (!codec->hw_configs || index < 0)
return NULL;
for (i = 0; i <= index; i++)
if (!codec->hw_configs[i])
return NULL;
return &codec->hw_configs[index]->public;
}
不过大多数时候都是设置为NULL