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;
short *dqcoeff;
unsigned char *predictor;
short *diff;
- short *reference;
-
short *dequant;
/* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
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]);
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];
}
}
}
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];
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
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,
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);
}
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)
{
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)
{
#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"
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);
if (cm->fb_idx_ref_cnt[i] == 0)
break;
+ assert(i < NUM_YV12_BUFFERS);
cm->fb_idx_ref_cnt[i] = 1;
return i;
}
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)
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);
typedef struct
{
int count;
- B_MODE_INFO bmi[16];
+ struct
+ {
+ B_PREDICTION_MODE mode;
+ int_mv mv;
+ } bmi[16];
} PARTITION_INFO;
typedef struct
// 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);
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;
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);
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;
}
}
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;
{
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);
}
}
// 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;
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;
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
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
(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
{
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)
{
(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
{
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)
{
{
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)
{
// 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
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)
{
(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
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)
{
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)
{
(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
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)
{
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)
{
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)
{
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;
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,
}
-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];
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)
{
*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;
}
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
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;
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.
//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
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)
}
}
- 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;
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);
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;
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);
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]);
}
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)
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);
{
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;
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)
{
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)
{
{
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 */
{
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];
}
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;
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)
{
// 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
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))
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)
{
{
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;
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;
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)
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);