PR #22936 opened by Matteo Croce (teknoraver)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22936
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22936.patch
Expose a -preset {veryslow..veryfast} enum mirroring av1_qsv.
The chosen value is copied into avctx->compression_level
(when not explicitly set by the user),
which the existing vaapi_encode quality plumbing forwards to the
driver as VAEncMiscParameterBufferQualityLevel.
This gives users a discoverable way to tune the libva quality_level knob,
closing the parity gap with av1_qsv whose -preset maps to MFX_TARGETUSAGE_*.
>From 65315557b106244b4a49dd49f31896ec4ae0ddc4 Mon Sep 17 00:00:00 2001
From: Matteo Croce <[email protected]>
Date: Mon, 27 Apr 2026 02:06:29 +0200
Subject: [PATCH] lavc/vaapi_encode_av1: add preset option
Expose a -preset {veryslow..veryfast} enum mirroring av1_qsv.
The chosen value is copied into avctx->compression_level
(when not explicitly set by the user),
which the existing vaapi_encode quality plumbing forwards to the
driver as VAEncMiscParameterBufferQualityLevel.
This gives users a discoverable way to tune the libva quality_level knob,
closing the parity gap with av1_qsv whose -preset maps to MFX_TARGETUSAGE_*.
---
libavcodec/vaapi_encode_av1.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c
index 9d837f5c6b..118229fa69 100644
--- a/libavcodec/vaapi_encode_av1.c
+++ b/libavcodec/vaapi_encode_av1.c
@@ -87,6 +87,7 @@ typedef struct VAAPIEncodeAV1Context {
int tier;
int tile_cols, tile_rows;
int tile_groups;
+ int preset;
} VAAPIEncodeAV1Context;
static void vaapi_encode_av1_trace_write_log(void *ctx,
@@ -889,6 +890,8 @@ static av_cold int vaapi_encode_av1_init(AVCodecContext
*avctx)
avctx->profile = priv->profile;
if (avctx->level == AV_LEVEL_UNKNOWN)
avctx->level = priv->level;
+ if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
+ avctx->compression_level = priv->preset;
if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0x1f) {
av_log(avctx, AV_LOG_ERROR, "Invalid level %d\n", avctx->level);
@@ -1018,6 +1021,16 @@ static const AVOption vaapi_encode_av1_options[] = {
{ "tile_groups", "Number of tile groups for encoding",
OFFSET(tile_groups), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, AV1_MAX_TILE_ROWS
* AV1_MAX_TILE_COLS, FLAGS },
+ { "preset", "Encoding preset (trades quality for speed; maps to libva
quality_level)",
+ OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = 4 }, 0, INT_MAX, FLAGS, .unit
= "preset" },
+ { "veryslow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "slower", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 5 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 6 }, 0, 0, FLAGS, .unit
= "preset" },
+ { "veryfast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 7 }, 0, 0, FLAGS, .unit
= "preset" },
+
{ NULL },
};
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]