Support live AMF QP ceiling updates in bundled FFmpeg
This commit is contained in:
1 parent
00698537ad
commit
fe86a16cac
2 files changed
+77
No files matched your search
@@ -0,0 +1,70 @@
|
||||
--- a/libavcodec/amfenc.h
|
||||
+++ b/libavcodec/amfenc.h
|
||||
@@ -112,6 +112,8 @@
|
||||
int aud;
|
||||
int max_consecutive_b_frames;
|
||||
int max_b_frames;
|
||||
+ 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" },
|
||||
--- 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" },
|
||||
--- a/libavcodec/amfenc.c
|
||||
+++ b/libavcodec/amfenc.c
|
||||
@@ -274,6 +274,7 @@
|
||||
av_unused int ret;
|
||||
|
||||
ctx->hwsurfaces_in_queue = 0;
|
||||
+ 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 (ctx->utun_qp_max >= 0 && ctx->utun_qp_max != ctx->utun_qp_applied) {
|
||||
+ const wchar_t *max_i, *max_p;
|
||||
+ if (avctx->codec_id == AV_CODEC_ID_H264) {
|
||||
+ max_i = AMF_VIDEO_ENCODER_MAX_QP;
|
||||
+ max_p = AMF_VIDEO_ENCODER_MAX_QP;
|
||||
+ } else if (avctx->codec_id == AV_CODEC_ID_HEVC) {
|
||||
+ max_i = AMF_VIDEO_ENCODER_HEVC_MAX_QP_I;
|
||||
+ max_p = AMF_VIDEO_ENCODER_HEVC_MAX_QP_P;
|
||||
+ } else {
|
||||
+ av_log(avctx, AV_LOG_ERROR, "Live QP ceiling is unsupported for codec %d\n", avctx->codec_id);
|
||||
+ return AVERROR(ENOSYS);
|
||||
+ }
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, max_i, ctx->utun_qp_max);
|
||||
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_EXTERNAL, "Live I QP ceiling failed: %d\n", res);
|
||||
+ if (avctx->codec_id == AV_CODEC_ID_HEVC) {
|
||||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, max_p, ctx->utun_qp_max);
|
||||
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_EXTERNAL, "Live P QP ceiling failed: %d\n", res);
|
||||
+ }
|
||||
+ 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) {
|
||||
@@ -3,6 +3,13 @@
|
||||
<TS version="2.1" language="ru_RU" sourcelanguage="en_US">
|
||||
<context>
|
||||
<name>ChatGui</name>
|
||||
<message><source>Maximum QP</source><translation>Верхний предел QP</translation></message>
|
||||
<message><source>Adapt QP to the target bitrate</source><translation>Подстраивать QP под заданный битрейт</translation></message>
|
||||
<message><source>Current QP ceiling: %1</source><translation>Текущий предел QP: %1</translation></message>
|
||||
<message><source>Lower QP preserves more detail and may require a higher bitrate. Applies to H.264 and H.265.</source><translation>Меньший QP сохраняет больше деталей и может требовать большего битрейта. Для H.264 и H.265.</translation></message>
|
||||
<message><source>Gradually raise the QP ceiling above the selected value when bitrate is too high, then return it. Requires live QP adjustment.</source><translation>При превышении битрейта плавно повышать предел QP выше выбранного, затем возвращать обратно. Нужна поддержка изменения QP во время трансляции.</translation></message>
|
||||
<message><source>Select a maximum QP before enabling adaptation</source><translation>Выберите верхний предел QP перед включением адаптации</translation></message>
|
||||
<message><source>QP adaptation is unavailable for this encoder. Disable adaptation or choose another codec.</source><translation>Этот кодировщик не поддерживает адаптацию QP. Отключите адаптацию или выберите другой кодек.</translation></message>
|
||||
<message><source>Local network</source><translation>Локальная сеть</translation></message>
|
||||
<message><source>Receive invitations from the local network</source><translation>Разрешить получать приглашения из локальной сети</translation></message>
|
||||
<message><source>Broadcast presence on the local network</source><translation>Разрешить отправлять широковещательные объявления</translation></message>
|
||||
|
||||
Reference in new issue
Block a user