1. 26 Apr, 2012 - 1 commit
    • Deb Mukherjee's avatar
      Adds search option for best interpolation filter. · acdda50a
      Deb Mukherjee authored
      Adds a speed feature to conduct a brute force search among a set of
      available interpolation filters for the best one in an RD sense.
      
      There is a gain of 0.4% on derf, 1.0% on Std-HD.
      
      Patch 2: A macro added to determine if the encoder state is reset
      for each new filter tried.
      
      Patch 3: rebase, also fixes a bug (decodframe.c) introduced by a
      couple of missing function pointer assignements.
      
      Patch 4: rebase.
      
      Change-Id: Ic9ccca9d8c35c6af557449ae867391a2f996cc29
      acdda50a
  2. 24 Apr, 2012 - 1 commit
    • Deb Mukherjee's avatar
      Differential encoding of probability updates · c6f1bf43
      Deb Mukherjee authored
      Adds differential encoding of prob updates using a subexponential
      code centered around the previous probability value.
      Also searches for the most cost-effective update, and breaks
      up the coefficient updates into smaller groups.
      
      Small gain on Derf: 0.2%
      
      Change-Id: Ie0071e3dc113e3d0d7ab95b6442bb07a89970030
      c6f1bf43
  3. 19 Apr, 2012 - 1 commit
  4. 18 Apr, 2012 - 1 commit
  5. 11 Apr, 2012 - 1 commit
    • Adrian Grange's avatar
      Superblock encoding order · 9daf3154
      Adrian Grange authored
      This is the first patch to add superblock (32x32) coding
      order capabilities. It does not yet do any mode selection
      at the SB level, that will follow in a further patch.
      
      This patch encodes rows of SBs rather than
      MBs, each SB contains 2x2 MBs.
      
      Two intra prediction modes have been disabled since they
      require reconstructed data for the above-right MB which
      may not have been encoded yet (e.g. for the bottom right
      MB in each SB).
      
      Results on the one test clip I have tried (720p GIPS clip)
      suggest that it is somewhere around 0.2dB worse than the
      baseline version, so there may be bugs.
      
      It has been tested with no experiments enabled and with
      the following 3 experiments enabled:
        --enable-enhanced_interp
        --enable-high_precision_mv
        --enable-sixteenth_subpel_uv
      in each case the decode buffer matches the recon buffer
      (using "cmp" to compare the dumped/decoded frames).
      Note: Testing these experiments individually created
      errors.
      
      Some problems were found with other experiments but it
      is unclear what state these experiments are in:
        --enable-comp_intra_pred
        --enable-newentropy
        --enable-uvintra
      
      This code has not been extensively tested yet, so there
      is every likelihood that further bugs remain. I also
      intend to do some code cleanup & refactoring in tandem
      with the next patch that adds the 32x32 modes.
      
      Change-Id: I1eba7f740a70b3510df58db53464535ef881b4d9
      9daf3154
  6. 21 Mar, 2012 - 2 commits
    • Yaowu Xu's avatar
      enable 8x8 transform for MBs in intra frames · 2823173e
      Yaowu Xu authored
      When ac_yquant>171, a key frame is enabled to use 8x8 transform. In
      such case, MBs with DC_PRED or TM_PRED are selected to use T8x8. This
      change helped the full STD-HD set by ~.1% or so, which is reasonable
      considering how often key frame occurs in these encodings.
      
      Change-Id: Id17009ef6327252177b19e6bf0d6628827febaf1
      2823173e
    • Deb Mukherjee's avatar
      Making subpel filters switchable at frame level · 475d5d56
      Deb Mukherjee authored
      Various refactoring to make the subpel motion compensation
      filters switchable by a frame level field.
      Two types of 8-tap filters are supported in addition to the existing
      bilinar and sixtap filters. One is the default 8-tap and the
      other has a sharper cut-off for use with frames with substantial
      edge content.
      
      Patch 2: Added a preliminary strategy for filter selection based on
      edginess detecton. Also includes some filter changes.
      
      Change-Id: I866085bda5ae143cfdf2ec88157feaabdf7bd63a
      475d5d56
  7. 07 Mar, 2012 - 1 commit
    • Paul Wilkins's avatar
      Snapshot candidate · 68033ca4
      Paul Wilkins authored
      Pulled out super block code for the snapshot as this
      is not quite ready and will need an extensive re-merge.
      
      Change-Id: I436369b511257447a7b0ea064016cb63f5011849
      68033ca4
  8. 01 Mar, 2012 - 1 commit
  9. 29 Feb, 2012 - 1 commit
  10. 28 Feb, 2012 - 3 commits
    • Deb Mukherjee's avatar
      Initial refactoring of high_precision mv code. · 3e1cad9c
      Deb Mukherjee authored
      This is the first patch for refactoring of the code related to
      high-precision mv, so that 1/4 and 1/8 pel motion vectors can
      co-exist in the same bit-stream by use of a frame level flag.
      The current patch works fine for only use of 1/4th and
      only use of 1/8th pel mv, but there are some issues with the
      mode switching in between. Subsequent patches on this change Id
      will fix the remaining issues.
      
      Patch 2: Adds fixes to make sure that multiple mv precisions can
      co-exist in the bit-stream. Frame level switching has been tested
      to work correctly.
      
      Patch 3: Fixes lines exceeding 80 char
      
      Patch 4:
      http://www.corp.google.com/~debargha/vp8_results/enhinterp.html
      
      Results on derf after ssse3 bugfix, compared to everything
      enabled but the 8-tap, 1/8-subpel and 1/16-subpel uv. Overall the
      gains are about 3% now. Hopefully there are no more bugs lingering.
      Apparently the sse3 bug affected the quartel subpel results more than
      the eighth pel ones (which is understandabale ...
      3e1cad9c
    • Paul Wilkins's avatar
      Experimental branch code clean up. · 25c127f5
      Paul Wilkins authored
      Removal of some further code relating to partitions
      and error resilience.
      
      Spelling correction.
      
      Change-Id: I36067aae67a4a23bec359541dda3400b0bbf26d0
      25c127f5
    • Paul Wilkins's avatar
      Code Simplification · b6f02c85
      Paul Wilkins authored
      Removal of code relating to token partitioning
      
      Change-Id: Iaf3c88d6758639a55bd92c3be5c51e6bed407a3c
      b6f02c85
  11. 27 Feb, 2012 - 1 commit
    • Paul Wilkins's avatar
      Corrected spelling · b00ed02a
      Paul Wilkins authored
      Apparently the correct spelling of segement is segment !
      
      Change-Id: I88593ee0523f251b3a96794c6166ef8c7898a029
      b00ed02a
  12. 23 Feb, 2012 - 1 commit
    • Deb Mukherjee's avatar
      Supporting high precision 1/8-pel motion vectors · 18e90d74
      Deb Mukherjee authored
      This is the initial patch for supporting 1/8th pel
      motion. Currently if we configure with enable-high-precision-mv,
      all motion vectors would default to 1/8 pel. Encode and
      decode syncs fine with the current code. In the next phase
      the code will be refactored so that we can choose the 1/8
      pel mode adaptively at a frame/segment/mb level.
      
      Derf results:
      http://www.corp.google.com/~debargha/vp8_results/enhinterp_hpmv.html
      (about 0.83% better than 8-tap interpoaltion)
      
      Patch 3: Rebased. Also adding 1/16th pel interpolation for U and V
      
      Patch 4: HD results.
      http://www.corp.google.com/~debargha/vp8_results/enhinterp_hd_hpmv.html
      Seems impressive (unless I am doing something wrong).
      
      Patch 5: Added mmx/sse for bilateral filtering, as well as enforced
      use of c-versions of subpel filters with 8-taps and 1/16th pel;
      Also redesigned the 8-tap filters to reduce the cut-off in order to
      introduce a denoising effect. There is a new configure option
      sixteenth-subpel-uv which will use 1/16 th pel interpolation for
      uv, if the motion vectors have 1/8 pel accuracy.
      
      With the fixes the results are promising on the derf set. The enhanced
      interpolation option with 8-taps alone gives 3% improvement over thei
      derf set:
      http://www.corp.google.com/~debargha/vp8_results/enhinterpn.html
      
      Results on high precision mv and on the hd set are to follow.
      
      Patch 6: Adding a missing condition for CONFIG_SIXTEENTH_SUBPEL_UV in
      vp8/common/x86/x86_systemdependent.c
      
      Patch 7: Cleaning up various debug messages.
      
      Patch 8: Merge conflict
      
      Change-Id: I5b1d844457aefd7414a9e4e0e06c6ed38fd8cc04
      18e90d74
  13. 15 Feb, 2012 - 1 commit
  14. 13 Feb, 2012 - 2 commits
    • Jim Bankoski's avatar
      vp8 - config_featureupdates · af8f1928
      Jim Bankoski authored
      Added a bit to signify that the feature changed since
      the last time we sent it, or not so that we don't need
      to send all the databits for every feature change.
      
      added config
      
      Change-Id: I8d3064ce90d4500bf0d5c6b87c664e46138dfcac
      af8f1928
    • Yaowu Xu's avatar
      Changed how coefficient probability table is updated · 2d1ead34
      Yaowu Xu authored
      Added a frame level flag to indicate if coef probabilities are updated
      at all for the frame.
      
      During the experimental work with 8x8 transform, it is discovered that
      even in the case of no probability is ever update, cost of transmitting
      "no update" for each of probabilities can run up to become a significant
      overhead cost. A single bit to indicate no-update for all coef probs
      is therefore helpful, which is also demonstrated by the test results:
      
      1. On Cif set:
      http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_updprob.html
      (avg psnr: .14%, glb psnr: .14% SSIM: .13%)
      
      2. On HD set:
      http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_updprob.html
      (avg psnr: .02%  glb psnr: .01% SSIM: .02%)
      It should be noted that the gain on HD is smaller because the average bit
      rate is much higher in contrast to the overhead bit cost.
      
      Change-Id: I46db270e693ee8799fef34a14d8260868ce4cd16
      2d1ead34
  15. 10 Feb, 2012 - 3 commits
    • Paul Wilkins's avatar
      Removal of threading code. · 2615ca5d
      Paul Wilkins authored
      For the experimental branch we are trying to slim the codebase
      down removing features such as threading for now which complicate
      the process of development and testing.
      
      Change-Id: I657c0246aef4d1fa8c8ffc6a1adfeee45bce8e24
      2615ca5d
    • Ronald S. Bultje's avatar
      Improved coding using 8x8 transform · f64725a0
      Ronald S. Bultje authored
      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
      f64725a0
    • Ronald S. Bultje's avatar
      Merge dualpred (compound prediction) experiment. · 29e4d7e8
      Ronald S. Bultje authored
      Change-Id: Ieaaa07c50eae41118596197f6a4d848135946e41
      29e4d7e8
  16. 09 Feb, 2012 - 2 commits
    • Paul Wilkins's avatar
      Removal of SEGFEATURES placeholder comments · d90f0eb4
      Paul Wilkins authored
      This commit only involves the removal of placeholder comments
      //#if CONFIG_SEGFEATURES.
      
      Change-Id: I94b350daaf998ee0cfdde5aa25b1d3b0522ab816
      d90f0eb4
    • Paul Wilkins's avatar
      Merge COMPRED · cf8af867
      Paul Wilkins authored
      Merged in most of the current common prediction changes
      that were under the #if CONFIG_COMPRED option.
      
      Change-Id: If4e6f61dbe7b86dd449f6effbe93b5eb7e893885
      cf8af867
  17. 06 Feb, 2012 - 1 commit
    • Paul Wilkins's avatar
      Merged NEWNEAR experiment · 9c9300f5
      Paul Wilkins authored
      This commit merges the NEWNEAR experiment such that it
      is effectively always on.
      
      The fact that there were changes in the threading code again
      highlights the need to strip out such features during the
      bitstream development phase as trying to maintain this code
      (especially as it is not being tested) slows the development cycle.
      
      Change-Id: I8b34950a1333231ced9928aa11cd6d6459984b65
      9c9300f5
  18. 02 Feb, 2012 - 1 commit
    • Adrian Grange's avatar
      Added encoding in Superblock Order · 5d0b5a17
      Adrian Grange authored
      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
      5d0b5a17
  19. 01 Feb, 2012 - 1 commit
  20. 31 Jan, 2012 - 4 commits
  21. 19 Dec, 2011 - 1 commit
    • Paul Wilkins's avatar
      Further QIndex realted Fixes: · fb807776
      Paul Wilkins authored
      Added code to support 256 index steps instead of 128 but disabled for now.
      Replace hard wired table vp8cx_base_skip_false_prob[128]
      Observed Qindex problem with setting minimum loop filter value.
      (Experiment code using real Q in place but for now just returning 0. This has a big
      beneficial effect on some clips, particularly waterfall which shows 5% ssim gain)
      
      Change-Id: I2f7117de8adc1797164c106aa13effc900a1467e
      fb807776
  22. 09 Dec, 2011 - 1 commit
  23. 07 Dec, 2011 - 3 commits
    • Yaowu Xu's avatar
      Removed #if CONFIG_MULCONTEXT · b70f23ca
      Yaowu Xu authored
      This commit removed the macro CONFIG_MULCONTEXT, which was used to
      indicate the experiment code for using separate context for altref
      and normal frames. This commit made the change fully merged in.
      
      Change-Id: I525f927f68e2365d37b340ef23b836a136a4f70b
      b70f23ca
    • Yaowu Xu's avatar
      Removed #if CONFIG_I8X8 · d37cd976
      Yaowu Xu authored
      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
      d37cd976
    • Yaowu Xu's avatar
      made vp8_mode_context adaptive · 76feb965
      Yaowu Xu authored
      vp8_mode_contexts[] is an entropy table used to code inter mode
      choices. It was a fixed constant table. This commit made the entropy
      context adaptive. Tests on derf set showed very good consistent gains
      on all metrics: avg psnr .47%, overall psnr .46% and ssim .40%.
      
      http://www.corp.google.com/~yaowu/no_crawl/newModeContext.html
      
      Change-Id: Ia62b14485c948e2b74586118619c5eb2068b43b2
      76feb965
  24. 06 Dec, 2011 - 1 commit
    • Ronald S. Bultje's avatar
      Dual 16x16 inter prediction. · 60cb39da
      Ronald S. Bultje authored
      This patch introduces the concept of dual inter16x16 prediction. A
      16x16 inter-predicted macroblock can use 2 references instead of 1,
      where both references use the same mvmode (new, near/est, zero). In the
      case of newmv, this means that two MVs are coded instead of one. The
      frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
      prediction, or per-MB single/dual prediction selection ("hybrid"), in
      which case a single bit is coded per-MB to indicate whether the MB uses
      single or dual inter prediction.
      
      In the future, we can (maybe?) get further gains by mixing this with
      Adrian's 32x32 work, per-segment dual prediction settings, or adding
      support for dual splitmv/8x8mv inter prediction.
      
      Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
      gain is at medium/high bitrates, but there's minor gains at low bitrates
      also. Output was confirmed to match between encoder and decoder.
      
      Note for optimization people: this patch introduces a 2nd version of
      16x16/8x8 sixtap/bilin functions, which does an avg instead of a
      store. They may want to look and make sure this is implemented to
      their satisfaction so we can optimize it best in the future.
      
      Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
      60cb39da
  25. 02 Dec, 2011 - 2 commits
    • Yaowu Xu's avatar
      added separate entropy context for alt_ref · acf5d20c
      Yaowu Xu authored
      This commit added code to keep track of separate entropy contexts for
      normal frames and alt ref frames. The underly assumption was that the
      two type of frames have different entropy characteristics given they
      typically have quite different quantization levels. By keeping entropy
      contexts separate, it helps the entropy context distribution to be more
      closely adapted to each frame type.
      
      Tests on derf set showed a good and very consistent gain on all clips
      on all metrics, avg psnr: 0.89%, overall psnr: 0.84% and ssim 0.93%.
      
      http://www.corp.google.com/~yaowu/no_crawl/mulcontext.html
      
      Change-Id: I15bc9697f6ff7829042911fe0c62930585d7e65d
      acf5d20c
    • Yaowu Xu's avatar
      enabled 8x8 intra prediction modes on inter frames · a8fbab86
      Yaowu Xu authored
      This commit enabled the usage of 8x8 intra prediction modes on inter
      frames. There are a few TODO items related to this: 1)baseline entropy
      need be calibrated; 2)cost of UV need to be done more properly rather
      than using decision only relying on Y; 3)Threshold for allowing picking
      8x8 intra prediction should be lowered to lower than the B_PRED.
      
      Even with all the TODOs, tests showed consistent gain on derf set ~0.1%
      (PSNR:0.08% and SSIM:0.14%). It is assumed that 8x8 intra prediction
      will help more on large resolution clips, especially with above TODOs
      addressed.
      
      Change-Id: I398ada49dfc32575cfab962a569c2885111ae3ba
      a8fbab86
  26. 01 Dec, 2011 - 1 commit
    • Yaowu Xu's avatar
      added transform type to MB_MODE_INFO · bba710fc
      Yaowu Xu authored
      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
      bba710fc
  27. 15 Nov, 2011 - 1 commit
    • Paul Wilkins's avatar
      Merge CONFIGURE_SEGMENTATION experiment. · 3cdfdb55
      Paul Wilkins authored
      Removal of CONFIGURE_SEGMENTATION ifdefs.
      
      Removal of legacy support code fo the old coding mechanism.
      
      Use local reference "xd" for MACROBLOCKD structure in
      encode_frame_to_data_rate()
      
      Moved call to choose_segmap_coding_method() out of encode
      loop as the cost of segmentation is not properly accounted
      in the loop anyway. If this is desirable in the future it
      can be moved back. The use of this function to do all the
      analysis and set the probabilities also removes the need
      to track segment useage in threading code.
      
      Change-Id: I85bc8fd63440e7176c73d26cb742698f9b70cade
      3cdfdb55