hw_base_encode: Support refs option to limit number of references

Set default value to 0 to keep the old behavior of using maximum number
of references.
This commit is contained in:
David Rosca
2025-06-25 08:46:23 +02:00
committed by Lynne
parent 7d606ef0cc
commit ac5303a5b9
10 changed files with 14 additions and 0 deletions

View File

@@ -762,6 +762,7 @@ static const FFCodecDefault d3d12va_encode_hevc_defaults[] = {
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -666,6 +666,11 @@ int ff_hw_base_init_gop_structure(FFHWBaseEncodeContext *ctx, AVCodecContext *av
ctx->ref_l0 = FFMIN(ref_l0, MAX_PICTURE_REFERENCES);
ctx->ref_l1 = FFMIN(ref_l1, MAX_PICTURE_REFERENCES);
if (avctx->refs > 0) {
ctx->ref_l0 = FFMIN(ctx->ref_l0, avctx->refs);
ctx->ref_l1 = FFMIN(ctx->ref_l1, avctx->refs);
}
if (flags & FF_HW_FLAG_INTRA_ONLY || avctx->gop_size <= 1) {
av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
ctx->gop_size = 1;

View File

@@ -1027,6 +1027,7 @@ static const FFCodecDefault vaapi_encode_av1_defaults[] = {
{ "g", "120" },
{ "qmin", "1" },
{ "qmax", "255" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -1153,6 +1153,7 @@ static const FFCodecDefault vaapi_encode_h264_defaults[] = {
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -1184,6 +1184,7 @@ static const FFCodecDefault vaapi_encode_h265_defaults[] = {
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -235,6 +235,7 @@ static const FFCodecDefault vaapi_encode_vp8_defaults[] = {
{ "g", "120" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -292,6 +292,7 @@ static const FFCodecDefault vaapi_encode_vp9_defaults[] = {
{ "g", "250" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -1367,6 +1367,7 @@ static const FFCodecDefault vulkan_encode_av1_defaults[] = {
{ "g", "300" },
{ "qmin", "1" },
{ "qmax", "255" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -1634,6 +1634,7 @@ static const FFCodecDefault vulkan_encode_h264_defaults[] = {
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};

View File

@@ -1761,6 +1761,7 @@ static const FFCodecDefault vulkan_encode_h265_defaults[] = {
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "refs", "0" },
{ NULL },
};