PDA

View Full Version : QMF & FMF v1.5 b1 (page 3)


HomiE FR
21st June 2003, 11:27
Hi all,

I've played a little (maybe more than that in fact) with the "new" built-in conditional functions inside Avisynth 2.5.1 and later. This script is one of the four different scripts that I made which use these conditional functions: the purpose is very simple, but it proved its strength on the different test clips that I gave it.

What does it do?
It splits the provided video clip into 3 motion levels: low motion, medium motion and high motion, using a (very) simple motion estimation algorithm. Then, it applies different user-defined filters for each motion level, allowing you to do some adaptive smoothing/sharpening (or anything else you want).

Features:
+ adaptive filtering according to motion
+ 3 motions levels (low, medium and high) for 3 different user-defined filters
+ built-in scene change detection algorithm for better motion estimation
+ use of chroma channels for better motion estimation (optional)
+ many user-defined parameters for tweaking
+ detailed debug information display for better tweaking experience (optional)
- YV12 input only! (use ConvertToYV12() when needed)
- Avisynth 2.5.2 or later recommended!

How can I use it?
You just need to define 3 user-defined at the beginning of the script, called Low_Motion_Filter, Medium_Motion_Filter and High_Motion_Filter, which you put your selected filters for each motion level in. Look at the examples provided with the release if needed.

What's this debug thing?
I have a few things to add about debug=true (a parameter which displays debug information over the video clip). When using debug=true, you should always look at the video clip (for instance inside VirtualDubMod) sequentially and in the right order (from past to future). Why? Because my scene change detection doesn't work on a 1-frame basis, but on a 5-frame basis. I won't go into the details here but if you want any information I'll be happy to answer.

What's next?
I've coded 3 other scripts which use the conditional functions:
- Continuous Motion Filter: this script is an adaptive motion filter, but with only one motion level. Inside this motion level, limited by min and max threshold values (user defined parameters), the parameters used inside the filters are scaled linearly on each frame between min and max values (user-defined parameters).
- Full Motion Filter: this script is the "son" of QMF and CMF. It uses 3 motion levels (like QMF), and inside these 3 motion levels the parameters used inside the filters are scaled linearly on each frame (like CMF).
- Scene Change Cleaner: this script is only designed for bad PAL anime sources, and its purpose is to clean the bad blended scene changes that occur all the time. It works quite good.
If someone wants to see one of these filters, feel free to ask for it. :)

Quantified Motion Filter v1.3 (http://perso.wanadoo.fr/homie.fr/qmf-1.3.zip) (21/06/2003)

I'd be happy to have some feedback if anyone is interested. Thanks in advance.

HomiE FR

Si
21st June 2003, 11:40
Hi HomiE
In your readme you've copyrighted your script and said not to steal it. :confused:

Most of us here release under the GPL (or completely non-copyright)and let people modify our efforts so that the whole community can benefit.

Maybe you'd consider changing your conditions ? :)

regards
Simon

HomiE FR
21st June 2003, 12:46
When I say steal I don't mind if people do some copy/paste (really) I just would like a word of credits if possible. :)
I'm no pro in the domain, but everyone can modify it (I don't know if the credits part is too much...). I wouldn't like to be seen as a guy who wants to copyright things which are so simple (and even if I wanted it, which is not the case, I wouldn't be able so)

Thanks for pointing this out, of course everyone can play with the script (which is well commented I think).

Edit : I've corrected the readme file. The "new" version is online.

iago
22nd June 2003, 00:43
Very useful! Thanks a lot! :)

I've been playing with it for some time now and trying to configure it to exactly suit my taste ;).

(For high motion -> UnFilter(-100,-100) for instance! :D)

avih
22nd June 2003, 00:55
that's a very good idea, however, i wonder how does it handle the transitions (didn't try your script yet). switching filters bay result in harsh quality differences. how about merging the transitions within about 5-10 frames using variable alpha transpatencies? (is that possible at all?)

cheers for the script.

bilu
22nd June 2003, 03:39
Imagine you do a Telecide or Uncomb over a telecined movie. You would get duplicates every five frames, even in high-motion scenes.
I presume this would be treated as low-motion...

Would it be possible for you to add a "scene protect threshold", i.e. that would treat the movie like high-motion until a defined number of low-motion scenes passes through?

This is what I have in mind:
http://forum.doom9.org/showthread.php?s=&postid=332822#post332822


Thanks in advance,
Bilu

HomiE FR
22nd June 2003, 07:05
First of all, thanks for the replies/feedback!

iago : I hope the whole debug thing is helping you in tweaking the script. :)

avih : This idea about transparencies seems really interesting. But there is another way to handle it I think (at least in some way) : I coded another script which is called CMF and which is quickly described in the first post. It uses only one motion level and adjusts parameters that you set (min/max value for min/max difference between frames) linearly. This way there is no transition anymore.

But this supposes that you use the same filters for the whole motion range, that's why your idea about transparency should be great in every other case (like this script). I'll look into that! Thanks.

bilu : Duplicates are not a real problem, because this script uses differences from past and future to compute its average difference/motion level (2 frames in the past and 2 frames in the future max). You can play with temporal_influence (from 0 to 100) to adjust the past and future frames difference ratios. But I could do what you want I think, I'll have a look at it.
(I'll check your topic about automatic decombing too. :) )

iago
23rd June 2003, 00:11
Originally posted by HomiE FR
iago : I hope the whole debug thing is helping you in tweaking the script. :)Sure it is. And imho the three motion levels are pretty well configured. Also, though I agree with avih that sharp transitions between filters and/or aggressive parameters may cause certain problems, in my first full encode with the script using my own tweaked filters/settings I haven't encountered such a problem (yet ;)).

Good work! Thanks again! :)

HomiE FR
23rd June 2003, 08:22
iago : I haven't seen these sharp transition problems yet either. But I'm trying to figure out how to do it better, although the problem is that transparencies need RGB32 (and the conditional functions need YV12). So it is not a real problem but it implies some color space conversions inside the script, which is not particularly good.
But I'll try to do something so that we can decide whether it is worth the conversions or not.

Thanks for using the script too. :)

yaz
23rd June 2003, 10:52
@HomiE FR
xxllent work!!! as my system is not fully sse compliant, i had to find sg of that kind. i did & it did worth to do so! man, it's damn good! (anyway, u should mention this compliancy issue in the readme)

some clues:
in this form, it's a thresholded filter. as the debug part is also very good it's not too hard to tweak. anyway, have u ever thought of adaptive thresholding? i mean, deriving the actual threshold from the previous difference(s). such algos were extensively used in the divx3 times & they work(ed) pretty good. imho, the best one is implemented in nandub. if anybody were interested, we'd go into details.
as an improvement; filter strength would be (should be?) derived directly from the motion output. say, higher motion -> lower temp & higher spat filter strength. or doing blurring/sharpening according to motion. i.e. sharpen, unfilter, asharp can be tuned very easily.

@iago
happy to see ya again!
... transition problems wont arise as long as motion thresholds are correct. i see crossfades more problematic. i haven't been able to tune these scenes correctly. even not with this cute filter.
... be careful with unfilter (& with other blur/sharpen tricks) i've just realized that ur earlier intentions were true (in that monstruos thread, d'ya remember? :-) they modify the yuv values, sometimes very heavily, & if so they can produce very strange effects. just a quick reflection to unfilter(-100,-100).

the bests
y

HomiE FR
23rd June 2003, 13:12
yaz : I didn't know there was a problem with SSE compliance. Thanks for pointing this out.

About adaptive thresholding and filter strength directly derived from motion, I already did a script which does (at least in some way) that : Continuous Motion Filter (I can give you a working version if you want).

In that filter, there is only one motion filter function, in which you put lines such as :
c = FluxSmooth(c,param1,param2)
Then when you call CMF (the main function), you use some parameters to define the min and max values of the parameters you used in the motion filter function. For instance, param1_min=0, param1_max=14. You also define min and max motion levels the same way, and scene change thresholds the same way too.

Then the parameters and the sc threshold are scaled linearly between their min and max values according to current motion. So I guess it's a sort of adaptive thresholding. I could also do something where (only for sc threshold) the user doesn't have to enter any min and max value but I believe people like to tweak things to their bests.

But if you have an idea on how to improve it, feel free to share your knowledge! :)

HomiE FR

iago
23rd June 2003, 14:31
Hello yaz,

