Fix lossless mismatch in EXT_TX
In lossless mode, transform should not be altered. Change-Id: I216d1700963b4d1c35e059cd7ff7b0cefaf46133
This commit is contained in:
parent
1c562aebd8
commit
cf7dc66e34
@ -262,17 +262,18 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
|
||||
const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi;
|
||||
|
||||
#if CONFIG_EXT_TX
|
||||
if (plane_type != PLANE_TYPE_Y)
|
||||
if (plane_type != PLANE_TYPE_Y || xd->lossless || mbmi->tx_size >= TX_32X32)
|
||||
return DCT_DCT;
|
||||
|
||||
if (is_inter_block(mbmi)) {
|
||||
if (mbmi->ext_txfrm == NORM || mbmi->tx_size >= TX_32X32)
|
||||
if (mbmi->ext_txfrm == NORM)
|
||||
return DCT_DCT;
|
||||
else
|
||||
return ADST_ADST;
|
||||
}
|
||||
#else
|
||||
if (plane_type != PLANE_TYPE_Y || is_inter_block(mbmi))
|
||||
if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi) ||
|
||||
mbmi->tx_size >= TX_32X32)
|
||||
return DCT_DCT;
|
||||
#endif
|
||||
return intra_mode_to_tx_type_lookup[mbmi->mode];
|
||||
|
@ -675,6 +675,7 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
|
||||
#if CONFIG_EXT_TX
|
||||
if (inter_block &&
|
||||
mbmi->tx_size <= TX_16X16 &&
|
||||
cm->base_qindex > 0 &&
|
||||
mbmi->sb_type >= BLOCK_8X8 &&
|
||||
!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
|
||||
!mbmi->skip) {
|
||||
|
@ -279,7 +279,8 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
|
||||
}
|
||||
#if CONFIG_EXT_TX
|
||||
if (is_inter &&
|
||||
mbmi->tx_size <= TX_16X16 &&
|
||||
mbmi->tx_size < TX_32X32 &&
|
||||
cm->base_qindex > 0 &&
|
||||
bsize >= BLOCK_8X8 &&
|
||||
!mbmi->skip &&
|
||||
!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
|
||||
|
@ -3886,6 +3886,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
|
||||
#if CONFIG_EXT_TX
|
||||
if (mbmi->tx_size < TX_32X32 &&
|
||||
is_inter_block(mbmi) &&
|
||||
cm->base_qindex > 0 &&
|
||||
bsize >= BLOCK_8X8 &&
|
||||
!mbmi->skip &&
|
||||
!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
|
||||
|
@ -649,7 +649,7 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block,
|
||||
break;
|
||||
case TX_4X4:
|
||||
#if CONFIG_EXT_TX
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM) {
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM || xd->lossless) {
|
||||
x->fwd_txm4x4(src_diff, coeff, diff_stride);
|
||||
} else {
|
||||
vp9_highbd_fht4x4(src_diff, coeff, diff_stride, ADST_ADST);
|
||||
@ -718,7 +718,7 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block,
|
||||
break;
|
||||
case TX_4X4:
|
||||
#if CONFIG_EXT_TX
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM) {
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM || xd->lossless) {
|
||||
x->fwd_txm4x4(src_diff, coeff, diff_stride);
|
||||
} else {
|
||||
vp9_fht4x4(src_diff, coeff, diff_stride, ADST_ADST);
|
||||
@ -845,7 +845,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
|
||||
break;
|
||||
case TX_4X4:
|
||||
#if CONFIG_EXT_TX
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM) {
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM || xd->lossless) {
|
||||
// this is like vp9_short_idct4x4 but has a special case around eob<=1
|
||||
// which is significant (not just an optimization) for the lossless
|
||||
// case.
|
||||
@ -905,7 +905,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
|
||||
break;
|
||||
case TX_4X4:
|
||||
#if CONFIG_EXT_TX
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM) {
|
||||
if (plane != 0 || mbmi->ext_txfrm == NORM || xd->lossless) {
|
||||
// this is like vp9_short_idct4x4 but has a special case around eob<=1
|
||||
// which is significant (not just an optimization) for the lossless
|
||||
// case.
|
||||
|
@ -2808,38 +2808,40 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int64_t sseuv = INT64_MAX;
|
||||
int64_t rdcosty = INT64_MAX;
|
||||
|
||||
vp9_subtract_plane(x, bsize, 0);
|
||||
#if CONFIG_EXT_TX
|
||||
int64_t rdcost_tx;
|
||||
int rate_y_tx;
|
||||
int64_t distortion_y_tx;
|
||||
int dummy;
|
||||
int64_t best_rdcost_tx = INT64_MAX;
|
||||
int best_ext_tx = NORM;
|
||||
double th = 0.99;
|
||||
|
||||
vp9_subtract_plane(x, bsize, 0);
|
||||
for (i = 0; i < EXT_TX_TYPES; i++) {
|
||||
mbmi->ext_txfrm = i;
|
||||
super_block_yrd(cpi, x, &rate_y_tx, &distortion_y_tx, &dummy, psse,
|
||||
bsize, txfm_cache, INT64_MAX);
|
||||
assert(rate_y_tx != INT_MAX);
|
||||
if (mbmi->tx_size < TX_32X32)
|
||||
rate_y_tx += vp9_cost_bit(cm->fc.ext_tx_prob, i);
|
||||
assert(rate_y_tx >= 0);
|
||||
rdcost_tx = RDCOST(x->rdmult, x->rddiv, rate_y_tx, distortion_y_tx);
|
||||
rdcost_tx = MIN(rdcost_tx, RDCOST(x->rdmult, x->rddiv, 0, *psse));
|
||||
assert(rdcost_tx >= 0);
|
||||
if (rdcost_tx < best_rdcost_tx * th) {
|
||||
best_ext_tx = i;
|
||||
best_rdcost_tx = rdcost_tx;
|
||||
}
|
||||
}
|
||||
if (mbmi->tx_size >= TX_32X32)
|
||||
if (xd->lossless) {
|
||||
mbmi->ext_txfrm = NORM;
|
||||
else
|
||||
mbmi->ext_txfrm = best_ext_tx;
|
||||
#else
|
||||
vp9_subtract_plane(x, bsize, 0);
|
||||
} else {
|
||||
int64_t rdcost_tx;
|
||||
int rate_y_tx;
|
||||
int64_t distortion_y_tx;
|
||||
int dummy;
|
||||
int64_t best_rdcost_tx = INT64_MAX;
|
||||
int best_ext_tx = NORM;
|
||||
double th = 0.99;
|
||||
|
||||
for (i = 0; i < EXT_TX_TYPES; i++) {
|
||||
mbmi->ext_txfrm = i;
|
||||
super_block_yrd(cpi, x, &rate_y_tx, &distortion_y_tx, &dummy, psse,
|
||||
bsize, txfm_cache, INT64_MAX);
|
||||
assert(rate_y_tx != INT_MAX);
|
||||
if (mbmi->tx_size < TX_32X32)
|
||||
rate_y_tx += vp9_cost_bit(cm->fc.ext_tx_prob, i);
|
||||
assert(rate_y_tx >= 0);
|
||||
rdcost_tx = RDCOST(x->rdmult, x->rddiv, rate_y_tx, distortion_y_tx);
|
||||
rdcost_tx = MIN(rdcost_tx, RDCOST(x->rdmult, x->rddiv, 0, *psse));
|
||||
assert(rdcost_tx >= 0);
|
||||
if (rdcost_tx < best_rdcost_tx * th) {
|
||||
best_ext_tx = i;
|
||||
best_rdcost_tx = rdcost_tx;
|
||||
}
|
||||
}
|
||||
if (mbmi->tx_size >= TX_32X32)
|
||||
mbmi->ext_txfrm = NORM;
|
||||
else
|
||||
mbmi->ext_txfrm = best_ext_tx;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Y cost and distortion
|
||||
@ -2855,7 +2857,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
|
||||
*rate2 += *rate_y;
|
||||
#if CONFIG_EXT_TX
|
||||
if (mbmi->tx_size < TX_32X32)
|
||||
if (mbmi->tx_size < TX_32X32 && !xd->lossless)
|
||||
*rate2 += vp9_cost_bit(cm->fc.ext_tx_prob, mbmi->ext_txfrm);
|
||||
#endif
|
||||
*distortion += distortion_y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user