summaryrefslogtreecommitdiff
path: root/vp8/encoder/encodeintra.c
AgeCommit message (Collapse)Author
2012-03-01Merge t8x8 experimentsYaowu Xu
Change-Id: I8e9b6b154e1a0d0cb42d596366380d69c00ac15f
2012-02-28Compound intra prediction (b_pred/4x4 only, for now),Ronald S. Bultje
Also remove duplicate build_intra_predictors_mby/uv(). Change-Id: I78607e7304952a9b962a5b25af9bb9c48692187b
2012-02-10Improved coding using 8x8 transformRonald S. Bultje
In summary, this commit encompasses a series of changes in attempt to improve the 8x8 transform based coding to help overall compression quality, please refer to the detailed commit history below for what are the rationale underly the series of changes: a. A frame level flag to indicate if 8x8 transform is used at all. b. 8x8 transform is not used for key frames and small image size. c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV and I8X8_PRED are forced to using 4x4 transform based coding, the rest uses 8x8 transform based coding. d. Encoder and decoder has the same assumption on the relationship between prediction modes and transform size, therefore no signaling is encoded in bitstream. e. Mode decision process now calculate the rate and distortion scores using their respective transforms. Overall test results: 1. HD set http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html (avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%) 2. Cif set: http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html (avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%) It should be noted here, as 8x8 transform coding itself is disabled for cif size clips, the 0.03% loss is purely from the 1 bit/frame flag overhead on if 8x8 transform is used or not for the frame. ---patch history for future reference--- Patch 1: this commit tries to select transform size based on macroblock prediction mode. If the size of a prediction mode is 16x16, then the macroblock is forced to use 8x8 transform. If the prediction mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced to use 4x4 transform. Tests on the following HD clips showed mixed results: (all hd clips only used first 100 frames in the test) http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html while the results are mixed and overall negative, it is interesting to see 8x8 helped a few of the clips. Patch 2: this patch tries to hard-wire selection of transform size based on prediction modes without using segmentation to signal the transform size. encoder and decoder both takes the same assumption that all macroblocks use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or SPLITMV. Test results are as follows: http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html Interestingly, by removing the overhead or coding the segmentation, the results on this limited HD set have turn positive on average. Patch 3: this patch disabled the usage of 8x8 transform on key frames, and kept the logic from patch 2 for inter frames only. test results on HD set turned decidedly positive with 8x8 transform enabled on inter frame with 16x16 prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%) http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html results on cif set still negative overall Patch 4: continued from last patch, but now in mode decision process, the rate and distortion estimates are computed based on 8x8 transform results for MBs with modes associated with 8x8 transform. This patch also fixed a problem related to segment based eob coding when 8x8 transform is used. The patch significantly improved the results on HD clips: http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html (avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%) results on cif also improved, though they are still negative compared to baseline that uses 4x4 transform only: http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html (avg psnr: -.78% glb psnr: -.86% ssim: -.19%) Patch 5: This patch does 3 things: a. a bunch of decoder bug fixes, encodings and decodings were verified to have matched recon buffer on a number of encodes on cif size mobile and hd version of _pedestrian. b. the patch further improved the rate distortion calculation of MBS that use 8x8 transform. This provided some further gain on compression. c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8 transformed macroblock, test results indicates it improves the cif set but hurt the HD set slightly. Tests results on HD clips: http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html (avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%) Test results on cif clips: http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html (avg psnr: -.47% glb psnr: -.51% ssim: +.28%) Patch 6: Added a frame level flag to indicate if 8x8 transform is allowed at all. temporarily the decision is based on frame size, can be optimized later one. This get the cif results to basically unchanged, with one bit per frame overhead on both cif and hd clips. Patch 8: Rebase and Merge to head by PGW. Fixed some suspect 4s that look like hey should be 64s in regard to segmented EOB. Perhaps #defines would be bette. Bulit and tested without T8x8 enabled and produces unchanged output. Patch 9: Corrected misalligned code/decode of "txfm_mode" bit. Limited testing for correct encode and decode with T8x8 configured on derf clips. Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-02Added encoding in Superblock OrderAdrian Grange
As a precursor to encoding 32x32 blocks this cl adds the ability to encode the frame superblock (=32x32 block) at a time. Within a SB the 4 indiviual MBs are encoded in raster-order (NW,NE,SW,SE). This functionality is added as an experiment which can be enabled by ispecifying --enable-superblocks in the command line specified to configure (CONFIG_SUPERBLOCKS macro in the code). To make this work I had to disable the two intra prediction modes that use data from the top-right of the MB. On the tests that I have run the results produce almost exactly the same PSNRs & SSIMs with a very slightly higher average data rate (and slightly higher data rate than just disabling the two intra modes in the original code). NOTE: This will also break the multi-threaded code. This replaces the abandoned change: Iebebe0d1a50ce8c15c79862c537b765a2f67e162 Change-Id: I1bc1a00f236abc1a373c7210d756e25f970fcad8
2011-12-07Removed #if CONFIG_I8X8Yaowu Xu
This commit removed the macro CONFIG_I8X8, which was used to indicate the 8x8 intra prediction experiment, made the change fully merged in. Change-Id: Iafa4443781ce6e83f5591c12ba615a0e92ce0ea0
2011-12-07Rename use_dc_pred to use_16x16_pred.Ronald S. Bultje
Because the variable doesn't distinguish between DC and non-DC prediction, but rather between 16x16 or 4x4 prediction. Change-ID: Ia4e7dda2bd6230c91515072e3277be2d64e42629
2011-12-01added transform type to MB_MODE_INFOYaowu Xu
this commit is to add an variable in the macroblock level mode info structure to track the transform size used in each MB, so the information can be used later in the loop filter to change how loop filter works on MBs with different transform sizes. Change-Id: Id0eeaba6cc854c6d1be00ed8d237b3d9e250e447
2011-11-08Segment signaling of TX sizePaul Wilkins
Initial attempt at using new segment feature signaling to indicate 4x4 or 8x8 transform. needs --enable-experimental --enable-t8x8 Note this is work in progress. Change-Id: Ib160d46a5d810307bfcbc79853ce1a65b5b870b7
2011-09-16add 8x8 intra prediction modesYaowu Xu
Patch 1 to Patch 3 is an initial implementation of 8x8 intra prediction modes, here are with the following assumptions: a. 8x8 has 4 prediction modes DC, H, V and TM b. UV 4x4 block use the same mode as corresponding 8x8 area c. i8x8 modes are enabled for key frame only for now Patch 4: d. removed debug code from previous patches Patch 5: e. added stats code to collect entropy stats and further cleaned up Patch 6: f. changed mode stats code to collect finer stats of modes Patch 7: g. normalized i8x8 modes distribution to total at 256 (8bits). Patch 8: h. fixed a bug in decoder and removed debug printf output. Patch 9: i. more cleanups to address paul's comment Patch 10: j. messy rebase/merges to bring the commit up to date. Tests on HD clips encoded with all key frame showing consistent gain on all clips and all metrics:~0.5%(psnr) and 0.6%(ssim): http://www.corp.google.com/~yaowu/no_crawl/i8x8hd_allkey_fixedq.html To build and test, configure with: --enable-experimental --enable-i8x8 Change-Id: I9813fe07ae48cab5fdb5d904bca022514ad01e7f
2011-07-20Add 8x8 transform to experimental branchDeb Mukherjee
Please refer to previous commit messages for detailed info: https://on2-git.corp.google.com/g/#change,5940 https://on2-git.corp.google.com/g/#change,6045 Change-Id: I8b16992f2f69c5a808ad40a3e32ef589cce7c59d
2011-06-23Copy macroblock data to a buffer before encoding itYunqing Wang
I got this idea from Pascal (Thanks). Before encoding a macroblock, copy it to a 16x16 buffer, and then read source data from there instead. This will help keep the source data in cache, and help with the performance. Change-Id: Id05f4cb601299150511d59dcba0ae62c49b5b757
2011-06-14Merge "Populate bmi for B_PRED only"Scott LaVarnway
2011-06-14Fix RT only buildTero Rintaluoma
Moved encode_intra function from firstpass.c to encodeintra.c to prevent linking problem in real-time only build. Also changed name of the function to vp8_encode_intra because it is not a static. Change-Id: Ibf3c6c1de3152567347e5fbef47d1d39564620a5
2011-06-13Populate bmi for B_PRED onlyScott LaVarnway
Small decode performance gain (~1%) on keyframes. No noticeable gains on encode. Also changed pick_intra4x4mby_modes() to read the above and left block modes for keyframes only. Change-Id: I1f4885252f5b3e9caf04d4e01e643960f910aba5
2011-06-02Removed B_MODE_INFOScott LaVarnway
Declared the bmi in BLOCKD as a union instead of B_MODE_INFO. Then removed B_MODE_INFO completely. Change-Id: Ieb7469899e265892c66f7aeac87b7f2bf38e7a67
2011-05-24MODE_INFO size reductionScott LaVarnway
Declared the bmi in MODE_INFO as a union instead of B_MODE_INFO. This reduced the memory footprint by 518,400 bytes for 1080 resolutions. The decoder performance improved by ~4% for the clip used and the encoder showed very small improvements. (0.5%) This reduction was first mentioned to me by John K. and in a later discussion by Yaowu. This is WIP. Change-Id: I8e175fdbc46d28c35277302a04bee4540efc8d29
2011-05-19revise two function definitions with less parametersYaowu Xu
Change-Id: Ia96e5bf915e4d3c0ac9c1795114bd9e5dd07327a
2011-05-19disable trellis optimization for first passYaowu Xu
also remove 2 #defines and 1 function declaration that are not in use. Change-Id: I8f743d0e3dd9ebf1de24a8b0c30ff09f29b00c53
2011-05-10remove a variable no longer in useYaowu Xu
The variable is introduced in commit 2e53e9e53 to make more use of trellis quantization, but this is no longer necessary after RDMULT was made adaptive in a number of later commits. Change-Id: I7420522ec7723f38cf77033466c25afb405d52ae
2011-04-27SSE2/SSSE3 optimizations for build_predictors_mbuv{,_s}().Ronald S. Bultje
decoding before 10.425 10.432 10.423 =10.426 after: 10.405 10.416 10.398 =10.406, 0.2% faster encoding before 14.252 14.331 14.250 14.223 14.241 14.220 14.221 =14.248 after 14.095 14.090 14.085 14.095 14.064 14.081 14.089 =14.086, 1.1% faster Change-Id: I483d3d8f0deda8ad434cea76e16028380722aee2
2011-04-11Set cpu_used range to [-16, 16] in real-time modeYunqing Wang
Remove encoding speed limitation in real-time mode. Change-Id: Ib5e35d8bb522b2a25f3e4ad5cfe2788ebebb3617
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-11Move build_intra_predictors_mby to RTCD frameworkJohn Koleszar
The vp8_build_intra_predictors_mby and vp8_build_intra_predictors_mby_s functions had global function pointers rather than using the RTCD framework. This can show up as a potential data race with tools such as helgrind. See https://bugzilla.mozilla.org/show_bug.cgi?id=640935 for an example. Change-Id: I29c407f828ac2bddfc039f852f138de5de888534
2011-02-17Merge "Fix relative include paths"John Koleszar
2011-02-14Improved vp8_rd_pick_intra_mbuv_modeScott LaVarnway
Eliminated unnecessary calculations. Very small change to performance. Change-Id: Ib7213d43c64e36955177c4d47950ff472266f822
2011-02-14Improved rd_pick_intra4x4blockScott LaVarnway
Eliminated unnecessary calculations. Improved performance by 10% on keyframes and 1.6% overall for the test clip used. Change-Id: I87671b26af5e2cc439e81d0fee3b15c7cd2a3309
2011-02-10Fix relative include pathsJohn Koleszar
Allow compiling without adding vp8/{common,encoder,decoder} to the include paths. Change-Id: Ifeb5dac351cdfadcd659736f5158b315a0030b6c
2011-01-26Rationalize vp8_rd_pick_intra16x16mby_mode()Paul Wilkins
Use the function macro_block_yrd() to calculate error and distortion in keeping with what is done for inter frames. The old code was using a variance metric for once case and an SSE function for measuring distortion in the other case. The function vp8_encode_intra16x16mbyrd() is no longer used. Change-Id: Ic228cb00a78ff637f4365b43f58fbe5a9273d36f
2010-12-03Merge 'Add simple version of activity masking.'John Koleszar
Merge commit 'refs/changes/79/779/2' of https://review.webmproject.org/p/libvpx Conflicts: vp8/encoder/encodeintra.c vp8/encoder/encodemb.c Change-Id: Id607063fabe92d99eeb3c380e8ca670b01bfb3ef
2010-10-26make vp8_recon16x16mb{,y} RTCD functionsJohn Koleszar
ARM NEON has a platform specific version of vp8_recon16x16mb, though it's just a stub to extract the various parameters from the MACROBLOCKD struct and pass them to vp8_recon16x16mb_neon(). Using that function's prototype directly will be a better long term solution, but it's quite an invasive change. Change-Id: I04273149e2ade34749e2d09e7edb0c396e1dd620
2010-10-15change to make use of more trellis quantizationYaowu Xu
when a subsequent frame is encoded as an alt reference frame, it is unlikely that any mb in current frame will be used as reference for future frames, so we can enable quantization optimization even when the RD constant is slightly rate-biased. The change has an overall benefit between 0.1% to 0.2% bit savings on the test sets based on vpxssim scores. Change-Id: I9aa7bc5cd573ea84e3ee655d2834c18c4460ceea
2010-10-12Centralize mb skip state calculationJohn Koleszar
This patch moves the scattered updates to the mb skip state (mode_info_context->mbmi.mb_skip_coeff) to vp8_tokenize_mb. Recent changes to the quantizer exposed a bug where if a macroblock could be coded as a skip but isn't, the encoder would run the loopfilter but the decoder wouldn't, causing a reference buffer mismatch. The loopfilter is controlled by a flag called dc_diff. The decoder looks at the number of decoded coefficients when setting this flag. The encoder sets this flag based on the skip state, since any skippable macroblock should be transmitted as a skip. The coefficient optimization pass (vp8_optimize_b()) could change the coefficients such that a block that was not a skip becomes one. The encoder was not updating the skip state in this situation for intra coded blocks. The underlying issue predates it, but this bug was recently triggered by enabling trellis quantization on the Y2 block in commit dcd29e3, and by changing the quantizer range control in commit 305be4e. Change-Id: I5cce5da0dbc2d22f7d79ee48149f01e868a64802
2010-10-12Add simple version of activity masking.Timothy B. Terriberry
This uses MB variance to change the RDO weight for mode decision and quantization. Activity is normalized against the average for the frame, which is currently tracked using feed-forward statistics. This could also be used to adjust the quantizer for the entire frame, but that requires more extensive rate control changes. This does not yet attempt to adapt the quantizer within the frame, but the signaling cost means that will likely only be useful at very high rates. Change-Id: I26cd7c755cac3ff33cfe0688b1da50b2b87b9c93
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-12Removed unnecessary MB_MODE_INFO copiesScott LaVarnway
These copies occurred for each macroblock in the encoder and decoder. Thetemp MB_MODE_INFO mbmi was removed from MACROBLOCKD. As a result, a large number compile errors had to be fixed. Change-Id: I4cf0ffae3ce244f6db04a4c217d52dd256382cf3
2010-08-10Removed duplicate functionsYaowu Xu
Change-Id: Ie587972ccefd3c762b8cdf8ef39345cd22924b9b
2010-08-10Add trellis quantization.Timothy B. Terriberry
Replace the exponential search for optimal rounding during quantization with a linear Viterbi trellis and enable it by default when using --best. Right now this operates on top of the output of the adaptive zero-bin quantizer in vp8_regular_quantize_b() and gives a small gain. It can be tested as a replacement for that quantizer by enabling the call to vp8_strict_quantize_b(), which uses normal rounding and no zero bin offset. Ultimately, the quantizer will have to become a function of lambda in order to take advantage of activity masking, since there is limited ability to change the quantization factor itself. However, currently vp8_strict_quantize_b() plus the trellis quantizer (which is lambda-dependent) loses to vp8_regular_quantize_b() alone (which is not) on my test clip. Patch Set 3: Fix an issue related to the cost evaluation of successor states when a coefficient is reduced to zero. With this issue fixed, now the trellis search almost exactly matches the exponential search. Patch Set 2: Overall, the goal of this patch set is to make "trellis" search to produce encodings that match the exponential search version. There are three main differences between Patch Set 2 and 1: a. Patch set 1 did not properly account for the scale of 2nd order error, so patch set 2 disable it all together for 2nd blocks. b. Patch set 1 was not consistent on when to enable the the quantization optimization. Patch set 2 restore the condition to be consistent. c. Patch set 1 checks quantized level L-1, and L for any input coefficient was quantized to L. Patch set 2 limits the candidate coefficient to those that were rounded up to L. It is worth noting here that a strategy to check L and L+1 for coefficients that were truncated down to L might work. (a and b get trellis quant to basically match the exponential search on all mid/low rate encodings on cif set, without a, b, trellis quant can hurt the psnr by 0.2 to .3db at 200kbps for some cif clips) (c gets trellis quant to match the exponential search to match at Q0 encoding, without c, trellis quant can be 1.5 to 2db lower for encodings with fixed Q at 0 on most derf cif clips) Change-Id: Ib1a043b665d75fbf00cb0257b7c18e90eebab95e
2010-06-24Redo the forward 4x4 dctYaowu Xu
The new fdct lowers the round trip sum squared error for a 4x4 block ~0.12. or ~0.008/pixel. For reference, the old matrix multiply version has average round trip error 1.46 for a 4x4 block. Thanks to "derf" for his suggestions and references. Change-Id: I5559d1e81d333b319404ab16b336b739f87afc79
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-07Remove duplicate and unused functionsYaowu Xu
Change-Id: I944035e720ef834561a9da0d723879a4f787312c
2010-06-04LICENSE: update with latest textJohn Koleszar
Change-Id: Ieebea089095d9073b3a94932791099f614ce120c
2010-05-18Initial WebM releaseJohn Koleszar