Yeah, it's nice to meet you again. And, sure, how can I forget that monster thread! :-)

UnFilter(-100,-100) was kinda kidding and not serious actually, but I used UnFilter(-60,-60) together with FluxSmooth(0,14) for high motion in my Blues Brothers encode, which 'surprisingly' gave me no visible artifacts or quality decrease due to filter/parameter transitions.

Also, I replaced FluxSmooth with TemporalCleaner(5,10) and TemporalCleaner(3,6) for low and middle motion together with UnFilter(-5,-5) and UnFilter(-20,-20) respectively, which would theoretically really 'invite' some artifacts especially when switching to hi-mo ;).

However, the result (and the compression gain due to heavy filtering of loads of high motion scenes that definitely resulted in the increase of the overall quality) was really good for that particular hard-to-compress movie with 640*336 bicubic resolution keeping the ac3 track.

Anyway, let's try the script with some tweaking on a couple of more sources now! ;)

ciao,
iago

yaz
23rd June 2003, 17:08
Originally posted by HomiE FR
I didn't know there was a problem with SSE compliance.
yep. most of the script functions need full sse compliance. (it's time to build a new system :-)

Originally posted by HomiE FR
... Continuous Motion Filter ...
i saw that description but it's not xactly what i meant. that good old scene change detectors i mentioned worked like this :
next_threshold = factor * current_threshold
they were pretty good in detecting scene changes &(!) crossfades. but (just to disagree with myself:-) it's less useful detecting motion as done by ur filter. in add, finding a good factor in yv12 would need some time. but (maybe) it'd worth. just a clue.

anyway, i'd be interested in ur other filters very much. scaling filter strength according to motion/changes (as u described) is a very promising field.

Originally posted by HomiE FR
But if you have an idea on how to improve it, feel free to share your knowledge! :)
sure, ya kiddin :-) it's just good as it is.
but why not ? what about joining your motion detector with my scene change detector (idea). imho, scene changes need different handling than high motion scenes & than crossfades (especiallly the slow ones) while any of that can generate similar motion values with your detector.

@iago:
what a settings:-) a brave user u r:-)
(offtopic) have u ever noticed that fluxsmooth are willing to make strange color spotting? say, just try fluxsmooth(x,128), or so. i thought that with such high threshold it should do something similar to undot, but instead it made heavy color dots here & there. it wasn't a thorough test (as i dropped it immediatly:-) but since then i'm very careful with its spatial part.
using unfilter for heavy blurring ... hmm ... should try anyway

the bests
y

Dali Lama
25th June 2003, 05:44
Hi Homie FR,

I just wanted to point out that I think 0 in fluxsmooth still performs spatial/temoral smoothing. One must use -1 to disable spatial/temporal smoothing.

Also, nice script!

Oh and I'd like to share my opinion that using conditional filtering is nice, but it doesn't mean one should forget about setting "proper" thresholds and not going to extremes...I am not going to mention names...Iago...just joking.

Take Care guys,

Dali

iago
25th June 2003, 15:13
Hello Dali,

Experimenting with extremes and gradually reducing strength is a good method to find the acceptable maximums for most filters :D.

iago

edit: as for fluxsmooth, yeah you're right, according to documentation by SansGrip one must use -1 (not 0) to cancel either temporal or spatial smoothing.

HomiE FR
25th June 2003, 16:05
yaz : Thanks! Your way of scaling scene change threshold could be ok, but the factor can't be constant IMHO. If I understood it right, we have threshold_sc = factor*motion (I'm not sure, maybe you meant new threshold_sc = factor*old threshold_sc). In both cases the factor must change according to motion. Maybe I'm missing something, anyway thanks. :)

Dali Lama : Thanks for the tip! ;) I'll change it in the next release.

I think I will release soon the other scripts I wrote with the same goal in mind. I discribed them in the first post, theoretically they are more "powerful" than this one, but I must warn you: if there is only a memory leak in the filter you use with one of the 2 other filters, be ready to abort the encoding process, because your physical/virtual memory will be eaten quite fast!
This is because ScriptClip (the conditional function used inside) calls the filter used for each new frame: so if the filter doesn't free all the memory it took for the frame process, you can imagine that even a "small" leak can become huge with more than 50000 frames!
But if you want to give them a try, I'll be happy to post them!

HomiE FR

Seiby
26th June 2003, 22:42
Hi,

thx for your filter, great work but...

The scene change detection doesn't work very well for me. For me less then 1/3 of all scene changes were found. Is there a way to tweak the scene change detection?

Sample: Scene Change, Medium Motion was detected, no scene change...
Sample (http://www.freegamescenter.de/scenechange.png)

Anyway, great work to save bits in high motion scenes and keep details in slow motion scenes :D

bilu
27th June 2003, 01:25
Welcome to the forum Seiby :)


The answer lies in your own sample.

diff is less than threshold_sc, you would have to lower the threshold.



Bilu

HomiE FR
27th June 2003, 06:38
bilu : Thanks for doing the feedback! :D

Seiby : Thanks for trying my script. I hope you'll be able to find good values without much problems (usually it should be the case).

yaz is totally right when he says that an adaptive thresholding could be great, but this wouldn't work well on anime where there are always (not during travellings) some duplicate frames where motion is very close to zero. So the factor wouldn't work.
But I could do some "anime=true" where the old thresholds are accessible (or maybe "thresholds=true") and with "thresholds=false" there is the yaz adaptive thresholding (© ):p which should work perfectly with normal movie (not anime).

I'll release the other scripts I did on saturday (tomorrow). If you understood how this one worked there won't be any problem with the others (same debug thing, etc...)

kilg0r3
27th June 2003, 14:38
@ iago, HomiE, ...

In know this is kind of a stupid question but are you able to quanitfy your results? Some rough estimation like saved KB at same perceived quality would be great.

HomiE FR
27th June 2003, 19:02
kilg0r3 : I'll do that this week-end if it can help. But the problem is that this filter is too powerful (just kidding) : you can use any combination of filters, and any parameters you like, so even though I post some results they won't be optimal (and maybe far from that).

At least on some anime source (which is the type I'm testing right now), I have really good results with this script using adaptive FluxSmooth, UnFilter and Deen (I'll post the script with the test).

I'm also thinking that a script that would help dark scenes (with some LumaFilter for instance, and maybe more if needed) would be really easy to code, so I'll do that quickly. :)

Seiby
27th June 2003, 20:38
... i got very good results out of my DVD source with this settings:

(2/3 CD HQ encodes, using xvid 24052003)

# LOW MOTION FILTER FUNCTION
LanczosResize
mergechroma(c,blur(c,1.3))
Undot(c)

# MEDIUM MOTION FILTER FUNCTION
BicubicResize 0.5
mergechroma(c,blur(c,1.3))
UnDot(c)
Temporalsoften(c,2,3,3,mode=2,scenechange=6)

# HIGH MOTION FILTER FUNCTION
BilinearResize
mergechroma(c,blur(c,1.3))
UnFilter(c,-5,-5)
Temporalsoften(c,2,3,3,mode=2,scenechange=6)

...compared with only Low Motion filtering i can save up to 10%, depending on the source.

- Increases quality in Low Motion Scenes because of the saved bits in High-/medium motion
- Increases quality in High Motion Scenes because of the filtering

for me a great filter :D

HomiE FR
27th June 2003, 21:31
Seiby : Thanks for the report. :) It's always interesting to have some examples/fine-tuned settings as a starting point for other encodes. I'll try QMF with different sources (the usual suspects, maybe saving private to see if we can do something about this highly uncompressible movie) in order to do a "full range" test.

iago
28th June 2003, 00:37
Seiby,

Though your parameters are quite reasonable, temporal filtering of high-motion scenes is not a good idea. The idea that lies behind this kind of motion adaptive filtering is that it tries to apply temporal filtering to low-motion and spatial filtering to high-motion scenes in order to attain the best results from both sort of filtering.
Anyway... if you are pleased with the results, no problem then... ;)


HomiE FR,

currently I'm considering to use the below script on a full test encode of The Hair (which contains loads of high motion scenes) aiming to fit it on 1CD with 128 ABR mp3. (XviD / h263 / cm / b-frames 2/150/100).


Can you please check it to make sure I haven't messed up something in the parameters: ;)

----------------------------------------------------
# QUANTIFIED MOTION FILTER v1.3
# EXAMPLE 2 : ADAPTIVE RESIZING FILTER

