@@ -2635,6 +2635,9 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
if (err < 0)
goto fail;
+ if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
+ avctx->compression_level = ctx->quality;
+
if (avctx->compression_level >= 0) {
err = vaapi_encode_init_quality(avctx);
if (err < 0)
@@ -364,6 +364,8 @@ typedef struct VAAPIEncodeContext {
AVFifo *encode_fifo;
// Max number of frame buffered in encoder.
int async_depth;
+ // Encode quality (trades off against speed, higher is faster)
+ int quality;
} VAAPIEncodeContext;
enum {
@@ -490,7 +492,11 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
{ "max_frame_size", \
"Maximum frame size (in bytes)",\
OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
- { .i64 = 0 }, 0, INT_MAX, FLAGS }
+ { .i64 = 0 }, 0, INT_MAX, FLAGS }, \
+ { "quality", \
+ "Set encode quality (trades off against speed, higher is faster)", \
+ OFFSET(common.quality), AV_OPT_TYPE_INT, \
+ { .i64 = -1 }, -1, INT_MAX, FLAGS }
#define VAAPI_ENCODE_RC_MODE(name, desc) \
{ #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
@@ -71,7 +71,6 @@ typedef struct VAAPIEncodeH264Context {
// User options.
int qp;
- int quality;
int coder;
int aud;
int sei;
@@ -1211,8 +1210,6 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
avctx->profile = priv->profile;
if (avctx->level == FF_LEVEL_UNKNOWN)
avctx->level = priv->level;
- if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
- avctx->compression_level = priv->quality;
// Reject unsupported profiles.
switch (avctx->profile) {
@@ -1282,8 +1279,6 @@ static const AVOption vaapi_encode_h264_options[] = {
{ "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
- { "quality", "Set encode quality (trades off against speed, higher is faster)",
- OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "coder", "Entropy coder type",
OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
{ "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" },