aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2016-04-12 23:16:30 +0100
committerAnton Khirnov <anton@khirnov.net>2016-04-15 10:07:05 +0200
commitfcf536b1301475c57a7f94d00b1aebf5d20fe9d3 (patch)
treefb8316fd0749a909a51f98a823a6c9ae0ec6806c /libavcodec
parent9629701ce9debe295da09bb0e117ee9392ef1fe3 (diff)
downloadffmpeg-fcf536b1301475c57a7f94d00b1aebf5d20fe9d3.tar.gz
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>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vaapi_encode_h264.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 940832e367..9841a708b6 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -113,10 +113,19 @@ typedef struct VAAPIEncodeH264Context {
VAEncMiscParameterBuffer misc;
VAEncMiscParameterHRD hrd;
} hrd_params;
+
+#if VA_CHECK_VERSION(0, 36, 0)
+ // Speed-quality tradeoff setting.
+ struct {
+ VAEncMiscParameterBuffer misc;
+ VAEncMiscParameterBufferQualityLevel quality;
+ } quality_params;
+#endif
} VAAPIEncodeH264Context;
typedef struct VAAPIEncodeH264Options {
int qp;
+ int quality;
} VAAPIEncodeH264Options;
@@ -801,6 +810,7 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeH264Context *priv = ctx->priv_data;
+ VAAPIEncodeH264Options *opt = ctx->codec_options;
int i, err;
switch (avctx->profile) {
@@ -869,6 +879,22 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
.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;
return 0;
@@ -906,6 +932,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
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 = 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 },
};