lavc/rkmppdec: allow to set decoder options from env

This allows decoder options to be overriden via env FFMPEG_RKMPP_DEC_OPT
where the client has not support to change the decoder options.
Additionally AVOptions are printed as VERBOSE on infochange.
This commit is contained in:
boogie 2024-01-28 01:10:45 +08:00 committed by nyanmisaka
parent 1a9a968810
commit 99ea69d6d4

View file

@ -140,11 +140,16 @@ static av_cold int rkmpp_decode_init(AVCodecContext *avctx)
{
RKMPPDecContext *r = avctx->priv_data;
MppCodingType coding_type = MPP_VIDEO_CodingUnused;
const char *opts_env = NULL;
int ret, is_fmt_supported = 0;
enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_DRM_PRIME,
AV_PIX_FMT_NV12,
AV_PIX_FMT_NONE };
opts_env = getenv("FFMPEG_RKMPP_DEC_OPT");
if (opts_env && av_set_options_string(r, opts_env, "=", " ") <= 0)
av_log(avctx, AV_LOG_WARNING, "Unable to set decoder options from env\n");
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUVJ420P:
@ -676,6 +681,7 @@ static int rkmpp_get_frame(AVCodecContext *avctx, AVFrame *frame, int timeout)
}
if (r->info_change = mpp_frame_get_info_change(mpp_frame)) {
char *opts = NULL;
int fast_parse = r->fast_parse;
int mpp_frame_mode = mpp_frame_get_mode(mpp_frame);
const MppFrameFormat mpp_fmt = mpp_frame_get_fmt(mpp_frame);
@ -685,8 +691,10 @@ static int rkmpp_get_frame(AVCodecContext *avctx, AVFrame *frame, int timeout)
av_log(avctx, AV_LOG_VERBOSE, "Noticed an info change\n");
if (r->afbc && !(mpp_fmt & MPP_FRAME_FBC_MASK))
if (r->afbc && !(mpp_fmt & MPP_FRAME_FBC_MASK)) {
av_log(avctx, AV_LOG_VERBOSE, "AFBC is requested but not supported\n");
r->afbc = 0;
}
pix_fmts[1] = rkmpp_get_av_format(mpp_fmt & MPP_FRAME_FMT_MASK);
@ -704,6 +712,9 @@ static int rkmpp_get_frame(AVCodecContext *avctx, AVFrame *frame, int timeout)
avctx->coded_height = FFALIGN(avctx->height, 64);
rkmpp_export_avctx_color_props(avctx, mpp_frame);
if (av_opt_serialize(r, 0, 0, &opts, '=', ' ') >= 0)
av_log(avctx, AV_LOG_VERBOSE, "Decoder options: %s\n", opts);
av_log(avctx, AV_LOG_VERBOSE, "Configured with size: %dx%d | pix_fmt: %s | sw_pix_fmt: %s\n",
avctx->width, avctx->height,
av_get_pix_fmt_name(avctx->pix_fmt),