View Full Version : Smooth in time and space?


bb
25th July 2002, 07:10
Well, I don't really know if there is already a filter available covering this idea:

The smoothing/denoising filters I know are either spatial or temporal filters. What about smoothing spatially AND temporally at the same time?

E.g. you could average a 3x3x3 block of 3 consecutive frames, i.e. the middle pixel would be averaged by its neighbours in the same frame and the neighbour pixels of the neighbour frames in the time dimension.

I hope the explanation wasn't too complicated to understand, but I think using existing averaging algorithms on a three-dimensional cube instead of just looking at a two-dimensional plane would not be too complicated to implement.

What do you think?

bb

Acaila
25th July 2002, 07:41
AFAIK that is exactly what the General Convolution 3D filter does. However it's made for VDub, not Avisynth.

Something like this can easily be achieve by just chaining two filters, but the problem is that they don't work intelligently to determine edges and sharp lines etc.

poptones
25th July 2002, 08:45
AVISynth has generalconvolution. Richard added it himself to the last couple releases. And you can chain them pretty easily, as well as add as much intelligence as you like. In addition to using edge detection filters to create masks, you can use lighten and darken via layer().

There are so many ways to do this now it's become difficult to decide which one is best for an application. There are the included filters and the plugins - between those and being able to layer clips using a variety of operations you have pretty much unlimited possibilities. My biggest gripe right now is with finding a way to remove MPEG artifacts without screwing things up too badly. And I'm working on that one, too.

bb
25th July 2002, 09:57
Hmm, the 3D averaging I was thinking of is not the same as chaining a spatial and a temporal filter. But the General Convolution 3D filter seem to be the solution (don't know if it has scene change detection, which would be nice). I'll try that one.

Is there a General Convolution 3D filter available for AviSynth, too?

If not, maybe someone feels challenged to implement it. There's also much room for tweaking, like edge detection, etc.

I think this could be a superior method of getting rid of noise in complicated sources like DV.

bb

avih
25th July 2002, 10:17
i think a specific 3d convolution filter should be written since it would be much faster, especially since it using 27 different values. also, it should be adaptive.

it can be adaptive in 2 ways:
1. apply the convolution result if it's not 'further' than 'x' from the original pixel value.

2. take into account only pixels that are not 'further' in value from the priginal pixel by 'x'

the 2nd method gives better results imo, but is considerably slower because of the 'if's during the convolution process itself.

it SHOULD be a great filter though.

Didée
25th July 2002, 11:43
Dreaming of SmartSmootherHiQ in 3D ...

manono
25th July 2002, 14:52
And then instead of taking twice the time to encode, it can take four times the amount.:)

sh0dan
25th July 2002, 15:56
Not entirely so, because the temporal check would not be a complete 3D-check, it would only check the current pixel against the same pixel in the previous frame (one check more per pixel).

The idea is quite neat - the algorithm could work like this:
*Calculate the blurred pixel as usual.
*Compare the original pixel to the previous frame. The bigger the difference, the less will the pixel get blurred.

That will make low-freqency noise even easier to detect.

Might actually work!

I've also recived a great suggestion for adaptive threshold, that adapts the threshold to the luma value of the current pixel - so there are lots of improvements in the works. First priority is still an MMX-optimized YUV version though.

manono
25th July 2002, 18:31
Hi Klaus-

SSHiQ is far and away the best spatial (and someday spatial-temporal?) smoother out there, and I use it frequently. Please don't get me wrong-I understand what you're saying and was just joking around. Much respect and thanks is due to you and your program, and the optimized version is eagerly awaited.

sh0dan
25th July 2002, 18:39
If I get the time, I'll try to throw together a test-version in C - I've been thinking about using temporal data for some time, and this just triggered a good idea. :)

Maybe I should do it tonight, instead of watching a movie ;)

poptones
25th July 2002, 19:36
I don't get it. Both multiplication (convolution) and addition (averaging) are associative and commutative. You can specify thresholds within layer or by making a mask from the original (unfiltered) source. 5+3 = 3+5 every time...

The problem with temporal filters is they are so doggone slow. It seems like every filter that adds another frame fetch from a file doubles the encode time.

dividee
25th July 2002, 20:09
Sorry I don't follow you. Adaptive operations are usually not commutative nor associative. If for example, the operator @ represents the following function:

a @ b = (a+b)/2 if |b-a| <= treshold
= a otherwise

then
a @ b != b @ a (not commutative)
a @ (b @ c) != (a @ b) @ c (not associative)

For instance, let a=10, b=25, c=15 and treshold=10:
a @ b = 10
b @ a = 25
a @ (b @ c) = 15
(a @ b) @ c = 12.5


The problem with temporal filters is they are so doggone slow. It seems like every filter that adds another frame fetch from a file doubles the encode time.

Not true! temporal filters usually works in 1D while spatial filters usually in 2D (such as convolution), so temporal filters are usually faster. You just have to be careful with implementation of such filters, using some kind of buffering to avoid fetching too much frames at once and trashing the cache with a lot of parallel pointers.

Koepi
25th July 2002, 20:30
Isn't it possible to adopt such pixel averaging with toms TomsMoComp filter? I mean that would be the best filter ever.

Apply some spatial smoothing if someone wants that and look where the pixel went an average that out as well ;)

Just to bring in this idea again...

Regards,
Koepi

Marc FD
26th July 2002, 00:13
The problem with temporal filters is they are so doggone slow. It seems like every filter that adds another frame fetch from a file doubles the encode time.

I agree with dividee. cnr2 is real-time capable on my AthlonXP 1.4 Ghz
in 640x480. And if richard finish the BitBlt optimisations, it could go damn faster (40-60 fps).

Isn't it possible to adopt such pixel averaging with toms TomsMoComp filter? I mean that would be the best filter ever.

Tom said is algo couldn't be used in a temporal filter :(

PS : I like fast filter and 3D-filter sounds like slow as hell for me.
Like koepi said, the best would be a MC filter, but i would be damn slow too. but will give a much bigger noise-removing effect.
(and would be much much harder to code :D )

vlad59
27th July 2002, 14:12
I just coded an avisynth filter that does the 3*3*3 average with a simple matrix till now :


Prec frame : Cur frame : Next frame :
1 2 1 2 4 2 1 2 1
2 4 2 4 8 4 2 4 2
1 2 1 2 4 2 1 2 1


I've also added a luma an chroma treshold like on the example of Dividee to keep edges and take care of scene change.

I work quite good but it's damn slow (in fact it's the slowest filter I've ever seen).

Next to do is MMX a little (the matrix is done for that) and add a little buffering.

If someone already want this filter (it's very very very slow, I warm you), I can post it throught this forum.

Marc FD
27th July 2002, 14:32
Slow, it was already know, but does it really worth it ??
I think that the real question.
I think people who chain several filters to gain quality like
sshq with tempsoften are far away from searching fast filters :)

avih
27th July 2002, 14:35
I've also added a luma an chroma treshold like on the example of Dividee to keep I've also added a luma an chroma treshold like on the example of Dividee to keep I've also added a luma an chroma treshold like on the example of Dividee to keep edges and take care of scene change.

how did u implement that? with respect to the final result only? or with respect to each of the 26 pixels?

it's also possible to provide different thresholds for the temporal vs 2d operations.

cheers for the work ;)

vlad59
27th July 2002, 14:46
@MarcFD

You can not imagine how slow it is ...........
I've attached a zip with the filter. it has only been tested on a full size vob with no other filter.
With a very noisy material, i use this :

convolution3D (8, 16)
first parameter : luma treshold
second parameter : chroma treshold


@avih

In fact, I've made a slow method (don't know if it's a good method).

For each pixel surrounding the center pixel :
if the absolute différence with the center pixel > Treshold
then the corresponding matrix value become 0 so I don't take this pixel into account.

This method will be hard to optimize so I'm corrently trying something else.

avih
27th July 2002, 14:59
yup. imo your method should produce very good results, but it's indeed hard to optimize.

i had really rough times trying to optimize this method on a 2d (3x3) deringing filter.. ;)

the other thresholding technique u can use is calc the convolution anyway, and apply it only if the final result is inside |thresh| from the original pixel. that's how deringing is usually implemented.

good luck anyway

vlad59
27th July 2002, 17:23
Can a moderator say me if I have attached a zip file with my last post ????

Sorry for this 0-use post

Swede
27th July 2002, 17:26
No attachment there... :rolleyes:

vlad59
27th July 2002, 17:30
Ooops, I always forget it :mad:

So you can test the slowest filter of earth

EDIT : removed this old zip file

dividee
27th July 2002, 18:14
Indeed checking the treshold for each pixel is much better, IMHO. Else, as poptones said, you can do it with existing filters.
And in fact in this case you could probably optimize it a lot by doing three separate [1 2 1] passes, one on each axis (horizontal, vertical and temporal). It would only need to process 9 pixels/output pixel instead of 27 (and 21 for a 7x7x7 instead of 343 :) ), altough temporary stores would be needed, it should be faster.

The intermediary solution is just using something like SmoothHQ followed by TemporalSoften...

What I mean is that for your filter not to be redundant, it has to work like it is working now. (this sentence feels somehow wrong, sorry for bad english)

tenebrenz
28th July 2002, 14:18
And in fact in this case you could probably optimize it a lot by doing three separate [1 2 1] passes, one on each axis (horizontal, vertical and temporal). It would only need to process 9 pixels/output pixel instead of 27 (and 21 for a 7x7x7 instead of 343 ), altough temporary stores would be needed, it should be faster.
This sounds like common sense, i think this kind of filter would be a good "one stop" solution to general denoising. I would use it.

vlad59
28th July 2002, 15:46
My first goal when I began to optimize this filter was to remove all multiplications so I had to change the way I use tresholds :

Now I do this way :
if the absolute difference is > treshold
the values of the working pixel is remplaced by the values of the center pixel.

So my coefficient matrix is always the same and my MMX/SSE (I use pextrw, don't know if it's a good idea) code only use add and shift (till now 2 times faster : only very very slow ;) ).

From the test I made it seems to respect also the edges and the scene change. I've not done a PSNR to compare the two methods.

I kept my original code so it could become an optionnal C fallback code.

Now my method is to compute the weight of each 3*3 matrix (prec, curr, next), to add them and to divide by 64 (i.e. << 6).

I've also tried to buffer the weight of each frame but as there is a treshold check for every pixel it could produce some ghosting at scene change (I've seen that).

So I you have some theory to help me to optimize or make the algo better, feel free to post here.

vlad59
28th July 2002, 16:00
@Dividee

What you propose is to have a matrix like that :


Prec frame : Cur frame : Next frame :
0 0 0 0 1 0 0 0 0
0 1 0 1 6 1 0 1 0
0 0 0 0 1 0 0 0 0


??

Of course it should be faster ... I make a test

avih
28th July 2002, 16:12
but that would sort of eliminate the advantage of 3x3x3... don't u think?

vlad59
28th July 2002, 16:57
I agree, that's why I asked dividee if I understood him well.

vlad59
28th July 2002, 18:32
Another dumb question : how do you debug a avisynth filter with VC6 ???

EDIT : Perhaps wrong section, ooops

dividee
28th July 2002, 18:54
No that wasn't what I meant.
What I was talking about is just a standard 3x3x3 convolution without pixel tresholding (although you could treshold the final result), using exactly the same matrix as yours:

1 1 2 1
2 x 1 2 1 = 2 4 2
1 1 2 1

and then

1 2 1 [ 1 2 1 2 4 2 1 2 1 ]
2 4 2 x [1 2 1] = [ 2 4 2 4 8 4 2 4 2 ]
1 2 1 [ 1 2 1 2 4 2 1 2 1 ]

where [ ] represents the third dimension

Sorry I'm not used to manipulate 3D matrixes but i hope you get idea: doing three 1-dimensional passes instead of one 3D pass.

But don't bother too much, it's just a particular cas of 3D convolution symmetrical along each plane.

dividee
28th July 2002, 19:02
for debugging filters, I usually create an avs that reference the dll directly in the Debug folder (or change the target of the Debug build to the folder where the avs is). I put VirtualDub as executable for debug session, then press F5 (after adding breakpoints if you want) and load the avs in virtualdub. Hope it helps

vlad59
28th July 2002, 19:06
Thanks Dividee

I'll try that. But I just make a post in developpement section for this question, can you remove it ???

Thanks again.

dividee
28th July 2002, 19:22
No I can't. But if you have additionnal questions about it, post them there.

Marc FD
28th July 2002, 23:04
Hmm, the thread gave me a good filter idea.
I'm going to create a MAD (motion adaptive denoiser) filter.
And maybe modifying it i could create a Noise Killer
( a filter who (almost) ONLY remove noise, like sshq )
But i will make some tests before. And i've my benchmark
project. I'll send a beta to this thread as soon as i've
made the first beta. It should lead to very good results :cool:

PS : It's far away from a 3D convolution but i will be a sort of
temporal+spatial filter ....

bb
29th July 2002, 07:16
Just wanted to add that I'm glad this discussion seems to lead to real improvements in denoising techniques. It's exciting to test the upcoming filters!

@vlad59:
Thanks for your effort. I'll test it this evening on analogue capture and on DV material.

@Marc FD:
That sounds very promising, too. I'm curious how it will compete to a 3D solution.


bb

Marc FD
29th July 2002, 10:22
That sounds very promising, too. I'm curious how it will compete to a 3D solution.
hehe :devil:
in fact (if it works) it will keep all the pros of temporal and spatial without the cons. The thing is that i'll use a motion detection engine (the same than in CopySame) and choose the best denoising solution for each pel of the video :)
And if i add pattern detection, maybe it could make a nk

I'm going to work. Would be better when you could test :cool:

bb
29th July 2002, 12:00
Originally posted by Marc FD
Would be better when you could test :cool:

I'll test it as soon as you have something up and running (and post it, of course).

bb

Marc FD
29th July 2002, 15:10
I've made a first "sample". It's not very fast (about 15 fps)
It's not a 3D filter and in fact i only implemented temporalfiltering in it because i don't know how to make a good spatial denoiser.
I've compared it with TempSoften2 and it seems to ghost less on movements scenes...
I didn't have the time to test it alot. i prefer try to create a new type of spatial filter with pattern noise detection.
I prefer create new algos than improving old ones.
When i would have a good spatial filter, MAD would be a real temporal and spatial filter. (in this version only the movement detection is a bit "spatial" :) )

@Dividee

I didn't exactly understood how do you debug avs filters...
do you have a special VDub version ??

I attached MAD.zip
just wait...

vlad59
29th July 2002, 15:14
In the alpha version I attached in this thread, i probably swapped the chroma and luma treshold so If you see something strange try to swap those two parameters.

I'm too lazy to check that now, in my next release it'll be clear.

Koepi
29th July 2002, 15:21
MarcFD,

you're great, finally a motion compensated temporal smoother, I love you (erm, not in that gay way of course ;) ).

I'm eager to test it on some TV footage as I have plenty problems with denoising such stuff. I think it'll turn out you're making yourself an unforgettable hero :)

Swede, come on, enable the attachment already! I need to test that stuff :)

Marc, how about first finishing the temporal smoother stuff until it works as you want it to and then you look into the sources for spatial filters and adopt that code? (should be the same code as the temporal smoother, just not in the z (time-)dimension, but in the x and y directions of a single picture, or am I mistaken here?).

Anhow, thanks for that (hopefully) amazing filter!

Regards,
Koepi

Marc FD
29th July 2002, 15:55
Whow,Whow,Whow !!!
NO RUSH !!!
IT'S NOT A MOTION COMPENSATED FILTER !!!!
IT'S A MOTION ADAPTIVE FILTER !!!!
it would not compensate motion it would adapts to
it !! Nothing to do with ME in codecs like XviD !!!!
And my filter is far from doing amazing results !!
I'm afraid you're overestimating this flter ;)

Currently it just look a _bit_ better in fast scenes
than ie tempsoften2 because it wouldn'nt smooth
what's moving. that's all :(

Koepi
29th July 2002, 16:05
Erm, sorry that's what I meant ;)

I think when you can detect motion (maybe the direction?) you can use that information to smooth "corresponding" regions. But I think it's easier to just detect motion areas and then apply the spatial soften, as proposed. Well, take your imte, I didn't want to rush things, I wanted to test it :)

Ok, back to add automaisation support to OggMux...

regards,
Koepi

Marc FD
29th July 2002, 16:05
Marc, how about first finishing the temporal smoother stuff until it works as you want it to and then you look into the sources for spatial filters and adopt that code? (should be the same code as the temporal smoother, just not in the z (time-)dimension, but in the x and y directions of a single picture, or am I mistaken here?).

In fact,like i said, i don't like to copy very used algos.
Peoples who have coded them are better than me for that.
I want to try a new way of spatial filtering (and maybe it wouldn't work...)
MAD is not a motion compensated filter :
It's an "hybrid" denoiser :
- In movement areas, he would use spatial filtering, because it leads to better results when there is motion, and if there is blending, it wouldn't be seen.
- In still areas, he would use very aggressive temporal filtering, because there is no ghosting, it wouldn't be seen too.

The idea is just to mix the advantages of spatial and temporal filtering.

@Koepi
Sorry, but i'm afraid you will be VERY disappointed if you think my filter will make miracles :( (i would create an MoComp filter if you want when i would be older.. let's say 18 Ok :) after all, i've writed my first C lines in the beginning of THIS month)

PS : when i say temporal/spatial filtering, it's not like a temporal/spatial smoother. i try to destroy High-frequency noise, not to blend low-freq noise.

PS@Koepi : If you have got an heavy chroma noised analog, you should try cnr2. I think would work much better than MAD on chroma denoising.

Back to work now. will try to create a pattern detection spatial noise killer... hope it would work better than normal Spatialsmoothers :D

bb
30th July 2002, 06:58
First testing results (I need to do a lot more, of course):

Convolution3D: Still needs some tweaking, but it seems to be superior to a pure spatial or temporal filter. It's slow indeed, but I had an optimizing approach in mind which I didn't want to keep by myself:
What if you cache three frames and interleave them like 3 lines of 1st frame, then 3 lines of second frame, then 3 lines of third frame, then next 3 lines of first frame again, etc. Then you apply the filter; in the end you have to de-interleave again. I think this could greatly improve processor cache hits.

MAD: I had to guess what the parameters mean, so I tested the proposed "Normal", "Hard", and "Soft" settings. "Normal" and "Hard" seemed to be unusable to me because of way too much ghosting. "Soft" simply didn't get rid of the noise - I'm afraid there's still a lot tweaking to be done...
Marc FD, could you please post the meaning of your filter's parameters?

