Moved zbin_mode_boost to macroblock struct

Fixing unsafe threading in VP8 encoder.

Change-Id: Ibf4c89a2043654834747811bc11eb283de0bb830
This commit is contained in:
Scott LaVarnway 2012-12-10 10:33:01 -08:00
parent 3a19eebe4d
commit 74efda4bd6
7 changed files with 30 additions and 29 deletions

View File

@ -142,6 +142,9 @@ typedef struct macroblock
int rd_threshes[MAX_MODES];
unsigned int mbs_tested_so_far;
unsigned int mode_test_hit_counts[MAX_MODES];
int zbin_mode_boost_enabled;
int zbin_mode_boost;
int last_zbin_mode_boost;
int last_zbin_over_quant;
int zbin_over_quant;

View File

@ -1229,7 +1229,7 @@ int vp8cx_encode_inter_macroblock
if (cpi->sf.RD)
{
int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
int zbin_mode_boost_enabled = x->zbin_mode_boost_enabled;
/* Are we using the fast quantizer for the mode selection? */
if(cpi->sf.use_fastquant_for_pick)
@ -1239,7 +1239,7 @@ int vp8cx_encode_inter_macroblock
/* the fast quantizer does not use zbin_extra, so
* do not recalculate */
cpi->zbin_mode_boost_enabled = 0;
x->zbin_mode_boost_enabled = 0;
}
vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate,
&distortion, &intra_error);
@ -1252,7 +1252,7 @@ int vp8cx_encode_inter_macroblock
}
/* restore cpi->zbin_mode_boost_enabled */
cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
x->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
}
else
@ -1298,22 +1298,22 @@ int vp8cx_encode_inter_macroblock
/* Experimental code. Special case for gf and arf zeromv modes.
* Increase zbin size to supress noise
*/
cpi->zbin_mode_boost = 0;
if (cpi->zbin_mode_boost_enabled)
x->zbin_mode_boost = 0;
if (x->zbin_mode_boost_enabled)
{
if ( xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME )
{
if (xd->mode_info_context->mbmi.mode == ZEROMV)
{
if (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME)
cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
x->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
else
cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
x->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
}
else if (xd->mode_info_context->mbmi.mode == SPLITMV)
cpi->zbin_mode_boost = 0;
x->zbin_mode_boost = 0;
else
cpi->zbin_mode_boost = MV_ZBIN_BOOST;
x->zbin_mode_boost = MV_ZBIN_BOOST;
}
}

View File

@ -425,6 +425,8 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
sizeof(x->rd_thresh_mult));
z->zbin_over_quant = x->zbin_over_quant;
z->zbin_mode_boost_enabled = x->zbin_mode_boost_enabled;
z->zbin_mode_boost = x->zbin_mode_boost;
}
}

View File

@ -3309,18 +3309,18 @@ static void encode_frame_to_data_rate
/* Clear zbin over-quant value and mode boost values. */
cpi->mb.zbin_over_quant = 0;
cpi->zbin_mode_boost = 0;
cpi->mb.zbin_mode_boost = 0;
/* Enable or disable mode based tweaking of the zbin
* For 2 Pass Only used where GF/ARF prediction quality
* is above a threshold
*/
cpi->zbin_mode_boost_enabled = 1;
cpi->mb.zbin_mode_boost_enabled = 1;
if (cpi->pass == 2)
{
if ( cpi->gfu_boost <= 400 )
{
cpi->zbin_mode_boost_enabled = 0;
cpi->mb.zbin_mode_boost_enabled = 0;
}
}

View File

@ -412,10 +412,6 @@ typedef struct VP8_COMP
int ni_frames;
int avg_frame_qindex;
int zbin_mode_boost;
int zbin_mode_boost_enabled;
int last_zbin_mode_boost;
int64_t total_byte_count;
int buffered_mode;

View File

@ -588,19 +588,19 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
#define ZBIN_EXTRA_Y \
(( cpi->common.Y1dequant[QIndex][1] * \
( x->zbin_over_quant + \
cpi->zbin_mode_boost + \
x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
#define ZBIN_EXTRA_UV \
(( cpi->common.UVdequant[QIndex][1] * \
( x->zbin_over_quant + \
cpi->zbin_mode_boost + \
x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
#define ZBIN_EXTRA_Y2 \
(( cpi->common.Y2dequant[QIndex][1] * \
( (x->zbin_over_quant / 2) + \
cpi->zbin_mode_boost + \
x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
@ -703,14 +703,14 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
x->q_index = QIndex;
x->last_zbin_over_quant = x->zbin_over_quant;
cpi->last_zbin_mode_boost = cpi->zbin_mode_boost;
x->last_zbin_mode_boost = x->zbin_mode_boost;
x->last_act_zbin_adj = x->act_zbin_adj;
}
else if(x->last_zbin_over_quant != x->zbin_over_quant
|| cpi->last_zbin_mode_boost != cpi->zbin_mode_boost
|| x->last_zbin_mode_boost != x->zbin_mode_boost
|| x->last_act_zbin_adj != x->act_zbin_adj)
{
/* Y */
@ -730,7 +730,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
x->block[24].zbin_extra = (short)zbin_extra;
x->last_zbin_over_quant = x->zbin_over_quant;
cpi->last_zbin_mode_boost = cpi->zbin_mode_boost;
x->last_zbin_mode_boost = x->zbin_mode_boost;
x->last_act_zbin_adj = x->act_zbin_adj;
}
}
@ -764,7 +764,7 @@ void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x)
void vp8cx_frame_init_quantizer(VP8_COMP *cpi)
{
/* Clear Zbin mode boost for default case */
cpi->zbin_mode_boost = 0;
cpi->mb.zbin_mode_boost = 0;
/* MB level quantizer setup */
vp8cx_mb_init_quantizer(cpi, &cpi->mb, 0);

View File

@ -2102,23 +2102,23 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Experimental code. Special case for gf and arf zeromv modes.
* Increase zbin size to supress noise
*/
if (cpi->zbin_mode_boost_enabled)
if (x->zbin_mode_boost_enabled)
{
if ( this_ref_frame == INTRA_FRAME )
cpi->zbin_mode_boost = 0;
x->zbin_mode_boost = 0;
else
{
if (vp8_mode_order[mode_index] == ZEROMV)
{
if (this_ref_frame != LAST_FRAME)
cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
x->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
else
cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
x->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
}
else if (vp8_mode_order[mode_index] == SPLITMV)
cpi->zbin_mode_boost = 0;
x->zbin_mode_boost = 0;
else
cpi->zbin_mode_boost = MV_ZBIN_BOOST;
x->zbin_mode_boost = MV_ZBIN_BOOST;
}
vp8_update_zbin_extra(cpi, x);