Skip to content

Commit

Permalink
fixup! lavc/rkmppdec: refactor RKMPP decoders and extend codecs
Browse files Browse the repository at this point in the history
Add HwFramesContext config method support.
  • Loading branch information
boogieeeee authored and nyanmisaka committed Jan 1, 2024
1 parent 9e73140 commit 6584518
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
35 changes: 23 additions & 12 deletions libavcodec/rkmppdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -644,10 +650,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);
Expand Down
1 change: 1 addition & 0 deletions libavcodec/rkmppdec.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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,
},
Expand Down

0 comments on commit 6584518

Please sign in to comment.