PDA

View Full Version : Need help debugging a filter


E-Male
29th March 2003, 01:40
sorry, i know many won´t lie kto see topics liek this, but i´m deperate at the moment
i wrote i lil avisynth filter, but it doesn´t work (access violation)
the problem i need it to work in a few hours (17h as total maximum)
it´s a filter that works like a blue screen, just with black
it take 2 clips as aguments, and shows the first, except that it replacec all black in it with pixels at the same place in clip 2 (equal resolution, framerate and lenth should be)

PLEASE someone look at it, i´m sure it´s just one or two newbie mistakes that can easily be corrected

http://e-rels.dyndns.org/bs.cpp

THX a lot
E-Male

p.s. if a filter like this already exists, pleas tell me

sh0dan
29th March 2003, 09:46
The loop should look something like this:

for (int y = 0; y < height; y++) {
for (int x = 0; x < row_size; x+=2) {

black = false;
if ((srcpa[x] == 16) && (srcpa[x+1] == 128))
black = true;

if (!black) {
dstp[x] = srcpa[x];
dstp[x+1] = srcpa[x+1];
} else {
dstp[x] = srcpb[x];
dstp[x+1] = srcpb[x+1];
}
srcpa += src_pitch;
srcpb += src_pitch;
dstp += dst_pitch;
}
}

But I don't know if what it does is correct - it does seem a bit strange to me though. Are you assuming YUY2 as colorspace??

Si
29th March 2003, 11:51
Quick/dirty solution is to maybe do a ConverttoRGB24 before this filter and use this modification of sh0dan's code for your filter :-


for (int y = 0; y < height; y++) {
for (int x = 0; x < row_size; x+=3) {

black = false;
if ((srcpa[x] == 0) && (srcpa[x+1] == 0) && (srcpa[x+2] == 0))
black = true;

if (!black) {
dstp[x] = srcpa[x];
dstp[x+1] = srcpa[x+1];
dstp[x+2] = srcpa[x+2];
} else {
dstp[x] = srcpb[x];
dstp[x+1] = srcpb[x+1];
dstp[x+2] = srcpb[x+2];
}
srcpa += src_pitch;
srcpb += src_pitch;
dstp += dst_pitch;
}
}

regards
Simon

Richard Berg
29th March 2003, 21:09
p.s. if a filter like this already exists, pleas tell me
Look at ColorKeyMask here: http://www.avisynth.org/index.php?page=Layer

E-Male
30th March 2003, 19:31
thx guys
i used layer with brighten for the urgent stuff
i´ll look into finishing the filter later

and yes i assumed yuv