bb

vlad59
30th July 2002, 09:27
@bb

Thanks for testing. I think I'll release a new beta today (3 times faster and exactly the same quality), just little bug to track and it will be good.

Till now I've just added some SSE optimizations but no buffering at all, I'll try to buffer when the main algo will be finished (I don't expect a big speedup if I want to keep quality, but I may be wrong).
I'll try to think about your idea tomorrow, but you have to keep in mind that the slowest part of this algo is the way I use the treshold and that's also prevent me from doing to much buffer optimization.
Let's explain with a sample :

I'm computing a Luma sample = 100 and my luma treshold is 10.
My original values are :
Prec frame : Cur frame : Next frame :
101 101 100 090 101 100 189 190 80
099 100 100 010 100 100 190 200 80
090 105 100 010 010 100 140 201 80

I use my treshold to detect edges and scene change and :
Prec frame : Cur frame : Next frame :
101 101 100 090 101 100 100 100 100
099 100 100 100 100 100 100 100 100
090 105 100 100 100 100 100 100 100

Next I calulate the weight of each frame :
Prec frame : Cur frame : Next frame :
1601 1592 1600

Now the new luma value = (1601 + 2* 1592 + 1600) / 64 = 100
New Cur frame (no change) :
090 101 100
010 100 100
010 010 100

No change with this sample


With this sample you see another pb :
The next frame must be a scene change so for my calculation I change all its values to 100.
Advantage : my convoluted luma value won't become 130 so no ghosting
Drawback : my convoluted luma value has a high probability to keep its original value.

I thought of adding a SAD to check for this case but it will slow again the filter.

What do you think about it

Ivion
30th July 2002, 09:27
Ok, also here are my first result using the MAD filter.

Tested on: Rurouni Kenshin Tsuiokuhen OVA 2 (I choose this one cuz RK [Rurouni Kenshin] is usually very noisy and I like this OVA :))
Results: Normal And Soft were both not capable of removing all of the noise, altough Normal did a 'decent' job, tough 2D Cleaner by Jaan Kalda was better. Hard didn't work to well, for there was alot of ghosting, and with alot, I mean alot!
Like: there was a scene of two people talking and one moment the 'camera' (it's anime, so there isn't really a camera :D) was pointed at the wall, and the second moment it pointed to one of the faces and then there were still some 'pieces' of the wall on the image.
So I think some tweaking is gonna be needed, good luck Marc FD!

I currently can't provide you guys with screenshot for it's now encoding and the result that's posted here is based on some still images of the avs script.

bb
30th July 2002, 12:01
@vlad59:
Unfortunately I haven't programmed filters (yet). Therefore I'm not familiar with all the MMX and SSE jargon (what's SAD?). I was just thinking that you need to process a lot of pixels from different frames in a way which is _very_ awful for a cache. Thus the reordering of the frame lines could be a huge advantage.

I have to think about your way of processing. Just a (maybe stupid) question: How exactly do you calculate the weight?

bb

Koepi
30th July 2002, 12:07
Hm.... i have some versions to offer:

Search And Destroy (hehe, sometimes it really does!)
See At Definition )I like that one)

or simply

Summation of Absolute Differences.

Regards,
Koepi

vlad59
30th July 2002, 12:33
Originally posted by Koepi
Hm.... i have some versions to offer:

Search And Destroy (hehe, sometimes it really does!)
See At Definition )I like that one)

or simply

Summation of Absolute Differences.

Regards,
Koepi

I prefer Search And Destroy ;) :D

With my previous example :
100 is my computed value.
200 is the same value but a frame later

Absolute difference is abs (100 - 200) = 100
if this AD > Treshold (10 in my sample)
then I don't use the next frame at all (more speed and maybe more quality)

So the new value is (1601 + 2* 1592) / 48.

Back to code ......

bb
30th July 2002, 13:01
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

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 ?

bb
1st August 2002, 08:11
@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.

bb
1st August 2002, 18:02
@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:

Suikun
1st August 2002, 21:35
MAM beta 5 keeps on crashing on me T_T
The VDub status bar states that it's trying to read from address 0x00000004.
I used the following script:


mpeg2source(...)

Telecide(chroma = true, threshold = 30)
Decimate()

Crop(16,8,688,464)

s = SmoothHiQ(3,50,40,192,3)
t = TemporalSoften2(1,6,8).Cnr2()

MAM(t,s,4,8,6,0)

CopySame(1, 32, 32, 0, 1, 2)

SimpleResize(480, 360)


It's definitely MAM causing the crash.
Using a PIII...

Marc FD
1st August 2002, 22:01
ARGH !
at first frame ??
sh*t. (and your CPU wouldn't change anything : it's plain C++)

@Shodan
I will try this on Cnr2. I will read it more seriously off-line...

@Shodan,Dividee,Vlad59 (&me?)
hey there is plenty good avisynth coders here...
adding audio support to avisynth would be piece of cake for such a team
(just a proposition. this avsEx thing "me fait chier" in french.)

MoonWalker
1st August 2002, 22:16
MAM Beta 4 works for me...Just downloaded beta 5 and I got an access violation error..


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)


I am using avisynth 2.02(from sourceforge)..
MoonWalker

Suikun
1st August 2002, 22:23
Yes, it crashes immediatly when I request a frame, so your first-frame bug seems to be back ^_^;

Marc FD
1st August 2002, 22:28
i think i updated too fast :(

okay i will release MAM beta5-2 in 30-60 min.
i can easily correct this bug : i eleminated in in CopySame 1.1 already
:cool:

EDIT : It wasn't 100% fixed (1/2 bugs) new beta5 work fine for me now.
I uploaded it (the .dll file should be created @23h41)

Suikun
1st August 2002, 23:09
Yep, it's there and works...

...as long as you don't use VDub scrollbar, which results in an access violation while trying to read from 0x00000000...sorry ^_^;
Scrolling frame by frame works though.

[Edit]
And encoding anything leads to the same error...

Marc FD
1st August 2002, 23:25
So you can't access to the first frame but you can access all other frames ??

strange. are you using it really alone ?? (no cnr2, no CopySame)
I get it working, even encode with my following script :

a=MPEG2source(...)
s=a.sshq(7,15,25,192,10)
t=a.cnr2().TemporalSoften(1,10,20) #cnr2.2
m=MAM(t,s,2,4,8,0) #MAM beta5-2

m=m.CopySame(1,4,8,2,0.05,3) #CopySame 1.1 dev

return m

I'll try again. Hope it'll crash (a coder saying that... LOL :) )

Suikun
1st August 2002, 23:46
No, I can access frames as long as I start with the first frame and don't make any jumps.
So watching in this order works:
1 2 3 4 5 ...
But this doesn't:
5 1 2 4 3

And yes, it's really MAM. I commented it out but used all other filters (Cnr2, CopySame, SmoothHQ), returned temporal+spatial or temporal.CopySame(...).SimpleResize(...) and everything worked fine.

Marc FD
2nd August 2002, 01:47
I founded a new bug. Now it work 100% @home :)

The bug was not in M.A.M. nor in Cnr2 but in TemporalSoften :rolleyes: !
it was accessing impossible frames (-1,-2,-3,ect..)

Try this script :
MPEG2source(...) #no trim !!!
TemporalSoften(n,...,...)

it will always crash at frame n-1 !!! (ie ts(3) will crash at frame 2)

So i added a protection against temporalsoften in my filters.

The script i wrote in my previous post work now, even without trim.
if you use a trim(n,0) with n > ts radius you wouldn't see any bug.

temporalsoften2 works well (better than ts1)

i hope this would correct your pb. if not, dl Cnr2.2b and M.A.M. beta5-3 and use exactly the same script as mine. If it still not works, try with TemporalSoften2 and MPEG2source(...).Trim(10,0)
If i can get it working, there is no reason you can't, right ?

@sh0dan
I tested you code against mine :
- It's not faster,it's as fast = 32 fps in 576x320
- Due to "src=src2;" (i think it should be "src=child->GetFrame(n-1);") and an omitted "srcp2+=src2->GetPitch();" ,it's a no-op (it wouldn't remove noise) and makes artifacts.

but even when it's corrected i don't see why it would go faster (because it is not going faster) :
- the BitBlt is only used at jumps (so never in stream use)
- the redundancy is compliled as fast as possible (it's just more convenient to read)
Anyway, thx for trying to improve it. but i think it would not be so easy :(

PS : i think MMX optimisation would be usefull in M.A.M. : maybe in beta6 :)

I think i first need to sleep some hours.

vlad59
2nd August 2002, 08:36
@bb and maybe others

I made a new filter SimpleConvolution3D (I've searched a long time to find a good name but I'm no good in that) wich accept 3 new parameters to specify the weight matrix of the previous, current and next frame (everything should be explained clearly in the txt file included).

The latest Convolution3d attached in this thread is equivalent to :

SimpleConvolution3D (8, 16, "1 2 1 2 4 2 1 2 1", "2 4 2 4 8 4 2 4 2", "1 2 1 2 4 2 1 2 1")

in an very optimized way (but without any quality loss).

I'll be away for the weekend, so if you have any problem please post feedback today

Wilbert
2nd August 2002, 10:05
@vlad59,

I'm very impressed with your Convolution3d filter. For those who are interested I made some tests with version alpha 3. I used it for filtering noise from an analog capture. I compared it with the following scripts:
_____
# MergeLuma & Cnr2
source=AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
LumaFiltered=Source.TemporalSmoother(2)
ChromaFiltered=LumaFiltered.Cnr2().MergeLuma(LumaFiltered)
Levels(ChromaFiltered,3,1.03,255,8,240)

# MAM:
AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
s=SpatialSoften(1,4,8)
t=TemporalSoften(1,4,8)
MAM(t,s,2,4,8)
Levels(3,1.03,255,8,240)

# 2d_cleaner:
AviSource("F:\shakira-underneath_your_clothes.avi")
ConvertToRGB32()
VD_2DCleaner(255,1)
Levels(3,1.03,255,8,240)

# Convolution3d:
AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
Convolution3d(8,16,0)
Levels(3,1.03,255,8,240)

# Layer (with 2 different broadcastings):
# Described in the thread Averaging two analog captures for noise reduction (http://forum.doom9.org/showthread.php?s=&threadid=28438).
clip1=AVISource("F:\shakira-underneath_your_clothes.avi")
clip2=AVISource("F:\shakira-underneath_your_clothes2.avi")
clip1=clip1.ConvertToYUY2.TomsMoComp(0,15,1)
clip2=clip2.ConvertToYUY2.TomsMoComp(0,15,1)
clip3=Layer(clip1,clip2,"fast")
Levels(clip3,3,1.03,255,8,240)
_____

I didn't finetune any parameters, so let me know if I used some stupid parameter sets. Since I did't have TemporalSoften2 or SmoothHiQ on my computer I couldn't use them :) I'm very impressed with Convolution3d because it beats everything (at least with the clip that I used) using one broadcasting.

The results (I took two snapshots of Shakira-underneath_the_your_clothes):

First picture (look at her hair): MergeLuma & Cnr2 (worst), MAM, 2d_cleaner, Convolution3d (best using one broadcasting), Layer (best).

Second picture (the one with the phone): 2d_cleaner (worst), MAM, MergeLuma & Cnr2, Convolution3d (best using one broadcasting), Layer (best).

vlad59
2nd August 2002, 10:42
@Wilbert

Thanks for the test and you should also thank bb who gave me the idea.

I'm happy someone make a test with an analog capture. I've only tested with some noisy anime (from DVD) and I was waiting for some other feedback.

I noticed that all filters except Layer darken the movie a little, or perhaps my eyes need a little rest.

The parameters of Convolution3d are only here to take care of edges and scene change. You can increase them (especially the chroma treshold) but stop as soon as you see some blurring around the edges or some ghosting. With the settings you used (and I use the same) you shouldn't have any of these problems.

One of my remaining worries is I can't have a strength parameter, the strength of the filter is only given by the weight matrix which is hardcoded in Convolution3D, that's why I released SimpleConvolution3d to check for other interesting matrix.

Thanks again for your test.

Wilbert
2nd August 2002, 11:15
I noticed that all filters except Layer darken the movie a little, or perhaps my eyes need a little rest.

Yes, I noticed that too. I don't understand why yet ...

Marc FD
2nd August 2002, 14:29
Originally posted by Wilbert
# MergeLuma & Cnr2
source=AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
LumaFiltered=Source.TemporalSmoother(2)
ChromaFiltered=LumaFiltered.Cnr2().MergeLuma(LumaFiltered)
i would use Cnr2 before
Levels(ChromaFiltered,3,1.03,255,8,240)

# MAM:
AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
s=SpatialSoften(1,4,8)
MAM'll avoid artifacts, so you can easy go for a ss(5,15,25) !!
t=TemporalSoften(1,4,8)
maybe a Cnr2().TemporalSoften(1,10,0) would be better ?
MAM(t,s,2,4,8)
This is an old version (before beta3). if you don't want to tweak, you can use these settings :
MAM(t,s,4,8,4,2)
Levels(3,1.03,255,8,240)


If you use a filter with aggressives settings, and others with soft settings, the first will always wash more ;)
And notice that MAM is increasing less compressibility than alone filters : it's designed to get maximum quality, so you can use very aggressive settings (ie "Avoid Blur" mode with Cnr2 + sshq(7,15,25,192,10) )

I'm going to make MMX optimisations for MAM and CopySame. I think it could go damn faster : 25-30 fps @640x480 (alone of course)

@Sh0dan
is sshq MMX optimised ?? i would really like to see a very fast spatial filter.
@Dividee
is ts2 MMX optimised ?? i would really like to see a very fast temporal filter.
if sshq and ts2 could get around 25 fps, we could make real-time MAM encodes with Cnr2+sshq+ts2+CopySame :cool:

sh0dan
2nd August 2002, 14:42
Originally posted by Marc FD

@Sh0dan
is sshq MMX optimised ?? i would really like to see a very fast spatial filter.
@Dividee
is ts2 MMX optimised ?? i would really like to see a very fast temporal filter.


SSHQ MMX is in the works - about 75% done, but it still needs debugging and testing. It'll most probably not reach 25fps (on todays machines anyway) - as with you, quality is in the high seat.
A simpler implementation is still on my todo-list, but there are still things as temporal testing in sshq, new audio filters, luma weighing in sshq on my list as well.
TS2 is optimized, and dividee has implemented it in Avisynth 2 as TemporalSoften (test it in the CVS snapshot if you like).

When you've got CNR2 and MAM completely tested and stabilized, I would like to nominate them for inclusion in Avs2 - they're very useful!

Wilbert
2nd August 2002, 14:47
Thanks for your input (got something to do sunday). Btw, I used MAM beta 4.

Originally posted by Wilbert
# MergeLuma & Cnr2
source=AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
LumaFiltered=Source.TemporalSmoother(2)
ChromaFiltered=LumaFiltered.Cnr2().MergeLuma(LumaFiltered)
i would use Cnr2 before
Levels(ChromaFiltered,3,1.03,255,8,240)

Can you elaborate, what do you mean with "i would use Cnr2 before"? How would you change the script above and why?

I will also try the following:

# MAM:
AviSource("F:\shakira-underneath_your_clothes.avi").ConvertToYUY2().TomsMoComp(0,15,1)
s=SpatialSoften(5,15,25) # or s=SmoothHiQ(7,15,25,192,10)
t=Cnr2().TemporalSoften(1,10,0)
MAM(t,s,4,8,4,2)
Levels(3,1.03,255,8,240)

Again, thanks for your suggestions!

Marc FD
2nd August 2002, 14:54
ts2 is C optimised or MMX optimised ?? (or both)

for Cnr2,ok. If there is no way to optimise a lookup table based algo :( .
but MAM and CopySame needs lots,lots of work ....
(in fact MAM is 75% finished but the Movement Detection Engine is the same than CopySame and it's evolving more and more.. i'm working on CAD_MMX, SAD_MMX SCAD_MMX now..)

Sh0dan, you seem to be well informed on digital audio. could you guide the others avisynth coders (trbarry,richard seemed interessed, and me too ) to make audio support ? I think everybody want to help, but we don't know how to start : maybe you could try to begin the work, and it would be more easier to follow you (to do optimisations, bugfixes,ect...)

Just an idea. (avisynth with audio sounds like a far dream for me...)

Marc FD
2nd August 2002, 14:57
@wilbert
maybe this :

Cnr2().TemporalSoften2(1,10,0)

(cool , only second version temporal filters :) )

It would go faster too.

EDIT : Keep in mind i only say values who are potentialy good. i don't have time enough to test my filters (only debbuging :( ) So please tweak,tweak, and tweak more. My readme.html files explain good what does each values.

sh0dan
2nd August 2002, 15:17
Originally posted by Marc FD
ts2 is C optimised or MMX optimised ?? (or both)

Both are very well optimized (dividee's wizardry :) )

but MAM and CopySame needs lots,lots of work ....
(in fact MAM is 75% finished but the Movement Detection Engine is the same than CopySame and it's evolving more and more.. i'm working on CAD_MMX, SAD_MMX SCAD_MMX now..)

Great to hear! Looking forward to it :)


Sh0dan, you seem to be well informed on digital audio. could you guide the others avisynth coders (trbarry,richard seemed interessed, and me too ) to make audio support ? I think everybody want to help, but we don't know how to start : maybe you could try to begin the work, and it would be more easier to follow you (to do optimisations, bugfixes,ect...)


Audio is quite easy to do - just have a look at audio.cpp. Samples are handled as a method in the image filters.

void __stdcall Amplify::GetAudio(void* buf, int start, int count, IScriptEnvironment* env)

You are handed a buffer in which you must place the final samples, you get an offset in samples (start), that indicates what sample should be the first in the buffer, you are handed a samplecount (count) that indicates how many samples you must put into the buffer. This method is then called each time avisynth needs more samples.

child->GetAudio(buf, start, count, env);

is you way of getting samples from the source clip - notice the similarity to your own method. :)

Since you can change the starting position it is possible to read other samples than the ones you must return. Normalize for instance reads all available samples on the first call, and calculates the amplification based on the maximum values.

These are the clip parameters that has something to do with audio:

int audio_samples_per_second; // 0 means no audio
int num_audio_samples;
bool stereo, sixteen_bit;



Just an idea. (avisynth with audio sounds like a far dream for me...) [/B]

Avisynth has quite good audiosupport ATM, even though I often have to save out waves in vdub, and importing them seperately.

bb
2nd August 2002, 16:59
In order to test the vlad59's SimpleConvolution3D filter I wondered how to distribute the weights on a mathematical basis. I thought it would be a good idea to make the weights proportional to the inverse square of the distance to the center pixel.

