PDA

View Full Version : I P B and Quant, what do I do with them?


Bassphine
19th December 2005, 05:48
O.k. so I've been here looking up information on these I/P/B frames and Quants, but I have yet to find an explanation that satisfys me on how they work together. I get it that the higher the quant is the more quality and the higher the bitrate is, and that I-Intra and P-Predicted and B-Bidirectional are different kinds of frames. However I keep seeing threads saying this and that about them and no one seems to have a consistant idea of what they do with each other, or maybe I'm just reading the threads wrong.
So my question is what do I do with them? This question is aimed at Koepi, Nic, or anyone who actually works with xvid code and knows exactly what these functions are supposed to do.

Also as a side question what is the latest build for xvid? I've heard some rumors of a 1.3 build on another site, is this true? If so or not where can I download the latest builds, betas and releases?

Bassphine
19th December 2005, 06:42
O.K. so from my experience (watching and analyzing the status box and what I've read here) this is what I know about I/P/B and Quant.

Frames
I-VOP Intra frame / Index frame
P-VOP Predictable frame / No motion frame
B-VOP Bidirectional frame / Motion frame

Quant
Min=1 Best Quality / Largest file size
Max=31 Worst Quality / Smallest file size

Distribution of Frames to Quants

I-VOP frames recieve the largest Avg Quant/Bitrate but there are very few of these as they are added only by the keyframe rate or when a scene changes enough that one is required

P-VOP frames Avg in the middle of the Quant/Bitrate range, these frames can peak at better quality then I-VOP frames but never go below B-VOP frames. P-VOP is also the "bread and butter" of the encoding process usually averging 80% or better of the size of the file, while also averaging only 50%-60% of the frames invloved.

B-VOP frames recieve the least Avg Quant/Bitrate and make up the bulk of frames encoded, but usually use only 25% of the bitrate in comparison to P-VOP.


How would I go about using this information to make decisions involving settings and so forth in order to get files of various quality, sizes, and bitrates? What are known no-nos when adjusting these, or known increases, decreases that can be proactive?
These settings have the most power over quality, yet there seems to be little explanation of their relationships with each other.

sysKin
19th December 2005, 07:44
Explaination here: http://forum.doom9.org/showthread.php?s=&threadid=19436

Bottom line: if you don't know what they are then you most likely can't use this information anyway.

Bassphine
19th December 2005, 08:46
Hmm from reading that thread I gather in laymens terms it's rather like this, I-VOP's are the foundation P-VOP's are the bricks and B-VOP's are the mortar. Meaning that you need to lay the foundation for a frame with the I-VOP, then lay out the P-VOP's for strength and finally pad the P-VOP's with B-VOP's for quality/motion control. Does that sound about right for an anology?
However this only tells me that I need all three VOP's to properly control frame quality and using the Quant to leverage that quality independently with each type of VOP throughout a frame reference.
Maybe I'm getting way too complicated on this matter. I just want to know how I go about properly using/adjusting I/P/B and Quant settings with the encoder. Like what are the basic rules of thumb, and if I adjust one item should I be adjusting another to maintain quality akin to an equalizer?

Bassphine

Teegedeck
19th December 2005, 17:23
My hint: Just leave the settings alone.

I'm afraid the topic is quite complicated and cannot really be simplified by means of an analogy. And in AVC it gets even more complex...

My go at saying it in a simple manner: All frames are predicted from other frames; except for i-frames. p-frames can also be predicted from another, immediately preceding p-frame. b-frames are predicted from a preceding and a following p- or i-frame. The difference between frames makes for the decision whether it is more efficient to code it as an i-, p- or b-frame. A very huge difference would usually trigger an i-frame, a very slight difference a b-frame and an intermediate one a p-frame. For prediction you need motion-estimation. The better the motion-estimation, the better the quality of the predicted frame (and the video you get in the end). Quantizers simplify actual data (kill details). The higher the quantizer, the worse the quality, the smaller the file. That perhaps simplifies the concept quite dangerously but so there.

You need to do NOTHING about quantizers; if you want to improve quality without improving filesize just select the highest-quality motion estimation, highest VHQ, Trellis, QuarterPixel, maybe even GMC, and AQ if you do two-pass encoding.

If filesize is no issue, encode a constant quantizer =2 and use a high-bitrate custom quantization matrix, like Didée's SixOfNine or Sharktooth's UHR.

Bassphine
19th December 2005, 19:54
Thanks for the info, I'll try the constant quant of 2 and the sixofnine matrix.
Is it also fair to say that if using a constant quant of 2 and all the motion estimation settings turned on/highest that I am recieving the best the codec has to offer? What about using a constant quant of 1? What will that do? I've heard some people say that Q2 is better then Q1 because Q1 just wasts bitrate at that high of a setting, is this true?
Also there is a setting to adjust B-VOP; #of B-VOP's and a Q-ratio system, it's currently set at #of@3 / 1.5 / 1.0, going from top to bottom. Is there an optimum setting or sweetspot for this?
I'm trying to get the best quality for a 2-CD backup of 'The Punisher' 2005 remake.
Currently I'm using the suggestings that Teegedeck recomended, encoding at a constant Q2 rate. Acording to XviD Stats window this gives me I@Q2,P@Q2, and B@Q4. Should B be at Q4? However it is now 60% complete and the VDubMod Status window indicates that the file will be around 1100-1200MB is size, is this normal? shouldn't it be a really large/huge file like 2+gigs or something?
The very worst part of this movie (from other trys at encoding) is at the begining when there is the comic book flip through of Punisher comics with the Marvel logo fly through. This has got to be the worst compressible scene that I've ever seen. I've done about 27 movies now in my collection so that I can just run them from my computer to the DProjector@ 102'', all of them @ 2-CD's or 3/6 movies per DVD5/DVD9 depending on which I have on hand.
Does anyone else have this movie? If so could you take a look at this particular scene and tell me what you think? I've read Doom9's codec comparisons for this year which is why I'm using the XviD codec and XviD does seem better then the others that I've tried. In his comparisons he used the Matrix, in particular the high motion weapons scene and lobby scene and they looked to compress decently enough. However I think this Punisher scene is even more complex maybe?
Doom9 if you read this, do you think it's possible to add this as a clip or movie to see how codecs stand up to it? Seems to me that the start of this movie is a great clip to challange the high motion ability to encode. The scene directly after is a B+W intro with prettymuch low motion that crossfades into color with virtually no motion of a bay and city sky line. This crossfade also seems to not compress well, the cloud areas blur uncontrollably, and the city sky line becomes all macro-blocky. As a bonus there's even a fireball scene at the end that is the same if not better then the one in the matrix. ;-)
Anyway this is the first movie that I've really had any problems with the others all went pretty smooth, then again those were drama and horror so lots of slow scenes and not very many fast ones.
P.S. I've been doing these as 2 pass with the bitrate set for 2-CD's and at full resolution so for Punisher with an AR of 2.35 it is 852x360 or 848x368 after resizing to adjusting for parts of the picture cropped during the letterbox cropping and maintaining mpeg4 16x16 compliance.

