diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 3ffca750d8..20bc22d98c 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -250,7 +250,7 @@ static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt, AMFBuffer *buff break; } - if (average_qp >= 0) { + if (ctx->qp_stats && average_qp >= 0) { ff_encode_add_stats_side_data(pkt, average_qp * FF_QP2LAMBDA, NULL, 0, pict_type); } @@ -475,7 +475,9 @@ static int amf_submit_frame(AVCodecContext *avctx, AVFrame *frame, AMFSurface switch (avctx->codec->id) { case AV_CODEC_ID_H264: - AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_STATISTICS_FEEDBACK, 1); + if (ctx->qp_stats) { + AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_STATISTICS_FEEDBACK, 1); + } AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_INSERT_AUD, !!ctx->aud); switch (frame->pict_type) { case AV_PICTURE_TYPE_I: @@ -496,7 +498,9 @@ static int amf_submit_frame(AVCodecContext *avctx, AVFrame *frame, AMFSurface } break; case AV_CODEC_ID_HEVC: - AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_HEVC_STATISTICS_FEEDBACK, 1); + if (ctx->qp_stats) { + AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_HEVC_STATISTICS_FEEDBACK, 1); + } AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_INSERT_AUD, !!ctx->aud); switch (frame->pict_type) { case AV_PICTURE_TYPE_I: @@ -513,7 +517,9 @@ static int amf_submit_frame(AVCodecContext *avctx, AVFrame *frame, AMFSurface } break; case AV_CODEC_ID_AV1: - AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_AV1_STATISTICS_FEEDBACK, 1); + if (ctx->qp_stats) { + AMF_ASSIGN_PROPERTY_BOOL(res, surface, AMF_VIDEO_ENCODER_AV1_STATISTICS_FEEDBACK, 1); + } if (frame->pict_type == AV_PICTURE_TYPE_I) { if (ctx->forced_idr) { AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_AV1_FORCE_INSERT_SEQUENCE_HEADER, 1); diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h index 1571541b9b..6a380208d1 100644 --- a/libavcodec/amfenc.h +++ b/libavcodec/amfenc.h @@ -100,6 +100,7 @@ typedef struct AMFEncoderContext { int qvbr_quality_level; int hw_high_motion_quality_boost; int forced_idr; + int qp_stats; // HEVC - specific options diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index af20b5d04d..a572d439a7 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -130,6 +130,7 @@ static const AVOption options[] = { { "caq", "context adaptive quantization", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_AQ_MODE_CAQ }, 0, 0, VE, .unit = "adaptive_quantisation_mode" }, { "forced_idr", "Force I frames to be IDR frames", OFFSET(forced_idr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "qp_stats", "Report average QP per frame as packet side data (reduces throughput)", OFFSET(qp_stats), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "align", "alignment mode", OFFSET(align), AV_OPT_TYPE_INT, {.i64 = AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_NO_RESTRICTIONS }, AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_64X16_ONLY, AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_NO_RESTRICTIONS, VE, .unit = "align" }, { "64x16", "", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_64X16_ONLY }, 0, 0, VE, .unit = "align" }, diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index 650a9bc7e9..214fac6909 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -140,6 +140,7 @@ static const AVOption options[] = { { "me_quarter_pel", "Enable ME Quarter Pixel", OFFSET(me_quarter_pel),AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE }, { "forced_idr", "Force I frames to be IDR frames", OFFSET(forced_idr) , AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "qp_stats", "Report average QP per frame as packet side data (reduces throughput)", OFFSET(qp_stats), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "aud", "Inserts AU Delimiter NAL unit", OFFSET(aud) , AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE }, { "smart_access_video", "Enable Smart Access Video to enhance performance by utilizing both APU and dGPU memory access", OFFSET(smart_access_video), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE}, diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 6fa20d172e..4e280fcf15 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -111,6 +111,7 @@ static const AVOption options[] = { { "me_quarter_pel", "Enable ME Quarter Pixel ", OFFSET(me_quarter_pel),AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE }, { "forced_idr", "Force I frames to be IDR frames", OFFSET(forced_idr) ,AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, + { "qp_stats", "Report average QP per frame as packet side data (reduces throughput)", OFFSET(qp_stats), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "aud", "Inserts AU Delimiter NAL unit", OFFSET(aud) ,AV_OPT_TYPE_BOOL,{ .i64 = -1 }, -1, 1, VE }, { "smart_access_video", "Enable Smart Access Video to enhance performance by utilizing both APU and dGPU memory access", OFFSET(smart_access_video), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE},