Fixes for Google style guide.

This commit is contained in:
Brandon W
2024-11-06 01:20:31 -08:00
committed by teejusb
parent 1626398244
commit 98b7f28c26
4 changed files with 173 additions and 173 deletions
+10 -10
View File
@@ -427,11 +427,11 @@ int MovieDecoder_FFMpeg::DecodePacketToFrame() {
return 0; /* packet done */ return 0; /* packet done */
} }
int MovieDecoder_FFMpeg::GetFrame(RageSurface* pSurface) int MovieDecoder_FFMpeg::GetFrame(RageSurface* surface_out)
{ {
avcodec::AVFrame pict; avcodec::AVFrame pict;
pict.data[0] = (unsigned char*)pSurface->pixels; pict.data[0] = (unsigned char*)surface_out->pixels;
pict.linesize[0] = pSurface->pitch; pict.linesize[0] = surface_out->pitch;
/* XXX 1: Do this in one of the Open() methods instead? /* XXX 1: Do this in one of the Open() methods instead?
* XXX 2: The problem of doing this in Open() is that m_AVTexfmt is not * XXX 2: The problem of doing this in Open() is that m_AVTexfmt is not
@@ -525,7 +525,7 @@ static int64_t AVIORageFile_Seek(void* opaque, int64_t offset, int whence)
return f->Seek((int)offset, whence); return f->Seek((int)offset, whence);
} }
RString MovieDecoder_FFMpeg::Open(RString sFile) RString MovieDecoder_FFMpeg::Open(RString file)
{ {
av_format_context_ = avcodec::avformat_alloc_context(); av_format_context_ = avcodec::avformat_alloc_context();
if (!av_format_context_) if (!av_format_context_)
@@ -533,10 +533,10 @@ RString MovieDecoder_FFMpeg::Open(RString sFile)
RageFile* f = new RageFile; RageFile* f = new RageFile;
if (!f->Open(sFile, RageFile::READ)) if (!f->Open(file, RageFile::READ))
{ {
RString errorMessage = f->GetError(); RString errorMessage = f->GetError();
RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str()); RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", file.c_str(), errorMessage.c_str());
delete f; delete f;
return error; return error;
} }
@@ -544,13 +544,13 @@ RString MovieDecoder_FFMpeg::Open(RString sFile)
av_buffer_ = (unsigned char*)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE); av_buffer_ = (unsigned char*)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE);
av_io_context_ = avcodec::avio_alloc_context(av_buffer_, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, nullptr, AVIORageFile_Seek); av_io_context_ = avcodec::avio_alloc_context(av_buffer_, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, nullptr, AVIORageFile_Seek);
av_format_context_->pb = av_io_context_; av_format_context_->pb = av_io_context_;
int ret = avcodec::avformat_open_input(&av_format_context_, sFile.c_str(), nullptr, nullptr); int ret = avcodec::avformat_open_input(&av_format_context_, file.c_str(), nullptr, nullptr);
if (ret < 0) if (ret < 0)
return RString(averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str())); return RString(averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", file.c_str()));
ret = avcodec::avformat_find_stream_info(av_format_context_, nullptr); ret = avcodec::avformat_find_stream_info(av_format_context_, nullptr);
if (ret < 0) if (ret < 0)
return RString(averr_ssprintf(ret, "AVCodec (%s): Couldn't find codec parameters", sFile.c_str())); return RString(averr_ssprintf(ret, "AVCodec (%s): Couldn't find codec parameters", file.c_str()));
int stream_idx = avcodec::av_find_best_stream(av_format_context_, avcodec::AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0); int stream_idx = avcodec::av_find_best_stream(av_format_context_, avcodec::AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
if (stream_idx < 0 || if (stream_idx < 0 ||
@@ -567,7 +567,7 @@ RString MovieDecoder_FFMpeg::Open(RString sFile)
RString sError = OpenCodec(); RString sError = OpenCodec();
if (!sError.empty()) if (!sError.empty())
return ssprintf("AVCodec (%s): %s", sFile.c_str(), sError.c_str()); return ssprintf("AVCodec (%s): %s", file.c_str(), sError.c_str());
LOG->Trace("Bitrate: %i", static_cast<int>(av_stream_codec_->bit_rate)); LOG->Trace("Bitrate: %i", static_cast<int>(av_stream_codec_->bit_rate));
LOG->Trace("Codec pixel format: %s", avcodec::av_get_pix_fmt_name(av_stream_codec_->pix_fmt)); LOG->Trace("Codec pixel format: %s", avcodec::av_get_pix_fmt_name(av_stream_codec_->pix_fmt));
+2 -2
View File
@@ -73,7 +73,7 @@ public:
MovieDecoder_FFMpeg(); MovieDecoder_FFMpeg();
~MovieDecoder_FFMpeg(); ~MovieDecoder_FFMpeg();
RString Open(RString sFile); RString Open(RString file);
void Close(); void Close();
// Rewind sends the reset signal to DecodeMovie. See DecodeMovie // Rewind sends the reset signal to DecodeMovie. See DecodeMovie
@@ -87,7 +87,7 @@ public:
// This draws a frame from the buffer onto the provided RageSurface. // This draws a frame from the buffer onto the provided RageSurface.
// Returns 1 if the last frame of the movie, -1 if there's an issue // Returns 1 if the last frame of the movie, -1 if there's an issue
// with the frame and we should skip. // with the frame and we should skip.
int GetFrame(RageSurface* pOut); int GetFrame(RageSurface* surface_out);
// Handles the next packet in decoding. // Handles the next packet in decoding.
int HandleNextPacket(); int HandleNextPacket();
+143 -143
View File
@@ -19,43 +19,43 @@
#endif #endif
static Preference<bool> g_bMovieTextureDirectUpdates( "MovieTextureDirectUpdates", true ); static Preference<bool> g_bMovieTextureDirectUpdates("MovieTextureDirectUpdates", true);
MovieTexture_Generic::MovieTexture_Generic( RageTextureID ID, MovieDecoder *pDecoder ): MovieTexture_Generic::MovieTexture_Generic(RageTextureID ID, MovieDecoder* pDecoder) :
RageMovieTexture( ID ) RageMovieTexture(ID)
{ {
LOG->Trace( "MovieTexture_Generic::MovieTexture_Generic(%s)", ID.filename.c_str() ); LOG->Trace("MovieTexture_Generic::MovieTexture_Generic(%s)", ID.filename.c_str());
m_pDecoder = pDecoder; decoder_ = pDecoder;
m_uTexHandle = 0; texture_handle_ = 0;
m_pRenderTarget = nullptr; render_target_ = nullptr;
m_pTextureIntermediate = nullptr; intermediate_texture_ = nullptr;
m_bLoop = true; loop_ = true;
m_pSurface = nullptr; surface_ = nullptr;
m_pTextureLock = nullptr; texture_lock_ = nullptr;
m_fRate = 1; rate_ = 1;
m_fClock = 0; clock_ = 0;
m_pSprite = new Sprite; sprite_ = new Sprite;
} }
RString MovieTexture_Generic::Init() RString MovieTexture_Generic::Init()
{ {
RString sError = m_pDecoder->Open(GetID().filename); RString sError = decoder_->Open(GetID().filename);
if (sError != "") if (sError != "")
return sError; return sError;
CreateTexture(); CreateTexture();
CreateFrameRects(); CreateFrameRects();
m_pDecoder->SetLooping(m_bLoop); decoder_->SetLooping(loop_);
decoding_thread = std::make_unique<std::thread>([this]() { decoding_thread_ = std::make_unique<std::thread>([this]() {
LOG->Trace("Beginning to decode video file \"%s\"", GetID().filename.c_str()); LOG->Trace("Beginning to decode video file \"%s\"", GetID().filename.c_str());
auto timer = RageTimer(); auto timer = RageTimer();
int ret = m_pDecoder->DecodeMovie(); int ret = decoder_->DecodeMovie();
if (ret == -1) { if (ret == -1) {
m_failure = true; failure_ = true;
} }
LOG->Trace("Done decoding video file \"%s\", took %f seconds", GetID().filename.c_str(), timer.Ago()); LOG->Trace("Done decoding video file \"%s\", took %f seconds", GetID().filename.c_str(), timer.Ago());
@@ -72,50 +72,50 @@ RString MovieTexture_Generic::Init()
MovieTexture_Generic::~MovieTexture_Generic() MovieTexture_Generic::~MovieTexture_Generic()
{ {
if (m_pDecoder) { if (decoder_) {
m_pDecoder->Cancel(); decoder_->Cancel();
decoding_thread->join(); decoding_thread_->join();
m_pDecoder->Close(); decoder_->Close();
} }
/* m_pSprite may reference the texture; delete it before DestroyTexture. */ /* sprite_ may reference the texture; delete it before DestroyTexture. */
delete m_pSprite; delete sprite_;
DestroyTexture(); DestroyTexture();
delete m_pDecoder; delete decoder_;
} }
/* Delete the surface and texture. The decoding thread must be stopped, and this /* Delete the surface and texture. The decoding thread must be stopped, and this
* is normally done after destroying the decoder. */ * is normally done after destroying the decoder. */
void MovieTexture_Generic::DestroyTexture() void MovieTexture_Generic::DestroyTexture()
{ {
delete m_pSurface; delete surface_;
m_pSurface = nullptr; surface_ = nullptr;
delete m_pTextureLock; delete texture_lock_;
m_pTextureLock = nullptr; texture_lock_ = nullptr;
if( m_uTexHandle ) if (texture_handle_)
{ {
DISPLAY->DeleteTexture( m_uTexHandle ); DISPLAY->DeleteTexture(texture_handle_);
m_uTexHandle = 0; texture_handle_ = 0;
} }
delete m_pRenderTarget; delete render_target_;
m_pRenderTarget = nullptr; render_target_ = nullptr;
delete m_pTextureIntermediate; delete intermediate_texture_;
m_pTextureIntermediate = nullptr; intermediate_texture_ = nullptr;
} }
class RageMovieTexture_Generic_Intermediate : public RageTexture class RageMovieTexture_Generic_Intermediate : public RageTexture
{ {
public: public:
RageMovieTexture_Generic_Intermediate( RageTextureID ID, int iWidth, int iHeight, RageMovieTexture_Generic_Intermediate(RageTextureID ID, int iWidth, int iHeight,
int iImageWidth, int iImageHeight, int iTextureWidth, int iTextureHeight, int iImageWidth, int iImageHeight, int iTextureWidth, int iTextureHeight,
RageSurfaceFormat SurfaceFormat, RagePixelFormat pixfmt ): RageSurfaceFormat SurfaceFormat, RagePixelFormat pixfmt) :
RageTexture(ID), RageTexture(ID),
m_SurfaceFormat( SurfaceFormat ) m_SurfaceFormat(SurfaceFormat)
{ {
m_PixFmt = pixfmt; m_PixFmt = pixfmt;
m_iSourceWidth = iWidth; m_iSourceWidth = iWidth;
@@ -128,71 +128,71 @@ public:
CreateFrameRects(); CreateFrameRects();
m_uTexHandle = 0; texture_handle_ = 0;
CreateTexture(); CreateTexture();
} }
virtual ~RageMovieTexture_Generic_Intermediate() virtual ~RageMovieTexture_Generic_Intermediate()
{ {
if( m_uTexHandle ) if (texture_handle_)
{ {
DISPLAY->DeleteTexture( m_uTexHandle ); DISPLAY->DeleteTexture(texture_handle_);
m_uTexHandle = 0; texture_handle_ = 0;
} }
} }
virtual void Invalidate() { m_uTexHandle = 0; } virtual void Invalidate() { texture_handle_ = 0; }
virtual void Reload() { } virtual void Reload() { }
virtual uintptr_t GetTexHandle() const virtual uintptr_t GetTexHandle() const
{ {
return m_uTexHandle; return texture_handle_;
} }
bool IsAMovie() const { return true; } bool IsAMovie() const { return true; }
private: private:
void CreateTexture() void CreateTexture()
{ {
if( m_uTexHandle ) if (texture_handle_)
return; return;
RageSurface *pSurface = CreateSurfaceFrom( m_iImageWidth, m_iImageHeight, RageSurface* pSurface = CreateSurfaceFrom(m_iImageWidth, m_iImageHeight,
m_SurfaceFormat.BitsPerPixel, m_SurfaceFormat.BitsPerPixel,
m_SurfaceFormat.Mask[0], m_SurfaceFormat.Mask[0],
m_SurfaceFormat.Mask[1], m_SurfaceFormat.Mask[1],
m_SurfaceFormat.Mask[2], m_SurfaceFormat.Mask[2],
m_SurfaceFormat.Mask[3], nullptr, 1 ); m_SurfaceFormat.Mask[3], nullptr, 1);
m_uTexHandle = DISPLAY->CreateTexture( m_PixFmt, pSurface, false ); texture_handle_ = DISPLAY->CreateTexture(m_PixFmt, pSurface, false);
delete pSurface; delete pSurface;
} }
uintptr_t m_uTexHandle; uintptr_t texture_handle_;
RageSurfaceFormat m_SurfaceFormat; RageSurfaceFormat m_SurfaceFormat;
RagePixelFormat m_PixFmt; RagePixelFormat m_PixFmt;
}; };
void MovieTexture_Generic::Invalidate() void MovieTexture_Generic::Invalidate()
{ {
m_uTexHandle = 0; texture_handle_ = 0;
if( m_pTextureIntermediate != nullptr ) if (intermediate_texture_ != nullptr)
m_pTextureIntermediate->Invalidate(); intermediate_texture_->Invalidate();
} }
void MovieTexture_Generic::CreateTexture() void MovieTexture_Generic::CreateTexture()
{ {
if( m_uTexHandle || m_pRenderTarget != nullptr ) if (texture_handle_ || render_target_ != nullptr)
return; return;
CHECKPOINT; CHECKPOINT;
m_iSourceWidth = m_pDecoder->GetWidth(); m_iSourceWidth = decoder_->GetWidth();
m_iSourceHeight = m_pDecoder->GetHeight(); m_iSourceHeight = decoder_->GetHeight();
/* Adjust m_iSourceWidth to support different source aspect ratios. */ /* Adjust m_iSourceWidth to support different source aspect ratios. */
float fSourceAspectRatio = m_pDecoder->GetSourceAspectRatio(); float fSourceAspectRatio = decoder_->GetSourceAspectRatio();
if( fSourceAspectRatio < 1 ) if (fSourceAspectRatio < 1)
m_iSourceHeight = std::lrint( m_iSourceHeight / fSourceAspectRatio ); m_iSourceHeight = std::lrint(m_iSourceHeight / fSourceAspectRatio);
else if( fSourceAspectRatio > 1 ) else if (fSourceAspectRatio > 1)
m_iSourceWidth = std::lrint( m_iSourceWidth * fSourceAspectRatio ); m_iSourceWidth = std::lrint(m_iSourceWidth * fSourceAspectRatio);
/* HACK: Don't cap movie textures to the max texture size, since we /* HACK: Don't cap movie textures to the max texture size, since we
* render them onto the texture at the source dimensions. If we find a * render them onto the texture at the source dimensions. If we find a
@@ -201,42 +201,42 @@ void MovieTexture_Generic::CreateTexture()
m_iImageHeight = m_iSourceHeight; m_iImageHeight = m_iSourceHeight;
/* Texture dimensions need to be a power of two; jump to the next. */ /* Texture dimensions need to be a power of two; jump to the next. */
m_iTextureWidth = power_of_two( m_iImageWidth ); m_iTextureWidth = power_of_two(m_iImageWidth);
m_iTextureHeight = power_of_two( m_iImageHeight ); m_iTextureHeight = power_of_two(m_iImageHeight);
MovieDecoderPixelFormatYCbCr fmt = PixelFormatYCbCr_Invalid; MovieDecoderPixelFormatYCbCr fmt = PixelFormatYCbCr_Invalid;
if( m_pSurface == nullptr ) if (surface_ == nullptr)
{ {
ASSERT( m_pTextureLock == nullptr ); ASSERT(texture_lock_ == nullptr);
if( g_bMovieTextureDirectUpdates ) if (g_bMovieTextureDirectUpdates)
m_pTextureLock = DISPLAY->CreateTextureLock(); texture_lock_ = DISPLAY->CreateTextureLock();
m_pSurface = m_pDecoder->CreateCompatibleSurface( m_iImageWidth, m_iImageHeight, surface_ = decoder_->CreateCompatibleSurface(m_iImageWidth, m_iImageHeight,
TEXTUREMAN->GetPrefs().m_iMovieColorDepth == 32, fmt ); TEXTUREMAN->GetPrefs().m_iMovieColorDepth == 32, fmt);
if( m_pTextureLock != nullptr ) if (texture_lock_ != nullptr)
{ {
delete [] m_pSurface->pixels; delete[] surface_->pixels;
m_pSurface->pixels = nullptr; surface_->pixels = nullptr;
} }
} }
RagePixelFormat pixfmt = DISPLAY->FindPixelFormat( m_pSurface->format->BitsPerPixel, RagePixelFormat pixfmt = DISPLAY->FindPixelFormat(surface_->format->BitsPerPixel,
m_pSurface->format->Mask[0], surface_->format->Mask[0],
m_pSurface->format->Mask[1], surface_->format->Mask[1],
m_pSurface->format->Mask[2], surface_->format->Mask[2],
m_pSurface->format->Mask[3] ); surface_->format->Mask[3]);
if( pixfmt == RagePixelFormat_Invalid ) if (pixfmt == RagePixelFormat_Invalid)
{ {
/* We weren't given a natively-supported pixel format. Pick a supported /* We weren't given a natively-supported pixel format. Pick a supported
* one. This is a fallback case, and implies a second conversion. */ * one. This is a fallback case, and implies a second conversion. */
int depth = TEXTUREMAN->GetPrefs().m_iMovieColorDepth; int depth = TEXTUREMAN->GetPrefs().m_iMovieColorDepth;
switch( depth ) switch (depth)
{ {
default: default:
FAIL_M(ssprintf("Unsupported movie color depth: %i", depth)); FAIL_M(ssprintf("Unsupported movie color depth: %i", depth));
case 16: case 16:
if( DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB5) ) if (DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB5))
pixfmt = RagePixelFormat_RGB5; pixfmt = RagePixelFormat_RGB5;
else else
pixfmt = RagePixelFormat_RGBA4; pixfmt = RagePixelFormat_RGBA4;
@@ -244,11 +244,11 @@ void MovieTexture_Generic::CreateTexture()
break; break;
case 32: case 32:
if( DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB8) ) if (DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB8))
pixfmt = RagePixelFormat_RGB8; pixfmt = RagePixelFormat_RGB8;
else if( DISPLAY->SupportsTextureFormat(RagePixelFormat_RGBA8) ) else if (DISPLAY->SupportsTextureFormat(RagePixelFormat_RGBA8))
pixfmt = RagePixelFormat_RGBA8; pixfmt = RagePixelFormat_RGBA8;
else if( DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB5) ) else if (DISPLAY->SupportsTextureFormat(RagePixelFormat_RGB5))
pixfmt = RagePixelFormat_RGB5; pixfmt = RagePixelFormat_RGB5;
else else
pixfmt = RagePixelFormat_RGBA4; pixfmt = RagePixelFormat_RGBA4;
@@ -256,45 +256,45 @@ void MovieTexture_Generic::CreateTexture()
} }
} }
if( fmt != PixelFormatYCbCr_Invalid ) if (fmt != PixelFormatYCbCr_Invalid)
{ {
RageUtil::SafeDelete( m_pTextureIntermediate ); RageUtil::SafeDelete(intermediate_texture_);
m_pSprite->UnloadTexture(); sprite_->UnloadTexture();
/* Create the render target. This will receive the final, converted texture. */ /* Create the render target. This will receive the final, converted texture. */
RenderTargetParam param; RenderTargetParam param;
param.iWidth = m_iImageWidth; param.iWidth = m_iImageWidth;
param.iHeight = m_iImageHeight; param.iHeight = m_iImageHeight;
RageTextureID TargetID( GetID() ); RageTextureID TargetID(GetID());
TargetID.filename += " target"; TargetID.filename += " target";
m_pRenderTarget = new RageTextureRenderTarget( TargetID, param ); render_target_ = new RageTextureRenderTarget(TargetID, param);
/* Create the intermediate texture. This receives the YUV image. */ /* Create the intermediate texture. This receives the YUV image. */
RageTextureID IntermedID( GetID() ); RageTextureID IntermedID(GetID());
IntermedID.filename += " intermediate"; IntermedID.filename += " intermediate";
m_pTextureIntermediate = new RageMovieTexture_Generic_Intermediate( IntermedID, intermediate_texture_ = new RageMovieTexture_Generic_Intermediate(IntermedID,
m_pDecoder->GetWidth(), m_pDecoder->GetHeight(), decoder_->GetWidth(), decoder_->GetHeight(),
m_pSurface->w, m_pSurface->h, surface_->w, surface_->h,
power_of_two(m_pSurface->w), power_of_two(m_pSurface->h), power_of_two(surface_->w), power_of_two(surface_->h),
*m_pSurface->format, pixfmt ); *surface_->format, pixfmt);
/* Configure the sprite. This blits the intermediate onto the ifnal render target. */ /* Configure the sprite. This blits the intermediate onto the ifnal render target. */
m_pSprite->SetHorizAlign( align_left ); sprite_->SetHorizAlign(align_left);
m_pSprite->SetVertAlign( align_top ); sprite_->SetVertAlign(align_top);
/* Hack: Sprite wants to take ownership of the texture, and will decrement the refcount /* Hack: Sprite wants to take ownership of the texture, and will decrement the refcount
* when it unloads the texture. Normally we'd make a "copy", but we can't access * when it unloads the texture. Normally we'd make a "copy", but we can't access
* RageTextureManager from here. Just increment the refcount. */ * RageTextureManager from here. Just increment the refcount. */
++m_pTextureIntermediate->m_iRefCount; ++intermediate_texture_->m_iRefCount;
m_pSprite->SetTexture( m_pTextureIntermediate ); sprite_->SetTexture(intermediate_texture_);
m_pSprite->SetEffectMode( GetEffectMode(fmt) ); sprite_->SetEffectMode(GetEffectMode(fmt));
return; return;
} }
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_pSurface, false ); texture_handle_ = DISPLAY->CreateTexture(pixfmt, surface_, false);
} }
/* /*
@@ -304,25 +304,25 @@ void MovieTexture_Generic::CreateTexture()
*/ */
float MovieTexture_Generic::CheckFrameTime() float MovieTexture_Generic::CheckFrameTime()
{ {
if (m_fRate == 0) { if (rate_ == 0) {
return 1; // "a long time until the next frame" return 1; // "a long time until the next frame"
} }
return (m_pDecoder->GetTimestamp() - m_fClock) / m_fRate; return (decoder_->GetTimestamp() - clock_) / rate_;
} }
void MovieTexture_Generic::UpdateMovie(float fSeconds) void MovieTexture_Generic::UpdateMovie(float seconds)
{ {
// Quick exit in case we failed to decode the movie. // Quick exit in case we failed to decode the movie.
if (m_failure) { if (failure_) {
return; return;
} }
m_fClock += fSeconds * m_fRate; clock_ += seconds * rate_;
// If the frame isn't ready, don't update. This does mean the video // If the frame isn't ready, don't update. This does mean the video
// will "speed up" to catch up when decoding does outpace display. // will "speed up" to catch up when decoding does outpace display.
// //
// In practice, display should rarely, if ever, outpace decoding. // In practice, display should rarely, if ever, outpace decoding.
if (m_pDecoder->IsCurrentFrameReady() && CheckFrameTime() <= 0) { if (decoder_->IsCurrentFrameReady() && CheckFrameTime() <= 0) {
UpdateFrame(); UpdateFrame();
return; return;
} }
@@ -337,18 +337,18 @@ void MovieTexture_Generic::UpdateFrame()
/* Just in case we were invalidated: */ /* Just in case we were invalidated: */
CreateTexture(); CreateTexture();
if(m_pTextureLock != nullptr) if (texture_lock_ != nullptr)
{ {
uintptr_t iHandle = m_pTextureIntermediate != nullptr ? m_pTextureIntermediate->GetTexHandle(): this->GetTexHandle(); uintptr_t iHandle = intermediate_texture_ != nullptr ? intermediate_texture_->GetTexHandle() : this->GetTexHandle();
m_pTextureLock->Lock(iHandle, m_pSurface); texture_lock_->Lock(iHandle, surface_);
} }
int frame_ret = m_pDecoder->GetFrame(m_pSurface); int frame_ret = decoder_->GetFrame(surface_);
// Are we looping? // Are we looping?
if (m_pDecoder->EndOfMovie() && m_bLoop) { if (decoder_->EndOfMovie() && loop_) {
LOG->Trace("File \"%s\" looping", GetID().filename.c_str()); LOG->Trace("File \"%s\" looping", GetID().filename.c_str());
m_pDecoder->Rollover(); decoder_->Rollover();
// There's a gap in the audio when the music preview loops. This value // There's a gap in the audio when the music preview loops. This value
// is dynamic based on the ending and starting beats (see // is dynamic based on the ending and starting beats (see
@@ -358,9 +358,9 @@ void MovieTexture_Generic::UpdateFrame()
// the movie texture doesn't have access to the SoundManager's offset. // the movie texture doesn't have access to the SoundManager's offset.
// Until it does, we can either freeze at the end of the video banner, // Until it does, we can either freeze at the end of the video banner,
// or give it a best effort approximation (0.5 seconds). // or give it a best effort approximation (0.5 seconds).
m_fClock = 0.5; clock_ = 0.5;
} }
else if (m_pDecoder->EndOfMovie()) { else if (decoder_->EndOfMovie()) {
// At the end of the movie, and not looping. // At the end of the movie, and not looping.
finished_ = true; finished_ = true;
} }
@@ -368,37 +368,37 @@ void MovieTexture_Generic::UpdateFrame()
// There's an issue with the frame, make sure it does not get // There's an issue with the frame, make sure it does not get
// uploaded. // uploaded.
if (frame_ret == -1) { if (frame_ret == -1) {
if (m_pTextureLock != nullptr) { if (texture_lock_ != nullptr) {
m_pTextureLock->Unlock(m_pSurface, true); texture_lock_->Unlock(surface_, true);
} }
return; return;
} }
if (m_pTextureLock != nullptr) { if (texture_lock_ != nullptr) {
m_pTextureLock->Unlock(m_pSurface, true); texture_lock_->Unlock(surface_, true);
} }
if (m_pRenderTarget != nullptr) if (render_target_ != nullptr)
{ {
CHECKPOINT_M("About to upload the texture."); CHECKPOINT_M("About to upload the texture.");
/* If we have no m_pTextureLock, we still have to upload the texture. */ /* If we have no texture_lock_, we still have to upload the texture. */
if (m_pTextureLock == nullptr) { if (texture_lock_ == nullptr) {
DISPLAY->UpdateTexture( DISPLAY->UpdateTexture(
m_pTextureIntermediate->GetTexHandle(), intermediate_texture_->GetTexHandle(),
m_pSurface, surface_,
0, 0, 0, 0,
m_pSurface->w, m_pSurface->h); surface_->w, surface_->h);
} }
m_pRenderTarget->BeginRenderingTo(false); render_target_->BeginRenderingTo(false);
m_pSprite->Draw(); sprite_->Draw();
m_pRenderTarget->FinishRenderingTo(); render_target_->FinishRenderingTo();
} }
else { else {
if (m_pTextureLock == nullptr) { if (texture_lock_ == nullptr) {
DISPLAY->UpdateTexture( DISPLAY->UpdateTexture(
m_uTexHandle, texture_handle_,
m_pSurface, surface_,
0, 0, 0, 0,
m_iImageWidth, m_iImageHeight); m_iImageWidth, m_iImageHeight);
} }
@@ -409,11 +409,11 @@ static EffectMode EffectModes[] =
{ {
EffectMode_YUYV422, EffectMode_YUYV422,
}; };
static_assert( ARRAYLEN(EffectModes) == NUM_PixelFormatYCbCr ); static_assert(ARRAYLEN(EffectModes) == NUM_PixelFormatYCbCr);
EffectMode MovieTexture_Generic::GetEffectMode( MovieDecoderPixelFormatYCbCr fmt ) EffectMode MovieTexture_Generic::GetEffectMode(MovieDecoderPixelFormatYCbCr fmt)
{ {
ASSERT( fmt != PixelFormatYCbCr_Invalid ); ASSERT(fmt != PixelFormatYCbCr_Invalid);
return EffectModes[fmt]; return EffectModes[fmt];
} }
@@ -421,28 +421,28 @@ void MovieTexture_Generic::Reload()
{ {
} }
void MovieTexture_Generic::SetPosition(float fSeconds) void MovieTexture_Generic::SetPosition(float seconds)
{ {
// TODO: The only non-zero use case of this function would be practice mode. // TODO: The only non-zero use case of this function would be practice mode.
// Implement this by mathing out fSeconds and frame counts to seek the // Implement this by mathing out fSeconds and frame counts to seek the
// video. // video.
if (fSeconds != 0) if (seconds != 0)
{ {
LOG->Warn("MovieTexture_Generic::SetPosition(%f): non-0 seeking unsupported; ignored", fSeconds); LOG->Warn("MovieTexture_Generic::SetPosition(%f): non-0 seeking unsupported; ignored", seconds);
return; return;
} }
LOG->Trace("Seek to %f", fSeconds); LOG->Trace("Seek to %f", seconds);
m_fClock = 0; clock_ = 0;
m_pDecoder->Rewind(); decoder_->Rewind();
} }
uintptr_t MovieTexture_Generic::GetTexHandle() const uintptr_t MovieTexture_Generic::GetTexHandle() const
{ {
if( m_pRenderTarget != nullptr ) if (render_target_ != nullptr)
return m_pRenderTarget->GetTexHandle(); return render_target_->GetTexHandle();
return m_uTexHandle; return texture_handle_;
} }
/* /*
+18 -18
View File
@@ -25,7 +25,7 @@ class MovieDecoder
public: public:
virtual ~MovieDecoder() { } virtual ~MovieDecoder() { }
virtual RString Open( RString sFile ) = 0; virtual RString Open(RString file) = 0;
virtual void Close() = 0; virtual void Close() = 0;
virtual void Rewind() = 0; virtual void Rewind() = 0;
virtual void Rollover() = 0; virtual void Rollover() = 0;
@@ -41,7 +41,7 @@ public:
/* /*
* Get the currently-decoded frame. * Get the currently-decoded frame.
*/ */
virtual int GetFrame( RageSurface *pOut ) = 0; virtual int GetFrame( RageSurface *surface_out ) = 0;
/* Return the dimensions of the image, in pixels (before aspect ratio /* Return the dimensions of the image, in pixels (before aspect ratio
* adjustments). */ * adjustments). */
@@ -95,41 +95,41 @@ public:
virtual void Reload(); virtual void Reload();
virtual void SetPosition( float fSeconds ); virtual void SetPosition(float seconds);
// UpdateMovie tells the MovieTexture to update the displayed frame based // UpdateMovie tells the MovieTexture to update the displayed frame based
// on fSeconds passed in. (e.g., 5.9 input means show the frame that should // on fSeconds passed in. (e.g., 5.9 input means show the frame that should
// be displayed 5.9 seconds into the movie). // be displayed 5.9 seconds into the movie).
virtual void UpdateMovie( float fSeconds ); virtual void UpdateMovie(float seconds);
virtual void SetPlaybackRate( float fRate ) { m_fRate = fRate; } virtual void SetPlaybackRate(float rate) { rate_ = rate; }
void SetLooping( bool bLooping=true ) { m_bLoop = bLooping; } void SetLooping(bool looping = true) { loop_ = looping; }
uintptr_t GetTexHandle() const; uintptr_t GetTexHandle() const;
static EffectMode GetEffectMode( MovieDecoderPixelFormatYCbCr fmt ); static EffectMode GetEffectMode( MovieDecoderPixelFormatYCbCr fmt );
private: private:
MovieDecoder *m_pDecoder; MovieDecoder *decoder_;
std::unique_ptr<std::thread> decoding_thread; std::unique_ptr<std::thread> decoding_thread_;
float m_fRate; float rate_;
bool m_bLoop; bool loop_;
bool finished_ = false; bool finished_ = false;
// If true, halts all decoding and display. // If true, halts all decoding and display.
bool m_failure = false; bool failure_ = false;
uintptr_t m_uTexHandle; uintptr_t texture_handle_;
RageTextureRenderTarget *m_pRenderTarget; RageTextureRenderTarget *render_target_;
RageTexture *m_pTextureIntermediate; RageTexture * intermediate_texture_;
Sprite *m_pSprite; Sprite *sprite_;
RageSurface *m_pSurface; RageSurface *surface_;
RageTextureLock *m_pTextureLock; RageTextureLock *texture_lock_;
/* The time the movie is actually at: */ /* The time the movie is actually at: */
float m_fClock; float clock_;
void UpdateFrame(); void UpdateFrame();