PDA

View Full Version : About Decoders


Matthaeus
23rd May 2003, 03:26
Hi!
I am a newbie here and it is my 1st post. I searched on the forum for
a decoder test because I wanted to know which decoder is the best for
playing XviD encoded movies, but I haven't found any good thread.
So I have decided to create a psnr-test with different mpeg-4 decoders.
I hope you find this test useful:

Source : 704x384 @25fps 3653 frames, RGB24
Encoder : XviD (uManiacs) 14/05/2003, 23:40

Average and Total average PSNR values were calculated using the
PSNR4AVI.EXE utility by Vanguard Software Solutions.
I think Y error has better influence on quality than U and V errors so
I have also calculated the average PSNR with weighted values.
Weighted average uses a 0.5 coefficient for Y-PSNR and 0.25 for U-PSNR
and 0.25 for V-PSNR.

1st Test
--------
Default options (Motion-6, H.263, all other options disabled)
1-pass Quantizer: 2

Compressed file size: 51,331,072 bytes

Decoder: xvid.dll
FourCC Used Codec: XVID, FourCC description Code: xvid
Results:
Average PSNR (Y U V): 41.68, 47.82, 48.07
Total Average PSNR: 45.86
Weighted Average PSNR: 44.81 <--

Decoder: 3ivxVfWCodec.dll (4.0.4.0)
FourCC Used Codec: 3IV2, FourCC description Code: 3iv2
Results:
Average PSNR (Y U V): 43.08, 48.40, 48.09
Total Average PSNR: 46.52
Weighted Average PSNR: 45.66 <--

Decoder: divx.dll (5.0.5.830)
FourCC Used Codec: DIVX, FourCC description Code: divx
Results:
Average PSNR (Y U V): 44.26, 48.47, 48.44
Total Average PSNR: 47.06
Weighted Average PSNR: 46.36 <--

Decoder: ffdshow(alpha)2003/0103 - Simple iDCT (and used grab option)
Results:
Average PSNR (Y U V): 41.62, 47.42, 47.22
Total Average PSNR: 45.42
Weighted Average PSNR: 44.47 <--
Note: the test took about 1 hour (on my computer) and I hadn't got
much time for testing the Reference iDCT in ffdshow, but with
a source of 100 frames I got eqvivalent results with the 3ivx
decoder.

As you can see the XviD decoding algorithm is not very precise, the
psnr is about 1.5db lower than the divx decoder (don't misunderstand
me, I am not a divx fan, these are only pure facts).
But don't think that 1.5db is a small difference!
Here is a demonstration:

2nd Test
--------
a.)Default options (Motion-6, H.263)
1-pass Quality: 80 (min 2, max 3) --> average quant: 2.2

Compressed file size: 48,783,360 bytes

Decoder: xvid.dll
Results:
Average PSNR (Y U V): 41.64, 47.79, 48.06
Total Average PSNR: 45.83
Weighted Average PSNR: 44.78 <--

b.)Default options (Motion-6, H.263) + VHQ=4 (!!!)
1-pass Quantizer: 2

Compressed file size: 48,590,848 bytes

Decoder: xvid.dll
Results:
Average PSNR (Y U V): 41.86, 48.04, 48.32
Total Average PSNR: 46.07
Weighted Average PSNR: 45.02 <--

The two file sizes are approximately the same (as with a 2-pass encode)
and the PSNR difference is "only" 0.24db between the VHQ and non-VHQ
encodes and encoding with VHQ=4 is about 3 or 4 times slower!
You can lose or earn 1.5db on the decoder side and only 0.24db on the encoder side!

That's all for now. Sorry for the long post but it's really my first.
Thanks for your patience.

Animaniac
23rd May 2003, 08:13
Wow, thanks. Comparing the PSNR's of decoders is really a novel idea (at least to me >.<). Newer builds of ffdshow have AviSynth support, so you could try running PSNR through there instead of grabbing snapshots. It would probably be much faster for you. Furthermore, newer builds also correct "Qpel smearing" which could produce a PSNR drop. Regardless, this is indeed food for thought.

cipher
23rd May 2003, 09:34
Matthaeus, could you explain more how you calculate PSNR among different decoders using PSNR4Avi?
P.S. Anyone would agree you are NOT a newbie anymore, for you did search a lot and didn't sound like a newbie at all by the tests you presented us.:)

Sigmatador
23rd May 2003, 09:38
Can you try to compare the PSNR in YUY2 with compare() fonction of avisynth (don't forget de 1 frame shift due to the bframes)

Koepi
23rd May 2003, 10:21
The higher PSNR in the 3div and divx decoder derive from the non-stoppable post processing. *hint*
Thanks a lot for this test, i never was sure if post processing does mathematically increase or decrease PSNR. Now we know for sure.

Regards
Koepi

shitowax
23rd May 2003, 11:28
I've got some remarks:

- This psnr4avi tool seems to use the vfw API and ask for RGB32 frames before converting them to YV12 and computes the PSNR ... What it simply shows is that the RGB32 output of xvid is fast but very bad quality ...
- the 3ivx DS decoder has deactivable post-processing and anyway, they are not used in the VfW codec ...
- this PSNR tool is cool but using RGB32 simply sucks ...
- I think postprocessed frames would get lower PSNR even if they would look better

just my two cents ;)

