summaryrefslogtreecommitdiff
path: root/vp9/decoder
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@google.com>2012-12-07 14:45:05 -0800
committerRonald S. Bultje <rbultje@google.com>2012-12-07 14:45:05 -0800
commitc456b35fdf1b1e9fd3c964b822e9de05437544e2 (patch)
tree9eb0624d58ae710964ba4a388ad8a1ad740ec49d /vp9/decoder
parenta36d9a4a150c2f7e7eaa825d7ca0289aeac6c5b1 (diff)
downloadlibvpx-c456b35fdf1b1e9fd3c964b822e9de05437544e2.tar
libvpx-c456b35fdf1b1e9fd3c964b822e9de05437544e2.tar.gz
libvpx-c456b35fdf1b1e9fd3c964b822e9de05437544e2.tar.bz2
libvpx-c456b35fdf1b1e9fd3c964b822e9de05437544e2.zip
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds code all over the place to wrap that in the bitstream/encoder/decoder/RD. Some implementation notes (these probably need careful review): - token range is extended by 1 bit, since the value range out of this transform is [-16384,16383]. - the coefficients coming out of the FDCT are manually scaled back by 1 bit, or else they won't fit in int16_t (they are 17 bits). Because of this, the RD error scoring does not right-shift the MSE score by two (unlike for 4x4/8x8/16x16). - to compensate for this loss in precision, the quantizer is halved also. This is currently a little hacky. - FDCT and IDCT is double-only right now. Needs a fixed-point impl. - There are no default probabilities for the 32x32 transform yet; I'm simply using the 16x16 luma ones. A future commit will add newly generated probabilities for all transforms. - No ADST version. I don't think we'll add one for this level; if an ADST is desired, transform-size selection can scale back to 16x16 or lower, and use an ADST at that level. Additional notes specific to Debargha's DWT/DCT hybrid: - coefficient scale is different for the top/left 16x16 (DCT-over-DWT) block than for the rest (DWT pixel differences) of the block. Therefore, RD error scoring isn't easily scalable between coefficient and pixel domain. Thus, unfortunately, we need to compute the RD distortion in the pixel domain until we figure out how to scale these appropriately. Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
Diffstat (limited to 'vp9/decoder')
-rw-r--r--vp9/decoder/vp9_decodemv.c22
-rw-r--r--vp9/decoder/vp9_decodframe.c49
-rw-r--r--vp9/decoder/vp9_dequantize.c27
-rw-r--r--vp9/decoder/vp9_detokenize.c59
-rw-r--r--vp9/decoder/vp9_detokenize.h6
5 files changed, 158 insertions, 5 deletions
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 7e53884f7..b9f411dd2 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -209,8 +209,17 @@ static void kfread_modes(VP9D_COMP *pbi,
m->mbmi.mode <= I8X8_PRED) {
// FIXME(rbultje) code ternary symbol once all experiments are merged
m->mbmi.txfm_size = vp9_read(bc, cm->prob_tx[0]);
- if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED)
+ if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) {
m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[1]);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.encoded_as_sb)
+ m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[2]);
+#endif
+ }
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ } else if (cm->txfm_mode >= ALLOW_32X32 && m->mbmi.encoded_as_sb) {
+ m->mbmi.txfm_size = TX_32X32;
+#endif
} else if (cm->txfm_mode >= ALLOW_16X16 && m->mbmi.mode <= TM_PRED) {
m->mbmi.txfm_size = TX_16X16;
} else if (cm->txfm_mode >= ALLOW_8X8 && m->mbmi.mode != B_PRED) {
@@ -1219,8 +1228,17 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// FIXME(rbultje) code ternary symbol once all experiments are merged
mbmi->txfm_size = vp9_read(bc, cm->prob_tx[0]);
if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED &&
- mbmi->mode != SPLITMV)
+ mbmi->mode != SPLITMV) {
mbmi->txfm_size += vp9_read(bc, cm->prob_tx[1]);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ if (mbmi->encoded_as_sb && mbmi->txfm_size != TX_8X8)
+ mbmi->txfm_size += vp9_read(bc, cm->prob_tx[2]);
+#endif
+ }
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ } else if (mbmi->encoded_as_sb && cm->txfm_mode >= ALLOW_32X32) {
+ mbmi->txfm_size = TX_32X32;
+#endif
} else if (cm->txfm_mode >= ALLOW_16X16 &&
((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= TM_PRED) ||
(mbmi->ref_frame != INTRA_FRAME && mbmi->mode != SPLITMV))) {
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 76349ad86..7f851a18a 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -693,6 +693,7 @@ static void decode_superblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size;
VP9_COMMON *const pc = &pbi->common;
MODE_INFO *orig_mi = xd->mode_info_context;
+ const int mis = pc->mode_info_stride;
assert(xd->mode_info_context->mbmi.encoded_as_sb);
@@ -733,6 +734,30 @@ static void decode_superblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
}
/* dequantization and idct */
+#if CONFIG_TX32X32
+ if (xd->mode_info_context->mbmi.txfm_size == TX_32X32) {
+ eobtotal = vp9_decode_sb_tokens(pbi, xd, bc);
+ if (eobtotal == 0) { // skip loopfilter
+ xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+ if (mb_col + 1 < pc->mb_cols)
+ xd->mode_info_context[1].mbmi.mb_skip_coeff = 1;
+ if (mb_row + 1 < pc->mb_rows) {
+ xd->mode_info_context[mis].mbmi.mb_skip_coeff = 1;
+ if (mb_col + 1 < pc->mb_cols)
+ xd->mode_info_context[mis + 1].mbmi.mb_skip_coeff = 1;
+ }
+ } else {
+ vp9_dequant_idct_add_32x32(xd->sb_coeff_data.qcoeff, xd->block[0].dequant,
+ xd->dst.y_buffer, xd->dst.y_buffer,
+ xd->dst.y_stride, xd->dst.y_stride,
+ xd->eobs[0]);
+ vp9_dequant_idct_add_uv_block_16x16_c(xd->sb_coeff_data.qcoeff + 1024,
+ xd->block[16].dequant,
+ xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.uv_stride, xd->eobs + 16);
+ }
+ } else {
+#endif
for (n = 0; n < 4; n++) {
int x_idx = n & 1, y_idx = n >> 1;
@@ -742,7 +767,7 @@ static void decode_superblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
xd->above_context = pc->above_context + mb_col + x_idx;
xd->left_context = pc->left_context + y_idx;
- xd->mode_info_context = orig_mi + x_idx + y_idx * pc->mode_info_stride;
+ xd->mode_info_context = orig_mi + x_idx + y_idx * mis;
for (i = 0; i < 25; i++) {
xd->block[i].eob = 0;
xd->eobs[i] = 0;
@@ -766,6 +791,9 @@ static void decode_superblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
xd->above_context = pc->above_context + mb_col;
xd->left_context = pc->left_context;
xd->mode_info_context = orig_mi;
+#if CONFIG_TX32X32
+ }
+#endif
}
#endif
@@ -1244,6 +1272,11 @@ static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
read_coef_probs_common(bc, pc->fc.coef_probs_16x16);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16);
}
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ if (pbi->common.txfm_mode > ALLOW_16X16) {
+ read_coef_probs_common(bc, pc->fc.coef_probs_32x32);
+ }
+#endif
}
int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
@@ -1433,9 +1466,16 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
/* Read the loop filter level and type */
pc->txfm_mode = vp9_read_literal(&header_bc, 2);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ if (pc->txfm_mode == 3)
+ pc->txfm_mode += vp9_read_bit(&header_bc);
+#endif
if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = vp9_read_literal(&header_bc, 8);
pc->prob_tx[1] = vp9_read_literal(&header_bc, 8);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ pc->prob_tx[2] = vp9_read_literal(&header_bc, 8);
+#endif
}
pc->filter_type = (LOOPFILTERTYPE) vp9_read_bit(&header_bc);
@@ -1591,6 +1631,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
pbi->common.fc.coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16,
pbi->common.fc.hybrid_coef_probs_16x16);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ vp9_copy(pbi->common.fc.pre_coef_probs_32x32,
+ pbi->common.fc.coef_probs_32x32);
+#endif
vp9_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
#if CONFIG_SUPERBLOCKS
vp9_copy(pbi->common.fc.pre_sb_ymode_prob, pbi->common.fc.sb_ymode_prob);
@@ -1610,6 +1654,9 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
vp9_zero(pbi->common.fc.hybrid_coef_counts_8x8);
vp9_zero(pbi->common.fc.coef_counts_16x16);
vp9_zero(pbi->common.fc.hybrid_coef_counts_16x16);
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ vp9_zero(pbi->common.fc.coef_counts_32x32);
+#endif
vp9_zero(pbi->common.fc.ymode_counts);
#if CONFIG_SUPERBLOCKS
vp9_zero(pbi->common.fc.sb_ymode_counts);
diff --git a/vp9/decoder/vp9_dequantize.c b/vp9/decoder/vp9_dequantize.c
index 79114d58c..22a66716f 100644
--- a/vp9/decoder/vp9_dequantize.c
+++ b/vp9/decoder/vp9_dequantize.c
@@ -352,3 +352,30 @@ void vp9_dequant_idct_add_16x16_c(int16_t *input, const int16_t *dq,
add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
}
}
+
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+void vp9_dequant_idct_add_32x32(int16_t *input, const int16_t *dq,
+ uint8_t *pred, uint8_t *dest, int pitch,
+ int stride, uint16_t eobs) {
+ short output[1024];
+ int i;
+
+ input[0]= input[0] * dq[0] / 2;
+ for (i = 1; i < 1024; i++)
+ input[i] = input[i] * dq[1] / 2;
+ vp9_short_idct32x32_c(input, output, 64);
+ vpx_memset(input, 0, 2048);
+
+ add_residual(output, pred, pitch, dest, stride, 32, 32);
+}
+
+void vp9_dequant_idct_add_uv_block_16x16_c(short *q, const short *dq,
+ unsigned char *dstu,
+ unsigned char *dstv,
+ int stride,
+ unsigned short *eobs) {
+ vp9_dequant_idct_add_16x16_c(q, dq, dstu, dstu, stride, stride, eobs[0]);
+ vp9_dequant_idct_add_16x16_c(q + 256, dq,
+ dstv, dstv, stride, stride, eobs[4]);
+}
+#endif
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 897ad5204..35a26477a 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -55,8 +55,9 @@
#define CAT5_PROB3 157
#define CAT5_PROB4 180
-static const unsigned char cat6_prob[14] =
-{ 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
+static const unsigned char cat6_prob[15] = {
+ 254, 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 */
@@ -161,6 +162,12 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
coef_counts = fc->hybrid_coef_counts_16x16[type];
}
break;
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+ case TX_32X32:
+ coef_probs = fc->coef_probs_32x32[type];
+ coef_counts = fc->coef_counts_32x32[type];
+ break;
+#endif
}
VP9_COMBINEENTROPYCONTEXTS(pt, *a, *l);
@@ -256,6 +263,54 @@ static int get_eob(MACROBLOCKD* const xd, int segment_id, int eob_max) {
return eob;
}
+#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
+int vp9_decode_sb_tokens(VP9D_COMP* const pbi,
+ MACROBLOCKD* const xd,
+ BOOL_DECODER* const bc) {
+ ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
+ ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
+ unsigned short* const eobs = xd->eobs;
+ const int segment_id = xd->mode_info_context->mbmi.segment_id;
+ int c, i, eobtotal = 0, seg_eob;
+
+ // Luma block
+ eobs[0] = c = decode_coefs(pbi, xd, bc, A, L, PLANE_TYPE_Y_WITH_DC,
+ DCT_DCT, get_eob(xd, segment_id, 1024),
+ xd->sb_coeff_data.qcoeff,
+ vp9_default_zig_zag1d_32x32,
+ TX_32X32, vp9_coef_bands_32x32);
+ A[1] = A[2] = A[3] = A[0];
+ L[1] = L[2] = L[3] = L[0];
+ eobtotal += c;
+
+ // 16x16 chroma blocks
+ seg_eob = get_eob(xd, segment_id, 256);
+ for (i = 16; i < 24; i += 4) {
+ ENTROPY_CONTEXT* const a = A + vp9_block2above_8x8[i];
+ ENTROPY_CONTEXT* const l = L + vp9_block2left_8x8[i];
+
+ eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, PLANE_TYPE_UV,
+ DCT_DCT, seg_eob,
+ xd->sb_coeff_data.qcoeff + 1024 + (i - 16) * 64,
+ vp9_default_zig_zag1d_16x16,
+ TX_16X16, vp9_coef_bands_16x16);
+ a[1] = a[0];
+ l[1] = l[0];
+ eobtotal += c;
+ }
+
+ // no Y2 block
+ vpx_memset(&A[8], 0, sizeof(A[8]));
+ vpx_memset(&L[8], 0, sizeof(L[8]));
+
+ vpx_memcpy(xd->above_context + 1, xd->above_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
+ vpx_memcpy(xd->left_context + 1, xd->left_context,
+ sizeof(ENTROPY_CONTEXT_PLANES));
+
+ return eobtotal;
+}
+#endif
static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
MACROBLOCKD* const xd,
diff --git a/vp9/decoder/vp9_detokenize.h b/vp9/decoder/vp9_detokenize.h
index 9b319d4a9..09d354ea6 100644
--- a/vp9/decoder/vp9_detokenize.h
+++ b/vp9/decoder/vp9_detokenize.h
@@ -23,6 +23,12 @@ int vp9_decode_coefs_4x4(VP9D_COMP *dx, MACROBLOCKD *xd,
int vp9_decode_mb_tokens(VP9D_COMP* const, MACROBLOCKD* const,
BOOL_DECODER* const);
+#if CONFIG_SUPERBLOCKS && CONFIG_TX32X32
+int vp9_decode_sb_tokens(VP9D_COMP* const pbi,
+ MACROBLOCKD* const xd,
+ BOOL_DECODER* const bc);
+#endif
+
int vp9_decode_mb_tokens_4x4_uv(VP9D_COMP* const dx, MACROBLOCKD* const xd,
BOOL_DECODER* const bc);