PDA

View Full Version : Modulated Quantization Type: Which type 1st pass...


Koepi
2nd August 2002, 20:04
Ahoy,

First I'm sorry to start a new thread with this, but I want to collect the data in this way I propose here and this wouldn't fit too well in the old thread which I therefore close now (sorry!).

Since we have no real statistical data but just some small test
clips made to decide to announce that using h263 quant type for the
1st pass when using modulated quantizer type in the 2nd pass, I
wanted to collect some data which can help us to give a more
transparent recommendation.

So this is a "real life" comparison for figuring out if MPEG quant
on 1st pass or h263 quant on 1st pass gives better results (in the
sense of a lower average quantizer) on the second pass, using modulated
quantization type.
Except for the quantizer type settings nothing was changed between
the encodings to produce a proper result.

Test was done with Rush Hour 2 R2 PAL DVD, which is extremely noisy in
some places.

The avisynth script:
LoadPlugin("D:\avisynth\mpeg2dec.dll")
LoadPlugin("D:\avisynth\SimpleResize.dll")
LoadPlugin("D:\VirtualDub-1_4_10\plugins\textsub.vdf")
mpeg2source("D:\movie.d2v")
Crop(4,78,712,424)
SimpleResize(704,304)
TextSub("D:\english-burn-in.srt")

Credits from frames 126.992-129.557 at 20% bitrate, not used for
the average quantizer as this doesn't matter for this comparison.

Results for this setup:

MPEG quant in first pass, filesize 1.598 MB,
heading for 642.000 KB (real: 642.340 KB):

[500] Quantizer distribution for 2nd pass:
[500] Q:2:137
[500] Q:3:20909
[500] Q:4:68763
[500] Q:5:30103
[500] Q:6:6398
[500] Q:7:505
[500] Q:8:160
[500] Q:9:17

Average quant: 4.1886

H263 quant in first pass, filesize 1.494 MB,
heading for 642.000 KB (real: 642.230 KB):

[500] Quantizer distribution for 2nd pass:
[500] Q:2:79
[500] Q:3:14515
[500] Q:4:80631
[500] Q:5:27470
[500] Q:6:3847
[500] Q:7:406
[500] Q:8:44

Average quant: 4.1499

In this case we have 7080 frames above quant 5 for using mpeg quant type in the first type, where we have 4297 frames in that range for using h263 quant type on first pass. Since those frames can be considered "ugly" there is my clear favorite h263 for the first pass. This isn't compensated by the more-often used quant 3 in mpeg, since those scenes take the "bad" quantisation very early after them, which destroys the overall flatness of the curve.
This is an extreme example, I know that.

If you would take the time to do your tests this way and post your
results here it would be very valuable to figure out the _real_
relation between 1st pass/2nd pass filesizes when using modulated quantizer
type. Ah, and further the noise in the source is important to mention, I
shouldn't forget to write that here as well.
Let's get some results! :)

Best regards,
Koepi

canadian_fbi
2nd August 2002, 20:14
alright, i'll set up a test for tonight and report back my findings tomorrow morning :)

Acaila
2nd August 2002, 20:31
@Koepi:

Unfortunately (for you :)) I don't have noisy sources, so I can only test this with clean DVD's. My theory is that whatever quant type is used most on the 2nd pass determines which one is best to use on the 1st pass. In that light, would you approve if I run my tests with a single source encoded to several different final sizes to reach different distributions?

Koepi
2nd August 2002, 21:01
Acaila,

I appreciate it, but "only one movie for all targets" is that what is biasing the results. We need much different footage (hence the classifications), so please, 1 movie with 2 2pass sessions only :)

I hope you understand me there!

EDIT: and sure, I know (and already approved [and wrote back then when I introduced mod. quant. type]) your theory about the second pass quantizer stuff. But what I think we should try is to find similarities to help us identifying "early" which quantizer type for the first pass is more ideal for which kind of movie.

Thanks a lot,

Best regards,
Koepi

Acaila
3rd August 2002, 10:49
Yes I understand why you want it like this, it's just that it takes a lot longer with different movies :D

