[libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

Luca Barbato lu_zero at gentoo.org
Wed Jan 3 23:29:58 CET 2018


On 03/01/2018 18:55, Mikhail Mironov wrote:
>  From 0b90d9c0eb300099ca6845e8ba42bce881670a83 Mon Sep 17 00:00:00 2001
> From: Michael Wootton <michael.wootton at amd.com>
> Date: Mon, 4 Dec 2017 02:29:01 -0500
> Subject: [PATCH] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK
>   Requires AMF headers for at least version 1.4.4.1.
> 
> Signed-off-by: Mikhail Mironov <mikhail.mironov at amd.com>

Thank you a lot!

If nobody has other comments I'd fold in the hwaccel caps/.wrapper_name 
support in and push.

diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index 47a057fdfa..01b0c3a562 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -366,7 +366,6 @@ static av_cold int 
amf_encode_init_h264(AVCodecContext *avctx)
  static const AVCodecDefault defaults[] = {
      { "refs",       "-1"  },
      { "aspect",     "0"   },
-//    { "sar",        "0"   },
      { "qmin",       "-1"  },
      { "qmax",       "-1"  },
      { "b",          "2M"  },
@@ -381,7 +380,7 @@ static const AVClass h264_amf_class = {
      .option = options,
      .version = LIBAVUTIL_VERSION_INT,
  };
-//TODO declare as HW encoder when available
+
  AVCodec ff_h264_amf_encoder = {
      .name           = "h264_amf",
      .long_name      = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder"),
@@ -394,7 +393,8 @@ AVCodec ff_h264_amf_encoder = {
      .priv_data_size = sizeof(AmfContext),
      .priv_class     = &h264_amf_class,
      .defaults       = defaults,
-    .capabilities   = AV_CODEC_CAP_DELAY,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
      .pix_fmts       = ff_amf_pix_fmts,
+    .wrapper_name   = "amf",
  };
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index b014a50c9a..fc64decde3 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -301,7 +301,6 @@ static av_cold int 
amf_encode_init_hevc(AVCodecContext *avctx)
  static const AVCodecDefault defaults[] = {
      { "refs",       "-1"  },
      { "aspect",     "0"   },
-//    { "sar",        "0"   },
      { "b",          "2M"  },
      { "g",          "250" },
      { "slices",     "1"   },
@@ -313,7 +312,7 @@ static const AVClass hevc_amf_class = {
      .option = options,
      .version = LIBAVUTIL_VERSION_INT,
  };
-//TODO declare as HW encoder when available
+
  AVCodec ff_hevc_amf_encoder = {
      .name           = "hevc_amf",
      .long_name      = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder"),
@@ -326,7 +325,8 @@ AVCodec ff_hevc_amf_encoder = {
      .priv_data_size = sizeof(AmfContext),
      .priv_class     = &hevc_amf_class,
      .defaults       = defaults,
-    .capabilities   = AV_CODEC_CAP_DELAY,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
      .pix_fmts       = ff_amf_pix_fmts,
+    .wrapper_name   = "amf",
  };


More information about the libav-devel mailing list