Few more changes, still very glitchy

Originally committed to SVN as r278.
This commit is contained in:
Rodrigo Braz Monteiro 2006-04-01 12:53:40 +00:00
parent 02cfa685fc
commit ba2af9505e
4 changed files with 44 additions and 21 deletions

View File

@ -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

View File

@ -287,6 +287,25 @@ void PRSFile::GetDisplayBlocksAtFrame(int n,std::vector<PRSDisplay*> &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<PRSEntry*>::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) {

View File

@ -68,6 +68,7 @@ public:
void Load(std::string path,bool reset=true);
void GetDisplayBlocksAtFrame(int n,std::vector<PRSDisplay*> &blocks);
bool HasDataAtFrame(int n);
void DrawFrame(int n,PRSVideoFrame *frame);
PRSImage *GetImageByID(int id);

View File

@ -103,24 +103,24 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al
// Draw the row
for (int i=0;i<rowLen;i++) {
// Read alpha
a = *src++;
da = *dst;
ia = 255-a;
// Read colors
sc1 = *src++;
dc1 = *(dst+1);
dc1 = *(dst);
sc2 = *src++;
dc2 = *(dst+2);
dc2 = *(dst+1);
sc3 = *src++;
dc3 = *(dst+3);
dc3 = *(dst+2);
// Read alpha
a = *src++;
da = *(dst+3);
ia = 255-a;
// Write colors
*dst++ = 255-(ia*(255-da)/255);
*dst++ = (sc1*a + dc1*ia)/255;
*dst++ = (sc2*a + dc2*ia)/255;
*dst++ = (sc3*a + dc3*ia)/255;
*dst++ = 255-(ia*(255-da)/255);
}
}
}