View Single Post
Old 30th October 2003, 01:38   #1  |  Link
karl_lillevold
Moderator
 
karl_lillevold's Avatar
 
Join Date: Oct 2002
Location: Seattle
Posts: 1,584
RV9 2-pass VBR improvements

NOTE: this improvement now superseeded by a completely re-written rate control. Please see RealVideo 10 'Elysian'

RV9 2-pass VBR rate control improvements
Download this erv4.dll [10/29/03] and copy to 'codecs' folder in producer's directory. The new DLL version information should read: "RV 9 EHQ+xVBR". Remember to back up existing erv4.dll. You don't have to do anything else, the new rate control is default in this DLL, just encode with 2-pass VBR with the settings you used before. Below is a detailed explanation of the changes.

New features:
More variable VBR : takes better advantage of gathered information from 1st pass, to let the codec spend more bits in high action scenes. See this comparison (750 kbps, cropped).

This includes better use of Max Startup Latency setting. MSL is still limited to 60 seconds, but this was not utilized well before.

TIP : Note that the maxBitrate parameter does not actually limit max bitrate (it never did, other problems, now fixed, were limiting factors). However, maxBitrate affects how constant the quality turns out, since the VBR does its calculations within a window with a length given as 2 * MSL * maxBitrate/avgBitrate. So, in order to get an even more constant quality throughout the clip than this new rate control now offers, choose a large maxBitrate, for instance 8X avgBitrate. See this plot for the effect on a 25 minute clip with more high action in the first half than the second half. With 8X you see how the maxSuggestedQP and minSuggestedQP are more constant than for 2X.

In light of this improvement, it may be a good idea to change maxBitrate from 2.1X avgBitrate (my previous advice) to a higher number, maybe as high as 4-5X average.

To encode with the old rate control, you have to switch DLLs back to the old version.

Especially for short clips, if you find that the resulting filesize is larger than the target filesize, try to reduce MSL from 60 seconds to a smaller number.

Better automatic selection of number of B frames in 2nd pass : For 2-pass encodes previously, 3 B frames were almost always used, even for very high action, where 1 would have been much more appropriate.

Separable 2-pass encoding : It is now possible to encode 1st and 2nd pass separately. Here is how:

1st pass:
Encode with the following line in <codecProperties> in your audience:
Code:
<codecProperties type="bag">
    <firstPassFile type="string">MyAnalysisFile.rva</firstPassFile>
</codecProperties>
Use extension .rva for the filename. Run producer in normal 2-pass mode. Now you can CTRL-C out of the 2nd pass, or let it finish normally. In any case, you can then view MyAnalysisFile.rva in the current directory, and potentially edit it. Currently I would suggest only to touch MinSuggestedQP, MaxSuggestedQP, and NumBFrames, or just view the file out of curiosity. I have not tested any changes to this file, so anything may happen. The same applies if you change any other settings between the two passes, for instance pre-filters or bitrates.

If you do not set a filename, with this special DLL, the analysis file will always be preserved. The default filename is ENCsomerandomstring.rva. This can be renamed and/or used for the 2nd pass as well, even if you did not specify a FirstPassFile option. This possibility will not exist in production build codecs, where the FirstPassFile option will be required to preserve the analysis file.

2nd pass re-start or re-encode:
Put the following in <codecProperties> in your audience:
Code:
<codecProperties type="bag">
    <secondPassFile type="string">MyAnalysisFile.rva</secondPassFile>
</codecProperties>
and encode with the '-dt' option to disable 2-pass. Include filename extension .rva. If you do not add the -dt option, producer will run two passes as it normally would, but with a wasted 1st pass. The reason this is necessary, is that this separable encoding mechanism is implemented in the codec itself, without producer knowing about it

HFEnhance : this is just a minor encoder improvement in preserving high frequency spatial information. It is not very visible, but is the new default. The main improvement is the 2-pass rate control above. HFEnhance can be disabled with the regkey NoHFEnhance=1 in the standard location:

[HKEY_LOCAL_MACHINE\SOFTWARE\RealNetworks\RV9]
"NoHFEnhance"=dword:00000001


This DLL also fixes the patternAdaptivity 2nd pass bug.


A special thanks to Ramirez and CruNcher for providing compelling demonstrations of how RV9 did not spend enough bits in high action scenes, when the content is mixed low and high action, and to D-C for his RMVB bitrate analysis tool. Please use this to see how bits are spent.

Now it is up to you to provide some feedback. I am sure more improvements can be made, but my tests so far have been promising. This however, does not by any means guarantee it will work for you.
__________________
This information is provided "AS IS" with no warranties, grants no rights, and reflects my personal opinion.

Last edited by karl_lillevold; 21st February 2004 at 17:42.
karl_lillevold is offline   Reply With Quote