From patchwork Tue Dec 5 06:46:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 44906 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9153:b0:181:818d:5e7f with SMTP id x19csp145709pzc; Mon, 4 Dec 2023 22:52:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAoRbY5JKs6mCyhmFZW6kHRT16QjRpt2sAHp6P98E+8ugAs2u3R6K+ra/neZ2snXEGp+q8 X-Received: by 2002:a17:906:4:b0:a19:9b79:8b4b with SMTP id 4-20020a170906000400b00a199b798b4bmr100040eja.92.1701759121005; Mon, 04 Dec 2023 22:52:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701759120; cv=none; d=google.com; s=arc-20160816; b=Nac5G+dS03k9QbP6MBTYyHCYzHle/81yMyGdELzkVY+MUV0OjL4OKwot+8xEz+XyAZ 03t2M7ki3aB84rWOvIVJ2lgYCWZWgNAIaPwQO3Ji8eT54Fs9ieva4eOe3/7rhdU3Cn66 uRrjMWz3KCZH2vdUi/Mf5mOgMGpP68M2FgQEwgItblsdZ0nX02WaLjA5oYIyGRvzgy2f lbV7Wgiy6f/FcVRhJMgp3uj1Ht2+IqfgIDuQ0K+dDoLuv7mFmcgo5n9u22UsOI3sCK/M 6eHQvvr4nlcDiyPefU+aQ4a6os7lOIpMsd/QiJPQ9PrcQhG9molTW5R6yWFMtGYZszVP MKlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=UwtK+iPD9jv5FlRHHnnNG5YITFue8yNEBgfZmGOa9Uw=; fh=9GN8hc/WTnabikg2VxPLeDN+i3R37IqYi/LhxNANmV0=; b=trjKUxmrR85Nz8iVtcKgawTFaj+tseiABDx6xNqUd5PZVNsSFrGt8SdDcTEpKI6GSo qYt/Ipnif+YQWia5/7fb3TqcLtuP/Unqm6mJRJuBgJu+a++7CdcoVVLrLjv8zm2HsiHa dY7AUpjMY/F8/78biBB+U5e4LPO+2+to/TJ0u52yE/TkCuXbS23QUjGhyXZnUY9iKd8N IVWtjvE69++nv2f3k6mgIGPea61JrM/TvTZyYGpX2L7skA4QrJSs75zKQJ72mf2E5+nc 1CedognQdFUZGZCjXG8RcmMERs52gVSeayMPio95fqUgiiX4A25YHKwBl08qGczYKiEj ljHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=B7HUehYS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i21-20020a170906251500b00a1872f23b68si5084853ejb.891.2023.12.04.22.52.00; Mon, 04 Dec 2023 22:52:00 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=B7HUehYS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E16768CED9; Tue, 5 Dec 2023 08:51:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE1FC68CA67 for ; Tue, 5 Dec 2023 08:51:28 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701759094; x=1733295094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gV7LP+VXPs7qIr4qBr310QNz48OEFl+mhbvO9TCXaGs=; b=B7HUehYSKWeUr7HiMDIrFgYK9MFyUOKgP6GL4mSJx9lBVKVJvZNorFpM E1OWKmRXm3dwtPE7eVPFA+h1nS79Gqt6si8pBaxWTk74jIFJhl14ae0x5 mGdpaQtHkbsI84Pqr21A+tKThWuneJyTJVfQZDpUZzH/WrDu89QdOm9Vp zHWNQJbW5V7P/+K31CGeFymq+En1+qFsfGH/9CvT3W2tJSbixPpKk5VAt aAK/3lQ9a1GXeh//ZHitDDsC3g+oL1vAQbz+fS2Voqn3TAfodk30nnchz SAB+45gx5RIi4TBs6Ramr6vbEe9/ZOPt01AMiFhOMifzLw7gpImDdreTO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="391012385" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="391012385" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 22:51:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="799853599" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="799853599" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.66]) by orsmga008.jf.intel.com with ESMTP; 04 Dec 2023 22:51:22 -0800 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Tue, 5 Dec 2023 14:46:45 +0800 Message-ID: <20231205065034.1621-3-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20231205065034.1621-1-tong1.wu@intel.com> References: <20231205065034.1621-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 3/9] avcodec: add D3D12VA hardware accelerated HEVC decoding X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Tong Wu , Wu Jianhua Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: p3R6LCvIRec2 From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 1 + libavcodec/d3d12va_hevc.c | 208 ++++++++++++++++++++++++++++++++++++ libavcodec/dxva2_hevc.c | 14 +-- libavcodec/dxva2_internal.h | 4 + libavcodec/hevcdec.c | 10 ++ libavcodec/hwaccels.h | 1 + 7 files changed, 234 insertions(+), 6 deletions(-) create mode 100644 libavcodec/d3d12va_hevc.c diff --git a/configure b/configure index 90b20da49a..f1a9406123 100755 --- a/configure +++ b/configure @@ -3100,6 +3100,8 @@ hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va2_hwaccel_select="hevc_decoder" +hevc_d3d12va_hwaccel_deps="d3d12va DXVA_PicParams_HEVC" +hevc_d3d12va_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ead3a4480e..66284b3420 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1013,6 +1013,7 @@ OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_H264_VULKAN_HWACCEL) += vulkan_decode.o vulkan_h264.o OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o +OBJS-$(CONFIG_HEVC_D3D12VA_HWACCEL) += dxva2_hevc.o d3d12va_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c new file mode 100644 index 0000000000..6537e46065 --- /dev/null +++ b/libavcodec/d3d12va_hevc.c @@ -0,0 +1,208 @@ +/* + * Direct3D 12 HEVC HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config_components.h" + +#include "libavutil/avassert.h" +#include "libavutil/hwcontext_d3d12va_internal.h" +#include "hevc_data.h" +#include "hevcdec.h" +#include "dxva2_internal.h" +#include "d3d12va_decode.h" +#include + +#define MAX_SLICES 256 + +typedef struct HEVCDecodePictureContext { + DXVA_PicParams_HEVC pp; + DXVA_Qmatrix_HEVC qm; + unsigned slice_count; + DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]; + const uint8_t *bitstream; + unsigned bitstream_size; +} HEVCDecodePictureContext; + +static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size) +{ + memset(slice, 0, sizeof(*slice)); + slice->BSNALunitDataLocation = position; + slice->SliceBytesInBuffer = size; + slice->wBadSliceChopping = 0; +} + +static int d3d12va_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ + const HEVCContext *h = avctx->priv_data; + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private; + + if (!ctx) + return -1; + + av_assert0(ctx_pic); + + ctx->used_mask = 0; + + ff_dxva2_hevc_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp); + + ff_dxva2_hevc_fill_scaling_lists(avctx, (AVDXVAContext *)ctx, &ctx_pic->qm); + + ctx_pic->slice_count = 0; + ctx_pic->bitstream_size = 0; + ctx_pic->bitstream = NULL; + + return 0; +} + +static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ + const HEVCContext *h = avctx->priv_data; + const HEVCFrame *current_picture = h->ref; + HEVCDecodePictureContext *ctx_pic = current_picture->hwaccel_picture_private; + unsigned position; + + if (ctx_pic->slice_count >= MAX_SLICES) + return AVERROR(ERANGE); + + if (!ctx_pic->bitstream) + ctx_pic->bitstream = buffer; + ctx_pic->bitstream_size += size; + + position = buffer - ctx_pic->bitstream; + fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count], position, size); + ctx_pic->slice_count++; + + return 0; +} + +#define START_CODE 65536 +#define START_CODE_SIZE 3 +static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer) +{ + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + AVHWFramesContext *frames_ctx = D3D12VA_FRAMES_CONTEXT(avctx); + AVD3D12VAFramesContext *frames_hwctx = frames_ctx->hwctx; + + const HEVCContext *h = avctx->priv_data; + const HEVCFrame *current_picture = h->ref; + HEVCDecodePictureContext *ctx_pic = current_picture->hwaccel_picture_private; + + int i; + uint8_t *mapped_data, *mapped_ptr; + DXVA_Slice_HEVC_Short *slice; + D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args; + + if (FAILED(ID3D12Resource_Map(buffer, 0, NULL, &mapped_data))) { + av_log(avctx, AV_LOG_ERROR, "Failed to map D3D12 Buffer resource!\n"); + return AVERROR(EINVAL); + } + + mapped_ptr = mapped_data; + for (i = 0; i < ctx_pic->slice_count; i++) { + UINT position, size; + slice = &ctx_pic->slice_short[i]; + + position = slice->BSNALunitDataLocation; + size = slice->SliceBytesInBuffer; + + slice->SliceBytesInBuffer += START_CODE_SIZE; + slice->BSNALunitDataLocation = mapped_ptr - mapped_data; + + *(uint32_t *)mapped_ptr = START_CODE; + mapped_ptr += START_CODE_SIZE; + + memcpy(mapped_ptr, &ctx_pic->bitstream[position], size); + mapped_ptr += size; + } + + ID3D12Resource_Unmap(buffer, 0, NULL); + + input_args->CompressedBitstream = (D3D12_VIDEO_DECODE_COMPRESSED_BITSTREAM){ + .pBuffer = buffer, + .Offset = 0, + .Size = mapped_ptr - mapped_data, + }; + + args = &input_args->FrameArguments[input_args->NumFrameArguments++]; + args->Type = D3D12_VIDEO_DECODE_ARGUMENT_TYPE_SLICE_CONTROL; + args->Size = sizeof(DXVA_Slice_HEVC_Short) * ctx_pic->slice_count; + args->pData = ctx_pic->slice_short; + + return 0; +} + +static int d3d12va_hevc_end_frame(AVCodecContext *avctx) +{ + HEVCContext *h = avctx->priv_data; + HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private; + + int scale = ctx_pic->pp.dwCodingParamToolFlags & 1; + + if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) + return -1; + + return ff_d3d12va_common_end_frame(avctx, h->ref->frame, &ctx_pic->pp, sizeof(ctx_pic->pp), + scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, update_input_arguments); +} + +static int d3d12va_hevc_decode_init(AVCodecContext *avctx) +{ + HEVCContext *h = avctx->priv_data; + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + DXVA_PicParams_HEVC pp; + + switch (avctx->profile) { + case FF_PROFILE_HEVC_MAIN_10: + ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN10; + break; + + case FF_PROFILE_HEVC_MAIN_STILL_PICTURE: + av_log(avctx, AV_LOG_ERROR, "D3D12 doesn't support PROFILE_HEVC_MAIN_STILL_PICTURE!\n"); + return AVERROR(EINVAL); + + case FF_PROFILE_HEVC_MAIN: + default: + ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN; + break; + }; + + ctx->max_num_ref = FF_ARRAY_ELEMS(pp.RefPicList) + 1; + + return ff_d3d12va_decode_init(avctx); +} + +#if CONFIG_HEVC_D3D12VA_HWACCEL +const FFHWAccel ff_hevc_d3d12va_hwaccel = { + .p.name = "hevc_d3d12va", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_HEVC, + .p.pix_fmt = AV_PIX_FMT_D3D12, + .init = d3d12va_hevc_decode_init, + .uninit = ff_d3d12va_decode_uninit, + .start_frame = d3d12va_hevc_start_frame, + .decode_slice = d3d12va_hevc_decode_slice, + .end_frame = d3d12va_hevc_end_frame, + .frame_params = ff_d3d12va_common_frame_params, + .frame_priv_data_size = sizeof(HEVCDecodePictureContext), + .priv_data_size = sizeof(D3D12VADecodeContext), +}; +#endif diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 9e1d081412..31d74a7164 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -57,9 +57,10 @@ static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index) return 0xff; } -static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h, +void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_HEVC *pp) { + const HEVCContext *h = avctx->priv_data; const HEVCFrame *current_picture = h->ref; const HEVCSPS *sps = h->ps.sps; const HEVCPPS *pps = h->ps.pps; @@ -79,8 +80,6 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * (0 << 14) | (0 << 15); - fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame, 1), 0); - pp->sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1; pp->log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3; pp->log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size; @@ -179,6 +178,8 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * } } + fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame, 1), 0); + #define DO_REF_LIST(ref_idx, ref_list) { \ const RefPicList *rpl = &h->rps[ref_idx]; \ for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ref_list); i++) { \ @@ -200,8 +201,9 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++; } -static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm) +void ff_dxva2_hevc_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_HEVC *qm) { + const HEVCContext *h = avctx->priv_data; unsigned i, j, pos; const ScalingList *sl = h->ps.pps->scaling_list_data_present_flag ? &h->ps.pps->scaling_list : &h->ps.sps->scaling_list; @@ -369,10 +371,10 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, av_assert0(ctx_pic); /* Fill up DXVA_PicParams_HEVC */ - fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp); + ff_dxva2_hevc_fill_picture_parameters(avctx, ctx, &ctx_pic->pp); /* Fill up DXVA_Qmatrix_HEVC */ - fill_scaling_lists(ctx, h, &ctx_pic->qm); + ff_dxva2_hevc_fill_scaling_lists(avctx, ctx, &ctx_pic->qm); ctx_pic->slice_count = 0; ctx_pic->bitstream_size = 0; diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 73bb954c6c..49c696068a 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -171,4 +171,8 @@ void ff_dxva2_h264_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACo void ff_dxva2_h264_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_H264 *qm); +void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_HEVC *pp); + +void ff_dxva2_hevc_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_HEVC *qm); + #endif /* AVCODEC_DXVA2_INTERNAL_H */ diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 3ce845dddb..b5311ae510 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -398,6 +398,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) { #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \ CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ + CONFIG_HEVC_D3D12VA_HWACCEL + \ CONFIG_HEVC_NVDEC_HWACCEL + \ CONFIG_HEVC_VAAPI_HWACCEL + \ CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \ @@ -415,6 +416,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) *fmt++ = AV_PIX_FMT_D3D11VA_VLD; *fmt++ = AV_PIX_FMT_D3D11; #endif +#if CONFIG_HEVC_D3D12VA_HWACCEL + *fmt++ = AV_PIX_FMT_D3D12; +#endif #if CONFIG_HEVC_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif @@ -439,6 +443,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) *fmt++ = AV_PIX_FMT_D3D11VA_VLD; *fmt++ = AV_PIX_FMT_D3D11; #endif +#if CONFIG_HEVC_D3D12VA_HWACCEL + *fmt++ = AV_PIX_FMT_D3D12; +#endif #if CONFIG_HEVC_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif @@ -3701,6 +3708,9 @@ const FFCodec ff_hevc_decoder = { #if CONFIG_HEVC_D3D11VA2_HWACCEL HWACCEL_D3D11VA2(hevc), #endif +#if CONFIG_HEVC_D3D12VA_HWACCEL + HWACCEL_D3D12VA(hevc), +#endif #if CONFIG_HEVC_NVDEC_HWACCEL HWACCEL_NVDEC(hevc), #endif diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 90b8beb0f5..6b71919b0a 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -39,6 +39,7 @@ extern const struct FFHWAccel ff_h264_videotoolbox_hwaccel; extern const struct FFHWAccel ff_h264_vulkan_hwaccel; extern const struct FFHWAccel ff_hevc_d3d11va_hwaccel; extern const struct FFHWAccel ff_hevc_d3d11va2_hwaccel; +extern const struct FFHWAccel ff_hevc_d3d12va_hwaccel; extern const struct FFHWAccel ff_hevc_dxva2_hwaccel; extern const struct FFHWAccel ff_hevc_nvdec_hwaccel; extern const struct FFHWAccel ff_hevc_vaapi_hwaccel;