src/video/SDL_yuv.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. SDL_CreateYUVOverlay
  2. SDL_LockYUVOverlay
  3. SDL_UnlockYUVOverlay
  4. SDL_DisplayYUVOverlay
  5. SDL_FreeYUVOverlay

   1 /*
   2     SDL - Simple DirectMedia Layer
   3     Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
   4 
   5     This library is free software; you can redistribute it and/or
   6     modify it under the terms of the GNU Library General Public
   7     License as published by the Free Software Foundation; either
   8     version 2 of the License, or (at your option) any later version.
   9 
  10     This library is distributed in the hope that it will be useful,
  11     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13     Library General Public License for more details.
  14 
  15     You should have received a copy of the GNU Library General Public
  16     License along with this library; if not, write to the Free
  17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18 
  19     Sam Lantinga
  20     slouken@devolution.com
  21 */
  22 
  23 #ifdef SAVE_RCSID
  24 static char rcsid =
  25  "@(#) $Id: SDL_yuv.c,v 1.1.2.5 2001/02/22 00:21:51 hercules Exp $";
  26 #endif
  27 
  28 /* This is the implementation of the YUV video surface support */
  29 
  30 #include <stdlib.h>
  31 #include <string.h>
  32 
  33 #include "SDL_getenv.h"
  34 #include "SDL_video.h"
  35 #include "SDL_sysvideo.h"
  36 #include "SDL_yuvfuncs.h"
  37 #include "SDL_yuv_sw_c.h"
  38 
  39 
  40 SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
     /* [<][>][^][v][top][bottom][index][help] */
  41                                   SDL_Surface *display)
  42 {
  43         SDL_VideoDevice *video = current_video;
  44         SDL_VideoDevice *this  = current_video;
  45         const char *yuv_hwaccel;
  46         SDL_Overlay *overlay;
  47 
  48         overlay = NULL;
  49 
  50         /* Display directly on video surface, if possible */
  51 #if 0
  52         if ( (display == SDL_PublicSurface) &&
  53              ((SDL_VideoSurface->format->BytesPerPixel == 2) ||
  54               (SDL_VideoSurface->format->BytesPerPixel == 4)) ) {
  55                 display = SDL_VideoSurface;
  56         }
  57 #endif
  58         yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL");
  59         if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
  60              (!yuv_hwaccel || (atoi(yuv_hwaccel) > 0)) ) {
  61                 overlay = video->CreateYUVOverlay(this, w, h, format, display);
  62         }
  63         /* If hardware YUV overlay failed ... */
  64         if ( overlay == NULL ) {
  65                 overlay = SDL_CreateYUV_SW(this, w, h, format, display);
  66         }
  67         return overlay;
  68 }
  69 
  70 int SDL_LockYUVOverlay(SDL_Overlay *overlay)
     /* [<][>][^][v][top][bottom][index][help] */
  71 {
  72         return overlay->hwfuncs->Lock(current_video, overlay);
  73 }
  74 
  75 void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
     /* [<][>][^][v][top][bottom][index][help] */
  76 {
  77         overlay->hwfuncs->Unlock(current_video, overlay);
  78 }
  79 
  80 int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
     /* [<][>][^][v][top][bottom][index][help] */
  81 {
  82         return overlay->hwfuncs->Display(current_video, overlay, dstrect);
  83 }
  84 
  85 void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
     /* [<][>][^][v][top][bottom][index][help] */
  86 {
  87         if ( overlay ) {
  88                 if ( overlay->hwfuncs ) {
  89                         overlay->hwfuncs->FreeHW(current_video, overlay);
  90                 }
  91                 free(overlay);
  92         }
  93 }

/* [<][>][^][v][top][bottom][index][help] */