diff options
Diffstat (limited to 'vp8')
-rw-r--r-- | vp8/common/default_coef_probs.h | 53 | ||||
-rw-r--r-- | vp8/common/entropy.h | 4 | ||||
-rw-r--r-- | vp8/common/entropymv.h | 2 | ||||
-rw-r--r-- | vp8/common/pred_common.c | 2 | ||||
-rw-r--r-- | vp8/common/type_aliases.h | 3 | ||||
-rw-r--r-- | vp8/decoder/decodframe.c | 25 | ||||
-rw-r--r-- | vp8/decoder/detokenize.c | 38 | ||||
-rw-r--r-- | vp8/encoder/block.h | 2 | ||||
-rw-r--r-- | vp8/encoder/encodeintra.c | 23 | ||||
-rw-r--r-- | vp8/encoder/encodemb.c | 8 | ||||
-rw-r--r-- | vp8/encoder/rdopt.c | 169 | ||||
-rw-r--r-- | vp8/encoder/rdopt.h | 8 | ||||
-rw-r--r-- | vp8/encoder/tokenize.c | 108 |
13 files changed, 367 insertions, 78 deletions
diff --git a/vp8/common/default_coef_probs.h b/vp8/common/default_coef_probs.h index d0e114a3d..145faf1ac 100644 --- a/vp8/common/default_coef_probs.h +++ b/vp8/common/default_coef_probs.h @@ -434,4 +434,57 @@ vp8_default_coef_probs_8x8[BLOCK_TYPES_8X8] { 6, 117, 180, 254, 199, 216, 255, 251, 128, 128, 128} } } +#if CONFIG_HTRANS8X8 + , + { /* block Type 3 */ + { /* Coeff Band 0 */ + { 192, 18, 155, 172, 145, 164, 192, 135, 246, 223, 255}, + { 94, 29, 97, 131, 131, 153, 171, 121, 250, 190, 255}, + { 25, 29, 63, 128, 119, 147, 168, 124, 251, 183, 255}, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128} + }, + { /* Coeff Band 1 */ + { 1, 108, 192, 220, 186, 173, 255, 194, 255, 255, 128}, + { 123, 104, 188, 221, 165, 171, 247, 180, 255, 255, 128}, + { 23, 76, 152, 216, 154, 166, 226, 182, 255, 209, 128}, + { 1, 26, 52, 162, 109, 152, 208, 144, 255, 231, 128} + }, + { /* Coeff Band 2 */ + { 1, 57, 179, 220, 156, 175, 210, 158, 255, 223, 128}, + { 48, 57, 134, 212, 151, 170, 219, 185, 255, 248, 128}, + { 4, 35, 63, 189, 120, 156, 221, 159, 255, 241, 128}, + { 1, 17, 23, 110, 97, 143, 187, 120, 255, 234, 128} + }, + { /* Coeff Band 3 */ + { 1, 115, 205, 243, 182, 187, 254, 218, 255, 255, 128}, + { 80, 101, 186, 241, 183, 186, 249, 182, 255, 255, 128}, + { 10, 81, 144, 229, 164, 175, 241, 185, 255, 255, 128}, + { 1, 44, 81, 192, 130, 148, 240, 180, 255, 255, 128} + }, + { /* Coeff Band 4 */ + { 1, 161, 207, 249, 187, 176, 255, 180, 128, 128, 128}, + { 79, 148, 196, 240, 186, 182, 253, 171, 255, 255, 128}, + { 14, 111, 171, 233, 170, 178, 235, 204, 255, 255, 128}, + { 1, 63, 103, 202, 143, 162, 240, 178, 255, 255, 128} + }, + { /* Coeff Band 5 */ + { 1, 101, 202, 239, 185, 184, 252, 186, 255, 255, 128}, + { 43, 67, 166, 237, 178, 190, 246, 194, 255, 255, 128}, + { 4, 49, 85, 220, 140, 168, 253, 182, 255, 255, 128}, + { 1, 24, 35, 144, 93, 135, 239, 159, 255, 253, 128} + }, + { /* Coeff Band 6 */ + { 1, 212, 243, 255, 240, 234, 255, 255, 128, 128, 128}, + { 98, 168, 234, 255, 229, 234, 255, 255, 128, 128, 128}, + { 19, 127, 199, 255, 212, 198, 255, 255, 128, 128, 128}, + { 1, 103, 162, 253, 186, 151, 255, 255, 128, 128, 128} + }, + { /* Coeff Band 7 */ + { 1, 188, 253, 255, 255, 128, 128, 128, 128, 128, 128}, + { 191, 68, 242, 255, 255, 128, 128, 128, 128, 128, 128}, + { 8, 132, 255, 128, 128, 128, 128, 128, 128, 128, 128}, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128} + } + } +#endif }; diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h index 9993741c8..36cae410c 100644 --- a/vp8/common/entropy.h +++ b/vp8/common/entropy.h @@ -63,7 +63,11 @@ extern vp8_extra_bit_struct vp8_extra_bits[12]; /* indexed by token value */ #define BLOCK_TYPES 4 +#if CONFIG_HTRANS8X8 +#define BLOCK_TYPES_8X8 4 +#else #define BLOCK_TYPES_8X8 3 +#endif /* Middle dimension is a coarsening of the coefficient's position within the 4x4 DCT. */ diff --git a/vp8/common/entropymv.h b/vp8/common/entropymv.h index c0726ecea..9141c2bce 100644 --- a/vp8/common/entropymv.h +++ b/vp8/common/entropymv.h @@ -79,9 +79,7 @@ extern struct vp8_token_struct vp8_small_mvencodings_hp [16]; #endif void vp8_entropy_mv_init(); -#if CONFIG_ADAPTIVE_ENTROPY struct VP8Common; void vp8_adapt_mv_probs(struct VP8Common *cm); -#endif #endif diff --git a/vp8/common/pred_common.c b/vp8/common/pred_common.c index b7d52a54f..ac5d86009 100644 --- a/vp8/common/pred_common.c +++ b/vp8/common/pred_common.c @@ -170,11 +170,9 @@ vp8_prob *get_pred_probs(VP8_COMMON *const cm, pred_probability = &cm->prob_comppred[pred_context]; break; -#if CONFIG_NEWENTROPY case PRED_MBSKIP: pred_probability = &cm->mbskip_pred_probs[pred_context]; break; -#endif #if CONFIG_SWITCHABLE_INTERP case PRED_SWITCHABLE_INTERP: diff --git a/vp8/common/type_aliases.h b/vp8/common/type_aliases.h index 22b531a76..eda6a2ec2 100644 --- a/vp8/common/type_aliases.h +++ b/vp8/common/type_aliases.h @@ -97,6 +97,9 @@ typedef unsigned char BOOLEAN; #ifdef _MSC_VER typedef __int64 INT64; +#ifndef INT64_MAX +#define INT64_MAX LLONG_MAX +#endif #else #ifndef TYPE_INT64 diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c index 2d91b3c7a..6cf9104f2 100644 --- a/vp8/decoder/decodframe.c +++ b/vp8/decoder/decodframe.c @@ -235,6 +235,13 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, xd->mode_info_context->mbmi.txfm_size = TX_8X8; } } + +#if CONFIG_HTRANS8X8 + if (xd->mode_info_context->mbmi.mode == I8X8_PRED) { + xd->mode_info_context->mbmi.txfm_size = TX_8X8; + } +#endif + tx_type = xd->mode_info_context->mbmi.txfm_size; if (xd->mode_info_context->mbmi.mb_skip_coeff) { @@ -356,11 +363,28 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int i8x8mode; BLOCKD *b; +#if CONFIG_HTRANS8X8 + int idx = (ib & 0x02) ? (ib + 2) : ib; + + short *q = xd->block[idx].qcoeff; + short *dq = xd->block[0].dequant; + unsigned char *pre = xd->block[ib].predictor; + unsigned char *dst = *(xd->block[ib].base_dst) + xd->block[ib].dst; + int stride = xd->dst.y_stride; + + tx_type = TX_4X4; + xd->mode_info_context->mbmi.txfm_size = TX_4X4; +#endif + b = &xd->block[ib]; i8x8mode = b->bmi.as_mode.first; RECON_INVOKE(RTCD_VTABLE(recon), intra8x8_predict) (b, i8x8mode, b->predictor); +#if CONFIG_HTRANS8X8 + vp8_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride); + q += 64; +#else for (j = 0; j < 4; j++) { b = &xd->block[ib + iblock[j]]; if (xd->eobs[ib + iblock[j]] > 1) { @@ -374,6 +398,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, ((int *)b->qcoeff)[0] = 0; } } +#endif b = &xd->block[16 + i]; RECON_INVOKE(RTCD_VTABLE(recon), intra_uv4x4_predict) diff --git a/vp8/decoder/detokenize.c b/vp8/decoder/detokenize.c index 1acde4c1e..155877a4c 100644 --- a/vp8/decoder/detokenize.c +++ b/vp8/decoder/detokenize.c @@ -124,7 +124,8 @@ void static count_tokens_adaptive_scan(const MACROBLOCKD *xd, INT16 *qcoeff_ptr, int QIndex = xd->q_index; int active_ht = (QIndex < ACTIVE_HT) && - (xd->mode_info_context->mbmi.mode == B_PRED); + (xd->mode_info_context->mbmi.mode == B_PRED) && + (type == PLANE_TYPE_Y_WITH_DC); if(active_ht) { switch(xd->block[block].bmi.as_mode.tx_type) { @@ -351,8 +352,16 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) { const int segment_id = xd->mode_info_context->mbmi.segment_id; const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB); INT16 *qcoeff_ptr = &xd->qcoeff[0]; + +#if CONFIG_HTRANS8X8 + int bufthred = (xd->mode_info_context->mbmi.mode == I8X8_PRED) ? 16 : 24; + if (xd->mode_info_context->mbmi.mode != B_PRED && + xd->mode_info_context->mbmi.mode != SPLITMV && + xd->mode_info_context->mbmi.mode != I8X8_PRED) { +#else if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV) { +#endif ENTROPY_CONTEXT *const a = A + vp8_block2above_8x8[24]; ENTROPY_CONTEXT *const l = L + vp8_block2left_8x8[24]; const int *const scan = vp8_default_zig_zag1d; @@ -376,10 +385,16 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) { seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB); else seg_eob = 64; + +#if CONFIG_HTRANS8X8 + for (i = 0; i < bufthred ; i += 4) { +#else for (i = 0; i < 24; i += 4) { +#endif ENTROPY_CONTEXT *const a = A + vp8_block2above_8x8[i]; ENTROPY_CONTEXT *const l = L + vp8_block2left_8x8[i]; const int *const scan = vp8_default_zig_zag1d_8x8; + if (i == 16) type = PLANE_TYPE_UV; @@ -393,6 +408,27 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) { qcoeff_ptr += 64; } +#if CONFIG_HTRANS8X8 + if (xd->mode_info_context->mbmi.mode == I8X8_PRED) { + type = PLANE_TYPE_UV; + seg_eob = 16; + + // use 4x4 transform for U, V components in I8X8 prediction mode + for (i = 16; i < 24; i++) { + ENTROPY_CONTEXT *const a = A + vp8_block2above[i]; + ENTROPY_CONTEXT *const l = L + vp8_block2left[i]; + const int *scan = vp8_default_zig_zag1d; + + c = vp8_decode_coefs(pbi, xd, a, l, type, seg_eob, qcoeff_ptr, + i, scan, TX_4X4, coef_bands_x); + a[0] = l[0] = ((eobs[i] = c) != !type); + + eobtotal += c; + qcoeff_ptr += 16; + } + } +#endif + return eobtotal; } diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index b69ffa94e..106036a0d 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -70,7 +70,7 @@ typedef struct { int_mv second_best_ref_mv; int rate; int distortion; - int intra_error; + int64_t intra_error; int best_mode_index; int rddiv; int rdmult; diff --git a/vp8/encoder/encodeintra.c b/vp8/encoder/encodeintra.c index 46b352ef8..01ae03a23 100644 --- a/vp8/encoder/encodeintra.c +++ b/vp8/encoder/encodeintra.c @@ -306,6 +306,25 @@ void vp8_encode_intra8x8(const VP8_ENCODER_RTCD *rtcd, } #endif +#if CONFIG_HTRANS8X8 + { + MACROBLOCKD *xd = &x->e_mbd; + int idx = (ib & 0x02) ? (ib + 2) : ib; + + // generate residual blocks + vp8_subtract_4b_c(be, b, 16); + x->vp8_short_fdct8x8(be->src_diff, (x->block + idx)->coeff, 32); + x->quantize_b_8x8(x->block + idx, xd->block + idx); + vp8_short_idct8x8_c(xd->block[idx].dqcoeff, xd->block[ib].diff, 32); + + // reconstruct submacroblock + for (i = 0; i < 4; i++) { + b = &xd->block[ib + iblock[i]]; + vp8_recon_b_c(b->predictor, b->diff, *(b->base_dst) + b->dst, + b->dst_stride); + } + } +#else for (i = 0; i < 4; i++) { b = &x->e_mbd.block[ib + iblock[i]]; be = &x->block[ib + iblock[i]]; @@ -314,8 +333,10 @@ void vp8_encode_intra8x8(const VP8_ENCODER_RTCD *rtcd, x->quantize_b(be, b); vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32); RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor, - b->diff, *(b->base_dst) + b->dst, b->dst_stride); + b->diff, *(b->base_dst) + b->dst, + b->dst_stride); } +#endif } extern const int vp8_i8x8_block[4]; diff --git a/vp8/encoder/encodemb.c b/vp8/encoder/encodemb.c index 530fa0582..653a4cc70 100644 --- a/vp8/encoder/encodemb.c +++ b/vp8/encoder/encodemb.c @@ -327,8 +327,8 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type, int rdmult; int rddiv; int final_eob; - int rd_cost0; - int rd_cost1; + int64_t rd_cost0; + int64_t rd_cost1; int rate0; int rate1; int error0; @@ -719,8 +719,8 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type, int rdmult; int rddiv; int final_eob; - int rd_cost0; - int rd_cost1; + int64_t rd_cost0; + int64_t rd_cost1; int rate0; int rate1; int error0; diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 5fd92a5fa..66f342302 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -447,6 +447,20 @@ int vp8_block_error_c(short *coeff, short *dqcoeff) { return error; } +#if CONFIG_HTRANS8X8 +int vp8_submb_error_c(short *coeff, short *dqcoeff) { + int i; + int error = 0; + + for (i = 0; i < 64; i++) { + int this_diff = coeff[i] - dqcoeff[i]; + error += this_diff * this_diff; + } + + return error; +} +#endif + int vp8_mbblock_error_c(MACROBLOCK *mb, int dc) { BLOCK *be; BLOCKD *bd; @@ -825,7 +839,7 @@ static void copy_predictor_8x8(unsigned char *dst, const unsigned char *predicto d[29] = p[29]; } -static int rd_pick_intra4x4block( +static int64_t rd_pick_intra4x4block( VP8_COMP *cpi, MACROBLOCK *x, BLOCK *be, @@ -852,7 +866,7 @@ static int rd_pick_intra4x4block( #if CONFIG_COMP_INTRA_PRED B_PREDICTION_MODE mode2; #endif - int best_rd = INT_MAX; + int64_t best_rd = INT64_MAX; int rate = 0; int distortion; @@ -871,7 +885,7 @@ static int rd_pick_intra4x4block( for (mode2 = (allow_comp ? 0 : (B_DC_PRED - 1)); mode2 != (allow_comp ? (mode + 1) : 0); mode2++) { #endif - int this_rd; + int64_t this_rd; int ratey; // TODO Temporarily ignore modes that need the above-right data. SB @@ -988,8 +1002,8 @@ static int rd_pick_intra4x4block( return best_rd; } -static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, - int *rate_y, int *Distortion, int best_rd, +static int64_t rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, + int *rate_y, int *Distortion, int64_t best_rd, #if CONFIG_COMP_INTRA_PRED int allow_comp, #endif @@ -1056,12 +1070,12 @@ static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, mic->bmi[i].as_mode.second = best_second_mode; #endif - if (total_rd >= (int64_t)best_rd) + if (total_rd >= best_rd) break; } - if (total_rd >= (int64_t)best_rd) - return INT_MAX; + if (total_rd >= best_rd) + return INT64_MAX; #if CONFIG_COMP_INTRA_PRED cost += vp8_cost_bit(128, allow_comp); @@ -1074,7 +1088,7 @@ static int rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, } -static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi, +static int64_t rd_pick_intra16x16mby_mode(VP8_COMP *cpi, MACROBLOCK *x, int *Rate, int *rate_y, @@ -1087,8 +1101,8 @@ static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi, #endif int rate, ratey; int distortion; - int best_rd = INT_MAX; - int this_rd; + int64_t best_rd = INT64_MAX; + int64_t this_rd; // Y Search for 16x16 intra prediction mode for (mode = DC_PRED; mode <= TM_PRED; mode++) { @@ -1138,7 +1152,7 @@ static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi, } -static int rd_pick_intra8x8block( +static int64_t rd_pick_intra8x8block( VP8_COMP *cpi, MACROBLOCK *x, int ib, @@ -1157,7 +1171,7 @@ static int rd_pick_intra8x8block( MB_PREDICTION_MODE mode2; #endif MACROBLOCKD *xd = &x->e_mbd; - int best_rd = INT_MAX; + int64_t best_rd = INT64_MAX; int rate = 0; int distortion; BLOCK *be = x->block + ib; @@ -1175,11 +1189,17 @@ static int rd_pick_intra8x8block( DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16 * 8); DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16 * 4); +#if CONFIG_HTRANS8X8 + // perform transformation of dimension 8x8 + // note the input and output index mapping + int idx = (ib & 0x02) ? (ib + 2) : ib; +#endif + for (mode = DC_PRED; mode <= TM_PRED; mode++) { #if CONFIG_COMP_INTRA_PRED for (mode2 = DC_PRED - 1; mode2 != TM_PRED + 1; mode2++) { #endif - int this_rd; + int64_t this_rd; int rate_t; // FIXME rate for compound mode and second intrapred mode @@ -1200,6 +1220,24 @@ static int rd_pick_intra8x8block( vp8_subtract_4b_c(be, b, 16); +#if CONFIG_HTRANS8X8 + x->vp8_short_fdct8x8(be->src_diff, (x->block + idx)->coeff, 32); + x->quantize_b_8x8(x->block + idx, xd->block + idx); + + // compute quantization mse of 8x8 block + distortion = vp8_submb_error_c((x->block + idx)->coeff, + (xd->block + idx)->dqcoeff)>>2; + + ta0 = *(a + vp8_block2above_8x8[idx]); + tl0 = *(l + vp8_block2left_8x8 [idx]); + + rate_t = cost_coeffs_8x8(x, xd->block + idx, PLANE_TYPE_Y_WITH_DC, + &ta0, + &tl0); + rate += rate_t; + ta1 = ta0; + tl1 = tl0; +#else x->vp8_short_fdct8x4(be->src_diff, be->coeff, 32); x->vp8_short_fdct8x4(be->src_diff + 64, be->coeff + 64, 32); @@ -1230,6 +1268,8 @@ static int rd_pick_intra8x8block( rate_t += cost_coeffs(x, xd->block + ib + 5, PLANE_TYPE_Y_WITH_DC, &ta1, &tl1); rate += rate_t; +#endif + this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); if (this_rd < best_rd) { *bestrate = rate; @@ -1257,20 +1297,28 @@ static int rd_pick_intra8x8block( b->bmi.as_mode.second = (*best_second_mode); #endif vp8_encode_intra8x8(IF_RTCD(&cpi->rtcd), x, ib); + +#if CONFIG_HTRANS8X8 + *(a + vp8_block2above_8x8[idx]) = besta0; + *(a + vp8_block2above_8x8[idx] + 1) = besta1; + *(l + vp8_block2left_8x8 [idx]) = bestl0; + *(l + vp8_block2left_8x8 [idx] + 1) = bestl1; +#else *(a + vp8_block2above[ib]) = besta0; *(a + vp8_block2above[ib + 1]) = besta1; *(l + vp8_block2above[ib]) = bestl0; *(l + vp8_block2above[ib + 4]) = bestl1; +#endif return best_rd; } const int vp8_i8x8_block[4] = {0, 2, 8, 10}; -int rd_pick_intra8x8mby_modes(VP8_COMP *cpi, +int64_t rd_pick_intra8x8mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *Rate, int *rate_y, int *Distortion, - int best_rd) { + int64_t best_rd) { MACROBLOCKD *const xd = &mb->e_mbd; int i, ib; int cost = mb->mbmode_cost [xd->frame_type] [I8X8_PRED]; @@ -1341,7 +1389,7 @@ static int rd_cost_mbuv(MACROBLOCK *mb) { } -static int rd_inter16x16_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate, +static int64_t rd_inter16x16_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int *distortion, int fullpixel) { ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride); @@ -1378,7 +1426,7 @@ static int rd_cost_mbuv_8x8(MACROBLOCK *mb) { } -static int rd_inter16x16_uv_8x8(VP8_COMP *cpi, MACROBLOCK *x, int *rate, +static int64_t rd_inter16x16_uv_8x8(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int *distortion, int fullpixel) { ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride); @@ -1394,7 +1442,7 @@ static int rd_inter16x16_uv_8x8(VP8_COMP *cpi, MACROBLOCK *x, int *rate, } -static int rd_inter4x4_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate, +static int64_t rd_inter4x4_uv(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int *distortion, int fullpixel) { vp8_build_inter4x4_predictors_mbuv(&x->e_mbd); ENCODEMB_INVOKE(IF_RTCD(&cpi->rtcd.encodemb), submbuv)(x->src_diff, @@ -1420,7 +1468,7 @@ static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, MB_PREDICTION_MODE mode2; MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode2_selected); #endif - int best_rd = INT_MAX; + int64_t best_rd = INT64_MAX; int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r); int rate_to; @@ -1430,7 +1478,7 @@ static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, #endif int rate; int distortion; - int this_rd; + int64_t this_rd; x->e_mbd.mode_info_context->mbmi.uv_mode = mode; #if CONFIG_COMP_INTRA_PRED @@ -1491,14 +1539,14 @@ static void rd_pick_intra_mbuv_mode_8x8(VP8_COMP *cpi, int *distortion) { MB_PREDICTION_MODE mode; MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected); - int best_rd = INT_MAX; + int64_t best_rd = INT64_MAX; int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r); int rate_to; for (mode = DC_PRED; mode <= TM_PRED; mode++) { int rate; int distortion; - int this_rd; + int64_t this_rd; x->e_mbd.mode_info_context->mbmi.uv_mode = mode; RECON_INVOKE(&cpi->rtcd.common->recon, build_intra_predictors_mbuv) @@ -1725,7 +1773,7 @@ typedef struct { int_mv *ref_mv, *second_ref_mv; int_mv mvp; - int segment_rd; + int64_t segment_rd; int segment_num; int r; int d; @@ -1754,7 +1802,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x, int label_count; - int this_segment_rd = 0; + int64_t this_segment_rd = 0; int label_mv_thresh; int rate = 0; int sbr = 0; @@ -1799,13 +1847,13 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x, for (i = 0; i < label_count; i++) { int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT]; - int best_label_rd = INT_MAX; + int64_t best_label_rd = INT64_MAX; B_PREDICTION_MODE mode_selected = ZERO4X4; int bestlabelyrate = 0; // search for the best motion vector on this segment for (this_mode = LEFT4X4; this_mode <= NEW4X4; this_mode ++) { - int this_rd; + int64_t this_rd; int distortion; int labelyrate; ENTROPY_CONTEXT_PLANES t_above_s, t_left_s; @@ -2030,7 +2078,7 @@ void vp8_cal_step_param(int sr, int *sp) { } static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, - int_mv *best_ref_mv, int_mv *second_best_ref_mv, int best_rd, + int_mv *best_ref_mv, int_mv *second_best_ref_mv, int64_t best_rd, int *mdcounts, int *returntotrate, int *returnyrate, int *returndistortion, int mvthresh, @@ -2640,9 +2688,9 @@ static void store_coding_context(MACROBLOCK *x, int mb_index, } void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, - int *returnrate, int *returndistortion, int *returnintra, - int *best_single_rd_diff, int *best_comp_rd_diff, - int *best_hybrid_rd_diff) { + int *returnrate, int *returndistortion, int64_t *returnintra, + int64_t *best_single_rd_diff, int64_t *best_comp_rd_diff, + int64_t *best_hybrid_rd_diff) { VP8_COMMON *cm = &cpi->common; BLOCK *b = &x->block[0]; BLOCKD *d = &x->e_mbd.block[0]; @@ -2664,13 +2712,13 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int int mdcounts[4]; int rate; int distortion; - int best_rd = INT_MAX; - int best_intra_rd = INT_MAX; - int best_comp_rd = INT_MAX; - int best_single_rd = INT_MAX; - int best_hybrid_rd = INT_MAX; + int64_t best_rd = INT64_MAX; + int64_t best_intra_rd = INT64_MAX; + int64_t best_comp_rd = INT64_MAX; + int64_t best_single_rd = INT64_MAX; + int64_t best_hybrid_rd = INT64_MAX; #if CONFIG_PRED_FILTER - int best_overall_rd = INT_MAX; + int64_t best_overall_rd = INT64_MAX; #endif int rate2, distortion2; int uv_intra_rate, uv_intra_distortion, uv_intra_rate_tokenonly; @@ -2679,7 +2727,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int int uv_intra_skippable_8x8 = 0; int rate_y, UNINITIALIZED_IS_SAFE(rate_uv); int distortion_uv; - int best_yrd = INT_MAX; + int64_t best_yrd = INT64_MAX; #if CONFIG_PRED_FILTER int best_filter_state; #endif @@ -2770,7 +2818,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset; } - *returnintra = INT_MAX; + *returnintra = INT64_MAX; x->skip = 0; @@ -2806,7 +2854,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int #else for (mode_index = 0; mode_index < MAX_MODES; ++mode_index) { #endif - int this_rd = INT_MAX; + int64_t this_rd = INT64_MAX; int disable_skip = 0; int other_cost = 0; int compmode_cost = 0; @@ -2936,7 +2984,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame) { switch (this_mode) { case B_PRED: { - int tmp_rd; + int64_t tmp_rd; // Note the rate value returned here includes the cost of coding the BPRED mode : x->mbmode_cost[x->e_mbd.frame_type][BPRED]; tmp_rd = rd_pick_intra4x4mby_modes(cpi, x, &rate, &rate_y, &distortion, best_yrd, @@ -2953,13 +3001,13 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int distortion2 += uv_intra_distortion; distortion_uv = uv_intra_distortion; } else { - this_rd = INT_MAX; + this_rd = INT64_MAX; disable_skip = 1; } } break; case I8X8_PRED: { - int tmp_rd; + int64_t tmp_rd; tmp_rd = rd_pick_intra8x8mby_modes(cpi, x, &rate, &rate_y, &distortion, best_yrd); @@ -2985,15 +3033,15 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int distortion2 += uv_intra_distortion; distortion_uv = uv_intra_distortion; } else { - this_rd = INT_MAX; + this_rd = INT64_MAX; disable_skip = 1; } } break; case SPLITMV: { - int tmp_rd; - int this_rd_thresh; + int64_t tmp_rd; + int64_t this_rd_thresh; this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? @@ -3025,7 +3073,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rate2 += rate_uv; distortion2 += distortion_uv; } else { - this_rd = INT_MAX; + this_rd = INT64_MAX; disable_skip = 1; } mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY; @@ -3378,8 +3426,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_nearest_mv[ref2].as_int; break; case SPLITMV: { - int tmp_rd; - int this_rd_thresh; + int64_t tmp_rd; + int64_t this_rd_thresh; this_rd_thresh = (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? @@ -3404,7 +3452,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rate2 += rate_uv; distortion2 += distortion_uv; } else { - this_rd = INT_MAX; + this_rd = INT64_MAX; disable_skip = 1; } } @@ -3646,7 +3694,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int /* keep record of best compound/single-only prediction */ if (!disable_skip && x->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME) { - int single_rd, hybrid_rd, single_rate, hybrid_rate; + int64_t single_rd, hybrid_rd; + int single_rate, hybrid_rate; if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) { single_rate = rate2 - compmode_cost; @@ -3782,15 +3831,15 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int x->partition_info->bmi[15].second_mv.as_int; } - if (best_single_rd == INT_MAX) + if (best_single_rd == INT64_MAX) *best_single_rd_diff = INT_MIN; else *best_single_rd_diff = best_rd - best_single_rd; - if (best_comp_rd == INT_MAX) + if (best_comp_rd == INT64_MAX) *best_comp_rd_diff = INT_MIN; else *best_comp_rd_diff = best_rd - best_comp_rd; - if (best_hybrid_rd == INT_MAX) + if (best_hybrid_rd == INT64_MAX) *best_hybrid_rd_diff = INT_MIN; else *best_hybrid_rd_diff = best_rd - best_hybrid_rd; @@ -3802,9 +3851,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x) { MACROBLOCKD *xd = &x->e_mbd; - int error4x4, error16x16; + int64_t error4x4, error16x16; #if CONFIG_COMP_INTRA_PRED - int error4x4d, rate4x4d, dist4x4d; + int64_t error4x4d; + int rate4x4d, dist4x4d; #endif int rate4x4, rate16x16 = 0, rateuv; int dist4x4, dist16x16, distuv; @@ -3812,7 +3862,8 @@ int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x) { int rate4x4_tokenonly = 0; int rate16x16_tokenonly = 0; int rateuv_tokenonly = 0; - int error8x8, rate8x8_tokenonly=0; + int64_t error8x8; + int rate8x8_tokenonly=0; int rate8x8, dist8x8; int mode16x16; int mode8x8[2][4]; @@ -3917,7 +3968,7 @@ int vp8cx_pick_mode_inter_macroblock MACROBLOCKD *const xd = &x->e_mbd; int rate; int distortion; - int intra_error = 0; + int64_t intra_error = 0; unsigned char *segment_id = &xd->mode_info_context->mbmi.segment_id; if (xd->segmentation_enabled) @@ -3929,7 +3980,7 @@ int vp8cx_pick_mode_inter_macroblock // For now this codebase is limited to a single rd encode path { int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled; - int single, compound, hybrid; + int64_t single, compound, hybrid; vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate, &distortion, &intra_error, &single, &compound, diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h index 0077411d0..c26708c71 100644 --- a/vp8/encoder/rdopt.h +++ b/vp8/encoder/rdopt.h @@ -12,13 +12,13 @@ #ifndef __INC_RDOPT_H #define __INC_RDOPT_H -#define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) ) -#define RDCOST_8x8(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) ) +#define RDCOST(RM,DM,R,D) ( ((128+((int64_t)R)*(RM)) >> 8) + ((int64_t)DM)*(D) ) +#define RDCOST_8x8(RM,DM,R,D) ( ((128+((int64_t)R)*(RM)) >> 8) + ((int64_t)DM)*(D) ) extern void vp8_initialize_rd_consts(VP8_COMP *cpi, 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, - int *best_single_rd_diff, int *best_comp_rd_diff, int *best_hybrid_rd_diff); + int *returnrate, int *returndistortion, int64_t *returnintra, + int64_t *best_single_rd_diff, int64_t *best_comp_rd_diff, int64_t *best_hybrid_rd_diff); extern int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8_mv_pred diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c index 50a31643d..81ba6f2be 100644 --- a/vp8/encoder/tokenize.c +++ b/vp8/encoder/tokenize.c @@ -334,9 +334,8 @@ static void tokenize1st_order_ht( MACROBLOCKD *xd, } // assign scanning order for luma components coded in intra4x4 mode - if( ( ( xd->mode_info_context->mbmi.mode == B_PRED ) || - ( xd->mode_info_context->mbmi.mode == I8X8_PRED ) ) && - ( type == PLANE_TYPE_Y_WITH_DC) ) { + if( (xd->mode_info_context->mbmi.mode == B_PRED) && + (type == PLANE_TYPE_Y_WITH_DC) ) { switch(b_mode) { case B_VE_PRED : case B_VR_PRED : @@ -455,6 +454,84 @@ static void tokenize1st_order_ht( MACROBLOCKD *xd, } #endif + +#if CONFIG_HTRANS8X8 +static void tokenize1st_order_chroma +( + MACROBLOCKD *xd, + TOKENEXTRA **tp, + int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */ + VP8_COMP *cpi +) { + unsigned int block; + const BLOCKD *b; + int pt; /* near block/prev token context index */ + int c; + int token; + TOKENEXTRA *t = *tp;/* store tokens starting here */ + const short *qcoeff_ptr; + ENTROPY_CONTEXT *a; + ENTROPY_CONTEXT *l; + int band, rc, v; + int tmp1, tmp2; + + int seg_eob = 16; + 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); + } + + b = xd->block; + b += 16; + + /* Chroma */ + for (block = 16; block < 24; block++, b++) { + tmp1 = vp8_block2above[block]; + tmp2 = vp8_block2left[block]; + qcoeff_ptr = b->qcoeff; + a = (ENTROPY_CONTEXT *)xd->above_context + tmp1; + l = (ENTROPY_CONTEXT *)xd->left_context + tmp2; + + VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l); + + for (c = 0; c < b->eob; c++) { + rc = vp8_default_zig_zag1d[c]; + band = vp8_coef_bands[c]; + v = qcoeff_ptr[rc]; + + t->Extra = vp8_dct_value_tokens_ptr[v].Extra; + token = vp8_dct_value_tokens_ptr[v].Token; + + t->Token = token; + t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt]; + + t->skip_eob_node = ((pt == 0) && (band > 0)); + + ++cpi->coef_counts [2] [band] [pt] [token]; + + pt = vp8_prev_token_class[token]; + t++; + } + + if (c < seg_eob) { + band = vp8_coef_bands[c]; + t->Token = DCT_EOB_TOKEN; + t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt]; + + t->skip_eob_node = ((pt == 0) && (band > 0)); + + ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN]; + + t++; + } + *tp = t; + pt = (c != 0); /* 0 <-> all coeff data is zero */ + *a = *l = pt; + } +} +#endif + static void tokenize1st_order_b ( MACROBLOCKD *xd, @@ -640,7 +717,8 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) { #if CONFIG_HYBRIDTRANSFORM int QIndex = cpi->mb.q_index; - int active_ht = (QIndex < ACTIVE_HT); + int active_ht = (QIndex < ACTIVE_HT) && + (x->mode_info_context->mbmi.mode == B_PRED); #endif if (!segfeature_active(x, segment_id, SEG_LVL_EOB) || @@ -717,7 +795,29 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) { if(active_ht) { tokenize1st_order_ht(x, t, plane_type, cpi); } else { + +#if CONFIG_HTRANS8X8 + if (x->mode_info_context->mbmi.mode == I8X8_PRED) { + ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context; + ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context; + for (b = 0; b < 16; b += 4) { + tokenize1st_order_b_8x8(x, + x->block + b, t, PLANE_TYPE_Y_WITH_DC, + x->frame_type, + A + vp8_block2above_8x8[b], + L + vp8_block2left_8x8[b], + cpi); + *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]); + *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]); + } + tokenize1st_order_chroma(x, t, PLANE_TYPE_UV, cpi); + } else { + tokenize1st_order_b(x, t, plane_type, cpi); + } +#else tokenize1st_order_b(x, t, plane_type, cpi); +#endif + } #else tokenize1st_order_b(x, t, plane_type, cpi); |