[MPlayer-users] Re: Constant Visual Quality

D Richard Felker III dalias at aerifal.cx
Thu Dec 12 07:54:02 CET 2002


On Wed, Dec 11, 2002 at 11:43:17PM -0600, Angel wrote:
> [Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
> > Yeah. Turning up scplx_mask, tcplx_mask, dark_mask, and lumi_mask,
> > then using constant naq and vqscale=N (where N is somewhere between 3
> > and 5) would probably produce very good results. Another way to
> > achieve "constant quality" is with vqcomp=1 and a specified bitrate,
> > although you probably need to do a two-pass code for it to come out
> > great... Personally I like the adaptive quantization method;
> 
> Two questions:
> 	If you specify a vqscale and you enable naq.. this will allow the quantizer 
> to vary?
> 
> 	What values would you recommend for the scplx_mask, tcplx_mask, dark_mask, 
> and lumi_mask?

OK, a quick explanation. The quantizer you set with vqscale=N is the
per-frame quantizer parameter (aka qp). However, with mpeg4 it's
allowed (and recommended!) for the encoder to vary the quantizer on a
per-macroblock (mb) basis (as I understand it, macroblocks are 16x16
regions composed of 4 8x8 luma blocks and 2 8x8 chroma blocks, u and
v). To do this, lavc scores each mb with a complexity value and
weights the quantizer accordingly. However, you can control this
behavior somewhat with scplx_mask, tcplx_mask, dark_mask, and
lumi_mask.

scplx_mask -- raise quantizer on mb's with lots of spacial complexity.
Spacial complexity is measured by variance of the texture (this is
just the actual image for I blocks and the difference from the
previous coded frame for P blocks).

tcplx_mask -- raise quantizer on mb's with lots of temporal
complexity. Temporal complexity is measured according to motion
vectors.

dark_mask -- raise quantizer on very dark mb's.

lumi_mask -- raise quantizer on very bright mb's.

Somewhere around 0-0.15 is a safe range for these values, IMHO. You
might try as high as 0.25 or 0.3. You should probably never go over
0.5 or so.

Now, about naq. When you adjust the quantizers on a per-mb basis like
this (called adaptive quantization), you might decrease or (more
likely) increase the average quantizer used, so that it no longer
matches the requested average quantizer (qp) for the frame. This will
result in weird things happening with the bitrate, at least from my
experience. What naq does is "normalize adaptive quantization". That
is, after the above masking parameters are applied on a per-mb basis,
the quantizers of all the blocks are rescaled so that the average
stays fixed at the desired qp.

So, if I used vqscale=4 with naq and fairly large values for the
masking parameters, I might be likely to see lots of frames using
qscale 2,3,4,5,6,7 across different macroblocks as needed, but with
the average sticking around 4. However, I haven't actually tested such
a setup yet, so it's just speculation right now.

Have fun playing around with it.

Rich







More information about the MPlayer-users mailing list