From ca75f1255feb1f9885d84c6b75f9b245f171adaa Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Mon, 15 Jul 2013 12:26:58 -0700 Subject: Removing and moving around constant definitions. Removing unused and duplicated constants, moving them from *.h to *.c if possible. Change-Id: Ief4d6b984a3ca2e9b38504f0d855ed072cf7133f --- vp9/common/vp9_blockd.h | 6 ++++-- vp9/common/vp9_entropy.c | 7 ++++--- vp9/common/vp9_entropy.h | 5 ----- vp9/common/vp9_idct.h | 2 ++ vp9/common/vp9_onyxc_int.h | 9 ++------- vp9/decoder/vp9_dboolhuff.c | 23 +++++++++++++++++++++++ vp9/decoder/vp9_dboolhuff.h | 23 +---------------------- vp9/encoder/vp9_lookahead.c | 2 -- vp9/encoder/vp9_lookahead.h | 2 ++ vp9/encoder/vp9_rdopt.c | 2 +- 10 files changed, 39 insertions(+), 42 deletions(-) diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index c98ca90b9..213e2a068 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -87,6 +87,10 @@ typedef enum { MB_MODE_COUNT } MB_PREDICTION_MODE; +static INLINE int is_intra_mode(MB_PREDICTION_MODE mode) { + return mode <= TM_PRED; +} + static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { return mode >= NEARESTMV && mode <= NEWMV; } @@ -95,8 +99,6 @@ static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { #define VP9_INTER_MODES (1 + NEWMV - NEARESTMV) -#define WHT_UPSCALE_FACTOR 2 - /* For keyframes, intra block modes are predicted by the (already decoded) modes for the Y blocks to the left and above us; for interframes, there is a single probability table. */ diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index f5d5c1aee..5e8af6c91 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c @@ -15,6 +15,8 @@ #include "vpx_mem/vpx_mem.h" #include "vpx/vpx_integer.h" +#define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES) + DECLARE_ALIGNED(16, const uint8_t, vp9_norm[256]) = { 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -252,7 +254,7 @@ const vp9_tree_index vp9_coefmodel_tree[6] = { // the probabilities for the rest of the nodes. // beta = 8 -const vp9_prob vp9_modelcoefprobs_pareto8[COEFPROB_MODELS][MODEL_NODES] = { +static const vp9_prob modelcoefprobs_pareto8[COEFPROB_MODELS][MODEL_NODES] = { { 3, 86, 128, 6, 86, 23, 88, 29}, { 9, 86, 129, 17, 88, 61, 94, 76}, { 15, 87, 129, 28, 89, 93, 100, 110}, @@ -386,8 +388,7 @@ const vp9_prob vp9_modelcoefprobs_pareto8[COEFPROB_MODELS][MODEL_NODES] = { static void extend_model_to_full_distribution(vp9_prob p, vp9_prob *tree_probs) { const int l = ((p - 1) / 2); - const vp9_prob (*model)[MODEL_NODES]; - model = vp9_modelcoefprobs_pareto8; + const vp9_prob (*model)[MODEL_NODES] = modelcoefprobs_pareto8; if (p & 1) { vpx_memcpy(tree_probs + UNCONSTRAINED_NODES, model[l], MODEL_NODES * sizeof(vp9_prob)); diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 68c36eaef..1da846dce 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -52,8 +52,6 @@ typedef struct { extern vp9_extra_bit vp9_extra_bits[12]; /* indexed by token value */ -#define PROB_UPDATE_BASELINE_COST 7 - #define MAX_PROB 255 #define DCT_MAX_VALUE 16384 @@ -183,7 +181,6 @@ const int16_t *vp9_get_coef_neighbors_handle(const int16_t *scan); #define COEFPROB_MODELS 128 #define UNCONSTRAINED_NODES 3 -#define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES) #define PIVOT_NODE 2 // which node is pivot @@ -200,8 +197,6 @@ typedef unsigned int vp9_coeff_stats_model[REF_TYPES][COEF_BANDS] void vp9_model_to_full_probs(const vp9_prob *model, vp9_prob *full); -extern const vp9_prob vp9_modelcoefprobs[COEFPROB_MODELS][ENTROPY_NODES - 1]; - static INLINE const int16_t* get_scan_4x4(TX_TYPE tx_type) { switch (tx_type) { case ADST_DCT: diff --git a/vp9/common/vp9_idct.h b/vp9/common/vp9_idct.h index 279b580a3..2d959f0ea 100644 --- a/vp9/common/vp9_idct.h +++ b/vp9/common/vp9_idct.h @@ -22,6 +22,8 @@ #define DCT_CONST_BITS 14 #define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1)) +#define WHT_UPSCALE_FACTOR 2 + #define pair_set_epi16(a, b) \ _mm_set1_epi32(((uint16_t)(a)) + (((uint16_t)(b)) << 16)) diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 46fcb2f2c..ad4471af5 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -24,13 +24,10 @@ #include "vp9/common/vp9_postproc.h" #endif -/* Create/destroy static data structures. */ +#define ALLOWED_REFS_PER_FRAME 3 -// Define the number of candidate reference buffers. -#define NUM_REF_FRAMES 8 #define NUM_REF_FRAMES_LOG2 3 - -#define ALLOWED_REFS_PER_FRAME 3 +#define NUM_REF_FRAMES (1 << NUM_REF_FRAMES_LOG2) // 1 scratch frame for the new frame, 3 for scaled references on the encoder // TODO(jkoleszar): These 3 extra references could probably come from the @@ -40,8 +37,6 @@ #define NUM_FRAME_CONTEXTS_LOG2 2 #define NUM_FRAME_CONTEXTS (1 << NUM_FRAME_CONTEXTS_LOG2) -#define MAX_LAG_BUFFERS 25 - typedef struct frame_contexts { // y_mode, uv_mode, partition vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES - 1]; diff --git a/vp9/decoder/vp9_dboolhuff.c b/vp9/decoder/vp9_dboolhuff.c index df77d650d..31b1ae2b0 100644 --- a/vp9/decoder/vp9_dboolhuff.c +++ b/vp9/decoder/vp9_dboolhuff.c @@ -13,6 +13,12 @@ #include "vp9/decoder/vp9_dboolhuff.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 VP9_LOTS_OF_BITS 0x40000000 + + int vp9_reader_init(vp9_reader *r, const uint8_t *buffer, size_t size) { int marker_bit; @@ -67,3 +73,20 @@ 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 VP9_LOTS_OF_BITS. So when + // count == VP9_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 > VP9_BD_VALUE_SIZE && r->count < VP9_LOTS_OF_BITS; +} diff --git a/vp9/decoder/vp9_dboolhuff.h b/vp9/decoder/vp9_dboolhuff.h index b50aa35fd..c46dd73a3 100644 --- a/vp9/decoder/vp9_dboolhuff.h +++ b/vp9/decoder/vp9_dboolhuff.h @@ -22,11 +22,6 @@ typedef size_t VP9_BD_VALUE; #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 - typedef struct { const uint8_t *buffer_end; const uint8_t *buffer; @@ -93,22 +88,6 @@ static int vp9_read_literal(vp9_reader *br, int bits) { return z; } -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 - // 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 VP9_LOTS_OF_BITS. So when - // count == VP9_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 > VP9_BD_VALUE_SIZE && r->count < VP9_LOTS_OF_BITS; -} +int vp9_reader_has_error(vp9_reader *r); #endif // VP9_DECODER_VP9_DBOOLHUFF_H_ diff --git a/vp9/encoder/vp9_lookahead.c b/vp9/encoder/vp9_lookahead.c index b07d92a44..81445a97f 100644 --- a/vp9/encoder/vp9_lookahead.c +++ b/vp9/encoder/vp9_lookahead.c @@ -15,8 +15,6 @@ #include "vp9/encoder/vp9_lookahead.h" #include "vp9/common/vp9_extend.h" -#define MAX_LAG_BUFFERS 25 - struct lookahead_ctx { unsigned int max_sz; /* Absolute size of the queue */ unsigned int sz; /* Number of buffers currently in the queue */ diff --git a/vp9/encoder/vp9_lookahead.h b/vp9/encoder/vp9_lookahead.h index 81baa2c6f..c773f8fcc 100644 --- a/vp9/encoder/vp9_lookahead.h +++ b/vp9/encoder/vp9_lookahead.h @@ -14,6 +14,8 @@ #include "vpx_scale/yv12config.h" #include "vpx/vpx_integer.h" +#define MAX_LAG_BUFFERS 25 + struct lookahead_entry { YV12_BUFFER_CONFIG img; int64_t ts_start; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index ff671aeea..91f606a1c 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -3593,7 +3593,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, // Keep record of best intra rd if (xd->mode_info_context->mbmi.ref_frame[0] == INTRA_FRAME && - xd->mode_info_context->mbmi.mode <= TM_PRED && + is_intra_mode(xd->mode_info_context->mbmi.mode) && this_rd < best_intra_rd) { best_intra_rd = this_rd; best_intra_mode = xd->mode_info_context->mbmi.mode; -- cgit v1.2.3