mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
vaapi_h264: Add encode quality option (for quality-speed tradeoff)
Only supported on VAAPI 0.36 and higher. Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
9629701ce9
commit
fcf536b130
@ -113,10 +113,19 @@ typedef struct VAAPIEncodeH264Context {
|
|||||||
VAEncMiscParameterBuffer misc;
|
VAEncMiscParameterBuffer misc;
|
||||||
VAEncMiscParameterHRD hrd;
|
VAEncMiscParameterHRD hrd;
|
||||||
} hrd_params;
|
} hrd_params;
|
||||||
|
|
||||||
|
#if VA_CHECK_VERSION(0, 36, 0)
|
||||||
|
// Speed-quality tradeoff setting.
|
||||||
|
struct {
|
||||||
|
VAEncMiscParameterBuffer misc;
|
||||||
|
VAEncMiscParameterBufferQualityLevel quality;
|
||||||
|
} quality_params;
|
||||||
|
#endif
|
||||||
} VAAPIEncodeH264Context;
|
} VAAPIEncodeH264Context;
|
||||||
|
|
||||||
typedef struct VAAPIEncodeH264Options {
|
typedef struct VAAPIEncodeH264Options {
|
||||||
int qp;
|
int qp;
|
||||||
|
int quality;
|
||||||
} VAAPIEncodeH264Options;
|
} VAAPIEncodeH264Options;
|
||||||
|
|
||||||
|
|
||||||
@ -801,6 +810,7 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
|
|||||||
|
|
||||||
VAAPIEncodeContext *ctx = avctx->priv_data;
|
VAAPIEncodeContext *ctx = avctx->priv_data;
|
||||||
VAAPIEncodeH264Context *priv = ctx->priv_data;
|
VAAPIEncodeH264Context *priv = ctx->priv_data;
|
||||||
|
VAAPIEncodeH264Options *opt = ctx->codec_options;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
switch (avctx->profile) {
|
switch (avctx->profile) {
|
||||||
@ -869,6 +879,22 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
|
|||||||
.value = ctx->va_rc_mode,
|
.value = ctx->va_rc_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (opt->quality > 0) {
|
||||||
|
#if VA_CHECK_VERSION(0, 36, 0)
|
||||||
|
priv->quality_params.misc.type =
|
||||||
|
VAEncMiscParameterTypeQualityLevel;
|
||||||
|
priv->quality_params.quality.quality_level = opt->quality;
|
||||||
|
|
||||||
|
ctx->global_params[ctx->nb_global_params] =
|
||||||
|
&priv->quality_params.misc;
|
||||||
|
ctx->global_params_size[ctx->nb_global_params++] =
|
||||||
|
sizeof(priv->quality_params);
|
||||||
|
#else
|
||||||
|
av_log(avctx, AV_LOG_WARNING, "The encode quality option is not "
|
||||||
|
"supported with this VAAPI version.\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ctx->nb_recon_frames = 20;
|
ctx->nb_recon_frames = 20;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -906,6 +932,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
|
|||||||
static const AVOption vaapi_encode_h264_options[] = {
|
static const AVOption vaapi_encode_h264_options[] = {
|
||||||
{ "qp", "Constant QP (for P frames; scaled by qfactor/qoffset for I/B)",
|
{ "qp", "Constant QP (for P frames; scaled by qfactor/qoffset for I/B)",
|
||||||
OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS },
|
OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS },
|
||||||
|
{ "quality", "Set encode quality (trades off against speed, higher is faster)",
|
||||||
|
OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FLAGS },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user