Mercurial > mm7
annotate VideoPlayer.cpp @ 2429:6d5877899730
* -novideo disables shop videos
* replaced bicubic resampling for linear
author | a.parshin |
---|---|
date | Wed, 23 Jul 2014 19:42:39 +0300 |
parents | d922225a6081 |
children | cb66a1082fcf |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2223
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 |
2336 | 7 #include "mm7_unsorted_subs.h" |
0 | 8 #include "Bink_Smacker.h" |
9 | |
1262 | 10 #include "mm7_data.h" |
1016 | 11 #include "CShow.h" |
12 #include "Mouse.h" | |
13 | |
0 | 14 #include "VideoPlayer.h" |
2345 | 15 #include "MediaPlayer.h" |
0 | 16 #include "AudioPlayer.h" |
17 #include "Game.h" | |
18 #include "Render.h" | |
19 #include "Party.h" | |
20 #include "GUIWindow.h" | |
2044 | 21 #include "Timer.h" |
0 | 22 #include "Log.h" |
1253 | 23 #include "texts.h" |
1299 | 24 #include "UI\UIHouses.h" |
0 | 25 |
26 VideoPlayer *pVideoPlayer = nullptr; | |
27 | |
2347 | 28 #pragma comment(lib, "Version.lib") |
0 | 29 bool GetDllVersion(const wchar_t *pDllName, uint *pMajor, uint *pMinor) |
30 { | |
31 uint uVersionSize = GetFileVersionInfoSizeW(pDllName, nullptr); | |
32 void *pVersionData = HeapAlloc(GetProcessHeap(), 0, uVersionSize); | |
33 { | |
34 GetFileVersionInfoW(pDllName, 0, uVersionSize, pVersionData); | |
35 | |
36 VS_FIXEDFILEINFO *pInfo = nullptr; | |
37 UINT uInfoSize = 0; | |
38 VerQueryValueW(pVersionData, L"\\", (void **)&pInfo, &uInfoSize); | |
39 | |
40 if (!pMajor || !pMinor) | |
41 { | |
42 HeapFree(GetProcessHeap(), 0, pVersionData); | |
43 return false; | |
44 } | |
45 *pMajor = pInfo->dwFileVersionMS; | |
46 *pMinor = pInfo->dwFileVersionLS; | |
47 } | |
48 HeapFree(GetProcessHeap(), 0, pVersionData); | |
49 return true; | |
50 } | |
51 | |
52 //----- (004BF794) -------------------------------------------------------- | |
2290 | 53 void ShowMM7IntroVideo_and_LoadingScreen() |
0 | 54 { |
55 RGBTexture tex; // [sp+Ch] [bp-30h]@1 | |
2290 | 56 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 |
57 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 | |
0 | 58 |
59 pVideoPlayer->bStopBeforeSchedule = false; | |
165 | 60 pVideoPlayer->pResetflag = 0; |
2290 | 61 bGameoverLoop = true; |
256 | 62 if (!bNoVideo) |
0 | 63 { |
64 pRenderer->PresentBlackScreen(); | |
65 if ( !pVideoPlayer->bStopBeforeSchedule ) | |
2290 | 66 PlayFullscreenMovie(MOVIE_Intro, true); |
0 | 67 } |
2334 | 68 // char pContainerName[64]; |
2278 | 69 |
2290 | 70 tex.Load("mm6title.pcx", 2); |
0 | 71 pRenderer->BeginScene(); |
72 pRenderer->DrawTextureRGB(0, 0, &tex); | |
73 free(tex.pPixels); | |
74 tex.pPixels = 0; | |
762 | 75 |
2290 | 76 //LoadFonts_and_DrawCopyrightWindow(); |
77 DrawMM7CopyrightWindow(); | |
762 | 78 |
0 | 79 pRenderer->EndScene(); |
80 pRenderer->Present(); | |
1004 | 81 |
82 #ifndef _DEBUG | |
83 Sleep(1500); // let the copyright window stay for a while | |
84 #endif | |
85 | |
2290 | 86 if (!bNoSound && pAudioPlayer->hAILRedbook ) |
0 | 87 { |
88 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); | |
89 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
2218 | 90 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); |
0 | 91 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
2290 | 92 } |
93 bGameoverLoop = false; | |
0 | 94 } |
95 | |
96 //----- (004BE70E) -------------------------------------------------------- | |
1802 | 97 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
0 | 98 { |
99 int v4; // ebp@1 | |
100 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | |
2218 | 101 |
0 | 102 v4 = a2; |
2061 | 103 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
0 | 104 { |
105 if ( a2 == 2 ) | |
106 v4 = 0; | |
2347 | 107 ShowCursor(0);//Убрать курсор |
108 OpenGlobalMovie(pMovieName, 0, ScreenSizeFlag); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
109 bPlayingMovie = 1; |
2218 | 110 field_44 = v4; |
2347 | 111 pRenderer->ClearTarget(0); |
151 | 112 pCurrentScreen = SCREEN_VIDEO; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
113 |
2218 | 114 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
115 RECT rc_client; | |
116 GetClientRect(hwnd, &rc_client); | |
117 int client_width = rc_client.right - rc_client.left, | |
118 client_height = rc_client.bottom - rc_client.top; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
119 |
2218 | 120 HDC dc = GetDC(hwnd); |
121 HDC back_dc = CreateCompatibleDC(dc); | |
2418 | 122 HBITMAP back_bmp = CreateCompatibleBitmap(dc, client_width, client_height); |
123 SelectObject(back_dc, back_bmp); | |
2347 | 124 |
125 DWORD t = GetTickCount();//текущее время от запуска ОС | |
126 | |
127 end_current_file = false;//установить флаг конца видеоролика | |
128 | |
129 while (true) //Цикл воспроизведения видеоролика | |
2218 | 130 { |
131 if ( pVideoPlayer->bStopBeforeSchedule ) | |
132 break; | |
133 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
134 { | |
135 if (Msg.message == 18) | |
136 Game_DeinitializeAndTerminate(0); | |
137 if (Msg.message == 15) | |
138 break; | |
139 TranslateMessage(&Msg); | |
140 DispatchMessageA(&Msg); | |
141 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
142 |
2347 | 143 double dt = (GetTickCount() - t) / 1000.0; //изменение времени |
2345 | 144 //dt = 1.0/15.0; |
145 t = GetTickCount(); | |
146 | |
147 //log("dt=%.5f\n", dt); | |
148 | |
149 auto image = new char[client_width * client_height * 4]; | |
150 | |
2394 | 151 pMovie_Track->GetNextFrame(dt, image); //получить следующий кадр |
2347 | 152 |
153 if (end_current_file)//достигнут ли конец видео? | |
2218 | 154 break; |
2347 | 155 |
2218 | 156 if (image) |
157 { | |
158 // draw to hwnd | |
159 BITMAPINFO bmi; | |
160 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
161 bmi.bmiHeader.biWidth = client_width; | |
162 bmi.bmiHeader.biHeight = -client_height; | |
163 bmi.bmiHeader.biPlanes = 1; | |
164 bmi.bmiHeader.biBitCount = 32; | |
165 bmi.bmiHeader.biCompression = BI_RGB; | |
166 bmi.bmiHeader.biSizeImage = 0; | |
167 bmi.bmiHeader.biXPelsPerMeter = 0; | |
168 bmi.bmiHeader.biYPelsPerMeter = 0; | |
169 bmi.bmiHeader.biClrUsed = 0; | |
170 bmi.bmiHeader.biClrImportant = 0; | |
171 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
172 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
173 BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
174 |
2218 | 175 } |
2347 | 176 |
2418 | 177 delete[] image;//удалить кадр |
178 | |
2347 | 179 GUI_MainMenuMessageProc(); //после отрисовки, т.к. иначе вылетает dt = 0.03, image - ??? |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
180 |
2347 | 181 if (pVideoPlayer->bStopBeforeSchedule == 1)//остановка видео |
182 Sleep(1000); //пауза после видеоролика | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
183 } |
2418 | 184 DeleteObject(back_bmp); |
185 DeleteObject(back_dc); | |
2347 | 186 pVideoPlayer->Unload(); |
187 | |
227 | 188 if (a4 == 1) |
151 | 189 pCurrentScreen = SCREEN_GAME; |
2347 | 190 |
0 | 191 pVideoPlayer->bPlayingMovie = 0; |
2347 | 192 |
193 ShowCursor(1);//вернуть курсор | |
194 | |
151 | 195 if ( pCurrentScreen == SCREEN_VIDEO ) |
196 pCurrentScreen = SCREEN_GAME; | |
0 | 197 } |
198 } | |
199 | |
200 //----- (004BE9D8) -------------------------------------------------------- | |
1802 | 201 void VideoPlayer::Initialize(OSWindow *target_window) |
0 | 202 { |
203 DWORD NumberOfBytesRead; // [sp+10h] [bp-4h]@9 | |
204 | |
1802 | 205 window = target_window; |
206 | |
0 | 207 uint uBinkVersionMajor = -1, |
208 uBinkVersionMinor = -1; | |
209 GetDllVersion(L"BINKW32.DLL", &uBinkVersionMajor, &uBinkVersionMinor); | |
210 uBinkVersion = (unsigned __int64)uBinkVersionMajor << 32 | uBinkVersionMinor; | |
211 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
212 strcpy(pTmpBuf.data(), "anims\\might7.vid"); |
2218 | 213 hMightVid = CreateFileW(L"anims\\might7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 214 if ( hMightVid == INVALID_HANDLE_VALUE ) |
215 { | |
1217 | 216 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
217 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 218 return; |
219 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
220 strcpy(pTmpBuf.data(), "anims\\magic7.vid"); |
2218 | 221 hMagicVid = CreateFileW(L"anims\\magic7.vid", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 222 if ( hMagicVid == INVALID_HANDLE_VALUE ) |
223 { | |
224 if ( !bCanLoadFromCD ) | |
2218 | 225 { |
1217 | 226 sprintf(pTmpBuf2.data(), "Can't open file - anims\\%s.smk", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
227 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 228 return; |
2218 | 229 } |
1217 | 230 sprintf(pTmpBuf2.data(), "%c:\\%s", (unsigned __int8)cMM7GameCDDriveLetter, pTmpBuf.data()); |
2218 | 231 hMagicVid = CreateFileA(pTmpBuf2.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080, 0); |
0 | 232 if ( hMagicVid == (HANDLE)INVALID_HANDLE_VALUE ) |
233 { | |
2218 | 234 sprintf(pTmpBuf2.data(), "Can't open file - %s", pTmpBuf.data()); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
235 MessageBoxA(0, pTmpBuf2.data(), "Video File Error", 0); |
0 | 236 return; |
237 } | |
238 } | |
239 ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); | |
240 ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); | |
1583 | 241 pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); |
242 pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); | |
0 | 243 ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); |
244 ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); | |
245 } | |
246 | |
247 //----- (004BEBD7) -------------------------------------------------------- | |
248 void VideoPlayer::Unload() | |
249 { | |
1802 | 250 if ( pSmackMovieBlit ) |
0 | 251 { |
1802 | 252 SmackBlitClose(pSmackMovieBlit); |
253 pSmackMovieBlit = 0; | |
0 | 254 } |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
255 bBufferLoaded = 0; |
1802 | 256 uMovieFormat = 0; |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
257 uMovieFormatSwapped = 0; |
1802 | 258 memset(pCurrentMovieName, 0, 0x40); |
0 | 259 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
260 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
261 pEventTimer->Resume(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
262 |
2394 | 263 delete pMovie_Track; |
264 Log::Warning(L"delete dynamic memory for pMovie_Track\n"); | |
265 pMovie_Track = nullptr; | |
0 | 266 } |
267 | |
1802 | 268 void VideoPlayer::_inlined_in_463149() |
269 { | |
2429 | 270 if (pMovie_Track && !bNoVideo) |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
271 { |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
272 pRenderer->BeginScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
273 pMouse->DrawCursorToTarget(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
274 UpdatePalette(); |
2216 | 275 pMouse->ReadCursorWithItem(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
276 pRenderer->EndScene(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
277 } |
1802 | 278 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
279 |
2356 | 280 void VideoPlayer::UpdatePalette() //UpdateVideo |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
281 { |
2218 | 282 Log::Warning(L"smacker"); |
2360 | 283 loop_current_file = true;//зацикленный ролик |
2218 | 284 pRenderer->BeginScene(); |
2360 | 285 if (end_current_file)//видео завершено/перезагрузка |
2218 | 286 { |
2425 | 287 unsigned int width = game_viewport_width; |
288 unsigned int height = game_viewport_height; | |
2360 | 289 MovieRelease(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
290 |
2218 | 291 SetFilePointer(hVidFile, uOffset, nullptr, FILE_BEGIN); |
2394 | 292 pMovie_Track = nullptr; |
293 Log::Warning(L"reload pMovie_Track"); | |
294 pMovie_Track = pMediaPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, width, height); | |
2360 | 295 end_current_file = false; |
2218 | 296 } |
2360 | 297 //else |
298 //{ | |
2345 | 299 double dt = (GetTickCount() - time_video_begin) / 1000.0; |
300 //dt = 1.0/15.0; | |
301 time_video_begin = GetTickCount(); | |
302 | |
303 //log("dt=%.5f\n", dt); | |
304 | |
305 auto image = new char[current_movie_width * current_movie_height * 4]; | |
306 | |
2394 | 307 pMovie_Track->GetNextFrame(dt, image); |
2345 | 308 |
2222 | 309 int image_array[460 * 344];//game_viewport_width * game_viewport_height |
2218 | 310 if (image) |
311 { | |
2222 | 312 memcpy(image_array, image, sizeof (image_array)); |
2223 | 313 for (unsigned int y = 8; y < 8 + game_viewport_height; ++y)//координаты местоположения видеоролика |
2221 | 314 { |
315 for (unsigned int x = 8; x < 8 + game_viewport_width; ++x) | |
316 { | |
2222 | 317 auto p = (unsigned __int32 *)pRenderer->pTargetSurface + x + y * pRenderer->uTargetSurfacePitch; |
318 *p = image_array[((x - 8) + ((y - 8)*game_viewport_width))]; | |
2221 | 319 } |
320 } | |
2218 | 321 delete[] image; |
322 } | |
2360 | 323 //} |
2218 | 324 pRenderer->EndScene(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
325 } |
0 | 326 |
327 //----- (004BF28F) -------------------------------------------------------- | |
898 | 328 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
0 | 329 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
330 if (!this->bBufferLoaded) |
0 | 331 { |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
332 //Prepare(); |
2218 | 333 pEventTimer->Pause(); |
334 if (pAudioPlayer->hAILRedbook) | |
335 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
336 |
2218 | 337 bStopBeforeSchedule = false; |
338 bBufferLoaded = 1; | |
339 bPlayingMovie = false; | |
340 bFirstFrame = false; | |
341 bUsingSmackerMMX = SmackUseMMX(1); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
342 |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
343 this->bLoopPlaying = a3_1; |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
344 if ( LOBYTE(this->field_104) == 1 ) |
0 | 345 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
346 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
0 | 347 return; |
348 } | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
349 |
2218 | 350 LoadMovie(pMovieName); |
2345 | 351 time_video_begin = GetTickCount(); |
0 | 352 } |
353 } | |
354 | |
355 //----- (004BF3F9) -------------------------------------------------------- | |
356 bool VideoPlayer::AnyMovieLoaded() | |
357 { | |
2425 | 358 if (pMovie_Track) |
2394 | 359 return pMovie_Track;// pSmackerMovie || pBinkMovie; |
2425 | 360 else |
361 return false; | |
0 | 362 } |
363 | |
364 //----- (004BF411) -------------------------------------------------------- | |
898 | 365 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
0 | 366 { |
2334 | 367 // unsigned int v10; // eax@11 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
368 |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
369 if (!this->bBufferLoaded) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
370 { |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
371 pEventTimer->Pause(); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
372 if (pAudioPlayer->hAILRedbook) |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
373 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
0 | 374 |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
375 bStopBeforeSchedule = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
376 bBufferLoaded = 1; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
377 bPlayingMovie = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
378 bFirstFrame = false; |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
379 bUsingSmackerMMX = SmackUseMMX(1); |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
380 this->bLoopPlaying = bLoop; |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
381 LoadMovie(pFilename); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
382 return; |
0 | 383 } |
384 } | |
385 | |
2347 | 386 //----- (004BF5B2) -------------------------------------------------------- |
0 | 387 void VideoPlayer::_4BF5B2() |
388 { | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
389 //__debugbreak(); |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
390 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
391 /*if ( this->uMovieFormat == 2 ) |
0 | 392 { |
393 BinkGoto(pBinkMovie, 1, 0); | |
394 BinkDoFrame(pBinkMovie); | |
395 BinkNextFrame(pBinkMovie); | |
396 } | |
397 else | |
398 { | |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
399 if ( this->uMovieFormat != 1 ) |
0 | 400 return; |
401 SmackGoto(pSmackerMovie, 1); | |
402 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
403 { | |
404 SmackDoFrame(pSmackerMovie); | |
405 SmackNextFrame(pSmackerMovie); | |
406 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
407 }*/ |
0 | 408 pMouse->_469E24(); |
2394 | 409 if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !pMovie_Track)//!this->pSmackerMovie ) |
0 | 410 { |
2218 | 411 bGameoverLoop = true; |
1919 | 412 HouseDialogPressCloseBtn(); |
336 | 413 window_SpeakInHouse->Release(); |
2218 | 414 pParty->uFlags &= 0xFFFFFFFD; |
481 | 415 if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) |
0 | 416 { |
388 | 417 pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2154
diff
changeset
|
418 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); |
2218 | 419 window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, 0x31, "", 0); |
420 window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, 0x32, "", 0); | |
421 window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, 0x33, "", 0); | |
422 window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, 0x34, "", 0); | |
0 | 423 } |
424 bGameoverLoop = 0; | |
425 } | |
426 } | |
427 | |
428 //----- (004BF73A) -------------------------------------------------------- | |
898 | 429 void VideoPlayer::SelectMovieType() |
0 | 430 { |
431 char Source[32]; // [sp+Ch] [bp-40h]@1 | |
432 | |
433 strcpy(Source, this->pCurrentMovieName); | |
434 Unload(); | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
435 if ( this->uMovieFormatSwapped == 1 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
436 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
437 else if ( this->uMovieFormatSwapped == 2 ) |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
438 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
0 | 439 else |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1397
diff
changeset
|
440 __debugbreak(); |
0 | 441 } |
442 | |
443 //----- (004BF8F6) -------------------------------------------------------- | |
444 void VideoPlayer::PlayDeathMovie() | |
445 { | |
446 bStopBeforeSchedule = 0; | |
165 | 447 pResetflag = 0; |
1397 | 448 PlayFullscreenMovie(MOVIE_Death, true); |
449 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | |
1262 | 450 } |
451 | |
452 //----- (004BE6F5) -------------------------------------------------------- | |
453 VideoPlayer::VideoPlayer() : | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
454 bBufferLoaded(0), |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
455 //pBinkMovie(nullptr), pBinkBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
456 //pSmackerMovie(nullptr), pSmackerBuffer(nullptr), |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
457 pSmackMovieBlit(nullptr) |
1262 | 458 { |
459 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | |
460 bStopBeforeSchedule = false; | |
461 pResetflag = 0; | |
2356 | 462 pMediaPlayer = new Media::MPlayer;//создаётся плеер |
2393 | 463 Log::Warning(L"allocation dynamic memory for pMediaPlayer\n"); |
2394 | 464 pMovie_Track = nullptr; |
1262 | 465 //pBinkMovie = nullptr; |
466 } | |
2134 | 467 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
468 int VideoPlayer::readFunction(void* opaque, uint8_t* buf, int buf_size) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
469 { |
2218 | 470 HANDLE stream = (HANDLE)opaque; |
471 //int numBytes = stream->read((char*)buf, buf_size); | |
472 int numBytes; | |
473 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
474 return numBytes; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
475 } |
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
476 |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
477 int64_t VideoPlayer::seekFunction(void* opaque, int64_t offset, int whence) |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
478 { |
2218 | 479 if (whence == AVSEEK_SIZE) |
480 return pVideoPlayer->uSize; | |
481 HANDLE h = (HANDLE)opaque; | |
482 LARGE_INTEGER li; | |
483 li.QuadPart = offset; | |
484 | |
485 if (!SetFilePointerEx(h, li, (PLARGE_INTEGER)&li, FILE_BEGIN)) | |
486 return -1; | |
487 return li.QuadPart; | |
2137
d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
zipi
parents:
2134
diff
changeset
|
488 } |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
489 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
490 void VideoPlayer::LoadMovie(const char * pFilename) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
491 { |
2218 | 492 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
493 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2 | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
494 |
2218 | 495 sprintf(pVideoNameBik, "%s.bik", pFilename); |
496 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
497 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
498 { | |
499 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
500 { | |
501 hVidFile = hMightVid; | |
502 uOffset = pMightVideoHeaders[i].uFileOffset; | |
503 uSize = pMightVideoHeaders[i + 1].uFileOffset - uOffset; | |
504 this->uMovieFormat = 1; | |
505 this->uMovieFormatSwapped = 2; | |
506 } | |
507 } | |
508 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
509 { | |
510 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
511 { | |
512 hVidFile = hMagicVid; | |
513 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
514 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
515 this->uMovieFormat = 2; | |
516 this->uMovieFormatSwapped = 1; | |
517 } | |
518 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
519 { | |
520 hVidFile = hMagicVid; | |
521 uOffset = pMagicVideoHeaders[i].uFileOffset; | |
522 uSize = pMagicVideoHeaders[i + 1].uFileOffset - uOffset; | |
523 this->uMovieFormat = 1; | |
524 this->uMovieFormatSwapped = 2; | |
525 } | |
526 } | |
527 if (!hVidFile) | |
528 { | |
529 Unload(); | |
530 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
531 return; | |
532 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
533 |
2218 | 534 SetFilePointer(hVidFile, uOffset, 0, FILE_BEGIN); |
535 strcpy(this->pCurrentMovieName, pFilename); | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
536 |
2218 | 537 auto hwnd = pVideoPlayer->window->GetApiHandle(); |
538 RECT rc_client; | |
539 GetClientRect(hwnd, &rc_client); | |
540 int client_width = rc_client.right - rc_client.left, | |
541 client_height = rc_client.bottom - rc_client.top; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
542 |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
543 |
2394 | 544 pMovie_Track = pMediaPlayer->LoadMovieFromLOD(hVidFile, &readFunction, &seekFunction, client_width, client_height); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2137
diff
changeset
|
545 |
2345 | 546 } |