View Full Version : Smooth in time and space?
vlad59
30th July 2002, 13:07
Originally posted by bb
Sounds like my question was way too stupid...
(You still didn't explain how you calculate the 1601, but never mind, I know by now that your weight matrix was
1 2 1
2 4 2
1 2 1
)
bb
Oooops sorry, it's Koepi's fault ;) , he make me laught so I only answered to your first question, sorry again.
As I always say, the only stupid questions are those you don't ask.
dividee
30th July 2002, 14:03
I just wanted to tell you that I have a SceneChangeDetector class ready for avisynth. It's not a filter, just an internal class, but it can easily be ripped from avisynth. It's not a very evoluted SCD, it just compares the current frame and the previous one.
In pseudo-code:
return (% of pixels where |p(n)-p(n-1)| > tolerance) > threshold;
That is, two pixels are considered different if their absolute difference is above 'tolerance'. If the total amount of different pixels is above 'treshold', a scene change is detected and it returns true.
It works in YUY2 and RGB32, is MMX optimized and quite fast. In YUY2, you have the option to only compare luma if you want.
I thought it would be better to implement it as a separate class, so any filter could use it and it can be tweaked independently.
Example:
In you constructor:
scd = new SceneChangeDector(child, 40 , 20, false , env);
// clip thresh tol use_chroma
In GetFrame:
scd->detect(n, env)
returns true if frame n is a scene change, else false
you can also call it like that:
scd->detect(frame, n, env)
if you already have a pointer to the current frame.
I think you just need to replace #include "internal.h" by #include "avisynth.h" to use it in a plugin.
I'll test your idea of using a SAD for scene change detection.
vlad59
30th July 2002, 16:55
@Dividee
I'll test it tomorrow (If I have time)
@All
I have a new version of the convolution3D for you to test. Please read the text file included.
The first alpha was purely mathematical so it was full quality. But with this alpha2, my goal was speed, I hope there is no quality issue.
Now the problems I have are :
- on my test vob there is always a little noise around the edges (typically the heads of the caracters)
- With my current algo a white spot surrounded by black ones will remain white (due to Treshold)
- To have better results it could be interesting to lower the weight of the center pixel (just an idea).
- Speed :devil:
@Moderators
I'll try to put this file in a website to avoid using too much bandwidth. But I just hate HTML :p
EDIT : Removed attachment, newer version available
Marc FD
30th July 2002, 18:27
@Dividee
LOL. Don't need it at all i have an advanced motion detector already for CopySame. :devil:
I'm really sorry :( (because i didn't know you were working on it)
@All
Okay, to business : i've tried 4 differents algos today and each time it wasn't good enough :( but finally i had THE idea :D
Here it is : MAM - Motion Adaptive Mixer :devil: + :cool:
What it does : Mix a spatial filtered clip with a temporal filtered clip : spatial in motions areas, and temporal in still area :
The goal is to avoid the defaults of spatial and temporal filtering:
spatial filtering blurs when too aggressive.
temporal filtering "ghosts" when too aggressive.
Using MAM, you can _theorically_ use very aggressives settings because :
- you won't see the blurring of the spatial filtering, because it's moving.
- you won't see the ghosting of the temporal filtering, because it's not moving.
And it is compatible with all the currents and coming spatial and temporal filters :)
To download it, just use the link for my dl site.
(please) TEST IT ! NOW ! ;)
PS : We should rename this thread to : The slow-as-hell smooth in time and/or space :D
(because using _both_ temporal and spatial filtering is not really a way to improve speed...)
Ivion
30th July 2002, 21:37
Ya know, I'dd really like to test it Marc FD, if I could get it. :)
Cuz there's no link on your website and http://ziquash.chez.tiscali.fr/mad.zip doesn't work, at least not for me. Could you please upload it, I wanna test it on my killer Kenshin clip. :p :D
Marc FD
30th July 2002, 22:35
OH SHIT !!!
I worked hard, and finally i forget to upload
too dumb.
thanks Ivion
and it's not MAD but MAM : Motion Adaptive Mixer :cool:
I'd really like feedback on very noisy sources or for HQ
It's really powerfull. I'll use it for all my encodes now :)
If you wanna see the better denoising achived in avisynth :devil:, just test it :)
MoonWalker
30th July 2002, 23:11
I tried to make a quick test of MAM but i couldn't :(
"Avisynt read error : Avisynth : caught an access violation at 0x01161480, attempting to read from 0x044bb000" :confused:
I may be doing something wrong ,cause I am a little sleepy right now.. :rolleyes:
Here is my avs :
LoadPlugin("D:\DivX\GORDIA~1\mpeg2dec.dll")
LoadPlugin("J:\Cnr2.dll")
LoadPlugin("J:\TemporalSoften2.dll")
LoadPlugin("J:\MAM.dll")
LoadPlugin("D:\DivX\GORDIA~1\Avisynth_Spatial.dll")
mpeg2source("J:\Matrix\matrix.d2v")
crop(0,79,718,418)
Temporal=TemporalSoften2(1,4,8).Cnr2()
Spatial=Temporal.SpatialSoftenMMX(1,4,8,false,false,4,4,6,8)
MAM(Temporal,Spatial,4,8,0)
I know there isn't a resizer..I want to see in full size what the filter can do :)
MoonWalker
Ivion
31st July 2002, 00:19
Hummm, it seems that I got the same error, or maybe slighty different. Tough the outcome was the same, we couldn't test the filter. Here's my avs script, generated with the help of gknot (for the auto crop ^.^):
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\decomb.dll")
LoadPlugin("C:\filters\cnr2.dll")
LoadPlugin("C:\filters\smoothhiq.dll")
LoadPlugin("C:\filters\mam.dll")
mpeg2source("C:\tempdvd\test.d2v")
FieldDeinterlace()
crop(11,5,699,568)
s=smoothhiq(7,25,35,192,15)
t=cnr2()
MAM(t,s,2,4,8)
For MAM I just used the default values, so I could see what the impact of the standard settings were. CNR2 is also default as you can see, and for SSHiQ I use the values I normally use on this DVD without denoising. My plan was to see what the outcome of these values was and 'tweak' them, for I believe my SSHiQ settings are too high.
2bad I couldn't test it, plz look into it Marc FD, for this filter -sounds- promising. :D
Marc FD
31st July 2002, 10:58
Strange.. maybe i've made a dumb error (like always)
I will look into it now and test it on 3-4 different sources.
i will release a new version in less than 1 hour :)
@MoonWalker : i would never use SpatialSmootherMMX, it will produce ghosting because there is a temporal filter in it ....
Use sshq or spatialsoften instead :)
EDIT temporal.ssMMX... ARGH you want to kill me. You will spoil everything like this !!!
temporal _should_ be only temporal and spatial _only_ spatial !!!!
Okay let's WORK !!
I'm back in 40-60 min :D
hakko504
31st July 2002, 11:21
Just a thought, but neither Ivion nor MoonWalker is using mod4 resolutions, could this be a source for problems?
Marc FD
31st July 2002, 12:01
Thx hakko, but it's not his one :
i added emms protection and tried !mod4 res and i couldn't reproduce it : in fact you can only have it if you don't trim your clip and encode : Generaly you never check the first frame with VDub, so M.A.M. was searching for the 0-1 frame to check movement...
I've fixed it. added a little buffuring too.
Would be as slow as before because it's the s & t filters who slow the process... :devil:
It _should_ work 100% now :cool:
@Hakko : i think avs is filling the mod4 gap, right ??
because i never check this in my filters :D
PS : this thread could be called : "the slowest encodes of your life" too :)
hakko504
31st July 2002, 12:16
I'm not sure, but AFAIK it will only add an extra pixel if you try to use odd resolution in YUY mode. There might be some differences depending on what version of AVIsynth youare using.
I've also had some problems when GK tried to use crops like the one Ivion used: crop(11,5,699,568). I've found that the safest way of doing thing is make sure all arguments to crop are even and the final resolution is mod4.
Marc FD
31st July 2002, 13:26
I'll not add barriers to my filters, it's not a coder job.
If users have pbs using !mod4 or !even values, they just need to restrict themselves, and everything will work :)
And i never had pbs using !mod4 values, but i always use them when i do a final encode, because XviD is not 100% safe with !mod4 values...
Any feedback on M.A.M. ??
vlad59
31st July 2002, 13:27
New version of convolution3D, here is the changelog :
2002/07/31 Alpha 3 :
- Lots of code cleanup
- removed unneeded emms (for higher speed)
- Now this filter is only 40% slower than TemporalSmoother only
- Added a check for SSE capable CPU only
- Added a check for YUV input only
I'll make a test with Acaila magic script, to compare the results. But now Convolution3d can compete with others scripts.
I'll continue to optimize it, if you see some weakness in the algo feel free to contact me fast if possible (I get back to work monday, so I won't have so many time to work on this filter).
@Dividee
I tried to use your SceneChangeDetector, it works quite good, but in my case it won't be usefull.
It's better for my case to check for each pixel if the temporal informations can be usefull. I've made a global test with your scene change detector and Convolution3D : it's faster but you can see the quality difference
EDIT : corrected some typos
EDIT : removed older version of convolution3D
vlad59
31st July 2002, 13:48
@Marc
I just made a test with MAM and it work great, it passed without any difficulty my torture test scene for any temporal filter (A long fade in from a totally white frame to a dark scene with a lot of detail).
But as soon as I tried to test the speed (Xvid null test) I got an avisynth read error (same error as CopySame), it can be reproduced when you access the frame 0.
Marc FD
31st July 2002, 17:06
you tested with beta1 ??
the beta2 as the first-frame (n=0) bug fix.
EDIT : I'll fix it on CopySame 1.1 too
I' ve uploaded a new version : beta3
What's new :
- More accurate
- Take chroma in consideration
- Mode selection : you can choose if you want to avoid ghosting or blurring in priority.
I've done my job. :cool:
I'll wait tests to make more improvements
vlad59
31st July 2002, 17:19
Nop I was testing with beta2 on a full size DVD (720*576) and it still crash.
I just downloaded your beta3 but the readme still talks about beta 2 ???
Marc FD
31st July 2002, 17:23
i've some pbs to update everything because i update too much and too fast :(
i don't see how it could crash...
I will get a serious look at it now.
Koepi
31st July 2002, 17:26
XviD 0 - test speed is buggy, I wouldn't use it... :)
Regards,
Koepi
vlad59
31st July 2002, 17:36
@Marc
Try to debug with VC++, dividee explain very clearly (thanks again) how to do this.
@Koepi
is it really ??
In fact, I don't really care ;) , I just use it before releasing a filter to see if it works correctly (just one or two second and it never crashed).
I'll make a first pass from now to be absolutly sure, thanks for the info.
MoonWalker
31st July 2002, 19:15
I have done a very very very very(ok you got the point :)) quick test...
My avs :
LoadPlugin("D:\DivX\GORDIA~1\mpeg2dec.dll")
LoadPlugin("J:\SmoothHiQ.dll")
#LoadPlugin("J:\Cnr2.dll")
LoadPlugin("J:\TemporalSoften2.dll")
LoadPlugin("J:\MAM.dll")
mpeg2source("J:\Matrix\matrix.d2v")
crop(0,79,718,418)
Temporal=TemporalSoften2(1,4,8)
Spatial=Temporal.SmoothHiQ(3,25,10,192,3)
MAM(Temporal,Spatial,4,8,0,2)
I attach an image..Left part the MAM avs, right the original..Less noise but some ghosting..
And the weird(this is for you MarcFD :) )..When I add Cnr2() in my avs I get an error message :
"Caught an access violation at 0x00fa1443, attempting to write to 0x00000000"
I don't know if my avs is 100% correct..
MoonWalker
P.S To see the image a mod must accept it..
Marc FD
31st July 2002, 19:31
Really, i don't see what's your problem...
I tested it with :
sshq+ss+unfilter
ts+ts2+cnr2
on a DVD and a DivX ( :rolleyes: ) source
with/without :
(even)crop,trim,resize,mod4 res, ect...
and it never crashed !!
NEVER !!
How do you want me to correct a bug i can't reproduce !!
@moonwalker
Try cnr2.1 please.
I've made somes corrections. maybe i corrected this bug ?
@ALL
I've uploaded M.A.M. beta4 . hope it would work for you too :D
@Koepi
I've made some tests,and it seems that MA gives better results than MC because MC create noise...
So you will gain nothing with a temporal MC filter :(
you can always try M.A.M. on your problematic source ;)
Koepi
31st July 2002, 20:09
@Koepi
is it really ??
In fact, I don't really care ;) , I just use it before releasing a filter to see if it works correctly (just one or two second and it never crashed).
I'll make a first pass from now to be absolutly sure, thanks for the info.
Uh, if it doesn't crash on you, it's ok. It just gets broken every now-and-then and I didn't really care about that, and just in case if it doesn't work, try a 1pass ;)
@Koepi
I've made some tests,and it seems that MA gives better results than MC because MC create noise...
So you will gain nothing with a temporal MC filter
you can always try M.A.M. on your problematic source
Hehe, I didn't mean it this way, motion-aware is good for starters as well. I think we really need to implement that into XviD as there we know where one pixel ends up (or a MB) and thus can just interpolate between old and new MB.
I thought about something like this. If you have really new regions then (=kblk in XviD), you'd need a spatial smoother, for the rest it's "easy" to do a temporal smooth.
I hope you get the idea behind this ;)
Regards,
Koepi
Marc FD
31st July 2002, 21:55
I see. filtering in the codec itself.
That's exactly what DivX denoise is doing.
but the big probem is that you can't check quality because the output is encoded then....
sure that MC filtering in XviD should be easy to do...
Maccara
31st July 2002, 22:28
Originally posted by MoonWalker
I have done a very very very very(ok you got the point :)) quick test...
My avs :
Temporal=TemporalSoften2(1,4,8)
Spatial=Temporal.SmoothHiQ(3,25,10,192,3)
MAM(Temporal,Spatial,4,8,0,2)
I attach an image..Left part the MAM avs, right the original..Less noise but some ghosting..
@Moonwalker
Why are you using Spatial=Temporal.[] in your testing? Isn't this exactly what causes the ghosting since MAM is supposed to take care of that for you? (especially since you're using mode 2)
Or have I understood completely wrong what is to be gained with this filter?
Please try Spatial=SmoothHiQ(3,25,10,192,3) in place of your original line and compare the results. I did get very good results with that method myself.
Also, cnr2 is acting strangely sometimes, as you said. It seems that with some combinations it blokes out sometimes. I noticed, that if I re-arranged the filter order for cnr2 it worked fine. (can't see why this would make a difference) (can't remember what filters I was using at the time or which order ;)
Rgds,
Maccara
pandv
31st July 2002, 22:36
If you have really new regions then (=kblk in XviD), you'd need a spatial smoother, for the rest it's "easy" to do a temporal smooth.
Another (bad?) suggestion.
This information, isn't in the mvhints first pass created file?. Maybe a filter can use this file (if present) to apply one or another method.
pandv
MoonWalker
31st July 2002, 22:50
@MarcFD
Sorry if I upset you.Didn't ment too :rolleyes:
It was my falt...Tha avs was wrong..I had joined the spatial with the temporal(BTW Thanks Maccara)..Now it works even with Cnr2()...
I will do some test with this avs :
LoadPlugin("D:\DivX\GORDIA~1\mpeg2dec.dll")
LoadPlugin("J:\SmoothHiQ.dll")
LoadPlugin("J:\Cnr2.dll")
LoadPlugin("J:\TemporalSoften2.dll")
LoadPlugin("J:\MAM.dll")
mpeg2source("J:\Matrix\matrix.d2v")
crop(0,79,718,418)
Temporal=TemporalSoften2(1,4,8).Cnr2()
Spatial=SmoothHiQ(3,25,10,192,3)
MAM(Temporal,Spatial,4,8,0,2)
MoonWalker
Ivion
31st July 2002, 23:17
Sorry that I haven't been around to test your filter, as I read the reply's and see the screenshots it seems that it the filter is very capable of doing what it's meant to do. :D Good Work Marc FD! :)
As for me, I won't be testing this filter untill somewhere tomorrow evening (in Holland that is [GMT+1]), for I'm currently visiting my uncle in Belgium. :D Hope to test it soon.
Keep up the good work. :)
Marc FD
31st July 2002, 23:33
Like trbarry pointed it out, Cnr2.0 bugs might come from an ommited emms in an avisynth resizer. I added emms protection in Cnr2.1, so please test again and try to crash it :D (i think it's easy ;) )
EDIT : I think it's something else but Cnr2.1 should work :)
EDIT : seems like M.A.M. beta4 work well for everyone, right ?
Maccara
1st August 2002, 07:48
EDIT : I think it's something else but Cnr2.1 should work :)
Yup, working ok with my tests so far. (bicubic resize caused some problems earlier with cnr2)
EDIT : seems like M.A.M. beta4 work well for everyone, right ?
Working like a charm for me. (slow as hell, though :D
Keep up the good work!
Rgds,
Maccara
vlad59
1st August 2002, 08:06
It seems that I'm the only one having problems with MAM.
What version of avisynth are you using ??
@bb
have you tested my latest convolution3d ?
@vlad59:
No, not yet, sorry. Maybe this evening, but I'll do some extensive testing this weekend for sure.
I had an idea of setting the weights of the 3D matrix according to the square of the distance to the center pixel, but I have to think this over.
bb
sh0dan
1st August 2002, 09:05
@Marc FD
Originally posted by Marc FD
@Dividee
LOL. Don't need it at all i have an advanced motion detector already for CopySame. :devil:
I'm really sorry :( (because i didn't know you were working on it)
You should still have a look at it, and perhaps even use it. From what I can see (without any sources), your algorithms are quite different.
Scene change detection can be used to avoid temporal ghosting. When a scene change occurs, it doesn't necessary mean, that the ENTIRE screen changes (luma dn chroma-wise), and therefore you'll get temporal ghosting in "almost identical" cases. So when dividee's scene-change detector tells you there is a scene change, you should only use spatial-smoothing, no matter what the pixel based check tells you.
On another matter - are you interested in an MMX-optimized CNR2 - the optimizations are fairly obvious, and should give a nice performance boost.
Ivion
1st August 2002, 15:40
Well, I've got a problem with the current MAM filter, for if I use SmothHiQ in conjunction with MAM it says something like: 'Invalid parameters for function SmoothHiQ'. But if I use SmoothHiQ 'alone' (thus without MAM) it works flawless, here is my script:
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\filters\mam.dll")
LoadPlugin("C:\filters\temporalsoften2.dll")
LoadPlugin("C:\filters\cnr2.dll")
LoadPlugin("C:\filters\smoothhiq.dll")
s=SmoothHiQ(3,25,10,192,3)
t=temporalsoften2(1,4,8).cnr2()
source=mpeg2source("C:\tempdvd\lotr\lotr.d2v").crop(0,78,718,418)
movie=source.trim(0,245536).MAM(t,s,4,8,6,2).BicubicResize(704,288,0,0.5)
credits=source.trim(245537,0).temporalsmoother(10).BilinearResize(704,288)
Return movie+credits
If anyone has a idea how this problem can be resolved, please tell me, I wanna test this filter! :D
BTW: SmoothHiq worked flawless with the MAM beta version 2 (latest version I tested), so it's a recent problem.
dividee
1st August 2002, 15:53
Your syntax is wrong. It's funny, a bit like if MAM could take functional arguments. Try this one:
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\filters\mam.dll")
LoadPlugin("C:\filters\temporalsoften2.dll")
LoadPlugin("C:\filters\cnr2.dll")
LoadPlugin("C:\filters\smoothhiq.dll")
source=mpeg2source("C:\tempdvd\lotr\lotr.d2v").crop(0,78,718,418)
movie=source.trim(0,245536)
s=movie.SmoothHiQ(3,25,10,192,3)
t=movie.temporalsoften2(1,4,8).cnr2()
movie=MAM(t,s,4,8,6,2).BicubicResize(704,288,0,0.5)
credits=source.trim(245537,0).temporalsmoother(10).BilinearResize(704,288)
Return movie+credits
Marc FD
1st August 2002, 16:20
@ivion
?? i really don't see how your script could work ??
keep in mind all filters need an implicit clip arg.
@ALL
I founded it !!
the ugly bad first-frame bug :devil: in all my filters
i will correct it in cnr2.2 / MAM beta5 / CopySame 1.1
@Dividee
you've added a piece of code in avisynth.cpp for memory buffer size, right ? Is the buffer still @5MB or is it @1/3 max memory now ??
dividee
1st August 2002, 17:02
Default is still 5MB. You can change the value with the SetMemoryMax filter. Maybe we should change the default? 5MB is not much.
Marc FD
1st August 2002, 17:13
@ Shodan
I think optimising Cnr2 is not very easy.
I don't see why using MMX could speed it up, because of the lookup tables : you can't have always cache-hits on a random seek on 3 tables with 512 values ??
I would try this myself when i would have time :)
and my Motion Detection algo don't need a scene detector,
because if the scene change M.A.M. would use spatial filtering on the whole image already :D
@All
I've upload M.A.M. beta5
it should not bug at first frame now :cool:
@Dividee
you think adding a SetMemoryMax(64) line in a script for exemple could speed up avisynth ??
vlad59
1st August 2002, 17:23
@Shodan
In fact I agree with Marc, I think it's better to use Temporal filtering when it's possible and to only use spatial filtering when you have no other choice (moving object, partial scene change).
I'm currently adding this to convolution3d to avoid using previous and next frame when it's not needed. I've no working filter to test now (perhaps tonight) but I think it's better to check pixel per pixel if there is movement to choose between spatial and temporal.
I'll let you know, I hope I won't be wrong ;) :D ;) :D
Marc FD
1st August 2002, 17:36
@vlad
are M.A.M. and CopySame working for you know ?
To discover the bug i had to go to frame 2 and the to return to frame 0. weird ...
EDIT : If s.o. as pbs with CopySame like vlad, i would attach the last beta bin. in the CopySame thread. Just ask.
vlad59
1st August 2002, 17:37
@Marc
I got your mail, I'll finish some improvements in Convolution3d and I'll test it
dividee
1st August 2002, 17:51
@Sh0dan
I'm curious about those 'obvious' MMX optimizations. I can't see how lookups can be parallelized. I've done it once for TemporalSoften: I had a lookup table with 16 entries and joined 4 of them to create a big lookup table with 16^4=65536 entries. But it doesn't work here: lookup tables are much too big.
@Marc
SetMemoryMax: It can speed things up, it depends on the script. For memory hungry scripts, a too small value (such as the default 5MB) won't crash since it's not an hard limit: avisynth can use more memory if needed, but the frame cache will become useless and that can slow it down a lot.
May I ask you what was exactly this first frame bug? Calling MakeWritable is not necessary after NewVideoFrame (although it doesn't hurt). Was it the test (!pre) ? I was thinking that a PVideoFrame was initialised to NULL upon creation. Isn't the constructor called for an object contained in another object when the cointaining object is dynamically created ?
vlad59
1st August 2002, 17:55
Originally posted by bb
@vlad59:
No, not yet, sorry. Maybe this evening, but I'll do some extensive testing this weekend for sure.
I had an idea of setting the weights of the 3D matrix according to the square of the distance to the center pixel, but I have to think this over.
bb
I'll try to make a filter with custom weight matrix tomorrow, it'll be slow but so you can test and find the best values.
As soon as we have a working matrix, I can try to optimize it.
@vlad59:
Great. I'll test it this weekend. Could you please provide a short parameter description?
bb
Marc FD
1st August 2002, 18:18
@Dividee
shit i don't remember. maybe the source is not the last build.
I know i founded how to crash it and small changes corrected it...but i can remember if i tested it definitively..
makewritable should be out of the IF statemement. it seems that the buffer frame need makewritable at each frame..and need to be initialized before using it. (!pre) is not neccessary because even if the buffer frame is initialized it seems that it's uninitialized when i jump to a frame...very strange. i remember there was 2 bugs too.
maybe giving the buffer frame in return value of GetFrame is not a good idea. it was a way to optimize it...
@ALL
but it should work now :confused: ...
dividee
1st August 2002, 18:38
maybe giving the buffer frame in return value of GetFrame is not a good idea. it was a way to optimize it...
Forgot about that. As long as you keep the buffer for yourself you don't need to call MakeWritable. But indeed in your cause you have to call MakeWritable for each frame.
sh0dan
1st August 2002, 20:00
Ok - dropped the idea, but still managed to squeeze quite a lot out of the C algorith. try this:
PVideoFrame __stdcall Cnr2::GetFrame(int n, IScriptEnvironment* env) {
if (lastf==(-666)) { env->ThrowError("Cnr2Ex : Mode should be -1,0,1,2,or 3"); }
PVideoFrame src = child->GetFrame(n, env);
if (!pre) { pre = env->NewVideoFrame(vi); }
PVideoFrame src2;
if ((lastf+1!=n)&&(n>0)) {
src2 = child->GetFrame(n-1, env);
} else {
src2=src;
}
const unsigned char *srcp = src->GetReadPtr();
const unsigned char *srcp2 = src2->GetReadPtr();
unsigned char *prep = pre->GetWritePtr();
for (int fy = 0; fy < src->GetHeight(); fy++) {
for (int x = 0; x < src->GetRowSize(); x+=4) {
int u = srcp[x+1];
int v = srcp[x+3];
int pu = srcp2[x+1];
int pv = srcp2[x+3];
const signed int ydiff = lt[256 + (((srcp[x+0]+srcp[x+2]) - (srcp2[x+0]+srcp2[x+2]))>>1)];
const int chroma1_ratio = (ydiff * ut[(u - pu)+256]);
const int chroma2_ratio = (ydiff * vt[(v - pv)+256]);
u = (0x8000 + chroma1_ratio * (pu-0x80) + (65536 - chroma1_ratio) * (u-0x80))>>16;
v = (0x8000 + chroma2_ratio * (pv-0x80) + (65536 - chroma2_ratio) * (v-0x80))>>16;
prep[x+0] = srcp[x+0];
prep[x+2] = srcp[x+2];
prep[x+1] = u+0x80;
prep[x+3] = v+0x80;
}
srcp += src->GetPitch();
prep += pre->GetPitch();
}
lastf = n;
return pre;
}
Does the same as 2.1, but is MUCH faster. (Eliminated much redundancy and the BitBlt). (Sorry the indentation look like crap here :( )
It's a really great filter! It does its job very well!
Ivion
1st August 2002, 20:29
*Reading dividee's and Marc FD's replies*
Damn, *hits himself twice* how could I be so stupid! I knew I shouldn't do doing so many complicated things, seems I still need to learn alot more about AviSynth :), thx for the solution!
/me hits himself a couple more times while saying: 'I don't have to be so stupid and irritate other people and waste their time while they could improve their filters instead of solving my problems.' :p ;)
sh0dan
1st August 2002, 20:39
Originally posted by Ivion
/me hits himself a couple more times while saying: 'I don't have to be so stupid and irritate other people and waste their time while they could improve their filters instead of solving my problems.' :p ;)
:) Well - we all make mistakes - and as long as nobody got hurt, I guess you're forgiven. We're all just here for the experience! :)
[Sentimental mode off - Well, I'm off to bed!]
PS. Cr*p! - who am I kidding - we're all just in this for the money and the chicks? :D
Ivion
1st August 2002, 21:00
Originally posted by sh0dan
:) Well - we all make mistakes - and as long as nobody got hurt, I guess you're forgiven. We're all just here for the experience! :)
[Sentimental mode off - Well, I'm off to bed!]
PS. Cr*p! - who am I kidding - we're all just in this for the money and the chicks? :D
We're in this for the money and chicks? Why didn't anyone tell me! :p If I knew that sooner, who would know how much I would improved myself ;). Ahhhhh......who am I kiddin', well, back to work (testing, I like testing..... ^.^), see if I can do it. :)
BTW: Thanks for forgiving me sh0dan-kun, arigatou. *Hugs sh0dan* ;) :p
Hey, it seems that the script you gave me, dividee, also doesn't work, now it says MAM has invalid arguments. I also tried a few variations of your script and they gave the same error. :confused:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.