From patchwork Sun Dec 3 00:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 44884 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a301:b0:181:818d:5e7f with SMTP id x1csp1998148pzk; Sat, 2 Dec 2023 16:39:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/IIteTMN2Hbit6ZemH/qejxlWpoN5XYczejojQG66csRaVK2LhCc8hNVLNffyGH7QCITi X-Received: by 2002:a2e:3a06:0:b0:2c9:f96f:eb86 with SMTP id h6-20020a2e3a06000000b002c9f96feb86mr149903lja.47.1701563982293; Sat, 02 Dec 2023 16:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701563982; cv=none; d=google.com; s=arc-20160816; b=ayDReVdRMVeEOKmGisOcxXz5f1ih34gB4KSuz7ZbcFErPFiwdQBQCkW8wf/A6M2Nqj EdgIhq4PILYxOhcn9S/NoE29ph5x4TTAGp8mzpTqdZdP8i/ntEjfnU2BdyzN0NW8akE+ dvnJQMCLLdVwcmGW4NJDxVoLzWmUdN+Ozl1Ibn5wQLVxPm5sllnGiGTzDBT4XqLyF1q3 RrjKJpo1bRDqvwe0FsKw9mAOqlBfjnNRlYA2Rab+E3s+X5Rkg7q3llOOUbmvLmNsjGzm MxE+mpj2LEN27JmahXENjJNaCSX7X2xuvxxgLp66MrifR1DYGXl4/04SF0+mRYtxZp7r /hgg== 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=r4jjQLb4G+Duo0B/6Xo+cfpoA/KHX0PGMYUNK7QLM+k=; fh=9GN8hc/WTnabikg2VxPLeDN+i3R37IqYi/LhxNANmV0=; b=Z3PrW6mC2b0ymrpwRf6Y10jte4WnQ3pZr3Av2AyR7pcWCKQVbY6mxwVejxAItEb08u NnH/QfPLWmqCBlFxfL3E5VAae/4F83cVo8aJqFEJKor89EyY1MhZQEMPJy24WbGOqelE bahPX1buK4aAC819SuzLwd6mllKS9FG8nIRyNnuV+0Tsgs463N2oQy//X0Hz0VZT1oQz FH11vgir2iJJwIB+56zTqYKNuItmtXCtcJ164HCmOhXyyxwUipKfEZfiwiPJvDkbGm9L quYJAnlEYW0SWABDip3eB7/iON1n7BBwRIEgd+CJi8Rl5DFLwqUZVjazil03P09Jqa93 juVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=UjusjK7E; 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 y5-20020a17090629c500b009ff19b72cb5si3143255eje.315.2023.12.02.16.39.41; Sat, 02 Dec 2023 16:39:42 -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=UjusjK7E; 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 C3FB568CED9; Sun, 3 Dec 2023 02:38:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A06B368CD40 for ; Sun, 3 Dec 2023 02:38:49 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701563935; x=1733099935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gCue/M4GjHFOY73qdem+YCqKC6i+rbd1Ie9YCzjgM+4=; b=UjusjK7Ec2sDw1JWaej6eGgEyhFuOhjyIqbx165ndkCv8prNlz0bE6yG 3R90u9Vsrk6Zav8CjW1UZ3yCXlHWV1MNesISmVT1junbOv9tFHXu7ftHi Esa4iEN8TB1vGQc8gDwzDlvB6X5QT5C0Kb0WDBKo7Mk8+RVXS2imRwhDp bTHYtTqbn5VXqewDBKv/pe0Wfm0ueErwNLijOu1krmP0704WYPpttalGH WHR33QBqjM9ZjRnGeLC3tnbKeAi57chaTPSuA/CXqishmgCbfZibuw9lh pw4+ERmcsjVfQCQaoCi11pUy9z2X4Oq2t0tEhUCIb83jrZ44mqWkzp36Q w==; X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="476956" X-IronPort-AV: E=Sophos;i="6.04,246,1695711600"; d="scan'208";a="476956" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 16:38:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="893602121" X-IronPort-AV: E=Sophos;i="6.04,246,1695711600"; d="scan'208";a="893602121" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.66]) by orsmga004.jf.intel.com with ESMTP; 02 Dec 2023 16:38:44 -0800 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Dec 2023 08:37:28 +0800 Message-ID: <20231203003732.1851-6-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20231203003732.1851-1-tong1.wu@intel.com> References: <20231203003732.1851-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v11 6/9] avcodec: add D3D12VA hardware accelerated MPEG-2 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: 2b+Dej+xDK9a 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_mpeg2.c | 191 ++++++++++++++++++++++++++++++++++++ libavcodec/dxva2_internal.h | 6 ++ libavcodec/dxva2_mpeg2.c | 20 ++-- libavcodec/hwaccels.h | 1 + libavcodec/mpeg12dec.c | 6 ++ 7 files changed, 217 insertions(+), 10 deletions(-) create mode 100644 libavcodec/d3d12va_mpeg2.c diff --git a/configure b/configure index 7feeeddaf5..000ea76c34 100755 --- a/configure +++ b/configure @@ -3130,6 +3130,8 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_d3d11va2_hwaccel_deps="d3d11va" mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder" +mpeg2_d3d12va_hwaccel_deps="d3d12va" +mpeg2_d3d12va_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" mpeg2_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0f152df17c..00c1c01cbd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1027,6 +1027,7 @@ OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o +OBJS-$(CONFIG_MPEG2_D3D12VA_HWACCEL) += dxva2_mpeg2.o d3d12va_mpeg2.o OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL) += nvdec_mpeg12.o OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o diff --git a/libavcodec/d3d12va_mpeg2.c b/libavcodec/d3d12va_mpeg2.c new file mode 100644 index 0000000000..91bf3f8b75 --- /dev/null +++ b/libavcodec/d3d12va_mpeg2.c @@ -0,0 +1,191 @@ +/* + * Direct3D12 MPEG-2 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 "mpegutils.h" +#include "mpegvideodec.h" +#include "d3d12va_decode.h" +#include "dxva2_internal.h" + +#define MAX_SLICES 1024 +#define INVALID_REF 0xffff + +#define REF_RESOURCE(index) if (index != INVALID_REF) { \ + ctx->ref_resources[index] = frames_hwctx->texture_infos[index].texture; \ +} + +typedef struct D3D12DecodePictureContext { + DXVA_PictureParameters pp; + DXVA_QmatrixData qm; + unsigned slice_count; + DXVA_SliceInfo slices[MAX_SLICES]; + const uint8_t *bitstream; + unsigned bitstream_size; +} D3D12DecodePictureContext; + +static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ + const MpegEncContext *s = avctx->priv_data; + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + DXVA_QmatrixData *qm = &ctx_pic->qm; + + if (!ctx) + return -1; + + av_assert0(ctx_pic); + + ctx->used_mask = 0; + + ff_dxva2_mpeg2_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp); + ff_dxva2_mpeg2_fill_quantization_matrices(avctx, (AVDXVAContext *)ctx, &ctx_pic->qm); + + // Post processing operations are not supported in D3D12 Video + ctx_pic->pp.wDeblockedPictureIndex = INVALID_REF; + + ctx_pic->bitstream = NULL; + ctx_pic->bitstream_size = 0; + ctx_pic->slice_count = 0; + + return 0; +} + +static int d3d12va_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ + const MpegEncContext *s = avctx->priv_data; + D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + + int is_field = s->picture_structure != PICT_FRAME; + + if (ctx_pic->slice_count >= MAX_SLICES) { + return AVERROR(ERANGE); + } + + if (!ctx_pic->bitstream) + ctx_pic->bitstream = buffer; + ctx_pic->bitstream_size += size; + + ff_dxva2_mpeg2_fill_slice(avctx, &ctx_pic->slices[ctx_pic->slice_count++], + buffer - ctx_pic->bitstream, buffer, size); + + return 0; +} + +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 MpegEncContext *s = avctx->priv_data; + D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + + const int is_field = s->picture_structure != PICT_FRAME; + const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); + + int i; + uint8_t *mapped_data = NULL; + D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args = &input_args->FrameArguments[input_args->NumFrameArguments++]; + + D3D12_RANGE range = { + .Begin = 0, + .End = ctx_pic->bitstream_size, + }; + + if (FAILED(ID3D12Resource_Map(buffer, 0, &range, &mapped_data))) { + av_log(avctx, AV_LOG_ERROR, "Failed to map D3D12 Buffer resource!\n"); + return AVERROR(EINVAL); + } + + for (i = 0; i < ctx_pic->slice_count; i++) { + DXVA_SliceInfo *slice = &ctx_pic->slices[i]; + + if (i < ctx_pic->slice_count - 1) + slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice; + else + slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice; + } + + memcpy(mapped_data, ctx_pic->bitstream, ctx_pic->bitstream_size); + + ID3D12Resource_Unmap(buffer, 0, &range); + + args->Type = D3D12_VIDEO_DECODE_ARGUMENT_TYPE_SLICE_CONTROL; + args->Size = sizeof(DXVA_SliceInfo) * ctx_pic->slice_count; + args->pData = ctx_pic->slices; + + input_args->CompressedBitstream = (D3D12_VIDEO_DECODE_COMPRESSED_BITSTREAM){ + .pBuffer = buffer, + .Offset = 0, + .Size = ctx_pic->bitstream_size, + }; + + return 0; +} + +static int d3d12va_mpeg2_end_frame(AVCodecContext *avctx) +{ + int ret; + MpegEncContext *s = avctx->priv_data; + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + + if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) + return -1; + + ret = ff_d3d12va_common_end_frame(avctx, s->current_picture_ptr->f, &ctx_pic->pp, sizeof(ctx_pic->pp), + &ctx_pic->qm, sizeof(ctx_pic->qm), update_input_arguments); + if (!ret) + ff_mpeg_draw_horiz_band(s, 0, avctx->height); + + return ret; +} + +static int d3d12va_mpeg2_decode_init(AVCodecContext *avctx) +{ + const MpegEncContext *s = avctx->priv_data; + D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); + + ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_MPEG2; + + ctx->max_num_ref = 3; + + return ff_d3d12va_decode_init(avctx); +} + +#if CONFIG_MPEG2_D3D12VA_HWACCEL +const FFHWAccel ff_mpeg2_d3d12va_hwaccel = { + .p.name = "mpeg2_d3d12va", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MPEG2VIDEO, + .p.pix_fmt = AV_PIX_FMT_D3D12, + .init = d3d12va_mpeg2_decode_init, + .uninit = ff_d3d12va_decode_uninit, + .start_frame = d3d12va_mpeg2_start_frame, + .decode_slice = d3d12va_mpeg2_decode_slice, + .end_frame = d3d12va_mpeg2_end_frame, + .frame_params = ff_d3d12va_common_frame_params, + .frame_priv_data_size = sizeof(D3D12DecodePictureContext), + .priv_data_size = sizeof(D3D12VADecodeContext), +}; +#endif diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 7a30672ecd..46a359aec6 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -181,4 +181,10 @@ int ff_dxva2_vp9_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACont int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_AV1 *pp); #endif +void ff_dxva2_mpeg2_fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PictureParameters *pp); + +void ff_dxva2_mpeg2_fill_quantization_matrices(AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_QmatrixData *qm); + +void ff_dxva2_mpeg2_fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, const uint8_t *buffer, unsigned size); + #endif /* AVCODEC_DXVA2_INTERNAL_H */ diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index b739dc1e54..4c9ed1d761 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -40,16 +40,15 @@ struct dxva2_picture_context { unsigned bitstream_size; }; -static void fill_picture_parameters(AVCodecContext *avctx, +void ff_dxva2_mpeg2_fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, - const struct MpegEncContext *s, DXVA_PictureParameters *pp) { + const struct MpegEncContext *s = avctx->priv_data; const Picture *current_picture = s->current_picture_ptr; int is_field = s->picture_structure != PICT_FRAME; memset(pp, 0, sizeof(*pp)); - pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, current_picture->f, 1); pp->wDeblockedPictureIndex = 0; if (s->pict_type != AV_PICTURE_TYPE_I) pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->last_picture.f, 0); @@ -59,6 +58,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, s->next_picture.f, 0); else pp->wBackwardRefPictureIndex = 0xffff; + pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(avctx, ctx, current_picture->f, 1); pp->wPicWidthInMBminus1 = s->mb_width - 1; pp->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1; pp->bMacroblockWidthMinus1 = 15; @@ -106,11 +106,11 @@ static void fill_picture_parameters(AVCodecContext *avctx, pp->bBitstreamConcealmentMethod = 0; } -static void fill_quantization_matrices(AVCodecContext *avctx, +void ff_dxva2_mpeg2_fill_quantization_matrices(AVCodecContext *avctx, AVDXVAContext *ctx, - const struct MpegEncContext *s, DXVA_QmatrixData *qm) { + const struct MpegEncContext *s = avctx->priv_data; int i; for (i = 0; i < 4; i++) qm->bNewQmatrix[i] = 1; @@ -123,12 +123,12 @@ static void fill_quantization_matrices(AVCodecContext *avctx, } } -static void fill_slice(AVCodecContext *avctx, - const struct MpegEncContext *s, +void ff_dxva2_mpeg2_fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, const uint8_t *buffer, unsigned size) { + const struct MpegEncContext *s = avctx->priv_data; int is_field = s->picture_structure != PICT_FRAME; GetBitContext gb; @@ -266,8 +266,8 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, return -1; assert(ctx_pic); - fill_picture_parameters(avctx, ctx, s, &ctx_pic->pp); - fill_quantization_matrices(avctx, ctx, s, &ctx_pic->qm); + ff_dxva2_mpeg2_fill_picture_parameters(avctx, ctx, &ctx_pic->pp); + ff_dxva2_mpeg2_fill_quantization_matrices(avctx, ctx, &ctx_pic->qm); ctx_pic->slice_count = 0; ctx_pic->bitstream_size = 0; @@ -293,7 +293,7 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, ctx_pic->bitstream_size += size; position = buffer - ctx_pic->bitstream; - fill_slice(avctx, s, &ctx_pic->slice[ctx_pic->slice_count++], position, + ff_dxva2_mpeg2_fill_slice(avctx, &ctx_pic->slice[ctx_pic->slice_count++], position, buffer, size); return 0; } diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 1c4825f2fb..927314c5e3 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -54,6 +54,7 @@ extern const struct FFHWAccel ff_mpeg1_vdpau_hwaccel; extern const struct FFHWAccel ff_mpeg1_videotoolbox_hwaccel; extern const struct FFHWAccel ff_mpeg2_d3d11va_hwaccel; extern const struct FFHWAccel ff_mpeg2_d3d11va2_hwaccel; +extern const struct FFHWAccel ff_mpeg2_d3d12va_hwaccel; extern const struct FFHWAccel ff_mpeg2_dxva2_hwaccel; extern const struct FFHWAccel ff_mpeg2_nvdec_hwaccel; extern const struct FFHWAccel ff_mpeg2_vaapi_hwaccel; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 020b7b7564..d07eed8744 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -850,6 +850,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { AV_PIX_FMT_D3D11VA_VLD, AV_PIX_FMT_D3D11, #endif +#if CONFIG_MPEG2_D3D12VA_HWACCEL + AV_PIX_FMT_D3D12, +#endif #if CONFIG_MPEG2_VAAPI_HWACCEL AV_PIX_FMT_VAAPI, #endif @@ -2620,6 +2623,9 @@ const FFCodec ff_mpeg2video_decoder = { #if CONFIG_MPEG2_D3D11VA2_HWACCEL HWACCEL_D3D11VA2(mpeg2), #endif +#if CONFIG_MPEG2_D3D12VA_HWACCEL + HWACCEL_D3D12VA(mpeg2), +#endif #if CONFIG_MPEG2_NVDEC_HWACCEL HWACCEL_NVDEC(mpeg2), #endif