summaryrefslogtreecommitdiff
path: root/vp8/encoder/ratectrl.c
AgeCommit message (Collapse)Author
2011-12-22Remove legacy integer typesJohn Koleszar
Remove BOOL, INTn, UINTn, etc, in favor of C99-style fixed width types. Change-Id: I396636212fb5edd6b347d43cc940186d8cd1e7b5
2011-12-14Merge "fix: active_worst_quality could be set above 127"John Koleszar
2011-12-13fix: active_worst_quality could be set above 127James Berry
add check to set active_worst_quality to 127 if it is set above 127 Change-Id: I7db353d5c1b1c8516a116542b6ed21c0110bb512
2011-12-09vp8e - entropy stats per frame typeJim Bankoski
Change-Id: I4168eb6ea22ae541471738a7a3453e7d52059275
2011-11-18Speed selection support for disabled reference framesJohn Koleszar
There was an implicit reference frame test order (typically LAST, GOLD, ARF) in the mode selection logic, but this doesn't provide the expected results when some reference frames are disabled. For instance, in real-time mode, the speed selection logic often disables the ARF modes. So if the user disables the LAST and GOLD frames, the encoder was always choosing INTRA, when in reality searching the ARF in this case has the same speed penalty as searching LAST would have had. Instead, introduce the notion of a reference frame search order. This patch preserves the former priorities, so if a frame is disabled, the other frames bump up a slot to take its place. This patch lays the groundwork for doing something smarter in the frame test order, for example considering temporal distance or looking at the frames used by nearby blocks. Change-Id: I1199149f8662a408537c653d2c021c7f1d29a700
2011-11-07Third set of checks of buffer level against maximum buffer sizeAdrian Grange
Additional check of buffer level to ensure it doesn't exceed the maximum buffer size. Change-Id: I1ba4f8b09bbec89646885040ff47470196af521e
2011-10-11Added rate-targeted temporal scalabilityAdrian Grange
Added the ability to create rate-targeted, temporally scalable, VP8 compatible bitstreams. The application vp8_scalable_patterns.c demonstrates how to use this capability. Users can create output bitstreams containing upto 5 temporally separable streams encoded as a single VP8 bitstream. (previously abandoned as: I92d1483e887adb274d07ce9e567e4d0314881b0a) Change-Id: I156250a3fe930be57c069d508c41b6a7a4ea8d6a
2011-08-12Revert "Improved 1-pass CBR rate control"John Koleszar
This reverts commit b5ea2fbc2c1554769848774c836aad262af95072. Further testing showed noticable keyframe popping in some cases, reverting this for now to give time for a proper fix. Conflicts: vp8/encoder/onyx_if.c vp8/encoder/ratectrl.c Change-Id: I159f53d1bf0e24c035754ab3ded8ccfd58fd04af
2011-07-26cosmetics: consistently use [u]int64_tJames Zern
Removes mixed usage of (unsigned) long long and INT64. Fixes Issue #208. Change-Id: I220d3ed5ce4bb1280cd38bb3715f208ce23cf83a
2011-07-18Improved 1-pass CBR rate controlJohn Koleszar
This patch attempts to improve the handling of CBR streams with respect to the short term buffering requirements. The "buffer level" is changed to be an average over the rc buffer, rather than a long running average. Overshoot is also tracked over the same interval and the golden frame targets suppressed accordingly to correct for overly aggressive boosting. Testing shows that this is fairly consistently positive in one metric or another -- some clips that show significant decreases in quality have better buffering characteristics, others show improvenents in both. Change-Id: I924c89aa9bdb210271f2e03311e63de3f1f8f920
2011-06-23Revert "Reduce overshoot in 1 pass rate control"John Koleszar
This reverts commit 212f6183739d448ad5fa2ccf1b4edd30829b2806. Further testing shows that the overshoot accumulation/damping is too aggressive on some clips. Allowing the accumulated overshoot to decay and limiting to damping to golden frames shows some promise. But some clips show significant overshoot in the buffer window, so I think this still needs work. Change-Id: Ic02a9ca34f55229f9cc04786f4fab54cdc1a3ef5
2011-06-03Reduce overshoot in 1 pass rate controlJohn Koleszar
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
2011-05-19cleanup: collect twopass variablesJohn Koleszar
This patch collects the twopass specific memebers of VP8_COMP into a dedicated struct. This is a first step towards isolating the two pass rate control and aids readability by decorating these variables with the 'twopass.' namespace. This makes it clear to the reader in what contexts the variable will be valid, and is a hint that a section of code might be a good candidate to move to firstpass.c in later refactoring. There likely will be other rate control modes that need their own specific data as well. This notation is probably overly verbose in firstpass.c, so an alternative would be to access this struct through a pointer like 'rc->' instead of 'cpi->firstpass.' in that file. Feel free to make a review comment to that effect if you prefer. Change-Id: I0ab8254647cb4b493a77c16b5d236d0d4a94ca4d
2011-05-19Remove unused members of VP8_COMPJohn Koleszar
Various members that were either completely unreferenced or written and not read. Change-Id: Ie41ebac0ff0364a76f287586e4fe09a68907806e
2011-05-06Don't override active_worst_quality in 2 passJohn Koleszar
Commit db5057c introduced a bug in that the active_worst_quality selected by the 2 pass rate controller was being overridden for key frames, causing a severe quality loss. Change-Id: I4865a6fbe3e94e9b4fb9271c7dd68b455d7b371d
2011-04-26Refactor calc_iframe_target_sizeJohn Koleszar
Combine calc_iframe_target_size, previously only used for forced keyframes, with calc_auto_iframe_target_size, which handled most keyframes. Change-Id: I227051361cf46727caa5cd2b155752d2c9789364
2011-04-26Move pick_frame_size() to ratectrl.cJohn Koleszar
This is a first step in cleaning up the redundancies between vp8_calc_{auto_,}iframe_target_size. The pick_frame_size() function is moved to ratectrl.c, and made to be the primary interface. This means that the various calc_*_target_size functions can be made private. Change-Id: I66a9a62a5f9c23c818015e03f92f3757bf3bb5c8
2011-04-25Fix duplicate vp8_compute_frame_size_boundsJohn Koleszar
Likely introduced by a bad automatic merge from gerrit. Change-Id: I0c6dd6ec18809cf9492f524d283fa4a3a8f4088b
2011-04-25Merge "Remove unused functions"John Koleszar
2011-04-25Remove unused functionsJohn Koleszar
Remove estimate_min_frame_size() and calc_low_ss_err(), as they are never referenced. Change-Id: I3293363c14ef70b79c4678ca27aa65b345077726
2011-04-25Merge "Change rc undershoot/overshoot semantics"John Koleszar
2011-04-25bug fix possible keyframe context divide by zeroJames Berry
vp8_adjust_key_frame_context() divides by estimate_keyframe_frequency() which can return 0 in the case where --kf-max-dist=0. Change-Id: Idfc59653478a0073187cd2aa420e98a321103daa
2011-04-19Remove unused kf rate variablesJohn Koleszar
Remove tot_key_frame_bits and prior_key_frame_size[] as they were tracked but never used. Remove intra_frame_target, as it was only used to initialize prior_key_frame_size. Refactor vp8_adjust_key_frame_context() some to remove unnecessary calculations. Change-Id: Icbc2c83d2b90e184be03e6f9679e678f3a4bce8f
2011-04-12Change rc undershoot/overshoot semanticsJohn Koleszar
This patch changes the rc_undershoot_pct and rc_overshoot_pct controls to set the "aggressiveness" of rate adaptation, by limiting the amount of difference between the target buffer level and the actual buffer level which is applied to the target frame rate for this frame. This patch was initially provided by arosenberg at logitech.com as an attachment to issue #270. It was modified to separate these controls from the other unrelated modifications in that patch, as well as to use the pre-existing variables rather than introducing new ones. Change-Id: Id542e3f5667dd92d857d5eabf29878f2fd730a62
2011-04-01Use full-pixel MV in mvsadcost calculationYunqing Wang
MV sad cost error is only used in full-pixel motion search, which only need full-pixel resolution instead of quarter-pixel resolution. This change reduced mvsadcost table size, and removed unneccessary pamameter passing since this table is constant once it is generated. Change-Id: I9f931e55f6abc3c99011321f1dfb2f3562e6f6b0
2011-03-17Increase static linkage, remove unused functionsJohn Koleszar
A large number of functions were defined with external linkage, even though they were only used from within one file. This patch changes their linkage to static and removes the vp8_ prefix from their names, which should make it more obvious to the reader that the function is contained within the current translation unit. Functions that were not referenced were removed. These symbols were identified by: $ nm -A libvpx.a | sort -k3 | uniq -c -f2 | grep ' [A-Z] ' \ | sort | grep '^ *1 ' Change-Id: I59609f58ab65312012c047036ae1e0634f795779
2011-03-111 Pass CQ and VBR bug fixesPaul Wilkins
Issue 291 highlighted the fact that CQ mode was not working as expected in 1 pass mode, This commit fixes that specific problem but in so doing I also uncovered an overflow issue in the VBR code for 1 pass and some data values not being correctly initialized. For some clips (particularly short clips), the resulting improvement is dramatic. Change-Id: Ieefd6c6e4776eb8f1b0550dbfdfb72f86b33c960
2011-02-10Fix relative include pathsJohn Koleszar
Allow compiling without adding vp8/{common,encoder,decoder} to the include paths. Change-Id: Ifeb5dac351cdfadcd659736f5158b315a0030b6c
2011-01-07CQ ModePaul Wilkins
The merge includes hooks to for CQ mode and other code changes merged from the test branch. CQ mode attempts to maintain a more stable quantizer within a clip whilst also trying to adhere to a guidline maximum bitrate. The existing target data rate parameter is used to specify the guideline maximum bitrate. A new parameter allows the user to specify a target CQ level. For normal (non kf/gf/arf) frames, the quantizer will not drop BELOW the user specified value (0-63). However, in some cases the encoder may choose to impose a target CQ that is above that specified by the user, if it estimates that consistent use of the target value is not compatible with guideline maximum bitrate. Change-Id: I2221f9eecae8cc3c431d36caf83503941b25e4c1
2010-12-06Fix for manual Golden frame frequencyPatrik Westin
When auto_golden wasn't set it forced all frames to be a golden frame. Now the manual configured frequency is adhered to. Change-Id: I360acac9bc487db0d9c4d4da6ee41f70c227c539
2010-12-01Set refresh_alt_ref_frame on keyframe encode.Fritz Koenig
On a keyframe alt ref and golden are refreshed. The flag was not being set and so on the frame after a keyframe, motion search would occur on the alt ref frame. This is not necessary because the alt ref frame identical to the last frame in this scenario. Handle corner case where a forward alt-ref frame is put directly after a keyframe. Change-Id: I9be4cf290d694f8cf2f9a31852014b5ccf1504d3
2010-11-22Recalibration of bits per MB tablesPaul Wilkins
The baseline bits per MB prediction tables have been re calibrated based on the assumption that bits per mb is inversely proportional to the quantizer level. Change-Id: Ibd355c7acac4b8053dda1baf1032fe35f11da7f7
2010-10-14safety check to avoid divide by 0sJim Bankoski
2010-09-09Use WebM in copyright notice for consistencyJohn Koleszar
Changes 'The VP8 project' to 'The WebM project', for consistency with other webmproject.org repositories. Fixes issue #97. Change-Id: I37c13ed5fbdb9d334ceef71c6350e9febed9bbba
2010-08-31Improved Force Key Frame BehaviourPaul Wilkins
These changes improve the behaviour of the code with forced key frames sent in by a calling application. The sizing of the frames is still suboptimal for two pass in particular but the behaviour is much better than it was. Change-Id: I35fae610c67688ccc69d11f385e87dfc884e65a1
2010-08-11Moved gf_active code to encoder onlyScott LaVarnway
The gf_active code is only used by the encoder, so it was moved from common and decoder. Change-Id: Iada15acd5b2b33ff70c34668ca87d4cfd0d05025
2010-07-19Rate control fix for ARNR filtered frames.Paul Wilkins
Previously we had assumed that it was necessary to give a full frame's bit allocation to the alt ref frame if it has been created through temporal filtering. This is not the case. The active max quantizer control insures that sufficient bits are allocated if needed and allocating a full frame's worth of bits creates an excessive overhead for the ARF. Change-Id: I83c95ed7bc7ce0e53ccae6ff32db5a97f145937a
2010-06-18cosmetics: trim trailing whitespaceJohn Koleszar
When the license headers were updated, they accidentally contained trailing whitespace, so unfortunately we have to touch all the files again. Change-Id: I236c05fade06589e417179c0444cb39b09e4200d
2010-06-08Correct commentPaul Wilkins
2010-06-04LICENSE: update with latest textJohn Koleszar
Change-Id: Ieebea089095d9073b3a94932791099f614ce120c
2010-05-25Correct bit allocation when the alternative reference framePaul Wilkins
is constructed from multiple source frames Change-Id: I2e026c10d02b071b401c9fe8ab8dcfc0ac306103
2010-05-20Fixed incorrect casts that broke rate control in some situations.Paul Wilkins
2010-05-19remove unneeded variablesPavol Rusnak
2010-05-18Initial WebM releaseJohn Koleszar