2008-12-26 03:15:47 +02:00
|
|
|
#ifndef __CVIDEOHANDLER_H__
|
|
|
|
#define __CVIDEOHANDLER_H__
|
2009-06-22 14:12:40 +03:00
|
|
|
#include "../global.h"
|
2008-12-26 03:15:47 +02:00
|
|
|
|
2009-06-20 17:52:20 +03:00
|
|
|
#ifdef _WIN32
|
2009-06-20 04:34:26 +03:00
|
|
|
|
2008-12-26 03:15:47 +02:00
|
|
|
#include <windows.h>
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
struct SDL_Surface;
|
2008-12-26 03:15:47 +02:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
#pragma pack(push,1)
|
|
|
|
struct BINK_STRUCT
|
|
|
|
{
|
|
|
|
si32 width;
|
|
|
|
si32 height;
|
|
|
|
si32 frameCount;
|
|
|
|
si32 currentFrame;
|
|
|
|
si32 lastFrame;
|
|
|
|
si32 FPSMul;
|
|
|
|
si32 FPSDiv;
|
|
|
|
si32 unknown0;
|
|
|
|
ui8 flags;
|
|
|
|
ui8 unknown1[260];
|
|
|
|
si32 CurPlane; // current plane
|
|
|
|
void *plane0; // posi32er to plane 0
|
|
|
|
void *plane1; // posi32er to plane 1
|
|
|
|
si32 unknown2;
|
|
|
|
si32 unknown3;
|
|
|
|
si32 yWidth; // Y plane width
|
|
|
|
si32 yHeight; // Y plane height
|
|
|
|
si32 uvWidth; // U&V plane width
|
|
|
|
si32 uvHeight; // U&V plane height
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
2008-12-26 03:15:47 +02:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
typedef BINK_STRUCT* HBINK;
|
2008-12-26 03:15:47 +02:00
|
|
|
|
|
|
|
class DLLHandler
|
|
|
|
{
|
|
|
|
public:
|
2009-06-23 11:14:49 +03:00
|
|
|
std::string name;
|
2008-12-26 03:15:47 +02:00
|
|
|
HINSTANCE dll;
|
|
|
|
void Instantiate(const char *filename);
|
|
|
|
const char *GetLibExtension();
|
2009-06-23 11:14:49 +03:00
|
|
|
void *FindAddress(const char *symbol);
|
2008-12-26 03:15:47 +02:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
DLLHandler();
|
2009-05-07 20:20:41 +03:00
|
|
|
virtual ~DLLHandler(); //d-tor
|
2008-12-26 03:15:47 +02:00
|
|
|
};
|
2009-06-23 11:14:49 +03:00
|
|
|
|
|
|
|
typedef void*(__stdcall* BinkSetSoundSystem)(void * soundfun, void*);
|
|
|
|
typedef HBINK(__stdcall* BinkOpen)(HANDLE bikfile, int flags);
|
|
|
|
typedef si32(__stdcall* BinkGetPalette)(HBINK);
|
|
|
|
typedef void(__stdcall* BinkNextFrame)(HBINK);
|
|
|
|
typedef void(__stdcall* BinkDoFrame)(HBINK);
|
|
|
|
typedef ui8(__stdcall* BinkWait)(HBINK);
|
|
|
|
typedef si32(__stdcall* BinkCopyToBuffer)(HBINK, void* buffer, int stride, int height, int x, int y, int mode);
|
|
|
|
|
2008-12-26 03:15:47 +02:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
class CBIKHandler : public DLLHandler
|
2008-12-26 03:15:47 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int newmode;
|
|
|
|
HANDLE hBinkFile;
|
|
|
|
HBINK hBink;
|
2009-06-23 11:14:49 +03:00
|
|
|
char * buffer;
|
|
|
|
BinkSetSoundSystem binkSetSoundSystem;
|
|
|
|
BinkOpen binkOpen;
|
|
|
|
BinkGetPalette getPalette;
|
|
|
|
BinkNextFrame binkNextFrame;
|
|
|
|
BinkDoFrame binkDoFrame;
|
|
|
|
BinkCopyToBuffer binkCopyToBuffer;
|
|
|
|
BinkWait binkWait;
|
|
|
|
|
|
|
|
void * waveOutOpen, * binkGetError;
|
2008-12-26 03:15:47 +02:00
|
|
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
CBIKHandler();
|
|
|
|
void open(std::string name);
|
2009-06-23 11:14:49 +03:00
|
|
|
void close();
|
|
|
|
void nextFrame();
|
|
|
|
void show(int x, int y, SDL_Surface *dst);
|
|
|
|
bool wait();
|
2008-12-26 03:15:47 +02:00
|
|
|
};
|
2009-06-20 04:34:26 +03:00
|
|
|
|
2009-06-22 14:12:40 +03:00
|
|
|
//////////SMK Player ///////////////////////////////////////////////////////
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
typedef enum { bmDIB, bmDDB} BitmapHandleType;
|
|
|
|
typedef enum { pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom} PixelFormat;
|
|
|
|
typedef enum {tmAuto, tmFixed} TransparentMode;
|
|
|
|
|
|
|
|
class TBitmap
|
2009-06-22 14:12:40 +03:00
|
|
|
{
|
2009-06-23 11:14:49 +03:00
|
|
|
public:
|
|
|
|
ui32 width;
|
|
|
|
ui32 height;
|
|
|
|
PixelFormat pixelFormat;
|
|
|
|
BitmapHandleType handleType;
|
|
|
|
char* buffer;
|
2009-06-22 14:12:40 +03:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
};
|
2009-06-22 14:12:40 +03:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
struct SmackStruct
|
|
|
|
{
|
|
|
|
si32 version;
|
|
|
|
si32 width;
|
|
|
|
si32 height;
|
|
|
|
si32 frameCount;
|
|
|
|
si32 mspf;
|
|
|
|
ui8 unk1[88];
|
|
|
|
ui8 palette[776];
|
|
|
|
si32 currentFrame; // Starting with 0
|
|
|
|
ui8 unk[56];
|
|
|
|
ui32 fileHandle; // exact type is HANDLE in windows.h
|
2009-06-22 14:12:40 +03:00
|
|
|
};
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
// defines function pointer types
|
|
|
|
typedef SmackStruct* (__stdcall* SmackOpen)(void* , ui32, si32 );
|
2009-06-22 14:12:40 +03:00
|
|
|
typedef int (__stdcall* SmackDoFrame)( SmackStruct * );
|
|
|
|
typedef void (__stdcall * SmackGoto )(SmackStruct *, int frameNumber);
|
|
|
|
typedef void (__stdcall* SmackNextFrame)(SmackStruct*);
|
|
|
|
typedef void (__stdcall* SmackClose)(SmackStruct*);
|
2009-06-23 11:14:49 +03:00
|
|
|
typedef void (__stdcall* SmackToBuffer) (SmackStruct*, int, int, int, int, char *, ui32);
|
2009-06-22 14:12:40 +03:00
|
|
|
typedef bool (__stdcall* SmackWait)(SmackStruct*);
|
|
|
|
typedef void (__stdcall* SmackSoundOnOff) (SmackStruct*, bool);
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
class CSmackPlayer: public DLLHandler
|
2009-06-22 14:12:40 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SmackOpen ptrSmackOpen;
|
|
|
|
SmackDoFrame ptrSmackDoFrame;
|
|
|
|
SmackToBuffer ptrSmackToBuffer;
|
|
|
|
SmackNextFrame ptrSmackNextFrame;
|
|
|
|
SmackWait ptrSmackWait;
|
|
|
|
SmackSoundOnOff ptrSmackSoundOnOff;
|
|
|
|
SmackStruct* data;
|
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
void init();
|
|
|
|
void preparePic(TBitmap &b);
|
|
|
|
TBitmap extractFrame(TBitmap &b);
|
2009-06-22 14:12:40 +03:00
|
|
|
void nextFrame();
|
|
|
|
bool wait();
|
|
|
|
};
|
|
|
|
|
|
|
|
class CVidHandler;
|
|
|
|
|
2009-06-21 16:44:15 +03:00
|
|
|
class CVideoPlayer
|
|
|
|
{
|
2009-06-22 14:12:40 +03:00
|
|
|
private:
|
|
|
|
CVidHandler * vidh; //.vid file handling
|
|
|
|
CSmackPlayer * smkPlayer;
|
2009-06-23 11:14:49 +03:00
|
|
|
|
2009-06-22 14:12:40 +03:00
|
|
|
int frame;
|
|
|
|
int xPos, yPos;
|
|
|
|
char * buffer;
|
|
|
|
char * buf;
|
2009-06-23 11:14:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
std::string fname; //name of current video file (empty if idle)
|
|
|
|
|
2009-06-22 14:12:40 +03:00
|
|
|
public:
|
|
|
|
CVideoPlayer(); //c-tor
|
|
|
|
~CVideoPlayer(); //d-tor
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
bool open(std::string fname, int x, int y); //x, y -> position where animation should be displayed on the screen
|
|
|
|
void close();
|
|
|
|
bool nextFrame(); // display next frame
|
2009-06-21 16:44:15 +03:00
|
|
|
};
|
|
|
|
|
2009-06-20 04:34:26 +03:00
|
|
|
#else
|
|
|
|
|
2009-06-21 16:44:15 +03:00
|
|
|
#include <SDL_video.h>
|
2009-06-20 04:34:26 +03:00
|
|
|
|
|
|
|
typedef struct AVFormatContext AVFormatContext;
|
|
|
|
typedef struct AVCodecContext AVCodecContext;
|
|
|
|
typedef struct AVCodec AVCodec;
|
|
|
|
typedef struct AVFrame AVFrame;
|
|
|
|
struct SwsContext;
|
|
|
|
class CVidHandler;
|
|
|
|
|
|
|
|
class CVideoPlayer
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int stream; // stream index in video
|
|
|
|
AVFormatContext *format;
|
|
|
|
AVCodecContext *codecContext; // codec context for stream
|
|
|
|
AVCodec *codec;
|
|
|
|
AVFrame *frame;
|
|
|
|
struct SwsContext *sws;
|
|
|
|
|
|
|
|
SDL_Overlay *overlay;
|
|
|
|
SDL_Rect pos; // overlay position
|
|
|
|
|
|
|
|
CVidHandler *vidh;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CVideoPlayer();
|
|
|
|
~CVideoPlayer();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
bool open(std::string fname, int x, int y);
|
|
|
|
void close();
|
|
|
|
bool nextFrame(); // display next frame
|
|
|
|
|
|
|
|
const char *data; // video buffer
|
|
|
|
int length; // video size
|
|
|
|
unsigned int offset; // current data offset
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-12-26 03:15:47 +02:00
|
|
|
#endif // __CVIDEOHANDLER_H__
|