Experimental; requires Skylake and VAAPI 0.39.1 (not yet released).
---
Just a flag to enable for now.  Needs better dynamic detection of features 
(notably the Skylake implementation does not support B-frames, and we could 
detect this via config attributes), though that is generally true for all of 
the setup here.

Runs a bit more than twice as fast as normal H.264 encode on my Skylake test 
machine (6300).
---
 libavcodec/vaapi_encode_h264.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 8690a85..1f0008b 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;


@@ -851,6 +852,14 @@ static av_cold int 
vaapi_encode_h264_init_internal(AVCodecContext *avctx)
         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_WARNING, "Low-power encoding is not "
+               "supported with this VAAPI version.\n");
+#endif
+    }

     ctx->input_width    = avctx->width;
     ctx->input_height   = avctx->height;
@@ -933,7 +942,9 @@ 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!)",
+      OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
     { NULL },
 };

-- 
2.8.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to