Removing unnecessary SDL driver from video player.

All SDL-specific code moved to tfb_draw system.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1260 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2003-09-23 23:10:13 +00:00
parent 63e22090d2
commit 4af483c6af
13 changed files with 112 additions and 129 deletions
-12
View File
@@ -711,18 +711,6 @@ SOURCE=..\sc2code\libs\strings\strintrn.h
# Begin Group "video"
# PROP Default_Filter ""
# Begin Group "sdl video"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\sc2code\libs\video\sdl\sdlvideo.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\video\sdl\sdlvideo.h
# End Source File
# End Group
# Begin Source File
SOURCE=..\sc2code\libs\video\vfileins.c
+66 -1
View File
@@ -147,7 +147,8 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
UnlockMutex (img->mutex);
}
TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
TFB_Canvas
TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
{
SDL_Surface *new_surf;
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, hasalpha ? 0xff000000 : 0);
@@ -158,6 +159,37 @@ TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
return new_surf;
}
TFB_Canvas
TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha)
{
SDL_Surface *new_surf;
SDL_PixelFormat* fmt = SDL_Screen->format;
if (fmt->palette)
{
fprintf(stderr, "TFB_DrawCanvas_New_ForScreen() WARNING:"
"Paletted display format will be slow");
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
32, 0x000000ff, 0x0000ff00, 0x00ff0000,
withalpha ? 0xff000000 : 0);
}
else
{
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask,
withalpha ? fmt->Amask : 0);
}
if (!new_surf)
{
fprintf(stderr, "TFB_DrawCanvas_New_ForScreen() INTERNAL PANIC:"
"Failed to create TFB_Canvas: %s", SDL_GetError());
exit (-1);
}
return new_surf;
}
TFB_Canvas
TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index)
{
@@ -864,3 +896,36 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas, TFB_Canvas dest_canvas,
src->format->BitsPerPixel, dst->format->BitsPerPixel, mipmap->format->BitsPerPixel);
}
}
void
TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt)
{
SDL_PixelFormat *sdl = SDL_Screen->format;
if (sdl->palette)
{
fprintf(stderr, "TFB_DrawCanvas_GetScreenFormat() WARNING:"
"Paletted display format will be slow");
fmt->BitsPerPixel = 32;
fmt->Rmask = 0x000000ff;
fmt->Gmask = 0x0000ff00;
fmt->Bmask = 0x00ff0000;
fmt->Amask = 0xff000000;
}
else
{
fmt->BitsPerPixel = sdl->BitsPerPixel;
fmt->Rmask = sdl->Rmask;
fmt->Gmask = sdl->Gmask;
fmt->Bmask = sdl->Bmask;
fmt->Amask = sdl->Amask;
}
}
void*
TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line)
{
SDL_Surface* surf = (SDL_Surface *)canvas;
return (uint8*)surf->pixels + surf->pitch * line;
}
+16
View File
@@ -268,6 +268,22 @@ TFB_DrawImage_New (TFB_Canvas canvas)
return img;
}
TFB_Image*
TFB_DrawImage_CreateForScreen (int w, int h, BOOLEAN withalpha)
{
TFB_Image* img = HMalloc (sizeof (TFB_Image));
img->mutex = CreateMutex ("image lock", SYNC_CLASS_VIDEO);
img->ScaledImg = NULL;
img->MipmapImg = NULL;
img->colormap_index = -1;
img->last_scale_type = -1;
img->Palette = NULL;
img->NormalImg = TFB_DrawCanvas_New_ForScreen (w, h, withalpha);
return img;
}
void
TFB_DrawImage_Delete (TFB_Image *image)
{
+13
View File
@@ -57,6 +57,15 @@ typedef struct tfb_image
BOOLEAN dirty;
} TFB_Image;
// we do not support paletted format for now
typedef struct tfb_pixelformat
{
int BitsPerPixel;
int BytesPerPixel;
DWORD Rmask, Gmask, Bmask, Amask;
DWORD Rshift, Gshift, Bshift, Ashift;
DWORD Rloss, Gloss, Bloss, Aloss;
} TFB_PixelFormat;
// Drawing commands
@@ -72,6 +81,7 @@ void TFB_DrawScreen_SetPalette (int paletteIndex, int r, int g, int b);
void TFB_FlushPaletteCache (void);
TFB_Image *TFB_DrawImage_New (TFB_Canvas canvas);
TFB_Image *TFB_DrawImage_CreateForScreen (int w, int h, BOOLEAN withalpha);
void TFB_DrawImage_Delete (TFB_Image *image);
void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type);
@@ -81,6 +91,7 @@ void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *
void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target);
TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha);
TFB_Canvas TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha);
TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index);
TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, TFB_Canvas oldcanvas, int type, int last_type);
TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas);
@@ -102,5 +113,7 @@ int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas);
void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, BOOLEAN rleaccel);
void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, BOOLEAN rleaccel);
void TFB_DrawCanvas_Initialize (void);
void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt);
void* TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line);
#endif
-1
View File
@@ -1,2 +1 @@
uqm_CFILES="vfileins.c video.c videodec.c vidplayer.c dukvid.c"
uqm_SUBDIRS="sdl"
+4 -4
View File
@@ -14,7 +14,7 @@
#define _THIS TFB_VideoDecoder* This
int dukv_GetError (_THIS);
bool dukv_Init (_THIS, TFB_VideoFormat* fmt);
bool dukv_Init (_THIS, TFB_PixelFormat* fmt);
void dukv_Term (_THIS);
bool dukv_Open (_THIS, uio_DirHandle *dir, const char *filename);
void dukv_Close (_THIS);
@@ -412,7 +412,7 @@ dukv_InitDeltas (TFB_DuckVideo* dukv, uint8* vectors, sint32* pl, sint32* pc)
}
__inline__ uint32
dukv_PixelConv (uint16 pix, const TFB_VideoFormat* fmt)
dukv_PixelConv (uint16 pix, const TFB_PixelFormat* fmt)
{
uint32 r, g, b;
@@ -430,7 +430,7 @@ void
dukv_RenderFrame (_THIS)
{
TFB_DuckVideo* dukv = This->dec_data;
const TFB_VideoFormat* fmt = This->format;
const TFB_PixelFormat* fmt = This->format;
uint32 h, x, y;
uint32* dec = dukv->decbuf;
@@ -508,7 +508,7 @@ int dukv_GetError (_THIS)
}
bool
dukv_Init (_THIS, TFB_VideoFormat* fmt)
dukv_Init (_THIS, TFB_PixelFormat* fmt)
{
This->format = fmt;
This->audio_synced = 1;
-1
View File
@@ -1 +0,0 @@
uqm_CFILES="sdlvideo.c"
-58
View File
@@ -1,58 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/video/video.h"
#include "sdlvideo.h"
void
TFB_GetScreenFormat (TFB_VideoFormat *fmt)
{
SDL_PixelFormat *sdl = SDL_Video->format;
fmt->BitsPerPixel = sdl->BitsPerPixel;
fmt->Rmask = sdl->Rmask;
fmt->Gmask = sdl->Gmask;
fmt->Bmask = sdl->Bmask;
fmt->Amask = 0; // no alpha support for now
}
TFB_Image*
TFB_CreateVideoImage (int w, int h)
{
TFB_Image* img;
SDL_PixelFormat* fmt = SDL_Video->format;
img = HMalloc (sizeof (TFB_Image));
img->mutex = CreateMutex ("vid image lock", SYNC_CLASS_VIDEO);
img->ScaledImg = NULL;
img->MipmapImg = NULL;
img->colormap_index = -1;
img->last_scale_type = -1;
img->Palette = NULL;
img->NormalImg = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask, 0);
return img;
}
void*
TFB_GetVideoLine (TFB_Image* img, uint32 line)
{
SDL_Surface* surf = img->NormalImg;
return (uint8*)surf->pixels + surf->pitch * line;
}
-28
View File
@@ -1,28 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SDLVIDEO_H
#define _SDLVIDEO_H
#include "libs/graphics/gfx_common.h"
#include "libs/graphics/tfb_draw.h"
#include "libs/gfxlib.h"
void TFB_GetScreenFormat (TFB_VideoFormat *fmt);
TFB_Image* TFB_CreateVideoImage (int w, int h);
void* TFB_GetVideoLine (TFB_Image* img, uint32 line);
#endif // _SDLVIDEO_H
+3 -4
View File
@@ -17,7 +17,6 @@
*/
#include "video.h"
#include "sdl/sdlvideo.h"
#include "vidplayer.h"
#define NULL_VIDEO_REF (0)
@@ -27,11 +26,11 @@ BOOLEAN
InitVideo (BOOLEAN useCDROM)
//useCDROM doesn't really apply to us
{
TFB_VideoFormat fmt;
TFB_PixelFormat fmt;
TFB_GetScreenFormat (&fmt);
TFB_DrawCanvas_GetScreenFormat (&fmt);
if (!VideoDecoder_Init (0, fmt.BitsPerPixel, fmt.Rmask,
fmt.Gmask, fmt.Bmask, fmt.Amask))
fmt.Gmask, fmt.Bmask, 0))
return FALSE;
return TFB_InitVideoPlayer ();
+3 -3
View File
@@ -19,7 +19,7 @@
#include "dukvid.h"
static bool vd_inited = 0;
static TFB_VideoFormat vd_vidfmt;
static TFB_PixelFormat vd_vidfmt;
static struct vd_DecoderInfo
{
@@ -33,7 +33,7 @@ vd_decoders[] =
{NULL, NULL, NULL} // null term
};
static void vd_computeMasks (uint32 mask, uint32* shift, uint32* loss);
static void vd_computeMasks (uint32 mask, DWORD* shift, DWORD* loss);
bool
VideoDecoder_Init (int flags, int depth, uint32 Rmask, uint32 Gmask,
@@ -208,7 +208,7 @@ VideoDecoder_Free (TFB_VideoDecoder *decoder)
// BEGIN: adapted from SDL
static void
vd_computeMasks (uint32 mask, uint32* shift, uint32* loss)
vd_computeMasks (uint32 mask, DWORD* shift, DWORD* loss)
{
*shift = 0;
*loss = 8;
+2 -13
View File
@@ -24,23 +24,12 @@
// forward-declare
typedef struct tfb_videodecoder TFB_VideoDecoder;
// we do not support paletted format for now
typedef struct tfb_videoformat
{
uint32 BitsPerPixel;
uint32 BytesPerPixel;
uint32 Rmask, Gmask, Bmask, Amask;
uint32 Rshift, Gshift, Bshift, Ashift;
uint32 Rloss, Gloss, Bloss, Aloss;
} TFB_VideoFormat;
#define _THIS TFB_VideoDecoder*
typedef struct tfb_videodecoderfunc
{
int (* GetError) (_THIS);
bool (* Init) (_THIS, TFB_VideoFormat* fmt);
bool (* Init) (_THIS, TFB_PixelFormat* fmt);
void (* Term) (_THIS);
bool (* Open) (_THIS, uio_DirHandle *dir, const char *filename);
void (* Close) (_THIS);
@@ -74,7 +63,7 @@ struct tfb_videodecoder
// decoder virtual funcs - R/O
const TFB_VideoDecoderFuncs *funcs;
// video formats - R/O
const TFB_VideoFormat *format;
const TFB_PixelFormat *format;
// decoder-set data - R/O
uint32 w, h;
float length; // total length in seconds
+5 -4
View File
@@ -14,8 +14,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "libs/graphics/gfx_common.h"
#include "libs/graphics/tfb_draw.h"
#include "vidplayer.h"
#include "sdl/sdlvideo.h"
// video callbacks
static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line);
@@ -46,7 +47,7 @@ static TFB_SoundCallbacks vp_AudioCBs =
// inter-thread param guarded by mutex
static Semaphore vp_interthread_lock = 0;
void* vp_interthread_clip = NULL;
static void* vp_interthread_clip = NULL;
typedef struct
{
@@ -304,7 +305,7 @@ TFB_PlayVideo (VIDEO_REF VidRef, uint32 x, uint32 y)
vid->decoder->callbacks = vp_DecoderCBs;
vid->decoder->data = vid;
vid->frame = TFB_CreateVideoImage (vid->w, vid->h);
vid->frame = TFB_DrawImage_CreateForScreen (vid->w, vid->h, FALSE);
vid->cur_frame = -1;
vid->want_frame = -1;
@@ -455,7 +456,7 @@ vp_GetCanvasLine (TFB_VideoDecoder* decoder, uint32 line)
if (!vid)
return NULL;
return TFB_GetVideoLine (vid->frame, line);
return TFB_DrawCanvas_GetLine (vid->frame->NormalImg, line);
}
static uint32