summaryrefslogtreecommitdiff
path: root/vp8/encoder/ratectrl.c
AgeCommit message (Collapse)Author
2013-12-11Merge "vp8: remove 2 unused tables"James Zern
2013-12-11Fix the printf format stringAdrian Grange
There were two problems with the format string in the conditionally compiled print statement. It referred to a variable that is no longer available and it used incorrect format specifiers. Change-Id: I315e22bea2691bb535a2e33f5ca206fc55287a37
2013-12-10vp8: remove 2 unused tablesJames Zern
Change-Id: Ib5ba4e0b438107741efa28251848306322fd7f89
2013-11-01Fixes to buffer update for temporal layers.Marco Paniconi
When a frame is dropped due to |buffer_level| < 0 for a given temporal layer, the buffer level for the upper temporal layers was not updated (in calc_pframe_target_size()). This change fixes that. Also, use the layer per-frame-bandwidth for updating the buffer level of the higher layers when a frame is dropped. Change-Id: I660c23f3229b47e9d124a950b480314b4307c5a8
2013-07-18VP[89]_COMMON: remove golden/altref frame countsJames Zern
these are only used in the encoder. frames_since_golden / frames_till_alt_ref_frame -> VP[89]_COMP Change-Id: Ie14a6f46987bced685ddb449b85dc261caba6dfe
2013-07-16use consistent framerate namingJames Zern
s/frame_rate/framerate/g Change-Id: I6fc3e088e419c5f46e3a9390dd8a2cad2677a2fc
2013-03-14Removed shadow warnings : bitstream.c encodeframe.c onyx_if.cScott LaVarnway
ratectrl.c and quantize.c Adding -Wshadow to CFLAGS generated a bunch of warnings. This patch removes these warnings. Change-Id: I8c8faa9fde57c1c49662d332a90bc8d9a0f4a2ce
2013-01-31Fix for divide by zero in vp8_adjust_key_frame.Marco Paniconi
Change-Id: I3bf9bdd95abfd287fbcb644f4fb85fb9204be95a
2012-12-10Moved zbin_over_quant to macroblock structScott LaVarnway
Change-Id: I76fe20ade099573997404b8733cf7f79e82fb21e WIP: Fixing unsafe threading in VP8 encoder.
2012-11-26Updates to qp-regulate and rate correction factor.Marco Paniconi
Don't use the switch to gf_rate_correction factor when temporal layers is used (i.e., cpi->oxcf.number_of_layers > 1). In temporal layers, we prefer to avoid this as any frame (e.g., base layer frame at anchor of pattern) may update both last and golden (and possibly alt-ref), and so we would get different rate correction factors within the same layer. This change will make sure one rate correction factor exists for each layer. Also, made some other code in qp-regulate that depends on alt/golden update specific to the 1 layer case. Change-Id: I41a6d085bd477f9307ef3b3c311695214273892c
2012-11-05Moving ymode_count, uv_mode_count to macroblock structScott LaVarnway
Change-Id: Ib73c7b2bee4cb2eb2528fa6b381fffe9503079a0
2012-09-13Removed pre_mvcScott LaVarnway
Not used. Change-Id: Ifbd97c9ad537d5184f7e305fa8acf6f027978b6b
2012-08-20silent compiling warnings for VC9 buildYaowu Xu
Change-Id: Iaa947e640f27e6f6eaf7d845f243536bca2df513
2012-07-27Remove the resetting of qp params for temporal layers.Marco Paniconi
The ambient qp and active worse/best qp were reset for every frame when temporal layers is on. This change removes this reset. As this affects the target size for forced key frames (it will actually lower the size somewhat), we increased the inital boost factor to compensate. Change-Id: Ie38d95f5c99ab3d447469c49e2177bc3fcc4ad28
2012-07-10Merge "Remove goldfreq in VP8_COMP"Yunqing Wang
2012-06-12Remove goldfreq in VP8_COMPYunqing Wang
goldfreq can be replaced by DEFAULT_GF_INTERVAL. Change-Id: I3659a9e7b9a6be9cb1952a1838e02c20d656e369
2012-06-11Fix pedantic compiler warningsJohn Koleszar
Allows building the library with the gcc -pedantic option, for improved portabilty. In particular, this commit removes usage of C99/C++ style single-line comments and dynamic struct initializers. This is a continuation of the work done in commit 97b766a46, which removed most of these warnings for decode only builds. Change-Id: Id453d9c1d9f44cc0381b10c3869fabb0184d5966
2012-06-07Remove unused code in drop_frameYunqing Wang
Removed unused parameters and code related to drop_frame. Change-Id: I594e050d49b1805c6f72abf06005ef624256bb57
2012-05-11fix warnings for building on win32Scott Graham
Change-Id: If6e11ba3d681e831d7d98662c0abdd2ac16b3811
2012-04-23Shares one set of RD costs tables between all encoding threadsAttila Nagy
RD costs were local to MACROBLOCK data and had to be copied all the time to each thread's MACROBLOCK data. Tables moved to a common place and only pointers are setup for each encoding thread. vp8_cost_tokens() generates 'int' costs so changed all types to be int (i.e. removed unsigned). NOTE: Could do some more cleaning in vp8cx_init_mbrthread_data(). Change-Id: Ifa4de4c6286dffaca7ed3082041fe5af1345ddc0
2012-04-23Removes duplication of key frame mode probabilitiesAttila Nagy
Key frame macrobock and block mode probabilities are constant. Remove the allocation of tables for each codec instance and use instead the default const prob tables. Change-Id: I8361798ac491f9b3889e86925a494c58647c753f
2012-03-13Merge "Update for key frame target size setting."Jim Bankoski
2012-03-12Update for key frame target size setting.Marco Paniconi
Set an iniital/minimun boost level for the frame rate factor of key frame target size setting. Change-Id: If2586f4ac76a1fa89378aa652a58607356a1f426
2012-03-01vp8e - force at least some change in over and under shootsPaul Wilkins
Change-Id: Ie1796f272dc33bf5a1c8ac990da625961d272aa9
2012-02-22Remove the frame rate factor for key frame size.Marco Paniconi
When temporal layers is used (i.e., number_of_layers > 1), we don't use the frame rate boost for setting the key frame target size. The factor was forcing the target size to be always at its minimum (2* per_frame_bandwidth) for low frame rates (i.e., base layer frame rate). Generally we should modify or remove this frame rate factor; for now we turn if off for number_of_layers > 1. Change-Id: Ia5acf406c9b2f634d30ac2473adc7b9bf2e7e6c6
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