summaryrefslogtreecommitdiff
path: root/vp8/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder')
-rw-r--r--vp8/encoder/bitstream.c18
-rw-r--r--vp8/encoder/block.h24
-rw-r--r--vp8/encoder/denoising.c12
-rw-r--r--vp8/encoder/encodeframe.c158
-rw-r--r--vp8/encoder/encodemv.c6
-rw-r--r--vp8/encoder/ethreading.c32
-rw-r--r--vp8/encoder/firstpass.c2
-rw-r--r--vp8/encoder/onyx_if.c293
-rw-r--r--vp8/encoder/onyx_int.h41
-rw-r--r--vp8/encoder/pickinter.c67
-rw-r--r--vp8/encoder/pickinter.h2
-rw-r--r--vp8/encoder/quantize.c26
-rw-r--r--vp8/encoder/ratectrl.c45
-rw-r--r--vp8/encoder/rdopt.c126
-rw-r--r--vp8/encoder/rdopt.h4
-rw-r--r--vp8/encoder/tokenize.c102
16 files changed, 493 insertions, 465 deletions
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index 27991433b..e666b6c7e 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -118,7 +118,7 @@ static void update_mbintra_mode_probs(VP8_COMP *cpi)
update_mode(
w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
- Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count
+ Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->mb.ymode_count
);
}
{
@@ -127,7 +127,7 @@ static void update_mbintra_mode_probs(VP8_COMP *cpi)
update_mode(
w, VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
- Pnew, x->fc.uv_mode_prob, bct, (unsigned int *)cpi->uv_mode_count
+ Pnew, x->fc.uv_mode_prob, bct, (unsigned int *)cpi->mb.uv_mode_count
);
}
}
@@ -493,7 +493,7 @@ static void write_mb_features(vp8_writer *w, const MB_MODE_INFO *mi, const MACRO
}
void vp8_convert_rfct_to_prob(VP8_COMP *const cpi)
{
- const int *const rfct = cpi->count_mb_ref_frame_usage;
+ const int *const rfct = cpi->mb.count_mb_ref_frame_usage;
const int rf_intra = rfct[INTRA_FRAME];
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
@@ -539,7 +539,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
{
int total_mbs = pc->mb_rows * pc->mb_cols;
- prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs;
+ prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_mbs;
if (prob_skip_false <= 1)
prob_skip_false = 1;
@@ -730,7 +730,7 @@ static void write_kfmodes(VP8_COMP *cpi)
{
int total_mbs = c->mb_rows * c->mb_cols;
- prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs;
+ prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_mbs;
if (prob_skip_false <= 1)
prob_skip_false = 1;
@@ -851,6 +851,7 @@ static int prob_update_savings(const unsigned int *ct,
static int independent_coef_context_savings(VP8_COMP *cpi)
{
+ MACROBLOCK *const x = & cpi->mb;
int savings = 0;
int i = 0;
do
@@ -867,7 +868,7 @@ static int independent_coef_context_savings(VP8_COMP *cpi)
*/
probs = (const unsigned int (*)[MAX_ENTROPY_TOKENS])
- cpi->coef_counts[i][j];
+ x->coef_counts[i][j];
/* Reset to default probabilities at key frames */
if (cpi->common.frame_type == KEY_FRAME)
@@ -926,6 +927,7 @@ static int independent_coef_context_savings(VP8_COMP *cpi)
static int default_coef_context_savings(VP8_COMP *cpi)
{
+ MACROBLOCK *const x = & cpi->mb;
int savings = 0;
int i = 0;
do
@@ -945,7 +947,7 @@ static int default_coef_context_savings(VP8_COMP *cpi)
MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
cpi->frame_coef_probs [i][j][k],
cpi->frame_branch_ct [i][j][k],
- cpi->coef_counts [i][j][k],
+ x->coef_counts [i][j][k],
256, 1
);
@@ -994,7 +996,7 @@ int vp8_estimate_entropy_savings(VP8_COMP *cpi)
{
int savings = 0;
- const int *const rfct = cpi->count_mb_ref_frame_usage;
+ const int *const rfct = cpi->mb.count_mb_ref_frame_usage;
const int rf_intra = rfct[INTRA_FRAME];
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
int new_intra, new_last, new_garf, oldtotal, newtotal;
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h
index 0b0a2346a..a30f88816 100644
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -18,6 +18,9 @@
#include "vp8/common/entropy.h"
#include "vpx_ports/mem.h"
+#define MAX_MODES 20
+#define MAX_ERROR_BINS 1024
+
/* motion search site */
typedef struct
{
@@ -127,7 +130,26 @@ typedef struct macroblock
unsigned char need_to_clamp_best_mvs;
#endif
-
+ int skip_true_count;
+ unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
+ unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */
+ int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
+ int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
+ int64_t prediction_error;
+ int64_t intra_error;
+ int count_mb_ref_frame_usage[MAX_REF_FRAMES];
+
+ int rd_thresh_mult[MAX_MODES];
+ 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;
+ int error_bins[MAX_ERROR_BINS];
void (*short_fdct4x4)(short *input, short *output, int pitch);
void (*short_fdct8x4)(short *input, short *output, int pitch);
diff --git a/vp8/encoder/denoising.c b/vp8/encoder/denoising.c
index 98526d640..1ee1cb59f 100644
--- a/vp8/encoder/denoising.c
+++ b/vp8/encoder/denoising.c
@@ -140,8 +140,7 @@ int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height)
int i;
assert(denoiser);
- /* don't need one for intra start at 1 */
- for (i = 1; i < MAX_REF_FRAMES; i++)
+ for (i = 0; i < MAX_REF_FRAMES; i++)
{
denoiser->yv12_running_avg[i].flags = 0;
@@ -175,8 +174,7 @@ void vp8_denoiser_free(VP8_DENOISER *denoiser)
int i;
assert(denoiser);
- /* we don't have one for intra ref frame */
- for (i = 1; i < MAX_REF_FRAMES ; i++)
+ for (i = 0; i < MAX_REF_FRAMES ; i++)
{
vp8_yv12_de_alloc_frame_buffer(&denoiser->yv12_running_avg[i]);
}
@@ -291,7 +289,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
{
/* Filter. */
decision = vp8_denoiser_filter(&denoiser->yv12_mc_running_avg,
- &denoiser->yv12_running_avg[LAST_FRAME],
+ &denoiser->yv12_running_avg[INTRA_FRAME],
x,
motion_magnitude2,
recon_yoffset, recon_uvoffset);
@@ -303,7 +301,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
*/
vp8_copy_mem16x16(
x->thismb, 16,
- denoiser->yv12_running_avg[LAST_FRAME].y_buffer + recon_yoffset,
- denoiser->yv12_running_avg[LAST_FRAME].y_stride);
+ denoiser->yv12_running_avg[INTRA_FRAME].y_buffer + recon_yoffset,
+ denoiser->yv12_running_avg[INTRA_FRAME].y_stride);
}
}
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index 2a86b88fd..d1b647be9 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -33,7 +33,7 @@
#endif
#include "encodeframe.h"
-extern void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
+extern void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) ;
extern void vp8_calc_ref_frame_costs(int *ref_frame_cost,
int prob_intra,
int prob_last,
@@ -45,7 +45,6 @@ extern void vp8_auto_select_speed(VP8_COMP *cpi);
extern void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
MACROBLOCK *x,
MB_ROW_COMP *mbr_ei,
- int mb_row,
int count);
static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x );
@@ -530,7 +529,8 @@ void encode_mb_row(VP8_COMP *cpi,
* segmentation map
*/
if ((cpi->current_layer == 0) &&
- (cpi->cyclic_refresh_mode_enabled && xd->segmentation_enabled))
+ (cpi->cyclic_refresh_mode_enabled &&
+ xd->segmentation_enabled))
{
cpi->segmentation_map[map_index+mb_col] = xd->mode_info_context->mbmi.segment_id;
@@ -642,10 +642,6 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi)
xd->left_context = &cm->left_context;
- vp8_zero(cpi->count_mb_ref_frame_usage)
- vp8_zero(cpi->ymode_count)
- vp8_zero(cpi->uv_mode_count)
-
x->mvc = cm->fc.mvc;
vpx_memset(cm->above_context, 0,
@@ -674,6 +670,43 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi)
xd->fullpixel_mask = 0xffffffff;
if(cm->full_pixel)
xd->fullpixel_mask = 0xfffffff8;
+
+ vp8_zero(x->coef_counts);
+ vp8_zero(x->ymode_count);
+ vp8_zero(x->uv_mode_count)
+ x->prediction_error = 0;
+ x->intra_error = 0;
+ vp8_zero(x->count_mb_ref_frame_usage);
+}
+
+static void sum_coef_counts(MACROBLOCK *x, MACROBLOCK *x_thread)
+{
+ int i = 0;
+ do
+ {
+ int j = 0;
+ do
+ {
+ int k = 0;
+ do
+ {
+ /* at every context */
+
+ /* calc probs and branch cts for this frame only */
+ int t = 0; /* token/prob index */
+
+ do
+ {
+ x->coef_counts [i][j][k][t] +=
+ x_thread->coef_counts [i][j][k][t];
+ }
+ while (++t < ENTROPY_NODES);
+ }
+ while (++k < PREV_COEF_CONTEXTS);
+ }
+ while (++j < COEF_BANDS);
+ }
+ while (++i < BLOCK_TYPES);
}
void vp8_encode_frame(VP8_COMP *cpi)
@@ -717,9 +750,7 @@ void vp8_encode_frame(VP8_COMP *cpi)
xd->subpixel_predict16x16 = vp8_bilinear_predict16x16;
}
- cpi->prediction_error = 0;
- cpi->intra_error = 0;
- cpi->skip_true_count = 0;
+ cpi->mb.skip_true_count = 0;
cpi->tok_count = 0;
#if 0
@@ -730,13 +761,11 @@ void vp8_encode_frame(VP8_COMP *cpi)
xd->mode_info_context = cm->mi;
- vp8_zero(cpi->MVcount);
-
- vp8_zero(cpi->coef_counts);
+ vp8_zero(cpi->mb.MVcount);
vp8cx_frame_init_quantizer(cpi);
- vp8_initialize_rd_consts(cpi,
+ vp8_initialize_rd_consts(cpi, x,
vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
vp8cx_initialize_me_consts(cpi, cm->base_qindex);
@@ -775,7 +804,8 @@ void vp8_encode_frame(VP8_COMP *cpi)
{
int i;
- vp8cx_init_mbrthread_data(cpi, x, cpi->mb_row_ei, 1, cpi->encoding_thread_count);
+ vp8cx_init_mbrthread_data(cpi, x, cpi->mb_row_ei,
+ cpi->encoding_thread_count);
for (i = 0; i < cm->mb_rows; i++)
cpi->mt_current_mb_col[i] = -1;
@@ -837,13 +867,49 @@ void vp8_encode_frame(VP8_COMP *cpi)
for (i = 0; i < cpi->encoding_thread_count; i++)
{
+ int mode_count;
+ int c_idx;
totalrate += cpi->mb_row_ei[i].totalrate;
+
+ cpi->mb.skip_true_count += cpi->mb_row_ei[i].mb.skip_true_count;
+
+ for(mode_count = 0; mode_count < VP8_YMODES; mode_count++)
+ cpi->mb.ymode_count[mode_count] +=
+ cpi->mb_row_ei[i].mb.ymode_count[mode_count];
+
+ for(mode_count = 0; mode_count < VP8_UV_MODES; mode_count++)
+ cpi->mb.uv_mode_count[mode_count] +=
+ cpi->mb_row_ei[i].mb.uv_mode_count[mode_count];
+
+ for(c_idx = 0; c_idx < MVvals; c_idx++)
+ {
+ cpi->mb.MVcount[0][c_idx] +=
+ cpi->mb_row_ei[i].mb.MVcount[0][c_idx];
+ cpi->mb.MVcount[1][c_idx] +=
+ cpi->mb_row_ei[i].mb.MVcount[1][c_idx];
+ }
+
+ cpi->mb.prediction_error +=
+ cpi->mb_row_ei[i].mb.prediction_error;
+ cpi->mb.intra_error += cpi->mb_row_ei[i].mb.intra_error;
+
+ for(c_idx = 0; c_idx < MAX_REF_FRAMES; c_idx++)
+ cpi->mb.count_mb_ref_frame_usage[c_idx] +=
+ cpi->mb_row_ei[i].mb.count_mb_ref_frame_usage[c_idx];
+
+ for(c_idx = 0; c_idx < MAX_ERROR_BINS; c_idx++)
+ cpi->mb.error_bins[c_idx] +=
+ cpi->mb_row_ei[i].mb.error_bins[c_idx];
+
+ /* add up counts for each thread */
+ sum_coef_counts(x, &cpi->mb_row_ei[i].mb);
}
}
else
#endif
{
+
/* for each macroblock row in image */
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
{
@@ -929,13 +995,14 @@ void vp8_encode_frame(VP8_COMP *cpi)
{
int tot_modes;
- tot_modes = cpi->count_mb_ref_frame_usage[INTRA_FRAME]
- + cpi->count_mb_ref_frame_usage[LAST_FRAME]
- + cpi->count_mb_ref_frame_usage[GOLDEN_FRAME]
- + cpi->count_mb_ref_frame_usage[ALTREF_FRAME];
+ tot_modes = cpi->mb.count_mb_ref_frame_usage[INTRA_FRAME]
+ + cpi->mb.count_mb_ref_frame_usage[LAST_FRAME]
+ + cpi->mb.count_mb_ref_frame_usage[GOLDEN_FRAME]
+ + cpi->mb.count_mb_ref_frame_usage[ALTREF_FRAME];
if (tot_modes)
- cpi->this_frame_percent_intra = cpi->count_mb_ref_frame_usage[INTRA_FRAME] * 100 / tot_modes;
+ cpi->this_frame_percent_intra =
+ cpi->mb.count_mb_ref_frame_usage[INTRA_FRAME] * 100 / tot_modes;
}
@@ -1065,8 +1132,8 @@ static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x)
#endif
- ++cpi->ymode_count[m];
- ++cpi->uv_mode_count[uvm];
+ ++x->ymode_count[m];
+ ++x->uv_mode_count[uvm];
}
@@ -1093,15 +1160,16 @@ static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x )
#endif
}
-int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
+int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
+ TOKENEXTRA **t)
{
MACROBLOCKD *xd = &x->e_mbd;
int rate;
if (cpi->sf.RD && cpi->compressor_speed != 2)
- vp8_rd_pick_intra_mode(cpi, x, &rate);
+ vp8_rd_pick_intra_mode(x, &rate);
else
- vp8_pick_intra_mode(cpi, x, &rate);
+ vp8_pick_intra_mode(x, &rate);
if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
{
@@ -1118,7 +1186,7 @@ int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
sum_intra_stats(cpi, x);
- vp8_tokenize_mb(cpi, &x->e_mbd, t);
+ vp8_tokenize_mb(cpi, x, t);
if (xd->mode_info_context->mbmi.mode != B_PRED)
vp8_inverse_transform_mby(xd);
@@ -1165,17 +1233,17 @@ 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)
{
- cpi->mb.quantize_b = vp8_fast_quantize_b;
- cpi->mb.quantize_b_pair = vp8_fast_quantize_b_pair;
+ x->quantize_b = vp8_fast_quantize_b;
+ x->quantize_b_pair = vp8_fast_quantize_b_pair;
/* 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);
@@ -1183,12 +1251,12 @@ int vp8cx_encode_inter_macroblock
/* switch back to the regular quantizer for the encode */
if (cpi->sf.improved_quant)
{
- cpi->mb.quantize_b = vp8_regular_quantize_b;
- cpi->mb.quantize_b_pair = vp8_regular_quantize_b_pair;
+ x->quantize_b = vp8_regular_quantize_b;
+ x->quantize_b_pair = vp8_regular_quantize_b_pair;
}
/* 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
@@ -1197,8 +1265,8 @@ int vp8cx_encode_inter_macroblock
&distortion, &intra_error, mb_row, mb_col);
}
- cpi->prediction_error += distortion;
- cpi->intra_error += intra_error;
+ x->prediction_error += distortion;
+ x->intra_error += intra_error;
if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
{
@@ -1234,22 +1302,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;
}
}
@@ -1259,7 +1327,7 @@ int vp8cx_encode_inter_macroblock
vp8_update_zbin_extra(cpi, x);
}
- cpi->count_mb_ref_frame_usage[xd->mode_info_context->mbmi.ref_frame] ++;
+ x->count_mb_ref_frame_usage[xd->mode_info_context->mbmi.ref_frame] ++;
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
{
@@ -1304,7 +1372,7 @@ int vp8cx_encode_inter_macroblock
if (!x->skip)
{
- vp8_tokenize_mb(cpi, xd, t);
+ vp8_tokenize_mb(cpi, x, t);
if (xd->mode_info_context->mbmi.mode != B_PRED)
vp8_inverse_transform_mby(xd);
@@ -1321,12 +1389,12 @@ int vp8cx_encode_inter_macroblock
if (cpi->common.mb_no_coeff_skip)
{
- cpi->skip_true_count ++;
+ x->skip_true_count ++;
vp8_fix_contexts(xd);
}
else
{
- vp8_stuff_mb(cpi, xd, t);
+ vp8_stuff_mb(cpi, x, t);
}
}
diff --git a/vp8/encoder/encodemv.c b/vp8/encoder/encodemv.c
index 7d8c84dd3..0c43d0692 100644
--- a/vp8/encoder/encodemv.c
+++ b/vp8/encoder/encodemv.c
@@ -363,10 +363,12 @@ void vp8_write_mvprobs(VP8_COMP *cpi)
active_section = 4;
#endif
write_component_probs(
- w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MVcount[0], 0, &flags[0]
+ w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0],
+ cpi->mb.MVcount[0], 0, &flags[0]
);
write_component_probs(
- w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MVcount[1], 1, &flags[1]
+ w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1],
+ cpi->mb.MVcount[1], 1, &flags[1]
);
if (flags[0] || flags[1])
diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c
index 4c6e5d870..d4b17cef1 100644
--- a/vp8/encoder/ethreading.c
+++ b/vp8/encoder/ethreading.c
@@ -17,12 +17,6 @@
#if CONFIG_MULTITHREAD
-extern int vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
- TOKENEXTRA **t,
- int recon_yoffset, int recon_uvoffset,
- int mb_row, int mb_col);
-extern int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
- TOKENEXTRA **t);
extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip);
extern void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm);
@@ -220,7 +214,9 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
* vp8cx_encode_inter_macroblock()) back into the
* global segmentation map
*/
- if (cpi->cyclic_refresh_mode_enabled && xd->segmentation_enabled)
+ if ((cpi->current_layer == 0) &&
+ (cpi->cyclic_refresh_mode_enabled &&
+ xd->segmentation_enabled))
{
const MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
cpi->segmentation_map[map_index + mb_col] = mbmi->segment_id;
@@ -422,13 +418,23 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
zd->block[i].dequant = zd->dequant_uv;
zd->block[24].dequant = zd->dequant_y2;
#endif
+
+
+ vpx_memcpy(z->rd_threshes, x->rd_threshes, sizeof(x->rd_threshes));
+ vpx_memcpy(z->rd_thresh_mult, x->rd_thresh_mult,
+ 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;
+
+ vpx_memset(z->error_bins, 0, sizeof(z->error_bins));
}
}
void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
MACROBLOCK *x,
MB_ROW_COMP *mbr_ei,
- int mb_row,
int count
)
{
@@ -436,7 +442,6 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
VP8_COMMON *const cm = & cpi->common;
MACROBLOCKD *const xd = & x->e_mbd;
int i;
- (void) mb_row;
for (i = 0; i < count; i++)
{
@@ -477,6 +482,15 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
mbd->fullpixel_mask = 0xffffffff;
if(cm->full_pixel)
mbd->fullpixel_mask = 0xfffffff8;
+
+ vp8_zero(mb->coef_counts);
+ vp8_zero(x->ymode_count);
+ mb->skip_true_count = 0;
+ vp8_zero(mb->MVcount);
+ mb->prediction_error = 0;
+ mb->intra_error = 0;
+ vp8_zero(mb->count_mb_ref_frame_usage);
+ mb->mbs_tested_so_far = 0;
}
}
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index e5306a425..5e41ec8ec 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -570,7 +570,7 @@ void vp8_first_pass(VP8_COMP *cpi)
/* Initialise the MV cost table to the defaults */
{
int flag[2] = {1, 1};
- vp8_initialize_rd_consts(cpi, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
+ vp8_initialize_rd_consts(cpi, x, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
}
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index e7d22701e..9837485fd 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -239,7 +239,7 @@ static void save_layer_context(VP8_COMP *cpi)
lc->rate_correction_factor = cpi->rate_correction_factor;
lc->key_frame_rate_correction_factor = cpi->key_frame_rate_correction_factor;
lc->gf_rate_correction_factor = cpi->gf_rate_correction_factor;
- lc->zbin_over_quant = cpi->zbin_over_quant;
+ lc->zbin_over_quant = cpi->mb.zbin_over_quant;
lc->inter_frame_target = cpi->inter_frame_target;
lc->total_byte_count = cpi->total_byte_count;
lc->filter_level = cpi->common.filter_level;
@@ -247,8 +247,8 @@ static void save_layer_context(VP8_COMP *cpi)
lc->last_frame_percent_intra = cpi->last_frame_percent_intra;
memcpy (lc->count_mb_ref_frame_usage,
- cpi->count_mb_ref_frame_usage,
- sizeof(cpi->count_mb_ref_frame_usage));
+ cpi->mb.count_mb_ref_frame_usage,
+ sizeof(cpi->mb.count_mb_ref_frame_usage));
}
static void restore_layer_context(VP8_COMP *cpi, const int layer)
@@ -277,16 +277,16 @@ static void restore_layer_context(VP8_COMP *cpi, const int layer)
cpi->rate_correction_factor = lc->rate_correction_factor;
cpi->key_frame_rate_correction_factor = lc->key_frame_rate_correction_factor;
cpi->gf_rate_correction_factor = lc->gf_rate_correction_factor;
- cpi->zbin_over_quant = lc->zbin_over_quant;
+ cpi->mb.zbin_over_quant = lc->zbin_over_quant;
cpi->inter_frame_target = lc->inter_frame_target;
cpi->total_byte_count = lc->total_byte_count;
cpi->common.filter_level = lc->filter_level;
cpi->last_frame_percent_intra = lc->last_frame_percent_intra;
- memcpy (cpi->count_mb_ref_frame_usage,
+ memcpy (cpi->mb.count_mb_ref_frame_usage,
lc->count_mb_ref_frame_usage,
- sizeof(cpi->count_mb_ref_frame_usage));
+ sizeof(cpi->mb.count_mb_ref_frame_usage));
}
static void setup_features(VP8_COMP *cpi)
@@ -356,8 +356,6 @@ static void dealloc_compressor_data(VP8_COMP *cpi)
/* Activity mask based per mb zbin adjustments */
vpx_free(cpi->mb_activity_map);
cpi->mb_activity_map = 0;
- vpx_free(cpi->mb_norm_activity_map);
- cpi->mb_norm_activity_map = 0;
vpx_free(cpi->mb.pip);
cpi->mb.pip = 0;
@@ -643,11 +641,10 @@ void vp8_set_speed_features(VP8_COMP *cpi)
for (i = 0; i < MAX_MODES; i ++)
{
cpi->mode_check_freq[i] = 0;
- cpi->mode_test_hit_counts[i] = 0;
cpi->mode_chosen_counts[i] = 0;
}
- cpi->mbs_tested_so_far = 0;
+ cpi->mb.mbs_tested_so_far = 0;
/* best quality defaults */
sf->RD = 1;
@@ -841,7 +838,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
for (i = 0; i < min; i++)
{
- sum += cpi->error_bins[i];
+ sum += cpi->mb.error_bins[i];
}
total_skip = sum;
@@ -850,7 +847,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
/* i starts from 2 to make sure thresh started from 2048 */
for (; i < 1024; i++)
{
- sum += cpi->error_bins[i];
+ sum += cpi->mb.error_bins[i];
if (10 * sum >= (unsigned int)(cpi->Speed - 6)*(total_mbs - total_skip))
break;
@@ -905,7 +902,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
if (Speed >= 15)
sf->half_pixel_search = 0;
- vpx_memset(cpi->error_bins, 0, sizeof(cpi->error_bins));
+ vpx_memset(cpi->mb.error_bins, 0, sizeof(cpi->mb.error_bins));
}; /* switch */
@@ -1080,10 +1077,7 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
}
/* Data used for real time vc mode to see if gf needs refreshing */
- cpi->inter_zz_count = 0;
cpi->zeromv_count = 0;
- cpi->gf_bad_count = 0;
- cpi->gf_update_recommended = 0;
/* Structures used to monitor GF usage */
@@ -1098,11 +1092,6 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
vpx_calloc(sizeof(*cpi->mb_activity_map),
cm->mb_rows * cm->mb_cols));
- vpx_free(cpi->mb_norm_activity_map);
- CHECK_MEM_ERROR(cpi->mb_norm_activity_map,
- vpx_calloc(sizeof(*cpi->mb_norm_activity_map),
- cm->mb_rows * cm->mb_cols));
-
/* allocate memory for storing last frame's MVs for MV prediction. */
vpx_free(cpi->lfmv);
CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cm->mb_rows+2) * (cm->mb_cols+2),
@@ -1932,7 +1921,7 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
/* Set starting values of RD threshold multipliers (128 = *1) */
for (i = 0; i < MAX_MODES; i++)
{
- cpi->rd_thresh_mult[i] = 128;
+ cpi->mb.rd_thresh_mult[i] = 128;
}
#ifdef ENTROPY_STATS
@@ -2010,7 +1999,7 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->refining_search_sad = vp8_refining_search_sad;
/* make sure frame 1 is okay */
- cpi->error_bins[0] = cpi->common.MBs;
+ cpi->mb.error_bins[0] = cpi->common.MBs;
/* vp8cx_init_quantizer() is first called here. Add check in
* vp8cx_frame_init_quantizer() so that vp8cx_init_quantizer is only
@@ -2783,10 +2772,14 @@ static void update_golden_frame_stats(VP8_COMP *cpi)
if (cpi->common.frames_since_golden > 1)
{
- cpi->recent_ref_frame_usage[INTRA_FRAME] += cpi->count_mb_ref_frame_usage[INTRA_FRAME];
- cpi->recent_ref_frame_usage[LAST_FRAME] += cpi->count_mb_ref_frame_usage[LAST_FRAME];
- cpi->recent_ref_frame_usage[GOLDEN_FRAME] += cpi->count_mb_ref_frame_usage[GOLDEN_FRAME];
- cpi->recent_ref_frame_usage[ALTREF_FRAME] += cpi->count_mb_ref_frame_usage[ALTREF_FRAME];
+ cpi->recent_ref_frame_usage[INTRA_FRAME] +=
+ cpi->mb.count_mb_ref_frame_usage[INTRA_FRAME];
+ cpi->recent_ref_frame_usage[LAST_FRAME] +=
+ cpi->mb.count_mb_ref_frame_usage[LAST_FRAME];
+ cpi->recent_ref_frame_usage[GOLDEN_FRAME] +=
+ cpi->mb.count_mb_ref_frame_usage[GOLDEN_FRAME];
+ cpi->recent_ref_frame_usage[ALTREF_FRAME] +=
+ cpi->mb.count_mb_ref_frame_usage[ALTREF_FRAME];
}
}
}
@@ -2798,7 +2791,7 @@ static void update_rd_ref_frame_probs(VP8_COMP *cpi)
{
VP8_COMMON *cm = &cpi->common;
- const int *const rfct = cpi->count_mb_ref_frame_usage;
+ const int *const rfct = cpi->mb.count_mb_ref_frame_usage;
const int rf_intra = rfct[INTRA_FRAME];
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
@@ -2865,38 +2858,17 @@ static int decide_key_frame(VP8_COMP *cpi)
if ((cpi->compressor_speed == 2) && (cpi->Speed >= 5) && (cpi->sf.RD == 0))
{
- double change = 1.0 * abs((int)(cpi->intra_error - cpi->last_intra_error)) / (1 + cpi->last_intra_error);
- double change2 = 1.0 * abs((int)(cpi->prediction_error - cpi->last_prediction_error)) / (1 + cpi->last_prediction_error);
+ double change = 1.0 * abs((int)(cpi->mb.intra_error -
+ cpi->last_intra_error)) / (1 + cpi->last_intra_error);
+ double change2 = 1.0 * abs((int)(cpi->mb.prediction_error -
+ cpi->last_prediction_error)) / (1 + cpi->last_prediction_error);
double minerror = cm->MBs * 256;
-#if 0
+ cpi->last_intra_error = cpi->mb.intra_error;
+ cpi->last_prediction_error = cpi->mb.prediction_error;
- if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
- && cpi->prediction_error > minerror
- && (change > .25 || change2 > .25))
- {
- FILE *f = fopen("intra_inter.stt", "a");
-
- if (cpi->prediction_error <= 0)
- cpi->prediction_error = 1;
-
- fprintf(f, "%d %d %d %d %14.4f\n",
- cm->current_video_frame,
- (int) cpi->prediction_error,
- (int) cpi->intra_error,
- (int)((10 * cpi->intra_error) / cpi->prediction_error),
- change);
-
- fclose(f);
- }
-
-#endif
-
- cpi->last_intra_error = cpi->intra_error;
- cpi->last_prediction_error = cpi->prediction_error;
-
- if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
- && cpi->prediction_error > minerror
+ if (10 * cpi->mb.intra_error / (1 + cpi->mb.prediction_error) < 15
+ && cpi->mb.prediction_error > minerror
&& (change > .25 || change2 > .25))
{
/*(change > 1.4 || change < .75)&& cpi->this_frame_percent_intra > cpi->last_frame_percent_intra + 3*/
@@ -3160,6 +3132,57 @@ static void update_reference_frames(VP8_COMP *cpi)
cpi->current_ref_frames[LAST_FRAME] = cm->current_video_frame;
#endif
}
+
+#if CONFIG_TEMPORAL_DENOISING
+ if (cpi->oxcf.noise_sensitivity)
+ {
+ /* we shouldn't have to keep multiple copies as we know in advance which
+ * buffer we should start - for now to get something up and running
+ * I've chosen to copy the buffers
+ */
+ if (cm->frame_type == KEY_FRAME)
+ {
+ int i;
+ vp8_yv12_copy_frame(
+ cpi->Source,
+ &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
+
+ vp8_yv12_extend_frame_borders(
+ &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
+
+ for (i = 2; i < MAX_REF_FRAMES - 1; i++)
+ vp8_yv12_copy_frame(
+ &cpi->denoiser.yv12_running_avg[LAST_FRAME],
+ &cpi->denoiser.yv12_running_avg[i]);
+ }
+ else /* For non key frames */
+ {
+ vp8_yv12_extend_frame_borders(
+ &cpi->denoiser.yv12_running_avg[INTRA_FRAME]);
+
+ if (cm->refresh_alt_ref_frame || cm->copy_buffer_to_arf)
+ {
+ vp8_yv12_copy_frame(
+ &cpi->denoiser.yv12_running_avg[INTRA_FRAME],
+ &cpi->denoiser.yv12_running_avg[ALTREF_FRAME]);
+ }
+ if (cm->refresh_golden_frame || cm->copy_buffer_to_gf)
+ {
+ vp8_yv12_copy_frame(
+ &cpi->denoiser.yv12_running_avg[INTRA_FRAME],
+ &cpi->denoiser.yv12_running_avg[GOLDEN_FRAME]);
+ }
+ if(cm->refresh_last_frame)
+ {
+ vp8_yv12_copy_frame(
+ &cpi->denoiser.yv12_running_avg[INTRA_FRAME],
+ &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
+ }
+ }
+
+ }
+#endif
+
}
void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm)
@@ -3203,51 +3226,6 @@ void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm)
}
vp8_yv12_extend_frame_borders(cm->frame_to_show);
-#if CONFIG_TEMPORAL_DENOISING
- if (cpi->oxcf.noise_sensitivity)
- {
-
-
- /* we shouldn't have to keep multiple copies as we know in advance which
- * buffer we should start - for now to get something up and running
- * I've chosen to copy the buffers
- */
- if (cm->frame_type == KEY_FRAME)
- {
- int i;
- vp8_yv12_copy_frame(
- cpi->Source,
- &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
-
- vp8_yv12_extend_frame_borders(
- &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
-
- for (i = 2; i < MAX_REF_FRAMES - 1; i++)
- vp8_yv12_copy_frame(
- cpi->Source,
- &cpi->denoiser.yv12_running_avg[i]);
- }
- else /* For non key frames */
- {
- vp8_yv12_extend_frame_borders(
- &cpi->denoiser.yv12_running_avg[LAST_FRAME]);
-
- if (cm->refresh_alt_ref_frame || cm->copy_buffer_to_arf)
- {
- vp8_yv12_copy_frame(
- &cpi->denoiser.yv12_running_avg[LAST_FRAME],
- &cpi->denoiser.yv12_running_avg[ALTREF_FRAME]);
- }
- if (cm->refresh_golden_frame || cm->copy_buffer_to_gf)
- {
- vp8_yv12_copy_frame(
- &cpi->denoiser.yv12_running_avg[LAST_FRAME],
- &cpi->denoiser.yv12_running_avg[GOLDEN_FRAME]);
- }
- }
-
- }
-#endif
}
@@ -3331,19 +3309,19 @@ static void encode_frame_to_data_rate
cm->copy_buffer_to_arf = 0;
/* Clear zbin over-quant value and mode boost values. */
- cpi->zbin_over_quant = 0;
- cpi->zbin_mode_boost = 0;
+ cpi->mb.zbin_over_quant = 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;
}
}
@@ -3410,7 +3388,7 @@ static void encode_frame_to_data_rate
/* Reset the RD threshold multipliers to default of * 1 (128) */
for (i = 0; i < MAX_MODES; i++)
{
- cpi->rd_thresh_mult[i] = 128;
+ cpi->mb.rd_thresh_mult[i] = 128;
}
}
@@ -4099,8 +4077,9 @@ static void encode_frame_to_data_rate
q_low = (Q < q_high) ? (Q + 1) : q_high;
/* If we are using over quant do the same for zbin_oq_low */
- if (cpi->zbin_over_quant > 0)
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
+ if (cpi->mb.zbin_over_quant > 0)
+ zbin_oq_low = (cpi->mb.zbin_over_quant < zbin_oq_high) ?
+ (cpi->mb.zbin_over_quant + 1) : zbin_oq_high;
if (undershoot_seen)
{
@@ -4116,11 +4095,13 @@ static void encode_frame_to_data_rate
* is max)
*/
if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
+ cpi->mb.zbin_over_quant = 0;
else
{
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
+ zbin_oq_low = (cpi->mb.zbin_over_quant < zbin_oq_high) ?
+ (cpi->mb.zbin_over_quant + 1) : zbin_oq_high;
+ cpi->mb.zbin_over_quant =
+ (zbin_oq_high + zbin_oq_low) / 2;
}
}
else
@@ -4133,7 +4114,9 @@ static void encode_frame_to_data_rate
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
- while (((Q < q_low) || (cpi->zbin_over_quant < zbin_oq_low)) && (Retries < 10))
+ while (((Q < q_low) ||
+ (cpi->mb.zbin_over_quant < zbin_oq_low)) &&
+ (Retries < 10))
{
vp8_update_rate_correction_factors(cpi, 0);
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
@@ -4146,12 +4129,13 @@ static void encode_frame_to_data_rate
/* Frame is too small */
else
{
- if (cpi->zbin_over_quant == 0)
+ if (cpi->mb.zbin_over_quant == 0)
/* Lower q_high if not using over quant */
q_high = (Q > q_low) ? (Q - 1) : q_low;
else
/* else lower zbin_oq_high */
- zbin_oq_high = (cpi->zbin_over_quant > zbin_oq_low) ? (cpi->zbin_over_quant - 1) : zbin_oq_low;
+ zbin_oq_high = (cpi->mb.zbin_over_quant > zbin_oq_low) ?
+ (cpi->mb.zbin_over_quant - 1) : zbin_oq_low;
if (overshoot_seen)
{
@@ -4167,9 +4151,10 @@ static void encode_frame_to_data_rate
* is max)
*/
if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
+ cpi->mb.zbin_over_quant = 0;
else
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
+ cpi->mb.zbin_over_quant =
+ (zbin_oq_high + zbin_oq_low) / 2;
}
else
{
@@ -4192,7 +4177,9 @@ static void encode_frame_to_data_rate
q_low = Q;
}
- while (((Q > q_high) || (cpi->zbin_over_quant > zbin_oq_high)) && (Retries < 10))
+ while (((Q > q_high) ||
+ (cpi->mb.zbin_over_quant > zbin_oq_high)) &&
+ (Retries < 10))
{
vp8_update_rate_correction_factors(cpi, 0);
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
@@ -4210,7 +4197,9 @@ static void encode_frame_to_data_rate
Q = q_low;
/* Clamp cpi->zbin_over_quant */
- cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ? zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ? zbin_oq_high : cpi->zbin_over_quant;
+ cpi->mb.zbin_over_quant = (cpi->mb.zbin_over_quant < zbin_oq_low) ?
+ zbin_oq_low : (cpi->mb.zbin_over_quant > zbin_oq_high) ?
+ zbin_oq_high : cpi->mb.zbin_over_quant;
Loop = Q != last_q;
}
@@ -4292,7 +4281,6 @@ static void encode_frame_to_data_rate
/* Point to beginning of MODE_INFO arrays. */
MODE_INFO *tmp = cm->mi;
- cpi->inter_zz_count = 0;
cpi->zeromv_count = 0;
if(cm->frame_type != KEY_FRAME)
@@ -4301,8 +4289,6 @@ static void encode_frame_to_data_rate
{
for (mb_col = 0; mb_col < cm->mb_cols; mb_col ++)
{
- if(tmp->mbmi.mode == ZEROMV && tmp->mbmi.ref_frame == LAST_FRAME)
- cpi->inter_zz_count++;
if(tmp->mbmi.mode == ZEROMV)
cpi->zeromv_count++;
tmp++;
@@ -4732,67 +4718,6 @@ static void encode_frame_to_data_rate
}
-
-
-static void check_gf_quality(VP8_COMP *cpi)
-{
- VP8_COMMON *cm = &cpi->common;
- int gf_active_pct = (100 * cpi->gf_active_count) / (cm->mb_rows * cm->mb_cols);
- int gf_ref_usage_pct = (cpi->count_mb_ref_frame_usage[GOLDEN_FRAME] * 100) / (cm->mb_rows * cm->mb_cols);
- int last_ref_zz_useage = (cpi->inter_zz_count * 100) / (cm->mb_rows * cm->mb_cols);
-
- /* Gf refresh is not currently being signalled */
- if (cpi->gf_update_recommended == 0)
- {
- if (cpi->common.frames_since_golden > 7)
- {
- /* Low use of gf */
- if ((gf_active_pct < 10) || ((gf_active_pct + gf_ref_usage_pct) < 15))
- {
- /* ...but last frame zero zero usage is reasonbable so a
- * new gf might be appropriate
- */
- if (last_ref_zz_useage >= 25)
- {
- cpi->gf_bad_count ++;
-
- /* Check that the condition is stable */
- if (cpi->gf_bad_count >= 8)
- {
- cpi->gf_update_recommended = 1;
- cpi->gf_bad_count = 0;
- }
- }
- else
- /* Restart count as the background is not stable enough */
- cpi->gf_bad_count = 0;
- }
- else
- /* Gf useage has picked up so reset count */
- cpi->gf_bad_count = 0;
- }
- }
- /* If the signal is set but has not been read should we cancel it. */
- else if (last_ref_zz_useage < 15)
- {
- cpi->gf_update_recommended = 0;
- cpi->gf_bad_count = 0;
- }
-
-#if 0
- {
- FILE *f = fopen("gfneeded.stt", "a");
- fprintf(f, "%10d %10d %10d %10d %10ld \n",
- cm->current_video_frame,
- cpi->common.frames_since_golden,
- gf_active_pct, gf_ref_usage_pct,
- cpi->gf_update_recommended);
- fclose(f);
- }
-
-#endif
-}
-
#if !(CONFIG_REALTIME_ONLY)
static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned char * dest_end, unsigned int *frame_flags)
{
@@ -5096,8 +5021,6 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
if (cpi->compressor_speed == 2)
{
- if (cpi->oxcf.number_of_layers == 1)
- check_gf_quality(cpi);
vpx_usec_timer_start(&tsctimer);
vpx_usec_timer_start(&ticktimer);
}
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 3f1fad60b..fb8ad357c 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -43,7 +43,7 @@
#define AF_THRESH 25
#define AF_THRESH2 100
#define ARF_DECAY_THRESH 12
-#define MAX_MODES 20
+
#define MIN_THRESHMULT 32
#define MAX_THRESHMULT 512
@@ -349,13 +349,9 @@ typedef struct VP8_COMP
int ambient_err;
unsigned int mode_check_freq[MAX_MODES];
- unsigned int mode_test_hit_counts[MAX_MODES];
unsigned int mode_chosen_counts[MAX_MODES];
- unsigned int mbs_tested_so_far;
- int rd_thresh_mult[MAX_MODES];
int rd_baseline_thresh[MAX_MODES];
- int rd_threshes[MAX_MODES];
int RDMULT;
int RDDIV ;
@@ -363,9 +359,7 @@ typedef struct VP8_COMP
CODING_CONTEXT coding_context;
/* Rate targetting variables */
- int64_t prediction_error;
int64_t last_prediction_error;
- int64_t intra_error;
int64_t last_intra_error;
int this_frame_target;
@@ -418,12 +412,6 @@ typedef struct VP8_COMP
int ni_frames;
int avg_frame_qindex;
- int zbin_over_quant;
- int zbin_mode_boost;
- int zbin_mode_boost_enabled;
- int last_zbin_over_quant;
- int last_zbin_mode_boost;
-
int64_t total_byte_count;
int buffered_mode;
@@ -452,13 +440,6 @@ typedef struct VP8_COMP
int drop_frames_allowed; /* Are we permitted to drop frames? */
int drop_frame; /* Drop this frame? */
- int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
- int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
-
- unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */
-
- unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
-
vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
@@ -486,7 +467,6 @@ typedef struct VP8_COMP
int Speed;
int compressor_speed;
- int interquantizer;
int auto_gold;
int auto_adjust_gold_quantizer;
int auto_worst_q;
@@ -502,25 +482,16 @@ typedef struct VP8_COMP
int last_skip_probs_q[3];
int recent_ref_frame_usage[MAX_REF_FRAMES];
- int count_mb_ref_frame_usage[MAX_REF_FRAMES];
int this_frame_percent_intra;
int last_frame_percent_intra;
int ref_frame_flags;
SPEED_FEATURES sf;
- int error_bins[1024];
- /* Data used for real time conferencing mode to help determine if it
- * would be good to update the gf
- */
- int inter_zz_count;
/* Count ZEROMV on all reference frames. */
int zeromv_count;
int lf_zeromv_pct;
- int gf_bad_count;
- int gf_update_recommended;
- int skip_true_count;
unsigned char *segmentation_map;
signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS];
@@ -659,7 +630,6 @@ typedef struct VP8_COMP
/* Per MB activity measurement */
unsigned int activity_avg;
unsigned int * mb_activity_map;
- int * mb_norm_activity_map;
/* Record of which MBs still refer to last golden frame either
* directly or through 0,0
@@ -723,13 +693,10 @@ typedef struct VP8_COMP
} rd_costs;
} VP8_COMP;
-void control_data_rate(VP8_COMP *cpi);
-
-void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned char *dest_end, unsigned long *size);
-
-int rd_cost_intra_mb(MACROBLOCKD *x);
+void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest,
+ unsigned char *dest_end, unsigned long *size);
-void vp8_tokenize_mb(VP8_COMP *, MACROBLOCKD *, TOKENEXTRA **);
+void vp8_tokenize_mb(VP8_COMP *, MACROBLOCK *, TOKENEXTRA **);
void vp8_set_speed_features(VP8_COMP *cpi);
diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c
index c4fa691a4..673de2b33 100644
--- a/vp8/encoder/pickinter.c
+++ b/vp8/encoder/pickinter.c
@@ -389,15 +389,16 @@ static void pick_intra_mbuv_mode(MACROBLOCK *mb)
}
-static void update_mvcount(VP8_COMP *cpi, MACROBLOCKD *xd, int_mv *best_ref_mv)
+static void update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
{
+ MACROBLOCKD *xd = &x->e_mbd;
/* Split MV modes currently not supported when RD is nopt enabled,
* therefore, only need to modify MVcount in NEWMV mode. */
if (xd->mode_info_context->mbmi.mode == NEWMV)
{
- cpi->MVcount[0][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.row -
+ x->MVcount[0][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.row -
best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.col -
+ x->MVcount[1][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.col -
best_ref_mv->as_mv.col) >> 1)]++;
}
}
@@ -679,7 +680,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
get_predictor_pointers(cpi, plane, recon_yoffset, recon_uvoffset);
/* Count of the number of MBs tested so far this frame */
- cpi->mbs_tested_so_far++;
+ x->mbs_tested_so_far++;
*returnintra = INT_MAX;
x->skip = 0;
@@ -700,7 +701,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_rd = INT_MAX;
int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]];
- if (best_rd <= cpi->rd_threshes[mode_index])
+ if (best_rd <= x->rd_threshes[mode_index])
continue;
if (this_ref_frame < 0)
@@ -745,22 +746,22 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Check to see if the testing frequency for this mode is at its max
* If so then prevent it from being tested and increase the threshold
* for its testing */
- if (cpi->mode_test_hit_counts[mode_index] &&
+ if (x->mode_test_hit_counts[mode_index] &&
(cpi->mode_check_freq[mode_index] > 1))
{
- if (cpi->mbs_tested_so_far <= (cpi->mode_check_freq[mode_index] *
- cpi->mode_test_hit_counts[mode_index]))
+ if (x->mbs_tested_so_far <= (cpi->mode_check_freq[mode_index] *
+ x->mode_test_hit_counts[mode_index]))
{
/* Increase the threshold for coding this mode to make it less
* likely to be chosen */
- cpi->rd_thresh_mult[mode_index] += 4;
+ x->rd_thresh_mult[mode_index] += 4;
- if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
- cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
- cpi->rd_threshes[mode_index] =
+ x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
- cpi->rd_thresh_mult[mode_index];
+ x->rd_thresh_mult[mode_index];
continue;
}
}
@@ -768,7 +769,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* We have now reached the point where we are going to test the current
* mode so increment the counter for the number of times it has been
* tested */
- cpi->mode_test_hit_counts[mode_index] ++;
+ x->mode_test_hit_counts[mode_index] ++;
rate2 = 0;
distortion2 = 0;
@@ -1108,12 +1109,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* 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[mode_index] =
+ x->rd_thresh_mult[mode_index] =
+ (x->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ?
+ x->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
+ x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
- cpi->rd_thresh_mult[mode_index];
+ x->rd_thresh_mult[mode_index];
}
/* If the mode did not help improve the best error case then raise the
@@ -1121,14 +1122,14 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
*/
else
{
- cpi->rd_thresh_mult[mode_index] += 4;
+ x->rd_thresh_mult[mode_index] += 4;
- if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
- cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
- cpi->rd_threshes[mode_index] =
+ x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
- cpi->rd_thresh_mult[mode_index];
+ x->rd_thresh_mult[mode_index];
}
if (x->skip)
@@ -1138,16 +1139,16 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Reduce the activation RD thresholds for the best choice mode */
if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
{
- int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 3);
+ int best_adjustment = (x->rd_thresh_mult[best_mode_index] >> 3);
- cpi->rd_thresh_mult[best_mode_index] =
- (cpi->rd_thresh_mult[best_mode_index]
+ x->rd_thresh_mult[best_mode_index] =
+ (x->rd_thresh_mult[best_mode_index]
>= (MIN_THRESHMULT + best_adjustment)) ?
- cpi->rd_thresh_mult[best_mode_index] - best_adjustment :
+ x->rd_thresh_mult[best_mode_index] - best_adjustment :
MIN_THRESHMULT;
- cpi->rd_threshes[best_mode_index] =
+ x->rd_threshes[best_mode_index] =
(cpi->rd_baseline_thresh[best_mode_index] >> 7) *
- cpi->rd_thresh_mult[best_mode_index];
+ x->rd_thresh_mult[best_mode_index];
}
@@ -1159,7 +1160,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
this_rdbin = 1023;
}
- cpi->error_bins[this_rdbin] ++;
+ x->error_bins[this_rdbin] ++;
}
#if CONFIG_TEMPORAL_DENOISING
@@ -1240,11 +1241,11 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
!= cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame])
best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int;
- update_mvcount(cpi, &x->e_mbd, &best_ref_mv);
+ update_mvcount(cpi, x, &best_ref_mv);
}
-void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
+void vp8_pick_intra_mode(MACROBLOCK *x, int *rate_)
{
int error4x4, error16x16 = INT_MAX;
int rate, best_rate = 0, distortion, best_sse;
diff --git a/vp8/encoder/pickinter.h b/vp8/encoder/pickinter.h
index 6fbd88795..35011cab3 100644
--- a/vp8/encoder/pickinter.h
+++ b/vp8/encoder/pickinter.h
@@ -18,7 +18,7 @@ extern void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int recon_uvoffset, int *returnrate,
int *returndistortion, int *returnintra,
int mb_row, int mb_col);
-extern void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate);
+extern void vp8_pick_intra_mode(MACROBLOCK *x, int *rate);
extern int vp8_get_inter_mbpred_error(MACROBLOCK *mb,
const vp8_variance_fn_ptr_t *vfp,
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c
index 88fea11bb..33c8ef055 100644
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -587,20 +587,20 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
#define ZBIN_EXTRA_Y \
(( cpi->common.Y1dequant[QIndex][1] * \
- ( cpi->zbin_over_quant + \
- cpi->zbin_mode_boost + \
+ ( x->zbin_over_quant + \
+ x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
#define ZBIN_EXTRA_UV \
(( cpi->common.UVdequant[QIndex][1] * \
- ( cpi->zbin_over_quant + \
- cpi->zbin_mode_boost + \
+ ( x->zbin_over_quant + \
+ x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
#define ZBIN_EXTRA_Y2 \
(( cpi->common.Y2dequant[QIndex][1] * \
- ( (cpi->zbin_over_quant / 2) + \
- cpi->zbin_mode_boost + \
+ ( (x->zbin_over_quant / 2) + \
+ x->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7)
void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
@@ -702,15 +702,15 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
/* save this macroblock QIndex for vp8_update_zbin_extra() */
x->q_index = QIndex;
- cpi->last_zbin_over_quant = cpi->zbin_over_quant;
- cpi->last_zbin_mode_boost = cpi->zbin_mode_boost;
+ x->last_zbin_over_quant = x->zbin_over_quant;
+ x->last_zbin_mode_boost = x->zbin_mode_boost;
x->last_act_zbin_adj = x->act_zbin_adj;
}
- else if(cpi->last_zbin_over_quant != cpi->zbin_over_quant
- || cpi->last_zbin_mode_boost != cpi->zbin_mode_boost
+ else if(x->last_zbin_over_quant != x->zbin_over_quant
+ || x->last_zbin_mode_boost != x->zbin_mode_boost
|| x->last_act_zbin_adj != x->act_zbin_adj)
{
/* Y */
@@ -729,8 +729,8 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
zbin_extra = ZBIN_EXTRA_Y2;
x->block[24].zbin_extra = (short)zbin_extra;
- cpi->last_zbin_over_quant = cpi->zbin_over_quant;
- cpi->last_zbin_mode_boost = cpi->zbin_mode_boost;
+ x->last_zbin_over_quant = x->zbin_over_quant;
+ 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);
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index 1432c143b..a399a3877 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -242,8 +242,8 @@ void vp8_save_coding_context(VP8_COMP *cpi)
vp8_copy(cc->ymode_prob, cpi->common.fc.ymode_prob);
vp8_copy(cc->uv_mode_prob, cpi->common.fc.uv_mode_prob);
- vp8_copy(cc->ymode_count, cpi->ymode_count);
- vp8_copy(cc->uv_mode_count, cpi->uv_mode_count);
+ vp8_copy(cc->ymode_count, cpi->mb.ymode_count);
+ vp8_copy(cc->uv_mode_count, cpi->mb.uv_mode_count);
/* Stats */
@@ -280,8 +280,8 @@ void vp8_restore_coding_context(VP8_COMP *cpi)
vp8_copy(cpi->common.fc.ymode_prob, cc->ymode_prob);
vp8_copy(cpi->common.fc.uv_mode_prob, cc->uv_mode_prob);
- vp8_copy(cpi->ymode_count, cc->ymode_count);
- vp8_copy(cpi->uv_mode_count, cc->uv_mode_count);
+ vp8_copy(cpi->mb.ymode_count, cc->ymode_count);
+ vp8_copy(cpi->mb.uv_mode_count, cc->uv_mode_count);
/* Stats */
#ifdef MODE_STATS
@@ -1109,7 +1109,9 @@ void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var)
}
else
{
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ if (cpi->oxcf.number_of_layers == 1 &&
+ (cpi->common.refresh_alt_ref_frame ||
+ cpi->common.refresh_golden_frame))
rate_correction_factor = cpi->gf_rate_correction_factor;
else
rate_correction_factor = cpi->rate_correction_factor;
@@ -1122,9 +1124,9 @@ void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var)
projected_size_based_on_q = (int)(((.5 + rate_correction_factor * vp8_bits_per_mb[cpi->common.frame_type][Q]) * cpi->common.MBs) / (1 << BPER_MB_NORMBITS));
/* Make some allowance for cpi->zbin_over_quant */
- if (cpi->zbin_over_quant > 0)
+ if (cpi->mb.zbin_over_quant > 0)
{
- int Z = cpi->zbin_over_quant;
+ int Z = cpi->mb.zbin_over_quant;
double Factor = 0.99;
double factor_adjustment = 0.01 / 256.0;
@@ -1186,7 +1188,9 @@ void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var)
cpi->key_frame_rate_correction_factor = rate_correction_factor;
else
{
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ if (cpi->oxcf.number_of_layers == 1 &&
+ (cpi->common.refresh_alt_ref_frame ||
+ cpi->common.refresh_golden_frame))
cpi->gf_rate_correction_factor = rate_correction_factor;
else
cpi->rate_correction_factor = rate_correction_factor;
@@ -1199,7 +1203,7 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
int Q = cpi->active_worst_quality;
/* Reset Zbin OQ value */
- cpi->zbin_over_quant = 0;
+ cpi->mb.zbin_over_quant = 0;
if (cpi->oxcf.fixed_q >= 0)
{
@@ -1209,11 +1213,13 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
{
Q = cpi->oxcf.key_q;
}
- else if (cpi->common.refresh_alt_ref_frame)
+ else if (cpi->oxcf.number_of_layers == 1 &&
+ cpi->common.refresh_alt_ref_frame)
{
Q = cpi->oxcf.alt_q;
}
- else if (cpi->common.refresh_golden_frame)
+ else if (cpi->oxcf.number_of_layers == 1 &&
+ cpi->common.refresh_golden_frame)
{
Q = cpi->oxcf.gold_q;
}
@@ -1232,7 +1238,9 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
correction_factor = cpi->key_frame_rate_correction_factor;
else
{
- if (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame)
+ if (cpi->oxcf.number_of_layers == 1 &&
+ (cpi->common.refresh_alt_ref_frame ||
+ cpi->common.refresh_golden_frame))
correction_factor = cpi->gf_rate_correction_factor;
else
correction_factor = cpi->rate_correction_factor;
@@ -1281,7 +1289,10 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
if (cpi->common.frame_type == KEY_FRAME)
zbin_oqmax = 0;
- else if (cpi->common.refresh_alt_ref_frame || (cpi->common.refresh_golden_frame && !cpi->source_alt_ref_active))
+ else if (cpi->oxcf.number_of_layers == 1 &&
+ (cpi->common.refresh_alt_ref_frame ||
+ (cpi->common.refresh_golden_frame &&
+ !cpi->source_alt_ref_active)))
zbin_oqmax = 16;
else
zbin_oqmax = ZBIN_OQ_MAX;
@@ -1307,12 +1318,12 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame)
* normal maximum by expanding the zero bin and hence
* decreasing the number of low magnitude non zero coefficients.
*/
- while (cpi->zbin_over_quant < zbin_oqmax)
+ while (cpi->mb.zbin_over_quant < zbin_oqmax)
{
- cpi->zbin_over_quant ++;
+ cpi->mb.zbin_over_quant ++;
- if (cpi->zbin_over_quant > zbin_oqmax)
- cpi->zbin_over_quant = zbin_oqmax;
+ if (cpi->mb.zbin_over_quant > zbin_oqmax)
+ cpi->mb.zbin_over_quant = zbin_oqmax;
/* Adjust bits_per_mb_at_this_q estimate */
bits_per_mb_at_this_q = (int)(Factor * bits_per_mb_at_this_q);
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index 946d22a8f..f0ec7b6e2 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -223,7 +223,7 @@ void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex];
}
-void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
+void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue)
{
int q;
int i;
@@ -238,15 +238,15 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
cpi->RDMULT = (int)(rdconst * (capped_q * capped_q));
/* Extend rate multiplier along side quantizer zbin increases */
- if (cpi->zbin_over_quant > 0)
+ if (cpi->mb.zbin_over_quant > 0)
{
double oq_factor;
double modq;
/* Experimental code using the same basic equation as used for Q above
- * The units of cpi->zbin_over_quant are 1/128 of Q bin size
+ * The units of cpi->mb.zbin_over_quant are 1/128 of Q bin size
*/
- oq_factor = 1.0 + ((double)0.0015625 * cpi->zbin_over_quant);
+ oq_factor = 1.0 + ((double)0.0015625 * cpi->mb.zbin_over_quant);
modq = (int)((double)capped_q * oq_factor);
cpi->RDMULT = (int)(rdconst * (modq * modq));
}
@@ -265,6 +265,11 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
vp8_set_speed_features(cpi);
+ for (i = 0; i < MAX_MODES; i++)
+ {
+ x->mode_test_hit_counts[i] = 0;
+ }
+
q = (int)pow(Qvalue, 1.25);
if (q < 8)
@@ -279,14 +284,14 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
{
if (cpi->sf.thresh_mult[i] < INT_MAX)
{
- cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
+ x->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
}
else
{
- cpi->rd_threshes[i] = INT_MAX;
+ x->rd_threshes[i] = INT_MAX;
}
- cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
+ cpi->rd_baseline_thresh[i] = x->rd_threshes[i];
}
}
else
@@ -297,14 +302,14 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
{
if (cpi->sf.thresh_mult[i] < (INT_MAX / q))
{
- cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
+ x->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
}
else
{
- cpi->rd_threshes[i] = INT_MAX;
+ x->rd_threshes[i] = INT_MAX;
}
- cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
+ cpi->rd_baseline_thresh[i] = x->rd_threshes[i];
}
}
@@ -625,7 +630,6 @@ static void copy_predictor(unsigned char *dst, const unsigned char *predictor)
d[12] = p[12];
}
static int rd_pick_intra4x4block(
- VP8_COMP *cpi,
MACROBLOCK *x,
BLOCK *be,
BLOCKD *b,
@@ -701,7 +705,7 @@ static int rd_pick_intra4x4block(
return best_rd;
}
-static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
+static int rd_pick_intra4x4mby_modes(MACROBLOCK *mb, int *Rate,
int *rate_y, int *Distortion, int best_rd)
{
MACROBLOCKD *const xd = &mb->e_mbd;
@@ -741,7 +745,7 @@ static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
}
total_rd += rd_pick_intra4x4block(
- cpi, mb, mb->block + i, xd->block + i, &best_mode, bmode_costs,
+ mb, mb->block + i, xd->block + i, &best_mode, bmode_costs,
ta + vp8_block2above[i],
tl + vp8_block2left[i], &r, &ry, &d);
@@ -766,8 +770,7 @@ static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate,
}
-static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi,
- MACROBLOCK *x,
+static int rd_pick_intra16x16mby_mode(MACROBLOCK *x,
int *Rate,
int *rate_y,
int *Distortion)
@@ -869,7 +872,8 @@ static int rd_inter4x4_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate,
return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
}
-static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int *rate_tokenonly, int *distortion)
+static void rd_pick_intra_mbuv_mode(MACROBLOCK *x, int *rate,
+ int *rate_tokenonly, int *distortion)
{
MB_PREDICTION_MODE mode;
MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
@@ -1739,18 +1743,18 @@ static void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
{
if (x->partition_info->bmi[i].mode == NEW4X4)
{
- cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].mv.as_mv.row
+ x->MVcount[0][mv_max+((x->partition_info->bmi[i].mv.as_mv.row
- best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col
+ x->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col
- best_ref_mv->as_mv.col) >> 1)]++;
}
}
}
else if (x->e_mbd.mode_info_context->mbmi.mode == NEWMV)
{
- cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
+ x->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row
- best_ref_mv->as_mv.row) >> 1)]++;
- cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
+ x->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col
- best_ref_mv->as_mv.col) >> 1)]++;
}
}
@@ -2011,7 +2015,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
*returnintra = INT_MAX;
/* Count of the number of MBs tested so far this frame */
- cpi->mbs_tested_so_far++;
+ x->mbs_tested_so_far++;
x->skip = 0;
@@ -2023,7 +2027,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]];
/* Test best rd so far against threshold for trying this mode. */
- if (best_mode.rd <= cpi->rd_threshes[mode_index])
+ if (best_mode.rd <= x->rd_threshes[mode_index])
continue;
if (this_ref_frame < 0)
@@ -2069,19 +2073,21 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
* max If so then prevent it from being tested and increase the
* threshold for its testing
*/
- if (cpi->mode_test_hit_counts[mode_index] && (cpi->mode_check_freq[mode_index] > 1))
+ if (x->mode_test_hit_counts[mode_index] && (cpi->mode_check_freq[mode_index] > 1))
{
- if (cpi->mbs_tested_so_far <= cpi->mode_check_freq[mode_index] * cpi->mode_test_hit_counts[mode_index])
+ if (x->mbs_tested_so_far <= cpi->mode_check_freq[mode_index] * x->mode_test_hit_counts[mode_index])
{
/* Increase the threshold for coding this mode to make it
* less likely to be chosen
*/
- cpi->rd_thresh_mult[mode_index] += 4;
+ x->rd_thresh_mult[mode_index] += 4;
- if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
- cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
- cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ x->rd_threshes[mode_index] =
+ (cpi->rd_baseline_thresh[mode_index] >> 7) *
+ x->rd_thresh_mult[mode_index];
continue;
}
@@ -2091,28 +2097,28 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
* current mode so increment the counter for the number of times
* it has been tested
*/
- cpi->mode_test_hit_counts[mode_index] ++;
+ x->mode_test_hit_counts[mode_index] ++;
/* 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);
@@ -2120,7 +2126,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
if(!uv_intra_done && this_ref_frame == INTRA_FRAME)
{
- rd_pick_intra_mbuv_mode(cpi, x, &uv_intra_rate,
+ rd_pick_intra_mbuv_mode(x, &uv_intra_rate,
&uv_intra_rate_tokenonly,
&uv_intra_distortion);
uv_intra_mode = x->e_mbd.mode_info_context->mbmi.uv_mode;
@@ -2146,7 +2152,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
* coding the BPRED mode: x->mbmode_cost[x->e_mbd.frame_type][BPRED]
*/
int distortion;
- tmp_rd = rd_pick_intra4x4mby_modes(cpi, x, &rate, &rd.rate_y, &distortion, best_mode.yrd);
+ tmp_rd = rd_pick_intra4x4mby_modes(x, &rate, &rd.rate_y, &distortion, best_mode.yrd);
rd.rate2 += rate;
rd.distortion2 += distortion;
@@ -2171,8 +2177,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_rd_thresh;
int distortion;
- this_rd_thresh = (vp8_ref_frame_order[mode_index] == 1) ? cpi->rd_threshes[THR_NEW1] : cpi->rd_threshes[THR_NEW3];
- this_rd_thresh = (vp8_ref_frame_order[mode_index] == 2) ? cpi->rd_threshes[THR_NEW2] : this_rd_thresh;
+ this_rd_thresh = (vp8_ref_frame_order[mode_index] == 1) ?
+ x->rd_threshes[THR_NEW1] : x->rd_threshes[THR_NEW3];
+ this_rd_thresh = (vp8_ref_frame_order[mode_index] == 2) ?
+ x->rd_threshes[THR_NEW2] : this_rd_thresh;
tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv,
best_mode.yrd, mdcounts,
@@ -2465,8 +2473,9 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* 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[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ x->rd_thresh_mult[mode_index] =
+ (x->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ?
+ x->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
}
/* If the mode did not help improve the best error case then raise
@@ -2474,13 +2483,14 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
*/
else
{
- cpi->rd_thresh_mult[mode_index] += 4;
-
- if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
- cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ x->rd_thresh_mult[mode_index] += 4;
- cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
}
+ x->rd_threshes[mode_index] =
+ (cpi->rd_baseline_thresh[mode_index] >> 7) *
+ x->rd_thresh_mult[mode_index];
if (x->skip)
break;
@@ -2490,10 +2500,16 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Reduce the activation RD thresholds for the best choice mode */
if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
{
- int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 2);
-
- cpi->rd_thresh_mult[best_mode_index] = (cpi->rd_thresh_mult[best_mode_index] >= (MIN_THRESHMULT + best_adjustment)) ? cpi->rd_thresh_mult[best_mode_index] - best_adjustment : MIN_THRESHMULT;
- cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
+ int best_adjustment = (x->rd_thresh_mult[best_mode_index] >> 2);
+
+ x->rd_thresh_mult[best_mode_index] =
+ (x->rd_thresh_mult[best_mode_index] >=
+ (MIN_THRESHMULT + best_adjustment)) ?
+ x->rd_thresh_mult[best_mode_index] - best_adjustment :
+ MIN_THRESHMULT;
+ x->rd_threshes[best_mode_index] =
+ (cpi->rd_baseline_thresh[best_mode_index] >> 7) *
+ x->rd_thresh_mult[best_mode_index];
}
/* Note how often each mode chosen as best */
@@ -2595,7 +2611,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
rd_update_mvcount(cpi, x, &best_ref_mv);
}
-void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
+void vp8_rd_pick_intra_mode(MACROBLOCK *x, int *rate_)
{
int error4x4, error16x16;
int rate4x4, rate16x16 = 0, rateuv;
@@ -2607,15 +2623,13 @@ void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
- rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
+ rd_pick_intra_mbuv_mode(x, &rateuv, &rateuv_tokenonly, &distuv);
rate = rateuv;
- error16x16 = rd_pick_intra16x16mby_mode(cpi, x,
- &rate16x16, &rate16x16_tokenonly,
+ error16x16 = rd_pick_intra16x16mby_mode(x, &rate16x16, &rate16x16_tokenonly,
&dist16x16);
- error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
- &rate4x4, &rate4x4_tokenonly,
+ error4x4 = rd_pick_intra4x4mby_modes(x, &rate4x4, &rate4x4_tokenonly,
&dist4x4, error16x16);
if (error4x4 < error16x16)
diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h
index bbcb59f67..1e11fa77d 100644
--- a/vp8/encoder/rdopt.h
+++ b/vp8/encoder/rdopt.h
@@ -65,9 +65,9 @@ static void insertsortsad(int arr[],int idx[], int len)
}
}
-extern void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue);
+extern void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue);
extern void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
-extern void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate);
+extern void vp8_rd_pick_intra_mode(MACROBLOCK *x, int *rate);
static void get_plane_pointers(const YV12_BUFFER_CONFIG *fb,
diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c
index ef41fa8f8..3b5268b61 100644
--- a/vp8/encoder/tokenize.c
+++ b/vp8/encoder/tokenize.c
@@ -23,7 +23,7 @@
#ifdef ENTROPY_STATS
_int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
#endif
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) ;
void vp8_fix_contexts(MACROBLOCKD *x);
#include "dct_value_tokens.h"
@@ -102,11 +102,12 @@ static void fill_value_tokens()
static void tokenize2nd_order_b
(
- MACROBLOCKD *x,
+ MACROBLOCK *x,
TOKENEXTRA **tp,
VP8_COMP *cpi
)
{
+ MACROBLOCKD *xd = &x->e_mbd;
int pt; /* near block/prev token context index */
int c; /* start at DC */
TOKENEXTRA *t = *tp;/* store tokens starting here */
@@ -117,11 +118,11 @@ static void tokenize2nd_order_b
int band, rc, v, token;
int eob;
- b = x->block + 24;
+ b = xd->block + 24;
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + 8;
- l = (ENTROPY_CONTEXT *)x->left_context + 8;
- eob = x->eobs[24];
+ a = (ENTROPY_CONTEXT *)xd->above_context + 8;
+ l = (ENTROPY_CONTEXT *)xd->left_context + 8;
+ eob = xd->eobs[24];
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
if(!eob)
@@ -131,7 +132,7 @@ static void tokenize2nd_order_b
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
@@ -145,7 +146,7 @@ static void tokenize2nd_order_b
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [token];
+ ++x->coef_counts [1] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
@@ -164,7 +165,7 @@ static void tokenize2nd_order_b
t->skip_eob_node = ((pt == 0));
- ++cpi->coef_counts [1] [band] [pt] [token];
+ ++x->coef_counts [1] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
@@ -177,7 +178,7 @@ static void tokenize2nd_order_b
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
@@ -189,12 +190,13 @@ static void tokenize2nd_order_b
static void tokenize1st_order_b
(
- MACROBLOCKD *x,
+ MACROBLOCK *x,
TOKENEXTRA **tp,
int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
VP8_COMP *cpi
)
{
+ MACROBLOCKD *xd = &x->e_mbd;
unsigned int block;
const BLOCKD *b;
int pt; /* near block/prev token context index */
@@ -207,15 +209,15 @@ static void tokenize1st_order_b
int band, rc, v;
int tmp1, tmp2;
- b = x->block;
+ b = xd->block;
/* Luma */
for (block = 0; block < 16; block++, b++)
{
tmp1 = vp8_block2above[block];
tmp2 = vp8_block2left[block];
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)x->left_context + tmp2;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
@@ -228,7 +230,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [type] [c] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [c] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [c] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
@@ -243,7 +245,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [type] [c] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [c] [pt] [token];
+ ++x->coef_counts [type] [c] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c++;
@@ -261,7 +263,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = (pt == 0);
- ++cpi->coef_counts [type] [band] [pt] [token];
+ ++x->coef_counts [type] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
@@ -273,7 +275,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
@@ -287,8 +289,8 @@ static void tokenize1st_order_b
tmp1 = vp8_block2above[block];
tmp2 = vp8_block2left[block];
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)x->left_context + tmp2;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
@@ -299,7 +301,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [2] [0] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
@@ -314,7 +316,7 @@ static void tokenize1st_order_b
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [0] [pt] [token];
+ ++x->coef_counts [2] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
@@ -333,7 +335,7 @@ static void tokenize1st_order_b
t->skip_eob_node = (pt == 0);
- ++cpi->coef_counts [2] [band] [pt] [token];
+ ++x->coef_counts [2] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
@@ -346,7 +348,7 @@ static void tokenize1st_order_b
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
@@ -374,16 +376,18 @@ static int mb_is_skippable(MACROBLOCKD *x, int has_y2_block)
}
-void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
+void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
+ MACROBLOCKD *xd = &x->e_mbd;
int plane_type;
int has_y2_block;
- has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV);
+ has_y2_block = (xd->mode_info_context->mbmi.mode != B_PRED
+ && xd->mode_info_context->mbmi.mode != SPLITMV);
- x->mode_info_context->mbmi.mb_skip_coeff = mb_is_skippable(x, has_y2_block);
- if (x->mode_info_context->mbmi.mb_skip_coeff)
+ xd->mode_info_context->mbmi.mb_skip_coeff =
+ mb_is_skippable(xd, has_y2_block);
+ if (xd->mode_info_context->mbmi.mb_skip_coeff)
{
if (!cpi->common.mb_no_coeff_skip)
{
@@ -391,8 +395,8 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
}
else
{
- vp8_fix_contexts(x);
- cpi->skip_true_count++;
+ vp8_fix_contexts(xd);
+ x->skip_true_count++;
}
return;
@@ -488,7 +492,8 @@ static void stuff2nd_order_b
TOKENEXTRA **tp,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
@@ -498,13 +503,12 @@ static void stuff2nd_order_b
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0;
*a = *l = pt;
-
}
static void stuff1st_order_b
@@ -513,7 +517,8 @@ static void stuff1st_order_b
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
int type,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
@@ -524,20 +529,21 @@ static void stuff1st_order_b
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0; /* 0 <-> all coeff data is zero */
*a = *l = pt;
-
}
+
static
void stuff1st_order_buv
(
TOKENEXTRA **tp,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
@@ -547,38 +553,38 @@ void stuff1st_order_buv
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0; /* 0 <-> all coeff data is zero */
*a = *l = pt;
-
}
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
+ MACROBLOCKD *xd = &x->e_mbd;
+ ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)xd->above_context;
+ ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)xd->left_context;
int plane_type;
int b;
plane_type = 3;
- if((x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV))
+ if((xd->mode_info_context->mbmi.mode != B_PRED
+ && xd->mode_info_context->mbmi.mode != SPLITMV))
{
stuff2nd_order_b(t,
- A + vp8_block2above[24], L + vp8_block2left[24], cpi);
+ A + vp8_block2above[24], L + vp8_block2left[24], cpi, x);
plane_type = 0;
}
for (b = 0; b < 16; b++)
stuff1st_order_b(t,
A + vp8_block2above[b],
- L + vp8_block2left[b], plane_type, cpi);
+ L + vp8_block2left[b], plane_type, cpi, x);
for (b = 16; b < 24; b++)
stuff1st_order_buv(t,
A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
+ L + vp8_block2left[b], cpi, x);
}
void vp8_fix_contexts(MACROBLOCKD *x)