Maybe a linaer or a cubic approach could give better results, so I decided to write a small Excel spreadsheet, which calculates the weights automatically for the linear, square, and cubic approaches by simply entering the desired weight of the center pixel.

Here we go. Of course we have to wait until the moderator checks the file.

bb

Marc FD
2nd August 2002, 23:08
@Sh0dan
The avisynth big hole is in Audio import. What we need is mp3 decoding from .avi files !!! That was what i was talking about !!
mp3 parsing + mp3 decooding in avisynth like in VDub would be my dream. It could be used as a standalone postprocessor :)

@All
MAM v0.6 out. Big improvements. Totally MMX/ISSE optimised and better accurancy. test you'll made now are a taste of the final version :)

I've made a little test (1500 frames / XviD quant2) :
1) MAM(Cnr2().TemporalSoften2(1,10,0),SmootherHIQ(3,15,25,192,10))
2) SmootherHIQ(3,15,25,192,10)
3) Cnr2().TemporalSoften2(1,10,0)
4) MPEG2source(...).Crop.SimpleResize.Trim only

1) 14,2 MB
2) 14 MB
3) 15 MB
4) 16 MB

The quality changes weren't noticable...

I'm really a n00b in spatial filtering but i'm still trying to do a SpatialSoften2 (only MMX) I'll try to get it damn fast. It'd be usefull to create some motion smooth with MAM.

EDIT : Whow 4 pages now !! This thread grow incrediblely fast !!

trbarry
3rd August 2002, 02:19
I usually don't do analog captures or smooth very much but there is some stuff from my Tivo I have to process before I send it back for repair. And you guys in this long thread got me intererested in the issue again.

So today I sat down and wrote a "Motion Compensated SpacioTemporal Median Filter, STMedianFilter().

The good news is that it has a very fancy name and does not generate many artifacts, even if the parms are cranked up to the max. The bad news is that it doesn't seem to filter very much for some reason. ;)

But I thought I would explain what I did and maybe someone else can take it and run with it, or at least point out how I could improve it.

There is no strong theory behind this, I just made it out of parts of my GreedyHMA and TomsMoComp filters.

But if I understand it right a simple median filter is just a clipping step where a value is set to not extend past the high and low of its neighbors.

For instance, if you had 3 pixels in a row that had the values <5,8,7> you could clip the center one to not be outside the low of 5 or the high of 7, so you would set it to 7.

Now imagine you had a small 3x3 video screen, like one surface of a Rubiks cube. Imagine the previous frame was the bottom layer of the cube, the current frame was the middle layer, and the next frame was the top.

Then the current center pixel would be right in the center of the Rubics cube and there would be 13 ways you could draw a line through it and a pair of two nearest neighbors.

What I did was to compare each of those pairs of neighbors to see which pair was most agreeing on value. I used that pair to clip the value of the center pixel. I clipped luma only, so it will take another filter like CNR2 for the chroma.

I also clipped the pixel value only if both:

1) It would not change the pixel value by more then the FilterThreshold parm value, and

2) The amount of 'uncompensated motion' (agreement on value by neighbors) was less than the MotionThreshHold parm value. So a typical application might look like:

STMedianFilter(150,20)

Still totally experimental but anyone interested in playing with it should see:

www.trbarry.com/Readme_STMedianFilter.txt and
www.trbarry.com/STMedianFilter.zip

... including source.

I'd be interested to hear if anyone thinks this actually accomplishes anything, or could be made to. I honestly don't understand why it does not filter a bunch more than it appears it currently does.

- Tom

edit: Just ran a test of 2000 frames of Xvid fixed quant=2 and the output was about 2.4% smaller so maybe the filter is doing something, even if I can hardly see it. But maybe that's close enough to be lost in the noise. ???

bb
3rd August 2002, 08:34
Ok, you think this is a looong thread? Let's make it even longer! :devil:

I did some testing with Marc FD's and vlad59's filters. Here are my test settings and the results:


DV Video: 1221 frames (ca. 49s)
Low light condition (much noise)

DivX 5.02
1-pass quality-based Quantizer 4
B-Frames
Max Keyframe interval 300

AviSynth: filter only, no resize

VirtualDub: fast recompress, no audio


test1:
s=v.SpatialSoften(1,4,8)
t=v.TemporalSoften(1,4,8)
MAM(t,s,2,4,8,1)

test2:
s=v.SpatialSoften(1,8,16)
t=v.TemporalSoften(1,8,16)
MAM(t,s,2,8,16,0)

test3:
SimpleConvolution3D (4, 8, "1 2 1 2 4 2 1 2 1", "2 4 2 4 8 4 2 4 2", "1 2 1 2 4 2 1 2 1")

test4:
SimpleConvolution3D (4, 8, "17 27 17 27 76 27 17 27 17", "27 76 27 76 255 76 27 76 27", "17 27 17 27 76 27 17 27 17")

test5:
SimpleConvolution3D (8, 16, "1 2 1 2 4 2 1 2 1", "2 4 2 4 8 4 2 4 2", "1 2 1 2 4 2 1 2 1")

test6:
SimpleConvolution3D (8, 16, "17 27 17 27 76 27 17 27 17", "27 76 27 76 255 76 27 76 27", "17 27 17 27 76 27 17 27 17")

test7:
Convolution3D(4, 8, 0)

test8:
Convolution3D(8, 16, 0)

testA:
SimpleConvolution3D (8, 16, "1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1")


Filter abbreviations:
M MAM by Marc FD (+ SpatialSoften and TemporalSoften)
S Simple Convolution 3D by vlad59
C Convolution 3D by vlad59
V VirtualDub filters (2d cleaner optimized, temporal smoother)

Results:
enc. time fps AVI size remarks
- test0 1,5 min 14 17.892 KB unfiltered (compressed only)
M test1 9 min 2 14.036 KB
M test2 8 min 3 10.898 KB
S test3 24 min 1 13.708 KB
S test4 24 min 1 14.098 KB
S test5 24 min 1 9.344 KB
S test6 24 min 1 9.936 KB
C test7 4 min 5 16.800 KB green flashing border
C test8 4 min 5 12.450 KB green flashing border
S testA 24 min 1 8.772 KB

V classic1 4 min 5 9.632 KB spots, blurry
V classic2 3,5 min 6 11.280 KB more spots, still blurry


classic1: 2d_cleaner opt. X2 Y2, temporalsmoother(1)
classic2: 2d_cleaner opt. X1 Y1, temporalsmoother(1)
(VirtualDub in full processing mode here, of course)


The resulting clips all looked very good compared to the original. I looked at test5, test6, and testA more closely, because they resulted in best compressibility. In spite of what you might expect, these were among the best in terms of quality.

@vlad59:
In test7/test8 the green flashing border seems to kill the compressibility. That one should be fixed, else it's unusable.
Watch the trivial convolution matrix in testA. The results turned out to be very good, and I guess that one could be optimized like hell!

@Marc FD:
I didn't have your last version of MAM available when I did the test. I think I have to use other spatial/temporal filters as well. Do you have recommendations?

bb

OUTPinged_
3rd August 2002, 09:53
Tbarry, your filter produces artifacts on thin vertical lines.


Tried it on a dvdsource with applied "FILM effect" (very light noise), the noise removal is pretty weak.

can provide pictures if needed

Marc FD
3rd August 2002, 12:16
@bb
use MAM v0.6 please : it will lead to much better results. I'm still happy my filter gives good results (test 2 seems a good compromise between encoding time and efficacity, could you expand on it)

The combinaison i tested the most is the following, it's only the combination who is the most dangerous (who will make crash avisynth the more often) but now it's stable. please keep in mind MAM as this powerfull (thanks to avisynth) feature to be compatible with ALL spatial and temporal filters.

MAM(Cnr2().TemporalSoften2(1,10,0),spatialsoften(2,15,25))
or MAM(Cnr2().TemporalSoften2(1,10,0),smootherHIQ(3,15,25,192,10))

I'll implement a fast SimpleSpatialSoftenMMX in MAM, so you will only need temporal filtering and source in a special fast mode (i'll try to achieve 20 fps)

