17ec681f3Smrg/**************************************************************************
27ec681f3Smrg *
37ec681f3Smrg * Copyright 2009 Younes Manton.
47ec681f3Smrg * All Rights Reserved.
57ec681f3Smrg *
67ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77ec681f3Smrg * copy of this software and associated documentation files (the
87ec681f3Smrg * "Software"), to deal in the Software without restriction, including
97ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish,
107ec681f3Smrg * distribute, sub license, and/or sell copies of the Software, and to
117ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to
127ec681f3Smrg * the following conditions:
137ec681f3Smrg *
147ec681f3Smrg * The above copyright notice and this permission notice (including the
157ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions
167ec681f3Smrg * of the Software.
177ec681f3Smrg *
187ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
197ec681f3Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
207ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
217ec681f3Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
227ec681f3Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
237ec681f3Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
247ec681f3Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
257ec681f3Smrg *
267ec681f3Smrg **************************************************************************/
277ec681f3Smrg
287ec681f3Smrg#include <assert.h>
297ec681f3Smrg
307ec681f3Smrg#include <X11/Xlib.h>
317ec681f3Smrg#include <X11/extensions/XvMClib.h>
327ec681f3Smrg
337ec681f3Smrg#include "util/u_memory.h"
347ec681f3Smrg
357ec681f3Smrg#include "xvmc_private.h"
367ec681f3Smrg
377ec681f3SmrgPUBLIC
387ec681f3SmrgStatus XvMCCreateBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCBlockArray *blocks)
397ec681f3Smrg{
407ec681f3Smrg   assert(dpy);
417ec681f3Smrg
427ec681f3Smrg   if (!context)
437ec681f3Smrg      return XvMCBadContext;
447ec681f3Smrg   if (num_blocks == 0)
457ec681f3Smrg      return BadValue;
467ec681f3Smrg
477ec681f3Smrg   assert(blocks);
487ec681f3Smrg
497ec681f3Smrg   blocks->context_id = context->context_id;
507ec681f3Smrg   blocks->num_blocks = num_blocks;
517ec681f3Smrg   blocks->blocks = MALLOC(BLOCK_SIZE_BYTES * num_blocks);
527ec681f3Smrg   blocks->privData = NULL;
537ec681f3Smrg
547ec681f3Smrg   return Success;
557ec681f3Smrg}
567ec681f3Smrg
577ec681f3SmrgPUBLIC
587ec681f3SmrgStatus XvMCDestroyBlocks(Display *dpy, XvMCBlockArray *blocks)
597ec681f3Smrg{
607ec681f3Smrg   assert(dpy);
617ec681f3Smrg   assert(blocks);
627ec681f3Smrg   FREE(blocks->blocks);
637ec681f3Smrg
647ec681f3Smrg   return Success;
657ec681f3Smrg}
667ec681f3Smrg
677ec681f3SmrgPUBLIC
687ec681f3SmrgStatus XvMCCreateMacroBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCMacroBlockArray *blocks)
697ec681f3Smrg{
707ec681f3Smrg   assert(dpy);
717ec681f3Smrg
727ec681f3Smrg   if (!context)
737ec681f3Smrg      return XvMCBadContext;
747ec681f3Smrg   if (num_blocks == 0)
757ec681f3Smrg      return BadValue;
767ec681f3Smrg
777ec681f3Smrg   assert(blocks);
787ec681f3Smrg
797ec681f3Smrg   blocks->context_id = context->context_id;
807ec681f3Smrg   blocks->num_blocks = num_blocks;
817ec681f3Smrg   blocks->macro_blocks = MALLOC(sizeof(XvMCMacroBlock) * num_blocks);
827ec681f3Smrg   blocks->privData = NULL;
837ec681f3Smrg
847ec681f3Smrg   return Success;
857ec681f3Smrg}
867ec681f3Smrg
877ec681f3SmrgPUBLIC
887ec681f3SmrgStatus XvMCDestroyMacroBlocks(Display *dpy, XvMCMacroBlockArray *blocks)
897ec681f3Smrg{
907ec681f3Smrg   assert(dpy);
917ec681f3Smrg   assert(blocks);
927ec681f3Smrg   FREE(blocks->macro_blocks);
937ec681f3Smrg
947ec681f3Smrg   return Success;
957ec681f3Smrg}
96