summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2016-05-17 23:08:57 +0100
committerMark Thompson <sw@jkqxz.net>2016-05-27 10:57:00 +0100
commita86aa16088ad7f22a8918d71adb8c040d6033d84 (patch)
treed9a88039d115cd3f86ddd427b8db14baf24422d7
parentb51c7c6b8a5b35cfd06cb9655f9ec4c9f0ddd81b (diff)
downloadffmpeg-a86aa16088ad7f22a8918d71adb8c040d6033d84.tar.gz
vaapi_h264: Add trivial support for low-power encoding
Experimental; requires Skylake and VAAPI 0.39.1 (not yet released). Also increases the allowed range of the quality option - in low-power mode, the Intel driver supports levels 1-8 (and 0 meaning default).
-rw-r--r--libavcodec/vaapi_encode_h264.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 7819788cf7..2341b123fc 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -126,6 +126,7 @@ typedef struct VAAPIEncodeH264Context {
typedef struct VAAPIEncodeH264Options {
int qp;
int quality;
+ int low_power;
} VAAPIEncodeH264Options;
@@ -854,7 +855,17 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx)
avctx->profile);
return AVERROR(EINVAL);
}
- ctx->va_entrypoint = VAEntrypointEncSlice;
+ if (opt->low_power) {
+#if VA_CHECK_VERSION(0, 39, 1)
+ ctx->va_entrypoint = VAEntrypointEncSliceLP;
+#else
+ av_log(avctx, AV_LOG_ERROR, "Low-power encoding is not "
+ "supported with this VAAPI version.\n");
+ return AVERROR(EINVAL);
+#endif
+ } else {
+ ctx->va_entrypoint = VAEntrypointEncSlice;
+ }
ctx->input_width = avctx->width;
ctx->input_height = avctx->height;
@@ -937,7 +948,10 @@ 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 },
+ OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, FLAGS },
+ { "low_power", "Use low-power encoding mode (experimental: only supported "
+ "on some platforms, does not support all features)",
+ OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL },
};