Subversion Repositories Kolibri OS

Rev

Rev 5362 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5362 Rev 5366
Line 6... Line 6...
6
 * "Software"), to deal in the Software without restriction, including
6
 * "Software"), to deal in the Software without restriction, including
7
 * without limitation the rights to use, copy, modify, merge, publish,
7
 * without limitation the rights to use, copy, modify, merge, publish,
8
 * distribute, sub license, and/or sell copies of the Software, and to
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
9
 * permit persons to whom the Software is furnished to do so, subject to
10
 * the following conditions:
10
 * the following conditions:
11
 * 
11
 *
12
 * The above copyright notice and this permission notice (including the
12
 * The above copyright notice and this permission notice (including the
13
 * next paragraph) shall be included in all copies or substantial portions
13
 * next paragraph) shall be included in all copies or substantial portions
14
 * of the Software.
14
 * of the Software.
15
 * 
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
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,
20
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
Line 41... Line 41...
41
 
41
 
42
    int width = 352;
42
    int width = 352;
43
    int height = 288;
43
    int height = 288;
44
    int surface_count = 4;
44
    int surface_count = 4;
45
    total_surfaces = surface_count;
45
    total_surfaces = surface_count;
46
    
46
 
Line 47... Line 47...
47
    surfaces = malloc(total_surfaces * sizeof(VASurfaceID));
47
    surfaces = malloc(total_surfaces * sizeof(VASurfaceID));
48
 
48
 
49
    // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config
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);
50
    va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, width, height, surfaces, total_surfaces, NULL, 0);
51
    ASSERT( VA_STATUS_SUCCESS == va_status );
51
    ASSERT( VA_STATUS_SUCCESS == va_status );
52
    
52
 
53
    status("vaCreateContext with config %08x\n", config);
53
    status("vaCreateContext with config %08x\n", config);
54
    int flags = 0;
54
    int flags = 0;
55
    va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context );
55
    va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context );
Line 56... Line 56...
56
    ASSERT( VA_STATUS_SUCCESS == va_status );
56
    ASSERT( VA_STATUS_SUCCESS == va_status );
57
}
57
}
58
 
58
 
59
void test_unique_buffers(VABufferID *buffer_list, int buffer_count)
59
void test_unique_buffers(VABufferID *buffer_list, int buffer_count)
60
{
60
{
61
    int i,j;
61
    int i,j;
62
    
62
 
63
    for(i = 0; i < buffer_count; i++)
63
    for(i = 0; i < buffer_count; i++)
64
    {
64
    {
Line 82... Line 82...
82
  VADeblockingParameterBufferType,
82
  VADeblockingParameterBufferType,
83
};
83
};
Line 84... Line 84...
84
 
84
 
85
unsigned int buffer_sizes[] =
85
unsigned int buffer_sizes[] =
86
{
86
{
87
  sizeof(VAPictureParameterBufferMPEG4), 
87
  sizeof(VAPictureParameterBufferMPEG4),
88
  sizeof(VAIQMatrixBufferH264),
88
  sizeof(VAIQMatrixBufferH264),
89
  32*1024,
89
  32*1024,
90
  48*1024,
90
  48*1024,
91
  sizeof(VASliceParameterBufferMPEG2),
91
  sizeof(VASliceParameterBufferMPEG2),
Line 110... Line 110...
110
    {
110
    {
111
        uint32_t *data;
111
        uint32_t *data;
Line 112... Line 112...
112
 
112
 
113
        input_data[i] = malloc(buffer_sizes[i]+4);
113
        input_data[i] = malloc(buffer_sizes[i]+4);
114
        ASSERT(input_data[i]);
114
        ASSERT(input_data[i]);
115
        
115
 
116
        /* Generate input data */
116
        /* Generate input data */
117
        for(j = buffer_sizes[i] / 4; j--;)
117
        for(j = buffer_sizes[i] / 4; j--;)
118
        {
118
        {
119
            input_data[i][j] = random();
119
            input_data[i][j] = 20; //random();
120
        }
120
        }
121
        
121
 
122
        /* Copy to secondary buffer */
122
        /* Copy to secondary buffer */
123
        data = malloc(buffer_sizes[i]);
123
        data = malloc(buffer_sizes[i]);
124
        ASSERT(data);
124
        ASSERT(data);
Line 125... Line 125...
125
        memcpy(data, input_data[i], buffer_sizes[i]);
125
        memcpy(data, input_data[i], buffer_sizes[i]);
126
 
126
 
127
        /* Create buffer and fill with data */
127
        /* Create buffer and fill with data */
128
        va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]);
128
        va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]);
129
        ASSERT( VA_STATUS_SUCCESS == va_status );
129
        ASSERT( VA_STATUS_SUCCESS == va_status );
130
        status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]);
130
        status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]);
131
        
131
 
132
        /* Wipe secondary buffer */
132
        /* Wipe secondary buffer */
133
        memset(data, 0, buffer_sizes[i]);
133
        memset(data, 0, buffer_sizes[i]);
Line 140... Line 140...
140
        /* Fetch VA Buffer */
140
        /* Fetch VA Buffer */
141
        va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data);
141
        va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data);
142
        ASSERT( VA_STATUS_SUCCESS == va_status );
142
        ASSERT( VA_STATUS_SUCCESS == va_status );
143
        status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]);
143
        status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]);
Line 144... Line 144...
144
 
144
 
145
        /* Compare data */        
145
        /* Compare data */
146
        ASSERT( memcmp(input_data[i], data, buffer_sizes[i]) == 0 );
146
        ASSERT( memcmp(input_data[i], data, buffer_sizes[i]) == 0 );
147
    }
147
    }
148
    
148
 
149
    for(i=0; i < NUM_BUFFER_TYPES; i++)
149
    for(i=0; i < NUM_BUFFER_TYPES; i++)
150
    {
150
    {
151
        va_status = vaUnmapBuffer(va_dpy, buffer_ids[i]);
151
        va_status = vaUnmapBuffer(va_dpy, buffer_ids[i]);
Line 152... Line 152...
152
        ASSERT( VA_STATUS_SUCCESS == va_status );
152
        ASSERT( VA_STATUS_SUCCESS == va_status );
153
 
153
 
154
        va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]);
154
        va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]);
155
        ASSERT( VA_STATUS_SUCCESS == va_status );
155
        ASSERT( VA_STATUS_SUCCESS == va_status );
156
        
156
 
157
        free(input_data[i]);
157
        free(input_data[i]);
Line 167... Line 167...
167
    ASSERT( VA_STATUS_SUCCESS == va_status );
167
    ASSERT( VA_STATUS_SUCCESS == va_status );
Line 168... Line 168...
168
 
168
 
169
    status("vaDestroyConfig for config %08x\n", config);
169
    status("vaDestroyConfig for config %08x\n", config);
170
    va_status = vaDestroyConfig( va_dpy, config );
170
    va_status = vaDestroyConfig( va_dpy, config );
171
    ASSERT( VA_STATUS_SUCCESS == va_status );
171
    ASSERT( VA_STATUS_SUCCESS == va_status );
172
    
172
 
173
    va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
173
    va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces);
174
    ASSERT( VA_STATUS_SUCCESS == va_status );
174
    ASSERT( VA_STATUS_SUCCESS == va_status );
175
    
175
 
Line 176... Line 176...
176
    free(surfaces);
176
    free(surfaces);
177
 
177