@trbarry
Argh ! If you make filters too, my filters would really look like crap :(
i don't know how to do any spatial filtering, so i'll test you method too (clipping). Can i use UnFilter to do spatial filtering ?? can you suggest settings (i never use UnFilter :( )

@Dividee
Why i not TemporalSoften2 in avs ?? It's not stable enough, it's a choice, or you just didn't had the time ??

@Sh0dan
Hey, making spatial filtering is really hard, i respect even more your work on SmootherHIQ now !!

ARDA
3rd August 2002, 13:06
@Marc FD
As I don't see Dividee here now I dare to answer
Just two days ago
focus.cpp 1.2 43 hours dividee TemporalSoften (MMX & C )
(previously released as plugin TemporalSoften2)
Get the avisynth.dll in:
http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html .

Arda

trbarry
3rd August 2002, 14:35
OUTPinged_

Yes, please post a pic. But I could see how a median filter could obscure single pixel detail by thinking it was noise. I could not find any cases where it actually did that in real life but the solution would be to lower the FilterThreshHold parm so high contrast single pixels are not eaten. The DScaler version of GreedyHMA has a median filter and I recommended running that one with an F-ThreshHold of no more than about 5 but my testing of STMedianFilter didn't show the problems so I cranked up the estimates.

I'll have to think about this some more. It was only about this time yesterday reading this thread that I decided to write this. And usually when I do something like that I have to throw away the first one. ;)

@trbarry
Argh ! If you make filters too, my filters would really look like crap
i don't know how to do any spatial filtering, so i'll test you method too (clipping). Can i use UnFilter to do spatial filtering ?? can you suggest settings (i never use UnFilter )

Mark FD -

Judging from my efforts yesterday my noise filters are not going to furnish much competition for anything. But maybe I'll get inspiration. ;)

I guess maybe looking at only a 3x3x3 cube is just too small for much noise, or I did something else pretty stupid.

You can use UnFilter for spatial softening a small amount with sharpness parms maybe UnFilter(-20,-20) and a larger softening over a 5x5 area with parms about UnFilter(-50,-50). But it is not a full convolution. The convolution matrix always is calculated to end up like:

0 0 x 0 0
0 0 x 0 0
x x x x x
0 0 x 0 0
0 0 x 0 0

with no interest in diagonals. And if the horiz and vertical filter parms are (abs value) low (about -30 < n < 30) then it effectively only uses a 3x3 matrix with the terms in the outer border also 0.

- Tom

OUTPinged_
3rd August 2002, 16:22
ok, here it is, a piece of processed image pasted on top of original.


Recommended setings were used.

Marc FD
3rd August 2002, 18:09
Whow. Making a MMX Spatial Median filter is really hard.

I made the following :


123 112233
456 in luma and 445566 in chroma (due to YUY2 subsampling)
789 778899

4321
+6789 (masked)
xxxx > sad / num > new 5


My MMX code need about 50 instructions to deinterlave YUY2 data and to get the 4321 and 6789 values in my luma 3x3 and my chroma 6x3 window.

Is my method totally dumb or is it really the faster way to do Spatial Median Filtering ??

Are there other ways to get good spatial filtering (something very fast, who blurs a little at high thresholds)

Does anyone know the algo of 2D cleaner for exemple

Thx

trbarry
3rd August 2002, 19:42
Whow. Making a MMX Spatial Median filter is really hard.

Yep. YUY2 is a pain to work on sometimes. That's why for my first cut at my non-functional filter I just did luma only. I processed 4 pixels at a time in MMX, letting it get the hopefully right answer for the luma bytes and the certainly wrong answer for the chroma bytes. Then I replaced the chroma bytes with the originals.

If I ever get a useful luma result then maybe I'll do chroma too but if the luma doesn't even work then I won't bother.

For performance I've thought of gradually building separate Y and UV work areas but it is way to soon for me to be thinking much of optimization so I don't really know if that would work well.

- Tom

Marc FD
3rd August 2002, 21:10
my MMX loop was too long (150 lines), so i decided to abort it :(
I was using 8xYUYV values at a time, but i'm not sure it would go faster than plain C :(
i think i will release my next version of MAM with 2-3 built-in spatial filters. so the users of this thread could do tons of tests.
I would optimitse the most used algo.
(the C version works great : i get 10% compressibility improvement over SpatialSoften(1,30,50) with 30,50 settings too and it has less artifact (good selective blur) il will do a 1D/1D version and a 1D/semi 2D version,it would easier to MMX-optimise)

The interest of adding built-in SpatialSoften in MAM is to gain much compressibility on motion, while it's moving too fast to be noticable... interessing to avoid blocking. the aim is of course to bo able to build the "super ultimate avisynth script" who'll use the betters filters to achieve HQ satured quant 2 encodes ;)
(don't fall of your chair, it's a _joke_ :D )

trbarry
3rd August 2002, 23:52
Well, I fixed a couple silly bugs and put out a new version of STMedianFilter at www.trbarry.com/STMedianFilter.zip .

Since it actually filters a bit now you have to be careful to not set the parms too high or you can get ghosting and disappearing fine lines.

It also now has 6 parms instead of 2 since I separately broke out the user threshhold parm values for spatial, temporal, and horizontal. See the descripion of the parms at www.trbarry.com/Readme_STMedianFilter.txt (or in the zip) for the new meaning of the parameter values, or maybe just try:

STMedianFilter(10,50,8,10,10,50)

which seems to work all right and not do anything too drastic.

I kept horizontal filtering separate from the other spatial filtering since horizontal streaks can often be caused by the cheap analog to digital converters in the capture cards and I wanted to process the vertical and diagonal componenets separately. Dunno if that helped or not.

But still tinkering, and it is still just a luma filter.

- Tom

Marc FD
4th August 2002, 01:33
3 spatials filters in testing...
maybe i would release MAM with 5 spatial filters to test

I tried median interpolation, it works good but it makes horrible artifacts when i use a raduis of 2 :(

@ trbarry
I'll try something like your clipping method too ( in 2D of course )
:)

trbarry
4th August 2002, 02:26
I tried median interpolation, it works good but it makes horrible artifacts when i use a raduis of 2

Mark FD -

I call it a clipping step because that's how I first designed it in DScaler, before I'd ever heard of a median filter. And with only 3 elements it amounts to the same thing.

But if a radius of 2 means 5 elements I guess a median filter still means sorting them and taking the middle out of 5. Is this what you were doing? Or sorting all the elements in the r=2 circle or square (cube?) and taking the middle. I don't know which is correct, but it seems hard.

I do know from my first median filter in DScaler that I fur sure need the FilterThreshHold parms. A median filter seems to work well only if you restrict it to small changes though I'm not quite sure why. But median temporal filters without the threshholds make ghosts and median spatial filters withouth threshholds eat thin lines.

- Tom

trbarry
4th August 2002, 03:37
What the heck, I'm up to v 0.0.3.0, see www.trbarry.com/STMedianFilter.zip

I realized I could add a small amount of chroma filtering with little effort and no run time overhead, so I did.

The spatial chroma filtering is only vertical and the temporal chroma filtering is motion compensated only vertically, but that got me around the YUY2 alignment issues, and it does seem to help a bit.

I think I'm finally ready to process my fuzzy captured Tivo stuff. ;)

- Tom

Marc FD
4th August 2002, 11:22
@trbarry
Could you explain how do you do motion compensation ??
when you say you're processing 2 pels at once, you mean one YU / YV pel ?? or do you mean YUYVYUYV at once. i tried to do 8 YUYV pels at once with YUYV deinterlaving. Is it a good idea ??

My first spatial filters was using 2D median interpolation.
but you can't use interpolation on larger raduis than 1 (seems logical...)

I will try median filtering in 2x 1D and in 2D now.i think 2D cleaner uses 2D median filtering. But i'm not sure (the algo must have been modified for better opt.)

What's the algo used by SpatialSoften ??

trbarry
4th August 2002, 13:11
trbarry
Could you explain how do you do motion compensation ??

Mark FD -

The poor man's version of motion comp that I use here just checks which pair of pixels would match best, from the prev an next frames, and assumes that is due to motion if close enough. For instance, let's just consider horizontal luma motion comp of a single pixel on a line, by comparing it to 3 values on the same line of the prev and next frames. Say we had luma values:

Prev frame: 10, 17, 20
Curr frame: x, 12, x
Next frame: 30, 5, 10

We could consider the pairs <10,10>, <17,5>, and <20,30>. The first one has the smaller abs diff so we could hope it was the same pixel moving to the right one frame at a time. Our temporal median filter would then clip the 12 to 10, as long as TMotionThreshHold => 0 and TFilterThreshHold => 2. It won't always be right but hopefully will be an improvement on average. I tried more complicated ideas when I wrote TomsMoComp but came back to the simplest algorithm. So it either takes the best match from the prev and next frame, or none at all, leaving the pixel unchanged.

In STMedianFilter.cpp in the zip see the single assembler macro called something like CHECK_BETTER_NEIGHBOR in the source code.


when you say you're processing 2 pels at once, you mean one YU / YV pel ?? or do you mean YUYVYUYV at once. i tried to do 8 YUYV pels at once with YUYV deinterlaving. Is it a good idea ??


I process 4 pixels (8 bytes) at a time in an MMX reg as (reversed byte order) VYUYVYUY. That's the main advantage of MMX for video. On my P4 I can even do 16 bytes at a time but there is a greater penalty for non-16 byte alignment and longer latency so it isn't always worth it.


My first spatial filters was using 2D median interpolation.
but you can't use interpolation on larger raduis than 1 (seems logical...)

I think the idea of a bigger median filter is still taking the middle value. If you were filtering the center of the 5 values <3,2,7,12,4> I think the answer would be 4. But I don't know how pleasing this would be since they aren't equally important as you get further away. I don't know how to weight a median filter for distance. ???


I will try median filtering in 2x 1D and in 2D now.i think 2D cleaner uses 2D median filtering. But i'm not sure (the algo must have been modified for better opt.)

What's the algo used by SpatialSoften ??

Sorry, I haven't looked at that filter.

- Tom

HarryM
4th August 2002, 13:50
Originally posted by trbarry
What the heck, I'm up to v 0.0.3.0, see www.trbarry.com/STMedianFilter.zip

I realized I could add a small amount of chroma filtering with little effort and no run time overhead, so I did.

The spatial chroma filtering is only vertical and the temporal chroma filtering is motion compensated only vertically, but that got me around the YUY2 alignment issues, and it does seem to help a bit.

I think I'm finally ready to process my fuzzy captured Tivo stuff. ;)

- Tom

Hi trbarry,


Can you add into your homepage links for all your utilities and avisynth filters (at least simplex, please)?

You produce verry useful things, but i can't find a compact view (list) of your utilities...

Thanks.

Ivion
4th August 2002, 13:55
Originally posted by HarryM


Hi trbarry,


Can you add into your homepage links for all your utilities and avisynth filters (at least simplex, please)?

You produce verry useful things, but i can't find a compact view (list) of your utilities...

Thanks.

Actually were getting offtopic, but, who cares *hides for the mods*. :p
You can find most of trbarry's filters in AviSynth FAQ. I hope that's enough for you. :D

dividee
4th August 2002, 15:42
SpatialSoften is very simple: it's basically a "thresholded convolution" with a matrix containing 1's (btw I think a "thresholded convolution" is not a convolution).
For instance with a radius of 1 and a threshold of 7, from the following pixels:

5 10 15
8 7 19
6 15 25

you would get for the center pixel:
5+10+8+7+6 / 5 = 7 (no change)

Well, this is not entirely true as it doesn't work independently on luma and chroma, a pixel is added to the sum only if both luma and chroma pass the threshold.

baz00ie
4th August 2002, 16:51
Well, in an attempt to make this the longest 'thread' in the world, i will add my findings....

I've been doing some quick experiments using the above mentioned filters and i've found that using both SimpleConvolution3D and MAM beta5 provided some great results.

here is a link: www3.sympatico.ca/joseph.cooke/index.htm

and,...
Thank you for you efforts, everyone, you're work does not go unappreciated.

take care
baz

Suikun
4th August 2002, 18:48
Sorry to bother you again ^_^;;

MAM still hates me...

MAM(Cnr2().TemporalSoften2(1,8,6),SmoothHiQ(3,50,40,192,3))

Most pictures are completely distorted and occasional it crashes stating "MMX statement left on: T:\[something I don't remember]..." but this is not reproducable. Yet again it works without MAM.
Used: MAM ver 0.6, Cnr2.2b
Attached it the picture of the a distorted image. Somehow looks like early XviD versions with resolutions % 16 != 0...

metallikop
4th August 2002, 19:19
Regarding MAM:

I'm getting an access violation, like the one seen with b5.

Avisynth: caught an access violation at 0x00d070d7, attempting to read from 0x00000000.

avisynth (beta 6) as follows:

LoadPlugin("E:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("E:\PROGRA~1\GORDIA~1\mam.dll") # v.6
LoadPlugin("E:\PROGRA~1\GORDIA~1\TemporalSoften2.dll")
mpeg2source("D:\DVD\BladeRunner\Source\bladerunner.d2v") # DVD2AVI v1.76
s=SpatialSoften(1,4,8)
t=TemporalSoften2(1,4,8) #TemporalSoften also
MAM(t,s,2,4,8,0)

and:

LoadPlugin("E:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("E:\PROGRA~1\GORDIA~1\TemporalSoften2.dll")
LoadPlugin("E:\PROGRA~1\GORDIA~1\SmoothHiQ.dll")
LoadPlugin("E:\PROGRA~1\GORDIA~1\mam.dll") # v.6
LoadPlugin("E:\PROGRA~1\GORDIA~1\Cnr2.dll") # 2.2b
mpeg2source("D:\DVD\BladeRunner\Source\bladerunner.d2v") # DVD2AVI v1.76
MAM(Cnr2().TemporalSoften2(1,10,0),smoothHIQ(3,15,25,192,10))

Sorry about the length of this post.

trbarry
4th August 2002, 20:13
OUTPinged_ -

Did you by any chance try the new STMedianFilter (and the new settings)? I'd be curious if it fixed your problem. It hopefully should.

BTW - The very first version that you tried had a bug that caused it to choose a pair of neighbors more or less randomly, which is why it didn't really filter much.

- Tom

Marc FD
4th August 2002, 21:02
If you have problems using MMX, there should be a way to desactive it...
i will check the code.

I didn't work on MAM today because i implemented a .dll C version of xla (XviD log analyser)

Recommendations to make MAM work :
- avoid TemporalSoften(1) use Ts2 instead.

- try MAM alone :
a = mpeg2source(...)
MAM(a,a)

- try all possible MAM settings (modes at least)
- try to trim the firsts frames of your source
- please read the readme.html carefully (you should understand everything)
- make plenty of tests, don't stuck on one script

When you say MAM is not working because when i remove it it works, i'm sorry but you're wrong. I tested MAM b5 crashed with temporal soften but was working alone. keep in mind it's not an usual filter, it's a composite filer who use other filters (who aren't always compatible or bugfree)

@Trbarry
I like the poor's man MoComp :)
I'll take a look on the sources.
I've ideas for a simple MoComp. I'll try to do MoComp of the entire image (for travellings and maybe zooms) it could be usefull for a temporal filter (travellings makes temporal filters totally useless, and i don't see MAM making heavy spatial filtering on the entire image (beurk))

EDIT : Saw the image :eek: "How My God !"... horrible :(
i think the debug mode is broken... didn't tested it...I will work more on MAM now :D

@dividee
i'll try MMXed SpatialSoften. hope it wouldn't be too hard :)

metallikop
4th August 2002, 22:34
@Marc FD

I took your advice and tried running your test through with the settings you suggested, then I tried with disabling everything to no avail. Is anyone else still getting these problems, or am I overlooking something simple?

MAM(a,a,2,4,0,0)
MAM(a,a)
MAM(a,a,2,4,8,0)
etc. etc.

Marc FD
4th August 2002, 22:47
i don't remember...

I will try to crash it myself, but i really don't see how i could do it.
maybe i've broken the code just before doing a release build (that would be really dumb)

Hope it would work (a day)

vlad59
5th August 2002, 15:41
@all

Wahoo, I'm going away 2 days and when I'm back : ~20 post to read.....

@bb
Yep, Convolution3d is fast but I know I've been lazy ;) when I began MMX optimizations so you could have a green rectangle around your image. I'll check that soon (maybe tonight).

I'll also add your very simple matrix (full 1) as it seems to be a good solution.

But I was happy when I saw the time results, my optimizations are working well :)

daiyam
5th August 2002, 16:03
@bb
Yep, Convolution3d is fast but I know I've been lazy ;) when I began MMX optimizations so you could have a green rectangle around your image. I'll check that soon (maybe tonight).


I have also a green rectangle all aroud the frame with width ~= 3 pixels.
But if we undersize the frames before call Convolution3d (we give a 5 pixels gap around the frames).
And after, if we delete this gap, there are no green rectangle!!!

Marc FD
5th August 2002, 17:46
normal, it's just that the algo is not used on the borders to avoid memory exeptions :)

I've released MAM v0.6 spe

there is no improvements in MAM but there is a special mode you can use to test the builts-in spatial filters :)

there are 6 filters :
2D median interpolation / 2x1D median inter. / 2D fixed convolution / 2D soft blur / 2D edge detection and 2D sharpening !

I'll add several new modes (thresholded convolutions and median clipping)

if anybody as another idea (just idea, don't need coding skills) of spatial filtering, just expose them and i will try to code them

(Of course to code all this so fast, they'are all alphas versions with fixed raduis (always 1))

But you can set the luma/chroma threshold
Let's make TONS of tests to keep only the bests filters who will be MMX-optimised :cool:
I'm counting on the testers :)

Ivion
5th August 2002, 20:27
Marc FD, while testing your filter I came across a problem wich was already been stated here in this topic. I got a acces violation, te be exact, this one; 'Avisynth: caught access violation at 0x090e70d7 attempting to read from 0x00000000'. Tough I tried everything you suggested, I still got the acces violation, even with this script:
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\filters\mamspe\mam.dll")

src=mpeg2source("E:\test.d2v")
MAM(src,src)
So my guess is that it's still MAM, or MAM in cooperation with mpeg2dec, tough I couldn't test it without mpeg2dec, for I do not capture or anything of the like. :)

dividee
5th August 2002, 21:13
I don't know how MAM reads frames but I think mpeg2source doesn't like too much random access. Could you try the following script ?

LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\filters\mamspe\mam.dll")

src1=mpeg2source("E:\test.d2v")
src2=mpeg2source("E:\test.d2v")

MAM(src1,src2)

Don't blame me if it doesn't work, but I think it's worth a test.

tenebrenz
5th August 2002, 22:00
With me I get an access violation when I open a script containing mpeg2source in virtualdub and then press play >0. If I advance one frame first and press play it doesn't crash.

Ivion
5th August 2002, 23:36
Originally posted by dividee
I don't know how MAM reads frames but I think mpeg2source doesn't like too much random access. Could you try the following script ?

LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\filters\mamspe\mam.dll")

src1=mpeg2source("E:\test.d2v")
src2=mpeg2source("E:\test.d2v")

MAM(src1,src2)

Don't blame me if it doesn't work, but I think it's worth a test.
Sorry, still doesn't work, again a acces violation, tough there was a subtle difference in the error, the previous error was: 'Avisynth: caught access violation at 0x090e70d7 attempting to read from 0x00000000'.
While this one is: 'Avisynth: caught access violation at 0x00d970d7 attempting to read from 0x00000000'

As I know repeat the test again (my script and dividee's script), the error's are suddenly the same :confused:. Dunno if that is of any help

scorchED
5th August 2002, 23:45
Originally posted by Ivion

Sorry, still doesn't work, again a acces violation, tough there was a subtle difference in the error, the previous error was: 'Avisynth: caught access violation at 0x090e70d7 attempting to read from 0x00000000'.
While this one is: 'Avisynth: caught access violation at 0x00d970d7 attempting to read from 0x00000000'



The MAM Filter works well with AVISource - with MPEG2Source you have prblems like above. Try this script with an AVI (maybe with VFAPIConv).

Ivion
5th August 2002, 23:48
Originally posted by scorchED



The MAM Filter works well with AVISource - with MPEG2Source you have prblems like above. Try this script with an AVI (maybe with VFAPIConv).

VFAPIConf *shivers*, all this trouble with avisynth, the greatest 'scriptable' frameserver, and we have to resort to VFAPI? ;) :p
Ok, I'll try, I'll edit this post after my attempt. :)


Results (Scripts can be found here: http://www.xs4all.nl/~mbeerman/Scripts)
Script 1: Works
Script 2: Miserable Failure (just like Suikun's image, somewhere on page 8)
Script 3: Works

Hope this'll help

Marc FD
6th August 2002, 00:00
I'm sorry but i can do whatever i want with MPEG2source, i can't crash it !!!!

I'm being more and more sure that the problem comes from MPEG2dec.dll

What's the version you're using ??
if you want i would attach my MPEG2dec.dll to this thread but before you should try an another version...

I think mine is the one who comes with GKnot 0.26 but i'm not sure.
(the MPEG2dec i use makes ONLY .d2v decoding and don't have others filters in (like dividee's version ) )

Hope whe will fix that :)

PS : If anyone can get MAM working (without the errors described before ) PLEASE say it !!! i'm beginingto think that my filter can only work for me..... :rolleyes:

and while i'm here, i released the more various filter of avisynth history : the 12 in 1 filter !!
In MAM v0.6 spe2, there is now 12 filters you can test (with 10 cleaners who 2-3 are really serious)
simply load MAM.dll and then play with :

SpatialFiltering(mode,lumathr,chromathr)

see the txt file for more info.

I would really like to see test results :)
with 12 modes it you could all play for a while :D

scorchED
6th August 2002, 00:21
I use the following script for ripping "Erkan und Steffan". It includes the MAM-filter (not the last:o ). It works well with VFAPIConv only.
___________________________________________________________________
LoadPlugin("D:\AudioVideoCoding\_AVISynth\mpeg2dec.dll")
LoadPlugin("D:\AudioVideoCoding\_AVISynth\mam.dll")
LoadPlugin("D:\AudioVideoCoding\_AVISynth\SmoothHiQ.dll")

Source=AVISource("D:\_DVDs\Erkan und Steffan\yuv 64.avi").crop(2,82,716,414).ConvertToYUY2

m_slowmotion=Source.SmoothHiQ(5,48,96,128,0).TemporalSmoother(2,1)
m_fastmotion=Source.SmoothHiQ(3,32,64,128,35)

c_slowmotion=Source.SmoothHiQ(7,48,96,128,0).TemporalSmoother(4,1)
c_fastmotion=Source.SmoothHiQ(3,32,64,256,35)

Movie=MAM(m_slowmotion,m_fastmotion).Trim(0,120535).BiLinearResize(560,320)
Credits=MAM(c_slowmotion,c_fastmotion).Trim(120536,0).BiLinearResize(560,320)

Return Movie+Credits
___________________________________________________________________


If i use the same cript with a MPEG2Source, the movie i get looks very crazy. Does anyone know whats wrong?:confused: :confused: I will attach a screenshot (don't know how to do it).

edited: here is a link to the bad pic (http://www.torstensanio.de/audio_video/doom9forum/mpeg2source.jpg)

Koepi
6th August 2002, 00:42
You should try the dx81-yuv-fix.exe which should be in the old news from last months or on another thread down here in the avisynth forum.

Your domain can't be found, so I can't see the picture, but I guess that's what's going on.

Using vfapi is a bad thing, we use avisynth to stay in YUV colour space to gain speed and less loss due to colour space conversions.

Koepi

Ivion
6th August 2002, 00:48
Originally posted by scorchED
edited: here is a link to the bad pic (http://www.torstensanio/audio_video/doom9forum/mpeg2source.jpg)

First point: Shouldn't your link be: http://www.torstensanio.de/audio_video/doom9forum/mpeg2source.jpg? :rolleyes: :sly: :D
Second point: Your 'disorted' image looks just like that one from Suikun and me with my 2nd Script. So the problem is related to eachother...well, gonna take a look into your script. :D

scorchED
6th August 2002, 01:03
i fixed the link - sorry for this misstake.

i installed the "fix" before the encoding and i have to say that i don't like it, because my BSPlayer can't play my HufYuv-files now. So i deinstall after my testing.

i know that VFAPI is for the "poor man's" quality, but i wanted to test it, because without it, my scipt doesn't work:(

i will test the MPEG2dec.dll from Marc FD now - i have dividee's version.

scorchED
6th August 2002, 01:41
MarcFD, can you add a scenechange-detection in your MAM filter? So after a scenechange, we can reset the x and y results (mam(x,y)). It's needed for the temporal filtering on still areas in a scenechange. It coult reduce the ghosting after a scenechange, which is produced by the temporal filter, and the keyframe"quality" is much more better. For example TemporalSmoother don't have to compare the first frame after the scenechange with frames before the scenechange.
Is it possible to code that in the MAM-filter or have the TemporalSmoother have to be rewritten?

dividee
6th August 2002, 02:10
Hum. In fact TemporalSmoother HAS BEEN rewritten to do exactly what you describe ;) The scene change code I posted was an extract from it.
But for now I only have C implementation and have been on other projects lately so it sits dormant on my disk. I promise I'll finish the MMX version as soon as I get my developing environment back.

scorchED
6th August 2002, 09:41
maybe i make something wrong, i think the scenchangedetection in TEmporalSmoother doesn't work. Only the second (TemporalSmoother(1)) or the thirt (TemporalSmoother(2)) frame after a scenechange is clean :(

vlad59
6th August 2002, 09:47
I think you misunderstood what Dividee said : he has changed TemporalSmoother only on his computer (he said : it sits dormant on my disk).

It's not released now.

Marc FD
6th August 2002, 11:37
in fact MAM does already change detection :) better, it does MOVEMENT detection !! (yes,yes) so when you have scene-change, it's considered to be a 100% movement frame, and temporal filtering is NOT used .
And remind MAM can (now) just prevent ghosting from raduis 1 temporal filters.
I'm waiting on results for my 12 spatial filters. then would add some temporal filters so MAM could work in "integrate mode"(with it's own filtering) who'll be much faster (at least 2x , with spatial filtring MMX much more...)


EDIT : I don't like scene-change detection.. I haven't tested dividee's pack but i'm afraid it's very difficult for a simple algo to see the difference between a travelling and a scene-change...maybe pattern detection ? or Motion compensation ?

bb
6th August 2002, 11:48
@Marc FD:
There are different scene change algorithms. E.g. some compare the average luma value of consecutive frames and detect a scene change, if the difference is above a certain threshold. I don't know how well this works, but this kind of scene change detection has nothing to do with motion detection.

bb

Marc FD
6th August 2002, 11:56
yes of course they are plenty of ways of doing it :)
but if you have a flashing light, your scene-change algo will get mad.
The problem is to have an all around scene-change algo. and that's not so easy !

bb
6th August 2002, 12:17
True. If you want a well-working solution you'll probably have to combine different methods (without compromising performance, of course :eek: )

It's so easy if you have camcorder timecodes...

bb

scorchED
6th August 2002, 12:43
@MarcFD

can you attach your MPEG2dec.dll on you're next post please?
I get an access violation error everyime i use a mpeg2source:(
i tested trbarry's dll, GKnot's dll and dividee's dll - everytime the same error. I tested it with the simple script you posted.

maybe this error depends on the CPU? I have an Athlon C 1333MHz.
which AVISynth version are you using? I am using 2.02.

Ivion
6th August 2002, 15:42
Yeah, Marc FD, could you please post your MPEG2dec.dll? The one I use is the one provided by the newest gknot (0.26, right?).
As you might have read my test, with my 3 sample scripts, it seems that crop in combination with avisource, converttoyuy2 and mam produces weird results. Maybe that's a bug too?
So, we've 2 bugs, one with MPEG2dec and one wich happens when using this script (http://www.xs4all.nl/~mbeerman/Scripts/test2.avs), for when using this script you will get one of the weird images, wich have already been posted in this thread.

Hope this'll help.

Marc FD
6th August 2002, 23:43
I'm really sorry :(
really.

In fact the bug was corrected in MAM b3-b4
And i dumbly reintroduced it !!
i've disabled buffering because it was giving less quality and could be buggy... and i replaced it with a very dangerous frame access
(never access the n-1 frame ....)

i've seen it in the code, could reproduce the bug (in fact if you use Trim(1,0) before MAM everything would work fine :rolleyes: )
so it's corrected now and it should work very good

PS : if you want to make an older MAM version work, simply add Trim(1,0) before :)

The new mam version is MAM spe2b
avaiable in 5 min on my site

scorchED
7th August 2002, 06:01
if you use MPEG2Source don't crop the source directly, you don't get strange looking results like in older posts. The best is, to crop and resize at the end of the script.

--wrong----------------------------------------------------------
source=(...).crop(...)
slowmotion=(source. ...)
fastmotion=(source. ...)
mam(slowmotion,fastmotion)
...Resize

--right----------------------------------------------------------
source=(...)
slowmotion=(source. ...)
fastmotion=(source. ...)
mam(slowmotion,fastmotion)
crop(...)
...Resize

but the calculation time is much more bigger, because there have to be more pixel calculated.
you can cropp an AVISource directly without getting strange results.

Ivion
7th August 2002, 11:31
Originally posted by scorchED
if you use MPEG2Source don't crop the source directly, you don't get strange looking results like in older posts. The best is, to crop and resize at the end of the script.

--wrong----------------------------------------------------------
source=(...).crop(...)
slowmotion=(source. ...)
fastmotion=(source. ...)
mam(slowmotion,fastmotion)
...Resize

--right----------------------------------------------------------
source=(...)
slowmotion=(source. ...)
fastmotion=(source. ...)
mam(slowmotion,fastmotion)
crop(...)
...Resize

but the calculation time is much more bigger, because there have to be more pixel calculated.
you can cropp an AVISource directly without getting strange results.

:confused:
That's not exactly the same conclusion I had, for with this script (http://www.xs4all.nl/~mbeerman/Scripts/test2.avs), I also had the 'weird' image problem, tough I'm using an AVIsource. So I presume it's because the YUY2 source (cuz of the ConvertToYUY2 in this case) in combination with a righ after it (thus before MAM) crop and MAM afterwards.

So, a 'correct' script at the moment will be to crop and resize after MAM, I hope this is also correctable. For the crop is meant to remove black bars wich have none to do with the movie, so using MAM on those while removing them later is a waste. :D

Marc FD
7th August 2002, 11:44
i use crop&resize before mam.
i would try crop only.
if there is a bug, i would correct it :)

PS : does it work better now (with spe2b)

scorchED
7th August 2002, 13:17
if you have an AVISource, you have to Cropp before ConvertToYuv and everything works fine (on my PC).
but the same doesn't work with MPEG2Source:(

Marc FD
7th August 2002, 15:36
BTW i never use ConvertToYUY2()
MPEG2source gives YUY2 output
AVISource with an DivX/XviD/huffyuv encoded file gives YUY2 output too...
but you may need it...
Will look at MAM now.

scorchED
7th August 2002, 16:46
Originally posted by Marc FD
BTW i never use ConvertToYUY2()
MPEG2source gives YUY2 output
AVISource with an DivX/XviD/huffyuv encoded file gives YUY2 output too...
but you may need it...

Yes of course, i know that. But if you use VFAPI than you have to convert the color table.
I think the most important for the MAM is, that is works fine with cropping before MAM (look at the scripts i posted before), because of the big increase in encodingspeed.
MAM is a very very very usefull tool/filter and thank u very much for you're great work, MarcFD.

Marc FD
7th August 2002, 17:09
done :cool:
dl MAM v0.6 spe II (c)

_should_ be bugfree

scorchED
7th August 2002, 20:14
YES!! (sorry about crying)
it works:D

very nice (and surely hard) work! thanks!
i have some ideas how to make the scenechange algos for TemporalSmoother of MAM better. i will make some screenshots and will write a pseudo-code. maybe you'll find my ideas nice to implement them. My goal is to make a perfect filtered I-Frame, so the encoding is more efficient.

vlad59
7th August 2002, 21:28
I'm finally back (too much work) ...
You can't imagine how much I would give to be a simple student again and have a little time.

Well I should stop dreaming.

You will find attached the latest version of convolution3D (the last alpha I think), the changelog is simple :
- No more green rectangle
- No more problem with cropped source
- But it should be a little slower.

I'll released the sources this weekend as soon as I comment asm a little more and change some "french sounding" variables to more english variables. But as usual you can get the latest sources just by emailing me or with PM.

@bb
I had no time to add the full 1 weight matrix, maybe this weekend.

EDIT : removed old version of Convolution3D

Marc FD
7th August 2002, 22:35
@scorchED
no pb. i'll have a look at it. improvements are always welcome.
I've several goods ideas myself. just need to implement and to test them...

@vlad59
he ouais, c con ca... le best c que moi je suis encore au bahut :)
j'ai même pas mon bac... alors tu peux imaginer le degré de glande
(la terminale c pas l'extenutation totale si tu vois c que je veux dire)

"french sounding" variables are COOL !!

bb
8th August 2002, 11:15
@vlad59:
Thanks, I'll test the new filter this weekend.
Do you think you can optimize "full 1 weight matrix" very much? (I think you could completely drop the weight calculation)

bb

vlad59
8th August 2002, 11:31
@bb

I'll be obliged to adapt a little the "full 1 weight matrix" to have a better divisor :

with this matrix I have a total divisor (sum of weight of the matrix) of 9+9+9 = 27
So if I use 27, all the speed gained with the simplier matrix will be lost with division.
I would prefer to have 32 as a divisor (to use right shift) but for this the weight matrix should change a little, for example :


1 1 1 1 1 1 1 1 1
1 2 1 2 2 2 1 2 1
1 1 1 1 1 1 1 1 1


With that I think it could be a little faster than the actual Convolution3D matrix.

Perhaps you could add this matrix to your previous test to see if it changes a lot

sh0dan
8th August 2002, 13:22
Originally posted by Marc FD
I didn't exactly understood how do you debug avs filters...
do you have a special VDub version ??
[/B]

No - use the released vdub.

1) Use the DEBUG configuration.

