mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(ui): add CSimpleMovieFrame::UpdateTiming implementation
This commit is contained in:
parent
f4acc58899
commit
3f004eca04
2 changed files with 79 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ui/CSimpleMovieFrame.hpp"
|
#include "ui/CSimpleMovieFrame.hpp"
|
||||||
#include "ui/CSimpleMovieFrameScript.hpp"
|
#include "ui/CSimpleMovieFrameScript.hpp"
|
||||||
#include "util/SFile.hpp"
|
#include "util/SFile.hpp"
|
||||||
|
#include <common/Time.hpp>
|
||||||
|
|
||||||
int32_t CSimpleMovieFrame::s_metatable;
|
int32_t CSimpleMovieFrame::s_metatable;
|
||||||
int32_t CSimpleMovieFrame::s_objectType;
|
int32_t CSimpleMovieFrame::s_objectType;
|
||||||
|
|
@ -27,8 +28,8 @@ void CSimpleMovieFrame::RegisterScriptMethods(lua_State* L) {
|
||||||
void CSimpleMovieFrame::RenderMovie(void* param) {
|
void CSimpleMovieFrame::RenderMovie(void* param) {
|
||||||
auto movieFrame = reinterpret_cast<CSimpleMovieFrame*>(param);
|
auto movieFrame = reinterpret_cast<CSimpleMovieFrame*>(param);
|
||||||
if (movieFrame->m_isPlaying) {
|
if (movieFrame->m_isPlaying) {
|
||||||
// movieFrame->UpdateTiming();
|
movieFrame->UpdateTiming();
|
||||||
// movieFrame->Render();
|
movieFrame->Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ void CSimpleMovieFrame::StopMovie() {
|
||||||
// UnloadDivxDecoder
|
// UnloadDivxDecoder
|
||||||
// CloseAudio
|
// CloseAudio
|
||||||
// CloseCaptions
|
// CloseCaptions
|
||||||
this->m_isStopped = 0;
|
this->m_isInterrupted = 0;
|
||||||
this->m_isPlaying = 0;
|
this->m_isPlaying = 0;
|
||||||
if (this->m_onMovieFinished.luaRef) {
|
if (this->m_onMovieFinished.luaRef) {
|
||||||
this->RunScript(this->m_onMovieFinished, 0, nullptr);
|
this->RunScript(this->m_onMovieFinished, 0, nullptr);
|
||||||
|
|
@ -275,6 +276,8 @@ int32_t CSimpleMovieFrame::ParseAVIFile(const char* filename) {
|
||||||
offset += 16;
|
offset += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->m_currentFrameData = this->m_videoData;
|
||||||
|
|
||||||
SFile::Close(videoFile);
|
SFile::Close(videoFile);
|
||||||
return dataSize > 0;
|
return dataSize > 0;
|
||||||
}
|
}
|
||||||
|
|
@ -282,3 +285,64 @@ int32_t CSimpleMovieFrame::ParseAVIFile(const char* filename) {
|
||||||
int32_t CSimpleMovieFrame::OpenVideo() {
|
int32_t CSimpleMovieFrame::OpenVideo() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame::UpdateTiming() {
|
||||||
|
bool isAudioPlaying = false; /* SE2::IsPlaying(this->m_audioChannel) */
|
||||||
|
|
||||||
|
if (isAudioPlaying) {
|
||||||
|
//this->m_elapsedTime = SE2::GetPositionInMS(this->m_audioChannel);
|
||||||
|
//this->m_startTime = OsGetAsyncTimeMs() - this->m_elapsedTime;
|
||||||
|
} else {
|
||||||
|
this->m_elapsedTime = OsGetAsyncTimeMs() - this->m_startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t currentFrame = static_cast<uint32_t>(this->m_elapsedTime * this->m_frameRate * 0.001 + 0.5);
|
||||||
|
|
||||||
|
if (isAudioPlaying) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
currentFrame += this->m_frameAudioSync;
|
||||||
|
if (currentFrame <= this->m_prevFrame) {
|
||||||
|
currentFrame = this->m_prevFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_currentFrame = currentFrame;
|
||||||
|
|
||||||
|
if (currentFrame >= this->m_numFrames) {
|
||||||
|
this->m_isInterrupted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->m_isInterrupted) {
|
||||||
|
this->StopMovie();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentFrame == this->m_prevFrame) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentFrame != this->m_prevFrame + 1) {
|
||||||
|
++this->m_lastKeyFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (this->m_prevFrame < this->m_currentFrame - 1) {
|
||||||
|
this->DecodeFrame(false);
|
||||||
|
++this->m_prevFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->DecodeFrame(true)) {
|
||||||
|
this->m_isInterrupted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_prevFrame = this->m_currentFrame;
|
||||||
|
|
||||||
|
// TODO: Subtitle stuff
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleMovieFrame::DecodeFrame(bool unk) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimpleMovieFrame::Render() {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,9 @@ class CSimpleMovieFrame : public CSimpleFrame {
|
||||||
static void RenderMovie(void* param);
|
static void RenderMovie(void* param);
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
|
void* m_audioChannel = nullptr;
|
||||||
int32_t m_isPlaying = 0;
|
int32_t m_isPlaying = 0;
|
||||||
int32_t m_isStopped = 0;
|
int32_t m_isInterrupted = 0;
|
||||||
int32_t m_enableSubtitles = 0;
|
int32_t m_enableSubtitles = 0;
|
||||||
char m_filename[256];
|
char m_filename[256];
|
||||||
int32_t m_volume = 100;
|
int32_t m_volume = 100;
|
||||||
|
|
@ -33,9 +34,16 @@ class CSimpleMovieFrame : public CSimpleFrame {
|
||||||
uint32_t m_videoHeight = 0;
|
uint32_t m_videoHeight = 0;
|
||||||
uint32_t m_numFrames = 0;
|
uint32_t m_numFrames = 0;
|
||||||
char* m_videoData = nullptr;
|
char* m_videoData = nullptr;
|
||||||
|
char* m_currentFrameData = nullptr;
|
||||||
uint32_t m_videoBytes = 0;
|
uint32_t m_videoBytes = 0;
|
||||||
char* m_audioData = nullptr;
|
char* m_audioData = nullptr;
|
||||||
uint32_t m_audioBytes = 0;
|
uint32_t m_audioBytes = 0;
|
||||||
|
uint64_t m_startTime = 0;
|
||||||
|
uint32_t m_prevFrame = 0;
|
||||||
|
uint32_t m_currentFrame = 0;
|
||||||
|
uint32_t m_frameAudioSync = 0;
|
||||||
|
uint32_t m_lastKeyFrame = 0;
|
||||||
|
uint64_t m_elapsedTime = 0;
|
||||||
|
|
||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
|
|
@ -49,6 +57,9 @@ class CSimpleMovieFrame : public CSimpleFrame {
|
||||||
void StopMovie();
|
void StopMovie();
|
||||||
int32_t ParseAVIFile(const char* filename);
|
int32_t ParseAVIFile(const char* filename);
|
||||||
int32_t OpenVideo();
|
int32_t OpenVideo();
|
||||||
|
int32_t UpdateTiming();
|
||||||
|
int32_t DecodeFrame(bool unk);
|
||||||
|
void Render();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue