Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: libvpx/source/libvpx/vp8/decoder/dboolhuff.h

Issue 7624054: Revert r97185 "Update libvpx snapshot to v0.9.7-p1 (Cayuga)." (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libvpx/source/libvpx/vp8/decoder/asm_dec_offsets.c ('k') | libvpx/source/libvpx/vp8/decoder/dboolhuff.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libvpx/source/libvpx/vp8/decoder/dboolhuff.h
diff --git a/libvpx/source/libvpx/vp8/decoder/dboolhuff.h b/libvpx/source/libvpx/vp8/decoder/dboolhuff.h
index 853c10f145234c20a44e409c91739886eb9e4c0a..a83e3f012ac4edeb76526a546be57ed64c4ea1e0 100644
--- a/libvpx/source/libvpx/vp8/decoder/dboolhuff.h
+++ b/libvpx/source/libvpx/vp8/decoder/dboolhuff.h
@@ -34,7 +34,7 @@ typedef struct
unsigned int range;
} BOOL_DECODER;
-DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
+DECLARE_ALIGNED(16, extern const unsigned char, vp8dx_bitreader_norm[256]);
int vp8dx_start_decode(BOOL_DECODER *br,
const unsigned char *source,
@@ -51,26 +51,19 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *br);
#define VP8DX_BOOL_DECODER_FILL(_count,_value,_bufptr,_bufend) \
do \
{ \
- int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \
- int loop_end, x; \
- size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \
- \
- x = shift + CHAR_BIT - bits_left; \
- loop_end = 0; \
- if(x >= 0) \
+ int shift; \
+ for(shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); shift >= 0; ) \
{ \
- (_count) += VP8_LOTS_OF_BITS; \
- loop_end = x; \
- if(!bits_left) break; \
- } \
- while(shift >= loop_end) \
- { \
- (_count) += CHAR_BIT; \
+ if((_bufptr) >= (_bufend)) { \
+ (_count) = VP8_LOTS_OF_BITS; \
+ break; \
+ } \
+ (_count) += 8; \
(_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \
- shift -= CHAR_BIT; \
+ shift -= 8; \
} \
} \
- while(0) \
+ while(0)
static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
@@ -81,14 +74,11 @@ static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
int count;
unsigned int range;
- split = 1 + (((br->range - 1) * probability) >> 8);
-
- if(br->count < 0)
- vp8dx_bool_decoder_fill(br);
-
value = br->value;
count = br->count;
+ range = br->range;
+ split = 1 + (((range - 1) * probability) >> 8);
bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
range = split;
@@ -101,7 +91,7 @@ static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
}
{
- register unsigned int shift = vp8_norm[range];
+ register unsigned int shift = vp8dx_bitreader_norm[range];
range <<= shift;
value <<= shift;
count -= shift;
@@ -109,7 +99,8 @@ static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
br->value = value;
br->count = count;
br->range = range;
-
+ if(count < 0)
+ vp8dx_bool_decoder_fill(br);
return bit;
}
@@ -128,19 +119,18 @@ static int vp8_decode_value(BOOL_DECODER *br, int bits)
static int vp8dx_bool_error(BOOL_DECODER *br)
{
- /* Check if we have reached the end of the buffer.
- *
- * Variable 'count' stores the number of bits in the 'value' buffer, minus
- * 8. The top byte is part of the algorithm, and the remainder is buffered
- * to be shifted into it. So if count == 8, the top 16 bits of 'value' are
- * occupied, 8 for the algorithm and 8 in the buffer.
- *
- * When reading a byte from the user's buffer, count is filled with 8 and
- * one byte is filled into the value buffer. When we reach the end of the
- * data, count is additionally filled with VP8_LOTS_OF_BITS. So when
- * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted.
- */
- if ((br->count > VP8_BD_VALUE_SIZE) && (br->count < VP8_LOTS_OF_BITS))
+ /* Check if we have reached the end of the buffer.
+ *
+ * Variable 'count' stores the number of bits in the 'value' buffer,
+ * minus 8. So if count == 8, there are 16 bits available to be read.
+ * Normally, count is filled with 8 and one byte is filled into the
+ * value buffer. When we reach the end of the buffer, count is instead
+ * filled with VP8_LOTS_OF_BITS, 8 of which represent the last 8 real
+ * bits from the bitstream. So the last bit in the bitstream will be
+ * represented by count == VP8_LOTS_OF_BITS - 16.
+ */
+ if ((br->count > VP8_BD_VALUE_SIZE)
+ && (br->count <= VP8_LOTS_OF_BITS - 16))
{
/* We have tried to decode bits after the end of
* stream was encountered.
« no previous file with comments | « libvpx/source/libvpx/vp8/decoder/asm_dec_offsets.c ('k') | libvpx/source/libvpx/vp8/decoder/dboolhuff.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698