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
PVideoFrame __stdcall DrawPRS::GetFrame(int n, IScriptEnvironment* env) {
// Get frame
PVideoFrame avsFrame = child->GetFrame(n,env);
//PVideoFrame avsFrame = child->GetFrame(n,env);
PVideoFrame avsFrame = env->NewVideoFrame(vi);
try {
// Create the PRSFrame structure
PRSVideoFrame frame;
frame.data[0] = (char*) avsFrame->GetWritePtr();
frame.w = avsFrame->GetRowSize();
frame.w = avsFrame->GetRowSize()/4;
frame.h = avsFrame->GetHeight();
frame.pitch = avsFrame->GetPitch();
frame.colorSpace = ColorSpace_RGB32;

View File

@ -65,7 +65,7 @@ PRSDisplay::~PRSDisplay() {
// Write data
void PRSDisplay::WriteData(std::vector<char> &vec) {
// 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);
size_t pos = 0;
@ -78,6 +78,14 @@ void PRSDisplay::WriteData(std::vector<char> &vec) {
memcpy(&vec[pos],&size,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
memcpy(&vec[pos],&start,4);
pos += 4;
@ -116,39 +124,47 @@ void PRSDisplay::WriteData(std::vector<char> &vec) {
// Read data
void PRSDisplay::ReadData(std::vector<char> &vec) {
// 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;
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);
pos += 4;
// Write end time
// Read end time
memcpy(&end,&vec[pos],4);
pos += 4;
// Write image identifier
// Read image identifier
memcpy(&id,&vec[pos],4);
pos += 4;
// Write layer
// Read layer
memcpy(&layer,&vec[pos],4);
pos += 4;
// Write x
// Read x
memcpy(&x,&vec[pos],2);
pos += 2;
// Write y
// Read y
memcpy(&y,&vec[pos],2);
pos += 2;
// Write alpha multiplier
// Read alpha multiplier
memcpy(&alpha,&vec[pos],1);
pos += 1;
// Write blend mode
// Read blend mode
memcpy(&blend,&vec[pos],1);
pos += 1;
}

View File

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

View File

@ -85,8 +85,8 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al
// Get boundaries
int srcBpp = 4;
int dstBpp = 4;
int srcRowLen = w * srcBpp;
int dstRowLen = dstFrame->w * dstBpp;
int srcRowLen = pitch;
int dstRowLen = dstFrame->pitch;
int dstStarty = MAX(0,y);
int dstEndy = MIN(y+h,dstFrame->h);
int height = dstEndy - dstStarty;
@ -117,7 +117,7 @@ void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char al
dc3 = *(dst+3);
// Write colors
*dst++ = da;
*dst++ = 255-(ia*(255-da)/255);
*dst++ = (sc1*a + dc1*ia)/255;
*dst++ = (sc2*a + dc2*ia)/255;
*dst++ = (sc3*a + dc3*ia)/255;