Bassphine

Teegedeck
19th December 2005, 21:03
Is it also fair to say that if using a constant quant of 2 and all the motion estimation settings turned on/highest that I am recieving the best the codec has to offer? What about using a constant quant of 1? What will that do? I've heard some people say that Q2 is better then Q1 because Q1 just wasts bitrate at that high of a setting, is this true?Yes, this is true. Several times the filesize of quant=2 but not much visible gain in quality. The way to raise quality and bitrate is to use high-bitrate matrices with lower coefficients, not to use quant=1.
Also there is a setting to adjust B-VOP; #of B-VOP's and a Q-ratio system, it's currently set at #of@3 / 1.5 / 1.0, going from top to bottom. Is there an optimum setting or sweetspot for this?Well, Didée's settings of 2/1.63/0 leads to a more lenient treatment of b-frames. It gets you very high-quality encodings at high bitrates (at p-frame quant=2 you get b-frame-quant=3) and still reasonably good compression at more 'normal' bitrates. I've been using that for the latter half of the year and I like it.
I'm trying to get the best quality for a 2-CD backup of 'The Punisher' 2005 remake.
Currently I'm using the suggestings that Teegedeck recomended, encoding at a constant Q2 rate. Acording to XviD Stats window this gives me I@Q2,P@Q2, and B@Q4. Should B be at Q4?See above.
However it is now 60% complete and the VDubMod Status window indicates that the file will be around 1100-1200MB is size, is this normal? shouldn't it be a really large/huge file like 2+gigs or something?With SixOfNine at quant=2 I'd rather expect something like 3-4 Gigs (at full resolution though). Are you sure you're using that matrix?
P.S. I've been doing these as 2 pass with the bitrate set for 2-CD's and at full resolution so for Punisher with an AR of 2.35 it is 852x360 or 848x368 after resizing to adjusting for parts of the picture cropped during the letterbox cropping and maintaining mpeg4 16x16 compliance.Throw out any noise-filters and resizers you use; only crop away black barrs but maintain a compliant resolution. That should do the trick. Though I don't know 'The Punisher'.

