Log in

View Full Version : Psnr.dll :)


Marc FD
20th July 2002, 19:04
Pfuiou !
I never coded a filter so fast (2 hours :devil: )
Big thx to gruel (see in the readme)

I always dreamed to calculate the PSNR (it seemed to be a secret and inreachable value because i've never seen a prog/util/filter to calc it !!)

Or maybe you all ignore PSNR and only trust your eyes :
Your're right ! PSNR is not Quality but write "i've got a terrible PSNR : 60 Db !!!" it's better than : "it's the best quality" sentences...

You use it to tune my avs filters chains and compare codecs :cool:

I hope you'll enjoy it :)

dividee
21st July 2002, 03:36
Arg! bad timing :(
I just wrote a filter that calculate the PSNR, as well as some other measures, and I'm in the process of making it a bit more flexible to include it in avisynth.

Marc FD
21st July 2002, 12:31
sorry :(
but test my filter : i've relly done a good job :)

(PS : We can work together if you want :) )

Koepi
21st July 2002, 15:41
Marc,

you can't compare codecs by PSNR.

It would be like comparing cars by PS numbers.

You can check whether you improved something with that, sure, but in NO way it's possible to comapre e.g. divx and xvid based on PSNR.

Regards,
Koepi

trbarry
21st July 2002, 18:49
you can't compare codecs by PSNR

Koepi -

Probably true. You can't compare codecs by putting a single number on them.

But from everything I've read, if you did have to settle for one simple fidelity measure the PSNR would be one of better ones.

So I'm going to try it. ;)

- Tom

sh0dan
22nd July 2002, 08:45
Marc FD: This is actually very useful! I do however seem to get some strange artifacts. I guess it's related to a missing call to MakeWriteable() before BitBlt?

The following script shows it:


LoadPlugin("c:\apps\AviSynth\psnr.dll")
colorbars(512,384)
converttoyuy2()
converttorgb()
converttoyuy2()
Psnr(colorbars(512,384).converttoyuy2())


Could a "Noise Peak" be implemented, so it shows the highest noise value?
Or even better - a noise graph that shows the amount of noise at a given frequency. (frequency on the x-axis and the amount on y-axis). It would help greatly to see the distribution.

Marc FD
22nd July 2002, 11:19
I'm MMixed :) i tried my first lines of MMX on the Psnr's SSD (square-sum of distances), because it should be the slower part of the PSNR calculation, but it didn't improve speed because the SSD calc is very fast in fact, and it's only working with 2 source at once who slow down the process (but 10 fps is enough for a tool :) )

I think psnr.dll could be usefull to compare avisynth chain-filters

@shodan
artifacts ??
you mean the PSNR-graph in black in the bottom of the screen ??
OR it's something else ??
PS : The output image is a BitBlt from clip2, but i didn't optimize it :(

@Koepi
I agree with you. Since you have read the readme, you' ve seen my warnings on the PSNR.
But i like cars with many PS, like many people :)

