Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th July 2003, 13:49   #1  |  Link
Shalcker
Programmer
 
Shalcker's Avatar
 
Join Date: Mar 2003
Location: Ekaterinburg, Russia
Posts: 112
CompareYV12

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

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
Code:
  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...
Shalcker is offline   Reply With Quote
Old 24th July 2003, 14:42   #2  |  Link
trbarry
Registered User
 
trbarry's Avatar
 
Join Date: Oct 2001
Location: Gainesville FL USA
Posts: 2,092
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
__________________
My video filters (still) at www.trbarry.com.
trbarry is offline   Reply With Quote
Old 25th July 2003, 12:46   #3  |  Link
temporance
Registered User
 
Join Date: Mar 2002
Posts: 486
Nice work, Shalcker

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 thread:
temporance is offline   Reply With Quote
Old 25th July 2003, 13:17   #4  |  Link
Shalcker
Programmer
 
Shalcker's Avatar
 
Join Date: Mar 2003
Location: Ekaterinburg, Russia
Posts: 112
Quote:
Originally posted by temporance
Nice work, Shalcker

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.
Shalcker is offline   Reply With Quote
Old 25th July 2003, 14:03   #5  |  Link
temporance
Registered User
 
Join Date: Mar 2002
Posts: 486
nice

I read the source too quickly!
temporance is offline   Reply With Quote
Old 25th July 2003, 15:30   #6  |  Link
CruNcher
Registered User
 
CruNcher's Avatar
 
Join Date: Apr 2002
Location: Germany
Posts: 4,929
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) 

           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)
__________________
all my compares are riddles so please try to decipher them yourselves :)

It is about Time

Join the Revolution NOW before it is to Late !

http://forum.doom9.org/showthread.php?t=168004

Last edited by CruNcher; 25th July 2003 at 15:40.
CruNcher is offline   Reply With Quote
Old 25th July 2003, 17:06   #7  |  Link
Shalcker
Programmer
 
Shalcker's Avatar
 
Join Date: Mar 2003
Location: Ekaterinburg, Russia
Posts: 112
Quote:
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.

Quote:
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

Last edited by Shalcker; 25th July 2003 at 19:36.
Shalcker is offline   Reply With Quote
Old 7th August 2003, 18:48   #8  |  Link
CruNcher
Registered User
 
CruNcher's Avatar
 
Join Date: Apr 2002
Location: Germany
Posts: 4,929
@Shalcker

there musst be still a problem somewhere

Code:
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)
__________________
all my compares are riddles so please try to decipher them yourselves :)

It is about Time

Join the Revolution NOW before it is to Late !

http://forum.doom9.org/showthread.php?t=168004
CruNcher is offline   Reply With Quote
Old 7th August 2003, 18:58   #9  |  Link
Shalcker
Programmer
 
Shalcker's Avatar
 
Join Date: Mar 2003
Location: Ekaterinburg, Russia
Posts: 112
Quote:
Originally posted by CruNcher
@Shalcker

there musst be still a problem somewhere

Code:
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.
Shalcker is offline   Reply With Quote
Old 24th August 2003, 01:52   #10  |  Link
quantum
Registered User
 
Join Date: Nov 2002
Location: USA
Posts: 528
So what is the average PSNR here?
Code:
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:
Code:
 48876    0.0000    +0.0000     0     +0     1.#INF   43.5857

Last edited by quantum; 24th August 2003 at 01:55.
quantum is offline   Reply With Quote
Old 24th August 2003, 05:41   #11  |  Link
Shalcker
Programmer
 
Shalcker's Avatar
 
Join Date: Mar 2003
Location: Ekaterinburg, Russia
Posts: 112
Quote:
Originally posted by quantum
So what is the average PSNR here?
Code:
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)
Code:
10*log10 (255*255/(SumValues[i][_MSE]/FramesProcessed) )
and this (average PSNR written at the end of the sequence)
Code:
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

Quote:

I have a number of frames like this in the video:
Code:
 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...
Shalcker is offline   Reply With Quote
Old 31st August 2003, 16:06   #12  |  Link
quantum
Registered User
 
Join Date: Nov 2002
Location: USA
Posts: 528
New version works okay so far, thanks.
quantum is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.