Merge "Don't allow very short GF groups even when the GF is predicted from an ARF."
authorJohn Koleszar <jkoleszar@google.com>
Mon, 6 Jun 2011 14:02:29 +0000 (07:02 -0700)
committerCode Review <code-review@webmproject.org>
Mon, 6 Jun 2011 14:02:29 +0000 (07:02 -0700)
16 files changed:
vp8/common/blockd.h
vp8/decoder/decodemv.c
vp8/decoder/decodframe.c
vp8/decoder/onyxd_if.c
vp8/decoder/threading.c
vp8/encoder/bitstream.c
vp8/encoder/block.h
vp8/encoder/encodeframe.c
vp8/encoder/encodeintra.c
vp8/encoder/ethreading.c
vp8/encoder/firstpass.c
vp8/encoder/mcomp.c
vp8/encoder/onyx_if.c
vp8/encoder/pickinter.c
vp8/encoder/rdopt.c
vp8/encoder/temporal_filter.c

index 3a70b18..be99256 100644 (file)
@@ -137,12 +137,6 @@ typedef enum
    modes for the Y blocks to the left and above us; for interframes, there
    is a single probability table. */
 
-typedef struct
-{
-    B_PREDICTION_MODE mode;
-    int_mv mv;
-} B_MODE_INFO;
-
 union b_mode_info
 {
     B_PREDICTION_MODE as_mode;
@@ -182,8 +176,6 @@ typedef struct
     short *dqcoeff;
     unsigned char  *predictor;
     short *diff;
-    short *reference;
-
     short *dequant;
 
     /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
@@ -197,14 +189,13 @@ typedef struct
 
     int eob;
 
-    B_MODE_INFO bmi;
+    union b_mode_info bmi;
 } BLOCKD;
 
 typedef struct
 {
     DECLARE_ALIGNED(16, short, diff[400]);      /* from idct diff */
     DECLARE_ALIGNED(16, unsigned char,  predictor[384]);
-/* not used    DECLARE_ALIGNED(16, short, reference[384]); */
     DECLARE_ALIGNED(16, short, qcoeff[400]);
     DECLARE_ALIGNED(16, short, dqcoeff[400]);
     DECLARE_ALIGNED(16, char,  eobs[25]);
@@ -284,19 +275,15 @@ extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
 static void update_blockd_bmi(MACROBLOCKD *xd)
 {
     int i;
-    if (xd->mode_info_context->mbmi.mode == SPLITMV)
-    {
-        for (i = 0; i < 16; i++)
-        {
-            BLOCKD *d = &xd->block[i];
-            d->bmi.mv.as_int = xd->mode_info_context->bmi[i].mv.as_int;
-        }
-    }else if (xd->mode_info_context->mbmi.mode == B_PRED)
+    int is_4x4;
+    is_4x4 = (xd->mode_info_context->mbmi.mode == SPLITMV) ||
+              (xd->mode_info_context->mbmi.mode == B_PRED);
+
+    if (is_4x4)
     {
         for (i = 0; i < 16; i++)
         {
-            BLOCKD *d = &xd->block[i];
-            d->bmi.mode = xd->mode_info_context->bmi[i].as_mode;
+            xd->block[i].bmi = xd->mode_info_context->bmi[i];
         }
     }
 }
index 5defa75..d569d88 100644 (file)
@@ -355,7 +355,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
             do  /* for each subset j */
             {
                 int_mv leftmv, abovemv;
-                B_MODE_INFO bmi;
+                int_mv blockmv;
                 int k;  /* first block in subset j */
                 int mv_contz;
                 k = vp8_mbsplit_offset[s][j];
@@ -364,30 +364,30 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
                 abovemv.as_int = above_block_mv(mi, k, mis);
                 mv_contz = vp8_mv_cont(&leftmv, &abovemv);
 
-                switch (bmi.mode = (B_PREDICTION_MODE) sub_mv_ref(bc, vp8_sub_mv_ref_prob2 [mv_contz])) /*pc->fc.sub_mv_ref_prob))*/
+                switch ((B_PREDICTION_MODE) sub_mv_ref(bc, vp8_sub_mv_ref_prob2 [mv_contz])) /*pc->fc.sub_mv_ref_prob))*/
                 {
                 case NEW4X4:
-                    read_mv(bc, &bmi.mv.as_mv, (const MV_CONTEXT *) mvc);
-                    bmi.mv.as_mv.row += best_mv.as_mv.row;
-                    bmi.mv.as_mv.col += best_mv.as_mv.col;
+                    read_mv(bc, &blockmv.as_mv, (const MV_CONTEXT *) mvc);
+                    blockmv.as_mv.row += best_mv.as_mv.row;
+                    blockmv.as_mv.col += best_mv.as_mv.col;
   #ifdef VPX_MODE_COUNT
                     vp8_mv_cont_count[mv_contz][3]++;
   #endif
                     break;
                 case LEFT4X4:
-                    bmi.mv.as_int = leftmv.as_int;
+                    blockmv.as_int = leftmv.as_int;
   #ifdef VPX_MODE_COUNT
                     vp8_mv_cont_count[mv_contz][0]++;
   #endif
                     break;
                 case ABOVE4X4:
-                    bmi.mv.as_int = abovemv.as_int;
+                    blockmv.as_int = abovemv.as_int;
   #ifdef VPX_MODE_COUNT
                     vp8_mv_cont_count[mv_contz][1]++;
   #endif
                     break;
                 case ZERO4X4:
-                    bmi.mv.as_int = 0;
+                    blockmv.as_int = 0;
   #ifdef VPX_MODE_COUNT
                     vp8_mv_cont_count[mv_contz][2]++;
   #endif
@@ -396,7 +396,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
                     break;
                 }
 
-                mbmi->need_to_clamp_mvs = vp8_check_mv_bounds(&bmi.mv,
+                mbmi->need_to_clamp_mvs = vp8_check_mv_bounds(&blockmv,
                                                           mb_to_left_edge,
                                                           mb_to_right_edge,
                                                           mb_to_top_edge,
@@ -412,7 +412,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
                     fill_offset = &mbsplit_fill_offset[s][(unsigned char)j * mbsplit_fill_count[s]];
 
                     do {
-                        mi->bmi[ *fill_offset].mv.as_int = bmi.mv.as_int;
+                        mi->bmi[ *fill_offset].mv.as_int = blockmv.as_int;
                         fill_offset++;
                     }while (--fill_count);
                 }
index 80e8723..fec5172 100644 (file)
@@ -288,7 +288,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
 
             BLOCKD *b = &xd->block[i];
             RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict)
-                         (b, b->bmi.mode, b->predictor);
+                          (b, b->bmi.as_mode, b->predictor);
 
             if (xd->eobs[i] > 1)
             {
@@ -974,8 +974,6 @@ int vp8_decode_frame(VP8D_COMP *pbi)
 
     vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
 
-    vpx_memcpy(&xd->block[0].bmi, &xd->mode_info_context->bmi[0], sizeof(B_MODE_INFO));
-
 #if CONFIG_MULTITHREAD
     if (pbi->b_multithreaded_rd && pc->multi_token_partition != ONE_PARTITION)
     {
index d10b2cb..23a3c7d 100644 (file)
@@ -24,6 +24,7 @@
 #include "vp8/common/threading.h"
 #include "decoderthreading.h"
 #include <stdio.h>
+#include <assert.h>
 
 #include "vp8/common/quant_common.h"
 #include "vpx_scale/vpxscale.h"
@@ -161,16 +162,19 @@ int vp8dx_set_reference(VP8D_PTR ptr, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_C
     int free_fb;
 
     if (ref_frame_flag == VP8_LAST_FLAG)
-        *ref_fb_ptr = cm->lst_fb_idx;
+        ref_fb_ptr = &cm->lst_fb_idx;
     else if (ref_frame_flag == VP8_GOLD_FLAG)
-        *ref_fb_ptr = cm->gld_fb_idx;
+        ref_fb_ptr = &cm->gld_fb_idx;
     else if (ref_frame_flag == VP8_ALT_FLAG)
-        *ref_fb_ptr = cm->alt_fb_idx;
+        ref_fb_ptr = &cm->alt_fb_idx;
     else
         return -1;
 
     /* Find an empty frame buffer. */
     free_fb = get_free_fb(cm);
+    /* Decrease fb_idx_ref_cnt since it will be increased again in
+     * ref_cnt_fb() below. */
+    cm->fb_idx_ref_cnt[free_fb]--;
 
     /* Manage the reference counters and copy image. */
     ref_cnt_fb (cm->fb_idx_ref_cnt, ref_fb_ptr, free_fb);
@@ -192,6 +196,7 @@ static int get_free_fb (VP8_COMMON *cm)
         if (cm->fb_idx_ref_cnt[i] == 0)
             break;
 
+    assert(i < NUM_YV12_BUFFERS);
     cm->fb_idx_ref_cnt[i] = 1;
     return i;
 }
index 4ca53fb..77c3f17 100644 (file)
@@ -186,7 +186,9 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int m
         for (i = 0; i < 16; i++)
         {
             BLOCKD *b = &xd->block[i];
-            vp8mt_predict_intra4x4(pbi, xd, b->bmi.mode, b->predictor, mb_row, mb_col, i);
+
+            vp8mt_predict_intra4x4(pbi, xd, b->bmi.as_mode, b->predictor, mb_row, mb_col, i);
+
             if (xd->eobs[i] > 1)
             {
                 DEQUANT_INVOKE(&pbi->dequant, idct_add)
index b10f8c0..ced9635 100644 (file)
@@ -1008,28 +1008,32 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
 
                     do
                     {
-                        const B_MODE_INFO *const b = cpi->mb.partition_info->bmi + j;
+                        B_PREDICTION_MODE blockmode;
+                        int_mv blockmv;
                         const int *const  L = vp8_mbsplits [mi->partitioning];
                         int k = -1;  /* first block in subset j */
                         int mv_contz;
                         int_mv leftmv, abovemv;
 
+                        blockmode =  cpi->mb.partition_info->bmi[j].mode;
+                        blockmv =  cpi->mb.partition_info->bmi[j].mv;
 
                         while (j != L[++k])
                             if (k >= 16)
                                 assert(0);
+
                         leftmv.as_int = left_block_mv(m, k);
                         abovemv.as_int = above_block_mv(m, k, mis);
                         mv_contz = vp8_mv_cont(&leftmv, &abovemv);
 
-                        write_sub_mv_ref(w, b->mode, vp8_sub_mv_ref_prob2 [mv_contz]); //pc->fc.sub_mv_ref_prob);
+                        write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_contz]);
 
-                        if (b->mode == NEW4X4)
+                        if (blockmode == NEW4X4)
                         {
 #ifdef ENTROPY_STATS
                             active_section = 11;
 #endif
-                            write_mv(w, &b->mv.as_mv, &best_mv, (const MV_CONTEXT *) mvc);
+                            write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONTEXT *) mvc);
                         }
                     }
                     while (++j < cpi->mb.partition_info->count);
index fbdc89e..bc6eeeb 100644 (file)
@@ -54,7 +54,11 @@ typedef struct
 typedef struct
 {
     int count;
-    B_MODE_INFO bmi[16];
+    struct
+    {
+        B_PREDICTION_MODE mode;
+        int_mv mv;
+    } bmi[16];
 } PARTITION_INFO;
 
 typedef struct
index 1bb0260..f72fccc 100644 (file)
@@ -272,6 +272,7 @@ static void build_activity_map( VP8_COMP *cpi )
 // Activity masking based on Tim T's original code
 void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x)
 {
+
     unsigned int a;
     unsigned int b;
     unsigned int act = *(x->mb_activity_ptr);
@@ -477,24 +478,9 @@ void encode_mb_row(VP8_COMP *cpi,
         x->mb_activity_ptr++;
         x->mb_norm_activity_ptr++;
 
-        if(cm->frame_type != INTRA_FRAME)
-        {
-            if (xd->mode_info_context->mbmi.mode != B_PRED)
-            {
-                for (i = 0; i < 16; i++)
-                    xd->mode_info_context->bmi[i].mv.as_int = xd->block[i].bmi.mv.as_int;
-            }else
-            {
-                for (i = 0; i < 16; i++)
-                    xd->mode_info_context->bmi[i].as_mode = xd->block[i].bmi.mode;
-            }
-        }
-        else
-        {
-            if(xd->mode_info_context->mbmi.mode != B_PRED)
-                for (i = 0; i < 16; i++)
-                    xd->mode_info_context->bmi[i].as_mode = xd->block[i].bmi.mode;
-        }
+        /* save the block info */
+        for (i = 0; i < 16; i++)
+            xd->mode_info_context->bmi[i] = xd->block[i].bmi;
 
         // adjust to the next column of macroblocks
         x->src.y_buffer += 16;
index 835c80d..5da69bc 100644 (file)
@@ -36,7 +36,7 @@ void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd,
     BLOCK *be = &x->block[ib];
 
     RECON_INVOKE(&rtcd->common->recon, intra4x4_predict)
-                (b, b->bmi.mode, b->predictor);
+                (b, b->bmi.as_mode, b->predictor);
 
     ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
 
@@ -89,19 +89,19 @@ void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
         switch (x->e_mbd.mode_info_context->mbmi.mode)
         {
         case DC_PRED:
-            d->bmi.mode = B_DC_PRED;
+            d->bmi.as_mode = B_DC_PRED;
             break;
         case V_PRED:
-            d->bmi.mode = B_VE_PRED;
+            d->bmi.as_mode = B_VE_PRED;
             break;
         case H_PRED:
-            d->bmi.mode = B_HE_PRED;
+            d->bmi.as_mode = B_HE_PRED;
             break;
         case TM_PRED:
-            d->bmi.mode = B_TM_PRED;
+            d->bmi.as_mode = B_TM_PRED;
             break;
         default:
-            d->bmi.mode = B_DC_PRED;
+            d->bmi.as_mode = B_DC_PRED;
             break;
         }
     }
index 1d92f20..3e6ed2a 100644 (file)
@@ -232,23 +232,9 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
                     x->mb_activity_ptr++;
                     x->mb_norm_activity_ptr++;
 
-                    if(cm->frame_type != INTRA_FRAME)
-                    {
-                        if (xd->mode_info_context->mbmi.mode != B_PRED)
-                        {
-                            for (i = 0; i < 16; i++)
-                                xd->mode_info_context->bmi[i].mv.as_int = xd->block[i].bmi.mv.as_int;
-                        }else
-                        {
-                            for (i = 0; i < 16; i++)
-                                xd->mode_info_context->bmi[i].as_mode = xd->block[i].bmi.mode;
-                        }
-                    }
-                    else {
-                        if(xd->mode_info_context->mbmi.mode != B_PRED)
-                            for (i = 0; i < 16; i++)
-                                xd->mode_info_context->bmi[i].as_mode = xd->block[i].bmi.mode;
-                    }
+                    /* save the block info */
+                    for (i = 0; i < 16; i++)
+                        xd->mode_info_context->bmi[i] = xd->block[i].bmi;
 
                     // adjust to the next column of macroblocks
                     x->src.y_buffer += 16;
index 7c07c9b..7b48695 100644 (file)
@@ -100,7 +100,7 @@ static int encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred)
     {
         for (i = 0; i < 16; i++)
         {
-            x->e_mbd.block[i].bmi.mode = B_DC_PRED;
+            x->e_mbd.block[i].bmi.as_mode = B_DC_PRED;
             vp8_encode_intra4x4block(IF_RTCD(&cpi->rtcd), x, i);
         }
     }
@@ -449,7 +449,9 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
 
     // Initial step/diamond search centred on best mv
     tmp_mv.as_int = 0;
-    tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param, x->errorperbit, &num00, &v_fn_ptr, x->mvcost, ref_mv);
+    tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param,
+                                      x->sadperbit16, &num00, &v_fn_ptr,
+                                      x->mvcost, ref_mv);
     if ( tmp_err < INT_MAX-new_mv_mode_penalty )
         tmp_err += new_mv_mode_penalty;
 
