Log in

View Full Version : A small SSIM test on x264 "--direct spatial" mode


MeteorRain
10th February 2006, 10:29
Well, just spend some time testing the "--direct spatial" option.

Source is a low motion anime(Full Metal Panic Fumoffu DVD source), 23:37 long, encoded at constant qp20, ref2, b-f12.

AVS script is:
setmemorymax(10)
LoadPlugin("g:\dgmpgdec146rc1\DGDecode.dll")
LoadPlugin("g:\avs\it.dll")
MPEG2Source("main.d2v")
IT(fps=30,ref="TOP",blend=false,diMode=3)
assumefps(2997,100)
crop(4,2,-4,-0)
bicubicresize(640,480,0.3333,0.3333)

Command lines are: (SP for spatial, TP for temporal)
SP:
H:\mp4\x264.exe --qp 20 --ref 2 --bframes 12 --b-pyramid --nf --weightb --analyse all --8x8dct --ipratio 1.0 --pbratio 1.0 --me umh --mixed-refs --progress --direct spatial --no-psnr --output "%1_sp.mp4" "%1\main.avs" 2> %1.log.txt

TP:
H:\mp4\x264.exe --qp 20 --ref 2 --bframes 12 --b-pyramid --nf --weightb --analyse all --8x8dct --ipratio 1.0 --pbratio 1.0 --me umh --mixed-refs --progress --no-psnr --output "%1_tp.mp4" "%1\main.avs" 2> %1.log.txt

Final works size: (video only)
SP: 106,012 KB
TP: 109,411 KB

I did an SSIM (Structural Similarity Index Metric 0.23) test. the overall result is:
SP Average SSIM = 87.92
TP Average SSIM = 87.89
(attention: x264 target file is in mp4, so i used directshowsource("xxx.mp4"))

SSIM peak image: (100 frame per pixel)
SP:
http://bbs.manmi.com/uploadFile/2006-2/200621017531927.gif
TP:
http://bbs.manmi.com/uploadFile/2006-2/2006210175358854.gif
Here the top of the image is 1.0, the bottom is 0.95.
The green line draws from the min SSIM value to its max(peak) per 100 frame.
The red point are the average SSIM per 100 frame.
There's some frames with SSIM 0.000 (don't know why) so there are long lines.

SSIM delta image:
delta value = SP SSIM - TP SSIM
Delta image:
http://bbs.manmi.com/uploadFile/2006-2/2006210175248349.gif
here the top of the image is 0.005, the bottom is -0.005.
the red point also average.
the white line is zero line.

and zoom more:
http://bbs.manmi.com/uploadfile/2006-2/2006210175141190.gif
here the top of the image is 0.002, the bottom is -0.002.

seems that spatial b-direct works better on this kind of materials ;)

============================================================
OK, the result of episode 2.

Size:
SP: 162,952 KB
TP: 165,404 KB

Average SSIM:
SP Average SSIM = 87.93
TP Average SSIM = 87.91

SSIM peak image:
SP:
http://bbs.manmi.com/UploadFile/2006-2/2006211193912233.gif
TP:
http://bbs.manmi.com/UploadFile/2006-2/2006211193928732.gif

SSIM delta image:
http://bbs.manmi.com/UploadFile/2006-2/2006211193938983.gif

zoom more:
http://bbs.manmi.com/UploadFile/2006-2/2006211193946841.gif

x264 core:37 svn-333M (built by Sharktooth)

SP: slice I:556 Avg QP:20.00 size: 23163 PSNR Mean Y:47.67 U:49.82 V:50.24 Avg:48.23 Global:47.37
TP: slice I:556 Avg QP:20.00 size: 23173 PSNR Mean Y:47.66 U:49.83 V:50.24 Avg:48.23 Global:47.37
SP: slice P:14410 Avg QP:20.00 size: 8412 PSNR Mean Y:45.60 U:47.70 V:47.78 Avg:46.15 Global:45.84
TP: slice P:14411 Avg QP:20.00 size: 8417 PSNR Mean Y:45.59 U:47.70 V:47.78 Avg:46.14 Global:45.84
SP: slice B:27504 Avg QP:20.00 size: 1176 PSNR Mean Y:46.05 U:48.24 V:48.31 Avg:46.63 Global:46.20
TP: slice B:27503 Avg QP:20.00 size: 1264 PSNR Mean Y:46.04 U:48.23 V:48.31 Avg:46.62 Global:46.19
SP: mb I I16..4: 31.4% 32.9% 35.7%
TP: mb I I16..4: 31.4% 32.8% 35.8%
SP: mb P I16..4: 4.3% 6.5% 5.1% P16..4: 16.5% 5.9% 4.6% 1.4% 0.9% skip:54.8%
TP: mb P I16..4: 4.3% 6.5% 5.1% P16..4: 16.4% 5.9% 4.6% 1.4% 0.9% skip:54.8%
SP: mb B I16..4: 0.2% 0.3% 0.4% B16..8: 5.9% 0.4% 0.7% direct: 5.6% skip:86.5%
TP: mb B I16..4: 0.2% 0.4% 0.4% B16..8: 12.8% 0.4% 0.7% direct: 3.5% skip:81.6%
SP: 8x8 transform intra:39.0% inter:20.4%
TP: 8x8 transform intra:39.0% inter:24.6%
SP: ref P 76.0% 24.0%
TP: ref P 76.5% 23.5%
SP: ref B 74.9% 25.1%
TP: ref B 80.9% 19.1%
SP: PSNR Mean Y:45.918 U:48.074 V:48.156 Avg:46.485 Global:46.086 kb/s:939.57
TP: PSNR Mean Y:45.911 U:48.073 V:48.155 Avg:46.480 Global:46.081 kb/s:953.75



