From 1e0aa9497fccf04d9c22a6195c580606af6aca71 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 1 Jul 2015 19:10:43 -0700 Subject: inline vp9_reader_has_error() this is tested for each block Change-Id: I229c6f0e9513fb206bdbce8be9699a4bf4008ca4 --- vp9/decoder/vp9_reader.c | 23 ----------------------- vp9/decoder/vp9_reader.h | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 25 deletions(-) (limited to 'vp9/decoder') 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; -- cgit v1.2.3