2
* Spandex benchmark and test framework.
4
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Kari J. Kangas <kari.j.kangas@nokia.com>
8
* This framework is free software; you can redistribute it and/or modify it
9
* under the terms of the GNU Lesser General Public License as published by the
10
* Free Software Foundation, version 2.1 of the License.
12
* This framework is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this framework; if not, see <http://www.gnu.org/licenses/>.
22
#include "sct_opengles2decodeaction.h"
23
#include "sct_sicommon.h"
24
#include "sct_sifile.h"
25
#include "sct_utils.h"
31
#define SCT_PVRTEXTOOL3_HEADER_LENGTH 52
37
void* sctiCreateOpenGLES2DecodeActionContext( void* moduleContext, SCTAttributeList* attributes )
39
SCTOpenGLES2DecodeActionContext* context;
41
SCT_ASSERT_ALWAYS( moduleContext != NULL );
42
SCT_ASSERT_ALWAYS( attributes != NULL );
44
context = ( SCTOpenGLES2DecodeActionContext* )( siCommonMemoryAlloc( NULL, sizeof( SCTOpenGLES2DecodeActionContext ) ) );
47
SCT_LOG_ERROR( "Allocation failed in Decode@OpenGLES2 action context creation." );
50
memset( context, 0, sizeof( SCTOpenGLES2DecodeActionContext ) );
52
context->moduleContext = ( SCTOpenGLES2ModuleContext* )( moduleContext );
54
if( sctiParseOpenGLES2DecodeActionAttributes( &( context->data ), attributes ) == SCT_FALSE )
56
sctiDestroyOpenGLES2DecodeActionContext( context );
60
if( sctiOpenGLES2ModuleIsValidDataIndex( context->moduleContext, context->data.srcDataIndex ) == SCT_FALSE )
62
sctiDestroyOpenGLES2DecodeActionContext( context );
63
SCT_LOG_ERROR( "Invalid source data index in Decode@OpenGLES2 context creation." );
67
if( sctiOpenGLES2ModuleIsValidDataIndex( context->moduleContext, context->data.dstDataIndex ) == SCT_FALSE )
69
sctiDestroyOpenGLES2DecodeActionContext( context );
70
SCT_LOG_ERROR( "Invalid destination data index in Decode@OpenGLES2 context creation." );
81
void sctiDestroyOpenGLES2DecodeActionContext( void* context )
88
siCommonMemoryFree( NULL, context );
95
SCTBoolean sctiOpenGLES2DecodeActionInit( SCTAction* action, SCTBenchmark* benchmark )
97
SCT_ASSERT_ALWAYS( action != NULL );
98
SCT_ASSERT_ALWAYS( action->context != NULL );
99
SCT_ASSERT_ALWAYS( benchmark != NULL );
108
SCTBoolean sctiOpenGLES2DecodeActionExecute( SCTAction* action, int frameNumber )
110
SCTOpenGLES2DecodeActionContext* context;
111
OpenGLES2DecodeActionData* data;
112
SCTOpenGLES2Data* srcData;
113
SCTOpenGLES2Data* dstData;
114
unsigned char* ptr = NULL;
117
SCT_ASSERT( action != NULL );
118
SCT_ASSERT( action->context != NULL );
119
SCT_USE_VARIABLE( frameNumber );
121
context = ( SCTOpenGLES2DecodeActionContext* )( action->context );
122
data = &( context->data );
124
srcData = sctiOpenGLES2ModuleGetData( context->moduleContext, data->srcDataIndex );
125
if( srcData == NULL )
127
SCT_LOG_ERROR( "Invalid source data index in Decode@OpenGLES2 action execute." );
131
if( data->encoder == DECODE_ENCODER_PVRTEXTOOL3 )
133
if( srcData->length <= SCT_PVRTEXTOOL3_HEADER_LENGTH )
135
SCT_LOG_ERROR( "Invalid PVRTEXTOOL3 data in Decode@OpenGLES2 action execute." );
139
ptr = &( ( unsigned char* )( srcData->data ) )[ SCT_PVRTEXTOOL3_HEADER_LENGTH ];
140
length = srcData->length - SCT_PVRTEXTOOL3_HEADER_LENGTH;
144
SCT_LOG_ERROR( "Unexpected encoder in Decode@OpenGLES2 action execute." );
148
dstData = sctiOpenGLES2ModuleGetData( context->moduleContext, data->dstDataIndex );
149
if( dstData != NULL )
151
if( dstData->length != length )
153
SCT_LOG_ERROR( "Destination data index already in use in Decode@OpenGLES2 action execute." );
157
memcpy( dstData->data, ptr, length );
161
dstData = sctOpenGLES2CreateData( ptr, length, SCT_TRUE );
162
if( dstData == NULL )
164
SCT_LOG_ERROR( "Destination data allocation failed in Decode@OpenGLES2 action execute." );
168
sctiOpenGLES2ModuleSetData( context->moduleContext, data->dstDataIndex, dstData );
178
void sctiOpenGLES2DecodeActionTerminate( SCTAction* action )
180
SCTOpenGLES2DecodeActionContext* context;
182
SCT_ASSERT_ALWAYS( action != NULL );
183
SCT_ASSERT_ALWAYS( action->context != NULL );
185
context = ( SCTOpenGLES2DecodeActionContext* )( action->context );
187
sctiOpenGLES2ModuleDeleteData( context->moduleContext, context->data.dstDataIndex );
194
void sctiOpenGLES2DecodeActionDestroy( SCTAction* action )
196
SCTOpenGLES2DecodeActionContext* context;
198
SCT_ASSERT_ALWAYS( action != NULL );
200
context = ( SCTOpenGLES2DecodeActionContext* )( action->context );
202
action->context = NULL;
203
sctiDestroyOpenGLES2DecodeActionContext( context );