From ba2af9505ed82b2e73d1763a48307b124d8dd376 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 1 Apr 2006 12:53:40 +0000 Subject: [PATCH] Few more changes, still very glitchy Originally committed to SVN as r278. --- avisynth_prs/draw_prs.cpp | 27 +++++++++++++++------------ prs/prs_file.cpp | 19 +++++++++++++++++++ prs/prs_file.h | 1 + prs/prs_video_frame.cpp | 18 +++++++++--------- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/avisynth_prs/draw_prs.cpp b/avisynth_prs/draw_prs.cpp index 5dd24e056..2a8e8d61e 100644 --- a/avisynth_prs/draw_prs.cpp +++ b/avisynth_prs/draw_prs.cpp @@ -70,21 +70,24 @@ DrawPRS::~DrawPRS() { ///////////// // Get frame PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) { - // Get frame - //PVideoFrame avsFrame = child->GetFrame(n,env); - PVideoFrame avsFrame = env->NewVideoFrame(vi); + // Avisynth frame + PVideoFrame avsFrame = child->GetFrame(n,env); try { - // Create the PRSFrame structure - PRSVideoFrame frame; - frame.data[0] = (char*) avsFrame->GetWritePtr(); - frame.w = avsFrame->GetRowSize()/4; - frame.h = avsFrame->GetHeight(); - frame.pitch = avsFrame->GetPitch(); - frame.colorSpace = ColorSpace_RGB32; + // Check if there is anything to be drawn + if (file.HasDataAtFrame(n)) { + // Create the PRSFrame structure + env->MakeWritable(&avsFrame); + PRSVideoFrame frame; + frame.data[0] = (char*) avsFrame->GetWritePtr(); + frame.w = avsFrame->GetRowSize()/4; + frame.h = avsFrame->GetHeight(); + frame.pitch = avsFrame->GetPitch(); + frame.colorSpace = ColorSpace_RGB32; - // Draw into the frame - file.DrawFrame(n,&frame); + // Draw into the frame + file.DrawFrame(n,&frame); + } } // Catch exception diff --git a/prs/prs_file.cpp b/prs/prs_file.cpp index 8ee97dc33..c5698eed9 100644 --- a/prs/prs_file.cpp +++ b/prs/prs_file.cpp @@ -287,6 +287,25 @@ void PRSFile::GetDisplayBlocksAtFrame(int n,std::vector &blocks) { } +//////////////////////////////////////////// +// Checks if there is anything at the frame +bool PRSFile::HasDataAtFrame(int n) { + // Find all blocks that match + unsigned int fn = n; + std::list::iterator cur; + PRSDisplay *display; + for (cur=entryList.begin();cur!=entryList.end();cur++) { + display = PRSEntry::GetDisplay(*cur); + if (display) { + if (display->startFrame <= fn && display->endFrame >= fn) { + return true; + } + } + } + return false; +} + + /////////////////////////////////////////////////////////////// // Gets a PRSImage by its ID, returns NULL if it doesn't exist PRSImage *PRSFile::GetImageByID(int id) { diff --git a/prs/prs_file.h b/prs/prs_file.h index 96a16e505..5360cbd1a 100644 --- a/prs/prs_file.h +++ b/prs/prs_file.h @@ -68,6 +68,7 @@ public: void Load(std::string path,bool reset=true); void GetDisplayBlocksAtFrame(int n,std::vector &blocks); + bool HasDataAtFrame(int n); void DrawFrame(int n,PRSVideoFrame *frame); PRSImage *GetImageByID(int id); diff --git a/prs/prs_video_frame.cpp b/prs/prs_video_frame.cpp index 172a609e5..7d0518b6b 100644 --- a/prs/prs_video_frame.cpp +++ b/prs/prs_video_frame.cpp @@ -103,24 +103,24 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al // Draw the row for (int i=0;i