Log in

View Full Version : CompareYV12


Shalcker
24th July 2003, 13:49
Since there seems to be no progress in that direction and widely used "ConvertToYUY2().Compare" blurs chroma resulting in "better" overall PSNR (which can be misleading) I created this filter - Compare for clips in YV12 colorspace.

Dll and source code (with SSE optimizations) can be downloaded here (http://web.etel.ru/~shalcker/CompareYV12.zip)

No On-Screen Display and no graph at the moment, only logfile and debug output supported.

While creating this I noted small bug in current AviSynth Compare function

if (channels[0] == 0) {
if (vi.IsRGB32() || vi.IsRGB24())
channels = "RGB";
else if (vi.IsYUY2())
channels = "YUV";
else env->ThrowError("Compare: clips have unknown format");
}

when you set channels to any non-empty value Compare will accept ANY input colorspace...

trbarry
24th July 2003, 14:42
Shalcker -

Thanks. That should be useful. I'll check that out.

I've also been using ConvertToYUY2().Compare() but I knew it probably changed the results a bit.

- Tom

temporance
25th July 2003, 12:46
Nice work, Shalcker :D

Could you add a computation of Overall PSNR? It produces more reliable results than a simple mean average PSNR.

It's already done by the regular Compare() (see latest avisynth CVS). There are some more details on this (http://forum.doom9.org/showthread.php?s=&threadid=57744
) thread:

Shalcker
25th July 2003, 13:17
Originally posted by temporance
Nice work, Shalcker :D

Could you add a computation of Overall PSNR? It produces more reliable results than a simple mean average PSNR.

Actually that "average" PSNR in my plugin is computed from Mean Square Error sum as:
Average PSNR = 10*log10 (255*255*FramesProcessed/ SumValues[Channel][_MSE])
so it is the "overall" PSNR you're reffering to;
since Mean Square Error (MSE) = (Pixel Error^2)/(bytecount), and SumValues is array containing sum of all values from processed frames.

temporance
25th July 2003, 14:03
nice :)

I read the source too quickly!

CruNcher
25th July 2003, 15:30
great work but unfortunately i cant use compareyv12, this is what im getting with mplayer 6.4 and mediaplayer classic @ the end of a compare


name = "none-2pass.avi"
original=avisource("low_motion-original.avi")
modified=avisource(name)
compareyv12(original,modified, "", name+".psnr.log", false)

Result :

Comparing channel(s)

Mean Max Max
Absolute Mean Pos. Neg.
Frame Dev. Dev. Dev. Dev. PSNR (dB) Avg. PSNR
---------------------------------------------------------------
2 -1.#IND -1.#IND 0 +0 0.0000 1.#INF
3 -1.#IND -1.#IND 0 +0 0.0000 1.#INF
4 -1.#IND -1.#IND 0 +0 0.0000 1.#INF
5 -1.#IND -1.#IND 0 +0 0.0000 1.#INF

Comparing channel(s)

Mean Max Max
Absolute Mean Pos. Neg.
Frame Dev. Dev. Dev. Dev. PSNR (dB) Avg. PSNR
---------------------------------------------------------------


