org.jcodec.codecs.vp8
Class BooleanArithmeticDecoder
java.lang.Object
org.jcodec.codecs.vp8.BooleanArithmeticDecoder
public class BooleanArithmeticDecoder
- extends Object
BooleanArithmeticDecoder
public BooleanArithmeticDecoder(ByteBuffer input,
int offset,
String debugName)
BooleanArithmeticDecoder
public BooleanArithmeticDecoder(ByteBuffer input,
int offset)
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.
- if tree element is a positive number it is treated as index of the child elements
tree[i] > 0
- left child is assumed to have index
i
and value tree[i]
- right child is assumed to have index
i+1
and value tree[i+1]
- a negative tree value means a leaf node was reached and it's negated value should be returned
-tree[i]
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.