summaryrefslogtreecommitdiff
path: root/vp9/decoder
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2015-07-01 19:10:43 -0700
committerJames Zern <jzern@google.com>2015-07-01 19:10:43 -0700
commit1e0aa9497fccf04d9c22a6195c580606af6aca71 (patch)
treedfeb40eb3ca00e534c04b600ce6aafa2ba9b041c /vp9/decoder
parente7578084299b7cc24e987367b20180ad4a91d78f (diff)
downloadlibvpx-1e0aa9497fccf04d9c22a6195c580606af6aca71.tar
libvpx-1e0aa9497fccf04d9c22a6195c580606af6aca71.tar.gz
libvpx-1e0aa9497fccf04d9c22a6195c580606af6aca71.tar.bz2
libvpx-1e0aa9497fccf04d9c22a6195c580606af6aca71.zip
inline vp9_reader_has_error()
this is tested for each block Change-Id: I229c6f0e9513fb206bdbce8be9699a4bf4008ca4
Diffstat (limited to 'vp9/decoder')
-rw-r--r--vp9/decoder/vp9_reader.c23
-rw-r--r--vp9/decoder/vp9_reader.h25
2 files changed, 23 insertions, 25 deletions
diff --git a/vp9/decoder/vp9_reader.c b/vp9/decoder/vp9_reader.c
index 6bb4f9f73..2c96f74f4 100644
--- a/vp9/decoder/vp9_reader.c
+++ b/vp9/decoder/vp9_reader.c
@@ -13,11 +13,6 @@
#include "vp9/decoder/vp9_reader.h"
-// This is meant to be a large, positive constant that can still be efficiently
-// loaded as an immediate (on platforms like ARM, for example).
-// Even relatively modest values like 100 would work fine.
-#define LOTS_OF_BITS 0x40000000
-
int vp9_reader_init(vp9_reader *r,
const uint8_t *buffer,
size_t size,
@@ -86,21 +81,3 @@ const uint8_t *vp9_reader_find_end(vp9_reader *r) {
}
return r->buffer;
}
-
-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
- // 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 LOTS_OF_BITS. So when
- // count == LOTS_OF_BITS - 1, the user's data has been exhausted.
- //
- // 1 if we have tried to decode bits after the end of stream was encountered.
- // 0 No error.
- return r->count > BD_VALUE_SIZE && r->count < LOTS_OF_BITS;
-}
diff --git a/vp9/decoder/vp9_reader.h b/vp9/decoder/vp9_reader.h
index a68a1d592..495998556 100644
--- a/vp9/decoder/vp9_reader.h
+++ b/vp9/decoder/vp9_reader.h
@@ -29,6 +29,11 @@ typedef size_t BD_VALUE;
#define BD_VALUE_SIZE ((int)sizeof(BD_VALUE) * CHAR_BIT)
+// This is meant to be a large, positive constant that can still be efficiently
+// loaded as an immediate (on platforms like ARM, for example).
+// Even relatively modest values like 100 would work fine.
+#define LOTS_OF_BITS 0x40000000
+
typedef struct {
// Be careful when reordering this struct, it may impact the cache negatively.
BD_VALUE value;
@@ -49,10 +54,26 @@ int vp9_reader_init(vp9_reader *r,
void vp9_reader_fill(vp9_reader *r);
-int vp9_reader_has_error(vp9_reader *r);
-
const uint8_t *vp9_reader_find_end(vp9_reader *r);
+static INLINE 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
+ // 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 LOTS_OF_BITS. So when
+ // count == LOTS_OF_BITS - 1, the user's data has been exhausted.
+ //
+ // 1 if we have tried to decode bits after the end of stream was encountered.
+ // 0 No error.
+ return r->count > BD_VALUE_SIZE && r->count < LOTS_OF_BITS;
+}
+
static INLINE int vp9_read(vp9_reader *r, int prob) {
unsigned int bit = 0;
BD_VALUE value;