2 * Copyright (c) 2007-2010 SlimDX Group
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #include "../ComObject.h"
25 #include "../DataStream.h"
26 #include "../stack_array.h"
28 const IID IID_CXAPOBase = __uuidof(IXAPO);
29 const IID IID_CXAPOParametersBase = __uuidof(IXAPOParameters);
31 #include "ParameterizedProcessor.h"
33 using namespace System;
34 using namespace SlimDX::Multimedia;
40 ParameterizedProcessor::ParameterizedProcessor( SlimDX::XAPO::RegistrationProperties properties, DataStream^ parameterBlocks, int blockSize, bool producer )
42 XAPO_REGISTRATION_PROPERTIES props = properties.ToUnmanaged();
44 Construct( static_cast<IXAPOParameters*>( new XAPOParametersImpl( this, &props, reinterpret_cast<BYTE*>( parameterBlocks->PositionPointer ), blockSize, producer ) ) );
47 IntPtr ParameterizedProcessor::BeginProcess()
49 return IntPtr( ParamPointer->BeginProcess() );
52 void ParameterizedProcessor::EndProcess()
54 ParamPointer->EndProcess();
57 void ParameterizedProcessor::OnSetParameters( DataStream^ parameters )
59 SLIMDX_UNREFERENCED_PARAMETER( parameters );
62 void ParameterizedProcessor::GetParameters( DataStream^ parameters )
64 ParamPointer->GetParameters( parameters->PositionPointer, static_cast<UINT32>( parameters->RemainingLength ) );
67 void ParameterizedProcessor::SetParameters( DataStream^ parameters )
69 ParamPointer->SetParameters( parameters->PositionPointer, static_cast<UINT32>( parameters->RemainingLength ) );
72 bool ParameterizedProcessor::ParametersChanged::get()
74 return ParamPointer->ParametersChanged() > 0;
77 XAPOParametersImpl::XAPOParametersImpl( ParameterizedProcessor^ processor, XAPO_REGISTRATION_PROPERTIES *pRegProperties, BYTE *pParameterBlocks, UINT32 uParameterBlockByteSize, BOOL fProducer )
78 : CXAPOParametersBase( pRegProperties, pParameterBlocks, uParameterBlockByteSize, fProducer )
80 m_processor = processor;
83 void XAPOParametersImpl::OnSetParameters( const void *pParameters, UINT32 ParameterByteSize )
85 m_processor->OnSetParameters( gcnew DataStream( pParameters, ParameterByteSize, true, false ) );
88 void XAPOParametersImpl::Process( UINT32 InputProcessParameterCount, const XAPO_PROCESS_BUFFER_PARAMETERS *pInputProcessParameters, UINT32 OutputProcessParameterCount, XAPO_PROCESS_BUFFER_PARAMETERS *pOutputProcessParameters, BOOL IsEnabled )
92 array<BufferParameter>^ input = gcnew array<BufferParameter>( InputProcessParameterCount );
93 for( int i = 0; i < input->Length; i++ )
96 p.Buffer = IntPtr( pInputProcessParameters[i].pBuffer );
97 p.Flags = static_cast<BufferFlags>( pInputProcessParameters[i].BufferFlags );
98 p.ValidFrameCount = pInputProcessParameters[i].ValidFrameCount;
103 array<BufferParameter>^ output = gcnew array<BufferParameter>( OutputProcessParameterCount );
104 for( int i = 0; i < output->Length; i++ )
107 p.Buffer = IntPtr( pOutputProcessParameters[i].pBuffer );
108 p.Flags = static_cast<BufferFlags>( pOutputProcessParameters[i].BufferFlags );
109 p.ValidFrameCount = pOutputProcessParameters[i].ValidFrameCount;
114 m_processor->Process( input, output, IsEnabled > 0 );