# LOADING AVISYNTH PLUGINS
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\TemporalCleaner.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\FluxSmooth.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\UnFilter.dll")

# LOADING QUANTIFIED MOTION FILTER SCRIPT
Import("c:\QMF\qmf-1.3.avs")

# LOW MOTION FILTER FUNCTION
# -> SHARP RESIZING + TEMPORAL ONLY
function Low_Motion_Filter(clip c)
{
c = TemporalCleaner(c,5,10)
c = LanczosResize(c,512,272)

return c
}

# MEDIUM MOTION FILTER FUNCTION
# -> NEUTRAL BICUBIC RESIZING + TEMPORAL & SPATIAL
function Medium_Motion_Filter(clip c)
{
c = FluxSmooth(c,7,7)
c = BicubicResize(c,512,272,0.00,0.50)

return c
}

# HIGH MOTION FILTER FUNCTION
# -> SOFT RESIZING + SPATIAL ONLY
function High_Motion_Filter(clip c)
{
c = FluxSmooth(c,-1,14)
c = UnFilter(c,-30,-30)
c = BilinearResize(c,512,272)

return c
}

# OPENING VIDEO SOURCE
MPEG2Source("D:\HAIR\VIDEO_TS\HAIR.d2v")
crop(4,68,-4,-68)

# APPLYING ADAPTATIVE RESIZING FILTER (USING QMF)
QMF()
-----------------------------------------------------

regards,
iago

Didée
28th June 2003, 02:28
First of all: Thanks, HomiE FR, for this very nice scripted function. That is using AviSynth like it's supposed to be ... ;)

However, I have some (not only) philosophical problems with this kind of processing. Call me sophisticated if you want ...

As the conditional toys came available, I also tried some similar processing, but even before having started, the following things came to my mind:

1. The already mentioned transitions between the different motion levels. If you want to use some more heavy filtering for the hi-motion parts, the transition becomes really obvious. Therefore, in my test scripts I ended with about eight to twelve different motion levels ... a little too much for the ease of using.

2. Much more important:
When performing different filtering through conditional handling, whatever you might try in your script, in the end you will always get this and nothing else: a decision how to handle the current *frame*.
Now, this is not satisfactory in a lot of cases. Most of the time, frames consist of mixed lo-mo and hi-mo content, and therefore you would like to treat *parts* of a frame differently, not only complete frames. This is no great news, I know ;) There are e.g. MarcFD's Motion Adaptive Mixer (MAM) and SansGrip's NoMoSmooth. Both try to follow that idea, with some success, but far from perfect.
[/me is almost falling asleep on my keyboard]

To see a really interesting approach to treat the content of a frame motion-adaptive, I would strongly suggest
to do a little reading and wondering (http://www11.brinkster.com/poptones/newcleus/ow.asp?FatMan), if you don't know it already.
Apart from the fact we already had some bad mood here, because of the project's name, I am really keen to see kinda this integrated into AviSynth 2.5. A powerful and useful set of layering/masking tools together with the conditional functionality ... me starts dreaming ...

Ah, that's exactly what I'll do now. Good night, friends.

- Didée

Seiby
28th June 2003, 03:38
Originally posted by iago
Seiby,

Though your parameters are quite reasonable, temporal filtering of high-motion scenes is not a good idea. The idea that lies behind this kind of motion adaptive filtering is that it tries to apply temporal filtering to low-motion and spatial filtering to high-motion scenes in order to attain the best results from both sort of filtering.
Anyway... if you are pleased with the results, no problem then... ;)


and that's the reason why I'm a Junior Member ;)

I tried to reach a high quality level with my encodes with bitrates arround 1500 kbits and a resolution 640*xxx or even higher. Therefor I've only used "soft" filtering also for High-Motion. Is there a "soft" spatial filter or a soft setting for a spatial filter that would do a better job in a high motion scene than temporal soften?

Tried Fluxsmooth (-1,14) but for me it softens the images too much.

btw: sorry for my bad english its late in here ;)

HomiE FR
28th June 2003, 06:21
Didée : Thanks a lot for all this information. I'm glad you didn't go to sleep before posting! :p

About the transitions and the layering/masking, I'll do something about it today. The links provided are great, thank you very much for that (it'll save me much time!).
But another approach is to use ScriptClip (which I did, I'll post the scripts tosay I promise), so that you have an "infinite" number of motion levels. The first script I did with this design had only one fitering function, so you couldn't use different filters for different motion levels, just move the parameters for each one. Then I coded a script using 3 motion levels AND parameter scaling (through ScriptClip) inside of each motion level.

But the idea of layering is so interesting (even though it'll slow everything down, maybe only during the transitions), that I can't let it go without trying to use it. :)

Treating parts of each frame differently was unreachable for me so I tried (so hard) to get it out of my mind when I coded this little one. You know, I'm just playing with "high-level" functions, not the C/C++ basics, so I can't do everything I could imagine.

Thanks again Didée.

Seiby : Sorry, I didn't see the TemporalSoften in High_Motion_Filter. But iago came quickly in support, so... :)

iago : I don't see any problem in this script, but to be sure you should test it (I know you already know :D ) on a few minutes just to be sure. Try to find a sequence with both high/low motion scenes if possible, just to check the transitions (I hope they won't get noticed). I'd be interested to have some results then (sorry, you ask and eventually I'm the one to ask!).

Thanks.

Wilbert
28th June 2003, 13:48
Didée : Thanks a lot for all this information. I'm glad you didn't go to sleep before posting! (...) But the idea of layering is so interesting (even though it'll slow everything down, maybe only during the transitions), that I can't let it go without trying to use it.
I will ask Poptones to mail the changes to Sh0dan :)

bond
28th June 2003, 14:02
wow real great idea!
thanks a lot for this filter, something new for testing :)

i have three questions:
1) is there any function/filter in avisynth which lets me mark frames, which could be put in the script in every motion level?
for example to mark all frames treated as low motion with "low"...
i think this would really help testing and tweaking the motion level used

2) any approximate results of how the motion estimation in qmf influences the encoding speed? i know that this cant really be measured but approximate values would be great...

3) couldnt lead the different filtering by motion level to any problems or "non-optimal" results with the motion estimation used by the video codecs?

iago
28th June 2003, 14:38
how the motion estimation in qmf influences the encoding speed?Its influence is next to nothing in my experience here (even on a very slow machine).

Wilbert
28th June 2003, 15:42
I'm looking at your script, and don't understand much of it yet (and I'm not behind my own computer right now ...). I see the following lines in qmf-1.3.avs:

# APPLYING MOTION FILTER ACCORDING TO MOTION LEVEL
c = ConditionalFilter(c, Low_Motion_Filter(clip), Medium_Motion_Filter(clip), "motion_level", "=", "0")
c = ConditionalFilter(c, High_Motion_Filter(clip), c, "motion_level", "=", "2")

As I understand it:
motion_level = 0 => Low_Motion_Filter
motion_level = 1 => Medium_Motion_Filter
motion_level = 2 => High_Motion_Filter

edit: I think I have edited this post about 100 times :) My only problem with the above two lines is: if motion_level = 2, then you are applying the motion filter twice. One in the first line (which is thrown away), and the correct one in the second line. Why don't you use the following:

c = (motion_level==0) ? Low_Motion_Filter(clip) : (motion_level==1) ? Medium_Motion_Filter(clip) : High_Motion_Filter(clip)

More questions will follow later :)

HomiE FR
28th June 2003, 18:58
My only problem with the above two lines is: if motion_level = 2, then you are applying the motion filter twice.

You're wrong when you're stating this: Just do a little test to convince yourself. Do only Greyscale(c) for Low motion, and nothing for the 2 others. You'll see that the high motion scenes have chroma information, so I'm not doing any "cross" filtering here.

But I understand this is quite tricky to get what I'm doing (even though I believe the script is really clean and with some comments).

You can see High_Motion_Filter(clip) on the second line, and clip is an unaltered version of the video clip, so I'm not filtering twice.

Just a little note: I coded this script without knowing everything about the conditional functions. I learnt how they worked with many tests (many many many...) so I really hope (and think) there is no huge mistake in my scripts. :)

But thanks for looking at the script, Wilbert. I hope at least this question is answered. Next please! :p

Wilbert
28th June 2003, 19:12
You're wrong when you're stating this: Just do a little test to convince yourself.
I don't think so. I'm only talking about the case motion_level=2:

I'm not say that you do this:

