shithub: libvpx

Download patch

ref: e8e7620a1f9330bc4e70de24f02d6f4e87cbf68f
parent: c5b0cd84059cd1cd6241aedd9c74e76965b58f91
parent: ca75f1255feb1f9885d84c6b75f9b245f171adaa
author: Dmitry Kovalev <dkovalev@google.com>
date: Mon Jul 15 20:52:53 EDT 2013

Merge "Removing and moving around constant definitions."

--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -87,6 +87,10 @@
   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;
 }
@@ -94,8 +98,6 @@
 #define VP9_INTRA_MODES (TM_PRED + 1)
 
 #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
--- 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 @@
 // 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 @@
 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));
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -52,8 +52,6 @@
 
 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 @@
 #define COEFPROB_MODELS             128
 
 #define UNCONSTRAINED_NODES         3
-#define MODEL_NODES                 (ENTROPY_NODES - UNCONSTRAINED_NODES)
 
 #define PIVOT_NODE                  2   // which node is pivot
 
@@ -199,8 +196,6 @@
                                           [UNCONSTRAINED_NODES][2];
 
 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) {
--- 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))
 
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -24,14 +24,11 @@
 #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 NUM_REF_FRAMES (1 << NUM_REF_FRAMES_LOG2)
 
-#define ALLOWED_REFS_PER_FRAME 3
-
 // 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
 // normal reference pool.
@@ -39,8 +36,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
--- 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 @@
   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;
+}
--- a/vp9/decoder/vp9_dboolhuff.h
+++ b/vp9/decoder/vp9_dboolhuff.h
@@ -22,11 +22,6 @@
 
 #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 @@
   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_
--- 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 */
--- 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;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -3593,7 +3593,7 @@
 
     // 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;