2) Project -> Settings -> Debug Tab

Select your virtualdub.exe as executeable for debug session.

3) Include the dll in the debug directory in your AVS script

4) Set debug breakpoints using F9.

5) Press 'F5'.

6) VC++ will complain about not finding debug information for virtualdub.exe - ignore this.

7) Load the AVS-file.

8) Seek to another frame.

Bingo! You're in Debug mode.
If you get bombed into debug mode using 'F5', just press 'F5' again.

You can adjust which exceptions should be caught by visual studio in the debug menu.

Marc FD
8th August 2002, 16:02
thanks sh0dan, but i used this feature a while ago now :)
you are too late ;)

Ivion
8th August 2002, 18:25
Well, I ran a quick test with the newest MAM (spe2c), and I was pleased with the result, on my LOTR:FOTR rip it COMPLETELY removed all the (visible) noise, it rocked. :D
Tough, I'm sorry to say, I discovered some bugs. When using this (http://www.xs4all.nl/~mbeerman/error1.avs) and this (http://www.xs4all.nl/~mbeerman/error2.avs) script, I get this image (http://www.xs4all.nl/~mbeerman/error.png).
Tough, this script (http://www.xs4all.nl/~mbeerman/bingo.avs) worked wonderfull!

So, option 3 (2x1D soft blur) and option 5 (2D fixed edge detection) give problems as far as I've tested, for these filters seemed also 'usefull' to test on my source. Option 12 (2D Thresolded Median Clip chroma/luma check) worked like a charm and option 9 looks very usefull for use on animation vids and/or anime, for I found the blurring on 'normal' (normal movies, with humans, special fx, etc.) sources to much for my liking.

Didn't tested the other ones, for it looked (I haven't checked, I'm basing this on the names :D) that 12 and 9 were the best in their 'series' (12, 11, 10, 2, 1 - 9, 8, 7, 4 [if I'm correct :)]), and 3 and 5 also looked interesting, 2bad they didn't worked.

Hope that this test will help you choose the right filters and fix the bugs. :)

scorchED
9th August 2002, 01:28
@MarcFD
why do you include some spatialfilters in mam? i personally use SmoothHiQ, which is the best so far, or do you know a better one?

vlad59
9th August 2002, 07:43
@bb and others

I forgot to inline some functions so now Convolution3D is 1.2fps faster. I'll release the beta1 with sources tonight (in about 10 hours)

@Trbarry
I tested your STMedianFilter and it did a very good job (better than convolution3d ;) ) when temporal informations are not interesting (I tested it in a long fade in from full white to a very complex landscape).
Whereas in static scene when you have very usefull temporal information it always soften less than Convolution3d, it also tend to blur the edges a little bit (only visible at 2* zoom).
Comparing speed was not funny :D , your filter is 2 times faster than mine. I'll definitly have to learn in ASM & MMX .... :( .

I haven't tried to play with the parameters so I only use your suggested settings. I can make a better test this weekend.

trbarry
9th August 2002, 07:52
Vlad -

Actually when I wrote the readme file I had mostly tested with my fairly noisy Tivo capture. For DVDs or other cleaner material I'd probably recomend filtering less, something like:

STMedianFilter(8,15,5,7,8,15)

And just about anything can go faster with a bit more assembler. :devil:

- Tom

vlad59
9th August 2002, 08:14
Originally posted by trbarry
Vlad -

Actually when I wrote the readme file I had mostly tested with my fairly noisy Tivo capture. For DVDs or other cleaner material I'd probably recomend filtering less, something like:

STMedianFilter(8,15,5,7,8,15)

And just about anything can go faster with a bit more assembler. :devil:

- Tom

I test with an old anime reedited in DVD without any good mastering. It has heavy noise and you can even see some scratch from the master, my VHS tape look better than the DVD, I've made a bad deal when I bought those DVD ;) .

So your suggested settings were good enought in most scenes and they could have been stronger in low motion scene.

Convolution3D has already a lot of ASM inside (every time critical part) but they aren't well optimized (I know it), so there's still a lot to do and I don't have your experience ;) ;) ;)

Marc FD
9th August 2002, 09:44
@ivion
i'll take a look next week. i go in holidays today :)

@sorchED
SmoothHIQ is great. No pb. but it's not the faster filter.
the filters i add in MAM would be used in next version in MAD mode.
And this would go damn faster (i'm aiming 20 fps)
It's just an another part of the filter (more strong filtering, more speed) more designed for VHS encodes or animes.

vlad59
9th August 2002, 11:33
@Tom

I just had a look to your sources and I found it :

you only work with bytes and I'm obliged (due to my weigth matrix) to work with word.

That's may be an explaination for the speed différence. ;) ;)

Sorry, but I was so sad to be two times slower, I couldn't have slept before finding a good reason for this difference. ;) :D ;) :D

EDIT : To tell the truth, another good reason is my code is crap sometimes :(

trbarry
9th August 2002, 18:03
To tell the truth, another good reason is my code is crap sometimes

Everybody's code is crap sometimes. ;)

Mine is no exception. But the advantage of open source and the reason I always force folks to download my source along with the DLL's (apart from free backup) is because people write me little notes telling me how to de-crap-itize it. This often gets things fixed in short order.

I think you have sent me a couple of these yourself. :)

- Tom

vlad59
9th August 2002, 19:24
@Tom

Yep, tomorrow everybody will be able to make my code better, I hope so.

@all

This time the last alpha Convolution3D (alpha 5).

The only change is more speed wich is always a good news.

Just a little precision on how the tresholds works :

The parameters of Convolution3d are only here to take care of edges and scene change. You can increase them (especially the chroma treshold) but stop as soon as you see some blurring around the edges or some ghosting. With the settings proposed you shouldn't have any of these problems.


EDIT : Removed old attachement

Slyde
10th August 2002, 22:19
All of you really impress me, I'm really slow as hell compared to all of you... still struggling with master trbarry filter sources to learn and understand. I have just be able to make a basic deinterlacer, CNR port for K!TV and two or three ridiculous things so far... Perhaps it's not good to begin with such optimized code, it really took me a loooong time to understand a bit of GreedyHMA sources :(


Marc FD => tu n'es qu'en term ??? AAAHHHHHHHHHHH :eek: :eek: :eek: je crois qu'on tiens un futur master là. Chapeau ! J'ai plus qu'a aller chercher ma corde...

vlad59
10th August 2002, 23:12
@all

New release of Convolution3d (beta 1) with sources.

Changelog :
- Added the simple full 1 matrix
- code is now included (I had no time to comment & clean it, but I promess to release it)

please read the txt file included before testing.
BB's idea of the full 1 matrix seems to work well but I got some strange results :
the result with the full 1 matrix seems to be better (at least for my tired eyes) but the compressibility test isn't better than the normal matrix.

I'm waiting for your tests.

@slyde
les français parlent aux français ;) :D ;) :D ;) :D
I think we are all learning by reading the sources from experienced coders (Tom, Donald, Dividee, Shodan, Poptones, ...... please don't be offended if I forgot you, I'm just tired :o )
That's great, thank you all.


EDIT : attachment is deleted, my full 1 matrix is buggy, sorry

Koepi
12th August 2002, 02:35
Well, I tested convulution3d a little and it gives me nice results, I'm amazed :)

Now I only have to tweak it a little, you have to speed it up and we're done! ;)

Thanks for the nice work!

Best regards,
Koepi

P.S.: any timeframe when you'll fix the full matrix? I'm eager to see the beta :)

vlad59
12th August 2002, 07:22
Hi Koepi,

I'm happy you find Convolution3d usefull.

I already fixed the full 1 matrix but the result are somehow disappointing (so no release :( ) : the compressibility test with the standard matrix (1 2 1) is still better.

Perhaps my source is strange, I hope bb could make a test with his test sources.

Next on my todo list is to add specific temporal tresholds so you can tweak them to be sure to avoid ghosting.
And then I'll try to optimize it better (I hope I can do that ;) ).

If nothing goes wrong, tomorrow you should have the beta.

bb
12th August 2002, 09:53
@vlad59:
I would like to test the Convolution3D with standard and full-1 matrix at the same time; this way it's easier to compare.
BTW: What do you say about the possibility of optimizing the algorithm for a full-1 matrix (in fact you wouldn't need a matrix at all in this special case)?

bb

vlad59
12th August 2002, 10:36
Originally posted by bb
@vlad59:
I would like to test the Convolution3D with standard and full-1 matrix at the same time; this way it's easier to compare.
BTW: What do you say about the possibility of optimizing the algorithm for a full-1 matrix (in fact you wouldn't need a matrix at all in this special case)?

bb

I don't fully understand, what I'll do is to provide a new Convolution wich has a new parameter to choose between the two matrix.
I hope that's what you want ;)

Optimizing for the full 1 matrix is not easy, let's take an example :

Tresholded matrix are :
10 11 11 13 15 5 10 11 11
10 11 11 13 15 5 10 11 11
10 11 11 13 15 5 10 11 11

To find my new convoluted values I've to add all the matrix values :
Sum = 10 + 11 + 11 + 13 + 15 + 5 + .........

And then divide by the numbers of matrix value i.e. 9+9+9 = 27

new values = sum / 27

That division is the problem :
- I have no MMX opcode to perform a division (or I missed something)
- and a simple division will be way too slow.

That's why I first tried having a weight matrix like that :
1 1 1 1 1 1 1 1 1
1 2 1 2 2 2 1 2 1
1 1 1 1 1 1 1 1 1

With this I can use a left shift to divide by 32
But with this the compressibility test is worse than with the standard matrix


So if anybody has an idea .... :rolleyes:
I have got no time to think about it this weekend, thursday is off in France so you can expect a release in 2 or 3 days max.

dividee
12th August 2002, 11:22
If you don't have division... use multiplication.
Basic Idea:
If you accumulate the sums in words in an MMX register, load an MMX register with four times 65536/27. The usual way in C code would be to multiply by that value and then >> 16. In MMX code, you can use PMULHW (or PMULHUW in ISSE) so you don't even have to do the shift.

Take care of rounding (if you don't want Acaila to complaint about a green tint ;)):
in C code you could do:
(sum * 65536/27 + 32768) >> 16
but that doesn't work with PMULHW (3DNow has a nice PMULHRW, though).
The technique I used in MMX code can be described in C code as:
((sum<<1) + sum) * 32768/27) >> 16

It becomes more difficult to do the "divisions" in parallel if the divisor can vary for each word.
In TemporalSoften(2), I had independent divisors for each word that can vary from 1 to 16, so I constructed a big lookup table with 16^4 QWORD entries. I packed four divisors in a WORD to use as an index in the table an so was able to do 4 "divisions" in parallel.

vlad59
12th August 2002, 13:10
@dividee

That's what I call a clear explaination, thanks a lot.

I'll have a look to TemporalSoften code to be sure I have understood.

thanks again, I'm now obliged to optimize better Convolution3D ;) ;) ;)

bb
12th August 2002, 14:01
@vlad59:
Just another idea: what about using a 2x2x2 or a 4x4x2 matrix?

bb

vlad59
12th August 2002, 15:30
@bb

In theory it's possible but with those matrix you have not a center pixel. I think it's annoying.
I thought about a 5x5x5 matrix, but it will be slower and I first want to have a stable Convolution3d before changing too much the basis.
But if you explain me better what could be cool with this, I can change my mind. You usually have great ideas ;) .

I also thought of not using the previous and next frame when there is too much difference between prev, current and next pixel (only luma will be checked). I should help a lot in fade in or fade out scene.

trbarry
12th August 2002, 16:46
Vlad -

As a small point on performance issues you can usually expand the matrix horizontally faster than vertically. That's because the data will be coming from the same cache lines. So something like a 3x5 will probably be faster than a 4x4 by more than you might expect.

- Tom

bb
12th August 2002, 19:25
@trbarry:
You are probably the master of filter optimisation. What do think about my proposal of interleaving the frames before filtering, then de-interleave again? Like you store 1st line of 1st frame, then 1st line of 2nd frame, then 1st line of 3rd frame, then 2nd line of 1st frame, etc., like
1111111111111111 (first line)
2222222222222222 (first line)
3333333333333333 (first line)
1111111111111111 (second line)
2222222222222222 (second line)
3333333333333333 (second line)
...

This way the pixels you have to touch during filtering would be close together in memory, which - I think - would improve cache hits.

Non-cubic matrices will have an impact on the picture, as far as I can see. You could get the effect that it smoothes more horizontally than vertically. I also thought about dropping the edge pixels, because they have the biggest distance to the center pixel. The perfect 3D matrix would probably be a sphere, not a cube... What do you think?

@vlad59:
You're right, not having a center pixel is annoying, I thought of that problem. I had the idea of something like a running total; the value of a pixel would be updated more than once while the algorithm is "passing by". I still have to think that over, but I can post my idea if you find it useful.

There's a VirtualDub filter using a 5x5x2 matrix, but I was a little disappointed with that one...

bb

trbarry
12th August 2002, 20:13
bb -

Dunno, you'd have to try it. But in order to do this you would have to copy the data 2 extra times and I'm not sure whether that would make up for the (hopefully) better arrangement. And the gain would be processor dependent since the different machines have different cache sizes and stuff.

- Tom

dividee
12th August 2002, 21:33
Why 2 extra times ? Or do you count read & write as 2 times ?
TemporalSoften (and TemporalSmoother) use a similar idea as bb exposed (I didn't invent it, that's the technique Avery used in Temporal Smoother for Virtualdub), except these filters interleave the clips on a per pixel basis instead of per line.
So you have ,with bb's notation (center = frame 2)
123123123...

Since these filters only operate on the temporal axis, it makes the inner loop works totally linearly. As long as the clip is read in sequential order, all you have to do for the next frame is replace the oldest pixels by the newest ones:
423423423 (for frame 3)
and then
453453453 (for frame 4)
The pixel replacement is also done in the inner loop.

The arithmetic of using such a circular buffer is sometimes a bit complicated (especially when you try to add full-scene change detection in the mix ;) ), but I think it's worth it.

trbarry
12th August 2002, 23:39
Maybe I didn't think it through well enough. I was thinking that if you wanted to work with the data in a different format that you would also have to copy/reformat the results back at some point, but that's not necessarily true I guess.

But again, I guess you would have to try it and see if what you gain makes up for the up-front overhead.

When I wrote Greedy/HM (DScaler GreedyHMA version) I reformated the data into what I thought was a clever arrangement that got around some then-current DScaler limitations but in hind sight I'm not sure it was worth it. And I'm almost certain that if I went to the work of pulling out that stuff for the Avisynth version it would go faster. But maybe I just did something silly when I designed the data structure I used.

I guess the way I think about it now is that it is not as important to keep everything close together in memory as it is to minimize the number of cache lines that have to be repeatedly filled on each pass through the filter. So if you hit say, 6 or 8 cache lines (of 32, 64, or 128 bytes each), but then move 8 bytes to the right and it is still the same 6 or 8 cache lines, then you sort of get it for free. But when you move to the next line of the screen then it is probably going to be a different cache line or at least a different (slower) level of memory cache.

There, I have thoroughly confused myself. What did I just say? ;)