so, spatial mode works fine, better than temporal in a low-motion, mid/high resolution, mid/high quality encoding.
============================================================

discussion welcomed. ;)

iceborne
10th February 2006, 10:43
too bad i can't see the image

DarkZell666
10th February 2006, 10:54
Cool Image host logo, upload them elsewere :p

MeteorRain
10th February 2006, 10:59
the image should work now ;)

Sirber
10th February 2006, 13:17
nice :D

Spatial will be use in RealAnime 4.0.0.

MeteorRain
10th February 2006, 16:07
/me would do the same test on episode 2 some time later.

Caroliano
10th February 2006, 19:20
I don't know if you saw the post I made for this matter before that, but for those who haven't: http://forum.doom9.org/showthread.php?p=783717

You can contribute there too. Your full episode results are aproximatetly the same as my for short samples. In anime.

MeteorRain
11th February 2006, 05:39
I don't know if you saw the post I made for this matter before that, but for those who haven't: http://forum.doom9.org/showthread.php?p=783717

You can contribute there too. Your full episode results are aproximatetly the same as my for short samples. In anime.
yea. in fact i start this test after reading your post. seems your test is only on some small part of an anime (hundreds of frames), and i'm testing on a whole episode with full resolution (640*480) and in mid-high quality (cq20) so i think it worth a new thread :)
-- MR

foxyshadis
11th February 2006, 06:03
SP Average SSIM = 87.92
TP Average SSIM = 87.89

Given the difference is pretty much below the noise threshold, I'm interested in whether you could spot actual visual differences, where spacial fixed a blocky area. Otherwise, the size reduction is still nice.

I'm also interested in whether it still holds true with dedup removing many of the duplicates. I'll probably run that test myself eventually.

Kami Butt
11th February 2006, 07:25
plese help me i need mp4 converter downlods free thanks advance

DarkZell666
11th February 2006, 10:09
Message to Kami Butt
----------------------

1) I think this post shouldn't really be here

2) you seem to know nothing about video/containers/etc ...
MP4 is a container (like AVI), in which is placed a video and/or audio stream (e.g. DivX+MP3, or XviD+OGG, but more likely AVC+AAC since it's a MP4 file ;)).

What you might want is a mp4 demuxer (to extract the streams from the mp4 file), then you would be able to put them into an AVI file and work with them in your favorite video editor.

YAMB 1.5 is what you probably are looking for (this does the mp4 demuxing via a commandline tool called mp4box bundled with it) : http://yamb.unite-video.com/Yamb-1.5.exe

Then you will need another program to remux the streams you extracted into an AVI file (AVIMux) : http://www.doom9.org/Soft21/Editing/AVI-Mux_GUI-1.17.4.zip

Beware, if you are to extract an AVC video stream, you will have to install ffdshow (get it here: http://x264.nl) and configure it to decode H264 (the other name for AVC) using the VFW interface. (Search the forum a bit you might learn some things)

MeteorRain
11th February 2006, 12:52
SP Average SSIM = 87.92
TP Average SSIM = 87.89

Given the difference is pretty much below the noise threshold, I'm interested in whether you could spot actual visual differences, where spacial fixed a blocky area. Otherwise, the size reduction is still nice.
can't see any obvious differences between those two. try it by urself ;)

*.mp4 guy
12th February 2006, 06:29
He used 12 bframes in a row, which is 4 times what the default value is. Using that many bframes in a row degrades pframe quality (because its hard to get good motion estimation between 2 frames that are 12 frame apart) this raises the size of pframes while degrading their quality. Since temporaly predicted bframes use pframes as references this test is biased against temporal prediction bframe prediction. You should redo the test with a sane number of bframes to get more unbiased results.

akupenguin
12th February 2006, 07:23
SP: slice P:14410 Avg QP:20.00 size: 8412 PSNR Mean Y:45.60 U:47.70 V:47.78 Avg:46.15 Global:45.84
TP: slice P:14411 Avg QP:20.00 size: 8417 PSNR Mean Y:45.59 U:47.70 V:47.78 Avg:46.14 Global:45.84
SP: slice B:27504 Avg QP:20.00 size: 1176 PSNR Mean Y:46.05 U:48.24 V:48.31 Avg:46.63 Global:46.20
TP: slice B:27503 Avg QP:20.00 size: 1264 PSNR Mean Y:46.04 U:48.23 V:48.31 Avg:46.62 Global:46.19
He used 12 bframes in a row, which is 4 times what the default value is.
No, he used as many B-frames as x264 thought appropriate. Which turned out to be an average of only 2 consecutive B-frames.
Although I'm suspicous of the --ipratio 1.0 --pbratio 1.0, and the SSIM=0 frames definitely indicate a bug in something.

NB : I used bframe bias = 100 to enforce the 6 consecutive Bframes
That comparison (http://forum.doom9.org/showthread.php?p=782078#post782078), on the other hand, is broken due to forcing too many B-frames.

*.mp4 guy
12th February 2006, 08:56
Heh forgot about that:o.

MeteorRain
12th February 2006, 14:34
the SSIM=0 frames definitely indicate a bug in something.
SSIM=0 frames are all pure black. could that be a yc color extend? (16~235 <-> 0~255?) becuz the x264 is opened through directshowsource. don't know :confused: :confused:

Kopernikus
12th February 2006, 17:55
No, if one frame is completely black (0) and the other frame is completely almost black (16), the ssim shouldn't be 0 but about 80 or so.