From b0afd8659c47fa86b5634d3bd4557d8c9de3992c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 28 Jun 2010 07:39:42 +0000 Subject: [PATCH] Frame data does need to be uploaded to the video card on every change as the subtitles and video frame are not seperate. Originally committed to SVN as r4633. --- aegisub/src/video_context.cpp | 2 +- aegisub/src/video_display.cpp | 72 +++++++++++++++++++---------------- aegisub/src/video_display.h | 3 ++ 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 3818f6c86..bb0d2e385 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -289,7 +289,7 @@ void VideoContext::SetVideo(const wxString &filename) { hasSubtitles = MatroskaWrapper::HasSubtitles(filename); } - UpdateDisplays(true, true); + UpdateDisplays(true); } catch (wxString &e) { diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index ff7abe079..5edf5746d 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -162,6 +162,8 @@ void VideoDisplay::SetFrame(int frameNumber) { VideoContext *context = VideoContext::Get(); ControlSlider->SetValue(frameNumber); + currentFrame = frameNumber; + // Get time for frame { int time = VFR_Output.GetTimeAtFrame(frameNumber, true, true); @@ -203,47 +205,51 @@ void VideoDisplay::SetFrame(int frameNumber) { // Render the new frame if (context->IsLoaded()) { context->GetScriptSize(scriptW, scriptH); - if (!tool.get()) tool.reset(new VisualToolCross(this, video, toolBar)); tool->SetFrame(frameNumber); - AegiVideoFrame frame; - try { - frame = context->GetFrame(currentFrame); - } - catch (const wxChar *err) { - wxLogError( - L"Failed seeking video. The video file may be corrupt or incomplete.\n" - L"Error message reported: %s", - err); - } - catch (...) { - wxLogError( - L"Failed seeking video. The video file may be corrupt or incomplete.\n" - L"No further error message given."); - } - try { - videoOut->UploadFrameData(frame); - } - catch (const VideoOutInitException& err) { - wxLogError( - L"Failed to initialize video display. Closing other running programs and updating your video card drivers may fix this.\n" - L"Error message reported: %s", - err.GetMessage().c_str()); - context->Reset(); - } - catch (const VideoOutRenderException& err) { - wxLogError( - L"Could not upload video frame to graphics card.\n" - L"Error message reported: %s", - err.GetMessage().c_str()); - } + UploadFrameData(); } Render(); +} - currentFrame = frameNumber; +void VideoDisplay::UploadFrameData() { + VideoContext *context = VideoContext::Get(); + AegiVideoFrame frame; + try { + frame = context->GetFrame(currentFrame); + } + catch (const wxChar *err) { + wxLogError( + L"Failed seeking video. The video file may be corrupt or incomplete.\n" + L"Error message reported: %s", + err); + } + catch (...) { + wxLogError( + L"Failed seeking video. The video file may be corrupt or incomplete.\n" + L"No further error message given."); + } + try { + videoOut->UploadFrameData(frame); + } + catch (const VideoOutInitException& err) { + wxLogError( + L"Failed to initialize video display. Closing other running programs and updating your video card drivers may fix this.\n" + L"Error message reported: %s", + err.GetMessage().c_str()); + context->Reset(); + } + catch (const VideoOutRenderException& err) { + wxLogError( + L"Could not upload video frame to graphics card.\n" + L"Error message reported: %s", + err.GetMessage().c_str()); + } } void VideoDisplay::Refresh() { + UploadFrameData(); + if (!tool.get()) tool.reset(new VisualToolCross(this, video, toolBar)); tool->Refresh(); Render(); } diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 0beaf1ba4..73b969613 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -96,6 +96,9 @@ class VideoDisplay: public wxGLCanvas { /// @param alpha The alpha of the mask void DrawOverscanMask(int sizeH, int sizeV, wxColor color, double alpha) const; + /// Upload the image for the current frame to the video card + void UploadFrameData(); + /// @brief Paint event void OnPaint(wxPaintEvent& event); /// @brief Key event handler