@@ -472,7 +474,10 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
             num00--;
         else
         {
-            tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param + n, x->errorperbit, &num00, &v_fn_ptr, x->mvcost, ref_mv);
+            tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv,
+                                              step_param + n, x->sadperbit16,
+                                              &num00, &v_fn_ptr, x->mvcost,
+                                              ref_mv);
             if ( tmp_err < INT_MAX-new_mv_mode_penalty )
                 tmp_err += new_mv_mode_penalty;
 
index 3ff5c6c..50c4745 100644 (file)
@@ -875,7 +875,9 @@ int vp8_hex_search
     this_offset = base_offset + (br * (d->pre_stride)) + bc;
     this_mv.as_mv.row = br;
     this_mv.as_mv.col = bc;
-    bestsad = vfp->sdf( what, what_stride, this_offset, in_what_stride, 0x7fffffff) + mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+    bestsad = vfp->sdf( what, what_stride, this_offset,
+                        in_what_stride, 0x7fffffff)
+            + mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
 
     // hex search
     //j=0
@@ -998,7 +1000,8 @@ cal_neighbors:
     this_mv.as_mv.col = bc<<3;
 
     this_offset = (unsigned char *)(*(d->base_pre) + d->pre + (br * (in_what_stride)) + bc);
-    return vfp->vf(what, what_stride, this_offset, in_what_stride, &bestsad) + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit) ;
+    return vfp->vf(what, what_stride, this_offset, in_what_stride, &bestsad)
+        + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit) ;
 }
 #undef CHECK_BOUNDS
 #undef CHECK_POINT
