212f618373
This patch attempts to reduce the peak bitrate hit by the encoder when using small buffer windows. Tested on the CIF set over 200-500kbps using these settings: --buf-sz=500 --buf-initial-sz=250 --buf-optimal-sz=250 \ --undershoot-pct=100 Two pass encodes were tested at best quality. One pass encodes were tested only at realtime speed 4: --rt --cpu-used=-4 The peak datarate (over the specified 500ms window) was measured for each encode, and averaged together to get metric for "average peak," computed as SUM(peak)/SUM(target). This patch reduces the average peak datarate as follows: One pass: baseline: 1.29715 this patch: 1.23664 Two pass: baseline: 1.32702 this patch: 1.37824 This change had a positive effect on our quality metrics as well: One pass CBR: Min / Mean / Max (pct) Average PSNR -0.42 / 2.86 / 27.32 Overall PSNR -0.90 / 2.00 / 17.27 SSIM -0.05 / 3.95 / 37.46 Two pass CBR: Min / Mean / Max (pct) Average PSNR -4.47 / 4.35 / 35.99 Overall PSNR -3.40 / 4.18 / 36.46 SSIM -4.56 / 6.98 / 53.67 One pass VBR: Min / Mean / Max (pct) Average PSNR -5.21 / 0.01 / 3.30 Overall PSNR -8.10 / -0.38 / 1.21 SSIM -7.38 / -0.11 / 3.17 (note: most values here were close to the mean, there were a few outliers on files that were very sensitive to golden frame size) Two pass VBR: Min / Mean / Max (pct) Average PSNR 0.00 / 0.00 / 0.00 Overall PSNR 0.00 / 0.00 / 0.00 SSIM 0.00 / 0.00 / 0.00 Neither one pass or two pass CBR mode adheres particularly strictly to the short term buffer constraints, and two pass is less consistent, even in the baseline commit. This should be addressed in a later commit. This likely will hurt the quality numbers, as it will have to reduce the burstiness of golden frames. Aside: My work on this commit makes it clear that we need to make rate control modes "pluggable", where you can easily write a new one or work on one in isolation. Change-Id: I1ea9a48f2beedd59891f1288aabf7064956b4716