Koepi
23rd May 2003, 11:35
Hm. RGB32. On an MMX machine. With XviD's YV12-2-RGB-MMX bug (yellow line on the left). Hmmmm.

Just another 2 cents. Are we getting rich yet? ;)

Regards
Koepi

V-tec
23rd May 2003, 14:55
Hi All!

following my tests with psnr4avi, I have noticed some things:

- If I use Xvid Decoder (Nic version 30.03) for Xvid encodings, I obtain a videos with PSNR around to 45 - 46 with Q2 quantizer.

- If I Use Divx decoder (5.0.5) for Xvid encodings, I obtain a videos with PSNR around to 40 - 41 with Q2 quantizer

in opposition of this,

- If I Use Divx decoder (5.0.5) for Divx encodings, I obtain a videos with PSNR around to 45 - 46 with Q2 quantizer

- If I use Xvid Decoder (Nic version 30.03) for Divx encodings, I obtain a videos with PSNR around to 40 - 41 with Q2 quantizer.

Someone have noticed the same?

Matthaeus
25th May 2003, 01:59
@cipher:

Matthaeus, could you explain more how you calculate PSNR among different decoders using PSNR4Avi?

It's simple. Just change the FourCC code with Nic's AviC program to another value. I have changed the FourCC Description Code too because VFW looks for this first.

@all:

Here comes another test between encodings with different optimizations:

Source: 1000 frames @25 fps, RGB

1.) All CPU optimizations enabled (MMX, Int.SSE, 3dnow!, "3dnow! 2")
File size: 14,819,328
PSNR: 45.61

2.) Only MMX optimizations enabled
File size: 14,819,328
PSNR: 45.61

Note: File size and PSNR are equivalent with the 1st test values, so Int.SSE, 3dnow! and "3dnow! 2" only affects encoding speed.

3.) All optimizations disabled
File size: 14,833,664
PSNR: 45.52

Note: Higher file size, lower PSNR, slower encoding.

Koepi
25th May 2003, 10:29
This thread is about DEcoders, not ENcoders.

(Anyways: It's strange that there is a PSNR difference between different processor extensions, this is alarming. )

That MMX/non-mmx statement of mine was meant for the xvid decoder btw., there is a VERY old and known bug in XviD Decoder which makes the leftmost line "yellow dotted" - it's an error in the mmx code - which will lead to lower PSNR of course.

I hope you get that hint now.

Regards
Koepi

mf
25th May 2003, 13:05
It used to be dotted, but somehow on the latest versions it's not anymore. Wonder how that'd come :).

Matthaeus
27th May 2003, 02:32
@Koepi:

Ok, I understand. btw. Is there any way to disable CPU optimizations for the decoder, and force the codec to use plain C code?

Matthaeus
28th May 2003, 01:59
Phew! I have finally find out how to disable the optimized YV12->RGB conversions: just comment the following lines in xvid.c:
yv12_to_rgb24 = yv12_to_rgb24_mmx;
yv12_to_rgb32 = yv12_to_rgb32_mmx;

and recompile the core library. Watch the difference!

Decoder: XviD, MMX colorspace conversion
Average PSNR (Y U V): 41.57, 47.98, 47.88
Total Average PSNR: 45.81

Decoder: XviD recompiled, non-MMX colorspace conversion
Average PSNR (Y U V): 42.84, 48.15, 47.90
Total Average PSNR: 46.29 (!)

Decoder: 3ivx
Average PSNR (Y U V): 42.92, 48.15, 47.88
Total Average PSNR: 46.32

Decoder: DivX 5
Average PSNR (Y U V): 44.05, 48.21, 48.22
Total Average PSNR: 46.83 (?)

Note: With my MinGW I could compile the 0.9.1 sources only, newer XviD builds may give better results.
I don't know why, but Divx decoder seems to be the best. With the refecence iDCT (floating point!) of ffdshow I got lower psnr (and about equivalent with 3ivx and XviD)! I suspect that PSNR4AVI's RGB->YUV conversion uses the same (or nearly the same) colorspace conversion matrix as the Divx YV12->RGB, so probably XviD decodes the frame correctly to RGB (after a small modification in the source, of course) but PSNR4AVI converts it back to YUV with a different matrix. That's why the huge (~ -0.5db) difference appears in psnr.
So do not use PSNR4AVI to compare divx and xvid encoded files!

Lobuz
28th May 2003, 02:38
I don't know if it's the same bug but with xvid decoder there is a little green halo at left side of the objects especially faces. When I set YUY2 output in nic's decoder it disappeare. It's the same with ffdshow yv12 and Divx yuv extended mode. I can fix it by setting luma offset +2 or chroma offset -2 in ffdshow.
Anyway it looks like the bug in the GeForce2Pro or in the Detonators. Has someone similar problem? Could it be fixed globally?

Regards
Lobuz

Matthaeus
28th May 2003, 03:07
It's not a codec-specific bug. Your video card probably not supports YV12 properly. Try installing a newer video card driver or DirectX.