filter2(filter1(clip))

but you are doing this:

clip2 = filter1(clip) # isn't used later
clip3 = fliter2(clip) # is used later

Concrete:

c = ConditionalFilter(c, Low_Motion_Filter(clip), Medium_Motion_Filter(clip), "motion_level", "=", "0")
In this line the Medium_Motion_Filter is applied to clip (even though motion_level=2). Agreed? This is not necessary, and costs time.

In the next line
c = ConditionalFilter(c, High_Motion_Filter(clip), c, "motion_level", "=", "2")
the preferred filtering is applied. This happens on the original "clip", which is want you want.

HomiE FR
28th June 2003, 19:18
Ok I'm "having fun" with transitions between scenes. I found a way which seems to work quite nicely (all in YV12, which is the color space needed for the conditional functions).

BUT there is a little problem : I have to use ScriptClip (let's say a more powerful conditionalfilter). But when using ScriptClip, you have to be aware that filters which have memory leaks can't be used.
Even though you think everything is working fine in normal conditions, these filters show their problems when used with ScriptClip (Deen by MarcFD for instance). Your memory will be eaten (I already explained why in this thread) and you won't be able to stop that without abording the process.

So I don't know what to do: let the user decide to use the transitions but be aware that things can go wrong, or throw them away??

When writing I think I found a way to do it without ScriptClip. I'll try that and I'll come back when I'm sure this is possible.

HomiE FR
28th June 2003, 19:43
In this line the Medium_Motion_Filter is applied to clip (even though motion_level=2). Agreed? This is not necessary, and costs time.

I totally agree on that. (I'll fix it in no time)

I don't think so. I'm only talking about the case motion_level=2

Maybe I'm not getting the whole point. If you say that I'm filtering the high motion scenes twice (one time "medium" or "low", the one you prefer, and then "high"), then I can assure you (I hope I'm not wrong but I just did some tests just to be sure :) ) that I'm not, even when motion_level=2.

I put greyscale in low and medium motion filters, and then I look at high motion filters, which have chroma information, so no double filtering.

Sorry to be that dumb, but I really don't know what could be wrong, apart from the excessive time needed.

BUT I've just understood what you were saying (I post everything so that everyone can see how dumb I am), you were talking about the double filtering inside the script, which has no influence at all on the result (if we forget about speed). :) Sorry!

Wilbert
28th June 2003, 22:59
BUT I've just understood what you were saying (I post everything so that everyone can see how dumb I am), you were talking about the double filtering inside the script, which has no influence at all on the result (if we forget about speed). Sorry!
Finally :)

Btw, I think you can solve it in the following way:

# APPLYING MOTION FILTER ACCORDING TO MOTION LEVEL
c = ConditionalFilter(c, Low_Motion_Filter(clip), clip, "motion_level", "=", "0")
c = ConditionalFilter(c, Medium_Motion_Filter(clip), c, "motion_level", "=", "1")
c = ConditionalFilter(c, High_Motion_Filter(clip), c, "motion_level", "=", "2")

HomiE FR
28th June 2003, 23:12
Wilbert : I already did this exact correction! :) I'm glad you found the same one (there wasn't many options however ;) ). Thanks for helping, this little bug was surely slowing the script quite much!

But on another subject, I'm having much trouble to make scene types transitions clean. I think that I won't finish it tonight, it's still too buggy to play with.
I'll come back when it has reached some "usability" (?!)

HomiE FR
29th June 2003, 17:00
OK, here is a new release of Quantified Motion Filter: QMF v1.4a1.
You can find it here: QMF v1.4a1 (http://perso.wanadoo.fr/homie.fr/qmf-1.4a1.rar)

What's new?
- I made different default values for chroma=true and chroma=false, so that you don't have to care about enabling chroma or not (but if you like to tweak values, you can).
- I used Wilbert's advice not to do a double internal filtering (which had NO impact on the clip outputted by QMF 1.3), so it should result in more speed when adaptive filtering is enabled.
- I added motion level transitions! :) (thanks to Didée's idea and yaz also I think). You can see this version is an alpha, so don't blame me if things go wrong.

How to use motion level transitions?
There is a new parameter for QMF called transition_length, and I think you understand how it works. 0 disables transitions, and you can use any integer over (but don't go too far). Default is 10. It's very simple: it uses mergeluma and mergechroma with a variable weight (weight moves linearly between 1.0 and 0.0) ni order to provide a smooth transition between motion levels.

Some warnings about transitions:
1. When a transition begins, the script stores in a variable where it comes from and where it goes to. These two things are NOT updated during the transition, so if there is two motion levels changes or more during one transition, the script will be a little late. But that's no real big problem I think. Normally there should'n be any "rude" :) motion level changes other than scene changes (I let scene changes do whatever they want, I think this is totally normal because what's before and after a scene change isn't linked, at least not as much as other frames).
2. I had to use ScriptClip to do the transitions, so all the "limits" of ScriptClip are now transferred to QMF (when transition_length > 0 only): if one of the filters you use in a motion filter function has a memory leak, each frame of a transition where this motion level is implied will eat a few kbytes (depends on the filter, some are very hungry, some not) of your memory. And this memory won't be free until the end of the whole process. For instance, Deen usually eats some memory at each frame, but others also. That's why you should test your scripts on a few thousands frames (if you wanna use the motion level transitions) before launching a full process.

Wilbert
29th June 2003, 22:58
Remark and a question:

# APPLYING MOTION FILTER ACCORDING TO MOTION LEVEL
c = ConditionalFilter(c, Low_Motion_Filter(clip), clip, "motion_level", "=", "0")
c = ConditionalFilter(c, Medium_Motion_Filter(clip), c, "motion_level", "=", "1")
c = ConditionalFilter(c, High_Motion_Filter(clip), c, "motion_level", "=", "2")

Nice, but there is one ploblem. "Low_Motion_Filter(clip)" and "clip" needs to be of the same size, so you can't include resizers in Low_Motion_Filter. But, ok.

I don't understand what happens at the first frame. Briefly summarized:

1) motion_level = 0
2) Low_Motion_Filter is applied => c
3) Something with transitions, not important right now ...
4) ME is applied to c. But how is this possible? ME needs quantities (like diff and diff_f2) which are defined in a later stage:

# COMPUTING MOTION ESTIMATION
c = FrameEvaluate(c,"ME") # diff_f2 needed, but not defined yet?

# GETTING DIFFERENCES BETWEEN PAST/PRESENT/FUTURE FRAMES
c = FrameEvaluate(c,"global diff_f2 = y_ratio*YDifferenceFromPrevious(clip_f2) + uv_ratio*UDifferenceFromPrevious(clip_f2) + uv_ratio*VDifferenceFromPrevious(clip_f2)") # diff_f2 defined

But vdubmod doesn't generate errors, so that just means that I don't understand what's happening in the lines above ...

HomiE FR
29th June 2003, 23:49
Wilbert: You proved me wrong here. I didn't let this "double filtering" for no reason, but I had totally forgotten why when I removed this line. I can do some information detection at the first frame of the clip to get width and height of the clip, and then apply a crop just to gain time and have the right width/height.
But I'm too tired right now to do that.

Then, about the next problem, I never found some proper documentation about conditional functions, and more important than that the links between them. So I did thousands of tests to make my things work like I wanted.
And I found that the lines under the conditionalfilter lines are read from bottom to top. I know this sounds crazy but this is how it works according to my tests. If I put the clip_p2 etc... definitions above the others (just like you think), then you'll see the error message asking for it.

If you want to know the order in which all the operations are done, you can use subtitle on the same part of the screen and see who is over/under (this is a bit tough but...).

What I believe for the order:
1. the conditionalfilter lines
2. All the diff_p2=... lines from bottom to top (that's why I put the p2 at the bottom, just to remember me that it's read this way) :)
3. ME (which can be applied if the script is read this way)
4. Transition and Debug within the ScriptClip

I believe I'm right here, but if you can prove me wrong feel free to do it. :) Then I'm sure the script works, because I spent hours testing it, there you can't make me say it's totally buggy (did you test it already?).

And if you have some explanation on why it works this way just tell me, I managed to do the scripts I wanted without documentation, but if I can read one now I'll be able to understand where I can improve things.

iago
30th June 2003, 00:39
Sorry to butt in, but just wanted to say that my full test encode on The Hair (with the script posted above and using the first version of QMF) came out totally crap :D, possibly due to not achieving a desired compression gain using that particular script and parameters.