- Tom

vlad59
13th August 2002, 19:50
@dividee
you've made a typo when you explain me how to divide :
instead of :
((sum<<1) + sum) * 32768/27) >> 16
you should have written :
((sum<<1) + 1) * 32768/27) >> 16

I just coded it, it works without any problem, thanks again.

@all
Tomorrow you'll have the new matrix (full 1).

dividee
13th August 2002, 20:39
Indeed I made a typo, but your correction is also wrong; it should be
((sum<<1)+27)*(32768/27))>>16 (or: ((sum+(27/2))*(65536/27))>>16 )
which is equivalent to the previously given
(sum * 65536/27 + 32768) >> 16

Koepi
13th August 2002, 20:45
walk like an egyptian... ;)

vlad59
13th August 2002, 21:22
@dividee

Of course you're right dividee, I really regret all the time I spent sleeping instead of listening to my Maths teacher.
Sorry to be such a pain in .... :( :( :(

@Koepi
I love the way you walk ;)

@all

thanks to dividee, you can now download the new version of convolution3D (beta 1) with sources (not commented at all :rolleyes: , I'll make that in 2 days).

You now have the full 1 weight matrix. The compressibility is better with this matrix.

No more speed for now, but I'll need a day or 2 to understand the discussion between Tom and Dividee ;)

EDIT : Removed old attachment

Koepi
13th August 2002, 21:32
vlad:

wanna walk that way as well?

then we could change to RunDMC feat. airosmith(?) - walk this way... and nod our heads like will smith. ;)

Maybe that helps understanding all those formulars.

I'm glad that I finally found out that there's a simple shift operator in c/++ - guess what I had to code around that in the xcdbackupcreator :-/

Dancing,

Koepi

NP: Velvet Acid Christ - Alien Surfaces

baz00ie
14th August 2002, 02:10
Thanks for your work, Vlad59.
I've noticed an increase in quality and speed with the latest release.

take care
baz

vlad59
14th August 2002, 09:47
@baz00ie

First, thanks for testing and using my filter.
Increase in speed ??, I've done nothing yesterday to speed up Convolution3D :confused: . I'll make benchs tonight.

vlad59
17th August 2002, 22:18
Here is the beta 2 of Convolution3D.

The main changes are the new temporal tresholds (thanks Tom for the idea) that will allow to have better compressibility and less ghosting.

This version shouldn't be faster than the beta 1.

I change some part of the internal engine, so if you see some difference, post here.

thanks in advance for testing.

I made some tests :
On my torture test (an old noisy anime badly mastered) :
Convolution3d (1, 12, 20, 8, 8, 0)
and
TemporalSmoother (4)
have roughly the same compressibility test (51.8 for C3D and 50.8 for TS)
but TemporalSmoother produce some ghosting and handle very badly fade in scene (C3D was also bad but somehow better than TS, Tom's STMedianFilter was the best for this scene).
On still scene TS is way better but lose some details.

I'll make new tests with MAM tomorrow.

trbarry
18th August 2002, 01:07
Vlad -

I just took a peek at your code. Looks like you've done a pretty good job optimizing in MMX. :)

I even learned something new from it. I hadn't realized the pinsrw and pextrw instructions could use general purpose register operands. Cool.

- Tom

vlad59
18th August 2002, 07:49
Originally posted by trbarry
Vlad -

I just took a peek at your code. Looks like you've done a pretty good job optimizing in MMX. :)

I even learned something new from it. I hadn't realized the pinsrw and pextrw instructions could use general purpose register operands. Cool.

- Tom

Thanks Tom, I read a lot of code (from you and dividee mainly) to understand better asm and learn new tips. I think I learned something :D . But I'm still not satisfied with my code, there is still a lot to do :o (especially to comment more).

Yep I used pinsrw and pextrw to compute each luma value individually, it cost a lot of time, and I still don't know if it really usefull.

wotef
18th August 2002, 12:06
after doing some tests on some pretty tough analogue VHS transfers, i just want to echo wilbert and koepi's comments - as dr evil would say, convolution3d is frikkin' excellent! i think it should go up on doom9's filters download page as soon as appropriate

bb
18th August 2002, 13:20
@vlad59:
Just a silly question: When you calculate the 3D convolution, do you always process the new values from the original frames? Or do you use the already averaged pixels, e.g. when referring to the previous frame (which would be a bad idea IMO)?

At a first glance the new filter (beta 2) gives great results on my test material (I don't have much time this weekend, sorry).

IMO the filter should get some speed improvement before "giving it to the public" at doom9's downloads.

bb

vlad59
18th August 2002, 13:58
@bb

I'm a little tired (done too much tests last night), so maybe I won't answer to your question. In convolution3d, nothing is buffered now so for each pixel of each frame everything is calculated.
And with avisynth, the frames I get are always unprocessed by my filter, so I always deal with original frames.

Speed improvements !!!
That's the problem, adding buffering can improve speed but I'm afraid it will be hard to make it faster than TemporalSmoother:( :(

Marc FD
18th August 2002, 15:03
Hi :)
I'm back ....
MAM and MAD (and copysame too) would not be continued...
so MAM v0.6 spe3 was the last version...
...until the Mpack implementation works :)

Guest
18th August 2002, 18:00
You guys keep talking about a 3D convolution in YUV space. That will be just dandy for luma. But because chroma is subsampled by 2, you cannot formally implement a 3x3 operation on it. So I have to ask: how are you implementing a 3x3 blur of chroma? I suspect you are causing chroma to leak outside the 3x3 area.

vlad59
18th August 2002, 18:56
@neuron2

In fact I implement the 3*3 operation on each plane Y, U and V. In my Readme.txt I perhaps talk about pixel it's just to simplify the reading.
In my Convolution3D I deinterleave YUY2 to simply work with coherent (don't know if it's an english word) data. I used the 3*3 blur on each plane and reinterleave in YUY2.

That also explain the speed of my filter ;) :( ;) :(

Hope I've been clear enought

EDIT : Oooops just get it, You're right Donald, I use a 3*3 matrix for luma, but for chroma I use 5*3 pixel so 3*3 chroma values.
You're right.

Guest
19th August 2002, 00:08
@vlad59

Well, sure, it had to be. But actually you have 6x3 pixels.

But it is really, really bad! If you iterate this thing, you start spreading chroma horizontally way past where it should be relative to the luma adjustments.

This is a serious problem that I have not yet solved (for 3x3).

Apparently only kernels that are even-sized in the horizontal dimension can be implemented correctly. One could do 4x3 for example.

That would make your filter even slower. :(

Guest
19th August 2002, 00:23
But then there is no center pixel. Oh, woe is me. Is there no solution?

Koepi
19th August 2002, 00:36
Ok, I know you don't see me as knowledgeable in this place, but did you try to use your 3x3 matrix, and for chroma... now it comes:

luma:
111
111
111

chroma:
xy11z
x11yz
xy11z

x, y and z get interpolated to respond to the "borders" given by luma.
You'd have a biased center, but it's somehow a center.

I don't know if this explains what I mean, but I hope the idea is visible: luma information should be different if chroma information is... at lest you won't "leak" wrong colors too much.

It's still far from perfect, but at least a try.

I hope this doesn't look as stupid as I see it now, it doesn't really fully explain what I try to say.

Best regards,
Koepi

Guest
19th August 2002, 01:34
@koepi

>Ok, I know you don't see me as knowledgeable in this place

Heavens, whatever gave you that idea? You must have misinterpreted something I said.

I don't understand your idea. Maybe you could make it clearer?

As I see it, any kind of interpolation is going to leak, and any kind of off center is going to make asymmetric output. Both of these look really awful after iterating many times.

The problem is only serious/observable after iterating, so it looks like my only solution is to just adopt a larger kernel to start with. This is for my new smoother. The downside is that I then have to muck around with boundary fill to find the pixels to blur. But it's probably better not to iterate anyway.

Koepi
19th August 2002, 01:57
Hum, knew it... it's really not easy to explain...

well, we _want_ to interpolate a 3x3 matrix. with luma, this can be done without big hassles.
In chroma, we have the problem that just 1 or 2 (depending on the yuv space) pixels are stored within such a matrix.

so if we have

luma:
111
111
111

and chroma:
1x1
xxx
1x1

or

1x1
1x1
1x1

(1 means, information stored, x means - thin air)

we should use something that "toggles" the center to be more "right centered" in the first step, and more "right centered" in the next.

So we have sometimes a little more weight on the color information from the left, and then again from the right.

so if we have to use something like a 5x3 matrix for chroma anyways, we should "move" the center around. This way, we would be closer to the original. It's like dithering, I'd say.

And about the luma respecting thing: if there is a huge jump in luma (or, if it's above <threshold>), it should mean that something different is starting there, so the interpolation has to be "cut off" at that place. SO if we have

(2 means "above threshold"

luma:

111
122
222

then the chroma should be calculated like this:

111yx
11xxx
xxxxx

(x now means: something deriving form the right, y means: possibly interpolated between the neighbour pixels - if too slow to use internally 4:4:4 yuv, or not noticable, just use 1 again)

I don't know if this is realistic.

I hope this is clarifying my idea - it's more or less that luma should make an "early stop" possible in calculating our convolution "chroma" matrix.

Best regards,
Koepi

Guest
19th August 2002, 04:50
Sorry, I still don't understand. Never mind; I'm a plodder when it comes to thinking.

For example, you start by saying "we _want_ to interpolate a 3x3 matrix". But that is not what I want to do, so right away I'm lost.

dividee
19th August 2002, 04:50
This chroma problem is what discouraged me of writing spatial filters in YUY2...

@Koepi: I must be dumb or something but I still don't grasp what you explained...

I have another idea:
Let's assume we would convert to YUV 4:4:4 before filtering. The chroma in YUY2 is supposed to be located on the left pixel of the pair. I can see two "easy" ways of doing that conversion.
a) duplicate chroma:
YUY2 : A B C
YUV 4:4:4 : A [A] B [B] C [C]

A,B,C represents chroma pixels; [] represents information that is not present in YUY2.
Applying a [1 1 1] horizontal matrix at position B would yield : (A+2B)/3; so it's equivalent to filtering in YUY2 (as vlad is doing now) with a matrix [1 2 0].
For the [1 2 1] matrix it gives (A+3B)/4 or a [1 3 0] matrix in YUY2.

b) interpolate chroma:
YUY2 : A B C
YUV 4:4:4 : A [(A+B)/2] B [(B+C)/2] C [(C+D)/2]

Same calculations as above:
[1 1 1] to pixel B gives (A+4B+C)/6 or [1 4 1]
[1 2 1] becomes [1 6 1]

I don't know if one method is better, but i like more method b). It still doesn't avoid some chroma bleeding, but reduce it by giving more weight to the center pixel (but it also reduce filter strength on chroma, of course).

I wonder how Sh0dan dealed with this in SmoothHiQ...

Guest
19th August 2002, 04:56
sh0dan did not have to iterate his kernel, I believe. No bleeding or asymmetry at all is acceptable if you want to iterate it a lot, because it magnifies the defects.

I've concluded the problem is insoluble and I can't do iteration. I am writing a configurable sized kernel instead. Even that is hard.

Guest
19th August 2002, 05:01
@dividee

Isn't it the conversion back to 4:2:2 that will cause the dilemma? In other words after converting back we will still have an asymmetric result with bleeding.

Marc FD
19th August 2002, 09:16
Hey, it exactly the problem i'm having with Blur/Soften MMX YUY2 optimisation.

My MMX version is very good (and damn fast, it's MMXed after all)
but when i come to massive iteration (x20/x40 !!) i get some artifacts in YUY2 because i used a bigger kernel in chroma :(
But because it's so fast in MMX, it's really dumb to be not able to use some iteration.

When i think of it, Sharpen(1,1) x 20 will give you _VERY_ ugly artifacts, so my little deviation in chroma is not very noticable...

I'll release a bin of Focus2 soon, and if you think it's good, i'll send my source to a avs coder with CVS acces.

vlad59
19th August 2002, 09:56
I'll have a second look to Tom's STMedianFilter to see how he handle this case.

I think that Convolution3D can keep it's actual way of averaging chroma.
But if I intend to make a multipass filter : I think I'll filter chroma only verticaly with a 2 pixel *3 pixel matrix (so 2 chroma value * 3). And I'll keep the same method for luma (3*3).
Optionaly I'll add a horizontal chroma averaging that will only be performed last to avoid leak.

Defiler
21st August 2002, 15:55
Vlad: If you want, I can host Convolution3D and the readme on some of my webspace. That would make it easier to link from the "Avisynth Q&A" thread.

vlad59
21st August 2002, 16:27
@Defiler

I agree, I'll be happy if you could host Convolution3d. As I already said I'm allergic to HTML stuff.

Thanks a lot.

Just PM me if you need something to do that.

Defiler
21st August 2002, 17:01
OK. It's up.
http://hellninjacommando.com/con3d/
Not a marvel of design, but simple and permanent.
Feel free to link to it in any imaginable way.

vlad59
21st August 2002, 19:45
@Defiler

Bravo (as we say in France)
I love the design (simple, easy to read, effective).

Just two little remarks :

- I'm not sure I'm talented ;) , If one day I'm able to optimize Convolution3D to gain 50% in speed, I'll accept this compliment ;) .
But I'll have to wait a long time for that moment :rolleyes: .

- I think it's important to credit bb who has the original idea. bb was the inventor and I only was the coder.

Thanks again Defiler, You've made a good work :D

Edit : I love your signature, I remember where Tom wrote that, in the Dvd2avi Sourceforge Project thread (a long one too).

Defiler
21st August 2002, 20:16
Thanks.
Do you have any contact info for bb? Should I just say something about "bb" having the original concept/design, or can I link to his homepage, etc?

vlad59
21st August 2002, 20:53
Nope no contact info for bb, just credit him for the concept and for the tests (look at the first page of this looooooong thread, I only arrived at the second or third page).

I'm sure if he want a special link, he'll ask it later ;) ;) .

Thanks

Ps : it's time to begin to think about the beta 3 (or maybe v1.0), let's code a little.

Bulletproof
22nd August 2002, 00:58
Could somebody port convolution3d or STMedian to Virtualdub with a preview button so that we could tweak easier?

bb
22nd August 2002, 06:59
@vlad59:
Thank you for the flowers. I would have tried to code it myself, if I only had the time... But unfortunately my time is very limited, therefore the project wouldn't ever have been realized. Thank you very much for picking up the idea; in my opinion the coding is at least as important as the concept.

Concerning the link to my homepage: I prefer to stay anonymous, and there is no homepage for my bb identity (yet). Do you think I should set up a page with a cute description of the 3D convolution (I mean with pictures, abstract algoritm explanation and such)?

If you want to give me some credits, just mention bb (the mod of doom9's DV forum).

If you want to contact me, you can simply send a PM. My e-mail address is bb_doom9<AT>gmx.de (replace the <AT> with an @ ;-)). For certain conversation I prefer using PGP.

bb

Marc FD
22nd August 2002, 10:23
Originally posted by Bulletproof
Could somebody port convolution3d or STMedian to Virtualdub with a preview button so that we could tweak easier?

??? do you realize the colorspace conversions problems ???
it seems to me that porting a avisynth filter to VirtualDub is really dumb.

a combinaison of a animate() and FreezeFrame() can help you to tweak settings, and is (in my point of view) far more powerfull than a dumb preview box... but of course it's a little harder to use the first time ;)

Koepi
22nd August 2002, 10:44
I just edit my avs script, hit ALT, hit "cursor down" twice, hit enter, use ALT+TAB (brings my vdub to front), hitting ALT again, 1x cursor down, 5x cursor up, enter - and then watch through the video via slider again... easiest way to tweak the settings, and you get used to it very fast, too ;)

Regards,
Koepi

bb
22nd August 2002, 11:07
Although this is getting off-topic now:
Don't you think AviSynth support in VirtualDub would be nice? Like an AviSynth menu where you can select filters, preview the filter chain, edit the AVS script, etc.

What do you think?

bb

Belgabor
22nd August 2002, 11:10
Even a 'reload' function would suffice, where you would end up on the same frame as before.

Belgabor

Marc FD
22nd August 2002, 11:25
a coder (like me or koepi) could create a little prog who reloads your avisynth script in VDub when you hit a key-combo.

i played with keyboard simulation to make my PSX Pad work on my computer and to play emulated SNES/NEOGEO games with some month ago.

some threading and simple API calls. i can try to use the concept to do a little notepad-virtualdub compatible reload function.

Belgabor
22nd August 2002, 13:33
Well, keypoint for my part is the "to the same frame" thing, as reloading is now simply a thing as going to the file menu and clicking on the first in the recent files section, but that reopens to the beginning so i have to remember with frame i was on and skip to it.

Cheers
Belgabor

Marc FD
22nd August 2002, 13:44
a solution : create a filter who saves the frame number in a file (ie frnum.log) , and a prog who reload VDub, then type CTRL+G and type the number of the last frame viewed. here you have a "reload at the same position" feature

Belgabor
22nd August 2002, 13:55
Well, thats imho not really less a hassle than the "read number, take notebook, write it down, reload, Ctrl+G #" approach I'm using atm ;)

Cheers
Belgabor

Didée
22nd August 2002, 15:10
Continuing with offfffffffffffffff topic ...

Some of the more capable text editors, like e.g. TextPad, allow some neat makros. So I got used to edit my script, press one button, and - POOF - Vdub gets started with the edited script. Still got to do the ALT+G grip, but half of the hassle is avoided.

Okay, editors like TextPad or UltraEdit arn´t really free, but ... YES MOM I´M COMING!

:D

stax76
24th August 2002, 00:09
in DVX just write #JumpTo: to your script and hit VirtualDub button

vlad59
25th August 2002, 13:54
Hi all,

Here is a new version of convolution3D (beta 3), if it's bug free (I hope so), it will be last beta. The only remaining thing to add will be some buffering to gain a little speed (maybe).

So I made a big update of the .txt file so don't forget to read it(please excuse me for my crappy english). I add suggested settings for different sources.

There is also a new parameter called Temporal influence (it was hardcoded to 3 in beta 2),it will allow you to tweak speed vs compressibility.
From the tests I've made 3 (or even 2.5) seemed to be a good value for compressibility :
Without any filters -> 33.9%
-1 (only spacial filtering) -> 45.5%
2 -> 50.6%
2.5 -> 51.0%
3 -> 51.2%
4 -> 51.3%

The zip will be available at http://hellninjacommando.com/con3d/ as soon as Defiler have time to update it.

The zip is also attached to this thread.

EDIT : corrected some typos.

iago
25th August 2002, 14:04
@vlad59

I'm so happy to hear that. I'm looking forward to testing this new version. I hope it is uploaded soon :).

Thanks,
iago

Marc FD
25th August 2002, 14:05
great work :)

