summaryrefslogtreecommitdiff
path: root/vp8/encoder/firstpass.c
AgeCommit message (Collapse)Author
2011-04-06Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: Ied0fedb05342dead6d34740209cf75997f155e72
2011-04-05Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I53be500dad1a98e21d0a28f9e07761d8d03fdcf6
2011-04-04Fixed unused variable warnings for firstpass.cScott LaVarnway
Change-Id: I8378a9a541ade2f098359a7b20fa08e6c1596d80
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-23Merge remote branch 'origin/master' into experimentalJohn Koleszar
Conflicts: vp8/encoder/ratectrl.c vp8/encoder/rdopt.c Change-Id: I4cc58acb432662d2c47aceda1680e52982adbc06
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-14Merge remote branch 'origin/master' into experimentalJohn Koleszar
Conflicts: vp8/encoder/onyx_if.c Change-Id: I230b63cef209cd1ac98357729a91ec07597756bd
2011-03-11Merge "Fix incorrect macroblock counts in twopass rate control"John Koleszar
2011-03-11Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: Ibc4a75dbbc8b35ce298477e055e5a88df080d4b3
2011-03-10Added missing format specifier in print statementAdrian Grange
Printout of firstpass stats for frame had one fewer format specifiers than arguments. Change-Id: I5a42c85aa79c471e1a70afd75e24a91546b7a1cd
2011-03-10Removed firstpass motion mapAdrian Grange
The firstpass motion map consists of an 8-bit flag for each MB indicating how strongly the firstpass code believes it should be filtered during the second pass ARNR filtering. For long or large format material the motion map can become extremely large and hamper the operation of the encoding process. This change removes the motion map altogether, leaving the second pass to rely on the magnitude of the motion compensated error to determine the filter weight to use for the MB during ARNR filtering. Tests on the derf set indicate that the effect of this change is neutral, with some small wins and losses. The motion map has therefore been removed based on a cost/benefit evaluation. Change-Id: I53e07d236f5ce09a6f0c54e7c4ffbb490fb870f6
2011-03-10Fix incorrect macroblock counts in twopass rate controlJames Berry
The previous calculation of macroblock count (w*h)/256 is not correct when the width/height are not multiples of 16. Use the precalculated macroblock count from cpi->common instead. This manifested itself as a divide by zero when the number of pixels was less than 256. num_mbs updated in estimate_max_q, estimate_q, estimate_kf_group_q, and estimate_cq Change-Id: I92ff98587864c801b1ee5485cfead964673a9973
2011-03-09Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: Ie52ff118b00ce462bb110ae349108e55d3d8ff3b
2011-03-08Fix a multi-line format-string warning.Ralph Giles
GCC 4.5 and 4.6 both issue a warning about the multi-line format string introduced in bc9c30a0, which also changed the whitespace in the associated stt file by line-wrapping the long format string. Instead, use multiple string constants, which the compiler will concatenate. This maintains the original formatting, but remains legible within the standard line length. Change-Id: I27c9f92d46be82d408105a3a4091f145f677e00e
2011-03-08Corrected minor typos.Paul Wilkins
Change-Id: Icc9f12bd1e1bdaf51256dc8a90d08aa9be89ef34
2011-03-07Improved key frame detection.Paul Wilkins
In some cases where clips have been encoded with borders (eg. some wide-screen content where there is a border top and bottom and slide shows containing portrait format photographs (border left and right)) key frames were not being correctly detected. The new code looks to measure cases where a portion of the image can be coded equally easily using intra or inter modes and where the resulting error score is also very low. These "neutral" areas are then discounted in the key frame detection code. Change-Id: I00c3e8230772b8213cdc08020e1990cf83b780d8
2011-03-07Improved KF insertion after fades to still.Paul Wilkins
This code extends what was previously done for GFs, to pick cases where insertion of a key frame after a fade (or other transition or complex motion) followed by a still section, will be beneficial and will reduce the number of forced key frames. Change-Id: If8bca00457f0d5f83dc3318a587f61c17d90f135
2011-03-05Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I70ac5a4f8388a7bfa058178c0ae53f6bdb0bb6e5
2011-03-02Fix drastic undershoot in long form contentJohn Koleszar
When the modified_error_left accumulator exceeds INT_MAX, an incorrect cast to int resulted in a negative value, causing the rate control to allocate no bits to that keyframe group, leading to severe undershoot and subsequent poor quality. This error was exposed by the recent change to the rolling target and actual spend accumulators in commit 305be4e4 which fixed them to actually calculate the average value rather than be re-initialized on every frame to the average per-frame bitrate. When this bug was triggered, the target bitrate could be 0, so the rolling target becomes small, which causes the undershoot. The code prior to 305be4e4 did not exhibit this behavior because the rolling target was always set to a reasonable value and was independent of the actual target bitrate. With this patch, the actual target bitrate is calculated correctly, and the rate control tracks as expected. This cast was likely added to silence a compiler warning on a comparison between a double (modified_error_left) and an int (0). Instead, this patch removes the cast and changes the comparison to be against 0.0, which should prevent the warning from reoccuring. This fixes issue #289. Special thanks to gnafu for his efforts in reporting and debugging this fix. Change-Id: Ie5cc1a7b516c578a76c3a50c892a6f04a11621fe
2011-02-25Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I52f21ff6f9a1dca7099a8459657f6f288c5bfe40
2011-02-24Overflow of frame error accumulators.Paul Wilkins
This fixes an overflow problem in the frame error accumulators. The overflow condition is extreme but did trigger when Frank B. coded some high motion interlaced HD content. The observed effect was a catastrophic breakdown of the rate control leading to massive undershoot and poor bit allocation. All the error values should really be unsigned but I will look at this separately. Change-Id: I9745f5c5ca2783620426b66b568b2088b579151f
2011-02-18Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I8999a33db82d38eb85482f3c423db238d6ee3ed9
2011-02-10Fix relative include pathsJohn Koleszar
Allow compiling without adding vp8/{common,encoder,decoder} to the include paths. Change-Id: Ifeb5dac351cdfadcd659736f5158b315a0030b6c
2011-02-01Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: Id1d4bbe257cd126bb5f44347b896ddb659724f0b
2011-01-28Merge remote branch 'origin/master' into experimentalJohn Koleszar
Conflicts: vp8/encoder/rdopt.c Change-Id: Ic17907df70fff45c9e766b5d0cbab0c5f1a1095f
2011-01-26Performance improvement of first passScott LaVarnway
Improved the performance of the first pass only (~6% on 720p test clip) by making use of LUT instead of the float calculations. Might try a SIMD version later. Also started to make use of int_mv instead of MV. Change-Id: If2a217c7d6b59cd2c25c5553e0ca7e0502403af8
2011-01-26Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I35581d7fd525fe972e750899e35de93867595e83
2011-01-25Fix for incorrect variable declaration.Fritz Koenig
Commit 336aa0b7da8a35ba57400ce92fc016fc7fb35233 incorrectly declared current_pos as and int, when it should have been a FIRSTPASS_STATS pointer. Change-Id: I0a51c7a86ebba8546c95dd5d9d1c1143d4613e40
2011-01-25Incorrect bit allocation in forced KF groups.Paul Wilkins
The old 2 pass code estimated error distribution when coding a forced (by interval) key frame. The result of this was that in some cases, when allocating bits at the GF group level within a KF group there was either a glut of bits or starvation of bits at the end of the KF group. Added code to rescan and get the correct data once the position of a forced key frame has been determined. Change-Id: I0c811675ef3f9e4109d14bd049d7641682ffcf11
2011-01-22Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: I2c3326f7e4d9e901f098e499973586e973e1b8fb
2011-01-21Modified static scene check.Paul Wilkins
Added code to scan ahead a few frames when we see what we think is a static scene in the two pass GF loop to see if the conditions persist. Moved calculation of decay rate out into a fuunction. Change-Id: I6e9c67e01ec9f555144deafc8ae67ef25bffb449
2011-01-21Merge remote branch 'origin/master' into experimentalJohn Koleszar
Conflicts: configure Change-Id: I87cdc3faac79e683038fa4a45c3ac542b8e931a5
2011-01-20Further work to reduce pulsing.Paul Wilkins
These changes are specifically targeted at fade transitions to static scenes. Here we want to place a GF/ARF immediately after the fade and prevent an ARF just before the fade. Also some code lines and comment lines shortened to 80 chars while I was there. Change-Id: Iefdc09a4fa7b265048fc017246b73e138693950f
2011-01-20Fixed use of motion percentage in KF/GF group calcAdrian Grange
In both vp8_find_next_key_frame and define_gf_group, motion_pct was initialised at the top of the loop before next_frame stats had been read in. This fix sets motion_pct after next_frame stats have been read. Change-Id: I8c0bebf372ef8aa97b97fd35b42973d1d831ee73
2011-01-20Merge remote branch 'origin/master' into experimentalJohn Koleszar
Change-Id: Ia0840303fe1dc8c12f3389e7a1fe20b6d3c6b9c5
2011-01-19experiment extending the quantizer rangeYaowu Xu
Prior to this change, VP8 min quantizer is 4, which caps the highest quality around 51DB. This experimental change extends the min quantizer to 1, removes the cap and allows the highest quality to be around ~73DB, consistent with the fdct/idct round trip error. To test this change, at configure time use options: --enable-experimental --enable-extend_qrange The following is a brief log of changes in each of the patch sets patch set 1: In this commit, the quantization/dequantization constants are kept unchanged, instead scaling factor 4 is rolled into fdct/idct. Fixed Q0 encoding tests on mobile: Before: 9560.567kbps Overall PSNR:50.255DB VPXSSIM:98.288 Now: 18035.774kbps Overall PSNR:73.022DB VPXSSIM:99.991 patch set 2: regenerated dc/ac quantizer lookup tables based on the scaling factor rolled in the fdct/idct. Also slightly extended the range towards the high quantizer end. patch set 3: slightly tweaked the quantizer tables and generated bits_per_mb table based on Paul's suggestions. patch set 4: fix a typo in idct, re-calculated tables relating active max Q to active min Q patch set 5: added rdmult lookup table based on Q patch set 6: fix rdmult scale: dct coefficient has scaled up by 4 patch set 7: make transform coefficients to be within 16bits patch set 8: normalize 2nd order quantizers patch set 9: fix mis-spellings patch set 10: change the configure script and macros to allow experimental code to be enabled at configure time with --enable-extend_qrange patch set 11: rebase for merge Change-Id: Ib50641ddd44aba2a52ed890222c309faa31cc59c
2011-01-19First pass loop bug.Paul Wilkins
Incorrect value loop_decay_rate used in GF loop. The intent was to test the cumulative value decay_accumulator. Change-Id: I62928c63eb09f4f6936a45ebd1c23784d1c9681b
2011-01-18Further CQ, Key frame and ARF changesPaul Wilkins
This code fixes a bug in the calculation of the minimum Q for alt ref frames. It also allows an extended gf/arf interval for sections of clips that completely static (or nearly so). Change-Id: I1a21aaa16d4f0578e5f99b13bebd78d59403c73b
2011-01-12Limit key frame quantizer for forced key frames.Paul Wilkins
Where a key frame occurs because of a minimum interval selected by the user, then these forced key frames ideally need to be more closely matched in quality to the surrounding frame. Change-Id: Ia55b1f047e77dc7fbd78379c45869554f25b3df7
2011-01-11Remove unused local variablesHenrik Lundin
Removing unused local variables causing compiler warnings in Visual Studio. Change-Id: I0e2096303be1fdbc01428a6e57cca9796bb32c8a
2011-01-10Two Pass VBR changePaul Wilkins
Further experiment with restriction of the Q range. This uses the average non KF/GF/ARF quantizer, instead of just relying on the initial value. It is not such a strong constraint but there may be a reduced risk of rate misses. Change-Id: I424fe782a37a2f4e18c70805e240db55bfaa25ec
2011-01-10Revert BASE_ERRPERMBPaul Wilkins
Constant value reverted pending more tests on different video formats. Change-Id: I07d11a0e0185e60724698c835416caf2e0774e61
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
2011-01-07Limit Q variability in two pass.Paul Wilkins
In two pass encoding each frame is given an active Q range to work with. This change limits how much this Q range can be altered over time from the initial estimate made for the clip as a whole. There is some danger this could lead to overshoot or undershoot in some corner cases but it helps considerably in regard to clips where either there is a glut or famine of bits in some sections, particularly near the end of a clip. Change-Id: I34fcd1af31d2ee3d5444f93e334645254043026e
2011-01-04Adjustment to boost calculation in two pass.Paul Wilkins
Calculate a minimum intra value to be used in determining the IIratio scores used in two pass, second pass. This is to make sure sections that are low complexity" in the intra domain are still boosted appropriately for KF/GF/ARF. For now I have commented out the Q based adjustment of KF boost. Change-Id: I15deb09c5bd9b53180a2ddd3e5f575b2aba244b3
2010-12-06Merge "Improve MV prediction accuracy to achieve performance gain"Scott LaVarnway
2010-12-03Improve MV prediction accuracy to achieve performance gainYunqing Wang
Add vp8_mv_pred() to better predict starting MV for NEWMV mode in vp8_rd_pick_inter_mode(). Set different search ranges according to MV prediction accuracy, which improves encoder performance without hurting the quality. Also, as Yaowu suggested, using diamond search result as full search starting point and therefore adjusting(reducing) full search range helps the performance. Change-Id: Ie4a3c8df87e697c1f4f6e2ddb693766bba1b77b6
2010-11-19Added extra two pass stats gathering.Paul Wilkins
Added code to record spend so far against planed budget. Change-Id: I5a3335346fa1771b2b1219df9f6127f9993d2594
2010-11-10Relax rate control for last few framesPaul Wilkins
VBR rate control can become very noisy for the last few frames. If there are a few bits to spare or a small overshoot then the target rate and hence quantizer may start to fluctuate wildly. This patch prevents further adjustment of the active Q limits for the last few frames. Patch also removes some redundant variables and makes one small bug fix. Change-Id: Ic167831bec79acc9f0d7e4698bcc4bb188840c45
2010-10-27Eliminate more warnings.Timothy B. Terriberry
This eliminates a large set of warnings exposed by the Mozilla build system (Use of C++ comments in ISO C90 source, commas at the end of enum lists, a couple incomplete initializers, and signed/unsigned comparisons). It also eliminates many (but not all) of the warnings expose by newer GCC versions and _FORTIFY_SOURCE (e.g., calling fread and fwrite without checking the return values). There are a few spurious warnings left on my system: ../vp8/encoder/encodemb.c:274:9: warning: 'sz' may be used uninitialized in this function gcc seems to be unable to figure out that the value shortcut doesn't change between the two if blocks that test it here. ../vp8/encoder/onyx_if.c:5314:5: warning: comparison of unsigned expression >= 0 is always true ../vp8/encoder/onyx_if.c:5319:5: warning: comparison of unsigned expression >= 0 is always true This is true, so far as it goes, but it's comparing against an enum, and the C standard does not mandate that enums be unsigned, so the checks can't be removed. Change-Id: Iaf689ae3e3d0ddc5ade00faa474debe73b8d3395