Anyway, after all it was kinda 'mission impossible' to try to fit it on 1CD!

Gonna try the new version(s) after the hot debate on the conditional functions/parameters (which I'm totally ignorant of) settles. ;)

best regards,
iago

Wilbert
30th June 2003, 00:54
Wilbert: You proved me wrong here. I didn't let this "double filtering" for no reason, but I had totally forgotten why when I removed this line. I can do some information detection at the first frame of the clip to get width and height of the clip, and then apply a crop just to gain time and have the right width/height.
But I'm too tired right now to do that.
Good idea!

And I found that the lines under the conditionalfilter lines are read from bottom to top.
It seems so, but I don't understand it. Where is Sh0dan when we need him?

sierrafoxtrot
2nd July 2003, 12:21
hi all

not sure if this is an avisynth-related issue, but i am trying out the abyss SE with this script (qmf-1.3_example1) using qmf-1.4a1, with added SetMemoryMax(40) and SeparateFields().SelectEven() and i am running out of virtual memory which tops out at 768MB after ~2hours.

encoding with other scripts (without qmf, with fluxsmooth, with unfilter) does not have this effect.

my system is winXP pro, 256MB RAM, Avisynth252, using koepi's xvid build 24.06.2003.

thanks!

Dark-Cracker
2nd July 2003, 12:47
Homie have alredy explain some filters (even some internal avisynth funtion) have some memory leak with dynamic filtering this create a new instance of filter every frames filtered.

try without fluxsmooth it seems to me it have a memory leak.

sierrafoxtrot
2nd July 2003, 18:54
thanks for that Dark-Cracker, i was confused about the older version of QMF (1.3) calling a filter twice during medium motion, that had been fixed in 1.4a1, and hadn't realised that it had another memory leak. anyway, it's working without eating up my virtual mem now. i can't wait to see the results!

thanks for the new toy Homie-FR! any chance of CMF or FMF? ;)

sierrafoxtrot
5th July 2003, 01:52
hi all,

just to report that fluxsmooth exhibits memory leaks with 1.4a1 but not with 1.3. other than that, my encode of that abyss using mergechroma and temporalsmooth with unfilter turned out really good, a lot less blocks in the high motion water splashing about scenes.

keep up the good work homie FR!

lamer_de
5th July 2003, 19:10
Hi all.
I did some short tests with this script, but somehow my encoding speed dropped rapidly (from around 4 fps to 0-1 fps ;) ). So I thought the filters I used would suffer from the memory leak problem. I tried the following scripts to investigate the problem:


LoadPlugin("c:\PROGRA~1\GORDIA~1\VDubmod\avsfil~1\UnFilter.dll")
Import("c:\PROGRA~1\GORDIA~1\VDubmod\qmf-1.4a1.avs")

function Low_Motion_Filter(clip c)
{
c = UnFilter(c,-30,-30)
return c
}
function Medium_Motion_Filter(clip c)
{
c = UnFilter(c,-30,-30)
return c
}
function High_Motion_Filter(clip c)
{
c = UnFilter(c,-30,-30)
return c
}
avisource("M:\UM Raws\um7.avi",false)
QMF()

Well, it's merely the script which was provided with the same filters for all motion levels. I compared it to a simple

LoadPlugin("c:\PROGRA~1\GORDIA~1\VDubmod\avsfil~1\UnFilter.dll")
avisource("M:\UM Raws\um7.avi",false)
UnFilter(-30,-30)

So, both scripts will do the same filtering. I used Avisynth 2.5.2 with VDubMod 1.4.13(build 14328), encoding the first 1000 frames of an Anime to VBLE lossless YV12. With QMF, it took 86secs, with the basic script 57secs. Those values are measured with my eyes using the VDub output window and not DBGView, so they might be not correct up to some digits ;) 1000 frames maybe a tad too short aswell, but somehow the speed drop is pretty heavy. That's around 30% speed loss. I tested some internal Avisynth filter aswell with similar results (e.g. Greyscale). Well, using more complex filters (maybe with memory leaks), I experienced the speed drop mentioned above (more than 100% :( ).

Is something wrong with my settings/Avisynth/Filter, or is this the normal speed drop? I wouldn't expect that great loss when it was called "almost no speed drop".

TIA,
lamer_de

CruNcher
6th July 2003, 19:18
@HomiE FR
avisynth 2.5.2
nice script but unfotunately its not working for me non of the both versions here is my script


import("qmf-1.3.avs")
#import("qmf-1.4a1.avs")
function Low_Motion_Filter(clip c)
{
c = LanczosResize(c,640,272)

return c
}

function Medium_Motion_Filter(clip c)
{
c = BicubicResize(c,640,272)

return c
}

function High_Motion_Filter(clip c)
{
c = SimpleResize(c,640,272)

return c
}

MPEG2Source("pearlharbor.d2v",idct=5,cpu2="oxxxxx")
crop(2,74,716,428)
QMF()


if i use this i get a error message ontop of the video telling me something like this
Evaluate: Unrecognized exception!
([Conditio([ScriptClip]line1
if i try the qmf-1.4a1.avs
ConditionalFilter: The two sources must have the same height!
(qmf-1.4a1.avs, line 81)
maybe thats the problem wilbert talked about a page ago ?

Wilbert
6th July 2003, 21:27
ConditionalFilter: The two sources must have the same height!
(qmf-1.4a1.avs, line 81)
maybe thats the problem wilbert talked about a page ago ?
Yes, it's the same problem. I'm sure that HomiE FR will put up a new version soon ;)

HomiE FR
7th July 2003, 00:51
CruNcher : Yep that's the same problem. I'll post a new version tomorrow. Thanks for testing the script.

HomiE FR
7th July 2003, 21:27
Wilbert: I'd like to ask you a little question. I do not like to do some "hacks" in my little script, and this problem about resizing within motion filter functions isn't that simple to handle. Indeed, if people try to enlarge the video clip inside the functions, my "Crop hack" (I hope you remember what I suggested before) won't work. So I guess I need to do something else such as PointResize (which seems to be the fastest internal resizing filter).

If you believe this is the best solution, I'm ready to release a new version. :)

Then I'm a little worried about the memory leaks problems when using ScriptClip (necessary for the transitions handling). I really wanted that QMF had no problems with any Avisynth plugin, that's why I think I'll leave the transitions for FMF (which is a more complex QMF where the parameters within each motion level are scaled linearly according to current motion level). This way people can choose between a simple filter which can handle ANY Avisynth script without any problem and another script (more powerful) which has problems with plugins that have a memory leak. Does it sound right?

Wilbert
7th July 2003, 21:46
Indeed, if people try to enlarge the video clip inside the functions, my "Crop hack" (I hope you remember what I suggested before) won't work. So I guess I need to do something else such as PointResize (which seems to be the fastest internal resizing filter).
I forgot about upscaling. The problem is, there is a bug in PointResize.

I guess the best to do is the following: just use pointresize, but add a warning that upscaling should only be used in AviSynth v2.53 and more recent versions. I hope Sh0dan corrected the bug by that time, or maybe he has some time to release a bugfix :D

that's why I think I'll leave the transitions for FMF (which is a more complex QMF where the parameters within each motion level are scaled linearly according to current motion level). This way people can choose between a simple filter which can handle ANY Avisynth script without any problem and another script (more powerful) which has problems with plugins that have a memory leak. Does it sound right?
Good idea!

HomiE FR
7th July 2003, 22:10
Thanks for the quick answer! :) Then, I'll do what you suggest, and I'll try to post new versions in less than 12 hours (both FMF and QMF). I have a full system reinstall to do before releasing them so it could take a little more time.

Wilbert
7th July 2003, 22:19
Speaking of the devil :) Have a look at: http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html. The bug is probably fixed in the latest binary. Thanks Sh0dan!

sh0dan
7th July 2003, 22:25
PointResize is actually (believe it or not) stretching the limits of the generic resizer - my fix is an attempt to fix it - the results looks ok here, but I'm not 100% sure it's correct.

bond
10th July 2003, 11:58
any news about this great filter?

HomiE FR
10th July 2003, 16:29
Yes it'll come tonight (it's not the first time I say that I know, but this time it'll come :) ). I'm writing a little help file for FMF (I already did one in French before but I have to translate it), and QMF is okay now (maybe it'll be the final version I don't know yet, you'll say if there are still bugs).

But I have some problems with FMF, the version that will come out is beta (maybe even alpha), just for trials.

Thanks for waiting for it! ;)