@Dividee
Is your filter very advanced ? If you can compute tons of others interessing values (like Zhou Wang's structural distortion measure :) ), we can always merge our filters. work would be done faster & better :cool:

dividee
23rd July 2002, 06:56
Sorry for not answering earlier, I had some hardware problem yesterday. One of my DDR stick died :(

Actually, the slowest part in your filter (as in mine) is probably the text output. Try it: comment out the font rendering functions and see how fast it goes :)
That's why you don't see any difference when the SSD calcs are in MMX.
In my filter, I added an option to log the results to a file and disable the on-screen output. That makes it go 10x faster for the C version, and about 30x faster for the Integer SSE version (I don't have an MMX version).

But no, my filter doesn't do a lot more. I don't have a graph, but I also display the mean of differences and the mean of absolute differences. By comparing the two, you can tell if your filter chain has a bias when it shouldn't. Very useful for tracking rounding errors in filters. To end the feature list comparison, it also allows to select only some channels for comparisons (Y,U,V or R,G,B[,A]). By default, it doesn't compare the alpha channel in RGB32, which is probably better.
If people like it, I could add your PSNR graph ?

Marc FD
23rd July 2002, 13:47
Hi.
the only algo i have is gruel's C psnr (i'm not even sure i did it himself..) so the MMX version was in fact my firsts steps in MMX coding :devil: .

PS: I can't see any difference between ISSE and MMX code. i think it's only a few new instructions. Right ??

I'm going to take a look on the "Intel arch instr. set devel ref manual" :cool:

And since psnr 1.0 is in GPL v2 you can do whatever you want with the code : just tag my name somewhere and lemme know if you ripp a part of my code :D

trbarry
23rd July 2002, 14:55
I'm going to take a look on the "Intel arch instr. set devel ref manual"

There is also a useful "Intel Architecture Optimization Reference" available on the Intel site that you might want to take a look at.

- Tom

dividee
23rd July 2002, 15:47
Yep, ISSE is just some additionnal instructions, but they come in handy sometimes. The problem with the "Inst. Set Ref." from Intel is that it doesn't tell explicitely which instructions are for which architecture. The other day I wanted to use PADDQ and didn't realise immediately that it's an SSE2 only instruction. So, while you're at it you might also grab the Volume 1: Basic Architecture; it includes that kind of details.

Well, I found the PSNR formula in Nandub source code, but I guess it can also be found it by googling at bit; it's not a "secret and inreachable value" ;)

Anyway, thanks for your offer. I think i'll rip the graph then :p

Marc FD
23rd July 2002, 17:56
And i've a little trick to speedup (by 1,5x) the text overlay :devil:
say me if you're interessed (now psnr.dll is 15 fps fast but i don't think it will stand before your filter so i won't make release anymore...)

dividee
24th July 2002, 21:22
I commited my filter to the CVS. It's called Compare and has the following syntax (with default values):

Compare(clip filtered, clip original, string channels="", string logfile="", bool show_graph=true)

It outputs the filtered clip (first arg) with text (Mean Absolute Difference, Mean Difference & PSNR) and Marc's PSNR graph (if show_graph is true). The channels string is a combination of R,G,B[,A] or Y,U,V , depending on the source clips. The empty string (default) means either "YUV" or "RGB". If logfile is not null, the results will be written to a file by this name and not drawn on the clip. It is much faster if you need to compare a lot of frames.
ex:
Compare(clip1,clip2,"UV") will only compare chroma channels of YUY2 clips.

BTW, I also optimized the text renderer a bit. Each time you change the text to be written, it has to recalculate the antialiasing mask, and it takes a huge amount of time. But most of the text bitmap is just black anyway so I optimized for this common case.

scorchED
4th August 2002, 18:37
what is a good or worse PSNR value, when copmaring original and encoded material?
I get around 45 and don't know if my filterchain for 1CD makes a good job (but in my eyes it looks perfectly).

Marc FD
4th August 2002, 21:13
Impossible to say.
45 seems a good value. it can get worser on very blocky scenes ( under 40) and you can get values close from 50 dB when the codec is doing is best... but i don't think higher values can be reached with quant2

dividee
4th August 2002, 21:23
What could be interesting is this:
* Create a filter chain using your eyes to tell you if it's good.
* Encode both the filtered and unfiltered video.
* Use PSNR to compare
(a) the unfiltered encoding with the unfiltered original
(b) the filtered encoding with the filtered original

this way you could tell ( if PSNR(b) > PSNR(a) ) if the filtering helped the codec.
It's even possible in some case that PSNR(c) between the filtered encoding and the unfiltered original is even higher than PSNR(a). that's the ideal situation, I think.

scorchED
4th August 2002, 23:46
i would like to see an average PSNR in this nice filter.
So we can compare globaly some movie-encodes with different settings.
i like the kind of the result output - very nice;)

Marc FD
4th August 2002, 23:48
there is a file-log option.
should give the avg PSNR.
but dividee can explain it better :)

scorchED
5th August 2002, 00:29
is it possible to write the average PSNR directly on the screen, while comparing the two movies?
Maybe:

- Frame - actual PSNR
- average PSNR
- highest PSNR
- lowest PSNR

dividee
5th August 2002, 01:00
That would be a lot of text on the screen, especially considering I already added other measurements. But - granted - it could be useful.

Marc FD
5th August 2002, 11:22
I don't get it...
you need to test _ALL_ frames to get the average PSNR.
if you want it on the screen, this feature will make you wait a serious time.
the log2file option who test the whole movie (with 1x1 output)
is the best solution : you simply run a "prewiew" in VDub and wait.
we just need to get it really fast (200 fps...)

@dividee
but this is already implemented, right ?

hum, back to work !
I'm going to finalize Cnr2 with the last optimisations (i will add a "fast" mode)

dividee
5th August 2002, 14:55
No, I was thinking about a running min/max/average, i.e. over frames already processed.
And it's not currently implemented; currently the logfile gives the same information as the OSD, with 1 line per frame, only faster.

And comparing the whole movie is not necessary most of the time. A 'compcheck' run would be enough. 200 fps is impossible anyway, no decoding can go that fast.

Marc FD
5th August 2002, 17:42
oups i forgot decoding.
BTW i tryed to improve Cnr2 speed, and i saw that in fact it was already as fast a a simple dstp[x] := srcp[x] on all pels !!!

scorchED
5th August 2002, 21:09
how can i get the logfile?

dividee
5th August 2002, 21:18
@scorchED
Use the version of avisynth here (http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html) and use the Compare filter I described above:
Compare(clip1,clip2) will do for on-screen display
Compare(clip1,clip2,"","compare.log") for creating a log file.

This version still doesn't output an average value. It's in the works but i have some hardware problems and can't work on it for now.