Commit 0742b1e4 authored by Deb Mukherjee's avatar Deb Mukherjee

Fixing 8x8/4x4 ADST for intra modes with tx select

This patch allows use of 8x8 and 4x4 ADST correctly for Intra
16x16 modes and Intra 8x8 modes when the block size selected
is smaller than the prediction mode. Also includes some cleanups
and refactoring.

Rebase.

Change-Id: Ie3257bdf07bdb9c6e9476915e3a80183c8fa005a
parent c6787398
......@@ -494,8 +494,23 @@ static TX_TYPE txfm_map(B_PREDICTION_MODE bmode) {
return tx_type;
}
#define USE_ADST_FOR_I16X16_8X8 0
#define USE_ADST_FOR_I16X16_4X4 0
#define USE_ADST_FOR_I8X8_4X4 1
#define USE_ADST_PERIPHERY_ONLY 1
static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, const BLOCKD *b) {
// TODO(debargha): explore different patterns for ADST usage when blocksize
// is smaller than the prediction size
TX_TYPE tx_type = DCT_DCT;
int ib = (int)(b - xd->block);
if (ib >= 16)
return tx_type;
#if CONFIG_SUPERBLOCKS
// TODO(rbultje, debargha): Explore ADST usage for superblocks
if (xd->mode_info_context->mbmi.encoded_as_sb)
return tx_type;
#endif
if (xd->mode_info_context->mbmi.mode == B_PRED &&
xd->q_index < ACTIVE_HT) {
tx_type = txfm_map(
......@@ -503,28 +518,92 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, const BLOCKD *b) {
b->bmi.as_mode.first == B_CONTEXT_PRED ? b->bmi.as_mode.context :
#endif
b->bmi.as_mode.first);
} else if (xd->mode_info_context->mbmi.mode == I8X8_PRED &&
xd->q_index < ACTIVE_HT) {
#if USE_ADST_FOR_I8X8_4X4
#if USE_ADST_PERIPHERY_ONLY
// Use ADST for periphery blocks only
int ic = (ib & 10);
b += ic - ib;
tx_type = (ic != 10) ?
txfm_map(pred_mode_conv((MB_PREDICTION_MODE)b->bmi.as_mode.first)) :
DCT_DCT;
#else
// Use ADST
tx_type = txfm_map(pred_mode_conv(
(MB_PREDICTION_MODE)b->bmi.as_mode.first));
#endif
#else
// Use 2D DCT
tx_type = DCT_DCT;
#endif
} else if (xd->mode_info_context->mbmi.mode < I8X8_PRED &&
xd->q_index < ACTIVE_HT) {
#if USE_ADST_FOR_I16X16_4X4
#if USE_ADST_PERIPHERY_ONLY
// Use ADST for periphery blocks only
tx_type = (ib < 4 || ((ib & 3) == 0)) ?
txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode)) : DCT_DCT;
#else
// Use ADST
tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
#endif
#else
// Use 2D DCT
tx_type = DCT_DCT;
#endif
}
return tx_type;
}
static TX_TYPE get_tx_type_8x8(const MACROBLOCKD *xd, const BLOCKD *b) {
// TODO(debargha): explore different patterns for ADST usage when blocksize
// is smaller than the prediction size
TX_TYPE tx_type = DCT_DCT;
int ib = (int)(b - xd->block);
if (ib >= 16)
return tx_type;
#if CONFIG_SUPERBLOCKS
// TODO(rbultje, debargha): Explore ADST usage for superblocks
if (xd->mode_info_context->mbmi.encoded_as_sb)
return tx_type;
#endif
if (xd->mode_info_context->mbmi.mode == I8X8_PRED &&
xd->q_index < ACTIVE_HT8) {
// TODO(rbultje): MB_PREDICTION_MODE / B_PREDICTION_MODE should be merged
// or the relationship otherwise modified to address this type conversion.
tx_type = txfm_map(pred_mode_conv(
(MB_PREDICTION_MODE)b->bmi.as_mode.first));
(MB_PREDICTION_MODE)b->bmi.as_mode.first));
} else if (xd->mode_info_context->mbmi.mode < I8X8_PRED &&
xd->q_index < ACTIVE_HT8) {
#if USE_ADST_FOR_I8X8_4X4
#if USE_ADST_PERIPHERY_ONLY
// Use ADST for periphery blocks only
tx_type = (ib != 10) ?
txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode)) : DCT_DCT;
#else
// Use ADST
tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
#endif
#else
// Use 2D DCT
tx_type = DCT_DCT;
#endif
}
return tx_type;
}
static TX_TYPE get_tx_type_16x16(const MACROBLOCKD *xd, const BLOCKD *b) {
TX_TYPE tx_type = DCT_DCT;
if (xd->mode_info_context->mbmi.mode < I8X8_PRED &&
int ib = (int)(b - xd->block);
if (ib >= 16)
return tx_type;
#if CONFIG_SUPERBLOCKS
!xd->mode_info_context->mbmi.encoded_as_sb &&
// TODO(rbultje, debargha): Explore ADST usage for superblocks
if (xd->mode_info_context->mbmi.encoded_as_sb)
return tx_type;
#endif
if (xd->mode_info_context->mbmi.mode < I8X8_PRED &&
xd->q_index < ACTIVE_HT16) {
tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
}
......@@ -549,6 +628,16 @@ static TX_TYPE get_tx_type(const MACROBLOCKD *xd, const BLOCKD *b) {
return tx_type;
}
static int get_2nd_order_usage(const MACROBLOCKD *xd) {
int has_2nd_order = (xd->mode_info_context->mbmi.mode != SPLITMV &&
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != B_PRED &&
xd->mode_info_context->mbmi.txfm_size != TX_16X16);
if (has_2nd_order)
has_2nd_order = (get_tx_type(xd, xd->block) == DCT_DCT);
return has_2nd_order;
}
extern void vp9_build_block_doffsets(MACROBLOCKD *xd);
extern void vp9_setup_block_dptrs(MACROBLOCKD *xd);
......
......@@ -40,20 +40,28 @@ void vp9_inverse_transform_b_4x4(MACROBLOCKD *xd, int block, int pitch) {
void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) {
int i;
BLOCKD *blockd = xd->block;
int has_2nd_order = get_2nd_order_usage(xd);
if (xd->mode_info_context->mbmi.mode != SPLITMV) {
if (has_2nd_order) {
/* do 2nd order transform on the dc block */
vp9_short_inv_walsh4x4(blockd[24].dqcoeff, blockd[24].diff);
recon_dcblock(xd);
}
for (i = 0; i < 16; i++) {
vp9_inverse_transform_b_4x4(xd, i, 32);
TX_TYPE tx_type = get_tx_type_4x4(xd, &xd->block[i]);
if (tx_type != DCT_DCT) {
vp9_ihtllm_c(xd->block[i].dqcoeff, xd->block[i].diff, 32,
tx_type, 4);
} else {
vp9_inverse_transform_b_4x4(xd, i, 32);
}
}
}
void vp9_inverse_transform_mbuv_4x4(MACROBLOCKD *xd) {
int i;
for (i = 16; i < 24; i++) {
vp9_inverse_transform_b_4x4(xd, i, 16);
}
......@@ -72,20 +80,31 @@ void vp9_inverse_transform_b_8x8(short *input_dqcoeff, short *output_coeff,
void vp9_inverse_transform_mby_8x8(MACROBLOCKD *xd) {
int i;
BLOCKD *blockd = xd->block;
int has_2nd_order = get_2nd_order_usage(xd);
if (xd->mode_info_context->mbmi.mode != SPLITMV) {
if (has_2nd_order) {
// do 2nd order transform on the dc block
vp9_short_ihaar2x2(blockd[24].dqcoeff, blockd[24].diff, 8);
recon_dcblock_8x8(xd); // need to change for 8x8
}
for (i = 0; i < 9; i += 8) {
vp9_inverse_transform_b_8x8(&blockd[i].dqcoeff[0],
&blockd[i].diff[0], 32);
TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[i]);
if (tx_type != DCT_DCT) {
vp9_ihtllm_c(xd->block[i].dqcoeff, xd->block[i].diff, 32, tx_type, 8);
} else {
vp9_inverse_transform_b_8x8(&blockd[i].dqcoeff[0],
&blockd[i].diff[0], 32);
}
}
for (i = 2; i < 11; i += 8) {
vp9_inverse_transform_b_8x8(&blockd[i + 2].dqcoeff[0],
&blockd[i].diff[0], 32);
TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[i]);
if (tx_type != DCT_DCT) {
vp9_ihtllm_c(xd->block[i + 2].dqcoeff, xd->block[i].diff, 32, tx_type, 8);
} else {
vp9_inverse_transform_b_8x8(&blockd[i + 2].dqcoeff[0],
&blockd[i].diff[0], 32);
}
}
}
......@@ -110,8 +129,14 @@ void vp9_inverse_transform_b_16x16(short *input_dqcoeff,
}
void vp9_inverse_transform_mby_16x16(MACROBLOCKD *xd) {
vp9_inverse_transform_b_16x16(&xd->block[0].dqcoeff[0],
&xd->block[0].diff[0], 32);
BLOCKD *bd = &xd->block[0];
TX_TYPE tx_type = get_tx_type_16x16(xd, bd);
if (tx_type != DCT_DCT) {
vp9_ihtllm_c(bd->dqcoeff, bd->diff, 32, tx_type, 16);
} else {
vp9_inverse_transform_b_16x16(&xd->block[0].dqcoeff[0],
&xd->block[0].diff[0], 32);
}
}
void vp9_inverse_transform_mb_16x16(MACROBLOCKD *xd) {
......
......@@ -278,7 +278,7 @@ void vp9_find_mv_refs(
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
if (c2_ref_frame > INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c2_ref_frame == ref_frame) << 4);
......@@ -304,7 +304,7 @@ void vp9_find_mv_refs(
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
if (c2_ref_frame > INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c2_ref_frame == ref_frame) << 4);
......@@ -337,7 +337,7 @@ void vp9_find_mv_refs(
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
if (c2_ref_frame > INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c2_ref_frame == ref_frame) << 4);
......
......@@ -382,8 +382,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
// TODO(debargha): Explore different ways of combining predictors
// or designing the tables below
static const int scale_bits = 8;
static const int scale_max = 1 << scale_bits;
static const int scale_round = (1 << scale_bits) - 1;
static const int scale_max = 256; // 1 << scale_bits;
static const int scale_round = 127; // (1 << (scale_bits - 1));
// This table is a function A + B*exp(-kx), where x is hor. index
static const int weights1d[32] = {
128, 122, 116, 111, 107, 103, 99, 96,
......
......@@ -28,6 +28,10 @@
#ifdef DEBUG_DEC_MV
int dec_mvcount = 0;
#endif
// #define DEC_DEBUG
#ifdef DEC_DEBUG
extern int dec_debug;
#endif
static int read_bmode(vp9_reader *bc, const vp9_prob *p) {
B_PREDICTION_MODE m = treed_read(bc, vp9_bmode_tree, p);
......@@ -775,6 +779,11 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
xd->pre.u_buffer = cm->yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
xd->pre.v_buffer = cm->yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset;
#ifdef DEC_DEBUG
if (dec_debug)
printf("%d %d\n", xd->mode_info_context->mbmi.mv[0].as_mv.row,
xd->mode_info_context->mbmi.mv[0].as_mv.col);
#endif
vp9_find_mv_refs(xd, mi, prev_mi,
ref_frame, mbmi->ref_mvs[ref_frame],
cm->ref_frame_sign_bias);
......@@ -787,6 +796,12 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp9_mv_ref_probs(&pbi->common, mv_ref_p,
mbmi->mb_mode_context[ref_frame]);
#ifdef DEC_DEBUG
if (dec_debug)
printf("[D %d %d] %d %d %d %d\n", ref_frame,
mbmi->mb_mode_context[ref_frame],
mv_ref_p[0], mv_ref_p[1], mv_ref_p[2], mv_ref_p[3]);
#endif
}
// Is the segment level mode feature enabled for this segment
......
This diff is collapsed.
......@@ -14,10 +14,6 @@
#include "vpx_mem/vpx_mem.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#ifdef DEC_DEBUG
extern int dec_debug;
#endif
static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch,
uint8_t *dest, int stride, int width, int height) {
int r, c;
......@@ -201,16 +197,6 @@ void vp9_dequantize_b_2x2_c(BLOCKD *d) {
for (i = 0; i < 16; i++) {
DQ[i] = (int16_t)((Q[i] * DQC[i]));
}
#ifdef DEC_DEBUG
if (dec_debug) {
int j;
printf("Dequantize 2x2\n");
for (j = 0; j < 16; j++) printf("%d ", Q[j]);
printf("\n");
for (j = 0; j < 16; j++) printf("%d ", DQ[j]);
printf("\n");
}
#endif
}
void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
......@@ -220,17 +206,6 @@ void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
int16_t *diff_ptr = output;
int i;
#ifdef DEC_DEBUG
if (dec_debug) {
int j;
printf("Input 8x8\n");
for (j = 0; j < 64; j++) {
printf("%d ", input[j]);
if (j % 8 == 7) printf("\n");
}
}
#endif
/* If dc is 1, then input[0] is the reconstructed value, do not need
* dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.
*/
......@@ -282,47 +257,13 @@ void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
for (i = 1; i < 64; i++) {
input[i] = input[i] * dq[1];
}
#ifdef DEC_DEBUG
if (dec_debug) {
int j;
printf("Input DQ 8x8\n");
for (j = 0; j < 64; j++) {
printf("%d ", input[j]);
if (j % 8 == 7) printf("\n");
}
}
#endif
// the idct halves ( >> 1) the pitch
vp9_short_idct8x8_c(input, output, 16);
#ifdef DEC_DEBUG
if (dec_debug) {
int j;
printf("Output 8x8\n");
for (j = 0; j < 64; j++) {
printf("%d ", output[j]);
if (j % 8 == 7) printf("\n");
}
}
#endif
vpx_memset(input, 0, 128);
add_residual(diff_ptr, pred, pitch, dest, stride, 8, 8);
#ifdef DEC_DEBUG
if (dec_debug) {
int k, j;
printf("Final 8x8\n");
for (j = 0; j < 8; j++) {
for (k = 0; k < 8; k++) {
printf("%d ", origdest[k]);
}
printf("\n");
origdest += stride;
}
}
#endif
}
}
......
......@@ -59,12 +59,11 @@ static const unsigned char cat6_prob[14] =
{ 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) {
/* Clear entropy contexts for Y2 blocks */
/* Clear entropy contexts */
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_16X16
) {
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != SPLITMV)
|| xd->mode_info_context->mbmi.txfm_size == TX_16X16) {
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
} else {
......@@ -309,10 +308,9 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
int c, i, eobtotal = 0, seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
int has_2nd_order = get_2nd_order_usage(xd);
// 2nd order DC block
if (xd->mode_info_context->mbmi.mode != B_PRED &&
xd->mode_info_context->mbmi.mode != SPLITMV &&
xd->mode_info_context->mbmi.mode != I8X8_PRED) {
if (has_2nd_order) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[24];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[24];
......@@ -325,6 +323,7 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC;
}
......@@ -336,7 +335,7 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, type,
type == PLANE_TYPE_Y_WITH_DC ?
get_tx_type(xd, xd->block + i) : DCT_DCT,
get_tx_type(xd, xd->block + i) : DCT_DCT,
seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8);
......@@ -392,7 +391,7 @@ int vp9_decode_coefs_4x4(VP9D_COMP *dx, MACROBLOCKD *xd,
TX_TYPE tx_type = DCT_DCT;
if (type == PLANE_TYPE_Y_WITH_DC)
tx_type = get_tx_type(xd, &xd->block[i]);
tx_type = get_tx_type_4x4(xd, &xd->block[i]);
switch (tx_type) {
case ADST_DCT :
scan = vp9_row_scan;
......@@ -429,14 +428,15 @@ static int vp9_decode_mb_tokens_4x4(VP9D_COMP* const dx,
int i, eobtotal = 0;
PLANE_TYPE type;
if (xd->mode_info_context->mbmi.mode != B_PRED &&
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != SPLITMV) {
int has_2nd_order = get_2nd_order_usage(xd);
if (has_2nd_order) {
eobtotal += vp9_decode_coefs_4x4(dx, xd, bc, PLANE_TYPE_Y2, 24) - 16;
type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
xd->eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC;
}
......
......@@ -23,8 +23,7 @@
* the regular quantize_b function pointer */
void vp8_quantize_mby_neon(MACROBLOCK *x) {
int i;
int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
int has_2nd_order = get_2nd_order_usage(xd);
for (i = 0; i < 16; i += 2)
x->quantize_b_pair(&x->block[i], &x->block[i + 1],
......@@ -36,8 +35,7 @@ void vp8_quantize_mby_neon(MACROBLOCK *x) {
void vp8_quantize_mb_neon(MACROBLOCK *x) {
int i;
int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
int has_2nd_order = get_2nd_order_usage(xd);
for (i = 0; i < 24; i += 2)
x->quantize_b_pair(&x->block[i], &x->block[i + 1],
......
......@@ -939,7 +939,6 @@ static void pack_inter_mode_mvs(VP9_COMP *const cpi, vp9_writer *const bc) {
#endif
write_ymode(bc, mode, pc->fc.ymode_prob);
}
if (mode == B_PRED) {
int j = 0;
#if CONFIG_COMP_INTRA_PRED
......
......@@ -47,9 +47,9 @@
#define IF_RTCD(x) NULL
#endif
// #define ENC_DEBUG
#ifdef ENC_DEBUG
int enc_debug = 0;
int mb_row_debug, mb_col_debug;
#endif
static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
......@@ -557,7 +557,7 @@ static void update_state(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->ref_mvs[rf], &best_mv);
mbmi->best_index = best_index;
if (mbmi->second_ref_frame) {
if (mbmi->second_ref_frame > 0) {
unsigned int best_index;
best_index =
pick_best_mv_ref(x, sec_ref_frame, mbmi->mv[1],
......@@ -764,6 +764,12 @@ static void pick_mb_modes(VP9_COMP *cpi,
cpi->seg0_progress = (((mb_col & ~1) * 2 + (mb_row & ~1) * cm->mb_cols + i) << 16) / cm->MBs;
}
#ifdef ENC_DEBUG
enc_debug = (cpi->common.current_video_frame == 73 &&
mb_row == 4 && mb_col == 13);
if (enc_debug)
printf("pick_mb_modes %d %d\n", mb_row, mb_col);
#endif
vp9_pick_mode_inter_macroblock(cpi, x, recon_yoffset,
recon_uvoffset, &r, &d);
*totalrate += r;
......@@ -1015,13 +1021,6 @@ static void encode_sb(VP9_COMP *cpi,
xd->mb_index = i;
#ifdef ENC_DEBUG
enc_debug = (cpi->common.current_video_frame == 0 &&
mb_row == 0 && mb_col == 0);
mb_col_debug = mb_col;
mb_row_debug = mb_row;
#endif
// Restore MB state to that when it was picked
#if CONFIG_SUPERBLOCKS
if (xd->mode_info_context->mbmi.encoded_as_sb) {
......@@ -1424,7 +1423,8 @@ static void encode_frame_internal(VP9_COMP *cpi) {
TOKENEXTRA *tp = cpi->tok;
int totalrate;
//printf("encode_frame_internal\n");
// printf("encode_frame_internal frame %d (%d)\n",
// cpi->common.current_video_frame, cpi->common.show_frame);
// Compute a modified set of reference frame probabilities to use when
// prediction fails. These are based on the current general estimates for
......@@ -2033,6 +2033,12 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
assert(!xd->mode_info_context->mbmi.encoded_as_sb);
#endif
#ifdef ENC_DEBUG
enc_debug = (cpi->common.current_video_frame == 73 &&
mb_row == 4 && mb_col == 13);
if (enc_debug)
printf("Encode MB %d %d output %d\n", mb_row, mb_col, output_enabled);
#endif
if (cm->frame_type == KEY_FRAME) {
if (cpi->oxcf.tuning == VP8_TUNE_SSIM && output_enabled) {
// Adjust the zbin based on this MB rate.
......@@ -2076,6 +2082,12 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
}
if (mbmi->ref_frame == INTRA_FRAME) {
#ifdef ENC_DEBUG
if (enc_debug) {
printf("Mode %d skip %d tx_size %d\n", mbmi->mode, x->skip,
mbmi->txfm_size);
}
#endif
if (mbmi->mode == B_PRED) {
vp9_encode_intra16x16mbuv(x);
vp9_encode_intra4x4mby(x);
......@@ -2091,6 +2103,13 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
sum_intra_stats(cpi, x);
} else {
int ref_fb_idx;
#ifdef ENC_DEBUG
if (enc_debug)
printf("Mode %d skip %d tx_size %d ref %d ref2 %d mv %d %d\n",
mbmi->mode, x->skip, mbmi->txfm_size,
mbmi->ref_frame, mbmi->second_ref_frame,
mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col);
#endif
assert(cm->frame_type != KEY_FRAME);
......@@ -2131,40 +2150,88 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->mb_skip_coeff = 0;
} else {
vp9_build_1st_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
xd->dst.u_buffer, xd->dst.v_buffer,
vp9_build_1st_inter16x16_predictors_mb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
xd->dst.v_buffer,
xd->dst.y_stride,
xd->dst.uv_stride);
if (xd->mode_info_context->mbmi.second_ref_frame > 0) {
vp9_build_2nd_inter16x16_predictors_mb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
xd->dst.v_buffer,
xd->dst.y_stride,
xd->dst.uv_stride);
}
#if CONFIG_COMP_INTERINTRA_PRED
else if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
vp9_build_interintra_16x16_predictors_mb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
xd->dst.v_buffer,
xd->dst.y_stride,
xd->dst.uv_stride);
}
#endif
}
}
if (!x->skip) {
#ifdef ENC_DEBUG
if (enc_debug) {
int i;
printf("Segment=%d [%d, %d]: %d %d:\n", mbmi->segment_id, mb_col_debug,
mb_row_debug, xd->mb_to_left_edge, xd->mb_to_top_edge);
int i, j;
printf("\n");
printf("qcoeff\n");
for (i = 0; i < 400; i++) {
printf("%3d ", xd->qcoeff[i]);
if (i % 16 == 15) printf("\n");
}
printf("\n");
printf("eobs = ");
for (i = 0; i < 25; i++)
printf("%d:%d ", i, xd->block[i].eob);
printf("predictor\n");
for (i = 0; i < 384; i++) {
printf("%3d ", xd->predictor[i]);
if (i % 16 == 15) printf("\n");
}
printf("\n");
printf("src_diff\n");
for (i = 0; i < 384; i++) {
printf("%3d ", x->src_diff[i]);
if (i % 16 == 15) printf("\n");
}
printf("\n");
printf("diff\n");
for (i = 0; i < 384; i++) {
printf("%3d ", xd->block[0].diff[i]);
if (i % 16 == 15) printf("\n");
}
printf("\n");
printf("final y\n");
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++)
printf("%3d ", xd->dst.y_buffer[i * xd->dst.y_stride + j]);
printf("\n");
}
printf("\n");
printf("final u\n");
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++)
printf("%3d ", xd->dst.u_buffer[i * xd->dst.uv_stride + j]);
printf("\n");
}
printf("\n");
printf("final v\n");
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++)
printf("%3d ", xd->dst.v_buffer[i * xd->dst.uv_stride + j]);
printf("\n");
}
fflush(stdout);
}
#endif
vp9_tokenize_mb(cpi, xd, t, !output_enabled);
#ifdef ENC_DEBUG
if (enc_debug) {
printf("Tokenized\n");
fflush(stdout);
}
#endif
} else {
int mb_skip_context =
cpi->common.mb_no_coeff_skip ?
......
......@@ -72,7 +72,7 @@ void vp9_encode_intra4x4block(MACROBLOCK *x, int ib) {
vp9_subtract_b(be, b, 16);
tx_type = get_tx_type(&x->e_mbd, b);
tx_type = get_tx_type_4x4(&x->e_mbd, b);
if (tx_type != DCT_DCT) {
vp9_fht(be->src_diff, 32, be->coeff, tx_type, 4);
vp9_ht_quantize_b_4x4(be, b, tx_type);
......@@ -112,21 +112,11 @@ void vp9_encode_intra16x16mby(MACROBLOCK *x) {
vp9_subtract_mby(x->src_diff, *(b->base_src), xd->predictor, b->src_stride);
if (tx_size == TX_16X16) {
BLOCKD *bd = &xd->block[0];
tx_type = get_tx_type(xd, bd);
if (tx_type != DCT_DCT) {
vp9_fht(b->src_diff, 32, b->coeff, tx_type, 16);
vp9_quantize_mby_16x16(x);
if (x->optimize)
vp9_optimize_mby_16x16(x);