From patchwork Mon Apr 13 15:33:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18918 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 49000449F3D for ; Mon, 13 Apr 2020 18:33:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D47468B815; Mon, 13 Apr 2020 18:33:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73DCB68AE53 for ; Mon, 13 Apr 2020 18:33:28 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id s8so10563525wrt.7 for ; Mon, 13 Apr 2020 08:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7czFKf9ll1NRPmwkSeXnKB7Utp0wQt+eZ/KKomAwFtg=; b=jYU9PzCPQAH3sEkZKpT2qbAfxYRUqnvxm/2r9Ny/difQTn0nynu0QNwZuIXB1XPNJw lhylsevGFGt76mSPEvvIo1j6YjFk+n+QM27LHIz5Yo9IuG9I/O4+98u/Q3qJd9AUP+wk 1PadrZCj7HI0NhWkSua7VCfcp0zxLWT/EfYBrFRarG7y3oTX/XBIqyHqndVYi8Qoc5Wg aOs/B+AVUTgz0AC0Sk+J6olYG4KZW7y9PLiX0OQdP0D1QcD+7UI5tyPMN797yO5sIeE+ qbHTpyQ6W/rCGAf10MgT2kTyXDuRmx5cSKn//khZsd1R3CBMJg/yfBbfuyLwIaCCSNkE UbfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7czFKf9ll1NRPmwkSeXnKB7Utp0wQt+eZ/KKomAwFtg=; b=dZrfKV1b0B/ZJfGwfdQ+/0v6HVuS42GF8e8ZePbJqQaqn0AuUcsYPtw+V+6r2EH57c w/nWk6j4swq1+gw7YDloZmwLjeRgGXfmhY9XXKkx/xaJBqQ+kDAryrVTRW9TxxDoMYr7 V71y10jeR+SXgcir/kBHI6Ns3Bd0xSspJsQdbNpqZtbiH53OYf/WzwLmw5Q95D8p5yEu zsNudbacgCr7YX16VkNRm6Z8yFM98TElTPB6ns/PZVQihP2FNT0BouvvkwO3JriAYPlF XnkH2fNeGEphhkWL9a/F2rnO/KFQ3NF0E0KpF9kQvin1WQGq1i+lwq41ySf7VBO8wZ9r v5qA== X-Gm-Message-State: AGi0PuZ6A3vhny/bQKbBiWUsJDmHzKKww7VOK/WCnMqX5VsrdwYzkQgO OPgvhky6aB0GbjmZetjI7ZRh2y5caIQ= X-Google-Smtp-Source: APiQypL4CMjZDBIUBgJNWnhtWYmvOqnKw0eENeRCw2LsDCHzwBwx5xWCeizzrzhSVeX42Kz+URzuCQ== X-Received: by 2002:a5d:6751:: with SMTP id l17mr18743380wrw.162.1586792007408; Mon, 13 Apr 2020 08:33:27 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:26 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:14 +0100 Message-Id: <20200413153321.5956-1-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] lavc: Rename hwaccel.h to hwconfig.h X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This already applied to decoders as well as hwaccels, and adding encoder support was going to make the name even more inaccurate. --- libavcodec/cuviddec.c | 2 +- libavcodec/decode.c | 2 +- libavcodec/h263dec.c | 2 +- libavcodec/h264dec.c | 2 +- libavcodec/hevcdec.c | 2 +- libavcodec/{hwaccel.h => hwconfig.h} | 6 +++--- libavcodec/mediacodecdec.c | 2 +- libavcodec/mjpegdec.c | 2 +- libavcodec/mmaldec.c | 2 +- libavcodec/mpeg12dec.c | 2 +- libavcodec/mpeg4videodec.c | 2 +- libavcodec/pthread_frame.c | 2 +- libavcodec/qsvdec.h | 2 +- libavcodec/rkmppdec.c | 2 +- libavcodec/utils.c | 2 +- libavcodec/vaapi_h264.c | 2 +- libavcodec/vaapi_hevc.c | 2 +- libavcodec/vaapi_mjpeg.c | 2 +- libavcodec/vaapi_mpeg2.c | 2 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vaapi_vc1.c | 2 +- libavcodec/vaapi_vp8.c | 2 +- libavcodec/vaapi_vp9.c | 2 +- libavcodec/vc1dec.c | 2 +- libavcodec/vdpau_h264.c | 2 +- libavcodec/vdpau_hevc.c | 2 +- libavcodec/vdpau_mpeg12.c | 2 +- libavcodec/vdpau_mpeg4.c | 2 +- libavcodec/vdpau_vc1.c | 2 +- libavcodec/vdpau_vp9.c | 2 +- libavcodec/vp8.c | 2 +- libavcodec/vp9.c | 2 +- 32 files changed, 34 insertions(+), 34 deletions(-) rename libavcodec/{hwaccel.h => hwconfig.h} (97%) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 50dc8956c3..9477b8fd3a 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -33,7 +33,7 @@ #include "avcodec.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "nvdec.h" #include "internal.h" diff --git a/libavcodec/decode.c b/libavcodec/decode.c index b7ae1fbb84..2625790b57 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -41,7 +41,7 @@ #include "avcodec.h" #include "bytestream.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "thread.h" diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 8ee844e298..31ac563f43 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -33,7 +33,7 @@ #include "flv.h" #include "h263.h" #include "h263_parser.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mpeg_er.h" #include "mpeg4video.h" diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index e374f32e91..4c355feb18 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -46,7 +46,7 @@ #include "h264_mvpred.h" #include "h264_ps.h" #include "golomb.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "mathops.h" #include "me_cmp.h" #include "mpegutils.h" diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 36be83948e..78299f4b32 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -41,7 +41,7 @@ #include "hevc_data.h" #include "hevc_parse.h" #include "hevcdec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "profiles.h" const uint8_t ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 }; diff --git a/libavcodec/hwaccel.h b/libavcodec/hwconfig.h similarity index 97% rename from libavcodec/hwaccel.h rename to libavcodec/hwconfig.h index 3aaa92571c..4199ffdd50 100644 --- a/libavcodec/hwaccel.h +++ b/libavcodec/hwconfig.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_HWACCEL_H -#define AVCODEC_HWACCEL_H +#ifndef AVCODEC_HWCONFIG_H +#define AVCODEC_HWCONFIG_H #include "avcodec.h" #include "hwaccels.h" @@ -81,4 +81,4 @@ typedef struct AVCodecHWConfigInternal { #define HWACCEL_XVMC(codec) \ HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## _xvmc_hwaccel) -#endif /* AVCODEC_HWACCEL_H */ +#endif /* AVCODEC_HWCONFIG_H */ diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index f5771bffb1..25410021e8 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -34,7 +34,7 @@ #include "decode.h" #include "h264_parse.h" #include "hevc_parse.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mediacodec_wrapper.h" #include "mediacodecdec_common.h" diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index d5e7c21610..cb5e2a9b9b 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -36,7 +36,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "copy_block.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "idctdsp.h" #include "internal.h" #include "jpegtables.h" diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 647a22ef7c..547bece576 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -34,7 +34,7 @@ #include #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "libavutil/avassert.h" #include "libavutil/buffer.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 67ce59d451..40d054def5 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -36,7 +36,7 @@ #include "avcodec.h" #include "bytestream.h" #include "error_resilience.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "idctdsp.h" #include "internal.h" #include "mpeg_er.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index bfb1f92b33..7e52bbef1b 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -26,7 +26,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "error_resilience.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "idctdsp.h" #include "internal.h" #include "mpegutils.h" diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 4cd890b295..64121f5a9a 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -28,7 +28,7 @@ #include #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "pthread_internal.h" #include "thread.h" diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index dec1f61ceb..cb948f516d 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -33,7 +33,7 @@ #include "libavutil/pixfmt.h" #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "qsv_internal.h" typedef struct QSVContext { diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c index 143d05bd51..248020d5d6 100644 --- a/libavcodec/rkmppdec.c +++ b/libavcodec/rkmppdec.c @@ -28,7 +28,7 @@ #include "avcodec.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "libavutil/buffer.h" #include "libavutil/common.h" diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 26c038dfd9..e77090daef 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -44,7 +44,7 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "decode.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "libavutil/opt.h" #include "mpegvideo.h" #include "thread.h" diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index dd2a657160..9332aa6f31 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -22,7 +22,7 @@ #include "h264dec.h" #include "h264_ps.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vaapi_decode.h" /** diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index d832b8cb0d..c83d481b90 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "hevcdec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vaapi_decode.h" #include "vaapi_hevc.h" #include "h265_profile_level.h" diff --git a/libavcodec/vaapi_mjpeg.c b/libavcodec/vaapi_mjpeg.c index 14e0206ae1..81582114b6 100644 --- a/libavcodec/vaapi_mjpeg.c +++ b/libavcodec/vaapi_mjpeg.c @@ -19,7 +19,7 @@ #include #include -#include "hwaccel.h" +#include "hwconfig.h" #include "vaapi_decode.h" #include "mjpegdec.h" diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index aaed434c88..26e0cd827c 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "hwaccel.h" +#include "hwconfig.h" #include "mpegutils.h" #include "mpegvideo.h" #include "internal.h" diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 11860ff747..71e155154c 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -21,7 +21,7 @@ */ #include "h263.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mpeg4video.h" #include "mpegvideo.h" diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 921ca6391b..4e9607d9be 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "vaapi_decode.h" #include "vc1.h" diff --git a/libavcodec/vaapi_vp8.c b/libavcodec/vaapi_vp8.c index 2426b30f13..06c23e760b 100644 --- a/libavcodec/vaapi_vp8.c +++ b/libavcodec/vaapi_vp8.c @@ -19,7 +19,7 @@ #include #include -#include "hwaccel.h" +#include "hwconfig.h" #include "vaapi_decode.h" #include "vp8.h" diff --git a/libavcodec/vaapi_vp9.c b/libavcodec/vaapi_vp9.c index f384ba7873..776382f683 100644 --- a/libavcodec/vaapi_vp9.c +++ b/libavcodec/vaapi_vp9.c @@ -22,7 +22,7 @@ #include "libavutil/pixdesc.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vaapi_decode.h" #include "vp9shared.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 15783e3b8d..7809234ff7 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "get_bits.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mpeg_er.h" #include "mpegvideo.h" diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c index 2a260f76ab..5ba73dafd4 100644 --- a/libavcodec/vdpau_h264.c +++ b/libavcodec/vdpau_h264.c @@ -27,7 +27,7 @@ #include "internal.h" #include "h264dec.h" #include "h264_ps.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "mpegutils.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c index 024ac6e2f2..29cb2da078 100644 --- a/libavcodec/vdpau_hevc.c +++ b/libavcodec/vdpau_hevc.c @@ -26,7 +26,7 @@ #include "internal.h" #include "hevc_data.h" #include "hevcdec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c index d286e7e57d..72220ffb4e 100644 --- a/libavcodec/vdpau_mpeg12.c +++ b/libavcodec/vdpau_mpeg12.c @@ -24,7 +24,7 @@ #include #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "mpegvideo.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 96f83026a8..93b25beb1f 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -24,7 +24,7 @@ #include #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "mpeg4video.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c index 671baf96b4..96c91b58be 100644 --- a/libavcodec/vdpau_vc1.c +++ b/libavcodec/vdpau_vc1.c @@ -24,7 +24,7 @@ #include #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vc1.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vdpau_vp9.c b/libavcodec/vdpau_vp9.c index 54e060fad5..a8609d647e 100644 --- a/libavcodec/vdpau_vp9.c +++ b/libavcodec/vdpau_vp9.c @@ -26,7 +26,7 @@ #include "internal.h" #include "vp9data.h" #include "vp9dec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "vdpau.h" #include "vdpau_internal.h" diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 1794d6d031..bab4223aca 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -27,7 +27,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "mathops.h" #include "rectangle.h" diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 2a3a4555b9..bf6cc3aea5 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -23,7 +23,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "hwaccel.h" +#include "hwconfig.h" #include "internal.h" #include "profiles.h" #include "thread.h" From patchwork Mon Apr 13 15:33:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18919 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4CCDE449F3D for ; Mon, 13 Apr 2020 18:33:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3605768B955; Mon, 13 Apr 2020 18:33:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 724CB68B6DA for ; Mon, 13 Apr 2020 18:33:29 +0300 (EEST) Received: by mail-wm1-f54.google.com with SMTP id e26so9691531wmk.5 for ; Mon, 13 Apr 2020 08:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JLM0M2/iM5IvBKksk3tv4/9fMZNZ9CPXIF7Se3ZZSBo=; b=TGP4h6LRO7MXdw38snmQnhJQZPvwoKs4cMrzi44GWf83p7jkPqliLFDbGgBkejdu9E 3EEiCDXHkV7CmggNqsRP2Sp5wZnER7UR5OLEDIBUp5cVwWq1tIoUEtQky0nhoGY2L9xo mObRfNorwDF4hVnww3RqAvu6MPoC5jDLS154dNN2TTfEaR5FRMCUHOsz5/qGfpgNjewp NDq1bJigMAru9S2+KfdUgZ1E2LZPOidKV3cfsbUkH4qyd/OskzOalk3KfO68vIg6Q5v2 nEZyOtCaPJYy9gzN9scgrBXJAXOoCbezb4hojEHiHQCJpDhB0cleyYCfRmNBxrFC0jHo SPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JLM0M2/iM5IvBKksk3tv4/9fMZNZ9CPXIF7Se3ZZSBo=; b=nqGFP8yR2Eomc4HiHpJA9Id4e2YbElUXCitFPjHduAjc0v4ATszcxp2LEBnih2E6g2 0nxTCcjn0ESAlaErdFgn94yFQn7Y6cNaoVuRJBRYvDc6jaJOQyH7950OoHPqrXEaZ0r1 skuQ0HVDkDj11SRTqhJqjezCJ4ijvWeEwX+f3w0TzrEf5MQnGeftUrFrjU+Qw4EfX0H+ F8P3/N9oJYCiX0q9ikGeTu45DykAzP3dRbw0brhJCmZlgJI1Lcf9q2JGj5ZLN1QyGziU y7F0CmUjJP2BkJbamfG8mW5OQFjpRI3weaxQDOWSWIhe/6IgQt4GMffT308voVpebN+B w15w== X-Gm-Message-State: AGi0PuYuUmjmxrzVpjkiGxWTgQUhxlIAwZGlRbZHDY9yz9zjr7vYc0ik cHoNtsa3RhftiFRU31j9lgLyTYJV7n0= X-Google-Smtp-Source: APiQypJA9r54wRdzeiPj6ypDPyrt941wM+qUAqlebHhhon481e/dIr+eHzQCpDdmhezYjZ20T1Blew== X-Received: by 2002:a1c:8141:: with SMTP id c62mr18977313wmd.87.1586792008191; Mon, 13 Apr 2020 08:33:28 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:27 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:15 +0100 Message-Id: <20200413153321.5956-2-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] lavc: Extend hardware config metadata to encoders X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/avcodec.h | 11 ++++++++++- libavcodec/hwconfig.h | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 55151a0b71..136292fee7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2534,6 +2534,10 @@ enum { * AVCodecContext.hw_frames_ctx should be set to a suitable frames * context inside the get_format() callback. The frames context * must have been created on a device of the specified type. + * + * When selecting this format for an encoder, + * AVCodecContext.hw_frames_ctx should be set to the context which + * will be used for the input frames before calling avcodec_open2(). */ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02, /** @@ -2556,7 +2560,12 @@ enum { typedef struct AVCodecHWConfig { /** - * A hardware pixel format which the codec can use. + * For decoders, a hardware pixel format which that decoder may be + * able to decode to if suitable hardware is available. + * + * For encoders, a pixel format which the encoder may be able to + * accept. If set to AV_PIX_FMT_NONE, this applies to all pixel + * formats supported by the codec. */ enum AVPixelFormat pix_fmt; /** diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h index 4199ffdd50..f421dc909f 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -81,4 +81,22 @@ typedef struct AVCodecHWConfigInternal { #define HWACCEL_XVMC(codec) \ HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## _xvmc_hwaccel) +#define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \ + &(const AVCodecHWConfigInternal) { \ + .public = { \ + .pix_fmt = AV_PIX_FMT_ ## format, \ + .methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 0) | \ + (frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 0) | \ + (ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC : 0), \ + .device_type = AV_HWDEVICE_TYPE_ ## device_type_, \ + }, \ + .hwaccel = NULL, \ + } + +#define HW_CONFIG_ENCODER_DEVICE(format, device_type_) \ + HW_CONFIG_ENCODER(1, 0, 0, format, device_type_) + +#define HW_CONFIG_ENCODER_FRAMES(format, device_type_) \ + HW_CONFIG_ENCODER(0, 1, 0, format, device_type_) + #endif /* AVCODEC_HWCONFIG_H */ From patchwork Mon Apr 13 15:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18920 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 57057449F3D for ; Mon, 13 Apr 2020 18:33:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4298868B952; Mon, 13 Apr 2020 18:33:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE20568B94E for ; Mon, 13 Apr 2020 18:33:30 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id d77so9679800wmd.3 for ; Mon, 13 Apr 2020 08:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ln9nwmgFh3bq0xKYN0hyYqBJvuYNszyDKjjUFNOwmoY=; b=e7L+7IbqwmQaeJ/wJr5MucmrO0cp5JO0LACHBeXNg0J9oBiK44aMaCldYnNUN/+DSV LQv4DHZgaLk3xAmuiXQCSp0vuAqun18Z+W+rllFK2R9VLcC9u10i7SLwsbFcrUM53N26 Asm6T2sqMnmXvkBY4iY9I6JRf8K9UmbyvwF5ZjUwf/lHZnFaLf20jy+UtSNLe3lvEVrh vYK2ZXMa/6mPaLC0zo4c+xVYLR4EujvQ1qgemCULgg5MIUkIiZKHgqx0EGUs9gDNrxiA NzMsenBMqhlmAEUCpN/tWjNc1Lw7oZ8sKoTvckS57MV4nVD6HI06gIICVOJ2EavYQlUs xjgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ln9nwmgFh3bq0xKYN0hyYqBJvuYNszyDKjjUFNOwmoY=; b=r7BGNi6jiqPkEgty2wC+7eLGP0JOOEPT0PRn+C/cDkYtIv84lXL2Iz6EG8b9uLJ29U xwz+6sx35M9U0bJ77XI9HoEz4tww8F4rZI+/c3yJa/9r7LGD4dMcCPm2/l4CRKUdWCgh j6EeTlNDN5eWeMNemwQ22w3C5Ay3uj3NZRmwYpGL0kOGEcgU22gh3Mzu5jxlSfttXbuF 9rXBN2HCi5Rm1WjSclPwONEhkWKvTpKoQG4rZx9GJ5Irt6CyA7oVFhULEbYjsNZ82zD+ tmE+WAbZbrxzPmU/9K6zSVQkPtztzmtu80zkqSm9mrBCq5XlTrO35RopQpyM5v7o0HnW XKZw== X-Gm-Message-State: AGi0PuYS7YcoUNyPbw2MrV7QvSuxgQCFAIvYtbdfq8tTXIlLdLORo+GR O/v5auSBbU0GD9e37+9+P34kyj1G6sA= X-Google-Smtp-Source: APiQypIl9PoL/hX+kMQGHYGJOYJTR2sYOoTcAf2DFwIHXamq/cCDw3QcwuX200rnfBeU9nFGSqz/ng== X-Received: by 2002:a1c:2b43:: with SMTP id r64mr19804005wmr.77.1586792009999; Mon, 13 Apr 2020 08:33:29 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:29 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:16 +0100 Message-Id: <20200413153321.5956-3-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] lavc/qsvenc: Add hardware config metadata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" All of these encoders can accept libmfx surfaces directly in a hardware frames context, or they can accept software frames if a suitable device is supplied to use. --- libavcodec/qsvenc.c | 7 +++++++ libavcodec/qsvenc.h | 3 +++ libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + libavcodec/qsvenc_jpeg.c | 1 + libavcodec/qsvenc_mpeg2.c | 1 + libavcodec/qsvenc_vp9.c | 1 + 7 files changed, 15 insertions(+) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index afab8fd715..9ec0636dde 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1652,3 +1652,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) return 0; } + +const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[] = { + HW_CONFIG_ENCODER_FRAMES(QSV, QSV), + HW_CONFIG_ENCODER_DEVICE(NV12, QSV), + HW_CONFIG_ENCODER_DEVICE(P010, QSV), + NULL, +}; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 6609171af3..4f579d1db1 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -32,6 +32,7 @@ #include "libavutil/fifo.h" #include "avcodec.h" +#include "hwconfig.h" #include "qsv_internal.h" #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6) @@ -97,6 +98,8 @@ { "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, \ { "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, VE},\ +extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[]; + typedef int SetEncodeCtrlCB (AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl* enc_ctrl); typedef struct QSVEncContext { diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 27f36b9f7b..364975bea5 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -197,4 +197,5 @@ AVCodec ff_h264_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", + .hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 27e2232a9f..36e5ef6052 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -288,4 +288,5 @@ AVCodec ff_hevc_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", + .hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index 1619a335c7..f76af9486b 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -95,4 +95,5 @@ AVCodec ff_mjpeg_qsv_encoder = { .priv_class = &class, .defaults = qsv_enc_defaults, .wrapper_name = "qsv", + .hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index e4ade56d62..0e34bb75dc 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -112,4 +112,5 @@ AVCodec ff_mpeg2_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", + .hw_configs = ff_qsv_enc_hw_configs, }; diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 9402f806b1..ce44c09397 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -110,4 +110,5 @@ AVCodec ff_vp9_qsv_encoder = { .defaults = qsv_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "qsv", + .hw_configs = ff_qsv_enc_hw_configs, }; From patchwork Mon Apr 13 15:33:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18921 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 81CF9449F3D for ; Mon, 13 Apr 2020 18:33:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 679FC68B962; Mon, 13 Apr 2020 18:33:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1E7668B947 for ; Mon, 13 Apr 2020 18:33:31 +0300 (EEST) Received: by mail-wm1-f51.google.com with SMTP id v8so10340886wma.0 for ; Mon, 13 Apr 2020 08:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Xpai8rRuGzKrB+JXCgTOAU3XDjF3JXW+xMDUhbuqSNE=; b=1w9+1SwUfB3MF6QJufDBPCZkRV7Ci7krDxgcRINUm6AXEJIqUT04OqkZJXG6u9CN8O W5VDYRmS7z15GixFWkpz0gzS/ypo8si8J9d57aQsPALM6TB9dG6zytKyAjW0xEWtiT2F fXz1ZJsxtwncFFdZq8phmRc4FpdjwHhM6kIdLaimEs8T8Vz+eN1nPZy408PIE21Hw8p7 ccx3u7/xzvpXaups8Zv3L+zz3Z9I1ICLkrgJal3IaN0HeyC2Q+mKkA1n1rFO81uliBrr dQYR6CQoTAFo/0Jv03tOW48YgKS5ZPdmbpfoT5DSpAMRvdAIixjxHao1D+SVepYW0QC3 t2iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xpai8rRuGzKrB+JXCgTOAU3XDjF3JXW+xMDUhbuqSNE=; b=YyYuJ0fEL0yaH1yhhGO9+T+SYvt1p0ue+NM3IeoRuOW17nzzWwPyiYcCvU86ubyauq 1o2ebn/RFheNI5bfoo6eeu9Q/BPUf7SsoZNXlQinXlGKPdhZ1umdTqfoCz9DpzE80kKE Jvkr/quM9tPVKMRrLYxIUI1NNeYO7uqz307efvhCivS1i5cJJLyLDIOcf3bYKJAzi7hZ jbL8OiK08xdc1IKIjXW3skaNoXQMXsssaH5nSmL7gVqW72kkLPweoz4ftIgqgQS1MpXe 0/k44rmBuccPvd/c3bPz3Qush1dwLbWL899LRVVpaK1r11OlP8jmDVj/2OwSOi9mjmwY EWOA== X-Gm-Message-State: AGi0PuaYINBpGykfHP2iweft2LYsj04FE3C+qtjG3fF3/zBmsVcdUJw7 Wp9tkW9iu2qb+mowz/XKeE+ZgwFIn9M= X-Google-Smtp-Source: APiQypJzgz6OKlxrIe5khlhFEUm+ywGIJa85dEVCx92uFoCsNvmzqUHTB8g4NqwVXDF3SY9vUCsg7Q== X-Received: by 2002:a05:600c:114d:: with SMTP id z13mr19305641wmz.54.1586792010827; Mon, 13 Apr 2020 08:33:30 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:30 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:17 +0100 Message-Id: <20200413153321.5956-4-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] lavc/vaapi_encode: Add hardware config metadata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These encoders all accept VAAPI surfaces in a hardware frames context. --- libavcodec/vaapi_encode.c | 5 +++++ libavcodec/vaapi_encode.h | 3 +++ libavcodec/vaapi_encode_h264.c | 1 + libavcodec/vaapi_encode_h265.c | 1 + libavcodec/vaapi_encode_mjpeg.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 1 + libavcodec/vaapi_encode_vp8.c | 1 + libavcodec/vaapi_encode_vp9.c | 1 + 8 files changed, 14 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 8ff720e395..f551967ad6 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -27,6 +27,11 @@ #include "vaapi_encode.h" #include "avcodec.h" +const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[] = { + HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI), + NULL, +}; + static const char * const picture_type_name[] = { "IDR", "I", "P", "B" }; static int vaapi_encode_make_packed_header(AVCodecContext *avctx, diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index b9a3defd72..1329f6428f 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -31,6 +31,7 @@ #include "libavutil/hwcontext_vaapi.h" #include "avcodec.h" +#include "hwconfig.h" struct VAAPIEncodeType; struct VAAPIEncodePicture; @@ -44,6 +45,8 @@ enum { MAX_PARAM_BUFFER_SIZE = 1024, }; +extern const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[]; + enum { PICTURE_TYPE_IDR = 0, PICTURE_TYPE_I = 1, diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index f4965d8b09..67b1ecae1b 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1361,5 +1361,6 @@ AVCodec ff_h264_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 97dc5a7e75..e20e8cbdd0 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1297,5 +1297,6 @@ AVCodec ff_hevc_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index bd029cc903..2b5d3bf4f9 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -570,5 +570,6 @@ AVCodec ff_mjpeg_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index bac9ea1fa6..0398c4cd8c 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -707,5 +707,6 @@ AVCodec ff_mpeg2_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index 6e7bf9d106..16cbcbd81c 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -262,5 +262,6 @@ AVCodec ff_vp8_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index d7f415d704..d05319ef39 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -296,5 +296,6 @@ AVCodec ff_vp9_vaapi_encoder = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE, }, + .hw_configs = ff_vaapi_encode_hw_configs, .wrapper_name = "vaapi", }; From patchwork Mon Apr 13 15:33:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18922 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 37C27449F3D for ; Mon, 13 Apr 2020 18:33:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 235D368B96A; Mon, 13 Apr 2020 18:33:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B4A0968B958 for ; Mon, 13 Apr 2020 18:33:32 +0300 (EEST) Received: by mail-wm1-f51.google.com with SMTP id v8so10340910wma.0 for ; Mon, 13 Apr 2020 08:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3bqUh7e0iDdvIrQgdHzm6lmPr4PQaqzLjBQFZ5Z99+o=; b=LOY6GMFNMdOtjRxw4w1QkbVIZpDP6rHx4mZ/qDtkWBt9wKcOrrqZGIU3pv9RcREl4T B4ETM0Ihzea1gnWPIIC46o86YObOO4iJhnz7/19H0RfWZPwCP2VIn5X1I3v++ga1Sqay mpyfoFpxwNDRnD1bsgn8QzKNaycUopTzTZjsAOUovgwMSz6ok+5xSofKVIHA8+aEQJXl jZ2eHmTEpdXK/D867lMouWtB+lLhh7iBpSPnm2U2634aSZH+RNlkkDQCba1H6+W+2QNx mf2Bw616k+vhWjpK060TsEMT/hIrbEhIbl7N3SdUOEbvehG7Qj5xXdNWjZe4uSY6Z6kc U3Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3bqUh7e0iDdvIrQgdHzm6lmPr4PQaqzLjBQFZ5Z99+o=; b=pS4ZXS2LY13PLEivw9QSSP3POQsNLN6G1Q6WhEIyPAlEz4mTMqXGbfJpMKiA/vqV7B lnYcA3guiHIhPDHaMQOwJyi95etyOPkqcjkXwShfHUeMryM6Ttr3zm5hfC0nrzkRKsiH JcQjlkh9dOOZyTPrWg9a1Ae6tJDS8Tz8txXkxfnZ3LOsbGnKiQ6PIt6kNz0PsHs0F8z0 fVMtq4ciPI605iOReMDgEnjglL7Hb7eV4qPVXiaQLRuJNeq6rfpIgeJFFGEWY+o7pqua 8/i+d3bfU5U2N00mVR+Kmm/5WE5lZDYCHwvSjC5AMftmQpjUV5CXp28NeWM5OSaILrD8 3unw== X-Gm-Message-State: AGi0PuYtsLpUNIAL1P0kt7H1ouPEHl6RwC8zM4IWosvX04+tJshh+iyF EywgcD21jMWgIyGmSwjQ6MrESmEmbRY= X-Google-Smtp-Source: APiQypI0bR82wLgA87TzC9YoGcf8OsJA6C0pu+izDC3YYFFssY6LCcw9P+Isg4RKoCLjD8UVlSdUOQ== X-Received: by 2002:a1c:f715:: with SMTP id v21mr17992287wmh.83.1586792011784; Mon, 13 Apr 2020 08:33:31 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:31 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:18 +0100 Message-Id: <20200413153321.5956-5-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] lavc/nvenc: Add hardware config metadata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" NOT TESTED. --- Needs someone with suitable hardware to try it. With this and the relevant ffmpeg patches, existing stuff should continue to work and you should also be able to choose between multiple devices for a standalone encoder with things like: ffmpeg -init_hw_device cuda:2 ... -c:v nvenc ... ffmpeg -init_hw_device d3d11:2 ... -c:v nvenc ... libavcodec/nvenc.c | 11 +++++++++++ libavcodec/nvenc.h | 1 + libavcodec/nvenc_h264.c | 1 + libavcodec/nvenc_hevc.c | 1 + 4 files changed, 14 insertions(+) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 9a96bf2bba..b0cd8874ee 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -30,6 +30,7 @@ #include "libavutil/avassert.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" +#include "hwconfig.h" #include "internal.h" #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x) @@ -55,6 +56,16 @@ const enum AVPixelFormat ff_nvenc_pix_fmts[] = { AV_PIX_FMT_NONE }; +const AVCodecHWConfigInternal *ff_nvenc_hw_configs[] = { + HW_CONFIG_ENCODER_FRAMES(CUDA, CUDA), + HW_CONFIG_ENCODER_DEVICE(NONE, CUDA), +#if CONFIG_D3D11VA + HW_CONFIG_ENCODER_FRAMES(D3D11, D3D11), + HW_CONFIG_ENCODER_DEVICE(NONE, D3D11), +#endif + NULL, +}; + #define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010 || \ pix_fmt == AV_PIX_FMT_P016 || \ pix_fmt == AV_PIX_FMT_YUV444P16) diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index c44c81e675..c80332d914 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -217,5 +217,6 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, void ff_nvenc_encode_flush(AVCodecContext *avctx); extern const enum AVPixelFormat ff_nvenc_pix_fmts[]; +extern const AVCodecHWConfigInternal *ff_nvenc_hw_configs[]; #endif /* AVCODEC_NVENC_H */ diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 479155fe15..6d82422308 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -248,4 +248,5 @@ AVCodec ff_h264_nvenc_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_nvenc_pix_fmts, .wrapper_name = "nvenc", + .hw_configs = ff_nvenc_hw_configs, }; diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 7c9b3848f1..58d5265977 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -206,4 +206,5 @@ AVCodec ff_hevc_nvenc_encoder = { .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "nvenc", + .hw_configs = ff_nvenc_hw_configs, }; From patchwork Mon Apr 13 15:33:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18925 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 57EB644B8E3 for ; Mon, 13 Apr 2020 18:41:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 322F268B956; Mon, 13 Apr 2020 18:41:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3F1B68B3F2 for ; Mon, 13 Apr 2020 18:41:26 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id g12so2561499wmh.3 for ; Mon, 13 Apr 2020 08:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HutUeCDLZhCxGxotwqef41mJRWOCtvBFzmd6vzhiv5g=; b=k0VBuIVsXRRkqGMCXpSpuu8Dh/DsluR2W73KvN6EFpjkFHVxXoKoN1Vq+j/JX3uv9B SLx6s+wlmm4BbBkYSG5sZFc1GInnoo4vMAOE62IwABar9xLI5fogt9MuH8ZSx6FvZNc8 U78cMAc4hE+O1hfc6BSH3uVtV19wdI2MZX6BlKNfMxXjQqWkB9vlUBvts1Usr1HH5iq+ 6Dml7/Hhf76TcTDpzSC4w3dxXjen3YR7zChrbkUq9Q7EG52YfOjKP30EmKIbIPHnrY8K mLh/ONCrX/XRs85GzaMFwUXdWiivOUxGIV2hj56QM7dxH1f6UkU7cAzV1WCIOOFMXYdX gJRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HutUeCDLZhCxGxotwqef41mJRWOCtvBFzmd6vzhiv5g=; b=j1m60H68iG/frzQIuzr9NBcm2++t21e1zu6cWfbXSnBIpPRZFWAHaOfKP1de2ucoUV d0jfD+BuyyVHvoBscgMl/DweSEpSb+qKXmjwWAm4VPPuL/BbOlIBXeaSdBnNnGukhPeJ 9tMv6tPOA0DVO7CpoDNdCNkH14LI/Qe6DqOu6/8y1oMwmbMfoxfrlEmRVeU4TJMqp6Aw LrvRcokd7GK+XAukOp/wWZDBrNJgws4bMjujs7b9GjxwKQQd4c5J30xvwV/FqYUDGb94 WoI3KQJBtYBnbbEyPGYny71E7S7NNpLAH7HDKlfrZhYVquyOYraLYiIBRDS0hnKzcQ53 ZhFA== X-Gm-Message-State: AGi0PuYLy1kOOP5pcvzJ/dVQI72Wd20PKrbkWBUdvSUY8GFCtvqoNUlC vOvkfP5BHUC/C/CgIlp6n4h7Fy6rtCw= X-Google-Smtp-Source: APiQypKcD5tCYY2MzDAB0o8BYa18VKjoPnp8ioJs9HNtBgiyrlD07B3u+m2qB+RzrYJvbrWyh95Rzw== X-Received: by 2002:a1c:9d8c:: with SMTP id g134mr19783615wme.79.1586792012702; Mon, 13 Apr 2020 08:33:32 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:32 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:19 +0100 Message-Id: <20200413153321.5956-6-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] ffmpeg: Make filter hardware device selection clearer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Also move it into a dedicated function in the hardware file. --- fftools/ffmpeg.h | 1 + fftools/ffmpeg_filter.c | 14 +++----------- fftools/ffmpeg_hw.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fbaae15377..43b5040f73 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -661,6 +661,7 @@ void hw_device_free_all(void); int hw_device_setup_for_decode(InputStream *ist); int hw_device_setup_for_encode(OutputStream *ost); +int hw_device_setup_for_filter(FilterGraph *fg); int hwaccel_decode_init(AVCodecContext *avctx); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index b66faa50b5..8b5b157be7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1061,17 +1061,9 @@ int configure_filtergraph(FilterGraph *fg) if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0) goto fail; - if (filter_hw_device || hw_device_ctx) { - AVBufferRef *device = filter_hw_device ? filter_hw_device->device_ref - : hw_device_ctx; - for (i = 0; i < fg->graph->nb_filters; i++) { - fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(device); - if (!fg->graph->filters[i]->hw_device_ctx) { - ret = AVERROR(ENOMEM); - goto fail; - } - } - } + ret = hw_device_setup_for_filter(fg); + if (ret < 0) + goto fail; if (simple && (!inputs || inputs->next || !outputs || outputs->next)) { const char *num_inputs; diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 962d8f7d5a..40739fc320 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -480,3 +480,31 @@ int hwaccel_decode_init(AVCodecContext *avctx) return 0; } + +int hw_device_setup_for_filter(FilterGraph *fg) +{ + HWDevice *dev; + int i; + + // If the user has supplied exactly one hardware device then just + // give it straight to every filter for convenience. If more than + // one device is available then the user needs to pick one explcitly + // with the filter_hw_device option. + if (filter_hw_device) + dev = filter_hw_device; + else if (nb_hw_devices == 1) + dev = hw_devices[0]; + else + dev = NULL; + + if (dev) { + for (i = 0; i < fg->graph->nb_filters; i++) { + fg->graph->filters[i]->hw_device_ctx = + av_buffer_ref(dev->device_ref); + if (!fg->graph->filters[i]->hw_device_ctx) + return AVERROR(ENOMEM); + } + } + + return 0; +} From patchwork Mon Apr 13 15:33:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18923 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 703A5449F3D for ; Mon, 13 Apr 2020 18:33:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B42468B96D; Mon, 13 Apr 2020 18:33:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8963068B954 for ; Mon, 13 Apr 2020 18:33:34 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id p10so10567338wrt.6 for ; Mon, 13 Apr 2020 08:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pjNdpAEnnMQSkms6arCjp718jia7pzj7OyEd1tSdcoI=; b=w3eNN7Bq7nDk1aFj3JRcaj75i3Qzr0XKnT30BeUmlAMpay6VyRIxCpp5vNMYAUyPFY +vHTi6vAYmnhtobMeKMbWkb/HC98N5bZe6aRRdU/31b7n/ZbMNuusZIjalANH8JSJXiA O1DSCP7BegNkLpJUFJeG8/thjk6FxmOvG18eRCKhJ/KdNqBn4nHCrqGrsPBCE+0C0CXd Ogs3DtvuS73z6hI3sBFfb7byjc2/fVTw+oqUjJFLDDVYwT/WcO1GnzQeLlPYl63ncRb8 Af2z7QNm+/ZIcw2B5SSHladcvwtdjeOL3Lyy+Q9xAxL4z8V3XxRygRf+HjI2HW1hsqaH 5Lfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pjNdpAEnnMQSkms6arCjp718jia7pzj7OyEd1tSdcoI=; b=PzSln0Ia2vOLG2CdLUwP2yyam0u2g/Q5cOh0jrVnPIAJx4P2qnni2IV1P8rbwfwEXa alxfQI6w0YzRWpbDxMQ2YRrTBnWt/7yBMHZAkKTO62Zjd5kaHaRaTZTTlVlAmwQ1pzaI 4MALVaKgqvXHGi+VOa8rPvx/QSb6zjtQJKqTBpmpkPBVRuV2qdEbFFchCdvu0xzkKv90 kNz5IuOn7uzUgyI+IdaN5aB9Z1S1ENz9s3V8BtlXGxf+5nhv9J5wIe1vuFGkIr70zPZF U2kx7nohKVVvPoq9zy71syEWV4Okiv5QAbVVMRH5d2ef2gSk90tV7mvYgO2pOlzFhXcX T0aA== X-Gm-Message-State: AGi0PuYrbVYzVSo6QDJDxNsgt8uXlFLPyRgCfHFPNrBMbC0TZQcPebXS UjyYATWKVFqFB5dwQoD0T+IMB8ulsRo= X-Google-Smtp-Source: APiQypJ+wnontPY5wW4P1IwNn0dbQ1GTKp34U/7s+Er493TlU9chPRSEjd8v8SkWulp5oO66QrSF8g== X-Received: by 2002:a5d:654f:: with SMTP id z15mr16463021wrv.338.1586792013661; Mon, 13 Apr 2020 08:33:33 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:32 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:20 +0100 Message-Id: <20200413153321.5956-7-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] ffmpeg: Use hardware config metadata with encoders X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This can support encoders which want frames and/or device contexts. For the device case, it currently picks the first initialised device of the desired type to give to the encoder - a new option would be needed if it were necessary to choose between multiple devices of the same type. --- fftools/ffmpeg.c | 19 ++++++------------ fftools/ffmpeg_hw.c | 48 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0578265c1e..5089443c9d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3476,21 +3476,14 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) av_dict_set(&ost->encoder_opts, "b", "128000", 0); - if (ost->filter && av_buffersink_get_hw_frames_ctx(ost->filter->filter) && - ((AVHWFramesContext*)av_buffersink_get_hw_frames_ctx(ost->filter->filter)->data)->format == - av_buffersink_get_format(ost->filter->filter)) { - ost->enc_ctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(ost->filter->filter)); - if (!ost->enc_ctx->hw_frames_ctx) - return AVERROR(ENOMEM); - } else { - ret = hw_device_setup_for_encode(ost); - if (ret < 0) { - snprintf(error, error_len, "Device setup failed for " - "encoder on output stream #%d:%d : %s", + ret = hw_device_setup_for_encode(ost); + if (ret < 0) { + snprintf(error, error_len, "Device setup failed for " + "encoder on output stream #%d:%d : %s", ost->file_index, ost->index, av_err2str(ret)); - return ret; - } + return ret; } + if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) { int input_props = 0, output_props = 0; AVCodecDescriptor const *input_descriptor = diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 40739fc320..c5c8aa97ef 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -19,6 +19,7 @@ #include #include "libavutil/avstring.h" +#include "libavfilter/buffersink.h" #include "ffmpeg.h" @@ -281,7 +282,10 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -static HWDevice *hw_device_match_by_codec(const AVCodec *codec) +static HWDevice *hw_device_match_by_codec(const AVCodec *codec, + enum AVPixelFormat format, + int possible_methods, + int *matched_methods) { const AVCodecHWConfig *config; HWDevice *dev; @@ -290,11 +294,18 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec) config = avcodec_get_hw_config(codec, i); if (!config) return NULL; - if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) + if (format != AV_PIX_FMT_NONE && + config->pix_fmt != AV_PIX_FMT_NONE && + config->pix_fmt != format) + continue; + if (!(config->methods & possible_methods)) continue; dev = hw_device_get_by_type(config->device_type); - if (dev) + if (dev) { + if (matched_methods) + *matched_methods = config->methods & possible_methods; return dev; + } } } @@ -340,7 +351,9 @@ int hw_device_setup_for_decode(InputStream *ist) if (!dev) err = hw_device_init_from_type(type, NULL, &dev); } else { - dev = hw_device_match_by_codec(ist->dec); + dev = hw_device_match_by_codec(ist->dec, AV_PIX_FMT_NONE, + AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, + NULL); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -417,12 +430,31 @@ int hw_device_setup_for_decode(InputStream *ist) int hw_device_setup_for_encode(OutputStream *ost) { HWDevice *dev; + AVBufferRef *frames_ref; + int methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; + int matched_methods; + + if (ost->filter) { + frames_ref = av_buffersink_get_hw_frames_ctx(ost->filter->filter); + if (frames_ref && + ((AVHWFramesContext*)frames_ref->data)->format == + ost->enc_ctx->pix_fmt) + methods |= AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX; + } - dev = hw_device_match_by_codec(ost->enc); + dev = hw_device_match_by_codec(ost->enc, ost->enc_ctx->pix_fmt, + methods, &matched_methods); if (dev) { - ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); - if (!ost->enc_ctx->hw_device_ctx) - return AVERROR(ENOMEM); + if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) { + ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); + if (!ost->enc_ctx->hw_device_ctx) + return AVERROR(ENOMEM); + } + if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) { + ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref); + if (!ost->enc_ctx->hw_frames_ctx) + return AVERROR(ENOMEM); + } return 0; } else { // No device required, or no device available. From patchwork Mon Apr 13 15:33:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 18924 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 51C56449F3D for ; Mon, 13 Apr 2020 18:33:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 368EE68B968; Mon, 13 Apr 2020 18:33:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BF4A68B966 for ; Mon, 13 Apr 2020 18:33:35 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id v5so10551109wrp.12 for ; Mon, 13 Apr 2020 08:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aQHP2Fui+V8DQAx4CBwJduNucerfsPMl8E33+gfOc8k=; b=h/XcRAy5wWO2U05PhmTv1X888e3utGb2YZ5RHXpc3+wm8IlEpasgOaDs/nl1cw2J5I Y7fcSfp4xE4yB407KQ0PtrI/bHHbClESuq6iFOYQvK8sDw4lNGyuNpNJcsnFmF9Etm5k e7OUGZ7W0+UfIM3iDIZS/5aSE8QW4uwb6CzEXZ0XS9p/ZwuDdvAPogT50TLbpgdWeKFs cvfFhLqXcfO6zHxKXeOXUd6k57yygbMzIUttHkKB1DHmy2lSoL4yR2HSPeLS1P93IoQd H1lr7BAP6fod8dfWaJ9snkgs2jKTpflZCuvjs3rjf3O89mpq1lavvEz544I1a2ZDIuO3 WHxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQHP2Fui+V8DQAx4CBwJduNucerfsPMl8E33+gfOc8k=; b=nYF3RAgzuy18Js09SNggwt9o7Y5upegzWKIyo4wDtbv4GNaUh4t3KuuCQ3nhYLxVTi pVruSAQKs35+26DkyPT3iDtRGqTx7fwihwx6yv8K160wuzKtJOlNWk7UURBH3kqZa9S9 zMCkY16Ptn5wysWgd1TK+lJxs0rc4FSnFeQ4u9ZByJanWArsLMlwzS+8KpIXKrP+5yRh 8TgztpPXD72meYTBYsf2y6Y+VnmRCf0KXkzqzwWN2s6/ujR7G/SYE6i5zFboU6OrKSJ4 lQp2dS9UOw1LjtzFy6Q0A3mMLpwOwUqEBhIOD8hU0WMoRyHqmTuPv5sAo21zFhJXRGOg TDgw== X-Gm-Message-State: AGi0PubxRVhzgheebjWZoLFAlTEzXA65cgn7AVX3AW2PtWKvGOSp5bsj 3UGZJ6NLEYSeu/1r56EmsNwbyo32OrI= X-Google-Smtp-Source: APiQypIiWy5nrxkn3ZR3rjMgaYXhFCiklAoFG1xOYvyOW6jNMzYHSjU31vE0kJtP4syiwn36DUdsWw== X-Received: by 2002:adf:a18c:: with SMTP id u12mr15500187wru.325.1586792014574; Mon, 13 Apr 2020 08:33:34 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id t8sm15157557wrq.88.2020.04.13.08.33.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:33:34 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Apr 2020 16:33:21 +0100 Message-Id: <20200413153321.5956-8-sw@jkqxz.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413153321.5956-1-sw@jkqxz.net> References: <20200413153321.5956-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] ffmpeg: Remove the hw_device_ctx global X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The ad-hoc libmfx setup code is the only place its still used, so move it into that file. --- fftools/ffmpeg.c | 1 - fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 11 ++--------- fftools/ffmpeg_qsv.c | 1 + 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 5089443c9d..32350fe24b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4759,7 +4759,6 @@ static int transcode(void) } } - av_buffer_unref(&hw_device_ctx); hw_device_free_all(); /* finished ! */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 43b5040f73..98700f24e5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -615,7 +615,6 @@ extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; extern const HWAccel hwaccels[]; -extern AVBufferRef *hw_device_ctx; #if CONFIG_QSV extern char *qsv_device; #endif diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 95001a963f..6b80b98f2d 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -139,7 +139,6 @@ const HWAccel hwaccels[] = { #endif { 0 }, }; -AVBufferRef *hw_device_ctx; HWDevice *filter_hw_device; char *vstats_filename; @@ -539,21 +538,15 @@ static int opt_sdp_file(void *optctx, const char *opt, const char *arg) #if CONFIG_VAAPI static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) { - HWDevice *dev; const char *prefix = "vaapi:"; char *tmp; int err; tmp = av_asprintf("%s%s", prefix, arg); if (!tmp) return AVERROR(ENOMEM); - err = hw_device_init_from_string(tmp, &dev); + err = hw_device_init_from_string(tmp, NULL); av_free(tmp); - if (err < 0) - return err; - hw_device_ctx = av_buffer_ref(dev->device_ref); - if (!hw_device_ctx) - return AVERROR(ENOMEM); - return 0; + return err; } #endif diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c index 9c4285b6c7..960c88b69d 100644 --- a/fftools/ffmpeg_qsv.c +++ b/fftools/ffmpeg_qsv.c @@ -28,6 +28,7 @@ #include "ffmpeg.h" +static AVBufferRef *hw_device_ctx; char *qsv_device = NULL; static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)