it's funny, i'm going to do 3D too. but not in a filter...In a game :D

primitive
25th August 2002, 14:18
vlad, your filter is amazing for animation.

An interesting side-effect I've seen is that it seems to reduce ghosting from bad analog captures by getting rid of the combing artifacts on the ghosts and also by blurring the edges of the ghosts, making them less noticable. They also resolve the tiny combed mouth flaps that decomb always seems to miss quite nicely.

My source was the Miyuki-chan in Wonderland DVD by ADV,region 1, the first 6 chapters (the Wonderland portion).

I'd like to run something by youall to see if it's workable. Since the ghosts seem to persist for only one frame, maybe two, and since they're only noticable after a scene change or after there's been a large amount of motion between frames, would it be possible to change the matricies con3d uses on the fly?

1. run a scene change routine set to very high sensitivity. We're not looking for actual scene changes, just frames with quite a bit of motion that would cause ghosting.

2. if the scene change algorithm returns true, edit the matricies. We want to zero out the matrix for the last frame (we don't want any of the pixels from the last frame to reinforce the ghost), and we want to heavily emphasize the next frame (to hopefully blend the ghost pixels with pixels which are clean or which are less ghosty).

3. After that frame, change the matricies back to what they were.

If I understand what the filter does correctly, this will cause the frames which are being corrected for ghosts to be more noisy than most. However, if this can get rid of the ghosting too, it might be a favorable exchange.

Thoughts?

-p

Guest
25th August 2002, 14:32
@primitive

Decomb does not "always miss mouth flaps" when used correctly. If you care to post a sample, I will be happy to prove that.

primitive
25th August 2002, 14:50
Originally posted by neuron2
@primitive

Decomb does not "always miss mouth flaps" when used correctly. If you care to post a sample, I will be happy to prove that.

Not to look down on your excellent tool, which I have happily used since its release.

I'm not talking about all mouth flaps, I'm talking about the tiniest of flaps that have one combed line, perhaps two, across the whole thing when they're missed. Every other region any larger than this is taken care of nicely.

-p

Guest
25th August 2002, 15:17
@primitive

Then why did you say this: "decomb always seems to miss"? It simply isn't true. Post your clip and let me see if you're using the tool correctly. If you make a broad, unjustified, general slam against a tool, expect to be called on it.

Finally, if you're going to apply a filter such as 3DConvolution on your clip, then you might as well set full=true to Telecide().

vlad59
25th August 2002, 15:22
@Marc FD
That's funny, I just crashed my car in CMR II so I lost the rally -> that's why I checked the forum.
Yes, 3D games are sometimes better than 3D convolution.... ;) ;)

@iago
I'm waiting for your tests, thanks in advance.

@primitive

I live in France and sometimes when I read all telecide problems, I thank God to only have PAL DVDs ...

Your idea seems feasible.

If you read my last convolution3d.txt, I have a new parameter called Temporal influence wich I use to do only spacial filtering if temporal information is not usefull.

Let's try to understand better :

1-Scene change
Should I do a scene change detector between current and next frame only ??

2-It's easy to avoid using previous frame values and to double (or more) the importance of next frame. But don't forget how the tresholds work : if was explained before in this thread. if the next frame is too different from the current frame it'll be replaced by the computed value (I know, I'm unable to explain correctly ;) ,but if you look at one of my previous sample,you'll understand).

Hope this helps

dividee
25th August 2002, 16:40
just spotted a bug:

you can't assume pitch will be the same for the three frames you read.
For instance, the following script makes convolution3d crash:
a=BlankClip(width=640,height=480,length=10,pixel_type="YUY2")
b=BlankClip(width=800,height=600,length=10,pixel_type="YUY2")

a+b.crop(0,0,640,480)

Convolution3d (0, 8, 8, 8, 8, 3, 0)
That's because two clips of different pitch are spliced together. If you insert a filter that works in-place between the splice and convolution3d, it will still crash convolution3d. If you insert a filter that outputs to a new buffer, it won't crash, unless the filter is allocating framebuffers with varying pitches (don't know why a filter would do that, but it is legal).

Ranma-kun
25th August 2002, 16:51
Originally posted by neuron2
Finally, if you're going to apply a filter such as 3DConvolution on your clip, then you might as well set full=true to Telecide(). [/B]

I'm going to use convolution3D for some tests, so I set full=true but Telecide doesn't support full argument... I'm not sure, but did you mean threshold=0?

Thx for your wonderful filter, and excuse my poor english.

iago
25th August 2002, 16:52
@vlad59

First of all, I would like to thank you for the credits. It's really kind of you... :)

Originally posted by vlad59
@iago
I'm waiting for your tests, thanks in advance.
@vlad59 and everybody,

Now I'm about to start a new test encode with convolution3d latest version, this time with a more reasonable/compressible movie, Fight Club / 2hr-19min / 640*272, aiming for 1CD to better see the results. (The previous one, The Blues Brothers (1980), aiming for 1CD was an extreme case imho.)

At the moment I'm trying to decide on the XviD encoding and avisynth parameters, which could have an influence on the quality of the final encode, and I would like to take some comments and ideas before starting the long test ;).

There seems two possible ways of encoding to me:
(Koepi's 18082002-1 build / two pass)

1.) (Using MPEG quantizers and no lumi in both passes together with) sharp bicubic resizing (in order to bring all possible noise to foreground) and then apply convolution3d(0,8,8,8,8,3,0).

LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\convolution3d.dll")
mpeg2source("C:\FIGHT\FIGHT.d2v")
crop(4,60,716,354)
BicubicResize(640,272,0,0.75)
convolution3d(0,8,8,8,8,3,0)
Trim(0,196015)+Trim(196016,0).TemporalSmoother(10)

2.) Applying convolution3d(0,8,8,8,8,3,0) to the source after cropping, and then use simple or neutral bicubic resizing (together with respectively H.263/MPEG and lumi masking in both passes).

LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\convolution3d.dll")
mpeg2source("C:\FIGHT\FIGHT.d2v")
crop(4,60,716,354)
convolution3d(0,8,8,8,8,3,0)
BicubicResize(640,272,0,0.5)
Trim(0,196015)+Trim(196016,0).TemporalSmoother(10)

Any comments would be appreciated (though some parts are purely XviD related, but essential to decide on the filter-applying method).

Best regards to all,
iago

Guest
25th August 2002, 17:22
@Ranma-kun

Yes, thanks for the correction.

But it was more a sarcastic remark than a real suggestion. :) My point was that if you are going to apply a filter such as 3DConvolution, you're going to change the good progressive frames. So why not just set threshold=0 to deinterlace every resulting frame? The point of having an interlaced frame threshold is to not touch good progressive frames.

vlad59
25th August 2002, 18:13
@Dividee

As usual, you're right ;) , thanks for the report.
So there will a beta 4 :D .

@iago

I'm sorry, once again I've only made test with anime, I'm ripping a chapter of Excalibur (only a little noisy, good mastered) and I'll make a few tests.

I'll check the effect of "temporal influence" and try to higher a little the spacial chroma treshold.

I let you know.

iago
25th August 2002, 18:34
@vlad59 (and everybody),

OK, just forget about the above post; it was just a moment of hesitation or loud thinking :) and both ways can be tried of course.

For the time being, I'm going with the script below, applying convolution3d after resizing (sharp bicubic and MPEG quantizers with no lumi in both passes, since the movie is dark and well compressible and as far as I remember from my previous encodes the second pass quantization will be mostly MPEG after all):

---------------------------------------------------
LoadPlugin("C:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\convolution3d.dll")
mpeg2source("C:\FIGHT\FIGHT.d2v")
crop(4,60,716,354)
BicubicResize(640,272,0,0.75)
convolution3d(0,8,8,8,8,3,0)
Trim(0,196015)+Trim(196016,0).TemporalSmoother(10)
---------------------------------------------------

SmartRipper 2.40
DVD2AVI 1.76 (FORCED FILM 29.97->23.976)
avisynth 2.05
VirtualDub 1.4.10

Movie: Fight Club NTSC 1
2hr-19min
640*272/sharp bicubic
[aimed video size: 644000kb (629mb)]

Koepi's 18082002-1 build
First Pass:
6.UltraHigh
MPEG
no lumi

I'll report back the results when finished.

(PS: Koepi, where are you? ;) The above monologue on the filter applying method in relation to XviD is still open to discussion :).)

best wishes,
iago

primitive
25th August 2002, 19:47
Originally posted by neuron2
@primitive

Then why did you say this: "decomb always seems to miss"? It simply isn't true. Post your clip and let me see if you're using the tool correctly. If you make a broad, unjustified, general slam against a tool, expect to be called on it.

Finally, if you're going to apply a filter such as 3DConvolution on your clip, then you might as well set full=true to Telecide().

*offtopic*

Ack, I seem to have hit a nerve. I promise I wasn't aiming for one. Decomb is certainly the best tool of its kind for performing IVTC. In my experience Decomb has always missed tiny combed areas, but I fully acknowledge that this could be due to my inexperience with using Decomb rather than a fault in Decomb itself.

Using decomb 3.9 beta 2 (I think), as well as the next-to-latest version of con3d.

My script, minus gknot garbage:

LoadPlugin("d:\PROGRA~1\GORDIA~1\mpeg2dec.dll")
LoadPlugin("d:\PROGRA~1\GORDIA~1\decomb.dll")
LoadPlugin("d:\PROGRA~1\GORDIA~1\Convolution3D.dll")
LoadPlugin("C:\WINNT\System32\vobsub.dll")
LoadPlugin("d:\PROGRA~1\GORDIA~1\SimpleResize.dll")

mpeg2source("D:\_dvdwf\miyuki-chan in wonderland.d2v")

Telecide(guide=1,gthresh=25,chroma=true,threshold=10)
Decimate(mode=2,cycle=5)

crop(16,0,688,478)

SimpleResize(544,416)

convolution3d(0,10,22,8,8,0)

VobSub("D:\_dvdwf\vts_02_0")

The following links point to video files demonstrating the problem. All these were prepared by opening the video sequence in question into vdub, saving the relavant sequences as .bmp files, and reencoding them in high-bitrate xvid, single-pass. Since they're so short (each less than a second), it'd be best to open them in vdub and step between frames.

Frames in question in encoded clip: 1, 9, 15.

Encoded clip: http://people.vanderbilt.edu/~b.nuttall/encoded.avi
Source clip: http://people.vanderbilt.edu/~b.nuttall/source.avi

Now that I look at my script, I realize I put "threshold" when I probably meant "dthreshold", but I'll leave it to you to determine if that really made a difference. BTW, the documentation I got with Decomb 3.9 didn't have an entry for full=true in association with Telecide().

-p

primitive
25th August 2002, 20:04
@vlad

While I'm sitting at my comp, I'll show you what I mean.

http://people.vanderbilt.edu/~b.nuttall/ghosts.avi

This is straight from the vob source, reencoded to high-bitrate xvid. Frame 4 is combed, but frame 5 is interesting. Switch back and forth between frame 5 and frame 6 to see what I mean.

What you're looking for:
- very slight combing artifacts in frame 5. Look in Miyuki's hair, you can still see the combed lines from the last frame.
- a faint outline of Miyuki's skirt from frame 3 superimposed on Miyuki's skirt in frame 5. Look on pleats 3, 4, and 5 from the left, mostly on pleat 4.

Also notice that Miyuki's color is darker in frame 5 than it is in frame 6, and notice that the part of Miyuki's left elbow that covers the door's face isn't subject to this darkening. This darkening is coming from the blue-black background from frame 3.

The whole idea is that with nasty material like this, you want frame 6's pixels more than frame 5's. This effect is less noticable when there's less motion, so that's why I suggested using a scene detection algorithm to tell you when the matricies need to change.

It's just an idea, I don't know how this kind of filtering would work in practice.

-p

Defiler
25th August 2002, 21:11
Maybe you should wrap the smoothing filters between a pair of reverse() statements? That would probably yield its own set of problems, though.

@Primitive:
What about this?

LoadPlugin("C:\Bin\Avisynth\CopySame.dll")
LoadPlugin("C:\Bin\Avisynth\cnr2.dll")
LoadPlugin("C:\Bin\Avisynth\Convolution3d.dll")
AVISource("D:\Temp\ghosts.avi")
cnr2()
Convolution3d (0, 10, 22, 8, 8, 0)
CopySame(mode=2,llt=32,lct=128,slt=32,mfs=3,lxs=100,lys=100)

Yielding this:
http://hellninjacommando.com/misc/avisynth/ghosts-cs.avi

primitive
25th August 2002, 21:30
Originally posted by Defiler
Maybe you should wrap the smoothing filters between a pair of reverse() statements? That would probably yield its own set of problems, though.

@Primitive:
What about this?

LoadPlugin("C:\Bin\Avisynth\CopySame.dll")
LoadPlugin("C:\Bin\Avisynth\cnr2.dll")
LoadPlugin("C:\Bin\Avisynth\Convolution3d.dll")
AVISource("D:\Temp\ghosts.avi")
cnr2()
Convolution3d (0, 10, 22, 8, 8, 0)
CopySame(mode=2,llt=32,lct=128,slt=32,mfs=3,lxs=100,lys=100)

Yielding this:
http://hellninjacommando.com/misc/avisynth/ghosts-cs.avi

Forgive me for my lack of knowledge, but is this a general solution to this problem, or does it address just this special case? To be clear, could I use a variation of the above script successfully on the entire movie, or is it "optimized" for the clip in question?

-p

Defiler
25th August 2002, 21:47
Should be a general solution. Take note that those CopySame settings are much more aggressive than the defaults. You may have to reduce some of the values if you run into trouble in other scenes.
"mfs=" (The maximum number of consecutive frames allowed to be "same") is a good value to tune. Higher is more aggressive.
Also, those settings are applicable to CopySame 1.2.. If you use 1.1b, the equivalent of "mode=2" is "mode=1" with "reverse()" before and after the CopySame statement.

Koepi
25th August 2002, 23:08
Hi again,

oopsi, I owe an answer! :)

Ok, tested Convolution3D again on The Matrix (640x272), lumi masking, mpeg/modulated quant...

Convolution3d (0, 8, 22, 8, 12, 0)

A little more aggressive settings now...

The resulting movie is a little too smooth in some places for my taste. So it's _very_ good for TV content, but for DVD ripping you have to use either very light settings or -i think that's best - no filters ;)

Best regards,
Koepi

primitive
26th August 2002, 00:05
Update.

Some of my problems were due to me doing the totally wrong thing as far as deinterlacing was concerned. I was trying to perform IVTC on a clip that wasn't progressive.

The rest of my problems were due to the video stream being particularlly diobolical. I spoke with Defiler and his best solution was to step up the framerate and use SeparateFields(). I chose to go with FieldDeinterlace() instead.