HomiE FR
10th July 2003, 21:47
So there are two new releases tonight:

1. QMF (Quantified Motion Filter) v1.5 beta 1
This new version doesn't bring new features: on the contrary, the motion level transitions are gone (but don't worry, they are built-in inside FMF v1.5 b1, see below). The bug about resizing inside motion filter functions should be gone now. This release could be a final release for QMF (at least the final version with this kind of motion estimation and thresholds).
The objective of this script is to be usable with ANY Avisynth filter (which is NOT the case when using the ScriptClip function inside the script), so I believe that QMF has become very powerful, since the user can really tweak it according to his needs.

Link: QMF v1.5 b1 (http://perso.wanadoo.fr/homie.fr/qmf-1.5b1.rar)

2. FMF (Full Motion Filter) v1.5 beta 1
Ok now it gets a little bit more complicated! :) If you don't fully understand QMF (but I think it isn't that hard), don't try to play with FMF. To put it in a nutshell, FMF is just an improved version of QMF: improved in the sense that there are many more options inside FMF which make it more powerful, but these new features don't allow it to be usable with any Avisynth filter (the ScriptClip issue I talked about many times before).

I didn't have time to make a proper help file, but since I'm late I post a version with a little help in this post, I think everyone should understand how to use it.

How do FMF work?
There are 3 motion levels just like QMF (Low, Medium and High), but inside these motion levels the user can use variable parameters instead of fixed ones in QMF. For instance here are two Low motion filter functions, the first for QMF, the second for FMF.

FOR QMF:
function Low_Motion_Filter(clip c)
{
c = FluxSmooth(c,14,-1)
c = UnFilter(c,-10,-10)
return c
}

FOR FMF:
function Low_Motion_Filter(clip c)
{
c = FluxSmooth(c,param1_lm,-1)
c = UnFilter(c,param2_lm,param2_lm)
return c
}

You can see the paramx_lm (lm for low motion, there are also paramx_mm and paramx_hm) for FMF, which are parameters which are linearly scaled on each frame according to the current motion level (not only low, medium and high but also the current average difference between the current frame and its neighbours). That's why it's more powerful than QMF: the filtering is really adapted for each frame (if the user does its job right).

How can we control these parameters in FMF?
When you call FMF, you must specify what the ranges for each used parameter are. For instance, in the example above, I should use at least write that (I don't take medium and high motion into account but they work the same):

FMF(param1_lm_min=14,param1_lm_max=7, \
param2_lm_min=-10,param2_lm_max=-20, \
...

param1_lm_min is the value for param1_lm when the current average difference is <= to the lower side of the low motion level.
param1_lm_max is the value for param1_lm when the current average difference is = to the upper side of the low motion level.

NOTE: There is no problem if param2_lm_min > param2_lm_max, the min and max are for min current average difference and max current average difference.

How can we set the different limits between the motion levels?

There are some thresholds (already defaulted) inside FMF:

THESE THRESHOLDS ARE FOR THE CURRENT AVERAGE DIFFERENCE, THE ONE YOU CAN SEE WITH DEBUG=TRUE (the debug thing looks like the one in QMF, just some more infos).

1. Below threshold_min, the low motion filter is used with the parameters fixed at their min values.
2. Between threshold_min and threshold_lm, the low motion filter is used with the parameters scaled (linearly) between their min and max according to the current average difference.
3. Between threshold_lm and threshold_hm, the medium motion filter is used with the parameters scaled (linearly) between their min and max according to the current average difference.
4. Between threshold_hm and threshold_max, the high motion filter is used with the parameters scaled (linearly) between their min and max according to the current average difference.
5. Above threshold_max, the high motion filter is used with the parameters fixed at their max values.

When a motion level function is applied to the video clip, the two other motion level functions are ignored for this frame.

I hope it does make sense, I already released this script on a French forum called Unité-Vidéo and the people understood it really quickly,so I guess it does make sense.

Now I quote the parameter list for FMF:

function FMF(clip c,
\ float "threshold_min",float "threshold_lm",
\ float "threshold_hm",float "threshold_max",
\ float "threshold_sc_min",float "threshold_sc_max",
\ int "distance_sc_min",
\ float "temporal_influence",bool "chroma",
\ int "transition_length",bool "debug",
\ val "param1_lm_min",val "param1_lm_max",
\ val "param2_lm_min",val "param2_lm_max",
\ val "param3_lm_min",val "param3_lm_max",
\ val "param4_lm_min",val "param4_lm_max",
\ val "param5_lm_min",val "param5_lm_max",
\ val "param1_mm_min",val "param1_mm_max",
\ val "param2_mm_min",val "param2_mm_max",
\ val "param3_mm_min",val "param3_mm_max",
\ val "param4_mm_min",val "param4_mm_max",
\ val "param5_mm_min",val "param5_mm_max",
\ val "param1_hm_min",val "param1_hm_max",
\ val "param2_hm_min",val "param2_hm_max",
\ val "param3_hm_min",val "param3_hm_max",
\ val "param4_hm_min",val "param4_hm_max",
\ val "param5_hm_min",val "param5_hm_max")

So you can find the threshold values that I talked about. There are also the parameters for each motion level (I put five "moving" parameters for each motion level, I believe it should be enough).
You can also find threshold_sc_min and threshold_sc_max which are the min and max scene change thresholds. The scene change threshold is just like a "moving" parameter, but it's scaled between threshold_min and threshold_max (so a bigger scale than the other "moving" parameters). Distance_sc_min, temporal_influence, chroma and debug are just the same as if in QMF.

The last (but not least) parameter is transition_length. It's the length in frames for the transitions between motion levels, so that these transitions aren't noticed. It's defaulted at 10, but you can disabled it with the 0 value if you don't like it (but why?).

Here is the link: FMF v1.5 b1 (http://perso.wanadoo.fr/homie.fr/fmf-1.5b1.rar)

Ok that's all for now, I'm here if there is any help needed (I think that I'm not the guy with clean explanations, so I don't mind "trying to" help).

Thanks for testing these scripts, I don't guarantee any results! :)

bond
10th July 2003, 23:24
great work!

one question:
the scene change thresholds are not clear to me:
if the old default ones were 30<40<50 does this mean the new equivalents are 30 (min) and 50 (max) and the thresholds are scaled linearly independently of the motion levels?

and then it would be great if you could tell us the new default settings.

thanks again for your great filter :)

sh0dan
10th July 2003, 23:30
Very nice work! Looking forward to getting to know this one! :)

A word of advice: Cut out your excellent explanation above and paste it into a html/txt file and put it along with the script. Furthermore - if you give your script a ".avsi" extension it fits right into the plugin directory along with the documentation! :)

HomiE FR
10th July 2003, 23:47
@bond: Thanks. Ok let's write all the defaults:

threshold_min = 0.0
threshold_lm = 4.0 (chroma=true) or 5.0 (chroma=false)
threshold_hm = 12.0 (chroma=true) or 15.0 (chroma=false)
threshold_max = 16.0 (chroma=true) or 20.0 (chroma=false)
threshold_sc_min = 20.0 (chroma=true) or 30.0 (chroma=false)
threshold_sc_max = 40.0 (chroma=true) or 60.0 (chroma=false)
distance_sc_min = 10
temporal_influence = 50.0 (means 50%)
chroma = false
transition_length = 10 (frames)
debug = false

I hope it helps! :)

@sh0dan: Thanks a lot for the advices (advice could be uncountable...)
I'll do the proper help file tomorrow morning, and I'll use the .avsi extension (I didn't know it existed!).

bond
11th July 2003, 00:28
thanks, thats a nice guideline!

two things on the "negative" side:

1) it seems that fmf doesnt really seem to work with nic's mpegdecoder (doesnt support seeking) because of jumping scenes (old scenes are shown again aso...)
this problem doesnt seem to occur with mpeg2dec3 (which means a speed loss of course compared to mpegdecoder)

2) I got the following error message while playing back a fmf script in vd (with debug on) exactly after the frame before a scene change:
"avisynth read error, avisynth caught an access violation at 0x01a2106c, attempting to read from 0x00142a11"
my fmf sttings were:
FMF(4,7,16,25,13,50,debug=true,parameter settings)

EDIT: added 2)

CruNcher
11th July 2003, 16:11
@ HomiE FR

i still get the same text message overlayed that says

