From ff1c171bae6c3f5a0845bb6de11903eac546fc56 Mon Sep 17 00:00:00 2001 From: "Pohsiang (John) Hsu" Date: Wed, 29 Apr 2026 15:29:56 -0700 Subject: [PATCH] mediafoundation: periodic clang-format Reviewed-by: Yubo Xie Part-of: --- .../frontends/mediafoundation/codecapi.cpp | 2 +- .../mediafoundation/dpb_buffer_manager.cpp | 4 +- .../frontends/mediafoundation/encode.cpp | 2 +- .../frontends/mediafoundation/encode_h264.cpp | 2 +- .../frontends/mediafoundation/encode_hevc.cpp | 6 ++- .../frontends/mediafoundation/mftransform.cpp | 51 +++++++++++-------- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/gallium/frontends/mediafoundation/codecapi.cpp b/src/gallium/frontends/mediafoundation/codecapi.cpp index 5bfea700e45..faffed8c932 100644 --- a/src/gallium/frontends/mediafoundation/codecapi.cpp +++ b/src/gallium/frontends/mediafoundation/codecapi.cpp @@ -958,7 +958,7 @@ CDX12EncHMFT::GetValue( const GUID *Api, VARIANT *Value ) hevcDeltaQPSettings.dataType = CODEC_API_QP_MAP_INT8; hevcDeltaQPSettings.minValue = static_cast( m_uiMinQP ); hevcDeltaQPSettings.maxValue = static_cast( m_uiMaxQP ); -#if defined(INPUTQPSETTINGS_HAS_STEPS) +#if defined( INPUTQPSETTINGS_HAS_STEPS ) hevcDeltaQPSettings.steps = 1; #else hevcDeltaQPSettings.step = 1; diff --git a/src/gallium/frontends/mediafoundation/dpb_buffer_manager.cpp b/src/gallium/frontends/mediafoundation/dpb_buffer_manager.cpp index d640fad8981..4255be29dc4 100644 --- a/src/gallium/frontends/mediafoundation/dpb_buffer_manager.cpp +++ b/src/gallium/frontends/mediafoundation/dpb_buffer_manager.cpp @@ -82,8 +82,8 @@ dpb_buffer_manager::dpb_buffer_manager( void *logId, PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_ENC_READABLE_RECONSTRUCTED_PICTURE ) != 0 ) { - m_template.bind = PIPE_BIND_SHARED | // Indicate we want shared resource capabilities - PIPE_BIND_RENDER_TARGET; // This is also required for opening shared resources in D3D11 + m_template.bind = PIPE_BIND_SHARED | // Indicate we want shared resource capabilities + PIPE_BIND_RENDER_TARGET; // This is also required for opening shared resources in D3D11 } for( auto &entry : m_pool ) diff --git a/src/gallium/frontends/mediafoundation/encode.cpp b/src/gallium/frontends/mediafoundation/encode.cpp index 162b432639f..bee66ef2266 100644 --- a/src/gallium/frontends/mediafoundation/encode.cpp +++ b/src/gallium/frontends/mediafoundation/encode.cpp @@ -581,7 +581,7 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E if( m_bSliceGenerationModeSet && pDX12EncodeContext->IsSliceAutoModeEnabled() ) { - num_output_buffers = std::max(128u, m_EncoderCapabilities.m_uiMaxHWSupportedMaxSlices); + num_output_buffers = std::max( 128u, m_EncoderCapabilities.m_uiMaxHWSupportedMaxSlices ); } // Minimum per-slice buffer size to prevent excessively small allocations. diff --git a/src/gallium/frontends/mediafoundation/encode_h264.cpp b/src/gallium/frontends/mediafoundation/encode_h264.cpp index 83851edcbd7..5b8c9b9435f 100644 --- a/src/gallium/frontends/mediafoundation/encode_h264.cpp +++ b/src/gallium/frontends/mediafoundation/encode_h264.cpp @@ -1150,7 +1150,7 @@ CDX12EncHMFT::GetMaxReferences( unsigned int width, unsigned int height ) if( width != 0 && height != 0 ) { int maxDPBSize = GetMaxDPBSize( width, height, m_uiLevel ); - uiMaxReferences = std::min( (int) m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity, maxDPBSize ); + uiMaxReferences = std::min( (int) m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity, maxDPBSize ); } return uiMaxReferences; } diff --git a/src/gallium/frontends/mediafoundation/encode_hevc.cpp b/src/gallium/frontends/mediafoundation/encode_hevc.cpp index bfc3d29ae78..f8400002ea5 100644 --- a/src/gallium/frontends/mediafoundation/encode_hevc.cpp +++ b/src/gallium/frontends/mediafoundation/encode_hevc.cpp @@ -153,7 +153,8 @@ CDX12EncHMFT::UpdateH265EncPictureDesc( pipe_h265_enc_picture_desc *pPicInfo, pPicInfo->seq.sar_height = m_VUIInfo.stSARInfo.usHeight; pPicInfo->seq.num_units_in_tick = m_FrameRate.Denominator; - pPicInfo->seq.time_scale = m_FrameRate.Numerator; // Table E.6 seq.vui_flags.frame_field_info_present_flag is 0, deltaToDivisor should be 1. + pPicInfo->seq.time_scale = + m_FrameRate.Numerator; // Table E.6 seq.vui_flags.frame_field_info_present_flag is 0, deltaToDivisor should be 1. pPicInfo->seq.video_format = m_VUIInfo.stVidSigType.eVideoFormat; pPicInfo->seq.colour_primaries = m_VUIInfo.stVidSigType.eColorPrimary; @@ -986,7 +987,8 @@ CDX12EncHMFT::GetMaxReferences( unsigned int width, unsigned int height ) UINT32 uiMaxReferences = m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity; if( width != 0 && height != 0 ) { - const int minCbSizeY = 1 << ( m_EncoderCapabilities.m_HWSupportH265BlockSizes.bits.log2_min_luma_coding_block_size_minus3 + 3 ); + const int minCbSizeY = + 1 << ( m_EncoderCapabilities.m_HWSupportH265BlockSizes.bits.log2_min_luma_coding_block_size_minus3 + 3 ); int maxDPBSize = GetMaxDPBSize( width, height, m_uiLevel, minCbSizeY ); uiMaxReferences = std::min( (int) m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity, maxDPBSize ); } diff --git a/src/gallium/frontends/mediafoundation/mftransform.cpp b/src/gallium/frontends/mediafoundation/mftransform.cpp index 6da39986176..52523f8764f 100644 --- a/src/gallium/frontends/mediafoundation/mftransform.cpp +++ b/src/gallium/frontends/mediafoundation/mftransform.cpp @@ -1262,10 +1262,10 @@ CDX12EncHMFT::ProcessSliceBitstreamZeroCopy( LPDX12EncodeContext pDX12EncodeCont return false; } - uint64_t total_slice_size = - std::accumulate( mfsample_codec_unit_metadata.begin(), mfsample_codec_unit_metadata.end(), 0ull, []( uint64_t sum, const auto &nal ) { - return sum + nal.size; - } ); + uint64_t total_slice_size = std::accumulate( mfsample_codec_unit_metadata.begin(), + mfsample_codec_unit_metadata.end(), + 0ull, + []( uint64_t sum, const auto &nal ) { return sum + nal.size; } ); // Create IMFMediaBuffer from the D3D12Resource (zero-copy) spMediaBuffer.Attach( @@ -1593,10 +1593,11 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) if( WaitForFence( pDX12EncodeContext->pSliceFences[slice_idx], OS_TIMEOUT_INFINITE ) ) { - if( !pThis->ProcessSliceBitstreamZeroCopy( pDX12EncodeContext, - slice_idx, - spMediaBuffer, - codec_unit_metadata ) ) // codec_unit_metadata.clear() will be called in this function + if( !pThis->ProcessSliceBitstreamZeroCopy( + pDX12EncodeContext, + slice_idx, + spMediaBuffer, + codec_unit_metadata ) ) // codec_unit_metadata.clear() will be called in this function { debug_printf( "[dx12 hmft 0x%p] Failed to process slice %u bitstream\n", pThis, slice_idx ); MFE_ERROR( "[dx12 hmft 0x%p] Failed to process slice %u bitstream", pThis, slice_idx ); @@ -1633,16 +1634,19 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) pendingMetadata.reserve( 16 ); uint32_t actual_slice_count = 0; - struct HandleCloser { - void operator()( void *h ) { - if(h) CloseHandle(h); + struct HandleCloser + { + void operator()( void *h ) + { + if( h ) + CloseHandle( h ); } }; std::unique_ptr lastSliceFenceEvent( - pThis->m_pPipeContext->screen->fence_get_win32_event( - pThis->m_pPipeContext->screen, pDX12EncodeContext->pLastSliceFence ) ); - assert(lastSliceFenceEvent); + pThis->m_pPipeContext->screen->fence_get_win32_event( pThis->m_pPipeContext->screen, + pDX12EncodeContext->pLastSliceFence ) ); + assert( lastSliceFenceEvent ); // Pre-create all slice fence events to avoid per-iteration // CreateEvent+SetEventOnCompletion kernel round-trips @@ -1651,8 +1655,9 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) sliceFenceEvents.reserve( num_slice_buffers ); for( uint32_t i = 0; i < num_slice_buffers; i++ ) { - sliceFenceEvents.emplace_back( pThis->m_pPipeContext->screen->fence_get_win32_event( - pThis->m_pPipeContext->screen, pDX12EncodeContext->pSliceFences[i] ) ); + sliceFenceEvents.emplace_back( + pThis->m_pPipeContext->screen->fence_get_win32_event( pThis->m_pPipeContext->screen, + pDX12EncodeContext->pSliceFences[i] ) ); assert( sliceFenceEvents[i] ); } @@ -1695,10 +1700,11 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) pendingSample = std::move( preallocatedSamples[slice_idx] ); pendingBuffer.Reset(); - if( !pThis->ProcessSliceBitstreamZeroCopy( pDX12EncodeContext, - slice_idx, - pendingBuffer, - pendingMetadata ) ) // pendingMetadata.clear() will be called in this function + if( !pThis->ProcessSliceBitstreamZeroCopy( + pDX12EncodeContext, + slice_idx, + pendingBuffer, + pendingMetadata ) ) // pendingMetadata.clear() will be called in this function { debug_printf( "[dx12 hmft 0x%p] Failed to process slice %u bitstream\n", pThis, slice_idx ); MFE_ERROR( "[dx12 hmft 0x%p] Failed to process slice %u bitstream", pThis, slice_idx ); @@ -1723,7 +1729,8 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) { // Unexpected WaitForMultipleObjects result on waitResult DWORD lastError = GetLastError(); - debug_printf( "[dx12 hmft 0x%p] WaitForMultipleObjects failed for slice %" PRIu32 " (result=0x%" PRIx32 ", GetLastError=0x%" PRIx32 ")\n", + debug_printf( "[dx12 hmft 0x%p] WaitForMultipleObjects failed for slice %" PRIu32 " (result=0x%" PRIx32 + ", GetLastError=0x%" PRIx32 ")\n", pThis, slice_idx, static_cast( waitResult ), @@ -2839,7 +2846,7 @@ CDX12EncHMFT::ProcessOutput( DWORD dwFlags, DWORD cOutputBufferCount, MFT_OUTPUT UINT32 isLastSlice = FALSE; if( SUCCEEDED( pOutputSamples[0].pSample->GetUINT32( MFSampleExtension_LastSlice, &isLastSlice ) ) ) { - if (!isLastSlice) + if( !isLastSlice ) { sendNeedInput = false; }