summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-04-19 10:37:24 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-04-19 10:37:24 -0700
commit0b44624c3780ae87272ffbbe5b4f10cb0fd62072 (patch)
treec61dccac6361fd0ac1444436b110f796327b2acb /vp9
parent2a1efafd29bcaa3b9b5c53b48d98a89d56c13ee4 (diff)
downloadlibvpx-0b44624c3780ae87272ffbbe5b4f10cb0fd62072.tar
libvpx-0b44624c3780ae87272ffbbe5b4f10cb0fd62072.tar.gz
libvpx-0b44624c3780ae87272ffbbe5b4f10cb0fd62072.tar.bz2
libvpx-0b44624c3780ae87272ffbbe5b4f10cb0fd62072.zip
Finally removing BOOL_DECODER and using vp9_reader instead.
Change-Id: I03d5b6f22f0930893709c6db5f1b06762ad3354e
Diffstat (limited to 'vp9')
-rw-r--r--vp9/decoder/vp9_dboolhuff.c39
-rw-r--r--vp9/decoder/vp9_dboolhuff.h28
-rw-r--r--vp9/decoder/vp9_decodframe.c12
-rw-r--r--vp9/decoder/vp9_treereader.h2
4 files changed, 40 insertions, 41 deletions
diff --git a/vp9/decoder/vp9_dboolhuff.c b/vp9/decoder/vp9_dboolhuff.c
index 390a68475..9921ea727 100644
--- a/vp9/decoder/vp9_dboolhuff.c
+++ b/vp9/decoder/vp9_dboolhuff.c
@@ -13,25 +13,25 @@
#include "vp9/decoder/vp9_dboolhuff.h"
-int vp9_start_decode(BOOL_DECODER *br, const uint8_t *buffer, size_t size) {
- br->buffer_end = buffer + size;
- br->buffer = buffer;
- br->value = 0;
- br->count = -8;
- br->range = 255;
+int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size) {
+ r->buffer_end = buffer + size;
+ r->buffer = buffer;
+ r->value = 0;
+ r->count = -8;
+ r->range = 255;
if (size && !buffer)
return 1;
- vp9_reader_fill(br);
+ vp9_reader_fill(r);
return 0;
}
-void vp9_reader_fill(BOOL_DECODER *br) {
- const uint8_t *const buffer_end = br->buffer_end;
- const uint8_t *buffer = br->buffer;
- VP9_BD_VALUE value = br->value;
- int count = br->count;
+void vp9_reader_fill(vp9_reader *r) {
+ const uint8_t *const buffer_end = r->buffer_end;
+ const uint8_t *buffer = r->buffer;
+ VP9_BD_VALUE value = r->value;
+ int count = r->count;
int shift = VP9_BD_VALUE_SIZE - 8 - (count + 8);
int loop_end = 0;
const int bits_left = (int)((buffer_end - buffer)*CHAR_BIT);
@@ -50,8 +50,17 @@ void vp9_reader_fill(BOOL_DECODER *br) {
}
}
- br->buffer = buffer;
- br->value = value;
- br->count = count;
+ r->buffer = buffer;
+ r->value = value;
+ r->count = count;
+}
+
+const uint8_t *vp9_reader_find_end(vp9_reader *r) {
+ // Find the end of the coded buffer
+ while (r->count > CHAR_BIT && r->count < VP9_BD_VALUE_SIZE) {
+ r->count -= CHAR_BIT;
+ r->buffer--;
+ }
+ return r->buffer;
}
diff --git a/vp9/decoder/vp9_dboolhuff.h b/vp9/decoder/vp9_dboolhuff.h
index dab330c02..b50aa35fd 100644
--- a/vp9/decoder/vp9_dboolhuff.h
+++ b/vp9/decoder/vp9_dboolhuff.h
@@ -33,24 +33,17 @@ typedef struct {
VP9_BD_VALUE value;
int count;
unsigned int range;
-} BOOL_DECODER;
+} vp9_reader;
DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
-int vp9_start_decode(BOOL_DECODER *br, const uint8_t *buffer, size_t size);
+int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size);
-void vp9_reader_fill(BOOL_DECODER *br);
+void vp9_reader_fill(vp9_reader *r);
-static INLINE const uint8_t *vp9_reader_find_end(BOOL_DECODER *br) {
- // Find the end of the coded buffer
- while (br->count > CHAR_BIT && br->count < VP9_BD_VALUE_SIZE) {
- br->count -= CHAR_BIT;
- br->buffer--;
- }
- return br->buffer;
-}
+const uint8_t *vp9_reader_find_end(vp9_reader *r);
-static int vp9_read(BOOL_DECODER *br, int probability) {
+static int vp9_read(vp9_reader *br, int probability) {
unsigned int bit = 0;
VP9_BD_VALUE value;
VP9_BD_VALUE bigsplit;
@@ -87,21 +80,20 @@ static int vp9_read(BOOL_DECODER *br, int probability) {
return bit;
}
-static int vp9_read_bit(BOOL_DECODER *r) {
+static int vp9_read_bit(vp9_reader *r) {
return vp9_read(r, 128); // vp9_prob_half
}
-static int vp9_read_literal(BOOL_DECODER *br, int bits) {
+static int vp9_read_literal(vp9_reader *br, int bits) {
int z = 0, bit;
- for (bit = bits - 1; bit >= 0; bit--) {
+ for (bit = bits - 1; bit >= 0; bit--)
z |= vp9_read_bit(br) << bit;
- }
return z;
}
-static int bool_error(BOOL_DECODER *br) {
+static int vp9_reader_has_error(vp9_reader *r) {
// Check if we have reached the end of the buffer.
//
// Variable 'count' stores the number of bits in the 'value' buffer, minus
@@ -116,7 +108,7 @@ static int bool_error(BOOL_DECODER *br) {
//
// 1 if we have tried to decode bits after the end of stream was encountered.
// 0 No error.
- return br->count > VP9_BD_VALUE_SIZE && br->count < VP9_LOTS_OF_BITS;
+ return r->count > VP9_BD_VALUE_SIZE && r->count < VP9_LOTS_OF_BITS;
}
#endif // VP9_DECODER_VP9_DBOOLHUFF_H_
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index f8ef6c030..b2830684c 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -715,7 +715,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd,
if (xd->segmentation_enabled)
mb_init_dequantizer(pbi, xd);
- if (!bool_error(r)) {
+ if (!vp9_reader_has_error(r)) {
#if CONFIG_NEWBINTRAMODES
if (mode != I4X4_PRED)
#endif
@@ -727,7 +727,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd,
mode != I4X4_PRED &&
mode != SPLITMV &&
mode != I8X8_PRED &&
- !bool_error(r)) {
+ !vp9_reader_has_error(r)) {
xd->mode_info_context->mbmi.mb_skip_coeff = 1;
} else {
#if 0 // def DEC_DEBUG
@@ -867,7 +867,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mb_row, int mb_col,
else
decode_mb(pbi, xd, mb_row, mb_col, r);
- xd->corrupted |= bool_error(r);
+ xd->corrupted |= vp9_reader_has_error(r);
}
static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col,
@@ -958,7 +958,7 @@ static void setup_token_decoder(VP9D_COMP *pbi,
"Truncated packet or corrupt partition "
"%d length", 1);
- if (vp9_start_decode(r, data, partition_size))
+ if (vp9_reader_init(r, data, partition_size))
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder %d", 1);
}
@@ -1533,7 +1533,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->width, pc->height,
VP9BORDERINPIXELS);
- if (vp9_start_decode(&header_bc, data, first_partition_size))
+ if (vp9_reader_init(&header_bc, data, first_partition_size))
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder 0");
@@ -1684,7 +1684,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
// Collect information about decoder corruption.
// 1. Check first boolean decoder for errors.
// 2. Check the macroblock information
- pc->yv12_fb[pc->new_fb_idx].corrupted = bool_error(&header_bc) |
+ pc->yv12_fb[pc->new_fb_idx].corrupted = vp9_reader_has_error(&header_bc) |
corrupt_tokens;
if (!pbi->decoded_key_frame) {
diff --git a/vp9/decoder/vp9_treereader.h b/vp9/decoder/vp9_treereader.h
index c9832e11d..4535688ea 100644
--- a/vp9/decoder/vp9_treereader.h
+++ b/vp9/decoder/vp9_treereader.h
@@ -15,8 +15,6 @@
#include "vp9/common/vp9_treecoder.h"
#include "vp9/decoder/vp9_dboolhuff.h"
-typedef BOOL_DECODER vp9_reader;
-
#define vp9_read_prob(r) ((vp9_prob)vp9_read_literal(r, 8))
#define vp9_read_and_apply_sign(r, value) (vp9_read_bit(r) ? -(value) : (value))