|
|
|
|
@ -1,48 +1,23 @@
|
|
|
|
|
--- a/libavcodec/amfenc.h
|
|
|
|
|
+++ b/libavcodec/amfenc.h
|
|
|
|
|
@@ -112,6 +112,8 @@
|
|
|
|
|
int aud;
|
|
|
|
|
int max_consecutive_b_frames;
|
|
|
|
|
int max_b_frames;
|
|
|
|
|
@@ -114,0 +115,2 @@
|
|
|
|
|
+ int utun_qp_max;
|
|
|
|
|
+ int utun_qp_applied;
|
|
|
|
|
int qvbr_quality_level;
|
|
|
|
|
int hw_high_motion_quality_boost;
|
|
|
|
|
|
|
|
|
|
--- a/libavcodec/amfenc_h264.c
|
|
|
|
|
+++ b/libavcodec/amfenc_h264.c
|
|
|
|
|
@@ -28,6 +28,7 @@
|
|
|
|
|
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
|
|
|
|
|
|
|
|
|
static const AVOption options[] = {
|
|
|
|
|
+ { "utun_qp_max", "Live QP ceiling", OFFSET(utun_qp_max), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
|
|
|
|
|
// Static
|
|
|
|
|
/// Usage
|
|
|
|
|
{ "usage", "Encoder Usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY, VE, .unit = "usage" },
|
|
|
|
|
@@ -30,0 +31 @@
|
|
|
|
|
+ { "utun_qp_max", "Live QP ceiling", OFFSET(utun_qp_max), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE | AV_OPT_FLAG_RUNTIME_PARAM },
|
|
|
|
|
--- a/libavcodec/amfenc_hevc.c
|
|
|
|
|
+++ b/libavcodec/amfenc_hevc.c
|
|
|
|
|
@@ -27,6 +27,7 @@
|
|
|
|
|
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
|
|
|
|
|
|
|
|
|
static const AVOption options[] = {
|
|
|
|
|
+ { "utun_qp_max", "Live QP ceiling", OFFSET(utun_qp_max), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
|
|
|
|
|
{ "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY, VE, .unit = "usage" },
|
|
|
|
|
{ "transcoding", "Generic Transcoding", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING }, 0, 0, VE, .unit = "usage" },
|
|
|
|
|
{ "ultralowlatency", "Ultra low latency usecase", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, .unit = "usage" },
|
|
|
|
|
@@ -29,0 +30 @@
|
|
|
|
|
+ { "utun_qp_max", "Live QP ceiling", OFFSET(utun_qp_max), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE | AV_OPT_FLAG_RUNTIME_PARAM },
|
|
|
|
|
--- a/libavcodec/amfenc.c
|
|
|
|
|
+++ b/libavcodec/amfenc.c
|
|
|
|
|
@@ -274,6 +274,7 @@
|
|
|
|
|
av_unused int ret;
|
|
|
|
|
|
|
|
|
|
ctx->hwsurfaces_in_queue = 0;
|
|
|
|
|
@@ -276,0 +277,3 @@
|
|
|
|
|
+ ctx->utun_qp_applied = -1;
|
|
|
|
|
ctx->hwsurfaces_in_queue_max = 16;
|
|
|
|
|
|
|
|
|
|
// configure AMF logger
|
|
|
|
|
@@ -680,6 +681,28 @@
|
|
|
|
|
}
|
|
|
|
|
} else if (!ctx->delayed_surface) { // submit frame
|
|
|
|
|
int hw_surface = 0;
|
|
|
|
|
+ if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC)
|
|
|
|
|
+ ctx->utun_qp_max = -1;
|
|
|
|
|
@@ -682,0 +686,22 @@
|
|
|
|
|
+
|
|
|
|
|
+ if (ctx->utun_qp_max >= 0 && ctx->utun_qp_max != ctx->utun_qp_applied) {
|
|
|
|
|
+ const wchar_t *max_i, *max_p;
|
|
|
|
|
@ -65,6 +40,3 @@
|
|
|
|
|
+ ctx->utun_qp_applied = ctx->utun_qp_max;
|
|
|
|
|
+ av_log(avctx, AV_LOG_INFO, "Live QP ceiling applied qp=%d\n", ctx->utun_qp_max);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
// prepare surface from frame
|
|
|
|
|
switch (frame->format) {
|
|
|
|
|
|