summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-02-21 13:50:15 -0800
committerDmitry Kovalev <dkovalev@google.com>2013-02-21 13:50:15 -0800
commit5a18106fb7829ecb2a6f8413ff5c34fc6419ea6e (patch)
tree2baba8dc2a9b1b6a74acc0152d971b0710846f54
parent9837bf4d407db9db9148e9c142ebd1b5cf371d35 (diff)
downloadlibvpx-5a18106fb7829ecb2a6f8413ff5c34fc6419ea6e.tar
libvpx-5a18106fb7829ecb2a6f8413ff5c34fc6419ea6e.tar.gz
libvpx-5a18106fb7829ecb2a6f8413ff5c34fc6419ea6e.tar.bz2
libvpx-5a18106fb7829ecb2a6f8413ff5c34fc6419ea6e.zip
Code cleanup.
Removing redundant 'extern' keywords. Moving VP9DX_BOOL_DECODER from .h to .c file. Change-Id: I5a3056cb3d33db7ed3c3f4629675aa8e21014e66
-rw-r--r--vp9/decoder/vp9_dboolhuff.c39
-rw-r--r--vp9/decoder/vp9_dboolhuff.h6
-rw-r--r--vp9/decoder/vp9_decodframe.h2
-rw-r--r--vp9/decoder/vp9_dequantize.h57
-rw-r--r--vp9/encoder/vp9_boolhuff.c1
-rw-r--r--vp9/encoder/vp9_encodeframe.h4
-rw-r--r--vp9/encoder/vp9_firstpass.h12
7 files changed, 68 insertions, 53 deletions
diff --git a/vp9/decoder/vp9_dboolhuff.c b/vp9/decoder/vp9_dboolhuff.c
index 5f1ef0408..82d6321c8 100644
--- a/vp9/decoder/vp9_dboolhuff.c
+++ b/vp9/decoder/vp9_dboolhuff.c
@@ -17,10 +17,10 @@ int vp9_start_decode(BOOL_DECODER *br,
const unsigned char *source,
unsigned int source_sz) {
br->user_buffer_end = source + source_sz;
- br->user_buffer = source;
- br->value = 0;
- br->count = -8;
- br->range = 255;
+ br->user_buffer = source;
+ br->value = 0;
+ br->count = -8;
+ br->range = 255;
if (source_sz && !source)
return 1;
@@ -33,16 +33,27 @@ int vp9_start_decode(BOOL_DECODER *br,
void vp9_bool_decoder_fill(BOOL_DECODER *br) {
- const unsigned char *bufptr;
- const unsigned char *bufend;
- VP9_BD_VALUE value;
- int count;
- bufend = br->user_buffer_end;
- bufptr = br->user_buffer;
- value = br->value;
- count = br->count;
-
- VP9DX_BOOL_DECODER_FILL(count, value, bufptr, bufend);
+ const unsigned char *bufptr = br->user_buffer;
+ const unsigned char *bufend = br->user_buffer_end;
+ VP9_BD_VALUE value = br->value;
+ int count = br->count;
+ int shift = VP9_BD_VALUE_SIZE - 8 - (count + 8);
+ int loop_end = 0;
+ int bits_left = (int)((bufend - bufptr)*CHAR_BIT);
+ int x = shift + CHAR_BIT - bits_left;
+
+ if (x >= 0) {
+ count += VP9_LOTS_OF_BITS;
+ loop_end = x;
+ }
+
+ if (x < 0 || bits_left) {
+ while (shift >= loop_end) {
+ count += CHAR_BIT;
+ value |= (VP9_BD_VALUE)*bufptr++ << shift;
+ shift -= CHAR_BIT;
+ }
+ }
br->user_buffer = bufptr;
br->value = value;
diff --git a/vp9/decoder/vp9_dboolhuff.h b/vp9/decoder/vp9_dboolhuff.h
index 5afdd67c8..bded15942 100644
--- a/vp9/decoder/vp9_dboolhuff.h
+++ b/vp9/decoder/vp9_dboolhuff.h
@@ -19,11 +19,11 @@
typedef size_t VP9_BD_VALUE;
-# define VP9_BD_VALUE_SIZE ((int)sizeof(VP9_BD_VALUE)*CHAR_BIT)
+#define VP9_BD_VALUE_SIZE ((int)sizeof(VP9_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 VP9_LOTS_OF_BITS (0x40000000)
+#define VP9_LOTS_OF_BITS (0x40000000)
typedef struct {
const unsigned char *user_buffer_end;
@@ -150,6 +150,6 @@ static int bool_error(BOOL_DECODER *br) {
return 0;
}
-extern int vp9_decode_unsigned_max(BOOL_DECODER *br, int max);
+int vp9_decode_unsigned_max(BOOL_DECODER *br, int max);
#endif // VP9_DECODER_VP9_DBOOLHUFF_H_
diff --git a/vp9/decoder/vp9_decodframe.h b/vp9/decoder/vp9_decodframe.h
index ae25428c4..391a26519 100644
--- a/vp9/decoder/vp9_decodframe.h
+++ b/vp9/decoder/vp9_decodframe.h
@@ -14,6 +14,6 @@
struct VP9Decompressor;
-extern void vp9_init_de_quantizer(struct VP9Decompressor *pbi);
+void vp9_init_de_quantizer(struct VP9Decompressor *pbi);
#endif // VP9_DECODER_VP9_DECODFRAME_H_
diff --git a/vp9/decoder/vp9_dequantize.h b/vp9/decoder/vp9_dequantize.h
index 848f98393..2e7c07357 100644
--- a/vp9/decoder/vp9_dequantize.h
+++ b/vp9/decoder/vp9_dequantize.h
@@ -11,34 +11,39 @@
#ifndef VP9_DECODER_VP9_DEQUANTIZE_H_
#define VP9_DECODER_VP9_DEQUANTIZE_H_
+
#include "vp9/common/vp9_blockd.h"
-extern void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
- unsigned char *pred,
- unsigned char *output,
- int pitch, int stride);
-extern void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
- unsigned char *pred,
- unsigned char *output,
- int pitch, int stride, int dc);
-extern void vp9_dequant_dc_idct_add_y_block_lossless_c(int16_t *q,
- const int16_t *dq,
- unsigned char *pre,
- unsigned char *dst,
- int stride,
- const int16_t *dc);
-extern void vp9_dequant_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
- unsigned char *pre,
- unsigned char *dst,
- int stride,
- struct macroblockd *xd);
-extern void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
- unsigned char *pre,
- unsigned char *dst_u,
- unsigned char *dst_v,
- int stride,
- struct macroblockd *xd);
+void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
+ unsigned char *pred,
+ unsigned char *output,
+ int pitch, int stride);
+
+void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
+ unsigned char *pred,
+ unsigned char *output,
+ int pitch, int stride, int dc);
+
+void vp9_dequant_dc_idct_add_y_block_lossless_c(int16_t *q,
+ const int16_t *dq,
+ unsigned char *pre,
+ unsigned char *dst,
+ int stride,
+ const int16_t *dc);
+
+void vp9_dequant_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
+ unsigned char *pre,
+ unsigned char *dst,
+ int stride,
+ struct macroblockd *xd);
+
+void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
+ unsigned char *pre,
+ unsigned char *dst_u,
+ unsigned char *dst_v,
+ int stride,
+ struct macroblockd *xd);
void vp9_ht_dequant_idct_add_c(TX_TYPE tx_type, int16_t *input, const int16_t *dq,
unsigned char *pred, unsigned char *dest,
@@ -88,4 +93,4 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
int stride,
MACROBLOCKD *xd);
-#endif
+#endif // VP9_DECODER_VP9_DEQUANTIZE_H_
diff --git a/vp9/encoder/vp9_boolhuff.c b/vp9/encoder/vp9_boolhuff.c
index d1b1e0e89..a590902c2 100644
--- a/vp9/encoder/vp9_boolhuff.c
+++ b/vp9/encoder/vp9_boolhuff.c
@@ -40,7 +40,6 @@ const unsigned int vp9_prob_cost[256] = {
};
void vp9_start_encode(BOOL_CODER *br, unsigned char *source) {
-
br->lowvalue = 0;
br->range = 255;
br->value = 0;
diff --git a/vp9/encoder/vp9_encodeframe.h b/vp9/encoder/vp9_encodeframe.h
index 1b056e163..9f13edcec 100644
--- a/vp9/encoder/vp9_encodeframe.h
+++ b/vp9/encoder/vp9_encodeframe.h
@@ -14,8 +14,8 @@
struct macroblock;
-extern void vp9_build_block_offsets(struct macroblock *x);
+void vp9_build_block_offsets(struct macroblock *x);
-extern void vp9_setup_block_ptrs(struct macroblock *x);
+void vp9_setup_block_ptrs(struct macroblock *x);
#endif // VP9_ENCODER_VP9_ENCODEFRAME_H_
diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h
index 19bc4d67d..2296a6669 100644
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -11,12 +11,12 @@
#ifndef VP9_ENCODER_VP9_FIRSTPASS_H_
#define VP9_ENCODER_VP9_FIRSTPASS_H_
-extern void vp9_init_first_pass(VP9_COMP *cpi);
-extern void vp9_first_pass(VP9_COMP *cpi);
-extern void vp9_end_first_pass(VP9_COMP *cpi);
+void vp9_init_first_pass(VP9_COMP *cpi);
+void vp9_first_pass(VP9_COMP *cpi);
+void vp9_end_first_pass(VP9_COMP *cpi);
-extern void vp9_init_second_pass(VP9_COMP *cpi);
-extern void vp9_second_pass(VP9_COMP *cpi);
-extern void vp9_end_second_pass(VP9_COMP *cpi);
+void vp9_init_second_pass(VP9_COMP *cpi);
+void vp9_second_pass(VP9_COMP *cpi);
+void vp9_end_second_pass(VP9_COMP *cpi);
#endif // VP9_ENCODER_VP9_FIRSTPASS_H_