vp8_default_bmode_probs(oci->fc.bmode_prob);
+#if CONFIG_T8X8
+ oci->txfm_mode = ONLY_4X4;
+#endif
oci->mb_no_coeff_skip = 1;
oci->dual_pred_mode = HYBRID_PREDICTION;
oci->no_lpf = 0;
NB_PREDICTION_TYPES = 3,
} DUALPREDMODE_TYPE;
+#if CONFIG_T8X8
+/* TODO: allows larger transform */
+typedef enum
+{
+ ONLY_4X4 = 0,
+ ALLOW_8X8 = 1
+} TXFM_MODE;
+#endif /* CONFIG_T8X8 */
+
typedef struct VP8_COMMON_RTCD
{
#if CONFIG_RUNTIME_CPU_DETECT
/* profile settings */
int experimental;
int mb_no_coeff_skip;
+#if CONFIG_T8X8
+ TXFM_MODE txfm_mode;
+#endif
DUALPREDMODE_TYPE dual_pred_mode;
int no_lpf;
int use_bilinear_mc_filter;
(xd->mb_to_bottom_edge + (16 << 3)) >> 1 : mv->row;
}
+
+
void vp8_build_inter16x16_predictors_mb(MACROBLOCKD *x,
unsigned char *dst_y,
unsigned char *dst_u,
clamp_mv_to_umv_border(&x->block[10].bmi.mv.as_mv, x);
}
+
build_inter_predictors4b(x, &x->block[ 0], 16);
build_inter_predictors4b(x, &x->block[ 2], 16);
build_inter_predictors4b(x, &x->block[ 8], 16);
if (x->mode_info_context->mbmi.need_to_clamp_mvs)
clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.mv.as_mv, x);
+ if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.mv.as_mv, x);
+
x->block[voffset].bmi.mv.as_mv.row =
x->block[uoffset].bmi.mv.as_mv.row ;
x->block[voffset].bmi.mv.as_mv.col =
int i;
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type( xd,
- xd->mode_info_context->mbmi.segment_id);
- xd->mode_info_context->mbmi.txfm_size = tx_type;
+ int tx_type;
+ if( pbi->common.txfm_mode==ONLY_4X4 )
+ {
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ }
+ else if( pbi->common.txfm_mode == ALLOW_8X8 )
+ {
+ if( xd->mode_info_context->mbmi.mode ==B_PRED
+ ||xd->mode_info_context->mbmi.mode ==I8X8_PRED
+ ||xd->mode_info_context->mbmi.mode ==SPLITMV)
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+ else
+ xd->mode_info_context->mbmi.txfm_size = TX_8X8;
+ }
+
+ tx_type = xd->mode_info_context->mbmi.txfm_size;
#endif
if (xd->mode_info_context->mbmi.mb_skip_coeff)
}
/* Read the loop filter level and type */
+#if CONFIG_T8X8
+ pc->txfm_mode = (TXFM_MODE) vp8_read_bit(bc);
+#endif
+
pc->filter_type = (LOOPFILTERTYPE) vp8_read_bit(bc);
pc->filter_level = vp8_read_literal(bc, 6);
pc->sharpness_level = vp8_read_literal(bc, 3);
}
}
#if CONFIG_T8X8
+ if(pbi->common.txfm_mode == ALLOW_8X8)
{
// read coef probability tree
INT16 v;
const vp8_prob *Prob;//
+ int seg_eob;
+ int segment_id = x->mode_info_context->mbmi.segment_id;
+
type = 3;
i = 0;
stop = 16;
if(i==24)
{
VP8_COMBINEENTROPYCONTEXTS(v, *a, *l);
+ if ( segfeature_active( x, segment_id, SEG_LVL_EOB ) )
+ {
+ seg_eob = get_segdata( x, segment_id, SEG_LVL_EOB );
+ }
+ else
+ seg_eob = 64;
}
else
{
VP8_COMBINEENTROPYCONTEXTS_8x8(v, *a, *l, *a1, *l1);
+ if ( segfeature_active( x, segment_id, SEG_LVL_EOB ) )
+ {
+ seg_eob = get_segdata( x, segment_id, SEG_LVL_EOB );
+ }
+ else
+ seg_eob = 64;
}
Prob = coef_probs;
Prob += v * ENTROPY_NODES;
DO_WHILE_8x8:
+//#if CONFIG_SEGFEATURES
+ if ( c == seg_eob )
+ goto BLOCK_FINISHED_8x8;
+
if(i==24)
Prob += coef_bands_x[c];
else
#if CONFIG_T8X8
- do
+ /* do not do this if not evena allowed */
+ if(cpi->common.txfm_mode == ALLOW_8X8)
{
- int j = 0;
-
do
{
- int k = 0;
-
+ int j = 0;
do
{
- /* at every context */
-
- /* calc probs and branch cts for this frame only */
- //vp8_prob new_p [ENTROPY_NODES];
- //unsigned int branch_ct [ENTROPY_NODES] [2];
-
- int t = 0; /* token/prob index */
-
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- cpi->frame_coef_probs_8x8 [i][j][k], cpi->frame_branch_ct_8x8 [i][j][k], cpi->coef_counts_8x8 [i][j][k],
- 256, 1
- );
-
+ int k = 0;
do
{
- const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
- const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ /* at every context */
+ /* calc probs and branch cts for this frame only */
+ //vp8_prob new_p [ENTROPY_NODES];
+ //unsigned int branch_ct [ENTROPY_NODES] [2];
+ int t = 0; /* token/prob index */
+ vp8_tree_probs_from_distribution(
+ MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ cpi->frame_coef_probs_8x8 [i][j][k],
+ cpi->frame_branch_ct_8x8 [i][j][k],
+ cpi->coef_counts_8x8 [i][j][k],
+ 256, 1
+ );
- const vp8_prob old = cpi->common.fc.coef_probs_8x8 [i][j][k][t];
- const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
+ do
+ {
+ const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
+ const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- const int old_b = vp8_cost_branch(ct, old);
- const int new_b = vp8_cost_branch(ct, newp);
+ const vp8_prob old = cpi->common.fc.coef_probs_8x8 [i][j][k][t];
+ const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
- const int update_b = 8 +
- ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
+ const int old_b = vp8_cost_branch(ct, old);
+ const int new_b = vp8_cost_branch(ct, newp);
- const int s = old_b - new_b - update_b;
+ const int update_b = 8 +
+ ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
- if (s > 0)
- savings += s;
+ const int s = old_b - new_b - update_b;
+ if (s > 0)
+ savings += s;
- }
- while (++t < MAX_ENTROPY_TOKENS - 1);
+ }
+ while (++t < MAX_ENTROPY_TOKENS - 1);
+
+ }
+ while (++k < PREV_COEF_CONTEXTS);
}
- while (++k < PREV_COEF_CONTEXTS);
+ while (++j < COEF_BANDS);
}
- while (++j < COEF_BANDS);
+ while (++i < BLOCK_TYPES);
}
- while (++i < BLOCK_TYPES);
#endif
while (++i < BLOCK_TYPES);
#if CONFIG_T8X8
- i = 0;
- do
+ /* do not do this if not evena allowed */
+ if(cpi->common.txfm_mode == ALLOW_8X8)
{
- int j = 0;
-
+ i = 0;
do
{
- int k = 0;
+ int j = 0;
do
{
- //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
- /* at every context */
+ int k = 0;
- /* calc probs and branch cts for this frame only */
- //vp8_prob new_p [ENTROPY_NODES];
- //unsigned int branch_ct [ENTROPY_NODES] [2];
+ do
+ {
+ //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
+ /* at every context */
- int t = 0; /* token/prob index */
+ /* calc probs and branch cts for this frame only */
+ //vp8_prob new_p [ENTROPY_NODES];
+ //unsigned int branch_ct [ENTROPY_NODES] [2];
- //vp8_tree_probs_from_distribution(
- // MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- // new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
- // 256, 1
- // );
+ int t = 0; /* token/prob index */
- do
- {
- const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
- const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
+ //vp8_tree_probs_from_distribution(
+ // MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
+ // new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
+ // 256, 1
+ // );
- vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
- const vp8_prob old = *Pold;
- const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
+ do
+ {
+ const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
+ const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
- const int old_b = vp8_cost_branch(ct, old);
- const int new_b = vp8_cost_branch(ct, newp);
+ vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
+ const vp8_prob old = *Pold;
+ const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
- const int update_b = 8 +
- ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
+ const int old_b = vp8_cost_branch(ct, old);
+ const int new_b = vp8_cost_branch(ct, newp);
- const int s = old_b - new_b - update_b;
- const int u = s > 0 ? 1 : 0;
+ const int update_b = 8 +
+ ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
- vp8_write(w, u, upd);
+ const int s = old_b - new_b - update_b;
+ const int u = s > 0 ? 1 : 0;
+
+ vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
- ++ tree_update_hist_8x8 [i][j][k][t] [u];
+ ++ tree_update_hist_8x8 [i][j][k][t] [u];
#endif
- if (u)
- {
- /* send/use new probability */
+ if (u)
+ {
+ /* send/use new probability */
- *Pold = newp;
- vp8_write_literal(w, newp, 8);
+ *Pold = newp;
+ vp8_write_literal(w, newp, 8);
- savings += s;
+ savings += s;
- }
+ }
- }
- while (++t < MAX_ENTROPY_TOKENS - 1);
+ }
+ while (++t < MAX_ENTROPY_TOKENS - 1);
- /* Accum token counts for generation of default statistics */
+ /* Accum token counts for generation of default statistics */
#ifdef ENTROPY_STATS
- t = 0;
+ t = 0;
- do
- {
- context_counters_8x8 [i][j][k][t] += cpi->coef_counts_8x8 [i][j][k][t];
- }
- while (++t < MAX_ENTROPY_TOKENS);
+ do
+ {
+ context_counters_8x8 [i][j][k][t] += cpi->coef_counts_8x8 [i][j][k][t];
+ }
+ while (++t < MAX_ENTROPY_TOKENS);
#endif
-
+ }
+ while (++k < PREV_COEF_CONTEXTS);
}
- while (++k < PREV_COEF_CONTEXTS);
+ while (++j < COEF_BANDS);
}
- while (++j < COEF_BANDS);
+ while (++i < BLOCK_TYPES);
}
- while (++i < BLOCK_TYPES);
-#endif
+#endif
}
#ifdef PACKET_TESTING
FILE *vpxlogc = 0;
}
}
+#if CONFIG_T8X8
+ vp8_write_bit(bc, pc->txfm_mode);
+#endif
+
// Encode the loop filter level and type
vp8_write_bit(bc, pc->filter_type);
vp8_write_literal(bc, pc->filter_level, 6);
int src_stride;
int eob_max_offset;
+#if CONFIG_T8X8
+ int eob_max_offset_8x8;
+#endif
} BLOCK;
x->active_ptr = cpi->active_map + map_index + mb_col;
+#if CONFIG_T8X8
+ /* force 4x4 transform for mode selection */
+ xd->mode_info_context->mbmi.txfm_size = TX_4X4;
+#endif
+
if (cm->frame_type == KEY_FRAME)
{
*totalrate += vp8cx_encode_intra_macro_block(cpi, x, tp);
vp8_update_zbin_extra(cpi, x);
}
+#if CONFIG_T8X8
+ /* test code: set transform size based on mode selection */
+ if(cpi->common.txfm_mode == ALLOW_8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != B_PRED)
+ {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
+ cpi->t8x8_count++;
+ }
+ else
+ {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
+ cpi->t4x4_count ++;
+ }
+#endif
+
if(x->e_mbd.mode_info_context->mbmi.mode == I8X8_PRED)
{
vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
sum_intra_stats(cpi, x);
vp8_tokenize_mb(cpi, &x->e_mbd, t);
-#if CONFIG_T8X8
- if ( get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id)
- == TX_8X8 )
- {
- cpi->t8x8_count++;
- }
- else
- cpi->t4x4_count++;
-#endif
+
return rate;
}
#ifdef SPEEDSTATS
cpi->dual_pred_count[pred_context]++;
}
+#if CONFIG_T8X8
+ /* test code: set transform size based on mode selection */
+ if( cpi->common.txfm_mode == ALLOW_8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+ && x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_8X8;
+ cpi->t8x8_count ++;
+ }
+ else
+ {
+ x->e_mbd.mode_info_context->mbmi.txfm_size = TX_4X4;
+ cpi->t4x4_count++;
+ }
+#endif
/* switch back to the regular quantizer for the encode */
if (cpi->sf.improved_quant)
{
cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
quantb_pair);
}
-
/* restore cpi->zbin_mode_boost_enabled */
cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
xd->dst.y_stride, xd->dst.uv_stride);
}
}
-#if CONFIG_T8X8
- if ( get_seg_tx_type( xd, *segment_id ) == TX_8X8 )
- {
- cpi->t8x8_count++;
- }
- else
- cpi->t4x4_count++;
-#endif
if (!x->skip)
{
cpi->skip_false_count ++;
}
}
-
return rate;
}
BLOCK *b = &x->block[0];
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id);
- x->e_mbd.mode_info_context->mbmi.txfm_size = tx_type;
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#endif
RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mby)(&x->e_mbd);
void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
{
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id);
- x->e_mbd.mode_info_context->mbmi.txfm_size = tx_type;
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#endif
-
RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mbuv)(&x->e_mbd);
ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
{
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id);
- x->e_mbd.mode_info_context->mbmi.txfm_size = tx_type;
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#endif
vp8_build_inter_predictors_mb(&x->e_mbd);
void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
{
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id);
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#endif
BLOCK *b = &x->block[0];
*/
z->block[i].src_stride = x->block[i].src_stride;
z->block[i].eob_max_offset = x->block[i].eob_max_offset;
+#if CONFIG_T8X8
+ z->block[i].eob_max_offset_8x8 = x->block[i].eob_max_offset_8x8;
+#endif
}
{
set_segdata( xd, 1, SEG_LVL_MODE, ZEROMV );
enable_segfeature(xd, 1, SEG_LVL_MODE);
- if ( !segfeature_active( xd, 1, SEG_LVL_TRANSFORM ) ||
- get_seg_tx_type( xd, 1 ) == TX_4X4 )
- {
- // EOB segment coding not fixed for 8x8 yet
- set_segdata( xd, 1, SEG_LVL_EOB, 0 );
- enable_segfeature(xd, 1, SEG_LVL_EOB);
- }
+ // EOB segment coding not fixed for 8x8 yet
+ set_segdata( xd, 1, SEG_LVL_EOB, 0 );
+ enable_segfeature(xd, 1, SEG_LVL_EOB);
}
}
-
// Disable segmentation and clear down features if alt ref
// is not active for this group
else
// Skip all MBs if high Q
if ( high_q )
{
- // EOB segment coding not fixed for 8x8 yet
- if ( !segfeature_active( xd, 0, SEG_LVL_TRANSFORM ) ||
- get_seg_tx_type( xd, 0 ) == TX_4X4 )
- {
- enable_segfeature(xd, 0, SEG_LVL_EOB);
- set_segdata( xd, 0, SEG_LVL_EOB, 0 );
- }
-
- // EOB segment coding not fixed for 8x8 yet
- if ( !segfeature_active( xd, 1, SEG_LVL_TRANSFORM ) ||
- get_seg_tx_type( xd, 1 ) == TX_4X4 )
- {
- enable_segfeature(xd, 1, SEG_LVL_EOB);
- set_segdata( xd, 1, SEG_LVL_EOB, 0 );
- }
+ enable_segfeature(xd, 0, SEG_LVL_EOB);
+ set_segdata( xd, 0, SEG_LVL_EOB, 0 );
+ enable_segfeature(xd, 1, SEG_LVL_EOB);
+ set_segdata( xd, 1, SEG_LVL_EOB, 0 );
}
-
// Enable data udpate
xd->update_mb_segmentation_data = 1;
}
// No updeates.. leave things as they are.
xd->update_mb_segmentation_map = 0;
xd->update_mb_segmentation_data = 0;
-
-#if CONFIG_T8X8
- {
- vp8_disable_segmentation((VP8_PTR)cpi);
- clearall_segfeatures(xd);
- vp8_enable_segmentation((VP8_PTR)cpi);
- // 8x8TX test code.
- // This assignment does not necessarily make sense but is
- // just to test the mechanism for now.
- enable_segfeature(xd, 0, SEG_LVL_TRANSFORM);
- set_segdata( xd, 0, SEG_LVL_TRANSFORM, TX_4X4 );
- enable_segfeature(xd, 1, SEG_LVL_TRANSFORM);
- set_segdata( xd, 1, SEG_LVL_TRANSFORM, TX_8X8 );
- /* force every mb to use 8x8 transform for testing*/
- vpx_memset(cpi->segmentation_map, 1,
- cpi->common.mb_rows * cpi->common.mb_cols);
-
- }
-#endif
}
}
}
#if CONFIG_INTERNAL_STATS
vp8_clear_system_state();
-
+#if CONFIG_T8X8
+ printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count);
+#endif
if (cpi->pass != 1)
{
FILE *f = fopen("opsnr.stt", "a");
void vp8_fast_quantize_b_8x8_c(BLOCK *b, BLOCKD *d)
{
- int i, rc, eob;
- int zbin;
- int x, y, z, sz;
- short *coeff_ptr = b->coeff;
- short *zbin_ptr = b->zbin;
- short *round_ptr = b->round;
- short *quant_ptr = b->quant;
- short *qcoeff_ptr = d->qcoeff;
- short *dqcoeff_ptr = d->dqcoeff;
- short *dequant_ptr = d->dequant;
- //double q1st = 2;
- vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
- vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
-
- eob = -1;
+ int i, rc, eob;
+ int zbin;
+ int x, y, z, sz;
+ short *coeff_ptr = b->coeff;
+ short *zbin_ptr = b->zbin;
+ short *round_ptr = b->round;
+ short *quant_ptr = b->quant;
+ short *qcoeff_ptr = d->qcoeff;
+ short *dqcoeff_ptr = d->dqcoeff;
+ short *dequant_ptr = d->dequant;
+ //double q1st = 2;
+ vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
+ vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
- for (i = 0; i < 64; i++)
- {
+ eob = -1;
- rc = vp8_default_zig_zag1d_8x8[i];
- z = coeff_ptr[rc];
- //zbin = zbin_ptr[rc!=0]/q1st ;
- zbin = zbin_ptr[rc!=0] ;
- sz = (z >> 31); // sign of z
- x = (z ^ sz) - sz; // x = abs(z)
- if (x >= zbin)
+ for (i = 0; i < 64; i++)
{
- //y = ((int)((x + round_ptr[rc!=0] / q1st) * quant_ptr[rc!=0] * q1st)) >> 16;
- y = ((int)((x + round_ptr[rc!=0]) * quant_ptr[rc!=0])) >> 16;
- x = (y ^ sz) - sz; // get the sign back
- qcoeff_ptr[rc] = x; // write to destination
- //dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
- dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
- dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
- if (y)
- {
- eob = i; // last nonzero coeffs
- }
+ rc = vp8_default_zig_zag1d_8x8[i];
+ z = coeff_ptr[rc];
+ //zbin = zbin_ptr[rc!=0]/q1st ;
+ zbin = zbin_ptr[rc!=0] ;
+
+ sz = (z >> 31); // sign of z
+ x = (z ^ sz) - sz; // x = abs(z)
+
+ if (x >= zbin)
+ {
+ //y = ((int)((x + round_ptr[rc!=0] / q1st) * quant_ptr[rc!=0] * q1st)) >> 16;
+ y = ((int)((x + round_ptr[rc!=0]) * quant_ptr[rc!=0])) >> 16;
+ x = (y ^ sz) - sz; // get the sign back
+ qcoeff_ptr[rc] = x; // write to destination
+ //dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
+ dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
+ dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
+
+ if (y)
+ {
+ eob = i; // last nonzero coeffs
+ }
+ }
}
- }
- d->eob = eob + 1;
+ d->eob = eob + 1;
}
#endif //EXACT_FASTQUANT
eob = -1;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < b->eob_max_offset_8x8; i++)
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
eob = -1;
- for (i = 0; i < 64; i++)
+ for (i = 0; i < b->eob_max_offset_8x8; i++)
{
rc = vp8_default_zig_zag1d_8x8[i];
{
x->block[i].eob_max_offset =
get_segdata( xd, segment_id, SEG_LVL_EOB );
+#if CONFIG_T8X8
+ x->block[i].eob_max_offset_8x8 =
+ get_segdata( xd, segment_id, SEG_LVL_EOB );
+#endif
}
else
+ {
x->block[i].eob_max_offset = 16;
+#if CONFIG_T8X8
+ x->block[i].eob_max_offset_8x8 = 64;
+#endif
+ }
}
// UV
{
x->block[i].eob_max_offset =
get_segdata( xd, segment_id, SEG_LVL_EOB );
+#if CONFIG_T8X8
+ x->block[i].eob_max_offset_8x8 =
+ get_segdata( xd, segment_id, SEG_LVL_EOB );
+#endif
+
}
else
+ {
x->block[i].eob_max_offset = 16;
+#if CONFIG_T8X8
+ x->block[i].eob_max_offset_8x8 = 64;
+#endif
+
+ }
}
// Y2
{
x->block[24].eob_max_offset =
get_segdata( xd, segment_id, SEG_LVL_EOB );
+#if CONFIG_T8X8
+ x->block[24].eob_max_offset_8x8 =
+ get_segdata( xd, segment_id, SEG_LVL_EOB );
+#endif
}
else
+ {
x->block[24].eob_max_offset = 16;
+#if CONFIG_T8X8
+ x->block[24].eob_max_offset_8x8 = 64;
+#endif
+ }
/* save this macroblock QIndex for vp8_update_zbin_extra() */
x->q_index = QIndex;
vpx_memset(cpi->common.fc.pre_mvc, 0, sizeof(cpi->common.fc.pre_mvc)); //initialize pre_mvc to all zero.
+#if CONFIG_T8X8
+ cpi->common.txfm_mode = ONLY_4X4;
+#endif
+
//cpi->common.filter_level = 0; // Reset every key frame.
cpi->common.filter_level = cpi->common.base_qindex * 3 / 8 ;
}
void vp8_setup_inter_frame(VP8_COMP *cpi)
{
+#if CONFIG_T8X8
+ if(cpi->common.Width * cpi->common.Height > 640*360)
+ cpi->common.txfm_mode = ALLOW_8X8;
+ else
+ cpi->common.txfm_mode = ONLY_4X4;
+#endif
+
if(cpi->common.refresh_alt_ref_frame)
{
vpx_memcpy( &cpi->common.fc,
d += ENCODEMB_INVOKE(rtcd, berr)(mb_y2->coeff, x_y2->dqcoeff)<<2;
*Distortion = (d >> 4);
-
// rate
*Rate = vp8_rdcost_mby(mb);
}
+#if CONFIG_T8X8
+
+static int cost_coeffs_2x2(MACROBLOCK *mb,
+ BLOCKD *b, int type,
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
+{
+ int c = !type; /* start at coef 0, unless Y with Y2 */
+ int eob = b->eob;
+ int pt ; /* surrounding block/prev coef predictor */
+ int cost = 0;
+ short *qcoeff_ptr = b->qcoeff;
+
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ assert(eob<=4);
+
+# define QC2X2( I) ( qcoeff_ptr [vp8_default_zig_zag1d[I]] )
+
+ for (; c < eob; c++)
+ {
+ int v = QC2X2(c);
+ int t = vp8_dct_value_tokens_ptr[v].Token;
+ cost += mb->token_costs_8x8[type] [vp8_coef_bands[c]] [pt] [t];
+ cost += vp8_dct_value_cost_ptr[v];
+ pt = vp8_prev_token_class[t];
+ }
+
+# undef QC2X2
+ if (c < 4)
+ cost += mb->token_costs_8x8 [type][vp8_coef_bands[c]]
+ [pt] [DCT_EOB_TOKEN];
+
+ pt = (c != !type); // is eob first coefficient;
+ *a = *l = pt;
+ return cost;
+}
+
+
+static int cost_coeffs_8x8(MACROBLOCK *mb,
+ BLOCKD *b, int type,
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
+ ENTROPY_CONTEXT *a1, ENTROPY_CONTEXT *l1)
+{
+ int c = !type; /* start at coef 0, unless Y with Y2 */
+ int eob = b->eob;
+ int pt ; /* surrounding block/prev coef predictor */
+ int cost = 0;
+ short *qcoeff_ptr = b->qcoeff;
+
+ VP8_COMBINEENTROPYCONTEXTS_8x8(pt, *a, *l, *a1, *l1);
+
+# define QC8X8( I) ( qcoeff_ptr [vp8_default_zig_zag1d_8x8[I]] )
+
+ for (; c < eob; c++)
+ {
+ int v = QC8X8(c);
+ int t = vp8_dct_value_tokens_ptr[v].Token;
+ cost += mb->token_costs_8x8[type] [vp8_coef_bands_8x8[c]] [pt] [t];
+ cost += vp8_dct_value_cost_ptr[v];
+ pt = vp8_prev_token_class[t];
+ }
+
+# undef QC8X8
+ if (c < 64)
+ cost += mb->token_costs_8x8 [type][vp8_coef_bands_8x8[c]]
+ [pt] [DCT_EOB_TOKEN];
+
+ pt = (c != !type); // is eob first coefficient;
+ *a = *l = pt;
+ return cost;
+}
+static int vp8_rdcost_mby_8x8(MACROBLOCK *mb)
+{
+ int cost = 0;
+ int b;
+ MACROBLOCKD *x = &mb->e_mbd;
+ ENTROPY_CONTEXT_PLANES t_above, t_left;
+ ENTROPY_CONTEXT *ta;
+ ENTROPY_CONTEXT *tl;
+
+ vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
+
+ ta = (ENTROPY_CONTEXT *)&t_above;
+ tl = (ENTROPY_CONTEXT *)&t_left;
+
+ for (b = 0; b < 16; b+=4)
+ cost += cost_coeffs_8x8(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
+ ta + vp8_block2above[b], tl + vp8_block2left[b],
+ ta + vp8_block2above[b+4], tl + vp8_block2left[b+4]);
+
+ cost += cost_coeffs_2x2(mb, x->block + 24, PLANE_TYPE_Y2,
+ ta + vp8_block2above[24], tl + vp8_block2left[24]);
+ return cost;
+}
+
+static void macro_block_yrd_8x8( MACROBLOCK *mb,
+ int *Rate,
+ int *Distortion,
+ const VP8_ENCODER_RTCD *rtcd)
+{
+ int b;
+ MACROBLOCKD *const x = &mb->e_mbd;
+ BLOCK *const mb_y2 = mb->block + 24;
+ BLOCKD *const x_y2 = x->block + 24;
+ short *Y2DCPtr = mb_y2->src_diff;
+ BLOCK *beptr;
+ int d;
+
+ ENCODEMB_INVOKE(&rtcd->encodemb, submby)
+ ( mb->src_diff, *(mb->block[0].base_src),
+ mb->e_mbd.predictor, mb->block[0].src_stride );
+
+ vp8_transform_mby_8x8(mb);
+ vp8_quantize_mby_8x8(mb);
+
+ /* remove 1st order dc to properly combine 1st/2nd order distortion */
+ mb->coeff[0] = 0;
+ mb->coeff[64] = 0;
+ mb->coeff[128] = 0;
+ mb->coeff[192] = 0;
+ mb->e_mbd.dqcoeff[0] = 0;
+ mb->e_mbd.dqcoeff[64] = 0;
+ mb->e_mbd.dqcoeff[128] = 0;
+ mb->e_mbd.dqcoeff[192] = 0;
+ d = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(mb, 0) << 2;
+
+#if CONFIG_EXTEND_QRANGE
+ d += ENCODEMB_INVOKE(rtcd, berr)(mb_y2->coeff, x_y2->dqcoeff)<<2;
+#else
+ d += ENCODEMB_INVOKE(&rtcd->encodemb, berr)(mb_y2->coeff, x_y2->dqcoeff);
+#endif
+
+ *Distortion = (d >> 4);
+ // rate
+ *Rate = vp8_rdcost_mby_8x8(mb);
+}
+#endif
static void copy_predictor(unsigned char *dst, const unsigned char *predictor)
{
int *distortion, int fullpixel)
{
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(&x->e_mbd,
- x->e_mbd.mode_info_context->mbmi.segment_id);
+ int tx_type = x->e_mbd.mode_info_context->mbmi.txfm_size;
#endif
ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff,
{
continue;
}
-#if CONFIG_T8X8
- // No 4x4 modes if segment flagged as 8x8
- else if ( ( get_seg_tx_type( xd, segment_id ) == TX_8X8 ) &&
- ( (this_mode == B_PRED)
- ||(this_mode == I8X8_PRED)
- || (this_mode == SPLITMV) ) )
- {
- continue;
- }
-#endif
// Disable this drop out case if either the mode or ref frame
// segment level feature is enabled for this segment. This is to
x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
(&x->e_mbd);
- macro_block_yrd(x, &rate_y, &distortion, IF_RTCD(&cpi->rtcd.encodemb)) ;
+#if CONFIG_T8X8
+ if(cpi->common.txfm_mode == ALLOW_8X8)
+ macro_block_yrd_8x8(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd)) ;
+ else
+#endif
+ macro_block_yrd(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd.encodemb)) ;
rate2 += rate_y;
distortion2 += distortion;
rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode];
}
}
}
-
-
//intermodecost[mode_index] = vp8_cost_mv_ref(this_mode, mdcounts); // Experimental debug code
// Add in the Mv/mode cost
rate2 += vp8_cost_mv_ref(&cpi->common, this_mode, mdcounts);
// Y cost and distortion
- macro_block_yrd(x, &rate_y, &distortion, IF_RTCD(&cpi->rtcd.encodemb));
+#if CONFIG_T8X8
+ if(cpi->common.txfm_mode == ALLOW_8X8)
+ macro_block_yrd_8x8(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd));
+ else
+#endif
+ macro_block_yrd(x, &rate_y, &distortion,
+ IF_RTCD(&cpi->rtcd.encodemb));
+
rate2 += rate_y;
distortion2 += distortion;
&rate16x16, &rate16x16_tokenonly,
&dist16x16);
mode16x16 = x->e_mbd.mode_info_context->mbmi.mode;
-#if CONFIG_T8X8
- if ( get_seg_tx_type( xd,
- xd->mode_info_context->mbmi.segment_id ) == TX_8X8)
- {
- error8x8 = INT_MAX;
- }
- else
-#else
- {
- error8x8 = rd_pick_intra8x8mby_modes(cpi, x,
- &rate8x8, &rate8x8_tokenonly,
- &dist8x8, error16x16);
- mode8x8[0]= x->e_mbd.mode_info_context->bmi[0].as_mode;
- mode8x8[1]= x->e_mbd.mode_info_context->bmi[2].as_mode;
- mode8x8[2]= x->e_mbd.mode_info_context->bmi[8].as_mode;
- mode8x8[3]= x->e_mbd.mode_info_context->bmi[10].as_mode;
- }
-#endif
-#if CONFIG_T8X8
- if ( get_seg_tx_type( xd,
- xd->mode_info_context->mbmi.segment_id ) == TX_4X4 )
- {
- error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
- &rate4x4, &rate4x4_tokenonly,
- &dist4x4, error16x16);
- }
- else
- {
- error4x4 = INT_MAX;
- }
-#else
+ error8x8 = rd_pick_intra8x8mby_modes(cpi, x,
+ &rate8x8, &rate8x8_tokenonly,
+ &dist8x8, error16x16);
+ mode8x8[0]= x->e_mbd.mode_info_context->bmi[0].as_mode;
+ mode8x8[1]= x->e_mbd.mode_info_context->bmi[2].as_mode;
+ mode8x8[2]= x->e_mbd.mode_info_context->bmi[8].as_mode;
+ mode8x8[3]= x->e_mbd.mode_info_context->bmi[10].as_mode;
+
error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
&rate4x4, &rate4x4_tokenonly,
&dist4x4, error16x16);
-#endif
if(error8x8> error16x16)
{
#if CONFIG_T8X8
static void tokenize2nd_order_b_8x8
(
+ MACROBLOCKD *xd,
const BLOCKD *const b,
TOKENEXTRA **tp,
const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
TOKENEXTRA *t = *tp; /* store tokens starting here */
int x;
const short *qcoeff_ptr = b->qcoeff;
+
+ int seg_eob = 64;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
+ {
+ seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
+ }
+
+
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
assert(eob<=4);
++cpi->coef_counts_8x8 [type] [band] [pt] [x];
}
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < 4);
+ while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c <seg_eob);
*tp = t;
pt = (c != !type); /* 0 <-> all coeff data is zero */
#if CONFIG_T8X8
static void tokenize1st_order_b_8x8
(
+ MACROBLOCKD *xd,
const BLOCKD *const b,
TOKENEXTRA **tp,
const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
TOKENEXTRA *t = *tp; /* store tokens starting here */
int x;
const short *qcoeff_ptr = b->qcoeff;
+
+ int seg_eob = 64;
+ int segment_id = xd->mode_info_context->mbmi.segment_id;
+
+ if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
+ {
+ seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
+ }
+
VP8_COMBINEENTROPYCONTEXTS_8x8(pt, *a, *l, *a1, *l1);
do
++cpi->coef_counts_8x8 [type] [band] [pt] [x];
}
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < 64);
+ while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < seg_eob);
*tp = t;
pt = (c != !type); /* 0 <-> all coeff data is zero */
int b;
#if CONFIG_T8X8
- int tx_type = get_seg_tx_type(x, x->mode_info_context->mbmi.segment_id);
+ int tx_type = x->mode_info_context->mbmi.txfm_size;
#endif
// If the MB is going to be skipped because of a segment level flag
{
ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
- tokenize2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type,
+ tokenize2nd_order_b_8x8(x,
+ x->block + 24, t, 1, x->frame_type,
A + vp8_block2above[24], L + vp8_block2left[24], cpi);
}
else
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
for (b = 0; b < 16; b+=4)
{
- tokenize1st_order_b_8x8(x->block + b, t, plane_type, x->frame_type,
+ tokenize1st_order_b_8x8(x,
+ x->block + b, t, plane_type, x->frame_type,
A + vp8_block2above[b],
L + vp8_block2left[b],
A + vp8_block2above[b+1],
}
for (b = 16; b < 24; b+=4) {
- tokenize1st_order_b_8x8(x->block + b, t, 2, x->frame_type,
+ tokenize1st_order_b_8x8(x,
+ x->block + b, t, 2, x->frame_type,
A + vp8_block2above[b],
L + vp8_block2left[b],
A + vp8_block2above[b+1],