org.jcodec.codecs.vp8
Class BooleanArithmeticDecoder

java.lang.Object
  extended by org.jcodec.codecs.vp8.BooleanArithmeticDecoder

public class BooleanArithmeticDecoder
extends Object


Constructor Summary
BooleanArithmeticDecoder(ByteBuffer input, int offset)
           
BooleanArithmeticDecoder(ByteBuffer input, int offset, String debugName)
           
 
Method Summary
 int decodeBit()
           
 int decodeBool(int probability)
           
 int decodeInt(int sizeInBits)
           
static int getBitInBytes(byte[] bs, int i)
           
static int getBitsInBytes(byte[] bytes, int idx, int len)
           
static int leadingZeroCountInByte(byte b)
           
 int readTree(int[] tree, int[] probability)
          General formula in VP8 trees.
 int readTreeSkip(int[] t, int[] p, int skip_branches)
           
 void seek()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanArithmeticDecoder

public BooleanArithmeticDecoder(ByteBuffer input,
                                int offset,
                                String debugName)

BooleanArithmeticDecoder

public BooleanArithmeticDecoder(ByteBuffer input,
                                int offset)
Method Detail

decodeBit

public int decodeBit()

decodeBool

public int decodeBool(int probability)

decodeInt

public int decodeInt(int sizeInBits)

readTree

public int readTree(int[] tree,
                    int[] probability)
General formula in VP8 trees. Here's a real example of a tree coded according to this formula in VP8 spec.
 const tree_index mb_segment_tree [2 * (4-1)] =
 // +-------+---+
 // |       |   |
  { 2,  4, -0, -1, -2, -3 };
 //     |           |   |
 //     +-----------+---+
 
If presented in hierarchical form this tree would look like:
 +---------------+
 |      root     |
 |     /    \    |
 |    2      4   |
 |   / \    / \  |
 | -0  -1 -2  -3 |
 +---------------+
 
 
 On the other hand probabilities are coded only for non-leaf nodes. 
 Thus tree array has twice as many nodes as probabilities array
 Consider (3>>1) == 1 == (2>>1), and (0>>1) == 0 == (1>>1)
 Thus single probability element refers to single parent element in tree.
 if (using that probability) a '0' is coded, algorithm goes to the left 
 branch, correspondingly if '1' is coded, algorithm goes to
 the right branch (see tree structure above).
 
 The process is repeated until a negative tree element is found.


readTreeSkip

public int readTreeSkip(int[] t,
                        int[] p,
                        int skip_branches)

seek

public void seek()

toString

public String toString()
Overrides:
toString in class Object

getBitInBytes

public static int getBitInBytes(byte[] bs,
                                int i)

getBitsInBytes

public static int getBitsInBytes(byte[] bytes,
                                 int idx,
                                 int len)

leadingZeroCountInByte

public static int leadingZeroCountInByte(byte b)


Copyright © 2013. All Rights Reserved.