fixup! lavc/rkmppdec: refactor RKMPP decoders and extend codecs

Add HwFramesContext config method support.
This commit is contained in:
boogie 2024-01-19 02:03:13 +08:00 committed by nyanmisaka
parent 2938ac0758
commit d0a1484db4
2 changed files with 24 additions and 12 deletions

View file

@ -136,22 +136,28 @@ static av_cold int rkmpp_decode_init(AVCodecContext *avctx)
is_fmt_supported =
avctx->codec_id == AV_CODEC_ID_H264;
break;
case AV_PIX_FMT_NONE: /* fallback to drm_prime */
is_fmt_supported = 1;
avctx->pix_fmt = AV_PIX_FMT_DRM_PRIME;
break;
default:
is_fmt_supported = 0;
break;
}
if (!is_fmt_supported) {
av_log(avctx, AV_LOG_ERROR, "MPP doesn't support codec '%s' with pix_fmt '%s'\n",
avcodec_get_name(avctx->codec_id), av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR(ENOSYS);
}
if (avctx->pix_fmt != AV_PIX_FMT_DRM_PRIME) {
if (!is_fmt_supported) {
av_log(avctx, AV_LOG_ERROR, "MPP doesn't support codec '%s' with pix_fmt '%s'\n",
avcodec_get_name(avctx->codec_id), av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR(ENOSYS);
}
if ((ret = ff_get_format(avctx, pix_fmts)) < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", ret);
return ret;
if ((ret = ff_get_format(avctx, pix_fmts)) < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", ret);
return ret;
}
avctx->pix_fmt = ret;
}
avctx->pix_fmt = ret;
if ((coding_type = rkmpp_get_coding_type(avctx)) == MPP_VIDEO_CodingUnused) {
av_log(avctx, AV_LOG_ERROR, "Unknown codec id: %d\n", avctx->codec_id);
@ -645,10 +651,15 @@ static int rkmpp_get_frame(AVCodecContext *avctx, AVFrame *frame, int timeout)
av_log(avctx, AV_LOG_VERBOSE, "AFBC is requested but not supported\n");
pix_fmts[1] = rkmpp_get_av_format(mpp_fmt & MPP_FRAME_FMT_MASK);
if ((ret = ff_get_format(avctx, pix_fmts)) < 0)
goto exit;
avctx->pix_fmt = ret;
if (avctx->pix_fmt == AV_PIX_FMT_DRM_PRIME)
avctx->sw_pix_fmt = pix_fmts[1];
else {
if ((ret = ff_get_format(avctx, pix_fmts)) < 0)
goto exit;
avctx->pix_fmt = ret;
}
avctx->width = mpp_frame_get_width(mpp_frame);
avctx->height = mpp_frame_get_height(mpp_frame);
avctx->coded_width = FFALIGN(avctx->width, 64);

View file

@ -115,6 +115,7 @@ static const AVCodecHWConfigInternal *const rkmpp_dec_hw_configs[] = {
.public = {
.pix_fmt = AV_PIX_FMT_DRM_PRIME,
.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
.device_type = AV_HWDEVICE_TYPE_RKMPP,
},