Index: source/libvpx/vp8/decoder/dboolhuff.c |
=================================================================== |
--- source/libvpx/vp8/decoder/dboolhuff.c (revision 191025) |
+++ source/libvpx/vp8/decoder/dboolhuff.c (working copy) |
@@ -10,8 +10,6 @@ |
#include "dboolhuff.h" |
-#include "vpx_ports/mem.h" |
-#include "vpx_mem/vpx_mem.h" |
int vp8dx_start_decode(BOOL_DECODER *br, |
const unsigned char *source, |
@@ -32,20 +30,33 @@ |
return 0; |
} |
- |
void vp8dx_bool_decoder_fill(BOOL_DECODER *br) |
{ |
- const unsigned char *bufptr; |
- const unsigned char *bufend; |
- VP8_BD_VALUE value; |
- int count; |
- bufend = br->user_buffer_end; |
- bufptr = br->user_buffer; |
- value = br->value; |
- count = br->count; |
+ const unsigned char *bufptr = br->user_buffer; |
+ const unsigned char *bufend = br->user_buffer_end; |
+ VP8_BD_VALUE value = br->value; |
+ int count = br->count; |
+ int shift = VP8_BD_VALUE_SIZE - 8 - (count + 8); |
+ size_t bits_left = (bufend - bufptr)*CHAR_BIT; |
+ int x = (int)(shift + CHAR_BIT - bits_left); |
+ int loop_end = 0; |
- VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend); |
+ if(x >= 0) |
+ { |
+ count += VP8_LOTS_OF_BITS; |
+ loop_end = x; |
+ } |
+ if (x < 0 || bits_left) |
+ { |
+ while(shift >= loop_end) |
+ { |
+ count += CHAR_BIT; |
+ value |= (VP8_BD_VALUE)*bufptr++ << shift; |
+ shift -= CHAR_BIT; |
+ } |
+ } |
+ |
br->user_buffer = bufptr; |
br->value = value; |
br->count = count; |