Anyway, I've just finished 2 movies. The Matrix (196155 frames) and X-Men (150043 frames). Both R2 PAL DVD's. Both quite clean sources (if you're not too picky anyways :)). Target filesize for both was 625MB. No special credits compression.

Script
The Matrix
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\Mpeg2dec.dll")
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\SimpleResize.dll")

MPEG2source("D:\DivX Rip\DivX\The_Matrix\The_Matrix_32bit.d2v")
Crop(0,65,720,446)
SimpleResize(640,272)

X-Men
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\Mpeg2dec.dll")
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\SimpleResize.dll")

MPEG2source("D:\DivX Rip\DivX\X-Men\X-Men_32bit.d2v")
Crop(16,75,696,432)
SimpleResize(640,272)
Results
The Matrix
H.263 MPEG
Quant 2: 4898 Quant 2: 10880
Quant 3: 100387 Quant 3: 105504
Quant 4: 78391 Quant 4: 60297
Quant 5: 12121 Quant 5: 15800
Quant 6: 350 Quant 6: 3562
Quant 7: 8 Quant 7: 110
Quant 8: 2

Average: 3.50 3.47X-Men
H.263 MPEG
Quant 2: 13152 Quant 2: 23971
Quant 3: 89354 Quant 3: 84895
Quant 4: 39210 Quant 4: 28366
Quant 5: 8225 Quant 5: 6285
Quant 6: 100 Quant 6: 6327
Quant 7: 3 Quant 7: 196
Quant 8: 3

Average: 3.29 3.24

As these were two fairly easy movies, I'm repeating this with two movies >2 hours in duration. Hopefully I can get a much higher average quant on those so things should get more interesting.

Koepi wrote:
But what I think we should try is to find similarities to help us identifying "early" which quantizer type for the first pass is more ideal for which kind of movie.From my experience the 1st pass percentage is in (almost) linear relationship (correlation of -0,98) with the final 2nd pass average quant (at least for MPEG->Modulated and in the range of 60%-75%, I haven't tested this for any movies that fell outside this range). If we could determine the percentage range where MPEG is better and where H.263 is better then all you'd need is a compressibility test.
Unless this is all about the amount of noise instead of final average quant, which I'm not too sure of yet.

TripleA
3rd August 2002, 11:22
Test encode of Fight Club R1. Using Keopi's July 27th build. The August 1st build crashes on my machine @ ~100th frame, for some reason :-(

Crop (Left, Right, Top, Bottom): 1, 2, 58, 65

BiLinear resize to: 624x256

Target size: 663028KB
Credits @ const. quant. 20

H.263:

1st pass size (inc. credits): 988726KB

Quantizer distribution for 2nd pass:
Q:2:10813
Q:3:150486
Q:4:34248
Q:5:462
Q:6:6

Pre-credits overflow: -9147
Final overflow: -240763

Avg. Quant: 3.059

MPEG:

1st pass size (inc. credits): 1178988KB

Quantizer distribution for 2nd pass:
Q:2:20050
Q:3:144450
Q:4:30968
Q:5:540
Q:6:7

Pre-credits overflow: 2905
Final overflow: -5889

Avg. Quant: 2.997

Subjectively, I like the result of using MPEG for 1st pass. Smoother color gradients, if there's such a thing...

I hope this is enough info. and that it helps some. If more info is needed, just ask!

Koepi
3rd August 2002, 12:44
Thanks for the results, let them come! :)

I think I can verify that if the average quantizer on second pass is >3 (i.e. 3.2) MPEG starts to "break away" and use more quantisers >5, which is _bad_. Look at X-Men. I wouldn't vavor an encoding which has a lower average quantiser, but qual. 6, 7 and 8 used quite heavily while the 1st pass h263 pass hs just some handful of those frames...

But these are just first conclusion, the results don't necessarily mean anything like that, it's a simple observation.

I'm redoing the tests with my new build since I fell over some problems with EPZS motion estimation, maybe the results differ.

I'll keep you posted.

Regards,
Koepi

canadian_fbi
3rd August 2002, 17:44
then these results here would confirm your latest theory, koepi. galaxy quest R1 (pretty clean), august 1 build:

LoadPlugin("C:\Video\Tools\GORDIA~1\mpeg2dec.dll")
mpeg2source("C:\Video\DVD ripping\galaxy quest.d2v")
crop(8,56,706,362)
BicubicResize(592,256,0.333,0.333)

H.263 first pass:
--- movie quantizers ---
quant amount percentage
2 7191 5.13%
3 111634 79.62%
4 21274 15.17%
5 101 0.07%

average quant = 3.102

MPEG first pass:
--- movie quantizers ---
quant amount percentage
2 11107 7.92%
3 102381 73.02%
4 26107 18.62%
5 600 0.43%
6 5 0.00%

average quant = 3.116

H.263 gknot compressibility: 63.8% (.262/.410)
MPEG gknot compressibility: 57.3% (.262/.456)

i also did a rip of this movie earlier using only H.263 quant type (with the 7/27 build i think) and got an avg. quant of 3.034.

Acaila
3rd August 2002, 19:51
And here's two more:

Star Wars Episode I and Lost In Space. Both R2 PAL DVD's. Both also quite clean sources. Target filesize for both was 625MB. No special credits compression.

Script
Star Wars
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\Mpeg2dec.dll")
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\SimpleResize.dll")

MPEG2source("D:\DivX Rip\DivX\Star_Wars\Star_Wars_32bit.d2v")
Crop(13,69,696,438)
SimpleResize(640,272)

Lost In Space
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\Mpeg2dec.dll")
LoadPlugin("D:\DivX Rip\DivX Programs\Avisynth\SimpleResize.dll")

MPEG2source("D:\DivX Rip\DivX\Lost_In_Space\Lost_In_Space_32bit.d2v")
Crop(10,71,698,436)
SimpleResize(640,272)

Results
Star Wars
H.263 MPEG
Quant 2: 1239 Quant 2: 2517
Quant 3: 23941 Quant 3: 35162
Quant 4: 67556 Quant 4: 64501
Quant 5: 60083 Quant 5: 48647
Quant 6: 32973 Quant 6: 28746
Quant 7: 9018 Quant 7: 13610
Quant 8: 1207 Quant 8: 2717
Quant 9: 72 Quant 9: 177
Quant 10: 4 Quant 10: 15
Quant 11: 1

Average: 4.67 4.60Lost In Space
H.263 MPEG
Quant 2: 1411 Quant 2: 2009
Quant 3: 23452 Quant 3: 33849
Quant 4: 84015 Quant 4: 78325
Quant 5: 57410 Quant 5: 48347
Quant 6: 16651 Quant 6: 18618
Quant 7: 2884 Quant 7: 5155
Quant 8: 821 Quant 8: 714
Quant 9: 410 Quant 9: 166
Quant 10: 135 Quant 10: 46
Quant 11: 45 Quant 11: 21
Quant 12: 19 Quant 12: 3
Quant 13: 6 Quant 13: 4
Quant 14: 3 Quant 14: 3

Average: 4.42 4.36

I expected H.263 to give a lower average quant on these movies, but apparently MPEG does it again. However you can also clearly see the shift to higher quants on Star Wars here for MPEG.

Koepi
3rd August 2002, 20:40
I did RH2 again with PMVfast to see if the EPZS errors are really that huge.

Results for the new setup with PMVfast motion estimation:

MPEG quant in first pass, filesize 1.603 MB,
heading for 642.000 KB (real: 642.338 KB):

Quantizer distribution for 2nd pass:
[832] Q:2:138
[832] Q:3:20773
[832] Q:4:68520
[832] Q:5:30347
[832] Q:6:6543
[832] Q:7:492
[832] Q:8:163
[832] Q:9:16

Average quant: 4.1936

H263 quant in first pass, filesize 1.499 MB,
heading for 642.000 KB (real: 642.226 KB):

Quantizer distribution for 2nd pass:
[832] Q:2:79
[832] Q:3:14400
[832] Q:4:80172
[832] Q:5:27894
[832] Q:6:3992
[832] Q:7:408
[832] Q:8:47

Average quant: 4.1790

So I think I can use EPZS again, it _does_ a better job on compression (visual quality tends to more blockyness when using PMVfast!).

Regards,
Koepi

TripleA
3rd August 2002, 21:52
Another test. This time of Bring it On. Which's the toughest movie I ever tried to encode. This particular encode's source is an earlier HQ encode I did of the movie. By HQ I mean 4CDs @ 720x528. The original DVD was a 4:3 R2.

This time I'm using the August 1st build. The problem I had with that was pretty weird, but it's now solved and I don't think it was related to XviD.

BiLinear resize to: 480x352

Target size: 718340KB
Credits @ const. quant. 20

H.263:

1st pass size (inc. credits): 1848244KB

Quantizer distribution for 2nd pass:
Q:2:72
Q:3:7857
Q:4:62270
Q:5:50902
Q:6:13276
Q:7:413
Q:8:9

Final size: 717840KB

Avg. Quant: 4.31575

MPEG:

1st pass size (inc. credits): 1841471KB

Quantizer distribution for 2nd pass:
Q:2:85
Q:3:12715
Q:4:58239
Q:5:44590
Q:6:17800
Q:7:1335
Q:8:35

Final size: 718422KB

Avg. Quant: 4.32086

I like H.263 better on this one. So maybe it *is* a case of which-quantizer-will-be-used-more-in-2nd-pass...

...Which wouldn't be an easy question to answer, I believe, without at least 3 pass encodes... :-(

My 1.2GHz Morgan is fast, but not *that* fast.

Koepi
3rd August 2002, 22:09
Hey, I'm doing these tests on a duron700. Don't complain about your processor ;)

Regards,
Koepi