[XviD-devel] 2pass credits

suxen_drol suxen_drol at hotmail.com
Fri Apr 11 23:19:14 CEST 2003


On Thu, 10 Apr 2003 21:42:08 +1000 suxen_drol <suxen_drol at hotmail.com> wrote:
> hi,
> 
> anyone got anyideas what to do with credits in 2pass?
> my ideas are pretty lame,

i have had another idea...

when encoding, there really is only two classes of rate control: single
pass and two-pass.
* single pass involes using fixed quantizer or cbrs.
* two-pass involves using fixed quantizer or average bitrate.

so we can simply the number of rate control plugins to:
xvid_plugin_single	(a combination of existing fixed and cbr plugins)
xvid_plugin_2pass1
xvid_plugin_2pass2

now, its often desirable to specify different rate parameters during for
various setions within an encoding. the parameters are either quantizer,
or bitrate. this can be described using the section_t structure.

typedef struct {
    int frames;	/* number of frames */
    int param;	/* quantizer/bitrate 
			if <0, |param| specifies quantizer
			if >0, param  specifies bitrate in kbps
			if==0, param specifies use external ratecontrol*/
} section_t;

each of the rate control plugins will accepts an array of section_t
structs (in addtion to thr existing configuation fields). each section_t
species what bitrate/quantization is used for nframes.

for example, if i wanted to encode the first 2000 frames at quantizer 5
and the next 4000 frames at 700 kbps, the array would look like:
section[0].frames=2000; section[0].param=-5
section[1].frames=4000; section[2].param=700;

if this array is fed into xvid_plugin_sigle, the algo will encoding with
quantizer 5 and then cbr 700.

if this array is fed into xvid_plugin_2pass1, the first 2000 frames will
be encoded at quant=5, the reamainder will be encoded at quant=2 (for
later scaling).

if this array is fed into xvid_plugin_2pass2, the scaling algo will know
the precise size of the initial fixed quant frames, and scale the curve
optimally for the remainder of the video sequence. if
section[x].param==0, the extenal scaled values from the stats file are
used.

the size of the section_t array can be as big or small as the user
wishes. therefore it enables not just credits encoding, but better
encoding control. e.g. manual assignment high bitrates to high action
scenes.

anyway, within the video-for-windows gui, i think it would look like
this:

+---------------------------------------+
|                                       |
| Profile         [AS at L1        ] [..]  |
| RC mode:        [Two pass     ] [..]  |
|                                       |
| rate control specifer:                |
| --frames-----kbps(q)------overides-AA |
| | 2000         (5)          +G     || |
| | 4000         7000                || |
| |                                  || |
| |                                  || |
| -----------------------------------VV |
| [Add]          [Edit]       [Remove]  |
|                                       |
|          [ Advanced... ]              |
|          [Load defaults]              |
|          [    OK       ]              |
+---------------------------------------+

sections are displayed in a list control.
	the add button will add an extra rate section,
	remove button will remove a section, 
	edit will popup an edit dialog.
	we can also add UP/DOWN ordering buttons.

the edit box will look something like:

+---------------------------------------+
|                                       |
|  number of frames  [       ]          |
|                                       |
|---overides----------------------------+
|                                       |
|  [X]  Greyscale                       |
|  [X]  Chroma optimzer                 |
|                                       |
|          [    OK       ]              |
|                                       |
+---------------------------------------+

overrides checkboxes have three states:
    checked:	enable the option for this section
    unchecked:	disable the option for this section
    greyed:	use the global/default option

depdning on how useful this is to everyone:
we could team up with the vdubmod chaps and extend the VFW API slighly,
so xvid knows the current frame number displayed within the vdub editor.
this would let users find the start/end frames of high-action scene
within vdub, and then press a button within xvid configuation to add a
new bitrate section automatically.

-- pete




More information about the XviD-devel mailing list