From: "Wu, Tong1" <tong1.wu-at-intel.com@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH v9 1/9] libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12 Date: Fri, 10 Nov 2023 02:20:01 +0000 Message-ID: <SN6PR11MB2990E4FABC91621CC5EFD475C0AEA@SN6PR11MB2990.namprd11.prod.outlook.com> (raw) In-Reply-To: <4b6393f5-c9a2-47d1-811a-ece7694d1dcc@betaapp.fastmail.com> >-----Original Message----- >From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Jean- >Baptiste Kempf >Sent: Wednesday, November 8, 2023 7:04 PM >To: fmpeg-devel <ffmpeg-devel@ffmpeg.org> >Subject: Re: [FFmpeg-devel] [PATCH v9 1/9] libavutil: add hwcontext_d3d12va >and AV_PIX_FMT_D3D12 > >Hello, > >On Wed, 8 Nov 2023, at 02:05, Tong Wu wrote: >> +/** >> + * @brief This struct is used to sync d3d12 execution >> + * >> + */ >> +typedef struct AVD3D12VASyncContext { >> + /** >> + * D3D12 fence object >> + */ >> + ID3D12Fence *fence; >> + >> + /** >> + * A handle to the event object >> + */ >> + HANDLE event; > >Sorry, but which event object? I would guess it's the ID3D12Fence::Signal, but >I'm not even sure. > >I think this needs a bit more doc and explanations. > Hi there. Yes it's the event that's raised when the fence reaches a certain value. I will put more details in the doc. Thanks. >> + >> + /** >> + * The fence value used for sync >> + */ >> + uint64_t fence_value; >> +} AVD3D12VASyncContext; >> + >> +/** >> + * @brief D3D12VA frame descriptor for pool allocation. >> + * >> + */ >> +typedef struct AVD3D12VAFrame { >> + /** >> + * The texture in which the frame is located. The reference count >> is >> + * managed by the AVBufferRef, and destroying the reference will >> release >> + * the interface. >> + */ >> + ID3D12Resource *texture; >> + >> + /** >> + * The index into the array texture element representing the frame >> + */ >> + intptr_t index; >> + >> + /** >> + * The sync context for the texture >> + * >> + * Use av_d3d12va_wait_idle(sync_ctx) to ensure the decoding or >> encoding have been finised >> + * @see: >> https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12- >video-overview#directx-12-fences >> + */ >> + AVD3D12VASyncContext *sync_ctx; >> +} AVD3D12VAFrame; >> + >> +/** >> + * @brief This struct is allocated as AVHWFramesContext.hwctx >> + * >> + */ >> +typedef struct AVD3D12VAFramesContext { >> + /** >> + * This field is not able to be user-allocated at the present. >> + */ >> + AVD3D12VAFrame *texture_infos; >> +} AVD3D12VAFramesContext; >> + >> +/** >> + * @brief Map sw pixel format to d3d12 format >> + * >> + * @return d3d12 specified format >> + */ >> +DXGI_FORMAT av_d3d12va_map_sw_to_hw_format(enum AVPixelFormat >pix_fmt); >> + >> +/** >> + * @brief Allocate an AVD3D12VASyncContext >> + * >> + * @return Error code (ret < 0 if failed) >> + */ >> +int av_d3d12va_sync_context_alloc(AVD3D12VADeviceContext *ctx, >> AVD3D12VASyncContext **sync_ctx); >> + >> +/** >> + * @brief Free an AVD3D12VASyncContext >> + */ >> +void av_d3d12va_sync_context_free(AVD3D12VASyncContext **sync_ctx); >> + >> +#endif /* AVUTIL_HWCONTEXT_D3D12VA_H */ >> diff --git a/libavutil/hwcontext_d3d12va_internal.h >> b/libavutil/hwcontext_d3d12va_internal.h >> new file mode 100644 >> index 0000000000..bfd89b3545 >> --- /dev/null >> +++ b/libavutil/hwcontext_d3d12va_internal.h >> @@ -0,0 +1,59 @@ >> +/* >> + * Direct3D 12 HW acceleration. >> + * >> + * copyright (c) 2022-2023 Wu Jianhua <toqsxw@outlook.com> >> + * >> + * 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 >> + */ >> + >> +#ifndef AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H >> +#define AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H >> + >> +/** >> + * @def COBJMACROS >> + * >> + * @brief Enable C style interface for D3D12 >> + */ >> +#ifndef COBJMACROS >> +#define COBJMACROS >> +#endif >> + >> +/** >> + * @def DX_CHECK >> + * >> + * @brief A check macro used by D3D12 functions highly frequently >> + */ >> +#define DX_CHECK(hr) \ >> + do { \ >> + if (FAILED(hr)) \ >> + goto fail; \ >> + } while (0) >> + >> +/** >> + * @def D3D12_OBJECT_RELEASE >> + * >> + * @brief A release macro used by D3D12 objects highly frequently >> + */ >> +#define D3D12_OBJECT_RELEASE(pInterface) \ >> + do { \ >> + if (pInterface) { \ >> + IUnknown_Release((IUnknown *)pInterface); \ >> + pInterface = NULL; \ >> + } \ >> + } while (0) >> + >> +#endif /* AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H */ >> \ No newline at end of file >> diff --git a/libavutil/hwcontext_internal.h >> b/libavutil/hwcontext_internal.h >> index e6266494ac..4df516ee6a 100644 >> --- a/libavutil/hwcontext_internal.h >> +++ b/libavutil/hwcontext_internal.h >> @@ -165,6 +165,7 @@ int ff_hwframe_map_replace(AVFrame *dst, const >> AVFrame *src); >> >> extern const HWContextType ff_hwcontext_type_cuda; >> extern const HWContextType ff_hwcontext_type_d3d11va; >> +extern const HWContextType ff_hwcontext_type_d3d12va; >> extern const HWContextType ff_hwcontext_type_drm; >> extern const HWContextType ff_hwcontext_type_dxva2; >> extern const HWContextType ff_hwcontext_type_opencl; >> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c >> index 4e4a63e287..0db4167934 100644 >> --- a/libavutil/pixdesc.c >> +++ b/libavutil/pixdesc.c >> @@ -2311,6 +2311,10 @@ static const AVPixFmtDescriptor >> av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { >> .name = "d3d11", >> .flags = AV_PIX_FMT_FLAG_HWACCEL, >> }, >> + [AV_PIX_FMT_D3D12] = { >> + .name = "d3d12", >> + .flags = AV_PIX_FMT_FLAG_HWACCEL, >> + }, >> [AV_PIX_FMT_GBRPF32BE] = { >> .name = "gbrpf32be", >> .nb_components = 3, >> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h >> index a26c72d56b..58f9ad28bd 100644 >> --- a/libavutil/pixfmt.h >> +++ b/libavutil/pixfmt.h >> @@ -429,6 +429,13 @@ enum AVPixelFormat { >> AV_PIX_FMT_GBRAP14BE, ///< planar GBR 4:4:4:4 56bpp, big-endian >> AV_PIX_FMT_GBRAP14LE, ///< planar GBR 4:4:4:4 56bpp, little-endian >> >> + /** >> + * Hardware surfaces for Direct3D 12. >> + * >> + * data[0] points to an AVD3D12VAFrame >> + */ >> + AV_PIX_FMT_D3D12, >> + >> AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE >> THIS if you want to link with shared libav* because the number of >> formats might differ between versions >> }; >> >> diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c >> index c57586613a..9d7964f9ee 100644 >> --- a/libavutil/tests/hwdevice.c >> +++ b/libavutil/tests/hwdevice.c >> @@ -137,6 +137,8 @@ static const struct { >> { "0", "1", "2" } }, >> { AV_HWDEVICE_TYPE_D3D11VA, >> { "0", "1", "2" } }, >> + { AV_HWDEVICE_TYPE_D3D12VA, >> + { "0", "1", "2" } }, >> { AV_HWDEVICE_TYPE_OPENCL, >> { "0.0", "0.1", "1.0", "1.1" } }, >> { AV_HWDEVICE_TYPE_VAAPI, >> diff --git a/libavutil/version.h b/libavutil/version.h >> index 589a42b0fa..c5fa7c3692 100644 >> --- a/libavutil/version.h >> +++ b/libavutil/version.h >> @@ -79,7 +79,7 @@ >> */ >> >> #define LIBAVUTIL_VERSION_MAJOR 58 >> -#define LIBAVUTIL_VERSION_MINOR 31 >> +#define LIBAVUTIL_VERSION_MINOR 32 >> #define LIBAVUTIL_VERSION_MICRO 100 >> >> #define LIBAVUTIL_VERSION_INT >AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ >> -- >> 2.41.0.windows.1 >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > >-- >Jean-Baptiste Kempf - President >+33 672 704 734 >_______________________________________________ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >To unsubscribe, visit link above, or email >ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-11-10 2:20 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-08 1:05 Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 2/9] avcodec: add D3D12VA hardware accelerated H264 decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 3/9] avcodec: add D3D12VA hardware accelerated HEVC decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 4/9] avcodec: add D3D12VA hardware accelerated VP9 decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 5/9] avcodec: add D3D12VA hardware accelerated AV1 decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 6/9] avcodec: add D3D12VA hardware accelerated MPEG-2 decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 7/9] avcodec: add D3D12VA hardware accelerated VC1 decoding Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 8/9] Changelog: D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and " Tong Wu 2023-11-08 1:05 ` [FFmpeg-devel] [PATCH v9 9/9] avcodec/d3d12va_hevc: enable allow_profile_mismatch flag for d3d12va msp profile Tong Wu 2023-11-08 1:08 ` [FFmpeg-devel] [PATCH v9 1/9] libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12 Wu, Tong1 2023-11-08 11:03 ` Jean-Baptiste Kempf 2023-11-10 2:20 ` Wu, Tong1 [this message] 2023-11-08 18:10 ` Lynne 2023-11-10 5:45 ` Wu, Tong1
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=SN6PR11MB2990E4FABC91621CC5EFD475C0AEA@SN6PR11MB2990.namprd11.prod.outlook.com \ --to=tong1.wu-at-intel.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git