If that's not enough to get a really BIG file at quant=2 use Sharktooth's EQM V3UHR matrix.

Bassphine
19th December 2005, 22:33
With SixOfNine at quant=2 I'd rather expect something like 3-4 Gigs (at full resolution though). Are you sure you're using that matrix?

Yes, I'm using the 6of9 filter.

Well, Didée's settings of 2/1.63/0 leads to a more lenient treatment of b-frames. It gets you very high-quality encodings at high bitrates (at p-frame quant=2 you get b-frame-quant=3) and still reasonably good compression at more 'normal' bitrates. I've been using that for the latter half of the year and I like it.

I went and manually changed the B-VOP settings to 2/1.63/0 and this seems to have changed it to 3 in the status window.

Throw out any noise-filters and resizers you use; only crop away black barrs but maintain a compliant resolution. That should do the trick. Though I don't know 'The Punisher'.

I'm not using any noise filters that I know of unless xvid auto does it.
I have to resize, otherwise the image would be squished. In resizing I always like to keep the maximum allowed resolution and for a 720x480 framed DVD image with 2.35 AR it's 852x360.
Heres the formula as I understand it.

Using the DAR (Display Aspect Ratio) [which is a flag used by DVD's to tell players how to display an image] 4:3 standard tv is 1.33 and for widescreen 1.78.
->Please note that all numbers are rounded to the nearest number that is divisible by 4<-

Taking the vertical resolution of 480 multiply that by 1.78 for the widescreen DAR and you get 852 (854.4 rounded) this is the DAR that stretches the video to it's max horizontal resolution to create a visually correct movie.
Now take 852 and divide that by the correct widescreen AR 2.35 and we get 360 (362.55319 rounded) this is the correct vertical resolution of the movie minus the black bars which must be cropped out to get to that resolution.

All DVD's are 852 wide compressed to 720 so the correct full frame sizes for a few of the most common widescreen formats are as follows
480x1.78=852 divided by
2.35 = 360
2.20 = 388
1.85 = 460
1.78 = 480

If a widescreen movie is placed with a 4:3 flag 1.33 then these would be correct.
480x1.333=640 divided by
2.35 = 272
2.20 = 292
1.85 = 344
1.78 = 360
1.33 = 480

O.k. so thats off topic and over explained :-) but these are the correct frame sizes people should be using if they claim full frame size encoding.

If that's not enough to get a really BIG file at quant=2 use Sharktooth's EQM V3UHR matrix.

The goal was never to have a really BIG file cause I want to fit it onto 2-CD's 1.4 gigs, it was just that with those settings I had the expectations that it would be huge, but it came out undersized by nearly 400MB. However now that I changed the B-VOP's manually the size seems to have fattened up a bit hovering around an avg. of 1.5 gigs (still encoding). If this comes out like the last encode then I guess this movie is highly compressable -> file size, but not very compressable -> visual quality. Which bugs me cause there is room to grow in the file size to add quality but xvid is refusing to do so no matter what I seem to tell it to do. *Frustrated* lol

Anyways if Doom9 here wants to add that full frame info to the aspect ratios explained section he can. Or he can request a full explanation and I'll see what I can do to oblige :-)
Damn I need to learn how to write shorter Replys. lol

Bassphine