Mercurial > mm7
comparison VideoPlayer.cpp @ 2137:d24ee391fd1f
libavcodec playing movies and houses, loops not working yet
author | zipi |
---|---|
date | Wed, 01 Jan 2014 13:43:09 +0000 |
parents | 992d2e6f907d |
children | ca548138d6aa |
comparison
equal
deleted
inserted
replaced
2136:d145d0e93a16 | 2137:d24ee391fd1f |
---|---|
299 pVideoPlayer->pResetflag = 0; | 299 pVideoPlayer->pResetflag = 0; |
300 bGameoverLoop = 1; | 300 bGameoverLoop = 1; |
301 if (!bNoVideo) | 301 if (!bNoVideo) |
302 { | 302 { |
303 pRenderer->PresentBlackScreen(); | 303 pRenderer->PresentBlackScreen(); |
304 //PlayFullscreenMovie(MOVIE_3DOLogo, true); | 304 PlayFullscreenMovie(MOVIE_3DOLogo, true); |
305 //pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); | 305 //pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); |
306 if ( !pVideoPlayer->bStopBeforeSchedule ) | 306 if ( !pVideoPlayer->bStopBeforeSchedule ) |
307 { | 307 { |
308 PlayFullscreenMovie(MOVIE_NWCLogo, true); | 308 PlayFullscreenMovie(MOVIE_NWCLogo, true); |
309 //pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); | 309 //pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); |
340 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); | 340 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); |
341 } | 341 } |
342 bGameoverLoop = 0; | 342 bGameoverLoop = 0; |
343 } | 343 } |
344 | 344 |
345 | |
346 | |
347 | |
348 //----- (004BE70E) -------------------------------------------------------- | 345 //----- (004BE70E) -------------------------------------------------------- |
349 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) | 346 void VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4) |
350 { | 347 { |
351 int v4; // ebp@1 | 348 int v4; // ebp@1 |
352 const char *pName; // edi@1 | 349 const char *pName; // edi@1 |
353 MSG Msg; // [sp+Ch] [bp-1Ch]@12 | 350 MSG Msg; // [sp+Ch] [bp-1Ch]@12 |
354 | 351 |
355 v4 = a2; | 352 v4 = a2; |
356 pName = pMovieName; | 353 pName = pMovieName; |
357 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) | 354 if ( !(dword_6BE364_game_settings_1 & (GAME_SETTINGS_NO_HOUSE_ANIM | GAME_SETTINGS_NO_INTRO)) ) |
358 { | 355 { |
359 if ( a2 == 2 ) | 356 if ( a2 == 2 ) |
360 v4 = 0; | 357 v4 = 0; |
361 ShowCursor(0); | 358 ShowCursor(0); |
362 pVideoPlayer->OpenGlobalMovie(pName, 0, ScreenSizeFlag); | 359 pVideoPlayer->OpenGlobalMovie(pName, 0, ScreenSizeFlag); |
363 pVideoPlayer->bPlayingMovie = 1; | 360 pVideoPlayer->bPlayingMovie = 1; |
364 pVideoPlayer->field_44 = v4; | 361 pVideoPlayer->field_44 = v4; |
365 if ( pRenderer->pRenderD3D ) | 362 if ( pRenderer->pRenderD3D ) |
366 { | 363 { |
367 pRenderer->ClearTarget(0); | 364 pRenderer->ClearTarget(0); |
368 } | 365 } |
369 else | 366 else |
371 pRenderer->BeginScene(); | 368 pRenderer->BeginScene(); |
372 pRenderer->ClearTarget(0); | 369 pRenderer->ClearTarget(0); |
373 pRenderer->EndScene(); | 370 pRenderer->EndScene(); |
374 } | 371 } |
375 pCurrentScreen = SCREEN_VIDEO; | 372 pCurrentScreen = SCREEN_VIDEO; |
373 | |
374 auto hwnd = pVideoPlayer->window->GetApiHandle(); | |
375 RECT rc_client; | |
376 GetClientRect(hwnd, &rc_client); | |
377 int client_width = rc_client.right - rc_client.left, | |
378 client_height = rc_client.bottom - rc_client.top; | |
379 | |
380 HDC dc = GetDC(hwnd); | |
381 HDC back_dc = CreateCompatibleDC(dc); | |
382 HBITMAP back_bmp; | |
383 SelectObject(back_dc, back_bmp = CreateCompatibleBitmap(dc, client_width, client_height)); | |
384 | |
385 while (true) | |
386 { | |
387 if ( pVideoPlayer->bStopBeforeSchedule ) | |
388 break; | |
389 while (PeekMessageA(&Msg, hwnd, 0, 0, PM_REMOVE)) | |
390 { | |
391 if (Msg.message == 18) | |
392 Game_DeinitializeAndTerminate(0); | |
393 if (Msg.message == 15) | |
394 break; | |
395 TranslateMessage(&Msg); | |
396 DispatchMessageA(&Msg); | |
397 } | |
398 GUI_MainMenuMessageProc(); | |
399 | |
400 if (!pVideoPlayer->mMovie) | |
401 { | |
402 pVideoPlayer->mMovie = pVideoPlayer->mPlayer->LoadMovie("dummyFilename", client_width, client_height); | |
403 } | |
404 else if (pVideoPlayer->mMovie->Stopped()) | |
405 break; | |
406 auto image = pVideoPlayer->mPlayer->DoFrame(); | |
407 if (image) | |
408 { | |
409 // draw to hwnd | |
410 BITMAPINFO bmi; | |
411 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
412 bmi.bmiHeader.biWidth = client_width; | |
413 bmi.bmiHeader.biHeight = -client_height; | |
414 bmi.bmiHeader.biPlanes = 1; | |
415 bmi.bmiHeader.biBitCount = 32; | |
416 bmi.bmiHeader.biCompression = BI_RGB; | |
417 bmi.bmiHeader.biSizeImage = 0; | |
418 bmi.bmiHeader.biXPelsPerMeter = 0; | |
419 bmi.bmiHeader.biYPelsPerMeter = 0; | |
420 bmi.bmiHeader.biClrUsed = 0; | |
421 bmi.bmiHeader.biClrImportant = 0; | |
422 GetDIBits(back_dc, back_bmp, 0, client_height, 0, &bmi, DIB_RGB_COLORS); | |
423 SetDIBits(back_dc, back_bmp, 0, client_height, image, &bmi, DIB_RGB_COLORS); | |
424 BitBlt(dc, 0, 0, client_width, client_height, back_dc, 0, 0, SRCCOPY); | |
425 | |
426 delete[] image; | |
427 } | |
428 if (pVideoPlayer->bStopBeforeSchedule == 1) | |
429 Sleep(0x3E8u); | |
430 } | |
431 pVideoPlayer->Unload(); | |
432 /* | |
376 if ( pVideoPlayer->uMovieFormat == 2 ) | 433 if ( pVideoPlayer->uMovieFormat == 2 ) |
377 { | 434 { |
378 if ( pVideoPlayer->pBinkMovie ) | 435 if ( pVideoPlayer->pBinkMovie ) |
379 { | 436 { |
380 pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); | 437 //pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); |
381 while ( pVideoPlayer->pBinkMovie ) | 438 |
382 { | 439 } |
383 if ( pVideoPlayer->bStopBeforeSchedule ) | 440 } |
384 break; | |
385 while ( PeekMessageA(&Msg, 0, 0, 0, 1) ) | |
386 { | |
387 if ( Msg.message == 18 ) | |
388 Game_DeinitializeAndTerminate(0); | |
389 if ( Msg.message == 15 ) | |
390 break; | |
391 TranslateMessage(&Msg); | |
392 DispatchMessageA(&Msg); | |
393 } | |
394 GUI_MainMenuMessageProc(); | |
395 if ( !pVideoPlayer->pBinkMovie ) | |
396 break; | |
397 if ( !BinkWait(pVideoPlayer->pBinkMovie) && !pVideoPlayer->bStopBeforeSchedule ) | |
398 pVideoPlayer->BinkDrawFrame(v4, ScreenSizeFlag); | |
399 } | |
400 } | |
401 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) | 441 if ( pVideoPlayer->bStopBeforeSchedule == 1 ) |
402 Sleep(0x3E8u); | 442 Sleep(0x3E8u); |
403 } | 443 }*/ |
404 else | 444 /* |
405 { | 445 if ( pVideoPlayer->uMovieFormat == 1 ) |
406 if ( pVideoPlayer->uMovieFormat == 1 ) | 446 { |
407 { | 447 if ( pVideoPlayer->pSmackerMovie ) |
408 if ( pVideoPlayer->pSmackerMovie ) | 448 { |
409 { | 449 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
410 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); | 450 while ( pVideoPlayer->pSmackerMovie ) |
411 while ( pVideoPlayer->pSmackerMovie ) | 451 { |
412 { | 452 if ( pVideoPlayer->bStopBeforeSchedule ) |
413 if ( pVideoPlayer->bStopBeforeSchedule ) | 453 break; |
414 break; | 454 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) |
415 while ( PeekMessageW(&Msg, 0, 0, 0, 1) ) | 455 { |
416 { | 456 if (Msg.message == WM_QUIT) |
417 if (Msg.message == WM_QUIT) | 457 Game_DeinitializeAndTerminate(0); |
418 Game_DeinitializeAndTerminate(0); | 458 if (Msg.message == WM_PAINT) |
419 if (Msg.message == WM_PAINT) | 459 break; |
420 break; | 460 TranslateMessage(&Msg); |
421 TranslateMessage(&Msg); | 461 DispatchMessageW(&Msg); |
422 DispatchMessageW(&Msg); | 462 } |
423 } | 463 GUI_MainMenuMessageProc(); |
424 GUI_MainMenuMessageProc(); | 464 if ( !pVideoPlayer->pSmackerMovie ) |
425 if ( !pVideoPlayer->pSmackerMovie ) | 465 break; |
426 break; | 466 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) |
427 if ( !SmackWait(pVideoPlayer->pSmackerMovie) && !pVideoPlayer->bStopBeforeSchedule ) | 467 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); |
428 pVideoPlayer->SmackDrawFrame(v4, ScreenSizeFlag); | 468 } |
429 } | 469 } |
430 } | 470 } |
431 } | 471 */ |
432 } | |
433 if (a4 == 1) | 472 if (a4 == 1) |
434 pCurrentScreen = SCREEN_GAME; | 473 pCurrentScreen = SCREEN_GAME; |
435 pVideoPlayer->bPlayingMovie = 0; | 474 pVideoPlayer->bPlayingMovie = 0; |
436 ShowCursor(1); | 475 ShowCursor(1); |
437 if ( pCurrentScreen == SCREEN_VIDEO ) | 476 if ( pCurrentScreen == SCREEN_VIDEO ) |
526 pEventTimer->Pause(); | 565 pEventTimer->Pause(); |
527 if ( pAudioPlayer->hAILRedbook ) | 566 if ( pAudioPlayer->hAILRedbook ) |
528 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | 567 AIL_redbook_pause(pAudioPlayer->hAILRedbook); |
529 | 568 |
530 bStopBeforeSchedule = false; | 569 bStopBeforeSchedule = false; |
531 field_54 = 1; | 570 bBufferLoaded = 1; |
532 pSmackerMovie = 0; | 571 pSmackerMovie = 0; |
533 pSmackerBuffer = 0; | 572 pSmackerBuffer = 0; |
534 pBinkMovie = 0; | 573 pBinkMovie = 0; |
535 pBinkBuffer = 0; | 574 pBinkBuffer = 0; |
536 bPlayingMovie = false; | 575 bPlayingMovie = false; |
539 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); | 578 BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver); |
540 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5) | 579 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5) |
541 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); | 580 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4); |
542 else | 581 else |
543 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer2); | 582 uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer2); |
583 | |
544 } | 584 } |
545 | 585 |
546 | 586 |
547 //----- (004BEBD7) -------------------------------------------------------- | 587 //----- (004BEBD7) -------------------------------------------------------- |
548 void VideoPlayer::Unload() | 588 void VideoPlayer::Unload() |
551 //_BINKBUF *pBinkBuffer; // eax@3 | 591 //_BINKBUF *pBinkBuffer; // eax@3 |
552 //_SMACK *pSmackerMovie; // eax@5 | 592 //_SMACK *pSmackerMovie; // eax@5 |
553 | 593 |
554 if ( pBinkMovie ) | 594 if ( pBinkMovie ) |
555 { | 595 { |
556 BinkPause(pBinkMovie, 1); | 596 //BinkPause(pBinkMovie, 1); |
557 Sleep(300); | 597 Sleep(300); |
558 BinkClose(pBinkMovie); | 598 //BinkClose(pBinkMovie); |
559 pBinkMovie = 0; | 599 pBinkMovie = 0; |
560 } | 600 } |
561 | 601 |
562 if ( pBinkBuffer ) | 602 if ( pBinkBuffer ) |
563 { | 603 { |
567 pBinkBuffer = 0; | 607 pBinkBuffer = 0; |
568 } | 608 } |
569 | 609 |
570 if ( pSmackerMovie ) | 610 if ( pSmackerMovie ) |
571 { | 611 { |
572 SmackSoundOnOff(pSmackerMovie, 0); | 612 //SmackSoundOnOff(pSmackerMovie, 0); |
573 SmackClose(pSmackerMovie); | 613 //SmackClose(pSmackerMovie); |
574 pSmackerMovie = 0; | 614 pSmackerMovie = 0; |
575 } | 615 } |
576 if ( pSmackerBuffer ) | 616 if ( pSmackerBuffer ) |
577 { | 617 { |
578 SmackBufferClose(pSmackerBuffer); | 618 SmackBufferClose(pSmackerBuffer); |
581 if ( pSmackMovieBlit ) | 621 if ( pSmackMovieBlit ) |
582 { | 622 { |
583 SmackBlitClose(pSmackMovieBlit); | 623 SmackBlitClose(pSmackMovieBlit); |
584 pSmackMovieBlit = 0; | 624 pSmackMovieBlit = 0; |
585 } | 625 } |
586 field_54 = 0; | 626 bBufferLoaded = 0; |
587 uMovieFormat = 0; | 627 uMovieFormat = 0; |
588 dword_0000A0 = 0; | 628 uMovieFormatSwapped = 0; |
589 memset(pCurrentMovieName, 0, 0x40); | 629 memset(pCurrentMovieName, 0, 0x40); |
590 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) | 630 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop ) |
591 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | 631 AIL_redbook_resume(pAudioPlayer->hAILRedbook); |
592 pEventTimer->Resume(); | 632 pEventTimer->Resume(); |
633 | |
634 if (mMovie) | |
635 { | |
636 delete mMovie; | |
637 mMovie = nullptr; | |
638 } | |
593 } | 639 } |
594 | 640 |
595 //----- (004BECD5) -------------------------------------------------------- | 641 //----- (004BECD5) -------------------------------------------------------- |
596 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) | 642 void VideoPlayer::FastForwardToFrame(unsigned int uDstFrameNum) |
597 { | 643 { |
814 } | 860 } |
815 } | 861 } |
816 | 862 |
817 void VideoPlayer::_inlined_in_463149() | 863 void VideoPlayer::_inlined_in_463149() |
818 { | 864 { |
819 if ( pSmackerMovie && !SmackWait(pSmackerMovie) ) | 865 if ( mMovie )// && !SmackWait(pSmackerMovie) ) |
820 { | 866 { |
821 pRenderer->BeginScene(); | 867 pRenderer->BeginScene(); |
822 pMouse->DrawCursorToTarget(); | 868 pMouse->DrawCursorToTarget(); |
823 SmackUpdatePalette(); | 869 SmackUpdatePalette(); |
824 pMouse->_469EA4(); | 870 pMouse->_469EA4(); |
825 pRenderer->EndScene(); | 871 pRenderer->EndScene(); |
826 } | 872 } |
827 else if ( pBinkMovie && !BinkWait(pBinkMovie) ) | 873 else if ( pBinkMovie )//&& !BinkWait(pBinkMovie) ) |
828 { | 874 { |
829 pRenderer->BeginScene(); | 875 pRenderer->BeginScene(); |
830 pMouse->DrawCursorToTarget(); | 876 pMouse->DrawCursorToTarget(); |
831 BinkUpdatePalette(); | 877 BinkUpdatePalette(); |
832 pMouse->_469EA4(); | 878 pMouse->_469EA4(); |
849 | 895 |
850 pRenderer->BeginScene(); | 896 pRenderer->BeginScene(); |
851 | 897 |
852 v3 = pixels;//pRenderer->pTargetSurface; | 898 v3 = pixels;//pRenderer->pTargetSurface; |
853 v4 = 640;//pRenderer->uTargetSurfacePitch; | 899 v4 = 640;//pRenderer->uTargetSurfacePitch; |
854 v5 = SmackCheckSurfaceFromat(); | 900 //v5 = SmackCheckSurfaceFromat(); |
855 | |
856 SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); | |
857 | |
858 | 901 |
902 //SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5); | |
903 | |
904 /* | |
859 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) | 905 for (unsigned int y = 8; y < 8 + pSmackerMovie->Height; ++y) |
860 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) | 906 for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x) |
861 { | 907 { |
862 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); | 908 pRenderer->WritePixel16(x, y, pixels[x + y * 640]); |
863 } | 909 } |
864 //delete [] pixels; | 910 //delete [] pixels; |
865 | 911 */ |
866 //v6 = pSmackerMovie; | 912 //v6 = pSmackerMovie; |
913 // int i = 0; | |
914 // while (true) | |
915 //{ | |
916 | |
917 if (pVideoPlayer->mMovie->Stopped()) | |
918 { | |
919 //delete pVideoPlayer->mMovie; | |
920 //pVideoPlayer->mMovie = nullptr; | |
921 //Unload();//break; | |
922 pVideoPlayer->mPlayer->Rewind(); | |
923 } | |
924 else | |
925 { | |
926 | |
927 auto image = pVideoPlayer->mPlayer->DoFrame(); | |
928 | |
929 if (image) | |
930 { | |
931 memcpy(pRenderer->pTargetSurface, image, 480*480*4); | |
932 /*for (unsigned int y = 8; y < 8 + 360; ++y) | |
933 for (unsigned int x = 8; x < 8 + 480; ++x) | |
934 { | |
935 pRenderer->WritePixel16(x, y, image[y + x * 360]); | |
936 | |
937 }*/ | |
938 delete[] image; | |
939 } | |
940 } | |
941 | |
942 //delete pVideoPlayer->mMovie; | |
943 //pVideoPlayer->mMovie = nullptr; | |
944 //pVideoPlayer->Unload(); | |
945 | |
946 /* | |
867 if ( pSmackerMovie->NewPalette ) | 947 if ( pSmackerMovie->NewPalette ) |
868 { | 948 { |
869 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); | 949 SmackBufferNewPalette(pSmackerBuffer, pSmackerMovie->Palette, (pSmackerMovie->PalType)); |
870 SmackColorRemapWithTrans( | 950 SmackColorRemapWithTrans( |
871 pSmackerMovie, | 951 pSmackerMovie, |
877 SmackDoFrame(pSmackerMovie); | 957 SmackDoFrame(pSmackerMovie); |
878 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) | 958 if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying ) |
879 SmackNextFrame(pSmackerMovie); | 959 SmackNextFrame(pSmackerMovie); |
880 else | 960 else |
881 Unload(); | 961 Unload(); |
962 */ | |
963 | |
882 pRenderer->EndScene(); | 964 pRenderer->EndScene(); |
883 } | 965 } |
884 | 966 |
885 | 967 |
886 | 968 |
950 } | 1032 } |
951 | 1033 |
952 //----- (004BF28F) -------------------------------------------------------- | 1034 //----- (004BF28F) -------------------------------------------------------- |
953 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) | 1035 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) |
954 { | 1036 { |
955 if ( !this->field_54 ) | 1037 if (!this->bBufferLoaded) |
956 { | 1038 { |
957 Prepare(); | 1039 //Prepare(); |
1040 pEventTimer->Pause(); | |
1041 if (pAudioPlayer->hAILRedbook) | |
1042 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1043 | |
1044 bStopBeforeSchedule = false; | |
1045 bBufferLoaded = 1; | |
1046 pSmackerMovie = 0; | |
1047 pSmackerBuffer = 0; | |
1048 pBinkMovie = 0; | |
1049 pBinkBuffer = 0; | |
1050 bPlayingMovie = false; | |
1051 bFirstFrame = false; | |
1052 bUsingSmackerMMX = SmackUseMMX(1); | |
1053 | |
958 this->bLoopPlaying = a3_1; | 1054 this->bLoopPlaying = a3_1; |
959 if ( LOBYTE(this->field_104) == 1 ) | 1055 if ( LOBYTE(this->field_104) == 1 ) |
960 { | 1056 { |
961 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); | 1057 MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); |
962 return; | 1058 return; |
963 } | 1059 } |
964 sprintfex(Str2, "%s.smk", pMovieName); | 1060 |
965 this->pSmackerMovie = OpenSmack(Str2); | 1061 sprintf(Str2, "%s.smk", pMovieName); |
1062 void *src = nullptr; | |
1063 unsigned int *offset = nullptr; | |
1064 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1065 { | |
1066 if (!_stricmp(Str2, pMightVideoHeaders[i].pVideoName)) | |
1067 { | |
1068 src = (void *)hMightVid; | |
1069 offset = &pMightVideoHeaders[i].uFileOffset; | |
1070 uVidFile = 0; | |
1071 } | |
1072 } | |
1073 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1074 { | |
1075 if (!_stricmp(Str2, pMagicVideoHeaders[i].pVideoName)) | |
1076 { | |
1077 src = (void *)hMagicVid; | |
1078 offset = &pMagicVideoHeaders[i].uFileOffset; | |
1079 uVidFile = 1; | |
1080 } | |
1081 } | |
1082 if (!src) | |
1083 { | |
1084 Unload(); | |
1085 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1086 return; | |
1087 } | |
1088 | |
1089 SetFilePointer(src, *offset, 0, FILE_BEGIN); | |
1090 strcpy(this->pCurrentMovieName, pMovieName); | |
1091 this->uMovieFormat = 1; | |
1092 this->uMovieFormatSwapped = 2; | |
1093 uSize = *(offset + sizeof(MovieHeader)) - *offset; | |
1094 | |
1095 | |
1096 auto hwnd = pVideoPlayer->window->GetApiHandle(); | |
1097 RECT rc_client; | |
1098 GetClientRect(hwnd, &rc_client); | |
1099 int client_width = rc_client.right - rc_client.left, | |
1100 client_height = rc_client.bottom - rc_client.top; | |
1101 | |
1102 pVideoPlayer->mMovie = pVideoPlayer->mPlayer->LoadMovie("dummyFilename", client_width, client_height); | |
1103 | |
1104 /* | |
1105 this->pSmackerMovie = OpenSmack(Str2); | |
966 if ( !this->pSmackerMovie ) | 1106 if ( !this->pSmackerMovie ) |
967 { | 1107 { |
968 this->Unload(); | 1108 this->Unload(); |
969 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); | 1109 sprintf(pTmpBuf.data(), "Can't load %s", &Str2); |
970 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); | 1110 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); |
971 return; | 1111 return; |
972 } | 1112 } |
973 this->uMovieFormat = 1; | 1113 */ |
974 strcpy(this->pCurrentMovieName, (const char *)pMovieName); | 1114 |
975 this->dword_0000A0 = 1; | 1115 |
976 this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(window->GetApiHandle(), 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); | 1116 |
1117 /* | |
1118 this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(window->GetApiHandle(), 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); | |
977 if ( this->pSmackerBuffer ) | 1119 if ( this->pSmackerBuffer ) |
978 { | 1120 { |
979 pRenderer->BeginScene(); | 1121 pRenderer->BeginScene(); |
980 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); | 1122 SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); |
981 pRenderer->EndScene(); | 1123 pRenderer->EndScene(); |
982 } | 1124 } |
983 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); | 1125 SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); |
1126 */ | |
1127 | |
984 } | 1128 } |
985 } | 1129 } |
986 | 1130 |
987 //----- (004BF3F9) -------------------------------------------------------- | 1131 //----- (004BF3F9) -------------------------------------------------------- |
988 bool VideoPlayer::AnyMovieLoaded() | 1132 bool VideoPlayer::AnyMovieLoaded() |
992 | 1136 |
993 //----- (004BF411) -------------------------------------------------------- | 1137 //----- (004BF411) -------------------------------------------------------- |
994 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) | 1138 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) |
995 { | 1139 { |
996 unsigned int v10; // eax@11 | 1140 unsigned int v10; // eax@11 |
997 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 | 1141 char pVideoNameBik[120]; // [sp+Ch] [bp-28h]@2 |
998 | 1142 char pVideoNameSmk[120]; // [sp+Ch] [bp-28h]@2 |
999 if ( !this->field_54 ) | 1143 |
1000 { | 1144 if (!this->bBufferLoaded) |
1001 Prepare(); | 1145 { |
1002 this->bLoopPlaying = bLoop; | 1146 //Prepare(); |
1147 pEventTimer->Pause(); | |
1148 if (pAudioPlayer->hAILRedbook) | |
1149 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
1150 | |
1151 bStopBeforeSchedule = false; | |
1152 bBufferLoaded = 1; | |
1153 pSmackerMovie = 0; | |
1154 pSmackerBuffer = 0; | |
1155 pBinkMovie = 0; | |
1156 pBinkBuffer = 0; | |
1157 bPlayingMovie = false; | |
1158 bFirstFrame = false; | |
1159 bUsingSmackerMMX = SmackUseMMX(1); | |
1160 this->bLoopPlaying = bLoop; | |
1161 | |
1162 sprintf(pVideoNameBik, "%s.bik", pFilename); | |
1163 sprintf(pVideoNameSmk, "%s.smk", pFilename); | |
1164 void *src = nullptr; | |
1165 unsigned int *offset = nullptr; | |
1166 for (uint i = 0; i < uNumMightVideoHeaders; ++i) | |
1167 { | |
1168 //no BIK in MightVid | |
1169 /* | |
1170 if (!_stricmp(pVideoNameBik, pMightVideoHeaders[i].pVideoName)) | |
1171 { | |
1172 src = (void *)hMightVid; | |
1173 offset = pMightVideoHeaders[i].uFileOffset; | |
1174 uVidFile = 1; | |
1175 this->uMovieFormat = 2; | |
1176 this->uMovieFormatSwapped = 1; | |
1177 } | |
1178 */ | |
1179 if (!_stricmp(pVideoNameSmk, pMightVideoHeaders[i].pVideoName)) | |
1180 { | |
1181 src = (void *)hMightVid; | |
1182 offset = &pMightVideoHeaders[i].uFileOffset; | |
1183 uVidFile = 0; | |
1184 this->uMovieFormat = 1; | |
1185 this->uMovieFormatSwapped = 2; | |
1186 } | |
1187 } | |
1188 for (uint i = 0; i < uNumMagicVideoHeaders; ++i) | |
1189 { | |
1190 if (!_stricmp(pVideoNameBik, pMagicVideoHeaders[i].pVideoName)) | |
1191 { | |
1192 src = (void *)hMagicVid; | |
1193 offset = &pMagicVideoHeaders[i].uFileOffset; | |
1194 uVidFile = 1; | |
1195 this->uMovieFormat = 2; | |
1196 this->uMovieFormatSwapped = 1; | |
1197 } | |
1198 if (!_stricmp(pVideoNameSmk, pMagicVideoHeaders[i].pVideoName)) | |
1199 { | |
1200 src = (void *)hMagicVid; | |
1201 offset = &pMagicVideoHeaders[i].uFileOffset; | |
1202 uVidFile = 1; | |
1203 this->uMovieFormat = 1; | |
1204 this->uMovieFormatSwapped = 2; | |
1205 } | |
1206 } | |
1207 if (!src) | |
1208 { | |
1209 Unload(); | |
1210 MessageBoxA(0, "VideoPlayer error", "VideoPlayer Error", 0); | |
1211 return; | |
1212 } | |
1213 | |
1214 SetFilePointer(src, *offset, 0, FILE_BEGIN); | |
1215 strcpy(this->pCurrentMovieName, pFilename); | |
1216 uSize = *(offset+sizeof(MovieHeader))-*offset; | |
1217 return; | |
1218 | |
1219 | |
1220 /* | |
1003 sprintf(pVideoName, "%s.bik", pFilename); | 1221 sprintf(pVideoName, "%s.bik", pFilename); |
1004 this->pBinkMovie = OpenBink(pVideoName); | 1222 this->pBinkMovie = OpenBink(pVideoName); |
1005 if ( this->pBinkMovie ) | 1223 if ( this->pBinkMovie ) |
1006 { | 1224 { |
1007 this->uMovieFormat = 2; | 1225 this->uMovieFormat = 2; |
1008 strcpy(this->pCurrentMovieName, pFilename); | 1226 strcpy(this->pCurrentMovieName, pFilename); |
1009 pBinkMovie = this->pBinkMovie; | 1227 pBinkMovie = this->pBinkMovie; |
1010 this->dword_0000A0 = 1; | 1228 this->uMovieFormatSwapped = 1; |
1011 if ( pBinkMovie ) | 1229 if ( pBinkMovie ) |
1012 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); | 1230 this->pBinkBuffer = CreateBinkBuffer(pBinkMovie->uWidth, pBinkMovie->uHeight, 0); |
1013 } | 1231 } |
1014 else | 1232 else |
1015 { | 1233 { |
1023 MessageBoxA(0, pVideoName, "Smacker Error", 0); | 1241 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1024 return; | 1242 return; |
1025 } | 1243 } |
1026 this->uMovieFormat = 1; | 1244 this->uMovieFormat = 1; |
1027 strcpy(this->pCurrentMovieName, pFilename); | 1245 strcpy(this->pCurrentMovieName, pFilename); |
1028 this->dword_0000A0 = 2; | 1246 this->uMovieFormatSwapped = 2; |
1029 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); | 1247 this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); |
1030 if ( !this->pSomeSmackerBuffer ) | 1248 if ( !this->pSomeSmackerBuffer ) |
1031 { | 1249 { |
1032 Unload(); | 1250 Unload(); |
1033 sprintf(pVideoName, "Can't allocate memory for buffer"); | 1251 sprintf(pVideoName, "Can't allocate memory for buffer"); |
1052 { | 1270 { |
1053 Unload(); | 1271 Unload(); |
1054 sprintf(pVideoName, "Failed to open Blit API"); | 1272 sprintf(pVideoName, "Failed to open Blit API"); |
1055 MessageBoxA(0, pVideoName, "Smacker Error", 0); | 1273 MessageBoxA(0, pVideoName, "Smacker Error", 0); |
1056 return; | 1274 return; |
1057 } | 1275 } |
1058 } | 1276 }*/ |
1059 } | 1277 } |
1060 } | 1278 } |
1061 | 1279 |
1062 | 1280 |
1063 //----- (004BF5B2) -------------------------------------------------------- | 1281 //----- (004BF5B2) -------------------------------------------------------- |
1105 { | 1323 { |
1106 char Source[32]; // [sp+Ch] [bp-40h]@1 | 1324 char Source[32]; // [sp+Ch] [bp-40h]@1 |
1107 | 1325 |
1108 strcpy(Source, this->pCurrentMovieName); | 1326 strcpy(Source, this->pCurrentMovieName); |
1109 Unload(); | 1327 Unload(); |
1110 if ( this->dword_0000A0 == 1 ) | 1328 if ( this->uMovieFormatSwapped == 1 ) |
1111 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); | 1329 OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); |
1112 else if ( this->dword_0000A0 == 2 ) | 1330 else if ( this->uMovieFormatSwapped == 2 ) |
1113 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); | 1331 OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); |
1114 else | 1332 else |
1115 __debugbreak(); | 1333 __debugbreak(); |
1116 } | 1334 } |
1117 | 1335 |
1124 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); | 1342 //pGame->pCShow->PlayMovie(MOVIE_Death, 1); |
1125 } | 1343 } |
1126 | 1344 |
1127 //----- (004BE6F5) -------------------------------------------------------- | 1345 //----- (004BE6F5) -------------------------------------------------------- |
1128 VideoPlayer::VideoPlayer() : | 1346 VideoPlayer::VideoPlayer() : |
1129 field_54(0), | 1347 bBufferLoaded(0), |
1130 pBinkMovie(nullptr), pBinkBuffer(nullptr), | 1348 pBinkMovie(nullptr), pBinkBuffer(nullptr), |
1131 pSmackerMovie(nullptr), pSmackerBuffer(nullptr), pSmackMovieBlit(nullptr) | 1349 pSmackerMovie(nullptr), pSmackerBuffer(nullptr), pSmackMovieBlit(nullptr) |
1132 { | 1350 { |
1133 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); | 1351 //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame); |
1134 bStopBeforeSchedule = false; | 1352 bStopBeforeSchedule = false; |
1135 pResetflag = 0; | 1353 pResetflag = 0; |
1136 byte_F8BC0C = 0; | 1354 byte_F8BC0C = 0; |
1355 mPlayer = new MultimediaPlayer(); | |
1356 mPlayer->Initialize(); | |
1357 mMovie = nullptr; | |
1137 //pBinkMovie = nullptr; | 1358 //pBinkMovie = nullptr; |
1138 } | 1359 } |
1139 | 1360 |
1140 bool MultimediaPlayer::libavcodec_initialized = false; | 1361 bool MultimediaPlayer::libavcodec_initialized = false; |
1141 | 1362 |
1145 vsprintf(msg, format, args); | 1366 vsprintf(msg, format, args); |
1146 | 1367 |
1147 DWORD w; | 1368 DWORD w; |
1148 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); | 1369 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, lstrlenA(msg), &w, nullptr); |
1149 } | 1370 } |
1371 | |
1372 int readFunction(void* opaque, uint8_t* buf, int buf_size) | |
1373 { | |
1374 HANDLE stream = (HANDLE)opaque; | |
1375 //int numBytes = stream->read((char*)buf, buf_size); | |
1376 int numBytes; | |
1377 ReadFile(stream, (char *)buf, buf_size, (LPDWORD)&numBytes, NULL); | |
1378 return numBytes; | |
1379 } | |
1380 | |
1381 int64_t seekFunction(void* opaque, int64_t offset, int whence) | |
1382 { | |
1383 if (whence == AVSEEK_SIZE) | |
1384 return pVideoPlayer->uSize;// -1; // I don't know "size of my handle in bytes" | |
1385 HANDLE stream = (HANDLE)opaque; | |
1386 /*if (stream->isSequential()) | |
1387 return -1; // cannot seek a sequential stream | |
1388 if (!stream->seek(offset)) | |
1389 return -1; | |
1390 return stream->pos();*/ | |
1391 LARGE_INTEGER li,li2; | |
1392 PLARGE_INTEGER pli = &li2; | |
1393 li.QuadPart = offset; | |
1394 SetFilePointerEx(stream, li, pli, FILE_BEGIN); | |
1395 return pli->QuadPart; | |
1396 return SetFilePointer(stream, LODWORD(offset), (PLONG)(&offset)+1, FILE_BEGIN); | |
1397 } |