1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "../Core/Interface.h"
27 #include "../Core/Video.h"
28 #include "../Core/Audio.h"
29 #include "../Core/Variables.h"
31 #include "mve_player.h"
32 #include "../../includes/ie_types.h"
34 static const char MVESignature
[] = "Interplay MVE File\x1A";
35 static const int MVE_SIGNATURE_LEN
= 19;
37 static Video
*video
= NULL
;
38 static unsigned char g_palette
[768];
39 static int g_truecolor
;
40 static ieDword maxRow
= 0;
41 static ieDword rowCount
= 0;
42 static ieDword frameCount
= 0;
43 static ieDword
*cbAtFrame
= NULL
;
44 static ieDword
*strRef
= NULL
;
46 MVEPlay::MVEPlay(void)
48 video
= core
->GetVideoDriver();
51 MVEPlay::~MVEPlay(void)
55 bool MVEPlay::Open(DataStream
* stream
, bool autoFree
)
57 if (!Resource::Open(stream
,autoFree
))
61 char Signature
[MVE_SIGNATURE_LEN
];
62 str
->Read( Signature
, MVE_SIGNATURE_LEN
);
63 if (memcmp( Signature
, MVESignature
, MVE_SIGNATURE_LEN
) != 0) {
67 str
->Seek( 0, GEM_STREAM_START
);
72 void MVEPlay::CallBackAtFrames(ieDword cnt
, ieDword
*arg
, ieDword
*arg2
)
86 //Start Movie Playback
94 MVEPlayer
player(this);
96 memset( g_palette
, 0, 768 );
99 //core->GetDictionary()->Lookup( "Volume Movie", volume );
100 player
.sound_init( core
->GetAudioDrv()->CanPlay() );
104 video
->InitMovieScreen(w
,h
);
105 player
.video_init(w
, h
);
107 if (!player
.start_playback()) {
108 printf("Failed to decode movie!\n");
112 g_truecolor
= player
.is_truecolour();
114 while (!done
&& player
.next_frame()) {
115 done
= video
->PollMovieEvents();
121 unsigned int MVEPlay::fileRead(void* buf
, unsigned int count
)
125 numread
= str
->Read( buf
, count
);
126 return ( numread
== count
);
129 void MVEPlay::showFrame(unsigned char* buf
, unsigned int bufw
,
130 unsigned int bufh
, unsigned int sx
, unsigned int sy
, unsigned int w
,
131 unsigned int h
, unsigned int dstx
, unsigned int dsty
)
133 ieDword titleref
= 0;
135 if (cbAtFrame
&& strRef
) {
137 if ((rowCount
<maxRow
) && (frameCount
>= cbAtFrame
[rowCount
]) ) {
142 titleref
= strRef
[rowCount
-1];
145 video
->showFrame(buf
,bufw
,bufh
,sx
,sy
,w
,h
,dstx
,dsty
, g_truecolor
, g_palette
, titleref
);
148 void MVEPlay::setPalette(unsigned char* p
, unsigned start
, unsigned count
)
150 //Set color 0 to be black
151 g_palette
[0] = g_palette
[1] = g_palette
[2] = 0;
153 //Set color 255 to be our subtitle color
154 g_palette
[765] = g_palette
[766] = g_palette
[767] = 50;
156 //movie libs palette into our array
157 memcpy( g_palette
+ start
* 3, p
+ start
* 3, count
* 3 );
160 int MVEPlay::setAudioStream()
163 core
->GetDictionary()->Lookup( "Volume Movie", volume
) ;
164 int source
= core
->GetAudioDrv()->SetupNewStream(0, 0, 0, volume
, false, false) ;
168 void MVEPlay::freeAudioStream(int stream
)
171 core
->GetAudioDrv()->ReleaseStream(stream
, true);
174 void MVEPlay::queueBuffer(int stream
, unsigned short bits
,
175 int channels
, short* memory
,
176 int size
, int samplerate
)
179 core
->GetAudioDrv()->QueueBuffer(stream
, bits
, channels
, memory
, size
, samplerate
) ;
183 #include "../../includes/plugindef.h"
185 GEMRB_PLUGIN(0x218963DC, "MVE Video Player")
186 PLUGIN_IE_RESOURCE(&MoviePlayer::ID
, MVEPlay
, ".mve", (ieWord
)IE_MVE_CLASS_ID
)