mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 05:10:11 +01:00
mediafoundation: Allow to build multiple codec MFT DLLs in one build pass
Reviewed-by: Sil Vilerino <sivileri@microsoft.com> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13235 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35264>
This commit is contained in:
parent
d9f0ddf336
commit
4df6954219
24 changed files with 206 additions and 183 deletions
|
|
@ -176,13 +176,6 @@ option(
|
|||
'defaults to libgallium_d3d10.dll to match DRI',
|
||||
)
|
||||
|
||||
option(
|
||||
'mediafoundation-windows-dll-name',
|
||||
type : 'string',
|
||||
value : 'mediafoundation_hmft',
|
||||
description : 'name of gallium mediafoundation DLL built for Windows. ',
|
||||
)
|
||||
|
||||
option(
|
||||
'mediafoundation-store-dll',
|
||||
type : 'boolean',
|
||||
|
|
@ -190,6 +183,18 @@ option(
|
|||
description : 'Selects whether the gallium mediafoundation DLL is built for the store. ',
|
||||
)
|
||||
|
||||
option(
|
||||
'mediafoundation-codecs',
|
||||
type : 'array',
|
||||
value : ['all'],
|
||||
choices: [
|
||||
'all', 'h264enc', 'h265enc', 'av1enc'
|
||||
],
|
||||
description : 'List of codecs to build mediafoundation frontend DLLs for. ' +
|
||||
'These will generate different MFT DLLs per codec and link' +
|
||||
'against the gallium drivers which uses the video-codecs option'
|
||||
)
|
||||
|
||||
option(
|
||||
'static-libclc',
|
||||
type : 'array',
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ CDX12EncHMFT::GetParameterRange( const GUID *Api, VARIANT *ValueMin, VARIANT *Va
|
|||
ValueMin->ulVal = HMFT_MIN_BITS_PER_SLICE;
|
||||
ValueMax->ulVal = 0xffffffff;
|
||||
break;
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
case SLICE_CONTROL_MODE_MB_ROW:
|
||||
if( m_spOutputType )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,12 +37,26 @@ Other files related to the MFT:
|
|||
| src/gallium/targets/mediafoundation | dllmain and resourc files for MFT, builds the dll |
|
||||
|
||||
## Build
|
||||
Current implementation is designed to build three differt codec (AV1, H264, HEVC) with the same code (note AV1 is stub right now). To build each codec, we run setup with different codec name.
|
||||
Current implementation is designed to build three differt codec (AV1, H264, HEVC) with the same code (note AV1 is stub right now).
|
||||
You can set up the build to build a single codec without comingling of other codec's code or you can build several (include all) codecs together that has comingle code.
|
||||
The comingle code currently comes from .\gallium\drivers\d3d12 folder.
|
||||
|
||||
To build the COM based H264 codec, you can use the following command to setup the build (please run the setup under the mesa folder, and by default the output will go to c:\bin)
|
||||
To select one codec, you can do:
|
||||
|
||||
```
|
||||
meson setup build/ --pkg-config-path="C:\lib\pkgconfig" -Dgallium-d3d12-graphics=disabled -Dintel-elk=false -Dmicrosoft-clc=disabled -Dllvm=disabled -Dvalgrind=disabled -Dlmsensors=disabled -Dzlib=disabled -Dzstd=disabled -Dxmlconfig=disabled -Dgles1=disabled -Dgles2=disabled -Degl=disabled -Dgbm=disabled -Dglx-direct=false -Denable-glcpp-tests=false -Dopengl=false -Dgallium-drivers=d3d12 -Dgallium-vdpau=disabled -Dgallium-va=disabled -Dgallium-mediafoundation=enabled -Dc_args="/guard:cf /we4146 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4700 /we4789 /wd4703" -Dc_link_args="/guard:cf /profile /DYNAMICBASE" -Dcpp_args="/guard:cf /we4146 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4700 /we4789 /wd4703" -Dcpp_link_args="/guard:cf /profile /DYNAMICBASE" --default-library=static -Db_vscrt=mt -Dc_std=c17 -Dcpp_std=c++17 -Dmicrosoft-clc=disabled -Ddebug=false --buildtype=release -Dwarning_level=2 -Dvideo-codecs=h264enc -Dmediafoundation-windows-dll-name="msh264enchmft" -Dmediafoundation-store-dll=false -Dgallium-mediafoundation-test=true
|
||||
-Dvideo-codecs=h264enc -Dmediafoundation-codecs=h264enc
|
||||
```
|
||||
|
||||
To select all codecs, you can do
|
||||
|
||||
```
|
||||
-Dvideo-codecs=all -Dmediafoundation-codecs=all
|
||||
```
|
||||
|
||||
Below is an example setup command that builds one codec
|
||||
|
||||
```
|
||||
meson setup build/ --pkg-config-path="C:\lib\pkgconfig" -Dgallium-d3d12-graphics=disabled -Dintel-elk=false -Dmicrosoft-clc=disabled -Dllvm=disabled -Dvalgrind=disabled -Dlmsensors=disabled -Dzlib=disabled -Dzstd=disabled -Dxmlconfig=disabled -Dgles1=disabled -Dgles2=disabled -Degl=disabled -Dgbm=disabled -Dglx-direct=false -Denable-glcpp-tests=false -Dopengl=false -Dgallium-drivers=d3d12 -Dgallium-vdpau=disabled -Dgallium-va=disabled -Dgallium-mediafoundation=enabled -Dc_args="/guard:cf /we4146 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4700 /we4789 /wd4703" -Dc_link_args="/guard:cf /profile /DYNAMICBASE" -Dcpp_args="/guard:cf /we4146 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4700 /we4789 /wd4703" -Dcpp_link_args="/guard:cf /profile /DYNAMICBASE" --default-library=static -Db_vscrt=mt -Dc_std=c17 -Dcpp_std=c++17 -Dmicrosoft-clc=disabled -Ddebug=false --buildtype=release -Dwarning_level=2 -Dvideo-codecs=h264enc -Dmediafoundation-codecs=h264enc -Dmediafoundation-store-dll=false -Dgallium-mediafoundation-test=true
|
||||
```
|
||||
|
||||
To build the COM based HEVC codec, use the above command but replace all instances of h264enc with h265enc to setup the build. Similarly for the pending AV1 codec, replace h264enc with av1enc.
|
||||
|
|
|
|||
|
|
@ -434,11 +434,11 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E
|
|||
// Otherwise fallback to full frame encoding fence notification using a single output buffer
|
||||
uint32_t num_output_buffers = 1u;
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
num_output_buffers = std::max( 1u, pDX12EncodeContext->encoderPicInfo.h264enc.num_slice_descriptors );
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
num_output_buffers = std::max( 1u, pDX12EncodeContext->encoderPicInfo.h265enc.num_slice_descriptors );
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
num_output_buffers =
|
||||
std::max( 1u, pDX12EncodeContext->encoderPicInfo.av1enc.tile_rows * pDX12EncodeContext->encoderPicInfo.av1enc.tile_cols );
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#if VIDEO_CODEC_AV1ENC
|
||||
#if MFT_CODEC_AV1ENC
|
||||
#include "hmft_entrypoints.h"
|
||||
#include "mfbufferhelp.h"
|
||||
#include "mfpipeinterop.h"
|
||||
|
|
@ -40,7 +40,7 @@ HRESULT
|
|||
CDX12EncHMFT::GetCodecPrivateData( LPBYTE pSPSPPSData, DWORD dwSPSPPSDataLen, LPDWORD lpdwSPSPPSDataLen )
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
done:
|
||||
// done:
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
#include "hmft_entrypoints.h"
|
||||
#include "mfbufferhelp.h"
|
||||
#include "mfpipeinterop.h"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#if VIDEO_CODEC_H265ENC
|
||||
#if MFT_CODEC_H265ENC
|
||||
#include "hmft_entrypoints.h"
|
||||
#include "mfbufferhelp.h"
|
||||
#include "mfpipeinterop.h"
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ done:
|
|||
return hr;
|
||||
}
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
MFT_REGISTER_TYPE_INFO rgOutputInfo = { MFMediaType_Video, MFVideoFormat_H264 };
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
MFT_REGISTER_TYPE_INFO rgOutputInfo = { MFMediaType_Video, MFVideoFormat_HEVC };
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
MFT_REGISTER_TYPE_INFO rgOutputInfo = { MFMediaType_Video, MFVideoFormat_AV1 };
|
||||
#endif
|
||||
MFT_REGISTER_TYPE_INFO rgInputInfo[NUM_INPUT_TYPES] = { { MFMediaType_Video, MFVideoFormat_NV12 },
|
||||
|
|
@ -72,8 +72,8 @@ CDX12EncHMFT::RuntimeClassInitialize()
|
|||
HRESULT hr = S_OK;
|
||||
ComPtr<IMFMediaType> spVideoType = NULL;
|
||||
|
||||
static_assert( VIDEO_CODEC_H264ENC ^ VIDEO_CODEC_H265ENC ^ VIDEO_CODEC_AV1ENC,
|
||||
"VIDEO_CODEC_H264ENC or VIDEO_CODEC_H265ENC or VIDEO_CODEC_AV1ENC must be defined but only one at a time" );
|
||||
static_assert( MFT_CODEC_H264ENC ^ MFT_CODEC_H265ENC ^ MFT_CODEC_AV1ENC,
|
||||
"MFT_CODEC_H264ENC or MFT_CODEC_H265ENC or MFT_CODEC_AV1ENC must be defined but only one at a time" );
|
||||
|
||||
// Start by configuring for 4:2:0 NV12 as the only possible input type.
|
||||
// Once the SetOutputType() happens with a profile, we'll reconfigure the available input type
|
||||
|
|
|
|||
|
|
@ -293,11 +293,11 @@ DEFINE_CODECAPI_GUID( AVEncVideoOutputBitsUsedMapBlockSize,"6C2CD11A-CA3B-44BD-9
|
|||
#define CODECAPI_AVEncVideoOutputBitsUsedMapBlockSize DEFINE_CODECAPI_GUIDNAMED( AVEncVideoOutputBitsUsedMapBlockSize )
|
||||
#endif
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
#define HMFT_GUID "8994db7c-288a-4c62-a136-a3c3c2a208a8"
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
#define HMFT_GUID "e7ffb8eb-fa0b-4fb0-acdf-1202f663cde5"
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
#define HMFT_GUID "1a6f3150-b121-4ce9-9497-50fedb3dcb70"
|
||||
#endif
|
||||
|
||||
|
|
@ -348,13 +348,13 @@ class __declspec( uuid( HMFT_GUID ) ) CDX12EncHMFT : CMFD3DManager,
|
|||
HRESULT InternalCheckOutputType( IMFMediaType *pType );
|
||||
HRESULT CheckMediaType( IMFMediaType *pmt, bool bInputType );
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
HRESULT CheckMediaTypeLevel(
|
||||
IMFMediaType *pmt, int width, int height, const encoder_capabilities &encoderCapabilities, eAVEncH264VLevel *pLevel ) const;
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
HRESULT CheckMediaTypeLevel(
|
||||
IMFMediaType *pmt, int width, int height, const encoder_capabilities &encoderCapabilities, eAVEncH265VLevel *pLevel ) const;
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
HRESULT CheckMediaTypeLevel(
|
||||
IMFMediaType *pmt, int width, int height, const encoder_capabilities &encoderCapabilities, eAVEncAV1VLevel *pLevel ) const;
|
||||
#endif
|
||||
|
|
@ -431,25 +431,25 @@ class __declspec( uuid( HMFT_GUID ) ) CDX12EncHMFT : CMFD3DManager,
|
|||
UINT32 m_uiSliceControlSize = 0;
|
||||
BOOL m_bSliceControlSizeSet = FALSE;
|
||||
BOOL m_bMaxNumRefFrameSet = FALSE;
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
UINT32 m_uiMaxNumRefFrame = PIPE_H264_MAX_REFERENCES;
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
UINT32 m_uiMaxNumRefFrame = PIPE_H265_MAX_REFERENCES;
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
UINT32 m_uiMaxNumRefFrame = PIPE_AV1_MAX_REFERENCES;
|
||||
#endif
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
eAVEncH264VProfile m_uiProfile = eAVEncH264VProfile_Main;
|
||||
eAVEncH264VLevel m_uiLevel = eAVEncH264VLevel5;
|
||||
const D3D12_VIDEO_ENCODER_CODEC m_Codec = D3D12_VIDEO_ENCODER_CODEC_H264;
|
||||
enum pipe_video_profile m_outputPipeProfile = PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
eAVEncH265VProfile m_uiProfile = eAVEncH265VProfile_Main_420_8;
|
||||
eAVEncH265VLevel m_uiLevel = eAVEncH265VLevel5;
|
||||
const D3D12_VIDEO_ENCODER_CODEC m_Codec = D3D12_VIDEO_ENCODER_CODEC_HEVC;
|
||||
enum pipe_video_profile m_outputPipeProfile = PIPE_VIDEO_PROFILE_HEVC_MAIN;
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
eAVEncAV1VProfile m_uiProfile = eAVEncAV1VProfile_Main_420_8;
|
||||
eAVEncAV1VLevel m_uiLevel = eAVEncAV1VLevel5;
|
||||
const D3D12_VIDEO_ENCODER_CODEC m_Codec = D3D12_VIDEO_ENCODER_CODEC_AV1;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,27 @@ mediafoundation_wpp_rsp = configure_file(
|
|||
configuration : {'WPP_ARGS' : mediafoundation_wpp_args}
|
||||
)
|
||||
|
||||
mft_codecs = get_option('mediafoundation-codecs')
|
||||
all_mft_codecs = ['h264enc', 'h265enc', 'av1enc']
|
||||
if mft_codecs.contains('all')
|
||||
mft_codecs = all_mft_codecs
|
||||
endif
|
||||
|
||||
foreach c : mft_codecs
|
||||
if not _codecs.contains(c)
|
||||
error('@0@ present in mediafoundation-codecs must also be present in video-codecs.'.format(c))
|
||||
endif
|
||||
endforeach
|
||||
|
||||
mf_codecs_cpp_args = {}
|
||||
foreach mf_codec_target : all_mft_codecs
|
||||
cpp_args = mf_cpp_args
|
||||
foreach c : all_mft_codecs
|
||||
cpp_args += '-DMFT_CODEC_@0@=@1@'.format(c.to_upper(), (c == mf_codec_target).to_int())
|
||||
endforeach
|
||||
mf_codecs_cpp_args += {mf_codec_target : cpp_args}
|
||||
endforeach
|
||||
|
||||
mediafoundation_wpp_preprocess = custom_target(
|
||||
'mediafoundation_wpp_preprocess',
|
||||
capture : true,
|
||||
|
|
@ -90,18 +111,20 @@ mediafoundation_wpp_preprocess = custom_target(
|
|||
command : ['tracewpp', '-cfgdir:@CURRENT_SOURCE_DIR@/wppconfig/rev1', '-scan:@CURRENT_SOURCE_DIR@/wpptrace.h', '-odir:@OUTDIR@', '@' + fs.relative_to(mediafoundation_wpp_rsp, 'a:\\')]
|
||||
)
|
||||
|
||||
gallium_mf_name = get_option('mediafoundation-windows-dll-name')
|
||||
|
||||
mediafoundation_st = static_library(
|
||||
'mediafoundation_st',
|
||||
mediafoundation_st = {}
|
||||
foreach codec : mft_codecs
|
||||
lib = static_library(
|
||||
'mediafoundation_st_' + codec,
|
||||
mediafoundation_files,
|
||||
mediafoundation_wpp_preprocess,
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
cpp_args : mf_cpp_args,
|
||||
cpp_args : mf_codecs_cpp_args[codec],
|
||||
override_options: ['cpp_std=c++20'],
|
||||
include_directories : [inc_include, inc_src, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||
dependencies : [idep_mesautil, dep_dxheaders],
|
||||
)
|
||||
)
|
||||
mediafoundation_st += {codec : lib}
|
||||
endforeach
|
||||
|
||||
if with_gallium_mediafoundation_test
|
||||
subdir('test')
|
||||
|
|
|
|||
|
|
@ -1165,7 +1165,7 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
&encoded_bitstream_bytes,
|
||||
&metadata );
|
||||
|
||||
#if (VIDEO_CODEC_H264ENC || VIDEO_CODEC_H265ENC)
|
||||
#if (MFT_CODEC_H264ENC || MFT_CODEC_H265ENC)
|
||||
if (pThis->m_pPipeVideoCodec->two_pass.enable &&
|
||||
(pThis->m_pPipeVideoCodec->two_pass.pow2_downscale_factor > 0) &&
|
||||
(pThis->m_pPipeVideoCodec->two_pass.skip_1st_dpb_texture))
|
||||
|
|
@ -1183,9 +1183,9 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
vpblit_params.src_surface_fence = NULL; // No need, we _just_ waited for completion above before get_feedback
|
||||
vpblit_params.base.fence = &dst_surface_fence; // Output surface fence (driver output)
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
auto &cur_pic_dpb_entry = pDX12EncodeContext->encoderPicInfo.h264enc.dpb[pDX12EncodeContext->encoderPicInfo.h265enc.dpb_curr_pic];
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
auto &cur_pic_dpb_entry = pDX12EncodeContext->encoderPicInfo.h265enc.dpb[pDX12EncodeContext->encoderPicInfo.h265enc.dpb_curr_pic];
|
||||
#endif
|
||||
|
||||
|
|
@ -1239,7 +1239,7 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
OS_TIMEOUT_INFINITE );
|
||||
assert(finished);
|
||||
}
|
||||
#endif // (VIDEO_CODEC_H264ENC || VIDEO_CODEC_H265ENC)
|
||||
#endif // (MFT_CODEC_H264ENC || MFT_CODEC_H265ENC)
|
||||
|
||||
// Only release the reconpic AFTER working on it for two pass if needed
|
||||
pThis->m_pGOPTracker->release_reconpic( pDX12EncodeContext->pAsyncDPBToken );
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@
|
|||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if VIDEO_CODEC_AV1ENC
|
||||
#if MFT_CODEC_AV1ENC
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#if VIDEO_CODEC_AV1ENC
|
||||
#if MFT_CODEC_AV1ENC
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
|
||||
#include "reference_frames_tracker_h264.h"
|
||||
#include <algorithm>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#if VIDEO_CODEC_H265ENC
|
||||
#if MFT_CODEC_H265ENC
|
||||
#include "reference_frames_tracker_hevc.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#if VIDEO_CODEC_H265ENC
|
||||
#if MFT_CODEC_H265ENC
|
||||
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
|
|
|
|||
|
|
@ -58,16 +58,16 @@ TEST( MediaFoundationEntrypoint, VerifySimpleEncodeSoftwareSample )
|
|||
ComPtr<IMFMediaBuffer> spOutBuffer;
|
||||
ComPtr<IMFMediaType> spInType = CreateVideoMT( width, height, FOURCC_NV12, FALSE, frameRateNum, frameRateDiv );
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
ComPtr<IMFMediaType> spOutType = CreateVideoMT( width, height, FOURCC_H264, FALSE, frameRateNum, frameRateDiv, bitRate * 1024 );
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
ComPtr<IMFMediaType> spOutType = CreateVideoMT( width, height, FOURCC_HEVC, FALSE, frameRateNum, frameRateDiv, bitRate * 1024 );
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
// NO AV1 doesn't work yet...
|
||||
assert( false );
|
||||
ComPtr<IMFMediaType> spOutType = CreateVideoMT( width, height, FOURCC_AV01, FALSE, frameRateNum, frameRateDiv, bitRate * 1024 );
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
GUID m_guidOutputVideoSubtype( MFVideoFormat_IYUV );
|
||||
|
|
@ -176,11 +176,11 @@ TEST( MediaFoundationEntrypoint, VerifySimpleEncodeSoftwareSample )
|
|||
// #define DUMP
|
||||
#if defined( DUMP )
|
||||
{
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
FILE *fp = fopen( "d:\\test\\output.h264", "ab" );
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
FILE *fp = fopen( "d:\\test\\output.h265", "ab" );
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
FILE *fp = fopen( "d:\\test\\output.av1", "ab" );
|
||||
#endif
|
||||
fwrite( pBuf, 1, dwLen, fp );
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
mediafoundation_test_st = static_library(
|
||||
'mediafoundation_test_st',
|
||||
mediafoundation_test_st = {}
|
||||
|
||||
foreach codec : mft_codecs
|
||||
test_lib = static_library(
|
||||
'mediafoundation_test_st_' + codec,
|
||||
files(
|
||||
'hmft_test_helpers.cpp',
|
||||
'hmft_codecapi_test.cpp',
|
||||
'hmft_simple_encode_test.cpp',
|
||||
'stub.cpp',
|
||||
),
|
||||
cpp_args : mf_cpp_args,
|
||||
cpp_args : mf_codecs_cpp_args[codec],
|
||||
override_options: ['cpp_std=c++20'],
|
||||
include_directories: [inc_include, inc_src, inc_gallium, inc_gallium_aux],
|
||||
dependencies: [idep_gtest, dep_dxheaders],
|
||||
)
|
||||
)
|
||||
mediafoundation_test_st += {codec : test_lib}
|
||||
endforeach
|
||||
|
|
@ -23,17 +23,17 @@
|
|||
|
||||
#include <guiddef.h>
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
const wchar_t *g_pMFTFriendlyName = L"Microsoft AVC DX12 Encoder HMFT";
|
||||
DEFINE_GUID( CLSID_CDX12EncoderHMFT, 0x8994db7c, 0x288a, 0x4c62, 0xa1, 0x36, 0xa3, 0xc3, 0xc2, 0xa2, 0x08, 0xa8 );
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
const wchar_t *g_pMFTFriendlyName = L"Microsoft HEVC DX12 Encoder HMFT";
|
||||
DEFINE_GUID( CLSID_CDX12EncoderHMFT, 0xe7ffb8eb, 0xfa0b, 0x4fb0, 0xac, 0xdf, 0x12, 0x2, 0xf6, 0x63, 0xcd, 0xe5 );
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
const wchar_t *g_pMFTFriendlyName = L"Microsoft AV1 DX12 Encoder HMFT";
|
||||
DEFINE_GUID( CLSID_CDX12EncoderHMFT, 0x1a6f3150, 0xb121, 0x4ce9, 0x94, 0x97, 0x50, 0xfe, 0xdb, 0x3d, 0xcb, 0x70 );
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
extern "C" struct pipe_screen *
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "wpptrace.tmh"
|
||||
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
||||
g_hEtwProvider, // Name of the provider handle
|
||||
|
|
@ -33,7 +33,7 @@ TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
|||
// 0000e264-0dc9-401d-b9b8-05e4eca4977e
|
||||
( 0x0000e264, 0x0dc9, 0x401d, 0xb9, 0xb8, 0x05, 0xe4, 0xec, 0xa4, 0x97, 0x7e ) );
|
||||
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
||||
g_hEtwProvider, // Name of the provider handle
|
||||
|
|
@ -41,7 +41,7 @@ TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
|||
// 0000e265-0dc9-401d-b9b8-05e4eca4977e
|
||||
( 0x0000e265, 0x0dc9, 0x401d, 0xb9, 0xb8, 0x05, 0xe4, 0xec, 0xa4, 0x97, 0x7e ) );
|
||||
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
||||
g_hEtwProvider, // Name of the provider handle
|
||||
|
|
@ -50,7 +50,7 @@ TRACELOGGING_DEFINE_PROVIDER( // defines g_hProvider
|
|||
( 0x0000eaa1, 0x0dc9, 0x401d, 0xb9, 0xb8, 0x05, 0xe4, 0xec, 0xa4, 0x97, 0x7e ) );
|
||||
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@
|
|||
|
||||
#include <TraceLoggingProvider.h>
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
#define DEFINE_MFE_WPP_GUID ( 264, 0dc9, 401d, b9b8, 05e4eca4977e )
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
#define DEFINE_MFE_WPP_GUID ( 265, 0dc9, 401d, b9b8, 05e4eca4977e )
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
#define DEFINE_MFE_WPP_GUID ( aa1, 0dc9, 401d, b9b8, 05e4eca4977e )
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
#define WPP_CONTROL_GUIDS WPP_DEFINE_CONTROL_GUID( CTRLGUID_MFE, DEFINE_MFE_WPP_GUID, WPP_DEFINE_BIT( MFE_ALL ) )
|
||||
|
|
@ -64,20 +64,20 @@
|
|||
TRACELOGGING_DECLARE_PROVIDER( g_hEtwProvider );
|
||||
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
|
||||
#define ETW_MODULE_STR "H264Enc"
|
||||
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
|
||||
#define ETW_MODULE_STR "H265Enc"
|
||||
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
|
||||
#define ETW_MODULE_STR "AV1Enc"
|
||||
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
#define HMFT_ETW_EVENT_START( EventId, this ) \
|
||||
|
|
|
|||
|
|
@ -31,20 +31,20 @@ using namespace Microsoft::WRL;
|
|||
extern "C" BOOL WINAPI
|
||||
DllEntryPoint(HINSTANCE, ULONG, __inout_opt LPVOID);
|
||||
|
||||
#if VIDEO_CODEC_H264ENC
|
||||
#if MFT_CODEC_H264ENC
|
||||
const wchar_t *g_pMFTFriendlyName =
|
||||
L"Microsoft AVC DX12 Encoder HMFT";
|
||||
DEFINE_GUID(CLSID_CDX12EncoderHMFT, 0x8994db7c, 0x288a, 0x4c62, 0xa1, 0x36, 0xa3, 0xc3, 0xc2, 0xa2, 0x08, 0xa8);
|
||||
#elif VIDEO_CODEC_H265ENC
|
||||
#elif MFT_CODEC_H265ENC
|
||||
const wchar_t *g_pMFTFriendlyName =
|
||||
L"Microsoft HEVC DX12 Encoder HMFT";
|
||||
DEFINE_GUID(CLSID_CDX12EncoderHMFT, 0xe7ffb8eb, 0xfa0b, 0x4fb0, 0xac, 0xdf, 0x12, 0x2, 0xf6, 0x63, 0xcd, 0xe5);
|
||||
#elif VIDEO_CODEC_AV1ENC
|
||||
#elif MFT_CODEC_AV1ENC
|
||||
const wchar_t *g_pMFTFriendlyName =
|
||||
L"Microsoft AV1 DX12 Encoder HMFT";
|
||||
DEFINE_GUID(CLSID_CDX12EncoderHMFT, 0x1a6f3150, 0xb121, 0x4ce9, 0x94, 0x97, 0x50, 0xfe, 0xdb, 0x3d, 0xcb, 0x70);
|
||||
#else
|
||||
#error VIDEO_CODEC_xxx must be defined
|
||||
#error MFT_CODEC_xxx must be defined
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hModule = nullptr;
|
||||
|
|
|
|||
|
|
@ -19,31 +19,8 @@
|
|||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
mf_cpp_args = cc.get_supported_arguments([
|
||||
'/we4267',
|
||||
'/we4996',
|
||||
'/we4146',
|
||||
'/we4244',
|
||||
'/we4389',
|
||||
'/we4838',
|
||||
'/we4302',
|
||||
'/we4018',
|
||||
'/we4056',
|
||||
'/we4305',
|
||||
'/we4351',
|
||||
'/we4756',
|
||||
'/we4800',
|
||||
'/we4291',
|
||||
'/we4624',
|
||||
'/we4309',
|
||||
'/we5105',
|
||||
'/we4020',
|
||||
'/we4024',
|
||||
'/we4189',
|
||||
])
|
||||
if get_option('mediafoundation-store-dll')
|
||||
mf_cpp_args += '-DBUILD_FOR_MSDK' # Can use #if BUILD_FOR_MSDK in .cpp code
|
||||
endif
|
||||
dxcore_lib = cpp.find_library('dxcore')
|
||||
rc_compiler = find_program('rc')
|
||||
|
||||
mediafoundation_link_args = ['runtimeobject.lib','mfplat.lib','mfuuid.lib','d3d12.lib','dxgi.lib']
|
||||
mediafoundation_link_depends = []
|
||||
|
|
@ -74,45 +51,43 @@ mediafoundation_def = custom_target(
|
|||
command : gen_vs_module_defs_normal_command,
|
||||
)
|
||||
|
||||
gallium_mf_name = get_option('mediafoundation-windows-dll-name')
|
||||
winmod = import('windows')
|
||||
dll_version = '1.0.5'
|
||||
foreach codec : mft_codecs
|
||||
gallium_mf_name = 'ms' + codec + 'hmft'
|
||||
if get_option('mediafoundation-store-dll')
|
||||
gallium_mf_name += '_store'
|
||||
endif
|
||||
mft_dll_version = dll_version
|
||||
|
||||
mft_dll_version = '1.0.5'
|
||||
mediafoundation_rc_conf_data = configuration_data()
|
||||
mediafoundation_rc_conf_data.set('CompanyName', '"Microsoft Corporation"')
|
||||
mediafoundation_rc_conf_data.set('FileDescription', '"Media Foundation DX12 Encoder MFT"')
|
||||
mediafoundation_rc_conf_data.set('FileVersion', '@0@.0'.format(mft_dll_version))
|
||||
mediafoundation_rc_conf_data.set('InternalName', '"@0@"'.format(gallium_mf_name))
|
||||
mediafoundation_rc_conf_data.set('OriginalFilename', '"@0@"'.format(gallium_mf_name))
|
||||
mediafoundation_rc_conf_data.set('ProductName', '"Media Foundation Encoder MFT"')
|
||||
mediafoundation_rc_conf_data.set('ProductVersion', '@0@.0'.format(mft_dll_version))
|
||||
|
||||
mediafoundation_rc_conf_data = configuration_data()
|
||||
mediafoundation_rc_conf_data.set('CompanyName', '"Microsoft Corporation"')
|
||||
mediafoundation_rc_conf_data.set('FileDescription', '"Media Foundation DX12 Encoder MFT"')
|
||||
mediafoundation_rc_conf_data.set('FileVersion', '@0@.0'.format(mft_dll_version))
|
||||
mediafoundation_rc_conf_data.set('InternalName', '"@0@"'.format(gallium_mf_name))
|
||||
mediafoundation_rc_conf_data.set('OriginalFilename', '"@0@"'.format(gallium_mf_name))
|
||||
mediafoundation_rc_conf_data.set('ProductName', '"Media Foundation Encoder MFT"')
|
||||
mediafoundation_rc_conf_data.set('ProductVersion', '@0@.0'.format(mft_dll_version))
|
||||
|
||||
mediafoundation_rc = configure_file(
|
||||
rc_file = configure_file(
|
||||
configuration: mediafoundation_rc_conf_data,
|
||||
input: 'mediafoundation.rc.in',
|
||||
output: 'mediafoundation.rc',
|
||||
)
|
||||
output: 'mediafoundation_@0@.rc'.format(codec),
|
||||
)
|
||||
rc_target = winmod.compile_resources(rc_file)
|
||||
|
||||
rc_compiler = find_program('rc')
|
||||
rc_target = custom_target('resource',
|
||||
input : mediafoundation_rc,
|
||||
output : 'mediafoundation.res',
|
||||
command : [rc_compiler, join_paths(meson.current_build_dir(), 'mediafoundation.rc')]
|
||||
)
|
||||
|
||||
dxcore_lib = cpp.find_library('dxcore')
|
||||
libmediafoundation_gallium = shared_library(
|
||||
libmediafoundation_gallium = shared_library(
|
||||
gallium_mf_name,
|
||||
'target.c',
|
||||
'dllmain.cpp',
|
||||
link_args : [mediafoundation_link_args, ld_args_gc_sections, ld_args_build_id],
|
||||
vs_module_defs : 'dx12enchmft.def', #mediafoundation_def,
|
||||
cpp_args : mf_cpp_args,
|
||||
cpp_args : mf_codecs_cpp_args[codec],
|
||||
override_options: ['cpp_std=c++20'],
|
||||
include_directories : [
|
||||
inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers, inc_gallium_winsys_sw
|
||||
],
|
||||
link_whole : [mediafoundation_st],
|
||||
link_whole : [mediafoundation_st[codec]],
|
||||
link_with : link_with_libmediafoundation_gallium,
|
||||
dependencies : [driver_d3d12, idep_mesautil, dxcore_lib, dep_dxheaders],
|
||||
soversion : host_machine.system() == 'windows' ? '' : mft_dll_version,
|
||||
|
|
@ -122,19 +97,20 @@ libmediafoundation_gallium = shared_library(
|
|||
name_suffix : 'dll',
|
||||
name_prefix : '', # otherwise mingw will create libXXX.dll
|
||||
objects: [rc_target]
|
||||
)
|
||||
)
|
||||
|
||||
gallium_mf_test_name = gallium_mf_name + '_test'
|
||||
if with_gallium_mediafoundation_test
|
||||
if with_gallium_mediafoundation_test
|
||||
gallium_mf_test_name = gallium_mf_name + '_test'
|
||||
test(
|
||||
gallium_mf_test_name,
|
||||
executable(
|
||||
gallium_mf_test_name,
|
||||
link_args : [mediafoundation_link_args, ld_args_gc_sections, ld_args_build_id, 'strmiids.lib'],
|
||||
link_whole: [mediafoundation_st, mediafoundation_test_st],
|
||||
link_whole: [mediafoundation_st[codec], mediafoundation_test_st[codec]],
|
||||
link_with : link_with_libmediafoundation_gallium,
|
||||
dependencies : [idep_gtest, driver_d3d12, idep_mesautil, dxcore_lib, dep_dxheaders],
|
||||
),
|
||||
protocol: 'gtest'
|
||||
)
|
||||
endif
|
||||
endif
|
||||
endforeach
|
||||
Loading…
Add table
Reference in a new issue