162074f44bb5944593b65d6203deae6300bead42dYounes Manton/************************************************************************** 2dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König * 362074f44bb5944593b65d6203deae6300bead42dYounes Manton * Copyright 2009 Younes Manton. 462074f44bb5944593b65d6203deae6300bead42dYounes Manton * All Rights Reserved. 5dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König * 662074f44bb5944593b65d6203deae6300bead42dYounes Manton * Permission is hereby granted, free of charge, to any person obtaining a 762074f44bb5944593b65d6203deae6300bead42dYounes Manton * copy of this software and associated documentation files (the 862074f44bb5944593b65d6203deae6300bead42dYounes Manton * "Software"), to deal in the Software without restriction, including 962074f44bb5944593b65d6203deae6300bead42dYounes Manton * without limitation the rights to use, copy, modify, merge, publish, 1062074f44bb5944593b65d6203deae6300bead42dYounes Manton * distribute, sub license, and/or sell copies of the Software, and to 1162074f44bb5944593b65d6203deae6300bead42dYounes Manton * permit persons to whom the Software is furnished to do so, subject to 1262074f44bb5944593b65d6203deae6300bead42dYounes Manton * the following conditions: 13dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König * 1462074f44bb5944593b65d6203deae6300bead42dYounes Manton * The above copyright notice and this permission notice (including the 1562074f44bb5944593b65d6203deae6300bead42dYounes Manton * next paragraph) shall be included in all copies or substantial portions 1662074f44bb5944593b65d6203deae6300bead42dYounes Manton * of the Software. 17dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König * 1862074f44bb5944593b65d6203deae6300bead42dYounes Manton * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1962074f44bb5944593b65d6203deae6300bead42dYounes Manton * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2062074f44bb5944593b65d6203deae6300bead42dYounes Manton * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2162074f44bb5944593b65d6203deae6300bead42dYounes Manton * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 2262074f44bb5944593b65d6203deae6300bead42dYounes Manton * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 2362074f44bb5944593b65d6203deae6300bead42dYounes Manton * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 2462074f44bb5944593b65d6203deae6300bead42dYounes Manton * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König * 2662074f44bb5944593b65d6203deae6300bead42dYounes Manton **************************************************************************/ 2762074f44bb5944593b65d6203deae6300bead42dYounes Manton 2862074f44bb5944593b65d6203deae6300bead42dYounes Manton#include <assert.h> 2962074f44bb5944593b65d6203deae6300bead42dYounes Manton#include <error.h> 3062074f44bb5944593b65d6203deae6300bead42dYounes Manton#include "testlib.h" 3162074f44bb5944593b65d6203deae6300bead42dYounes Manton 3262074f44bb5944593b65d6203deae6300bead42dYounes Mantonint main(int argc, char **argv) 3362074f44bb5944593b65d6203deae6300bead42dYounes Manton{ 3462074f44bb5944593b65d6203deae6300bead42dYounes Manton const unsigned int width = 16, height = 16; 3562074f44bb5944593b65d6203deae6300bead42dYounes Manton const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2}; 3662074f44bb5944593b65d6203deae6300bead42dYounes Manton 3762074f44bb5944593b65d6203deae6300bead42dYounes Manton Display *display; 3862074f44bb5944593b65d6203deae6300bead42dYounes Manton XvPortID port_num; 3962074f44bb5944593b65d6203deae6300bead42dYounes Manton int surface_type_id; 4062074f44bb5944593b65d6203deae6300bead42dYounes Manton unsigned int is_overlay, intra_unsigned; 4162074f44bb5944593b65d6203deae6300bead42dYounes Manton int colorkey; 4262074f44bb5944593b65d6203deae6300bead42dYounes Manton XvMCContext context; 4362074f44bb5944593b65d6203deae6300bead42dYounes Manton XvMCSurface surface = {0}; 4462074f44bb5944593b65d6203deae6300bead42dYounes Manton 4562074f44bb5944593b65d6203deae6300bead42dYounes Manton display = XOpenDisplay(NULL); 4662074f44bb5944593b65d6203deae6300bead42dYounes Manton 4762074f44bb5944593b65d6203deae6300bead42dYounes Manton if (!GetPort 4862074f44bb5944593b65d6203deae6300bead42dYounes Manton ( 4962074f44bb5944593b65d6203deae6300bead42dYounes Manton display, 5062074f44bb5944593b65d6203deae6300bead42dYounes Manton width, 5162074f44bb5944593b65d6203deae6300bead42dYounes Manton height, 5262074f44bb5944593b65d6203deae6300bead42dYounes Manton XVMC_CHROMA_FORMAT_420, 53dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König mc_types, 54dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König 2, 55dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König &port_num, 56dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König &surface_type_id, 57dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König &is_overlay, 58dcf8ee7d6ac89bb2a9d608618a51604a3c78fe96Christian König &intra_unsigned 5962074f44bb5944593b65d6203deae6300bead42dYounes Manton )) 6062074f44bb5944593b65d6203deae6300bead42dYounes Manton { 6162074f44bb5944593b65d6203deae6300bead42dYounes Manton XCloseDisplay(display); 6262074f44bb5944593b65d6203deae6300bead42dYounes Manton error(1, 0, "Error, unable to find a good port.\n"); 6362074f44bb5944593b65d6203deae6300bead42dYounes Manton } 6462074f44bb5944593b65d6203deae6300bead42dYounes Manton 6562074f44bb5944593b65d6203deae6300bead42dYounes Manton if (is_overlay) 6662074f44bb5944593b65d6203deae6300bead42dYounes Manton { 6762074f44bb5944593b65d6203deae6300bead42dYounes Manton Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0); 6862074f44bb5944593b65d6203deae6300bead42dYounes Manton XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey); 6962074f44bb5944593b65d6203deae6300bead42dYounes Manton } 7062074f44bb5944593b65d6203deae6300bead42dYounes Manton 7162074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success); 7262074f44bb5944593b65d6203deae6300bead42dYounes Manton 7362074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test NULL context */ 7462074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCCreateSurface(display, NULL, &surface) == XvMCBadContext); 7562074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test NULL surface */ 7662074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCCreateSurface(display, &context, NULL) == XvMCBadSurface); 7762074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test valid params */ 7862074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCCreateSurface(display, &context, &surface) == Success); 7962074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test surface id assigned */ 8062074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(surface.surface_id != 0); 8162074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test context id assigned and correct */ 8262074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(surface.context_id == context.context_id); 8362074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test surface type id assigned and correct */ 8462074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(surface.surface_type_id == surface_type_id); 8562074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test width & height assigned and correct */ 8662074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(surface.width == width && surface.height == height); 8762074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test valid params */ 8862074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCDestroySurface(display, &surface) == Success); 8962074f44bb5944593b65d6203deae6300bead42dYounes Manton /* Test NULL surface */ 9062074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCDestroySurface(display, NULL) == XvMCBadSurface); 9162074f44bb5944593b65d6203deae6300bead42dYounes Manton 9262074f44bb5944593b65d6203deae6300bead42dYounes Manton assert(XvMCDestroyContext(display, &context) == Success); 9362074f44bb5944593b65d6203deae6300bead42dYounes Manton 9462074f44bb5944593b65d6203deae6300bead42dYounes Manton XvUngrabPort(display, port_num, CurrentTime); 9562074f44bb5944593b65d6203deae6300bead42dYounes Manton XCloseDisplay(display); 9662074f44bb5944593b65d6203deae6300bead42dYounes Manton 9762074f44bb5944593b65d6203deae6300bead42dYounes Manton return 0; 9862074f44bb5944593b65d6203deae6300bead42dYounes Manton} 99