Avisynth filter won't crash anymore, but shows a bunch of glitches instead, now

Originally committed to SVN as r277.
This commit is contained in:
Rodrigo Braz Monteiro 2006-04-01 12:43:22 +00:00
parent b1f6012762
commit 02cfa685fc
4 changed files with 36 additions and 18 deletions

View file

@ -71,13 +71,14 @@ DrawPRS::~DrawPRS() {
// Get frame // Get frame
PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) { PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) {
// Get frame // Get frame
PVideoFrame avsFrame = child->GetFrame(n,env); //PVideoFrame avsFrame = child->GetFrame(n,env);
PVideoFrame avsFrame = env->NewVideoFrame(vi);
try { try {
// Create the PRSFrame structure // Create the PRSFrame structure
PRSVideoFrame frame; PRSVideoFrame frame;
frame.data[0] = (char*) avsFrame->GetWritePtr(); frame.data[0] = (char*) avsFrame->GetWritePtr();
frame.w = avsFrame->GetRowSize(); frame.w = avsFrame->GetRowSize()/4;
frame.h = avsFrame->GetHeight(); frame.h = avsFrame->GetHeight();
frame.pitch = avsFrame->GetPitch(); frame.pitch = avsFrame->GetPitch();
frame.colorSpace = ColorSpace_RGB32; frame.colorSpace = ColorSpace_RGB32;

View file

@ -65,7 +65,7 @@ PRSDisplay::~PRSDisplay() {
// Write data // Write data
void PRSDisplay::WriteData(std::vector<char> &vec) { void PRSDisplay::WriteData(std::vector<char> &vec) {
// Set length // Set length
unsigned __int32 size = 4 + 4 + 4 + 4 + 2 + 2 + 1 + 1; unsigned __int32 size = 4 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 1 + 1;
vec.resize(size+8); vec.resize(size+8);
size_t pos = 0; size_t pos = 0;
@ -78,6 +78,14 @@ void PRSDisplay::WriteData(std::vector<char> &vec) {
memcpy(&vec[pos],&size,4); memcpy(&vec[pos],&size,4);
pos += 4; pos += 4;
// Write start frame
memcpy(&vec[pos],&startFrame,4);
pos += 4;
// Write end frame
memcpy(&vec[pos],&endFrame,4);
pos += 4;
// Write start time // Write start time
memcpy(&vec[pos],&start,4); memcpy(&vec[pos],&start,4);
pos += 4; pos += 4;
@ -116,39 +124,47 @@ void PRSDisplay::WriteData(std::vector<char> &vec) {
// Read data // Read data
void PRSDisplay::ReadData(std::vector<char> &vec) { void PRSDisplay::ReadData(std::vector<char> &vec) {
// Set length // Set length
unsigned __int32 size = 4 + 4 + 4 + 4 + 2 + 2 + 1 + 1; unsigned __int32 size = 4 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 1 + 1;
if (size != vec.size()) return; if (size != vec.size()) return;
size_t pos = 0; size_t pos = 0;
// Write start time // Read start frame
memcpy(&startFrame,&vec[pos],4);
pos += 4;
// Read end frame
memcpy(&endFrame,&vec[pos],4);
pos += 4;
// Read start time
memcpy(&start,&vec[pos],4); memcpy(&start,&vec[pos],4);
pos += 4; pos += 4;
// Write end time // Read end time
memcpy(&end,&vec[pos],4); memcpy(&end,&vec[pos],4);
pos += 4; pos += 4;
// Write image identifier // Read image identifier
memcpy(&id,&vec[pos],4); memcpy(&id,&vec[pos],4);
pos += 4; pos += 4;
// Write layer // Read layer
memcpy(&layer,&vec[pos],4); memcpy(&layer,&vec[pos],4);
pos += 4; pos += 4;
// Write x // Read x
memcpy(&x,&vec[pos],2); memcpy(&x,&vec[pos],2);
pos += 2; pos += 2;
// Write y // Read y
memcpy(&y,&vec[pos],2); memcpy(&y,&vec[pos],2);
pos += 2; pos += 2;
// Write alpha multiplier // Read alpha multiplier
memcpy(&alpha,&vec[pos],1); memcpy(&alpha,&vec[pos],1);
pos += 1; pos += 1;
// Write blend mode // Read blend mode
memcpy(&blend,&vec[pos],1); memcpy(&blend,&vec[pos],1);
pos += 1; pos += 1;
} }

View file

@ -108,15 +108,16 @@ void PRSImage::ReadData(std::vector<char> &vec) {
memcpy(&id,&vec[pos],4); memcpy(&id,&vec[pos],4);
pos += 4; pos += 4;
// Write image format // Read image format
memcpy(&imageType,&vec[pos],4); memcpy(&imageType,&vec[pos],4);
pos += 4; pos += 4;
// Write data length // Read data length
memcpy(&dataLen,&vec[pos],4); memcpy(&dataLen,&vec[pos],4);
pos += 4; pos += 4;
// Write data // Read data
data = new char[dataLen];
memcpy(data,&vec[pos],dataLen); memcpy(data,&vec[pos],dataLen);
pos += dataLen; pos += dataLen;
} }

View file

@ -85,8 +85,8 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al
// Get boundaries // Get boundaries
int srcBpp = 4; int srcBpp = 4;
int dstBpp = 4; int dstBpp = 4;
int srcRowLen = w * srcBpp; int srcRowLen = pitch;
int dstRowLen = dstFrame->w * dstBpp; int dstRowLen = dstFrame->pitch;
int dstStarty = MAX(0,y); int dstStarty = MAX(0,y);
int dstEndy = MIN(y+h,dstFrame->h); int dstEndy = MIN(y+h,dstFrame->h);
int height = dstEndy - dstStarty; int height = dstEndy - dstStarty;
@ -117,7 +117,7 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al
dc3 = *(dst+3); dc3 = *(dst+3);
// Write colors // Write colors
*dst++ = da; *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;