any idea what could cause this, the plugin is in the plugins dir and gets autoloaded a normal compare with Converttoyuy2 works :(

avisynth is 2.5.2 17.06.03 build
system: p4 1.8
os: windows xp pro
directx: 9.0b

originalclip = vble (avisource)
modified= Xvid Devapi4 rendered thtough xvid.dll (avisource)

Shalcker
25th July 2003, 17:06
Originally posted by CruNcher
great work but unfortunately i cant use compareyv12, this is what im getting with mplayer 6.4 and mediaplayer classic @ the end of a compare
[CODE]
name = "none-2pass.avi"
original=avisource("low_motion-original.avi")
modified=avisource(name)
compareyv12(original,modified, "", name+".psnr.log", false)

Result :

Comparing channel(s)


Empty channels... weird... oh, yes, i forgotten to check channels string for zero length. I'll fix this shortly, it only requires one line of code.

any idea what could cause this, the plugin is in the plugins dir and gets autoloaded a normal compare with Converttoyuy2 works :(
Just set channels to "YUV" instead of "" and bug should be gone. Or try
compareyv12(original,modified, logfile=name+".psnr.log")

Edit: Fixed. Updated version (v1.01) available at the same URL here (http://web.etel.ru/~shalcker/CompareYV12.zip)

CruNcher
7th August 2003, 18:48
@Shalcker

there musst be still a problem somewhere


Total frames processed: 2520
Minimum Average Maximum

Y: Mean Absolute Deviation: 0.0000 1.9301 5.0150
U: Mean Absolute Deviation: 0.0000 1.3147 3.7740
V: Mean Absolute Deviation: 0.0000 1.1159 4.2228
Sum: Mean Absolute Deviation: 0.0000 1.6919 4.5222

Y: Mean Deviation: -2.8939 -0.0665 1.4344
U: Mean Deviation: -2.0027 -0.1061 1.9306
V: Mean Deviation: -0.9144 -0.0271 1.7173
Sum: Mean Deviation: -1.9241 -0.0665 1.2777

Y: Mean Square Error: 0.0000 10.3204 68.5512
U: Mean Square Error: 0.0000 4.7763 36.3066
V: Mean Square Error: 0.0000 3.7386 42.8451
Sum: Mean Square Error: 0.0000 8.2995 52.7642

Y: Root Mean Square Error: 0.0000 2.9492 8.2796
U: Root Mean Square Error: 0.0048 1.9763 6.0255
V: Root Mean Square Error: 0.0000 1.7278 6.5456
Sum: Root Mean Square Error: 0.0020 2.6554 7.2639

Y: PSNR: 29.7707 37.9938 1.#INF
U: PSNR: 32.5310 41.3399 94.5177
V: PSNR: 31.8118 42.4037 1.#INF
Sum: PSNR: 30.9074 38.9403 102.2992
Minimum Average Maximum

Mean Absolute Deviation: 0.0000 1.6919 4.5222
Mean Deviation: -1.9241 -0.0665 1.2777
PSNR: 30.9074 38.9403 102.2992



look @ those 2 1.#INF i think thats resulting in a wrong overall result isn't it ?

compareyv12(original,modified,"YUV", name+".psnr.log", false)

Shalcker
7th August 2003, 18:58
Originally posted by CruNcher
@Shalcker

there musst be still a problem somewhere


Total frames processed: 2520
Minimum Average Maximum

Y: Mean Absolute Deviation: 0.0000 1.9301 5.0150
U: Mean Absolute Deviation: 0.0000 1.3147 3.7740
V: Mean Absolute Deviation: 0.0000 1.1159 4.2228
Sum: Mean Absolute Deviation: 0.0000 1.6919 4.5222

Y: Mean Deviation: -2.8939 -0.0665 1.4344
U: Mean Deviation: -2.0027 -0.1061 1.9306
V: Mean Deviation: -0.9144 -0.0271 1.7173
Sum: Mean Deviation: -1.9241 -0.0665 1.2777

Y: Mean Square Error: 0.0000 10.3204 68.5512
U: Mean Square Error: 0.0000 4.7763 36.3066
V: Mean Square Error: 0.0000 3.7386 42.8451
Sum: Mean Square Error: 0.0000 8.2995 52.7642

Y: Root Mean Square Error: 0.0000 2.9492 8.2796
U: Root Mean Square Error: 0.0048 1.9763 6.0255
V: Root Mean Square Error: 0.0000 1.7278 6.5456
Sum: Root Mean Square Error: 0.0020 2.6554 7.2639

Y: PSNR: 29.7707 37.9938 1.#INF
U: PSNR: 32.5310 41.3399 94.5177
V: PSNR: 31.8118 42.4037 1.#INF
Sum: PSNR: 30.9074 38.9403 102.2992
Minimum Average Maximum

Mean Absolute Deviation: 0.0000 1.6919 4.5222
Mean Deviation: -1.9241 -0.0665 1.2777
PSNR: 30.9074 38.9403 102.2992



look @ those 2 1.#INF i think thats resulting in a wrong overall result isn't it ?

No, they don't. Look up in this thread - final Average PSNR is calculated as 10*log10 (255*255*FramesProcessed/ SumValues[Channel][_MSE]). Now, infinite PSNR is only possible for frames with zero MSE - which means that they are just ignored in final Sum while FramesProcessed increases. MSE Sum is not zero as long as at least one frame is different from another. And if all frames are identical then infinite PSNR is RIGHT and absolutely valid result.

quantum
24th August 2003, 01:52
So what is the average PSNR here?
Total frames processed: 49001
Minimum Average Maximum

Y: Mean Absolute Deviation: 0.0000 3.9589 5.7205
U: Mean Absolute Deviation: 0.0000 0.4881 2.5603
V: Mean Absolute Deviation: 0.0000 0.3679 2.2183
Sum: Mean Absolute Deviation: 0.0000 5.0053 3.9889

Y: Mean Deviation: -0.3584 0.4515 0.7846
U: Mean Deviation: -0.5319 0.0983 0.6549
V: Mean Deviation: -0.3375 0.0828 0.8397
Sum: Mean Deviation: -0.2154 0.6608 0.5377

Y: Mean Square Error: 0.0000 3.8224 76.5912
U: Mean Square Error: 0.0000 1.3902 15.1334
V: Mean Square Error: 0.0000 1.0398 10.8859
Sum: Mean Square Error: 0.0000 2.9533 51.8263

Y: Root Mean Square Error: 0.0000 1.7033 8.7516
U: Root Mean Square Error: 0.0000 1.0113 3.8902
V: Root Mean Square Error: 0.0000 0.8660 3.2994
Sum: Root Mean Square Error: 0.0000 1.5065 7.1990

Y: PSNR: 29.2890 -1.#IND 1.#INF
U: PSNR: 36.3314 -1.#IND 1.#INF
V: PSNR: 37.7621 -1.#IND 1.#INF
Sum: PSNR: 30.9853 -1.#IND 1.#INF
Minimum Average Maximum

Mean Absolute Deviation: 0.0000 5.0053 3.9889
Mean Deviation: -0.2154 0.6608 0.5377
PSNR: 30.9853 -1.#IND 1.#INF


I have a number of frames like this in the video:
48876 0.0000 +0.0000 0 +0 1.#INF 43.5857

Shalcker
24th August 2003, 05:41
Originally posted by quantum
So what is the average PSNR here?
Total frames processed: 49001
<skip>
Y: PSNR: 29.2890 -1.#IND 1.#INF
U: PSNR: 36.3314 -1.#IND 1.#INF
V: PSNR: 37.7621 -1.#IND 1.#INF
Sum: PSNR: 30.9853 -1.#IND 1.#INF


Weird... really weird...
I don't see how things can be that different between this (average PSNR writtten for each frame, which is ok as you noted below in frame example)
10*log10 (255*255/(SumValues[i][_MSE]/FramesProcessed) )
and this (average PSNR written at the end of the sequence)
10*log10 (255*255*FramesProcessed/ SumValues[i][_MSE])
SumValues is array of doubles, and i don't think there can be a problem with that, so maybe problem comes with big number of frames. hmm... yes, looks like that creates error.
(255*255*49001)=3186290025 (0xBDEAED69)
Problem starts at frame 33026, guess not many people process sources that big...

Fixed version 1.02 is available at the same URL
http://web.etel.ru/~shalcker/CompareYV12.zip


I have a number of frames like this in the video:
48876 0.0000 +0.0000 0 +0 1.#INF 43.5857
Look at this information on the last frame - last number there is average PSNR for all 49001 frames...

quantum
31st August 2003, 16:06
New version works okay so far, thanks.