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 // Get frame
PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) { PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) {
// Get frame // Avisynth frame
//PVideoFrame avsFrame = child->GetFrame(n,env); PVideoFrame avsFrame = child->GetFrame(n,env);
PVideoFrame avsFrame = env->NewVideoFrame(vi);
try { try {
// Create the PRSFrame structure // Check if there is anything to be drawn
PRSVideoFrame frame; if (file.HasDataAtFrame(n)) {
frame.data[0] = (char*) avsFrame->GetWritePtr(); // Create the PRSFrame structure
frame.w = avsFrame->GetRowSize()/4; env->MakeWritable(&avsFrame);
frame.h = avsFrame->GetHeight(); PRSVideoFrame frame;
frame.pitch = avsFrame->GetPitch(); frame.data[0] = (char*) avsFrame->GetWritePtr();
frame.colorSpace = ColorSpace_RGB32; frame.w = avsFrame->GetRowSize()/4;
frame.h = avsFrame->GetHeight();
frame.pitch = avsFrame->GetPitch();
frame.colorSpace = ColorSpace_RGB32;
// Draw into the frame // Draw into the frame
file.DrawFrame(n,&frame); file.DrawFrame(n,&frame);
}
} }
// Catch exception // 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 // Gets a PRSImage by its ID, returns NULL if it doesn't exist
PRSImage *PRSFile::GetImageByID(int id) { PRSImage *PRSFile::GetImageByID(int id) {

View File

@ -68,6 +68,7 @@ public:
void Load(std::string path,bool reset=true); void Load(std::string path,bool reset=true);
void GetDisplayBlocksAtFrame(int n,std::vector<PRSDisplay*> &blocks); void GetDisplayBlocksAtFrame(int n,std::vector<PRSDisplay*> &blocks);
bool HasDataAtFrame(int n);
void DrawFrame(int n,PRSVideoFrame *frame); void DrawFrame(int n,PRSVideoFrame *frame);
PRSImage *GetImageByID(int id); 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 // Draw the row
for (int i=0;i<rowLen;i++) { for (int i=0;i<rowLen;i++) {
// Read alpha
a = *src++;
da = *dst;
ia = 255-a;
// Read colors // Read colors
sc1 = *src++; sc1 = *src++;
dc1 = *(dst+1); dc1 = *(dst);
sc2 = *src++; sc2 = *src++;
dc2 = *(dst+2); dc2 = *(dst+1);
sc3 = *src++; sc3 = *src++;
dc3 = *(dst+3); dc3 = *(dst+2);
// Read alpha
a = *src++;
da = *(dst+3);
ia = 255-a;
// Write colors // Write colors
*dst++ = 255-(ia*(255-da)/255);
*dst++ = (sc1*a + dc1*ia)/255; *dst++ = (sc1*a + dc1*ia)/255;
*dst++ = (sc2*a + dc2*ia)/255; *dst++ = (sc2*a + dc2*ia)/255;
*dst++ = (sc3*a + dc3*ia)/255; *dst++ = (sc3*a + dc3*ia)/255;
*dst++ = 255-(ia*(255-da)/255);
} }
} }
} }