Home | History | Annotate | Download | only in basic
      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 destory surfaces"
     26 
     27 #include "test_common.c"
     28 
     29 void pre()
     30 {
     31     test_init();
     32 }
     33 
     34 #define DEAD_SURFACE_ID 	(VASurfaceID) 0xbeefdead
     35 
     36 void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2)
     37 {
     38     int i,j;
     39 
     40     for(i = 0; i < surface_count1; i++)
     41     {
     42         for(j = 0; j < surface_count2; j++)
     43         {
     44             if ((surface_list1 == surface_list2) && (i == j)) continue;
     45             ASSERT(surface_list1[i] != VA_INVALID_SURFACE);
     46             ASSERT(surface_list2[j] != VA_INVALID_SURFACE);
     47             ASSERT(surface_list1[i] != surface_list2[j]);
     48         }
     49     }
     50 }
     51 
     52 
     53 void test()
     54 {
     55     VASurfaceID surfaces_1[1+1];
     56     VASurfaceID surfaces_4[4+1];
     57     VASurfaceID surfaces_16[16+1];
     58     VASurfaceID surfaces_6[6+1];
     59 
     60     memset(surfaces_1, 0xff, sizeof(surfaces_1));
     61     memset(surfaces_4, 0xff, sizeof(surfaces_4));
     62     memset(surfaces_16, 0xff, sizeof(surfaces_16));
     63     memset(surfaces_6, 0xff, sizeof(surfaces_6));
     64 
     65     status("vaCreateSurfaces 1 surface\n");
     66     surfaces_1[1] = DEAD_SURFACE_ID;
     67     va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_1, 1, NULL, 0);
     68     ASSERT( VA_STATUS_SUCCESS == va_status );
     69     ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */
     70 
     71     status("vaCreateSurfaces 4 surfaces\n");
     72     surfaces_4[4] = DEAD_SURFACE_ID;
     73     va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_4, 4, NULL, 0);
     74     ASSERT( VA_STATUS_SUCCESS == va_status );
     75     ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */
     76 
     77     status("vaCreateSurfaces 16 surfaces\n");
     78     surfaces_16[16] = DEAD_SURFACE_ID;
     79     va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_16, 16, NULL, 0);
     80     ASSERT( VA_STATUS_SUCCESS == va_status );
     81     ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */
     82 
     83     test_unique_surfaces(surfaces_1, 1, surfaces_4, 4);
     84     test_unique_surfaces(surfaces_4, 4, surfaces_16, 4);
     85     test_unique_surfaces(surfaces_4, 4, surfaces_16, 16);
     86     test_unique_surfaces(surfaces_4, 1, surfaces_16, 16);
     87     test_unique_surfaces(surfaces_1, 16, surfaces_16, 16);
     88 
     89     status("vaDestroySurface 4 surfaces\n");
     90     va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4);
     91     ASSERT( VA_STATUS_SUCCESS == va_status );
     92 
     93     status("vaCreateSurfaces 6 surfaces\n");
     94     surfaces_6[6] = DEAD_SURFACE_ID;
     95     va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_6, 6, NULL, 0);
     96     ASSERT( VA_STATUS_SUCCESS == va_status );
     97     ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */
     98 
     99     test_unique_surfaces(surfaces_1, 1, surfaces_6, 6);
    100     test_unique_surfaces(surfaces_6, 6, surfaces_16, 16);
    101     test_unique_surfaces(surfaces_1, 6, surfaces_16, 6);
    102 
    103     status("vaDestroySurface 16 surfaces\n");
    104     va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16);
    105     ASSERT( VA_STATUS_SUCCESS == va_status );
    106 
    107     status("vaDestroySurface 1 surface\n");
    108     va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1);
    109     ASSERT( VA_STATUS_SUCCESS == va_status );
    110 
    111     status("vaDestroySurface 6 surfaces\n");
    112     va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6);
    113     ASSERT( VA_STATUS_SUCCESS == va_status );
    114 }
    115 
    116 void post()
    117 {
    118     test_terminate();
    119 }
    120