diff options
author | David Conrad <lessen42@gmail.com> | 2010-06-22 19:24:09 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2010-06-22 19:24:09 +0000 |
commit | 3b636f21daa6996e20ef97131a1c3649c3043304 (patch) | |
tree | 8321dd9f0db957b5b61a6cb397693d3102108146 /libavcodec/vp56.h | |
parent | c6ef6e14cfc472b8077f2d0805c092aeebc1c0f2 (diff) | |
download | ffmpeg-3b636f21daa6996e20ef97131a1c3649c3043304.tar.gz |
Native VP8 decoder.
Patch by David Conrad <lessen42 gmail com> and myself.
Originally committed as revision 23719 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vp56.h')
-rw-r--r-- | libavcodec/vp56.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 0b6f2a870c..4eb414bbbe 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -237,6 +237,12 @@ static inline int vp56_rac_get(VP56RangeCoder *c) return bit; } +// rounding is different than vp56_rac_get, is vp56_rac_get wrong? +static inline int vp8_rac_get(VP56RangeCoder *c) +{ + return vp56_rac_get_prob(c, 128); +} + static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) { int value = 0; @@ -248,12 +254,46 @@ static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) return value; } +static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits) +{ + int value = 0; + + while (bits--) { + value = (value << 1) | vp8_rac_get(c); + } + + return value; +} + +// fixme: add 1 bit to all the calls to this? +static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits) +{ + int v; + + if (!vp8_rac_get(c)) + return 0; + + v = vp8_rac_get_uint(c, bits); + + if (vp8_rac_get(c)) + v = -v; + + return v; +} + +// P(7) static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) { int v = vp56_rac_gets(c, 7) << 1; return v + !v; } +static inline int vp8_rac_get_nn(VP56RangeCoder *c) +{ + int v = vp8_rac_get_uint(c, 7) << 1; + return v + !v; +} + static inline int vp56_rac_get_tree(VP56RangeCoder *c, const VP56Tree *tree, const uint8_t *probs) @@ -267,4 +307,39 @@ static inline int vp56_rac_get_tree(VP56RangeCoder *c, return -tree->val; } +/** + * This is identical to vp8_rac_get_tree except for the possibility of starting + * on a node other than the root node, needed for coeff decode where this is + * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) + */ +static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs, int i) +{ + do { + i = tree[i][vp56_rac_get_prob(c, probs[i])]; + } while (i > 0); + + return -i; +} + +// how probabilities are associated with decisions is different I think +// well, the new scheme fits in the old but this way has one fewer branches per decision +static inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) +{ + return vp8_rac_get_tree_with_offset(c, tree, probs, 0); +} + +// DCTextra +static inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) +{ + int v = 0; + + do { + v = (v<<1) + vp56_rac_get_prob(c, *prob++); + } while (*prob); + + return v; +} + #endif /* AVCODEC_VP56_H */ |