Log in

View Full Version : Smart Smoother IQ port to Avisynth?


soulfx
2nd July 2002, 08:35
This filter is awesome when it comes to getting rid of those rainbow artifacts. It's just not up to par when it comes to speed. Anyone know of any effort or want to make an effort to get this filter ported over to Avisynth?

Tim has got the source code up on his website, but I'm not much of a coder. http://www.fiction.org/www/smoothiq/

In it's current form it has to
RGB -> YIQ
Smooth Q - plane
Smooth I - plane
YIQ -> RGB

Wouldn't there be a way to get rid of the RGB conversion it has to do and just let it operate in the YUY colorspace? From what I can see I don't think the code is MMX or SSE optimized. If the smoothing was done with one pass instead of two that would help as well.

Acaila
2nd July 2002, 09:02
Just search for "SmoothHiQ" (it's the avisynth version of Smart Smooth High Quality)

It might be a little different, but can't imagine it to be much.

soulfx
3rd July 2002, 09:14
I've tried the SSHiQ, but I can't get it to just get rid of the rainbow artifacts like Tim's I and Q only filter does.

SSHiQ is a great filter by itself, but by my standards still a bit slow. The code isn't MMX optimized yet, maybe when such optimizations are made I'll consider using it more often.

sh0dan
3rd July 2002, 16:59
Regarding the Smooth IQ, porting it to Avisynth should be a matter of finding an YUV -> YIQ conversion algorithm. Should just be a matter of:


YUV -> YIQ | YIQ -> YUV
Y = Y (no changes) | Y = Y (no changes)
I = -0.2676*U+0.7361*V | U = -1.1270*I+1.8050*Q
Q = 0.3869*U+0.4596*V | V = 0.9489*I+0.6561*Q


Then the filter is directly portable - and will be somewhat faster than using the VDUB version (since it only needs to smooth half the data, since there are only 1 chroma value for every second pixel). When I´m done writing the Smooth HiQ Avs MMX-code I´ll have time to look at it. Should be fairly straightforward though, so perhaps someone else is up to the challenge.

Another more hacky, but more useful way would be to do YUV -> YIQ and YIQ -> YUV conversion routines for AVS, but without telling AVS that it has actually been converted. That way all filters can be used in YIQ colorspace. A sample script could look like this:


AVISource("")
YUVToYIQ()
YIQsource=SmoothHiQ(params)
MergeChroma(YIQSource)
YIQToYUV()


The colors will look strange, if YIQToYUV() isn't called - but hey it'll work.

Another way to get a good result may be to smooth the chroma channels of your video, and then merging it with the luma channel - the result should be quite similar to SmoothIQ. You need MergeLuma/MergeChroma (Luma / Chroma Merger (http://cultact-server.novi.dk/kpo/avisynth/merge_as.html)).

An avs-script like this (from head - I can't test it on this machine):

Avisource("")
chromavid=smoothhiq(very high params) (try other filters as well)
mergechroma(chromavid)



Regarding the MMX-version of the Smooth HiQ it is fairly complex, and will still require some time before the first version is available. The fastest way to get it to work in AVS is still to use the vdub-version with colorspace conversions.

soulfx
4th July 2002, 04:25
Thanks for your input sh0dan, I tried MergeLuma/MergeChroma way back when I first started looking for an AVS way of doing a Smooth IQ, but for everything I did and all the filters I could throw at it I couldn't get it to reduce the rainbows by any noticeable amount.

And for all the messing around I've done in AVS I've completely forgotten that the VDUB SSHiQ is already MMX(+) and even Athlon optimized. Thanks for the reminder. I'm going to run a couple tests here in a bit and give it a shot.

Richard Berg
4th July 2002, 04:45
Tim's website seems to be down. Can anyone who downloaded it (or can get to the site) post the source here?

Meantime, someone want to try this filter (http://freevcr.ifrance.com/freevcr/virtualdub/cnr-en.html) and see if it's an adequate alternative for porting? I'm not aware of any disadvantages smoothing in YUV space has vs. YIQ, and it would be a much easier port (not to mention its website is up :)).

sh0dan -- Of course I'm curious why the MMX/SSE optimizations for the VDub plugin aren't adaptable to the AVS version, but I have only glanced at your code and am by no means an expert in such things...anyway, are you planning a YUV mode for SSHiQ? It's by far the best smoothing plugin available for VDub, and while the preview functions are kind of its killer app there, an AVS-native YUV mode would definitely have advantages of its own.

sh0dan
6th July 2002, 14:27
Originally posted by Richard Berg

sh0dan -- Of course I'm curious why the MMX/SSE optimizations for the VDub plugin aren't adaptable to the AVS version, but I have only glanced at your code and am by no means an expert in such things...anyway, are you planning a YUV mode for SSHiQ? It's by far the best smoothing plugin available for VDub, and while the preview functions are kind of its killer app there, an AVS-native YUV mode would definitely have advantages of its own.

I've already written a pure YUV-mode smoother for avisynth (get it here (http://cultact-server.novi.dk/kpo/avisynth/smooth_hiq_as.html)). I'm not promotoing it, since it is still slower than the optimized vdub-filter (quality and compresability is better though).

The AVS version is pure YUY2, so there has to be massive restructuring, due to the very different pixel format (2 pixels per int vs 1 pixel per int). Also some tests can be omitted - thus it is only necessary to test chroma values every second pixel (since the chroma is the same for each even and odd pixel. The biggest problem is that the same algorithms have to be implemented many times, but with slight modifications. I do however expect this to be faster than the RGB-version, when it is finished.

Furthermore I intend to further unroll loops, so a diameter of 3 or 5 doesn't require any looping.