diff --git a/vp8/decoder/dboolhuff.c b/vp8/decoder/dboolhuff.c index 7e7b05aa62c8c71a78ca943a5a52d909bbb35ac9..cd6d575557aa32836eb1533723695696ba5a1884 100644 --- a/vp8/decoder/dboolhuff.c +++ b/vp8/decoder/dboolhuff.c @@ -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,19 +30,32 @@ int vp8dx_start_decode(BOOL_DECODER *br, 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; - - VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend); + 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; + + 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; diff --git a/vp8/decoder/dboolhuff.h b/vp8/decoder/dboolhuff.h index 1a08c057bde63fe8a2e4cd865d43576b63e9abf5..756821a6e84ad28c37ab45bb8289cbe5d968d9de 100644 --- a/vp8/decoder/dboolhuff.h +++ b/vp8/decoder/dboolhuff.h @@ -9,21 +9,24 @@ */ -#ifndef DBOOLHUFF_H -#define DBOOLHUFF_H +#ifndef DBOOLHUFF_H_ +#define DBOOLHUFF_H_ + #include <stddef.h> #include <limits.h> + #include "vpx_config.h" #include "vpx_ports/mem.h" #include "vpx/vpx_integer.h" typedef size_t VP8_BD_VALUE; -# define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_BD_VALUE)*CHAR_BIT) +#define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_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 VP8_LOTS_OF_BITS (0x40000000) +#define VP8_LOTS_OF_BITS (0x40000000) typedef struct { @@ -42,36 +45,6 @@ int vp8dx_start_decode(BOOL_DECODER *br, void vp8dx_bool_decoder_fill(BOOL_DECODER *br); -/*The refill loop is used in several places, so define it in a macro to make - sure they're all consistent. - An inline function would be cleaner, but has a significant penalty, because - multiple BOOL_DECODER fields must be modified, and the compiler is not smart - enough to eliminate the stores to those fields and the subsequent reloads - from them when inlining the function.*/ -#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 = (int)(shift + CHAR_BIT - bits_left); \ - loop_end = 0; \ - if(x >= 0) \ - { \ - (_count) += VP8_LOTS_OF_BITS; \ - loop_end = x; \ - if(!bits_left) break; \ - } \ - while(shift >= loop_end) \ - { \ - (_count) += CHAR_BIT; \ - (_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \ - shift -= CHAR_BIT; \ - } \ - } \ - while(0) \ - static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) { unsigned int bit = 0; @@ -151,4 +124,5 @@ static int vp8dx_bool_error(BOOL_DECODER *br) /* No error. */ return 0; } -#endif + +#endif // DBOOLHUFF_H_ diff --git a/vp8/decoder/decodemv.h b/vp8/decoder/decodemv.h index 940342447963e7071b31ecc3696f270391a5fe65..05a33d27f6a30c780c5bdfd587d7e267157e50f8 100644 --- a/vp8/decoder/decodemv.h +++ b/vp8/decoder/decodemv.h @@ -8,7 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#ifndef DECODEMV_H_ +#define DECODEMV_H_ #include "onyxd_int.h" void vp8_decode_mode_mvs(VP8D_COMP *); + +#endif // DECODEMV_H_ diff --git a/vp8/decoder/decoderthreading.h b/vp8/decoder/decoderthreading.h index 60c39d1e10a57f0a527513f0b69be64c2bbf3718..bc716e489e088caec3d70036c3901157e7fce6b7 100644 --- a/vp8/decoder/decoderthreading.h +++ b/vp8/decoder/decoderthreading.h @@ -8,19 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ - - - - -#ifndef _DECODER_THREADING_H -#define _DECODER_THREADING_H +#ifndef DECODERTHREADING_H_ +#define DECODERTHREADING_H_ #if CONFIG_MULTITHREAD -extern void vp8mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd); -extern void vp8_decoder_remove_threads(VP8D_COMP *pbi); -extern void vp8_decoder_create_threads(VP8D_COMP *pbi); -extern void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows); -extern void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows); +void vp8mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd); +void vp8_decoder_remove_threads(VP8D_COMP *pbi); +void vp8_decoder_create_threads(VP8D_COMP *pbi); +void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows); +void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows); #endif -#endif +#endif // DECODERTHREADING_H_ diff --git a/vp8/decoder/detokenize.h b/vp8/decoder/detokenize.h index 8640bda4c05d0885c27a9b8a42fdeb0038163c15..f2130b36178961a03f6fef6acb034d226947a7c9 100644 --- a/vp8/decoder/detokenize.h +++ b/vp8/decoder/detokenize.h @@ -8,13 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ - -#ifndef DETOKENIZE_H -#define DETOKENIZE_H +#ifndef DETOKENIZE_H_ +#define DETOKENIZE_H_ #include "onyxd_int.h" void vp8_reset_mb_tokens_context(MACROBLOCKD *x); int vp8_decode_mb_tokens(VP8D_COMP *, MACROBLOCKD *); -#endif /* DETOKENIZE_H */ +#endif // DETOKENIZE_H diff --git a/vp8/decoder/ec_types.h b/vp8/decoder/ec_types.h index ccb5ddbb9f50e30e02a34865de092550384ceccb..b24bfd9439f751a22c0579b085b906e762a092e4 100644 --- a/vp8/decoder/ec_types.h +++ b/vp8/decoder/ec_types.h @@ -14,7 +14,6 @@ #define MAX_OVERLAPS 16 - /* The area (pixel area in Q6) the block pointed to by bmi overlaps * another block with. */ @@ -48,4 +47,4 @@ typedef struct MV_REFERENCE_FRAME ref_frame; } EC_BLOCK; -#endif /* VP8_DEC_EC_TYPES_H */ +#endif // VP8_DEC_EC_TYPES_H diff --git a/vp8/decoder/error_concealment.c b/vp8/decoder/error_concealment.c index 8b2e32be638d7906fabb91c7300ffe804caaf0e2..0b58c98fd88a5a3317b352e9df1854db1db5cceb 100644 --- a/vp8/decoder/error_concealment.c +++ b/vp8/decoder/error_concealment.c @@ -8,14 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <assert.h> + #include "error_concealment.h" #include "onyxd_int.h" #include "decodemv.h" #include "vpx_mem/vpx_mem.h" #include "vp8/common/findnearmv.h" -#include <assert.h> - #define MIN(x,y) (((x)<(y))?(x):(y)) #define MAX(x,y) (((x)>(y))?(x):(y)) diff --git a/vp8/decoder/error_concealment.h b/vp8/decoder/error_concealment.h index 65ae9d9be7c3de41628998fa2115bcbd7b7c78ee..fb96b3605ec8c437e333d13ad4ac969d6974e1d8 100644 --- a/vp8/decoder/error_concealment.h +++ b/vp8/decoder/error_concealment.h @@ -9,8 +9,8 @@ */ -#ifndef ERROR_CONCEALMENT_H -#define ERROR_CONCEALMENT_H +#ifndef ERROR_CONCEALMENT_H_ +#define ERROR_CONCEALMENT_H_ #include "onyxd_int.h" #include "ec_types.h" @@ -38,4 +38,4 @@ void vp8_interpolate_motion(MACROBLOCKD *mb, */ void vp8_conceal_corrupt_mb(MACROBLOCKD *xd); -#endif +#endif // ERROR_CONCEALMENT_H_ diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h index fb2dde8527f7a5895916471c32ee1928d0b895a1..939bc3ecec1b3c3767022e280eec612886ac22b8 100644 --- a/vp8/decoder/onyxd_int.h +++ b/vp8/decoder/onyxd_int.h @@ -9,8 +9,9 @@ */ -#ifndef __INC_VP8D_INT_H -#define __INC_VP8D_INT_H +#ifndef ONYXD_INT_H_ +#define ONYXD_INT_H_ + #include "vpx_config.h" #include "vp8/common/onyxd.h" #include "treereader.h" @@ -145,4 +146,4 @@ int vp8_remove_decoder_instances(struct frame_buffers *fb); } while(0) #endif -#endif +#endif // ONYXD_INT_H_ diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c index b18cb50650b65794fd869a429ba503efaf724566..73f9a8356da610fd36209b896c9a5df9771c4ce3 100644 --- a/vp8/decoder/threading.c +++ b/vp8/decoder/threading.c @@ -36,7 +36,7 @@ } while (0) -extern void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd); +void vp8_mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd); static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_DEC *mbrd, int count) { diff --git a/vp8/decoder/treereader.h b/vp8/decoder/treereader.h index 238ff853612ed588ba9bb19800ced203bef567f1..9393bb4785700c4d3cfca9adef492faca7d7b966 100644 --- a/vp8/decoder/treereader.h +++ b/vp8/decoder/treereader.h @@ -9,18 +9,17 @@ */ -#ifndef tree_reader_h -#define tree_reader_h 1 +#ifndef TREEREADER_H_ +#define TREEREADER_H_ #include "vp8/common/treecoder.h" - #include "dboolhuff.h" typedef BOOL_DECODER vp8_reader; #define vp8_read vp8dx_decode_bool #define vp8_read_literal vp8_decode_value -#define vp8_read_bit( R) vp8_read( R, vp8_prob_half) +#define vp8_read_bit(R) vp8_read(R, vp8_prob_half) /* Intent of tree data structure is to make decoding trivial. */ @@ -38,4 +37,4 @@ static int vp8_treed_read( return -i; } -#endif /* tree_reader_h */ +#endif // TREEREADER_H_