lavc/rkmppenc: add support for enabling intra refresh (GDR)

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
nyanmisaka 2025-09-26 18:34:19 +08:00
parent 88e527cb47
commit 3dbfaebfeb
2 changed files with 20 additions and 0 deletions

View file

@ -539,6 +539,15 @@ static int rkmpp_set_enc_cfg(AVCodecContext *avctx)
mpp_enc_cfg_set_s32(cfg, "rc:qp_min", qp_min);
mpp_enc_cfg_set_s32(cfg, "rc:qp_max_i",qp_max_i);
mpp_enc_cfg_set_s32(cfg, "rc:qp_min_i", qp_min_i);
/* Intra Refresh / GDR */
if (r->intra_refresh && r->refresh_num) {
mpp_enc_cfg_set_u32(cfg, "rc:refresh_en", 1);
mpp_enc_cfg_set_u32(cfg, "rc:refresh_mode", r->refresh_mode);
mpp_enc_cfg_set_u32(cfg, "rc:refresh_num", r->refresh_num);
av_log(avctx, AV_LOG_VERBOSE, "Requested to use Intra Refresh, "
"Mode/Num is set to %d/%d\n", r->refresh_mode, r->refresh_num);
}
}
break;
case AV_CODEC_ID_MJPEG:

View file

@ -84,6 +84,9 @@ typedef struct RKMPPEncContext {
int udu_sei;
int prefix_mode;
int chroma_fmt;
int intra_refresh;
int refresh_mode;
int refresh_num;
} RKMPPEncContext;
static const AVRational mpp_tb = { 1, 1000000 };
@ -114,6 +117,14 @@ static const AVRational mpp_tb = { 1, 1000000 };
{ .i64 = -1 }, -1, 51, VE, "qp_max_i" }, \
{ "qp_min_i", "Set the min QP value for I frame", OFFSET(qp_min_i), AV_OPT_TYPE_INT, \
{ .i64 = -1 }, -1, 51, VE, "qp_min_i" }, \
{ "intra_refresh", "Use Intra Refresh instead of IDR frames", OFFSET(intra_refresh), AV_OPT_TYPE_BOOL, \
{ .i64 = 0 }, 0, 1, VE, "intra_refresh" }, \
{ "refresh_mode", "Set the Intra Refresh mode", OFFSET(refresh_mode), AV_OPT_TYPE_INT, \
{ .i64 = MPP_ENC_RC_INTRA_REFRESH_ROW }, MPP_ENC_RC_INTRA_REFRESH_ROW, MPP_ENC_RC_INTRA_REFRESH_COL, VE, "refresh_mode" }, \
{ "row", "Refresh by MB row", 0, AV_OPT_TYPE_CONST, { .i64 = MPP_ENC_RC_INTRA_REFRESH_ROW }, 0, 0, VE, .unit = "refresh_mode" }, \
{ "col", "Refresh by MB column", 0, AV_OPT_TYPE_CONST, { .i64 = MPP_ENC_RC_INTRA_REFRESH_COL }, 0, 0, VE, .unit = "refresh_mode" }, \
{ "refresh_num", "Set how many MB rows or columns refresh each time", OFFSET(refresh_num), AV_OPT_TYPE_INT, \
{ .i64 = 1 }, 1, INT_MAX, VE, "refresh_num" }, \
static const AVOption h264_options[] = {
RKMPP_ENC_COMMON_OPTS