[x264-devel] Re: bit allocation algorithms among frames

Tuukka Toivonen tuukkat at ee.oulu.fi
Wed Aug 30 17:56:44 CEST 2006


On Sun, 23 Jul 2006, Loren Merritt wrote:

> I don't know either why sdrc gets worse with higher initial quants, nor why the
> local search ended up better yet.

Looks like it happens very often especially at larger QPs, that either
rate or distortion is not monotonic, but goes to unexpected direction, and
in those cases your perl code
http://students.washington.edu/lorenm/src/x264/x264_sdrc.0.pl
sets $dDdRs[$f] = 0 and the QP will be then fixed forever.

I don't know why it took so long from me to fix it, but this new version 
appears to work finally, at least with the few cases I've tested it with:

http://www.ee.oulu.fi/%7Etuukkat/tmp/sd/x264_sdrc_orig.0.pl

Usage is pretty much same as before, although it is pretty much rewritten. 
New arguments are: -i xx (set initial QP for frames) and -s xx (QP step 
size).

Here are couple of example test case:

-----1----- (2 B-frames)

SDRC:

* version      : x264_sdrc_orig.0.pl 20060829-1
* search_after : 0
* search_before: 0
* reset_rate   : 0
* bitrate      : 5000
* initial qp   : 50
* qp step size : 1
* exe          : ./x264 --fps 25 -o /dev/null 
/video/std-video/football-352x240.yuv --frames 28 --no-b-adapt --scenecut 
-1 -m3 -8 --ipratio 1 --pbratio 1 -b2
...
Rtot   863.200 (=bitrate)
Dtot   31.1471 (=PSNR at the rate)
...
Rtot   866.564
Dtot   31.1650

X264RC:
./x264 --fps 25 -o /dev/null /video/std-video/football-352x240.yuv --frames 
28 --no-b-adapt --scenecut -1 -m3 -8 -b2 -B 500
x264 [info]: PSNR Mean Y:29.367 U:35.027 V:36.905 Avg:30.633
Global:29.283 kb/s:865.69
encoded 28 frames, 60.82 fps, 864.81 kb/s

--> We get 1.9 dB increase from SDRC

-----2----- (no B-frames)

SDRC:

* version      : x264_sdrc_orig.0.pl 20060829-1
* search_after : 0
* search_before: 0
* reset_rate   : 0
* bitrate      : 5000
* initial qp   : 50
* qp step size : 1
* exe          : ./x264 --fps 25 -o /dev/null 
/video/std-video/football-352x240.yuv --frames 28 --no-b-adapt --scenecut 
-1 -m3 -8 --ipratio 1 --pbratio 1 -b0
...
Rtot   690.821
Dtot   30.2515

X264RC:

./x264 --fps 25 -o /dev/null /video/std-video/football-352x240.yuv --frames 
28 --no-b-adapt --scenecut -1 -m3 -8 -B 500 -v -b0
x264 [info]: PSNR Mean Y:28.648 U:34.539 V:36.468 Avg:29.952
Global:29.238 kb/s:692.59
encoded 28 frames, 22.74 fps, 691.71 kb/s

--> We get 1.0 dB increase from SDRC

-----3----- (SDRC with various parameters)

Below IPP, III, and IPB denote the frame formats,
-aX- means that x264_sdrc_orig was run with options -aX -bX
and -sX means options -sX (QP step size).

Because -aX -bX approximates dRdD, the target bitrate is occasionally
exceeded.

For exact options used for each case, see my test script:
http://www.ee.oulu.fi/%7Etuukkat/tmp/sd/runtest.sh

football-ipp-a0-s5.log:final: 695460/700000, psnr=42.2994, encodes=5226
football-ipp-a5-s5.log:final: 707582/700000, psnr=42.4340, encodes=2043
football-ipp-a2-s5.log:final: 707462/700000, psnr=42.4346, encodes=1138
football-ipp-a0-s8.log:final: 687871/700000, psnr=42.4473, encodes=3279
football-ipp-a0-s3.log:final: 698287/700000, psnr=42.5814, encodes=8780
football-ipp-a0-s1.log:final: 698958/700000, psnr=42.6274, encodes=28662
football-ipp-a2-s1.log:final: 700836/700000, psnr=42.6383, encodes=5886
football-ipp-a5-s1.log:final: 701501/700000, psnr=42.6658, encodes=10648

football-iii-a0-s8.log:final: 693108/700000, psnr=38.0732, encodes=2670
football-iii-a0-s5.log:final: 698545/700000, psnr=38.7406, encodes=4260
football-iii-a5-s5.log:final: 709866/700000, psnr=38.8518, encodes=1657
football-iii-a2-s5.log:final: 709866/700000, psnr=38.8518, encodes=921
football-iii-a0-s3.log:final: 699164/700000, psnr=38.9237, encodes=7144
football-iii-a0-s1.log:final: 698074/700000, psnr=39.0365, encodes=21433
football-iii-a2-s1.log:final: 700232/700000, psnr=39.0655, encodes=4578
football-iii-a5-s1.log:final: 700232/700000, psnr=39.0655, encodes=8305

football-ipb-a0-s8.log:final: 690619/700000, psnr=42.2587, encodes=3234
football-ipb-a0-s5.log:final: 695906/700000, psnr=42.4489, encodes=5222
football-ipb-a0-s3.log:final: 693811/700000, psnr=42.5151, encodes=8690
football-ipb-a2-s5.log:final: 708781/700000, psnr=42.5780, encodes=1135
football-ipb-a0-s1.log:final: 699793/700000, psnr=42.6626, encodes=26725
football-ipb-a2-s1.log:final: 701840/700000, psnr=42.6833, encodes=5642

-----4----- (other test cases)

Here: http://www.ee.oulu.fi/~tuukkat/tmp/sd/
are some more test cases. I used x264_sdrc_orig.0.pl 
to generate test results and then logmov.sh 
to generate the *.png and *.avi files from the numerical results.
(sorry, it requires Matlab, had trouble with Octave)

For example
http://www.ee.oulu.fi/%7Etuukkat/tmp/sd/football-ipp-a0-s1.log-MSEs.avi
displays animation of the SD algorithm, where the MSE from
each frame is plotted, using frame format IPP and argument -s1 to 
x264_sdrc_orig.0.pl.
(I recommend using avidemux to watch the file frame-by-frame)

http://www.ee.oulu.fi/%7Etuukkat/tmp/sd/football-ipp-a0-s3.log.png
is a single figure of the SD algorithm: here you can see as it
ascends from lower bit rates and qualities into higher ones.

Enjoy (sorry my lack of ability to write short and clear emails...)

-- 
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html



More information about the x264-devel mailing list