Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5362 serge 1
/*
2
 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the
6
 * "Software"), to deal in the Software without restriction, including
7
 * without limitation the rights to use, copy, modify, merge, publish,
8
 * distribute, sub license, and/or sell copies of the Software, and to
9
 * permit persons to whom the Software is furnished to do so, subject to
10
 * the following conditions:
11
 *
12
 * The above copyright notice and this permission notice (including the
13
 * next paragraph) shall be included in all copies or substantial portions
14
 * of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 */
24
 
25
#define TEST_DESCRIPTION	"Create and destroy buffers"
26
 
27
#include "test_common.c"
28
 
29
VAConfigID config;
30
VAContextID context;
31
VASurfaceID *surfaces;
32
int total_surfaces;
33
 
34
void pre()
35
{
36
    test_init();
37
 
38
    va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config);
39
    ASSERT( VA_STATUS_SUCCESS == va_status );
40
    status("vaCreateConfig returns %08x\n", config);
41
 
42
    int width = 352;
43
    int height = 288;
44
    int surface_count = 4;
45
    total_surfaces = surface_count;
46
 
47
    surfaces = malloc(total_surfaces * sizeof(VASurfaceID));
48
 
49
    // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config
50
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, width, height, surfaces, total_surfaces, NULL, 0);
51
    ASSERT( VA_STATUS_SUCCESS == va_status );
52
 
53
    status("vaCreateContext with config %08x\n", config);
54
    int flags = 0;
55
    va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context );
56
    ASSERT( VA_STATUS_SUCCESS == va_status );
57
}
58
 
59
void test_unique_buffers(VABufferID *buffer_list, int buffer_count)
60
{
61
    int i,j;
62
 
63
    for(i = 0; i < buffer_count; i++)
64
    {
65
        for(j = 0; j < i; j++)
66
        {
67
            ASSERT(buffer_list[i] != buffer_list[j]);
68
        }
69
    }
70
}
71
 
72
VABufferType buffer_types[] =
73
{
74
  VAPictureParameterBufferType,
75
  VAIQMatrixBufferType,
76
  VABitPlaneBufferType,
77
  VASliceGroupMapBufferType,
78
  VASliceParameterBufferType,
79
  VASliceDataBufferType,
80
  VAMacroblockParameterBufferType,
81
  VAResidualDataBufferType,
82
  VADeblockingParameterBufferType,
83
};
84
 
85
unsigned int buffer_sizes[] =
86
{
87
  sizeof(VAPictureParameterBufferMPEG4),
88
  sizeof(VAIQMatrixBufferH264),
89
  32*1024,
90
  48*1024,
91
  sizeof(VASliceParameterBufferMPEG2),
92
  128*1024,
93
  sizeof(VAMacroblockParameterBufferMPEG2),
94
  32*1024,
95
  15*1024,
96
};
97
 
98
 
99
#define NUM_BUFFER_TYPES 	(sizeof(buffer_types) / sizeof(VABufferType))
100
 
101
#define DEAD_BUFFER_ID	((VABufferID) 0x1234ffff)
102
 
103
void test()
104
{
105
    VABufferID buffer_ids[NUM_BUFFER_TYPES+1];
106
    unsigned int i;
107
    memset(buffer_ids, 0xff, sizeof(buffer_ids));
108
    for(i=0; i < NUM_BUFFER_TYPES; i++)
109
    {
110
        buffer_ids[i+1] = DEAD_BUFFER_ID;
111
        va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, NULL, &buffer_ids[i]);
112
        ASSERT( VA_STATUS_SUCCESS == va_status );
113
        ASSERT( DEAD_BUFFER_ID == buffer_ids[i+1] ); /* Bounds check */
114
    }
115
    test_unique_buffers(buffer_ids, NUM_BUFFER_TYPES);
116
 
117
    for(i=0; i < NUM_BUFFER_TYPES; i++)
118
    {
119
        va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]);
120
        ASSERT( VA_STATUS_SUCCESS == va_status );
121
    }
122
}
123
 
124
void post()
125
{
126
    status("vaDestroyContext for context %08x\n", context);
127
    va_status = vaDestroyContext( va_dpy, context );
128
    ASSERT( VA_STATUS_SUCCESS == va_status );
129
 
130
    status("vaDestroyConfig for config %08x\n", config);
131
    va_status = vaDestroyConfig( va_dpy, config );
132
    ASSERT( VA_STATUS_SUCCESS == va_status );
133
 
134
    va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
135
    ASSERT( VA_STATUS_SUCCESS == va_status );
136
 
137
    free(surfaces);
138
 
139
    test_terminate();
140
}