`Hey, I write a ffmpeg codec based on openmax. It can run success with my test code or ffmpeg test. However it run with error when I use it in chrome. The error is [3845:3880:0710/110530.508867:ERROR:ffmpeg_video_decoder.cc(487)] avcodec_open2 failed.-558323010 [3845:3880:0710/110530.509921:ERROR:ffmpeg_video_decoder.cc(491)] avcodec_open2 error: Internal bug, should not have happened
now I am confused with open the ffmpeg logging in chrome , so I can't resolve this problem.
The following is my codec settings:
#define OFFSET(x) offsetof(OMXCodecDecoderContext, x)
#define VDE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "omx_libname", "OpenMAX library name", OFFSET(libname), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "omx_libprefix", "OpenMAX library prefix", OFFSET(libprefix), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "profile", "Set the Decoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_H264_HIGH, VE, "profile" },
{ "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_BASELINE }, 0, 0, VE, "profile" },
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_MAIN }, 0, 0, VE, "profile" },
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_HIGH }, 0, 0, VE, "profile" },
{ NULL }
};
static const AVCodecHWConfigInternal *const omx_hw_configs[] = {
&(const AVCodecHWConfigInternal) {
.public = {
.pix_fmt = AV_PIX_FMT_NV12,
.methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
.device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
},
.hwaccel = NULL,
},
NULL
};
static const AVOption ff_omxcodec_vdec_options[] = {
{ "delay_flush", "Delay flush until hw output buffers are returned to the decoder",
OFFSET(delay_flush), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD },
{ NULL }
};
#define DECLARE_OMX_VCLASS(short_name) \
static const AVClass ff_##short_name##_omxcodec_dec_class = { \
.class_name = #short_name "_libomxh264", \
.item_name = av_default_item_name, \
.option = ff_omxcodec_vdec_options, \
.version = LIBAVUTIL_VERSION_INT, \
};
#define DECLARE_OMX_VDEC(short_name, full_name, codec_id, bsf) \
DECLARE_OMX_VCLASS(short_name) \
const FFCodec ff_ ## short_name ## _omx_decoder = { \
.p.name = #short_name "_omxcodec", \
CODEC_LONG_NAME(full_name " OpenMAX IL decoder"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = codec_id, \
.p.priv_class = &ff_##short_name##_omxcodec_dec_class, \
.priv_data_size = sizeof(OMXCodecDecoderContext), \
.init = omx_decode_init, \
FF_CODEC_DECODE_CB(omx_decode_frame), \
.close = omx_decode_end, \
.flush = omx_decode_flush, \
.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_SETS_PKT_DTS, \
.bsfs = bsf, \
.hw_configs = omx_hw_configs, \
.p.wrapper_name = "omxcodec", \
};
DECLARE_OMX_VDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb")
DECLARE_OMX_VDEC(hevc, "H.265", AV_CODEC_ID_HEVC, "hevc_mp4toannexb")
DECLARE_OMX_VDEC(mpeg4, "MPEG-4", AV_CODEC_ID_MPEG4, NULL)
can someone give me a advice to resolve this problem?