Evaluate: Unrecognized exception!
([Conditio([ScriptClip]line1 <- i think 2 messages are overlayed
([ScriptClip],line 1)

i also tried to deactivate plugin autoloading by changing the plugins dirname and loading the plugings mpeg2dec3 and simpleresize with the Loadplugin command ,but it doesn't helped a similiar error also occours in the FMF script

Evaluate: Unrecognized exception!
([Conditio([ScriptClip]line1 <- i think 2 messages are overlayed
(fmf-1.5b1.avs, line 206)
(fmf-1.5b1.avs, line 263)
([ScriptClip],line 1)

anybody a idea ? got the newest avisynth version from shodans site

HomiE FR
11th July 2003, 23:33
@bond: I have the same crashs when using filters with memory leaks... Could you do some Ctrl+Alt+Del (if you're using Win2000/XP) and tell me if the memory usage is growing abnormally fast. Thanks.

@Cruncher: I don't know where it comes from: did you use the defaults parameters for FMF? If not, could you please provide the parameters used? Thanks in advance. :)

bond
11th July 2003, 23:58
Originally posted by HomiE FR
[B]@bond: I have the same crashs when using filters with memory leaks... Could you do some Ctrl+Alt+Del (if you're using Win2000/XP) and tell me if the memory usage is growing abnormally fast.sorry i am using winme :(

i used
undot
unfilter
temporalcleaner
mpeg2dec3 1.08
bicubic, simple and bilinear resize

CruNcher
12th July 2003, 00:39
@ HomiE FR

i still try it with that simple script one page ago


import("qmf-1.5b1.avs")

function Low_Motion_Filter(clip c)
{
c = LanczosResize(c,640,272)

return c
}

function Medium_Motion_Filter(clip c)
{
c = BicubicResize(c,640,272)

return c
}

function High_Motion_Filter(clip c)
{
c = SimpleResize(c,640,272)

return c
}

MPEG2Source("pearlharbor.d2v",idct=5,cpu2="oxxxxx")
crop(2,74,716,428)
QMF()


also the same ([scriptclip], line 1) error



import("fmf-1.5b1.avs")

function Low_Motion_Filter(clip c)
{
c = UnFilter(c,param1_lm,param1_lm)

return c
}

function Medium_Motion_Filter(clip c)
{
c = UnFilter(c,param1_mm,param1_mm)

return c
}

function High_Motion_Filter(clip c)
{
c = UnFilter(c,param1_hm,param1_hm)

return c
}

MPEG2Source("pearlharbor.d2v",idct=5,cpu2="oxxxxx")
crop(2,74,716,428)
LanczosResize(640,272)
FMF(param1_lm_min=14,param1_lm_max=7, \
param1_mm_min=14,param1_mm_max=7, \
param1_hm_min=14,param1_hm_max=7)

tempetai
13th July 2003, 20:32
I don't know whether this happen to everyone or only happen to me. OK on version 1.3 and 1.4, but when I use version 1.5b1, the frame 0 of my clip will be shown again at frame 300. A few more incorrect frame has occurred at 305, 318 and so on.

HomiE FR, perhaps you can check this out.

HomiE FR
13th July 2003, 23:31
@bond, CruNcher & tempetai: Ok thanks for the bug reports, I'll check everything tomorrow morning. :)

ssaga
14th July 2003, 03:06
Originally posted by tempetai
I don't know whether this happen to everyone or only happen to me. OK on version 1.3 and 1.4, but when I use version 1.5b1, the frame 0 of my clip will be shown again at frame 300. A few more incorrect frame has occurred at 305, 318 and so on.

Which source plugin did u use?
If you're using Nic's Mpegdecoder plugin, and move randomly in VirtualDub, u may got this problem.

I'm using mpeg2dec3 and I didn't find any duplicate frames with FMF.
Hope this imformation can help u.;)

tempetai
14th July 2003, 03:47
ssaga, thanks for the info. I already been using mpeg2dec3 since I play around with HomiE's excellent script.

Now OK after take out the GoldDust filter from High Motion Filter function. I guess the QMF does not like GoldDust.

cweb
14th July 2003, 08:52
I am trying out your qmf script version 1.5b1 and I've got the latest cvs binary installed of Avisynth 2.52 (the one dated 11th july 2003). It tells me "Script error: there is no function named ConditionalFilter" (qmf-1.5b1.avs, line 105). I think it's a bug in the latest cvs... :)

I'm reinstalling Avisynth 2.52 from the sourceforge project page for the moment.
Edit: oops - avisynth 2.52 did the same thing. I'm using Virtualdubmod (latest cvs binary) by the way. I think I found the culprit. Virtualdubmod's directory contained another avisynth.dll. I renamed this (rather than deleting it, for the moment) and IT WORKED. I think it was left over from a previous version. It was dated March..

So if you have the same error message like I got, check whether you have
another avisynth.dll somewhere such as the VirtualDubMod directory. You should be able to safely delete it (or just rename it like I did).

cweb
14th July 2003, 09:17
Originally posted by ssaga
Which source plugin did u use?
If you're using Nic's Mpegdecoder plugin, and move randomly in VirtualDub, u may got this problem.

I'm using mpeg2dec3 and I didn't find any duplicate frames with FMF.
Hope this imformation can help u.;)

I did a small test with Nic's Mpegdecoder and VirtualDubMod, and QMF 1.5b1 - there were no duplicate frames. So using QMF may be a solution also.

Edit: I did another test and the first frame looked like a frame from further on, so you were right... it seems there is an interaction.

I also noticed some corrupted blocks when viewing with virtualdubmod - they were not there with mpeg2dec3.

MasterYoshidino
15th July 2003, 21:24
omg this is what I was lookin for all this time (a filter to get rid of edge crawl in anime, happens when someone masters a dvd to have no rainbows but leaves the line edge crawl effect in)

Something to temporal filter heavily on luma but just on low motion :)

:D good job on this nice coding

HomiE FR
17th July 2003, 09:53
Thanks for the nice reports! :)

I don't use Nic's MPEGDecoder so I wasn't aware of this problem of duplicate frames... I really don't know what to do about it, so I suggest using MPEG2Dec3 instead (sorry).

@tempetai: Thanks for the info. I'll try GoldDust too.

@cweb: Thanks for explaining your problems (and your solutions to them too :p ). It seems it would be safer to use MPEG2Dec3 with QMF/FMF. I'll add a warning in the readme.

@MasterYoshidino: Thanks. I'm really happy if this script can help. :)

There are not so many bugs it seems, apart from GoldDust and Nic's MPEGDecoder.

Didée
17th July 2003, 12:40
When Steady introduced his Dust filter package, he stated that dust *must not* appear in more than one instance in the filter chain.

- Didée

HomiE FR
17th July 2003, 15:37
Didée: Thanks, it may explain why GoldDust doesn't get along well with QMF/FMF.

AlphaDivxMovies
2nd August 2003, 19:55
Originally posted by CruNcher
@ HomiE FR

i still get the same text message overlayed that says

Evaluate: Unrecognized exception!
([Conditio([ScriptClip]line1 <- i think 2 messages are overlayed
([ScriptClip],line 1)

i also tried to deactivate plugin autoloading by changing the plugins dirname and loading the plugings mpeg2dec3 and simpleresize with the Loadplugin command ,but it doesn't helped a similiar error also occours in the FMF script

Evaluate: Unrecognized exception!
([Conditio([ScriptClip]line1 <- i think 2 messages are overlayed
(fmf-1.5b1.avs, line 206)
(fmf-1.5b1.avs, line 263)
([ScriptClip],line 1)

anybody a idea ? got the newest avisynth version from shodans site

Altough QMF 1.5b1 seems to work properly, FMF 1.5b1 spits out the exact same error in the the exact same way but at different (i think) lines. VirtualDubMod (latest bug fix) crashes the encoding and displays an error message saying there was some avisynth reading error error of sorts, the resulting avi is marked with the error messages described above until VdubMOD crashes the encoding.
I have all the latest versions of required software, problem prevails even when changing to more "stable" versions of Avisynth and VDubMOD. The only filters used are FluxSmooth, Unfilter and Undot.
Trying only the first two results are the same. I am baffled since i cannot pinpoint the problem, i am sure it is not the main avs script since i tried almost every possible variation.

Ps(Until it crashes it seems to work well!)

Script:

#SET FUNCTION VALUES
SetMemoryMax(40)
PluginPath ="C:\MAINUS~1\MULTIM~1\Video\GKnot\"

#SET PLUGINS
LoadPlugin("C:\MAINUS~1\MULTIM~1\Video\GKnot\MPEG2Dec3.dll")
LoadPlugin("C:\MAINUS~1\MULTIM~1\Video\GKnot\FLUXSMOOTH.dll")
LoadPlugin("C:\MAINUS~1\MULTIM~1\Video\GKnot\UNDOT.dll")
LoadPlugin("C:\MAINUS~1\MULTIM~1\Video\GKnot\UNFILTER.dll")

#LOADING FMF SCRIPT
Import("C:\MAINUS~1\MULTIM~1\Video\GKnot\fmf-1.5b1.avs")

# LOW MOTION FILTER FUNCTION
# -> STRONG FRAME ADAPTED TEMPORAL SMOOTHING (USING FLUXSMOOTH)
# -> SOFT FRAME ADAPTED SPATIAL SMOOTHING (USING UNFILTER)

function Low_Motion_Filter(clip c)
{
c = FluxSmooth(c,param1_lm,-1)
c = UnFilter(c,param2_lm,param2_lm)
return c
}

# MEDIUM MOTION FILTER FUNCTION
# -> MEDIUM FRAME ADAPTED TEMPORAL SMOOTHING (USING FLUXSMOOTH)
# -> MEDIUM FRAME ADAPTED SPATIAL SMOOTHING (USING FLUXSMOOTH AND UNFILTER)

function Medium_Motion_Filter(clip c)
{
c = FluxSmooth(c,param1_mm,param2_mm)
c = UnFilter(c,param3_mm,param3_mm)
return c
}

# HIGH MOTION FILTER FUNCTION
# -> NO TEMPORAL SMOOTHING
# -> STRONG FRAME ADAPTED SPATIAL SMOOTHING (USING FLUXSMOOTH AND UNFILTER)

function High_Motion_Filter(clip c)
{
c = FluxSmooth(c,-1,param1_hm)
c = UnFilter(c,param2_hm,param2_hm)
return c
}


# OPENING VIDEO SOURCE
MPEG2Source("E:\DVD Ripping Layouts\The Deep End\THE_DEEP_END\DeepEnd.d2v",cpu=4,moderate_h=40,moderate_v=40,iDCT=2)

# CROPPING AND CUTTING THE VIDEO SOURCE
crop(2,74,716,432)

#APPLYING GENERAL STRAY PIXEL REMOVER
Undot()

# APPLYING FRAME BY FRAME ADAPTATIVE SPATIO-TEMPORAL SMOOTHER (USING FMF)
FMF(param1_lm_min=14,param1_lm_max=7,param2_lm_min=-1,param2_lm_max=-4,param1_mm_min=7,param1_mm_max=5,param2_mm_min=3,param2_mm_max=7,param3_mm_min=-2,param3_mm_max=-4,param1_hm_min=8,param1_hm_max=14,param2_hm_min=-4,param2_hm_max=-8)


# RESIZING VIDEO CLIP
LanczosResize(640,272)

# TWEAKING BRIGHTNESS AND OTHER PROPERTIES
#tweak(-1.5,1.6,3,1.1)
Limiter()

The VdubMod error message is:
Avisynth read error: avisynth:caught an access violation at 0x01a2187a
attempting to read from 0xfffff

bond
2nd August 2003, 23:37
any fmf updates, because of the above mentioned errors?

HomiE FR,
i hope it is still under development as it is really a great idea imho

HomiE FR
3rd August 2003, 15:59
I just came back from holidays. :) I'll have time to check any possible bugs (and looking at the last posts it seems there are some). Thanks again for the interest!

Assault
19th August 2003, 19:22
@ AlphaDivxMovies

I got the same error message today. Fluxsmooth seems to be the reason for this crash because when I removed it VdubMod didn't crash anymore. I think Fluxsmooth has a memory leak because the memory usage grows very fast when it is in use(as HomiE FR already suspected).

P.S.: I haven't read the whole thread. If this bug of Fluxsmooth has already been reported then please apologize.

Assault

Dreassica
19th August 2003, 20:00
i used fluxsmoth in combinatin with qmf a few times and never experienced the problem at all.

AlphaDivxMovies
19th August 2003, 20:10
Thanks for the tip, i just assumed that if it worked well with QMF i would have no "memory leaking" in FMF, but FMF is much more involved.
Any suggestions about a suitable replacement?
Gonna test it without FluxSmooth and gonna try to find ou if it is true about the memory leak.

Regards
AlphaDivxMovies

Assault
19th August 2003, 20:13
@ Dreassica
Yes, I didn't get a crash with qmf either. :)
But I think HomiE FR was right when he said that this crash occurs when you use FMF with filters which have memory leaks.

Assault

HomiE FR
20th August 2003, 17:16
Hi,

I'm really happy to see that QMF/FMF can be useful to anyone besides me. :) I'm really sorry for the problems with FMF, but in fact I can't do anything about them since I play with "high level" functions only. I can't unload plugins from memory (which could be a GREAT feature for Avisynth 3.0 even though I'm not sure this is possible...) so I depend on the plugins used in the script.

In latest FMF I use MergeLuma and MergeChroma for motion levels smooths transitions and I'm not even sure that these internal plugins have no memory leaks (I mean no bits left behind).

The only thing to do is to test a script before launching a full encode to see if the memory usage is stable. Pretty annoying but... :( Sorry. Or to use QMF which is quite good in fact. ;)

HomiE FR

PS : Feel free to share your problems/working scripts here, it'll help me (and others). Thanks in advance.

DDogg
20th August 2003, 17:27
FYI, just for the heck of it I did a search and replace on a modified version of the script AlphaDivxMovies posted above. replacing Fluxsmooth with TemporalCleaner and changing the parameters of the LM line:
c = FluxSmooth(c,param1_lm,-1) #(TC does not allow the -1)
to
c = TemporalCleaner(c,param1_lm,param2_lm)

I was just trying to verify if it was Fluxsmooth causing the memory problem and was not concerned about the parameters being passed to TC so long as it worked to test the memory problem.

The result was no more memory problems.

So, I am wondering if one of the programmers could take a look at the source of Fluxsmooth and see if they could fix the memory leaks? That does not sound like a lot of fun but it is a good filter and I hope somebody will feel it is worth the effort. Alternatively, could anyone suggest an alternative to Fluxsmooth that uses a similar technique?

AlphaDivxMovies
20th August 2003, 19:55
Yeah you are right, FluxSmooth is the culprit.
Too bad since my theory script depended on it.
Gonna check other available options and report back.

@Homie
The guys at http://www.kvcd.net/forum/ would love too see your work!
They make wide use of their Motion Adapted Optimal Scripts, check it out, your work is right on the sweetspot in here.

DDogg
20th August 2003, 20:25
Speaking of the MAF script, If you substitute fluxsmooth where they use temporal cleaner like this you get the exact same
memory leak problems.


mpeg2source("C:\usual\DVD2AV~1.D2V")
nf=0
GripCrop(480, 480+0+0, overscan=1, source_anamorphic=true, dest_anamorphic=false)
GripSize(resizer="BiCubicResize")
Undot()
Asharp(1, 4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(1.58))
MergeLuma(blur(0.1))
SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
ScriptClip("nf = round(YDifferenceToNext())"+chr(13)+ "nf >= SwitchThreshold ? unfilter(-(fmin(nf*2,100)),-(fmin(nf*2,100))) : Fluxsmooth(6+nf,11+nf) ")
GripBorders()
function fmin(int f1, int f2) { return (f1<f2) ? f1 : f2 }

DDogg
7th September 2003, 21:23
AlphaDivxMovies, did you (or anybody else) make any progress finding a replacement in the FMF script for fluxsmooth that would not exhibit the memory leak problem?
Gonna check other available options and report back.

NOTE: I noticed the Sep 3 CSV build of avisynth and the QMF script shows an error in mplayer (but not in VDub). It has been reported in the devel section. Never got an answer as to whether it was replicatable by others or specific to my setup only.

Wilbert
11th November 2003, 22:53
AlphaDivxMovies, did you (or anybody else) make any progress finding a replacement in the FMF script for fluxsmooth that would not exhibit the memory leak problem?
A new version of fluxsmooth is out (hopefully without memory leaks):

http://forum.doom9.org/showthread.php?s=&threadid=64831