[FFmpeg-devel] [PATCH] RoQ video encoder

Michael Niedermayer michaelni
Sat Jun 2 01:29:41 CEST 2007


On Fri, Jun 01, 2007 at 06:07:26PM -0400, Eric Lasota wrote:
> Michael Niedermayer wrote:
>  > the encoder is scary ...
> First video encoder I ever wrote.  Over 2 years ago.  :P
>  > ignoring the codebook generation the optimal solution is to iterate
>  > over all possible encodings and choose the one with the lowest
>  > rate distortion, that is distortion + lambda*bits (lambda is a constant
>  > for the whole frame or movie which can be used to tune quality vs. 
> bitrate,
>  > distortion is the sum of squared differences or something like that)
> The result would be the same.  Lambda represents the amount of error 
> that the
> encoder is willing to exchange for one bit, so you could say the reducer
> defines lambda as the lowest number that will cause a reduction, a 
> number that
> will increase every iteration until the target is met, starting at zero.

it may or may not end up the same as your sorting code, i dont know ...

but a single pass over the possibilities, with no sorting, no lists, ...
beats your code by a quite large amount in terms of simplicity

its just
for all macroblocks in the image{
    for all possible encodinds of the current macroblock{
        find distortion
        find number of bits needed
        if(distortion + lambda*bits < best){
            best= distortion + lambda*bits
            best_choice is current possibility
    encode as best_choice

and if you like you can then do some ratecontrol by vary the lambda value

trying to encode each frame to a fixed number of bits will just look bad
so theres no real sense in supporting that unless you have some max bitrate
constraint ...

>  > do you also have a video which shows artifacts due to the YV12 instead of
>  > RGB ?
> I still need to reinstall Cygwin and test it with FFMPEG, but this should
> break it.  Red box scrolling one pixel to the left for half a second.  Works
> fine with Q3, should smear with subsampled chroma.
> http://icculus.org/~riot/redbox.bz2

i can confirm that it doesnt look good with ffmpeg, didnt try Q3 as i dont
have that installed

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070602/7c62a1a1/attachment.pgp>

More information about the ffmpeg-devel mailing list