@@ -1062,7 +1065,9 @@ int vp8_diamond_search_sad
     (ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
     {
         // Check the starting position
-        bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+        bestsad = fn_ptr->sdf(what, what_stride, in_what,
+                              in_what_stride, 0x7fffffff)
+                + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
     }
 
     // search_param determines the length of the initial step and hence the number of iterations
@@ -1091,7 +1096,8 @@ int vp8_diamond_search_sad
                 {
                     this_mv.as_mv.row = this_row_offset;
                     this_mv.as_mv.col = this_col_offset;
-                    thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                    thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                                mvsadcost, sad_per_bit);
 
                     if (thissad < bestsad)
                     {
@@ -1182,7 +1188,9 @@ int vp8_diamond_search_sadx4
     (ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
     {
         // Check the starting position
-        bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+        bestsad = fn_ptr->sdf(what, what_stride,
+                              in_what, in_what_stride, 0x7fffffff)
+                + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
     }
 
     // search_param determines the length of the initial step and hence the number of iterations
@@ -1222,7 +1230,8 @@ int vp8_diamond_search_sadx4
                     {
                         this_mv.as_mv.row = best_mv->as_mv.row + ss[i].mv.row;
                         this_mv.as_mv.col = best_mv->as_mv.col + ss[i].mv.col;
-                        sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                        sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                                       mvsadcost, sad_per_bit);
 
                         if (sad_array[t] < bestsad)
                         {
@@ -1251,7 +1260,8 @@ int vp8_diamond_search_sadx4
                     {
                         this_mv.as_mv.row = this_row_offset;
                         this_mv.as_mv.col = this_col_offset;
-                        thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                        thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                                   mvsadcost, sad_per_bit);
 
                         if (thissad < bestsad)
                         {
@@ -1331,7 +1341,9 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
         // Baseline value at the centre
 
         //bestsad = fn_ptr->sf( what,what_stride,bestaddress,in_what_stride) + (int)sqrt(mv_err_cost(ref_mv,ref_mv, mvcost,error_per_bit*14));
-        bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+        bestsad = fn_ptr->sdf(what, what_stride, bestaddress,
+                              in_what_stride, 0x7fffffff)
+                + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
     }
 
     // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
@@ -1357,7 +1369,8 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
             thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
 
             this_mv.as_mv.col = c;
-            thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+            thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                        mvsadcost, sad_per_bit);
 
             if (thissad < bestsad)
             {
@@ -1427,7 +1440,9 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
     (ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
     {
         // Baseline value at the centre
-        bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+        bestsad = fn_ptr->sdf(what, what_stride,
+                              bestaddress, in_what_stride, 0x7fffffff)
+                + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
     }
 
     // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
@@ -1462,7 +1477,8 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
                 if (thissad < bestsad)
                 {
                     this_mv.as_mv.col = c;
-                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                                mvsadcost, sad_per_bit);
 
                     if (thissad < bestsad)
                     {
@@ -1485,7 +1501,8 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
             if (thissad < bestsad)
             {
                 this_mv.as_mv.col = c;
-                thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                            mvsadcost, sad_per_bit);
 
                 if (thissad < bestsad)
                 {
@@ -1559,7 +1576,9 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
     (ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
     {
         // Baseline value at the centre
-        bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+        bestsad = fn_ptr->sdf(what, what_stride,
+                              bestaddress, in_what_stride, 0x7fffffff)
+                + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
     }
 
     // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
@@ -1594,7 +1613,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
                 if (thissad < bestsad)
                 {
                     this_mv.as_mv.col = c;
-                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                                                mvsadcost, sad_per_bit);
 
                     if (thissad < bestsad)
                     {
@@ -1623,7 +1643,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
                 if (thissad < bestsad)
                 {
                     this_mv.as_mv.col = c;
-                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                    thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                        mvsadcost, sad_per_bit);
 
                     if (thissad < bestsad)
                     {
@@ -1646,7 +1667,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
             if (thissad < bestsad)
             {
                 this_mv.as_mv.col = c;
-                thissad  += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
+                thissad  += mvsad_err_cost(&this_mv, &fcenter_mv,
+                    mvsadcost, sad_per_bit);
 
                 if (thissad < bestsad)
                 {
index 2363c9d..bf074c6 100644 (file)
@@ -1947,13 +1947,13 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
         cpi->total_ssimg_all = 0;
     }
 
+#endif
+
 #ifndef LLONG_MAX
 #define LLONG_MAX  9223372036854775807LL
 #endif
     cpi->first_time_stamp_ever = LLONG_MAX;
 
-#endif
-
     cpi->frames_till_gf_update_due      = 0;
     cpi->key_frame_count              = 1;
 
index d1dc7ae..e6716fa 100644 (file)
@@ -47,7 +47,6 @@ extern unsigned int (*vp8_get16x16pred_error)(unsigned char *src_ptr, int src_st
 extern unsigned int (*vp8_get4x4sse_cs)(unsigned char *src_ptr, int  source_stride, unsigned char *ref_ptr, int  recon_stride);
 extern int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, MV *best_ref_mv, int best_rd, int *, int *, int *, int, int *mvcost[2], int, int fullpixel);
 extern int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]);
-extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv);
 
 
 int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d,
@@ -71,7 +70,10 @@ int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d,
 }
 
 
-static int get_inter_mbpred_error(MACROBLOCK *mb, const vp8_variance_fn_ptr_t *vfp, unsigned int *sse)
+static int get_inter_mbpred_error(MACROBLOCK *mb,
+                                  const vp8_variance_fn_ptr_t *vfp,
+                                  unsigned int *sse,
+                                  int_mv this_mv)
 {
 
     BLOCK *b = &mb->block[0];
@@ -80,10 +82,10 @@ static int get_inter_mbpred_error(MACROBLOCK *mb, const vp8_variance_fn_ptr_t *v
     int what_stride = b->src_stride;
     unsigned char *in_what = *(d->base_pre) + d->pre ;
     int in_what_stride = d->pre_stride;
-    int xoffset = d->bmi.mv.as_mv.col & 7;
-    int yoffset = d->bmi.mv.as_mv.row & 7;
+    int xoffset = this_mv.as_mv.col & 7;
+    int yoffset = this_mv.as_mv.row & 7;
 
-    in_what += (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+    in_what += (this_mv.as_mv.row >> 3) * d->pre_stride + (this_mv.as_mv.col >> 3);
 
     if (xoffset | yoffset)
     {
@@ -212,7 +214,8 @@ static int pick_intra4x4block(
             *best_mode = mode;
         }
     }
-    b->bmi.mode = (B_PREDICTION_MODE)(*best_mode);
+
+    b->bmi.as_mode = (B_PREDICTION_MODE)(*best_mode);
     vp8_encode_intra4x4block(rtcd, x, ib);
     return best_rd;
 }
@@ -248,7 +251,7 @@ int vp8_pick_intra4x4mby_modes
 
         cost += r;
         distortion += d;
-        mic->bmi[i].as_mode = xd->block[i].bmi.mode = best_mode;
+        mic->bmi[i].as_mode = best_mode;
 
         // Break out case where we have already exceeded best so far value
         // that was passed in
@@ -440,7 +443,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
     BLOCK *b = &x->block[0];
     BLOCKD *d = &x->e_mbd.block[0];
     MACROBLOCKD *xd = &x->e_mbd;
-    B_MODE_INFO best_bmodes[16];
+    union b_mode_info best_bmodes[16];
     MB_MODE_INFO best_mbmode;
 
     int_mv best_ref_mv;
@@ -482,6 +485,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
     vpx_memset(nearest_mv, 0, sizeof(nearest_mv));
     vpx_memset(near_mv, 0, sizeof(near_mv));
     vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
+    vpx_memset(&best_bmodes, 0, sizeof(best_bmodes));
 
 
     // set up all the refframe dependent pointers.
@@ -733,36 +737,41 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
                 //adjust search range according to sr from mv prediction
                 if(sr > step_param)
                     step_param = sr;
-
-                col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
-                col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
-                row_min = (best_ref_mv.as_mv.row - MAX_FULL_PEL_VAL) >>3;
-                row_max = (best_ref_mv.as_mv.row + MAX_FULL_PEL_VAL) >>3;
-
-                // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
-                if (x->mv_col_min < col_min )
-                    x->mv_col_min = col_min;
-                if (x->mv_col_max > col_max )
-                    x->mv_col_max = col_max;
-                if (x->mv_row_min < row_min )
-                    x->mv_row_min = row_min;
-                if (x->mv_row_max > row_max )
-                    x->mv_row_max = row_max;
             }else
             {
                 mvp.as_int = best_ref_mv.as_int;
             }
 
+            col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
+            col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
+            row_min = (best_ref_mv.as_mv.row - MAX_FULL_PEL_VAL) >>3;
+            row_max = (best_ref_mv.as_mv.row + MAX_FULL_PEL_VAL) >>3;
+
+            // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
+            if (x->mv_col_min < col_min )
+                x->mv_col_min = col_min;
+            if (x->mv_col_max > col_max )
+                x->mv_col_max = col_max;
+            if (x->mv_row_min < row_min )
+                x->mv_row_min = row_min;
+            if (x->mv_row_max > row_max )
+                x->mv_row_max = row_max;
+
             further_steps = (cpi->Speed >= 8)? 0: (cpi->sf.max_step_search_steps - 1 - step_param);
 
             if (cpi->sf.search_method == HEX)
             {
-                bestsme = vp8_hex_search(x, b, d, &mvp, &d->bmi.mv, step_param, sadpb/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv);
+                bestsme = vp8_hex_search(x, b, d, &mvp, &d->bmi.mv, step_param,
+                                      sadpb, &num00, &cpi->fn_ptr[BLOCK_16X16],
+                                      x->mvsadcost, x->mvcost, &best_ref_mv);
                 mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
             }
             else
             {
-                bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb < 9
+                bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv,
+                                      step_param, sadpb, &num00,
+                                      &cpi->fn_ptr[BLOCK_16X16],
+                                      x->mvcost, &best_ref_mv);
                 mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
 
                 // Further step/diamond searches as necessary
@@ -784,7 +793,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
                         cpi->diamond_search_sad(x, b, d, &mvp,
                                                 &d->bmi.mv,
                                                 step_param + n,
-                                                sadpb / 4, &num00,
+                                                sadpb, &num00,
                                                 &cpi->fn_ptr[BLOCK_16X16],
                                                 x->mvcost, &best_ref_mv);
                         if (thissme < bestsme)
@@ -800,16 +809,17 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
                 }
             }
 
-            if(cpi->sf.improved_mv_pred)
-            {
-                x->mv_col_min = tmp_col_min;
-                x->mv_col_max = tmp_col_max;
-                x->mv_row_min = tmp_row_min;
-                x->mv_row_max = tmp_row_max;
-            }
+            x->mv_col_min = tmp_col_min;
+            x->mv_col_max = tmp_col_max;
+            x->mv_row_min = tmp_row_min;
+            x->mv_row_max = tmp_row_max;
 
             if (bestsme < INT_MAX)
-                cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost, &distortion2, &sse);
+                cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,
+                                             x->errorperbit,
+                                             &cpi->fn_ptr[BLOCK_16X16],
+                                             cpi->mb.mvcost,
+                                             &distortion2,&sse);
 
             mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
 
@@ -833,13 +843,14 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
                 continue;
 
             rate2 += vp8_cost_mv_ref(this_mode, mdcounts);
-            x->e_mbd.mode_info_context->mbmi.mode = this_mode;
-            x->e_mbd.mode_info_context->mbmi.mv.as_mv = mode_mv[this_mode].as_mv;
-            x->e_mbd.block[0].bmi.mode = this_mode;
-            x->e_mbd.block[0].bmi.mv.as_int = x->e_mbd.mode_info_context->mbmi.mv.as_int;
+            x->e_mbd.mode_info_context->mbmi.mv.as_int =
+                                                    mode_mv[this_mode].as_int;
 
-            if((this_mode != NEWMV) || !(have_subp_search) || cpi->common.full_pixel==1)
-                distortion2 = get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], &sse);
+            if((this_mode != NEWMV) ||
+                !(have_subp_search) || cpi->common.full_pixel==1)
+                distortion2 = get_inter_mbpred_error(x,
+                                                     &cpi->fn_ptr[BLOCK_16X16],
+                                                     &sse, mode_mv[this_mode]);
 
             this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
 
@@ -881,12 +892,8 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
             if (this_mode == B_PRED)
                 for (i = 0; i < 16; i++)
                 {
-                    vpx_memcpy(&best_bmodes[i], &x->e_mbd.block[i].bmi, sizeof(B_MODE_INFO));
+                     best_bmodes[i].as_mode = x->e_mbd.block[i].bmi.as_mode;
                 }
-            else
-            {
-                best_bmodes[0].mv = x->e_mbd.block[0].bmi.mv;
-            }
 
             // Testing this mode gave rise to an improvement in best error score. Lower threshold a bit for next time
             cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
@@ -917,13 +924,6 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
         cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
     }
 
-    if (best_mbmode.mode <= B_PRED)
-    {
-        x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-        vp8_pick_intra_mbuv_mode(x);
-        best_mbmode.uv_mode = x->e_mbd.mode_info_context->mbmi.uv_mode;
-    }
-
 
     {
         int this_rdbin = (*returndistortion >> 7);
@@ -936,40 +936,35 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
         cpi->error_bins[this_rdbin] ++;
     }
 
-
-    if (cpi->is_src_frame_alt_ref && (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
+    if (cpi->is_src_frame_alt_ref &&
+        (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
     {
-        best_mbmode.mode = ZEROMV;
-        best_mbmode.ref_frame = ALTREF_FRAME;
-        best_mbmode.mv.as_int = 0;
-        best_mbmode.uv_mode = 0;
-        best_mbmode.mb_skip_coeff = (cpi->common.mb_no_coeff_skip) ? 1 : 0;
-        best_mbmode.partitioning = 0;
-
-        vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
-
-        for (i = 0; i < 16; i++)
-        {
-            vpx_memset(&x->e_mbd.block[i].bmi, 0, sizeof(B_MODE_INFO));
-        }
-
+        x->e_mbd.mode_info_context->mbmi.mode = ZEROMV;
+        x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME;
         x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
+        x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
+        x->e_mbd.mode_info_context->mbmi.mb_skip_coeff =
+                                        (cpi->common.mb_no_coeff_skip) ? 1 : 0;
+        x->e_mbd.mode_info_context->mbmi.partitioning = 0;
+
         return;
     }
 
-    // macroblock modes
+    /* set to the best mb mode */
     vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
 
+    if (best_mbmode.mode <= B_PRED)
+    {
+        /* set mode_info_context->mbmi.uv_mode */
+        vp8_pick_intra_mbuv_mode(x);
+    }
 
-    if (x->e_mbd.mode_info_context->mbmi.mode <= B_PRED)
+    if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
+    {
         for (i = 0; i < 16; i++)
         {
-            x->e_mbd.block[i].bmi.mode = best_bmodes[i].mode;
+            x->e_mbd.block[i].bmi.as_mode = best_bmodes[i].as_mode;
         }
-    else
-    {
-        vp8_set_mbmode_and_mvs(x, x->e_mbd.mode_info_context->mbmi.mode, &best_bmodes[0].mv);
     }
-
     update_mvcount(cpi, &x->e_mbd, &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame]);
 }
index 9834fc4..d4d6cd7 100644 (file)
@@ -198,8 +198,8 @@ static int sad_per_bit4lut[QINDEX_RANGE] =
 
 void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
 {
-    cpi->mb.sadperbit16 =  sad_per_bit16lut[QIndex];
-    cpi->mb.sadperbit4  =  sad_per_bit4lut[QIndex];
+    cpi->mb.sadperbit16 =  sad_per_bit16lut[QIndex]/2;
+    cpi->mb.sadperbit4  =  sad_per_bit4lut[QIndex]/2;
 }
 
 void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
@@ -650,7 +650,7 @@ static int rd_pick_intra4x4block(
             vpx_memcpy(best_dqcoeff, b->dqcoeff, 32);
         }
     }
-    b->bmi.mode = (B_PREDICTION_MODE)(*best_mode);
+    b->bmi.as_mode = (B_PREDICTION_MODE)(*best_mode);
 
     IDCT_INVOKE(IF_RTCD(&cpi->rtcd.common->idct), idct16)(best_dqcoeff, b->diff, 32);
     RECON_INVOKE(IF_RTCD(&cpi->rtcd.common->recon), recon)(best_predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
@@ -1141,8 +1141,9 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
 
                     {
                         bestsme = cpi->diamond_search_sad(x, c, e, &bsi->mvp,
-                                                          &mode_mv[NEW4X4], step_param,
-                                                          sadpb / 2, &num00, v_fn_ptr, x->mvcost, bsi->ref_mv);
+                                                &mode_mv[NEW4X4], step_param,
+                                                sadpb, &num00, v_fn_ptr,
+                                                x->mvcost, bsi->ref_mv);
 
                         n = num00;
                         num00 = 0;
@@ -1155,9 +1156,11 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
                                 num00--;
                             else
                             {
-                                thissme = cpi->diamond_search_sad(x, c, e, &bsi->mvp,
-                                                                  &temp_mv, step_param + n,
-                                                                  sadpb / 2, &num00, v_fn_ptr, x->mvcost, bsi->ref_mv);
+                                thissme = cpi->diamond_search_sad(x, c, e,
+                                                    &bsi->mvp, &temp_mv,
+                                                    step_param + n, sadpb,
+                                                    &num00, v_fn_ptr,
+                                                    x->mvcost, bsi->ref_mv);
 
                                 if (thissme < bestsme)
                                 {
@@ -1179,7 +1182,8 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
                         full_mvp.as_mv.col = bsi->mvp.as_mv.col >>3;
 
                         thissme = cpi->full_search_sad(x, c, e, &full_mvp,
-                                                       sadpb / 4, 16, v_fn_ptr, x->mvcost, bsi->ref_mv);
+                                                       sadpb, 16, v_fn_ptr,
+                                                       x->mvcost, bsi->ref_mv);
 
                         if (thissme < bestsme)
                         {
@@ -1198,13 +1202,10 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
                 {
                     int distortion;
                     unsigned int sse;
+                    cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
+                        bsi->ref_mv, x->errorperbit, v_fn_ptr, x->mvcost,
+                        &distortion, &sse);
 
-                    if (!cpi->common.full_pixel)
-                        cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
-                                                     bsi->ref_mv, x->errorperbit / 2, v_fn_ptr, x->mvcost, &distortion, &sse);
-                    else
-                        vp8_skip_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
-                                                    bsi->ref_mv, x->errorperbit, v_fn_ptr, x->mvcost, &distortion, &sse);
                 }
             } /* NEW4X4 */
 
@@ -1398,8 +1399,7 @@ static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x,
     {
         BLOCKD *bd = &x->e_mbd.block[i];
 
-        bd->bmi.mv.as_mv = bsi.mvs[i].as_mv;
-        bd->bmi.mode = bsi.modes[i];
+        bd->bmi.mv.as_int = bsi.mvs[i].as_int;
         bd->eob = bsi.eobs[i];
     }
 
@@ -1714,7 +1714,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
     BLOCK *b = &x->block[0];
     BLOCKD *d = &x->e_mbd.block[0];
     MACROBLOCKD *xd = &x->e_mbd;
-    B_MODE_INFO best_bmodes[16];
+    union b_mode_info best_bmodes[16];
     MB_MODE_INFO best_mbmode;
     PARTITION_INFO best_partition;
     int_mv best_ref_mv;
@@ -1758,6 +1758,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
     unsigned char *v_buffer[4];
 
     vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
+    vpx_memset(&best_bmodes, 0, sizeof(best_bmodes));
 
     if (cpi->ref_frame_flags & VP8_LAST_FLAG)
     {
@@ -2062,7 +2063,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
 
             // Initial step/diamond search
             {
-                bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb < 9
+                bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv,
+                                        step_param, sadpb, &num00,
+                                        &cpi->fn_ptr[BLOCK_16X16],
+                                        x->mvcost, &best_ref_mv);
                 mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
 
                 // Further step/diamond searches as necessary
@@ -2084,7 +2088,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
                         num00--;
                     else
                     {
-                        thissme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv, step_param + n, sadpb / 4/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb = 9
+                        thissme = cpi->diamond_search_sad(x, b, d, &mvp,
+                                    &d->bmi.mv, step_param + n, sadpb, &num00,
+                                    &cpi->fn_ptr[BLOCK_16X16], x->mvcost,
+                                    &best_ref_mv);
 
                         /* check to see if refining search is needed. */
                         if (num00 > (further_steps-n))
@@ -2113,7 +2120,9 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
                 search_range = 8;
 
                 //thissme = cpi->full_search_sad(x, b, d, &d->bmi.mv.as_mv, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
-                thissme = cpi->refining_search_sad(x, b, d, &d->bmi.mv, sadpb/4, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
+                thissme = cpi->refining_search_sad(x, b, d, &d->bmi.mv, sadpb,
+                                       search_range, &cpi->fn_ptr[BLOCK_16X16],
+                                       x->mvcost, &best_ref_mv);
 
                 if (thissme < bestsme)
                 {
@@ -2135,7 +2144,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
             {
                 int dis; /* TODO: use dis in distortion calculation later. */
                 unsigned int sse;
-                cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv, x->errorperbit / 4, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &dis, &sse);
+                cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,
+                                             x->errorperbit,
+                                             &cpi->fn_ptr[BLOCK_16X16],
+                                             x->mvcost, &dis, &sse);
             }
 
             mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
@@ -2319,10 +2331,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
             vpx_memcpy(&best_mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE_INFO));
             vpx_memcpy(&best_partition, x->partition_info, sizeof(PARTITION_INFO));
 
-            for (i = 0; i < 16; i++)
-            {
-                vpx_memcpy(&best_bmodes[i], &x->e_mbd.block[i].bmi, sizeof(B_MODE_INFO));
-            }
+            if ((this_mode == B_PRED) || (this_mode == SPLITMV))
+                for (i = 0; i < 16; i++)
+                {
+                    best_bmodes[i] = x->e_mbd.block[i].bmi;
+                }
+
 
             // Testing this mode gave rise to an improvement in best error score. Lower threshold a bit for next time
             cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
@@ -2375,34 +2389,28 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
     cpi->mode_chosen_counts[best_mode_index] ++;
 
 
-    if (cpi->is_src_frame_alt_ref && (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
+    if (cpi->is_src_frame_alt_ref &&
+        (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
     {
-        best_mbmode.mode = ZEROMV;
-        best_mbmode.ref_frame = ALTREF_FRAME;
-        best_mbmode.mv.as_int = 0;
-        best_mbmode.uv_mode = 0;
-        best_mbmode.mb_skip_coeff = (cpi->common.mb_no_coeff_skip) ? 1 : 0;
-        best_mbmode.partitioning = 0;
-
-        vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
-        vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
-
-        for (i = 0; i < 16; i++)
-        {
-            vpx_memset(&x->e_mbd.block[i].bmi, 0, sizeof(B_MODE_INFO));
-        }
-
+        x->e_mbd.mode_info_context->mbmi.mode = ZEROMV;
+        x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME;
         x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
+        x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
+        x->e_mbd.mode_info_context->mbmi.mb_skip_coeff =
+                                        (cpi->common.mb_no_coeff_skip) ? 1 : 0;
+        x->e_mbd.mode_info_context->mbmi.partitioning = 0;
+
         return;
     }
 
+
     // macroblock modes
     vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
 
     if (best_mbmode.mode == B_PRED)
     {
         for (i = 0; i < 16; i++)
-          x->e_mbd.block[i].bmi.mode = best_bmodes[i].mode;
+          x->e_mbd.block[i].bmi.as_mode = best_bmodes[i].as_mode;
     }
 
     if (best_mbmode.mode == SPLITMV)
index 483a98c..2997f77 100644 (file)
@@ -200,7 +200,7 @@ static int vp8_temporal_filter_find_matching_mb_c
     bestsme = vp8_hex_search(x, b, d,
         &best_ref_mv1, &d->bmi.mv,
         step_param,
-        sadpb/*x->errorperbit*/,
+        sadpb,
         &num00, &cpi->fn_ptr[BLOCK_16X16],
         mvsadcost, mvcost, &best_ref_mv1);