(Another one of my problems was that I didn't realize that blended fields on ths clip were the best I could get :( )

At this point, I don't know if having a modified con3d to reduce the blending deinterlacing solutions will yield on difficult clips would be the solution we would like, but I might as well throw it out there, it might be fun to play with.

-p

iago
26th August 2002, 01:00
Hi again vlad59 and everybody,

Well, the first pass returned a 1stpass/2ndpass ratio of 1170/629: 1.86 with the previously mentioned settings [aiming for 644000kb (~629mb)].

Second pass started with:
6.UltraHigh
MPEG
no lumi
Min-Max I-frame quant: 2-6
Min-Max P-frame quant: 2-16
all the rest: default (using default AltCC)

I'll post the second pass results when finished, with some screenshots attached (maybe together with the screenshots of a former, unfiltered encode of the same movie for comparison).

best wishes,
iago

Guest
26th August 2002, 04:43
@primitive

Sorry, but I can't read Xvid. The last time I tried to use it, it crashed my system. Besides, I need clean source, not highly compressed source. Try HUFYUV.

primitive
26th August 2002, 05:45
Originally posted by neuron2
@primitive

Sorry, but I can't read Xvid. The last time I tried to use it, it crashed my system. Besides, I need clean source, not highly compressed source. Try HUFYUV.

Eww, it sucks that you can't read xvid. Not that it's a problem anymore, I was having trouble because I was stupid, not because of your filter.

-p

(perhaps tomorrow I'll post the losless copy; defiler did say that the interlacing scheme was particularlly diobolical. It might be of personal interest to you.)

Bulletproof
26th August 2002, 06:25
I've been getting some strange artifacts when using Decomb in conjunction with Convultion3D. The settings I've been using have been very weak with Convultion3D, I'm using the default parameters with Decomb. I disabled blending with Decomb so that it just resizes a field, as you know this causes a bit of jaggyness to the frame. But when I have Convultion3D on it seems to smear the jagged lines in a weird way, and keep in mind I had Convultion3D to a relatively low setting (mostly 7's). And also, I was finding that some static objects were jittering with convultion3D on, the Jitter is not caused by Decomb since Decomb is not alternating the fields (The best way to describe the effect is Alternating fields). So I see jittering lines on some things.

vlad59
26th August 2002, 07:31
@bulletproof

Can you post your script ?
I assume you use Convolution3D after the decomb stuff ....

@iago and Koepi
Yep, convolution3d (even with 8,8,8,8 tresholds) is maybe too strong for normal movies :
On a sample of Excalibur :
Not filtering : 30% (compressibility)
Convolution3D (0, 8, 8, 8, 8, 3, 0) : 50%

The result is not bad but you can see some blurring in the background in the trees and in the armour.
They are hard to see at 1x but at 2x they are viewable.

I'll make a second pass aiming for 1CD to make sure

iago
26th August 2002, 10:16
@vlad59 and everybody,

The test results and encoding process are discussed in full detail in thread: http://forum.doom9.org/showthread.php?s=&threadid=32243

@vlad59

@iago and Koepi
Yep, convolution3d (even with 8,8,8,8 tresholds) is maybe too strong for normal movies :
On a sample of Excalibur :
Not filtering : 30% (compressibility)
Convolution3D (0, 8, 8, 8, 8, 3, 0) : 50% It seems that these values greatly depend on the quantization choice and resizing method too, as observed in the above mentioned test, and may change from movie to movie.

best regards,
iago

Bulletproof
26th August 2002, 18:07
Yes, I used convolution3D after decomb, here is the script:

LoadPlugin("D:\AVISynth\MPEG2DEC.dll")
LoadPlugin("D:\AVISynth\decomb.dll")
LoadPlugin("D:\AVISynth\convolution3d.dll")
mpeg2source("D:\TEMP\clip.d2v")
Telecide(chroma=true,blend=false)
Decimate(mode=2,cycle=5)
Convolution3d(1, 7, 7, 7, 7, 3, 0)

The target material was animation.

I will try to get some screenshots later on today.

vlad59
30th August 2002, 07:52
Sorry to answer maybe too late.

Have you tried to lower
the Temporal Influence :
Convolution3d(1, 7, 7, 7, 7, 2, 0)
or the temporal tresholds :
Convolution3d(1, 7, 7, 4, 4, 3, 0)

I'm not sure of the results but it may help

bb
7th September 2002, 12:46
I like to extend long threads even more, so here we go:

There are always people on the forums asking what's special about Convolution3D, and I'll try to give a simple answer, based on my initial idea.

Neighbour pixels are correlated in films, the closer they are, the higher is the correlation; this applies to neighbours in the same frame and to neighbours in consecutive frames. Averaging neighbour pixels reduces noise.

Spatial filters look at a single frame only. A pixel has eight direct neighbours, so you can average nine pixels for the filtered frame. You can increase the pixel radius to get more pixels to average, but the you will average pixels that don't correlate much...

Temporal filters look at consecutive frames, a single pixel from each frame and the pixels before and behind. If you average the highly correlated direct neighbour pixels only, then there are three pixels to average only. Like with spatial filters you can increase the number of frames to get more pixels to average. But then you'll get ghosting effects - the pixels don't correlate any longer...

Convolution3D looks at direct neighbours only - the pixel radius is only one, but because you are averaging through "time and space", you get 27 (=3x3x3) highly correlated pixels. A (weighted) average of all these pixels is capable of getting rid of almost all the noise. That's the basic idea. And it works, as you can see.

bb

Wilbert
9th September 2002, 09:30
For those who are interested I did a second test round:
I also tested STMedianFilter and found something unexpected:
As you can see by looking at the pictures in the url at the end of the page, the ones done with STMedianFilter are brighter and contain a purple hue (or however you call that). Here are the scripts including the encoding times. The clip could be properly deinterlaced with VD_DeinterlacePALMovie and consists of 1000 frames.

# STMedianFilter v0.0.3.0: (purple hue all over the clip)
Import("C:\install\avisynth\vdub_filters_test3.avs")
AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
STMedianFilter(10, 50, 8, 10, 10, 50)
Levels(3, 1.03, 255, 8, 240)
# time: 2:40

# MAM1 vb2, SmoothHiQ v1.0: (needs a little bit more smoothing although less than Convolution3d, see all pictures 300%)
Import("C:\install\avisynth\vdub_filters_test3.avs")
LoadPlugin("C:\Program Files\AviSynth\Plugins\SmoothHiQ.dll")
LoadPlugin("C:\Program Files\AviSynth\Plugins\MAM.dll")
AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
s=SmoothHiQ(3, 25, 35, 200, 5)
t=TemporalSoften(1, 4, 8)
MAM(t, s, 2, 4, 8)
Levels(3, 1.03, 255, 8, 240)
# time: 6:12

# MAM2 vb2, SmoothHiQ v1.0: (smoothed too much, see hair third picture 200%)
Import("C:\install\avisynth\vdub_filters_test3.avs")
AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
s=SmoothHiQ(7, 25, 40, 250, 10)
t=TemporalSoften(1, 4, 8)
MAM(t, s, 2, 4, 8)
Levels(3, 1.03, 255, 8, 240)
# time: 10:00

# 2DCleaner: (too smooth and too noisy, see skin/eyes first picture 100%)
AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true)
VD_2DCleaner(200,1).ConvertbackToYUY2
Levels(3, 1.03, 255, 8, 240)
# time: 4:10

# Convolution3d vb3: (needs more smoothing, see all pictures 300%)
Import("C:\install\avisynth\vdub_filters_test3.avs")
LoadPlugin("C:\Program Files\AviSynth\Plugins\convolution3d.dll")
AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
Convolution3d(0, 8, 16, 8, 8, 3, 0)
Levels(3, 1.03, 255, 8, 240)
# time: 3:15

# Layer (with 2 broadcastings): (needs a little bit more smoothing although less than Convolution3d, see all pictures 300%)
Import("C:\install\avisynth\vdub_filters_test3.avs")
clip1=AviSource("F:\Test2\atomic_kitten-the_tide_is_high.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
clip2=AviSource("F:\Test2\atomic_kitten-the_tide_is_high2.avi").ConvertToRGB32.VD_DeinterlacePALMovie(true).ConvertbackToYUY2
Layer(clip1, clip2, "fast")
Levels(3, 1.03, 255, 8, 240)
# time: 3:49

# general remarks:
# - in this case proper deinterlacing was possible (in many case with clips from tmf)
# - 2DCleaner worst (too noisy and too smooth)
# - STMedianFilter needs improvement
# - I didn't stretch them to the correct size: 768x576.
#
# other remarks:
# - finetuning parameters is important, especially when you want to compare filters
# - convolution3d/layer with little bit more smoothing is faster (and gives similar quality) as MAM (with SmoothHiQ(5,25,35,5))


The zip-file containing the pictures and the script can be found
here (http://www.geocities.com/wilbertdijkhof/atomic_kitten-the_tide_is_high.zip).

ronnylov
9th September 2002, 15:03
Wilbert, your link to the zip file is broken.

Wilbert
9th September 2002, 15:07
"Right click" and "Save link as" should work ... Otherwise copy this url www.geocities.com/ararodrigu/atomic_kitten-the_tide_is_high.zip (with the full name: atomic_kitten-the_tide_is_high.zip) to your explorer.

Defiler
9th September 2002, 15:21
Originally posted by ronnylov
Wilbert, your link to the zip file is broken. Worked for me. Interesting content, as well.

ronnylov
9th September 2002, 15:51
Yes, right click and save as worked.
Thanks!

vlad59
10th September 2002, 08:08
Yes interesting test, thanks Wilbert.

The main problem in using noise reducer is you will never know for sure wich parameters you should use.
It's hard to say how much noisy is your source.
So the only to find good parameters is to test and retest parameters until you find something YOU like (again it's a matter of taste : I prefer smoother movie, my wife prefer sharper movie)

I was thinking of making a noise analyzer : the user select a long scene with very low motion (or no motion at all) of a source and inside this scene he choose a rectangle to analyze (again with no motion at all) and then we are able to provide some statitics :
for each values (luma or chroma) : mean/min value/max values/max variation/max variation div luma/.....

With this I consider that noise is the same throught all the movie (wich is not true) but it should be good enought (only a test could proove it).

I hope I will have time to build that

WarpEnterprises
10th September 2002, 09:01
I fear measuring noise won't be that easy, as it may depend on the video content as well (e.g. the brightness).
But indeed some kind of "noise analyser" should be helpful (similar thoughts and needs had vidiot in http://forum.doom9.org/showthread.php?s=&threadid=33259 !)

vlad59
21st September 2002, 14:06
Wahoo this thread was already at page 4.

Just a little post to say that beta4 of Convolution3d is available here (http://forum.doom9.org/showthread.php?s=&postid=183735#post183735)

High Speed Dubb
22nd September 2002, 07:09
Originally posted by vlad59
I was thinking of making a noise analyzer : the user select a long scene with very low motion (or no motion at all) of a source and inside this scene he choose a rectangle to analyze (again with no motion at all) and then we are able to provide some statitics :
for each values (luma or chroma) : mean/min value/max values/max variation/max variation div luma/.....

With this I consider that noise is the same throught all the movie (wich is not true) but it should be good enought (only a test could proove it).That should be very effective &mdash; It&rsquo;s generally reasonable to expect the same amount of noise throughout a source. The only big exceptions come when different parts of the source were produced or processed differently. (That happens a lot with news shows and ads.)

Potentially a 3:2 pulldown algorithm could generate the noise information automatically, using the repeated fields.

It&rsquo;s even possible to get this information from mixed moving/non-moving fields, but that&rsquo;s very tricky. If you&rsquo;re feeling very brave, take a look at my (reasonably successful) attempt at this at:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/deinterlace/DScaler/Plugins/FLT_AdaptiveNoise/

The important code is all in C. FLT_AdaptiveNoise.asm collects a histogram of the (oddly processed) differences between pixels in the current and previous frame. Then the AnalyzeHistogram() routine in FLT_AdaptiveNoise.asm finds the low peak in the difference histogram. The low peak usually corresponds to the part of the picture in which there is no motion. But it doesn&rsquo;t always, so a measure of the reliability of the peak as a measure of noise is also determined. Based on its reliablility, the new estimate of the noise amount is combined with the old estimate to figure out the current amount of noise.

jarthel
22nd September 2002, 07:18
Originally posted by vlad59
Wahoo this thread was already at page 4.

Just a little post to say that beta4 of Convolution3d is available here (http://forum.doom9.org/showthread.php?s=&postid=183735#post183735)

Is there mmx, 3dnow or sse optimizations with the latest beta? Thanks

Jayel

vlad59
22nd September 2002, 09:24
@High Speed Dubb
My first test show it could be effective but you have to find a long still scene to provide useful stats. 2 or 3 seconds are a minimum.

I only made tests on a PAL non interlaced source.

I'll have a look to your code and especially to the statistics you provide.

Thanks for the link.

@Jarthel

Convolution3d is mainly MMXed. I use iSSE instructions mainly for prefetching and to calculate a SAD (Summation of Absolute Difference) quickly.

I don't use any 3dnow instruction because I don't need any. At first I wanted to make a MMX version and an MMX/iSSE version but now I think I'll be too lazy to split Convolution3D.

Last night I have optimized the last part of Convolution3D that was not ASM and I only gain 2% in speed so I think it will be hard to optimize better without a complete rewrite.

High Speed Dubb
23rd September 2002, 03:47
I should point out a couple hidden gotchas in estimating noise.

- It&rsquo;s important to exclude pixels with a value near 0, because these pixels have a different noise distribution.

- With a composite (PAL or NTSC) source, color crosstalk will mess up a straightforward difference measure, since crosstalk will be misinterpreted as noise. That&rsquo;s a problem because the amount of crosstalk varies depending on the image, which means the noise measure will vary somewhat. I handled this by just looking at the noise in the quietest parts of the picture. Another possibility would be an explicit comb filter of some sort.

metallikop
7th October 2002, 23:25
As you can see by looking at the pictures in the url at the end of the page, the ones done with STMedianFilter are brighter and contain a purple hue (or however you call that). Here are the scripts including the encoding times.

I thought this thread could use a revival. I recently tested Tr's STM filter and came up with the same purple hue problem as Wilbert. Have you had a chance to take a look at this tom?

trbarry
8th October 2002, 17:08
metallikop -

I wrote STMedianFilter just as a lark one day, in response to this thread. It doesn't really seem anybody besides me is using it, at least compared to Vlad's nifty convolution 3D. So I'm actually thinking about withdrawing it and dropping support, in favor of just using Vlad's filter. I'm not sure yet either way but I haven't worked on it recently.

- Tom

ronnylov
8th October 2002, 17:19
I have used the STMedianFilter and I liked it! I used it when denoising a VHS capture. I also noticed a slight purple touch of the final movie but I thought it was there on the original.

metallikop
8th October 2002, 17:22
Tom-

I guess that means two of us are using the filter. ;) It's too bad to hear you're dropping support for it.

I favor STM because of the huge speed boost over c3d. I've done a lot of comparisons between Vlads filter and yours, in some cases I prefer STM, and like I said earlier, the speed does help a great deal.

Do a fellow detroiter a favor and keep up production on it. ;)

Regards,
-kop

Metalazzo
8th October 2002, 18:42
I also use it ^^
it works great :D
and since i use tweak() in my avs script i have not a pb of hue or sat or anything else
conv3d is sometimes hard to find some good values for anime and STMedianFilter(8,15,5,7,8,15) works fine with the gundam dvd i use
a big thx Tom ;)
conv3d and STM are the main reducing noise filters i use now :)

vlad59
8th October 2002, 20:12
As always Tom's code is perfectly commented. So even if he has not any time to check it out (I respect his decision), another coder can try to fix it. The code is full ASM but not too long ;).

I'm also using StMedianFilter because of its wonderful result in fade in or fade out scene. I often use C3d on other scene because StMedianFilter doesn't soften enought but thanks to Trim I can have exactly the quality I want on each part of the movie (including fade in/out).

I personnaly never noticed the purple hue ! My eyes are not good enought :sly:

Just my 2 (euro) cents.

trbarry
9th October 2002, 05:52
Thanks guys for the kind comments. I just didn't want to be the author of a filter where everybody said "Well, it doesn't do much, but it's fast". ;)

To be honest, I usually don't do that much filtering since I mostly am doing HDTV clips and rarely process noisy analog captures. But it just happend that this thread appeared at a time when I needed to cap a Tai Chi instructional video tape and everybody was tossing out all the good ideas, so I wrote the darn thing on impulse just to handle that one capture.

But if folks are actually getting some use out of it then I won't drop it. It's not that big or that much code anyway, mostly just some pieces parts pilfered from TomsMoComp. I have never noticed the purple, but I'll go look for it.

Incidentally, the default parms I first recommended were too strong for most use. What I mostly use it for now is a little deringing and removing mosquito noise from mostly clean clips, using fairly small values like:

STMedianFilter(8,10,4,7,8,10) or so.

This way it doesn't soften noticeably but will pick up many of the stray dots. Use something else for heavy filtering.

And I still say Convolution3D is both much more powerful and general.

- Tom

Jeff D
15th March 2003, 10:11
What would be the best settings for removing "dust and dirt" black spots?

I've tried convolution3d with most of the presets, but each time the black spot is still there. (I'd post a image, but upload has diappeared..)

the dirt is a black spot on a single frame, so the pre and next frames are key and maybe the current frame's matrix weighting should be lowered, but I haven't been able to get anyting to work. Without seriously bluring the rest of the image.

I like the results of the movieLQ settings, the results look like they should compress way better than without the cleanup.

trbarry
15th March 2003, 14:37
"What would be the best settings for removing "dust and dirt" black spots?"

Jeff -

Your best bet might be temporal filtering though it may create some ghosting. Note the STMedianFilter parms have changed a bit, at least for Avisynth 2.5 but you might try something stronger than above, like:

STMedianFilter(15,50,25,25)

and then crank the last 2 parms back down a bit if there is too much smearing.

Be aware the temporal filtering relies on the spots being on only a single frame and won't help otherwise.

- Tom

bb
22nd April 2003, 17:15
I must admit that I feel somehow stupid, but...

Is there a way to make Convolution3D deal with YUV2 input using AviSynth 2.51?

I guess the AviSynth 2.0x version should be ok, except that it lacks the "AvisynthPluginInit2" call. So AviSynth 2.5x rejects the filter. And Convolution3dYV12 for AviSynth 2.5x lacks YUV2 support.

By the way: does anybody continue development of the filter since Vlad59 said he won't have the time any more?


bb

Defiler
22nd April 2003, 17:27
You just need to convert between colorspaces. The 2.5x plugin assumes YV12 input.

WarpEnterprises
22nd April 2003, 22:13
here you go:
C3d compiled for 2.5.

(attachement)

bb
3rd May 2003, 17:57
@WarpEnterprises:
I know I'm late - but thank you! This version is great if you just need to clean up a YUV2 capture without much further processing, and then hand it over to CCE to encode (something I've done quite often lately since I have a DVD burner).

Edit: Why not add it to your AviSynth Filter Collection?

bb

WarpEnterprises
4th May 2003, 20:46
Done.
Btw why is the attachement gone?

bb
5th May 2003, 17:07
There was a database error. Has been fixed in the meantime, but some attachments are gone.

bb

WarpEnterprises
5th May 2003, 23:15
now I have another reason for setting up my collection :)

troy
20th June 2003, 03:43
There seems to be some issues with what is the best way to use convolution3d with interlaced sources. I know that a lot of people must be doing vcr to mpeg transfers since this is a good filter for this. So then a lot of people must be using this filter on interlaces sources. My question is about how best to use this filter on interlaced AVI DV BFF sourses.
Is it best to use this script.

LoadPlugin("d:\Convolution3D.dll")
AviSource("c:\test.avi")
SeparateFields()
convertToYUY2()
Convolution3D(preset="movieHQ")
Weave()
DoubleWeave().SelectOdd()
resampleaudio(44100) #only necessary for certain versions of CCE

or should I use this script

LoadPlugin("d:\c3d\Convolution3D.dll")
avisource("D:\test.avi")
fps50=SeparateFields()
even=selectEven(fps50).Convolution3D(preset="movieHQ")
odd=selectOdd(fps50).Convolution3D(preset="movieHQ")
interleave(even,odd).weave() #possibly swap Even and Odd
resampleaudio(44100) #only necessary for certain versions of CCE