OSDN Git Service

#32713 初コミット。SVNrev567時点での、ファイルはbranch/140707(ReBuild XGVersion)から移行したもの。
[dtxmaniaxg-verk/dtxmaniaxg-verk-git.git] / SlimDXc_Jun2010(VC++2008) / source / xapo / ParameterizedProcessor.cpp
1 /*
2 * Copyright (c) 2007-2010 SlimDX Group
3
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:
10
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13
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
20 * THE SOFTWARE.
21 */
22 #include "stdafx.h"
23
24 #include "../ComObject.h"
25 #include "../DataStream.h"
26 #include "../stack_array.h"
27
28 const IID IID_CXAPOBase = __uuidof(IXAPO);
29 const IID IID_CXAPOParametersBase = __uuidof(IXAPOParameters);
30
31 #include "ParameterizedProcessor.h"
32
33 using namespace System;
34 using namespace SlimDX::Multimedia;
35
36 namespace SlimDX
37 {
38 namespace XAPO
39 {
40         ParameterizedProcessor::ParameterizedProcessor( SlimDX::XAPO::RegistrationProperties properties, DataStream^ parameterBlocks, int blockSize, bool producer )
41         {
42                 XAPO_REGISTRATION_PROPERTIES props = properties.ToUnmanaged();
43
44                 Construct( static_cast<IXAPOParameters*>( new XAPOParametersImpl( this, &props, reinterpret_cast<BYTE*>( parameterBlocks->PositionPointer ), blockSize, producer ) ) );
45         }
46
47         IntPtr ParameterizedProcessor::BeginProcess()
48         {
49                 return IntPtr( ParamPointer->BeginProcess() );
50         }
51
52         void ParameterizedProcessor::EndProcess()
53         {
54                 ParamPointer->EndProcess();
55         }
56
57         void ParameterizedProcessor::OnSetParameters( DataStream^ parameters )
58         {
59                 SLIMDX_UNREFERENCED_PARAMETER( parameters );
60         }
61
62         void ParameterizedProcessor::GetParameters( DataStream^ parameters )
63         {
64                 ParamPointer->GetParameters( parameters->PositionPointer, static_cast<UINT32>( parameters->RemainingLength ) );
65         }
66
67         void ParameterizedProcessor::SetParameters( DataStream^ parameters )
68         {
69                 ParamPointer->SetParameters( parameters->PositionPointer, static_cast<UINT32>( parameters->RemainingLength ) );
70         }
71
72         bool ParameterizedProcessor::ParametersChanged::get()
73         {
74                 return ParamPointer->ParametersChanged() > 0;
75         }
76
77         XAPOParametersImpl::XAPOParametersImpl( ParameterizedProcessor^ processor, XAPO_REGISTRATION_PROPERTIES *pRegProperties, BYTE *pParameterBlocks, UINT32 uParameterBlockByteSize, BOOL fProducer )
78                 : CXAPOParametersBase( pRegProperties, pParameterBlocks, uParameterBlockByteSize, fProducer )
79         {
80                 m_processor = processor;
81         }
82
83         void XAPOParametersImpl::OnSetParameters( const void *pParameters, UINT32 ParameterByteSize )
84         {
85                 m_processor->OnSetParameters( gcnew DataStream( pParameters, ParameterByteSize, true, false ) );
86         }
87
88         void XAPOParametersImpl::Process( UINT32 InputProcessParameterCount, const XAPO_PROCESS_BUFFER_PARAMETERS *pInputProcessParameters, UINT32 OutputProcessParameterCount, XAPO_PROCESS_BUFFER_PARAMETERS *pOutputProcessParameters, BOOL IsEnabled )
89         {
90                 try
91                 {
92                         array<BufferParameter>^ input = gcnew array<BufferParameter>( InputProcessParameterCount );
93                         for( int i = 0; i < input->Length; i++ )
94                         {
95                                 BufferParameter p;
96                                 p.Buffer = IntPtr( pInputProcessParameters[i].pBuffer );
97                                 p.Flags = static_cast<BufferFlags>( pInputProcessParameters[i].BufferFlags );
98                                 p.ValidFrameCount = pInputProcessParameters[i].ValidFrameCount;
99
100                                 input[i] = p;
101                         }
102
103                         array<BufferParameter>^ output = gcnew array<BufferParameter>( OutputProcessParameterCount );
104                         for( int i = 0; i < output->Length; i++ )
105                         {
106                                 BufferParameter p;
107                                 p.Buffer = IntPtr( pOutputProcessParameters[i].pBuffer );
108                                 p.Flags = static_cast<BufferFlags>( pOutputProcessParameters[i].BufferFlags );
109                                 p.ValidFrameCount = pOutputProcessParameters[i].ValidFrameCount;
110
111                                 output[i] = p;
112                         }
113
114                         m_processor->Process( input, output, IsEnabled > 0 );
115                 }
116                 catch(...)
117                 {
118                 }
119         }
120 }
121 }