Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: source/libvpx/vp9/decoder/vp9_decodframe.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decodframe.h ('k') | source/libvpx/vp9/decoder/vp9_dequantize.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/decoder/vp9_decodframe.c
===================================================================
--- source/libvpx/vp9/decoder/vp9_decodframe.c (revision 177019)
+++ source/libvpx/vp9/decoder/vp9_decodframe.c (working copy)
@@ -10,17 +10,19 @@
#include "vp9/decoder/vp9_onyxd_int.h"
+#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_header.h"
#include "vp9/common/vp9_reconintra.h"
#include "vp9/common/vp9_reconintra4x4.h"
#include "vp9/common/vp9_reconinter.h"
+#include "vp9/common/vp9_entropy.h"
#include "vp9/decoder/vp9_decodframe.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_invtrans.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_quant_common.h"
-#include "vpx_scale/vpxscale.h"
+#include "vpx_scale/vpx_scale.h"
#include "vp9/common/vp9_setupintrarecon.h"
#include "vp9/decoder/vp9_decodemv.h"
@@ -81,17 +83,17 @@
VP9_COMMON *const pc = &pbi->common;
for (Q = 0; Q < QINDEX_RANGE; Q++) {
- pc->Y1dequant[Q][0] = (short)vp9_dc_quant(Q, pc->y1dc_delta_q);
- pc->Y2dequant[Q][0] = (short)vp9_dc2quant(Q, pc->y2dc_delta_q);
- pc->UVdequant[Q][0] = (short)vp9_dc_uv_quant(Q, pc->uvdc_delta_q);
+ pc->Y1dequant[Q][0] = (int16_t)vp9_dc_quant(Q, pc->y1dc_delta_q);
+ pc->Y2dequant[Q][0] = (int16_t)vp9_dc2quant(Q, pc->y2dc_delta_q);
+ pc->UVdequant[Q][0] = (int16_t)vp9_dc_uv_quant(Q, pc->uvdc_delta_q);
/* all the ac values =; */
for (i = 1; i < 16; i++) {
- int rc = vp9_default_zig_zag1d[i];
+ int rc = vp9_default_zig_zag1d_4x4[i];
- pc->Y1dequant[Q][rc] = (short)vp9_ac_yquant(Q);
- pc->Y2dequant[Q][rc] = (short)vp9_ac2quant(Q, pc->y2ac_delta_q);
- pc->UVdequant[Q][rc] = (short)vp9_ac_uv_quant(Q, pc->uvac_delta_q);
+ pc->Y1dequant[Q][rc] = (int16_t)vp9_ac_yquant(Q);
+ pc->Y2dequant[Q][rc] = (int16_t)vp9_ac2quant(Q, pc->y2ac_delta_q);
+ pc->UVdequant[Q][rc] = (int16_t)vp9_ac_uv_quant(Q, pc->uvac_delta_q);
}
}
}
@@ -170,20 +172,25 @@
*/
static void skip_recon_mb(VP9D_COMP *pbi, MACROBLOCKD *xd) {
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
+ if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
+ vp9_build_intra_predictors_sb64uv_s(xd);
+ vp9_build_intra_predictors_sb64y_s(xd);
+ } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
vp9_build_intra_predictors_sbuv_s(xd);
vp9_build_intra_predictors_sby_s(xd);
} else {
-#endif
- vp9_build_intra_predictors_mbuv_s(xd);
- vp9_build_intra_predictors_mby_s(xd);
-#if CONFIG_SUPERBLOCKS
+ vp9_build_intra_predictors_mbuv_s(xd);
+ vp9_build_intra_predictors_mby_s(xd);
}
-#endif
} else {
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
+ if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
+ vp9_build_inter64x64_predictors_sb(xd,
+ xd->dst.y_buffer,
+ xd->dst.u_buffer,
+ xd->dst.v_buffer,
+ xd->dst.y_stride,
+ xd->dst.uv_stride);
+ } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
vp9_build_inter32x32_predictors_sb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
@@ -191,35 +198,32 @@
xd->dst.y_stride,
xd->dst.uv_stride);
} else {
-#endif
- 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,
+ 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 CONFIG_COMP_INTERINTRA_PRED
- else if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
- vp9_build_interintra_16x16_predictors_mb(xd,
+
+ 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 CONFIG_SUPERBLOCKS
}
-#endif
}
}
@@ -283,10 +287,10 @@
for (i = 0; i < 4; i++) {
int ib = vp9_i8x8_block[i];
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;
+ int16_t *q = xd->block[idx].qcoeff;
+ int16_t *dq = xd->block[0].dequant;
+ uint8_t *pre = xd->block[ib].predictor;
+ uint8_t *dst = *(xd->block[ib].base_dst) + xd->block[ib].dst;
int stride = xd->dst.y_stride;
BLOCKD *b = &xd->block[ib];
if (xd->mode_info_context->mbmi.mode == I8X8_PRED) {
@@ -414,9 +418,6 @@
assert(get_2nd_order_usage(xd) == 0);
for (i = 0; i < 16; i++) {
int b_mode;
-#if CONFIG_COMP_INTRA_PRED
- int b_mode2;
-#endif
BLOCKD *b = &xd->block[i];
b_mode = xd->mode_info_context->bmi[i].as_mode.first;
#if CONFIG_NEWBINTRAMODES
@@ -425,17 +426,8 @@
#endif
if (!xd->mode_info_context->mbmi.mb_skip_coeff)
eobtotal += vp9_decode_coefs_4x4(pbi, xd, bc, PLANE_TYPE_Y_WITH_DC, i);
-#if CONFIG_COMP_INTRA_PRED
- b_mode2 = xd->mode_info_context->bmi[i].as_mode.second;
- if (b_mode2 == (B_PREDICTION_MODE)(B_DC_PRED - 1)) {
-#endif
- vp9_intra4x4_predict(b, b_mode, b->predictor);
-#if CONFIG_COMP_INTRA_PRED
- } else {
- vp9_comp_intra4x4_predict(b, b_mode, b_mode2, b->predictor);
- }
-#endif
+ vp9_intra4x4_predict(b, b_mode, b->predictor);
tx_type = get_tx_type_4x4(xd, b);
if (tx_type != DCT_DCT) {
vp9_ht_dequant_idct_add_c(tx_type, b->qcoeff,
@@ -446,12 +438,12 @@
vp9_dequant_idct_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride);
}
- xd->above_context->y2 = 1;
- xd->left_context->y2 = 1;
}
if (!xd->mode_info_context->mbmi.mb_skip_coeff) {
vp9_decode_mb_tokens_4x4_uv(pbi, xd, bc);
}
+ xd->above_context->y2 = 0;
+ xd->left_context->y2 = 0;
vp9_build_intra_predictors_mbuv(xd);
pbi->idct_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant,
@@ -546,10 +538,10 @@
}
}
-#if CONFIG_SUPERBLOCKS
static void decode_16x16_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
- BOOL_DECODER* const bc, int n) {
- int x_idx = n & 1, y_idx = n >> 1;
+ BOOL_DECODER* const bc, int n,
+ int maska, int shiftb) {
+ int x_idx = n & maska, y_idx = n >> shiftb;
TX_TYPE tx_type = get_tx_type_16x16(xd, &xd->block[0]);
if (tx_type != DCT_DCT) {
vp9_ht_dequant_idct_add_16x16_c(
@@ -573,17 +565,18 @@
};
static void decode_8x8_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
- BOOL_DECODER* const bc, int n) {
+ BOOL_DECODER* const bc, int n,
+ int maska, int shiftb) {
+ int x_idx = n & maska, y_idx = n >> shiftb;
BLOCKD *b = &xd->block[24];
- int x_idx = n & 1, y_idx = n >> 1;
TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[0]);
if (tx_type != DCT_DCT) {
int i;
for (i = 0; i < 4; i++) {
int ib = vp9_i8x8_block[i];
int idx = (ib & 0x02) ? (ib + 2) : ib;
- short *q = xd->block[idx].qcoeff;
- short *dq = xd->block[0].dequant;
+ int16_t *q = xd->block[idx].qcoeff;
+ int16_t *dq = xd->block[0].dequant;
int stride = xd->dst.y_stride;
BLOCKD *b = &xd->block[ib];
tx_type = get_tx_type_8x8(xd, &xd->block[ib]);
@@ -634,9 +627,10 @@
};
static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
- BOOL_DECODER* const bc, int n) {
+ BOOL_DECODER* const bc, int n,
+ int maska, int shiftb) {
+ int x_idx = n & maska, y_idx = n >> shiftb;
BLOCKD *b = &xd->block[24];
- int x_idx = n & 1, y_idx = n >> 1;
TX_TYPE tx_type = get_tx_type_4x4(xd, &xd->block[0]);
if (tx_type != DCT_DCT) {
int i;
@@ -689,15 +683,16 @@
xd->dst.uv_stride, xd->eobs + 16, xd);
};
-static void decode_superblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
- int mb_row, unsigned int mb_col,
- BOOL_DECODER* const bc) {
+static void decode_superblock64(VP9D_COMP *pbi, MACROBLOCKD *xd,
+ int mb_row, unsigned int mb_col,
+ BOOL_DECODER* const bc) {
int i, n, eobtotal;
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);
+ assert(xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64);
if (pbi->common.frame_type != KEY_FRAME)
vp9_setup_interp_filters(xd, xd->mode_info_context->mbmi.interp_filter, pc);
@@ -707,7 +702,133 @@
mb_init_dequantizer(pbi, xd);
if (xd->mode_info_context->mbmi.mb_skip_coeff) {
+ int n;
+
vp9_reset_mb_tokens_context(xd);
+ for (n = 1; n <= 3; n++) {
+ if (mb_col < pc->mb_cols - n)
+ xd->above_context += n;
+ if (mb_row < pc->mb_rows - n)
+ xd->left_context += n;
+ vp9_reset_mb_tokens_context(xd);
+ if (mb_col < pc->mb_cols - n)
+ xd->above_context -= n;
+ if (mb_row < pc->mb_rows - n)
+ xd->left_context -= n;
+ }
+
+ /* Special case: Force the loopfilter to skip when eobtotal and
+ * mb_skip_coeff are zero.
+ */
+ skip_recon_mb(pbi, xd);
+ return;
+ }
+
+ /* do prediction */
+ if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
+ vp9_build_intra_predictors_sb64y_s(xd);
+ vp9_build_intra_predictors_sb64uv_s(xd);
+ } else {
+ vp9_build_inter64x64_predictors_sb(xd, xd->dst.y_buffer,
+ xd->dst.u_buffer, xd->dst.v_buffer,
+ xd->dst.y_stride, xd->dst.uv_stride);
+ }
+
+ /* dequantization and idct */
+ if (xd->mode_info_context->mbmi.txfm_size == TX_32X32) {
+ for (n = 0; n < 4; n++) {
+ const int x_idx = n & 1, y_idx = n >> 1;
+
+ if (mb_col + x_idx * 2 >= pc->mb_cols ||
+ mb_row + y_idx * 2 >= pc->mb_rows)
+ continue;
+
+ xd->left_context = pc->left_context + (y_idx << 1);
+ xd->above_context = pc->above_context + mb_col + (x_idx << 1);
+ xd->mode_info_context = orig_mi + x_idx * 2 + y_idx * 2 * mis;
+ 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 + x_idx * 32 +
+ xd->dst.y_stride * y_idx * 32,
+ xd->dst.y_buffer + x_idx * 32 +
+ xd->dst.y_stride * y_idx * 32,
+ 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 + x_idx * 16 +
+ xd->dst.uv_stride * y_idx * 16,
+ xd->dst.v_buffer + x_idx * 16 +
+ xd->dst.uv_stride * y_idx * 16,
+ xd->dst.uv_stride, xd->eobs + 16);
+ }
+ }
+ } else {
+ for (n = 0; n < 16; n++) {
+ int x_idx = n & 3, y_idx = n >> 2;
+
+ if (mb_col + x_idx >= pc->mb_cols || mb_row + y_idx >= pc->mb_rows)
+ continue;
+
+ 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 * mis;
+ for (i = 0; i < 25; i++) {
+ xd->block[i].eob = 0;
+ xd->eobs[i] = 0;
+ }
+
+ eobtotal = vp9_decode_mb_tokens(pbi, xd, bc);
+ if (eobtotal == 0) { // skip loopfilter
+ xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+ continue;
+ }
+
+ if (tx_size == TX_16X16) {
+ decode_16x16_sb(pbi, xd, bc, n, 3, 2);
+ } else if (tx_size == TX_8X8) {
+ decode_8x8_sb(pbi, xd, bc, n, 3, 2);
+ } else {
+ decode_4x4_sb(pbi, xd, bc, n, 3, 2);
+ }
+ }
+ }
+
+ xd->above_context = pc->above_context + mb_col;
+ xd->left_context = pc->left_context;
+ xd->mode_info_context = orig_mi;
+}
+
+static void decode_superblock32(VP9D_COMP *pbi, MACROBLOCKD *xd,
+ int mb_row, unsigned int mb_col,
+ BOOL_DECODER* const bc) {
+ int i, n, eobtotal;
+ 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.sb_type == BLOCK_SIZE_SB32X32);
+
+ if (pbi->common.frame_type != KEY_FRAME)
+ vp9_setup_interp_filters(xd, xd->mode_info_context->mbmi.interp_filter, pc);
+
+ // re-initialize macroblock dequantizer before detokenization
+ if (xd->segmentation_enabled)
+ mb_init_dequantizer(pbi, xd);
+
+ if (xd->mode_info_context->mbmi.mb_skip_coeff) {
+ vp9_reset_mb_tokens_context(xd);
if (mb_col < pc->mb_cols - 1)
xd->above_context++;
if (mb_row < pc->mb_rows - 1)
@@ -736,41 +857,62 @@
}
/* dequantization and idct */
- for (n = 0; n < 4; n++) {
- int x_idx = n & 1, y_idx = n >> 1;
+ 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 {
+ for (n = 0; n < 4; n++) {
+ int x_idx = n & 1, y_idx = n >> 1;
- if (mb_col + x_idx >= pc->mb_cols || mb_row + y_idx >= pc->mb_rows)
- continue;
+ if (mb_col + x_idx >= pc->mb_cols || mb_row + y_idx >= pc->mb_rows)
+ continue;
+ xd->above_context = pc->above_context + mb_col + x_idx;
+ xd->left_context = pc->left_context + y_idx + (mb_row & 2);
+ 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;
+ }
- 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;
- for (i = 0; i < 25; i++) {
- xd->block[i].eob = 0;
- xd->eobs[i] = 0;
- }
+ eobtotal = vp9_decode_mb_tokens(pbi, xd, bc);
+ if (eobtotal == 0) { // skip loopfilter
+ xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+ continue;
+ }
- eobtotal = vp9_decode_mb_tokens(pbi, xd, bc);
- if (eobtotal == 0) { // skip loopfilter
- xd->mode_info_context->mbmi.mb_skip_coeff = 1;
- continue;
+ if (tx_size == TX_16X16) {
+ decode_16x16_sb(pbi, xd, bc, n, 1, 1);
+ } else if (tx_size == TX_8X8) {
+ decode_8x8_sb(pbi, xd, bc, n, 1, 1);
+ } else {
+ decode_4x4_sb(pbi, xd, bc, n, 1, 1);
+ }
}
- if (tx_size == TX_16X16) {
- decode_16x16_sb(pbi, xd, bc, n);
- } else if (tx_size == TX_8X8) {
- decode_8x8_sb(pbi, xd, bc, n);
- } else {
- decode_4x4_sb(pbi, xd, bc, n);
- }
+ xd->above_context = pc->above_context + mb_col;
+ xd->left_context = pc->left_context + (mb_row & 2);
+ xd->mode_info_context = orig_mi;
}
-
- xd->above_context = pc->above_context + mb_col;
- xd->left_context = pc->left_context;
- xd->mode_info_context = orig_mi;
}
-#endif
static void decode_macroblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
int mb_row, unsigned int mb_col,
@@ -780,9 +922,7 @@
int i;
int tx_size;
-#if CONFIG_SUPERBLOCKS
- assert(!xd->mode_info_context->mbmi.encoded_as_sb);
-#endif
+ assert(!xd->mode_info_context->mbmi.sb_type);
// re-initialize macroblock dequantizer before detokenization
if (xd->segmentation_enabled)
@@ -904,190 +1044,176 @@
FILE *vpxlog = 0;
#endif
-/* Decode a row of Superblocks (2x2 region of MBs) */
-static void
-decode_sb_row(VP9D_COMP *pbi, VP9_COMMON *pc, int mbrow, MACROBLOCKD *xd,
- BOOL_DECODER* const bc) {
- int i;
- int sb_col;
- int mb_row, mb_col;
- int recon_yoffset, recon_uvoffset;
- int ref_fb_idx = pc->lst_fb_idx;
- int dst_fb_idx = pc->new_fb_idx;
- int recon_y_stride = pc->yv12_fb[ref_fb_idx].y_stride;
- int recon_uv_stride = pc->yv12_fb[ref_fb_idx].uv_stride;
- int row_delta[4] = { 0, +1, 0, -1};
- int col_delta[4] = { +1, -1, +1, +1};
- int sb_cols = (pc->mb_cols + 1) >> 1;
+static void set_offsets(VP9D_COMP *pbi, int block_size,
+ int mb_row, int mb_col) {
+ VP9_COMMON *const cm = &pbi->common;
+ MACROBLOCKD *const xd = &pbi->mb;
+ const int mis = cm->mode_info_stride;
+ const int idx = mis * mb_row + mb_col;
+ const int dst_fb_idx = cm->new_fb_idx;
+ const int recon_y_stride = cm->yv12_fb[dst_fb_idx].y_stride;
+ const int recon_uv_stride = cm->yv12_fb[dst_fb_idx].uv_stride;
+ const int recon_yoffset = mb_row * 16 * recon_y_stride + 16 * mb_col;
+ const int recon_uvoffset = mb_row * 8 * recon_uv_stride + 8 * mb_col;
- // For a SB there are 2 left contexts, each pertaining to a MB row within
- vpx_memset(pc->left_context, 0, sizeof(pc->left_context));
+ xd->mode_info_context = cm->mi + idx;
+ xd->mode_info_context->mbmi.sb_type = block_size >> 5;
+ xd->prev_mode_info_context = cm->prev_mi + idx;
+ xd->above_context = cm->above_context + mb_col;
+ xd->left_context = cm->left_context + (mb_row & 3);
- mb_row = mbrow;
- mb_col = 0;
+ /* Distance of Mb to the various image edges.
+ * These are specified to 8th pel as they are always compared to
+ * values that are in 1/8th pel units
+ */
+ block_size >>= 4; // in mb units
+ xd->mb_to_top_edge = -((mb_row * 16)) << 3;
+ xd->mb_to_left_edge = -((mb_col * 16) << 3);
+ xd->mb_to_bottom_edge = ((cm->mb_rows - block_size - mb_row) * 16) << 3;
+ xd->mb_to_right_edge = ((cm->mb_cols - block_size - mb_col) * 16) << 3;
- for (sb_col = 0; sb_col < sb_cols; sb_col++) {
- MODE_INFO *mi = xd->mode_info_context;
+ xd->up_available = (mb_row != 0);
+ xd->left_available = (mb_col != 0);
-#if CONFIG_SUPERBLOCKS
- mi->mbmi.encoded_as_sb = vp9_read(bc, pc->sb_coded);
-#endif
+ xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
+ xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
+ xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
+}
- // Process the 4 MBs within the SB in the order:
- // top-left, top-right, bottom-left, bottom-right
- for (i = 0; i < 4; i++) {
- int dy = row_delta[i];
- int dx = col_delta[i];
- int offset_extended = dy * xd->mode_info_stride + dx;
+static void set_refs(VP9D_COMP *pbi, int block_size,
+ int mb_row, int mb_col) {
+ VP9_COMMON *const cm = &pbi->common;
+ MACROBLOCKD *const xd = &pbi->mb;
+ MODE_INFO *mi = xd->mode_info_context;
+ MB_MODE_INFO *const mbmi = &mi->mbmi;
- xd->mb_index = i;
+ if (mbmi->ref_frame > INTRA_FRAME) {
+ int ref_fb_idx, ref_yoffset, ref_uvoffset, ref_y_stride, ref_uv_stride;
- mi = xd->mode_info_context;
- if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols)) {
- // MB lies outside frame, skip on to next
- mb_row += dy;
- mb_col += dx;
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
- continue;
- }
-#if CONFIG_SUPERBLOCKS
- if (i)
- mi->mbmi.encoded_as_sb = 0;
-#endif
+ /* Select the appropriate reference frame for this MB */
+ if (mbmi->ref_frame == LAST_FRAME)
+ ref_fb_idx = cm->lst_fb_idx;
+ else if (mbmi->ref_frame == GOLDEN_FRAME)
+ ref_fb_idx = cm->gld_fb_idx;
+ else
+ ref_fb_idx = cm->alt_fb_idx;
- // Set above context pointer
- xd->above_context = pc->above_context + mb_col;
- xd->left_context = pc->left_context + (i >> 1);
+ ref_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
+ ref_yoffset = mb_row * 16 * ref_y_stride + 16 * mb_col;
+ xd->pre.y_buffer = cm->yv12_fb[ref_fb_idx].y_buffer + ref_yoffset;
+ ref_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
+ ref_uvoffset = mb_row * 8 * ref_uv_stride + 8 * mb_col;
+ xd->pre.u_buffer = cm->yv12_fb[ref_fb_idx].u_buffer + ref_uvoffset;
+ xd->pre.v_buffer = cm->yv12_fb[ref_fb_idx].v_buffer + ref_uvoffset;
- /* Distance of Mb to the various image edges.
- * These are specified to 8th pel as they are always compared to
- * values that are in 1/8th pel units
- */
- xd->mb_to_top_edge = -((mb_row * 16)) << 3;
- xd->mb_to_left_edge = -((mb_col * 16) << 3);
-#if CONFIG_SUPERBLOCKS
- if (mi->mbmi.encoded_as_sb) {
- xd->mb_to_bottom_edge = ((pc->mb_rows - 2 - mb_row) * 16) << 3;
- xd->mb_to_right_edge = ((pc->mb_cols - 2 - mb_col) * 16) << 3;
- } else {
-#endif
- xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
- xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
-#if CONFIG_SUPERBLOCKS
+ /* propagate errors from reference frames */
+ xd->corrupted |= cm->yv12_fb[ref_fb_idx].corrupted;
+
+ if (mbmi->second_ref_frame > INTRA_FRAME) {
+ int second_ref_fb_idx;
+
+ /* Select the appropriate reference frame for this MB */
+ if (mbmi->second_ref_frame == LAST_FRAME)
+ second_ref_fb_idx = cm->lst_fb_idx;
+ else if (mbmi->second_ref_frame == GOLDEN_FRAME)
+ second_ref_fb_idx = cm->gld_fb_idx;
+ else
+ second_ref_fb_idx = cm->alt_fb_idx;
+
+ xd->second_pre.y_buffer =
+ cm->yv12_fb[second_ref_fb_idx].y_buffer + ref_yoffset;
+ xd->second_pre.u_buffer =
+ cm->yv12_fb[second_ref_fb_idx].u_buffer + ref_uvoffset;
+ xd->second_pre.v_buffer =
+ cm->yv12_fb[second_ref_fb_idx].v_buffer + ref_uvoffset;
+
+ /* propagate errors from reference frames */
+ xd->corrupted |= cm->yv12_fb[second_ref_fb_idx].corrupted;
+ }
+ }
+
+ if (mbmi->sb_type) {
+ const int n_mbs = 1 << mbmi->sb_type;
+ const int y_mbs = MIN(n_mbs, cm->mb_rows - mb_row);
+ const int x_mbs = MIN(n_mbs, cm->mb_cols - mb_col);
+ const int mis = cm->mode_info_stride;
+ int x, y;
+
+ for (y = 0; y < y_mbs; y++) {
+ for (x = !y; x < x_mbs; x++) {
+ mi[y * mis + x] = *mi;
}
-#endif
-#ifdef DEC_DEBUG
- dec_debug = (pbi->common.current_video_frame == 1 &&
- mb_row == 2 && mb_col == 8);
- if (dec_debug)
-#if CONFIG_SUPERBLOCKS
- printf("Enter Debug %d %d sb %d\n", mb_row, mb_col,
- mi->mbmi.encoded_as_sb);
-#else
- printf("Enter Debug %d %d\n", mb_row, mb_col);
-#endif
-#endif
- xd->up_available = (mb_row != 0);
- xd->left_available = (mb_col != 0);
+ }
+ }
+}
+/* Decode a row of Superblocks (2x2 region of MBs) */
+static void decode_sb_row(VP9D_COMP *pbi, VP9_COMMON *pc,
+ int mb_row, MACROBLOCKD *xd,
+ BOOL_DECODER* const bc) {
+ int mb_col;
- recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
+ // For a SB there are 2 left contexts, each pertaining to a MB row within
+ vpx_memset(pc->left_context, 0, sizeof(pc->left_context));
- xd->dst.y_buffer = pc->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
- xd->dst.u_buffer = pc->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
- xd->dst.v_buffer = pc->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
-
+ for (mb_col = 0; mb_col < pc->mb_cols; mb_col += 4) {
+ if (vp9_read(bc, pc->sb64_coded)) {
+ set_offsets(pbi, 64, mb_row, mb_col);
vp9_decode_mb_mode_mv(pbi, xd, mb_row, mb_col, bc);
+ set_refs(pbi, 64, mb_row, mb_col);
+ decode_superblock64(pbi, xd, mb_row, mb_col, bc);
+ xd->corrupted |= bool_error(bc);
+ } else {
+ int j;
- update_blockd_bmi(xd);
-#ifdef DEC_DEBUG
- if (dec_debug)
- printf("Hello\n");
-#endif
+ for (j = 0; j < 4; j++) {
+ const int x_idx_sb = (j & 1) << 1, y_idx_sb = j & 2;
- /* Select the appropriate reference frame for this MB */
- if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
- ref_fb_idx = pc->lst_fb_idx;
- else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
- ref_fb_idx = pc->gld_fb_idx;
- else
- ref_fb_idx = pc->alt_fb_idx;
+ if (mb_row + y_idx_sb >= pc->mb_rows ||
+ mb_col + x_idx_sb >= pc->mb_cols) {
+ // MB lies outside frame, skip on to next
+ continue;
+ }
- xd->pre.y_buffer = pc->yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
- xd->pre.u_buffer = pc->yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset;
- xd->pre.v_buffer = pc->yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset;
+ xd->sb_index = j;
- if (xd->mode_info_context->mbmi.second_ref_frame > 0) {
- int second_ref_fb_idx;
+ if (vp9_read(bc, pc->sb32_coded)) {
+ set_offsets(pbi, 32, mb_row + y_idx_sb, mb_col + x_idx_sb);
+ vp9_decode_mb_mode_mv(pbi,
+ xd, mb_row + y_idx_sb, mb_col + x_idx_sb, bc);
+ set_refs(pbi, 32, mb_row + y_idx_sb, mb_col + x_idx_sb);
+ decode_superblock32(pbi,
+ xd, mb_row + y_idx_sb, mb_col + x_idx_sb, bc);
+ xd->corrupted |= bool_error(bc);
+ } else {
+ int i;
- /* Select the appropriate reference frame for this MB */
- if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
- second_ref_fb_idx = pc->lst_fb_idx;
- else if (xd->mode_info_context->mbmi.second_ref_frame ==
- GOLDEN_FRAME)
- second_ref_fb_idx = pc->gld_fb_idx;
- else
- second_ref_fb_idx = pc->alt_fb_idx;
+ // Process the 4 MBs within the SB in the order:
+ // top-left, top-right, bottom-left, bottom-right
+ for (i = 0; i < 4; i++) {
+ const int x_idx = x_idx_sb + (i & 1), y_idx = y_idx_sb + (i >> 1);
- xd->second_pre.y_buffer =
- pc->yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
- xd->second_pre.u_buffer =
- pc->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset;
- xd->second_pre.v_buffer =
- pc->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset;
- }
+ if (mb_row + y_idx >= pc->mb_rows ||
+ mb_col + x_idx >= pc->mb_cols) {
+ // MB lies outside frame, skip on to next
+ continue;
+ }
- if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME) {
- /* propagate errors from reference frames */
- xd->corrupted |= pc->yv12_fb[ref_fb_idx].corrupted;
- }
+ set_offsets(pbi, 16, mb_row + y_idx, mb_col + x_idx);
+ xd->mb_index = i;
+ vp9_decode_mb_mode_mv(pbi, xd, mb_row + y_idx, mb_col + x_idx, bc);
+ update_blockd_bmi(xd);
+ set_refs(pbi, 16, mb_row + y_idx, mb_col + x_idx);
+ vp9_intra_prediction_down_copy(xd);
+ decode_macroblock(pbi, xd, mb_row, mb_col, bc);
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
- if (mb_col < pc->mb_cols - 1)
- mi[1] = mi[0];
- if (mb_row < pc->mb_rows - 1) {
- mi[pc->mode_info_stride] = mi[0];
- if (mb_col < pc->mb_cols - 1)
- mi[pc->mode_info_stride + 1] = mi[0];
+ /* check if the boolean decoder has suffered an error */
+ xd->corrupted |= bool_error(bc);
+ }
}
}
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
- decode_superblock(pbi, xd, mb_row, mb_col, bc);
- } else {
-#endif
- vp9_intra_prediction_down_copy(xd);
- decode_macroblock(pbi, xd, mb_row, mb_col, bc);
-#if CONFIG_SUPERBLOCKS
- }
-#endif
-
- /* check if the boolean decoder has suffered an error */
- xd->corrupted |= bool_error(bc);
-
-#if CONFIG_SUPERBLOCKS
- if (mi->mbmi.encoded_as_sb) {
- assert(!i);
- mb_col += 2;
- xd->mode_info_context += 2;
- xd->prev_mode_info_context += 2;
- break;
- }
-#endif
-
- // skip to next MB
- xd->mode_info_context += offset_extended;
- xd->prev_mode_info_context += offset_extended;
- mb_row += dy;
- mb_col += dx;
}
}
-
- /* skip prediction column */
- xd->mode_info_context += 1 - (pc->mb_cols & 0x1) + xd->mode_info_stride;
- xd->prev_mode_info_context += 1 - (pc->mb_cols & 0x1) + xd->mode_info_stride;
}
static unsigned int read_partition_size(const unsigned char *cx_size) {
@@ -1210,14 +1336,13 @@
}
-static void read_coef_probs_common(
- BOOL_DECODER* const bc,
- vp9_prob coef_probs[BLOCK_TYPES][COEF_BANDS]
- [PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
+static void read_coef_probs_common(BOOL_DECODER* const bc,
+ vp9_coeff_probs *coef_probs,
+ int block_types) {
int i, j, k, l;
if (vp9_read_bit(bc)) {
- for (i = 0; i < BLOCK_TYPES; i++) {
+ for (i = 0; i < block_types; i++) {
for (j = !i; j < COEF_BANDS; j++) {
/* NB: This j loop starts from 1 on block type i == 0 */
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
@@ -1240,17 +1365,21 @@
static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
VP9_COMMON *const pc = &pbi->common;
- read_coef_probs_common(bc, pc->fc.coef_probs);
- read_coef_probs_common(bc, pc->fc.hybrid_coef_probs);
+ read_coef_probs_common(bc, pc->fc.coef_probs_4x4, BLOCK_TYPES_4X4);
+ read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_4x4, BLOCK_TYPES_4X4);
if (pbi->common.txfm_mode != ONLY_4X4) {
- read_coef_probs_common(bc, pc->fc.coef_probs_8x8);
- read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_8x8);
+ read_coef_probs_common(bc, pc->fc.coef_probs_8x8, BLOCK_TYPES_8X8);
+ read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_8x8, BLOCK_TYPES_8X8);
}
if (pbi->common.txfm_mode > ALLOW_8X8) {
- read_coef_probs_common(bc, pc->fc.coef_probs_16x16);
- read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16);
+ read_coef_probs_common(bc, pc->fc.coef_probs_16x16, BLOCK_TYPES_16X16);
+ read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16,
+ BLOCK_TYPES_16X16);
}
+ if (pbi->common.txfm_mode > ALLOW_16X16) {
+ read_coef_probs_common(bc, pc->fc.coef_probs_32x32, BLOCK_TYPES_32X32);
+ }
}
int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
@@ -1435,15 +1564,17 @@
}
}
-#if CONFIG_SUPERBLOCKS
- pc->sb_coded = vp9_read_literal(&header_bc, 8);
-#endif
+ pc->sb64_coded = vp9_read_literal(&header_bc, 8);
+ pc->sb32_coded = vp9_read_literal(&header_bc, 8);
/* Read the loop filter level and type */
pc->txfm_mode = vp9_read_literal(&header_bc, 2);
+ if (pc->txfm_mode == 3)
+ pc->txfm_mode += vp9_read_bit(&header_bc);
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);
+ pc->prob_tx[2] = vp9_read_literal(&header_bc, 8);
}
pc->filter_type = (LOOPFILTERTYPE) vp9_read_bit(&header_bc);
@@ -1575,6 +1706,33 @@
}
}
+#if CONFIG_NEW_MVREF
+ // If Key frame reset mv ref id probabilities to defaults
+ if (pc->frame_type == KEY_FRAME) {
+ // Defaults probabilities for encoding the MV ref id signal
+ vpx_memset(xd->mb_mv_ref_probs, VP9_DEFAULT_MV_REF_PROB,
+ sizeof(xd->mb_mv_ref_probs));
+ } else {
+ // Read any mv_ref index probability updates
+ int i, j;
+
+ for (i = 0; i < MAX_REF_FRAMES; ++i) {
+ // Skip the dummy entry for intra ref frame.
+ if (i == INTRA_FRAME) {
+ continue;
+ }
+
+ // Read any updates to probabilities
+ for (j = 0; j < MAX_MV_REF_CANDIDATES - 1; ++j) {
+ if (vp9_read(&header_bc, VP9_MVREF_UPDATE_PROB)) {
+ xd->mb_mv_ref_probs[i][j] =
+ (vp9_prob)vp9_read_literal(&header_bc, 8);
+ }
+ }
+ }
+ }
+#endif
+
if (0) {
FILE *z = fopen("decodestats.stt", "a");
fprintf(z, "%6d F:%d,G:%d,A:%d,L:%d,Q:%d\n",
@@ -1587,10 +1745,10 @@
fclose(z);
}
- vp9_copy(pbi->common.fc.pre_coef_probs,
- pbi->common.fc.coef_probs);
- vp9_copy(pbi->common.fc.pre_hybrid_coef_probs,
- pbi->common.fc.hybrid_coef_probs);
+ vp9_copy(pbi->common.fc.pre_coef_probs_4x4,
+ pbi->common.fc.coef_probs_4x4);
+ vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_4x4,
+ pbi->common.fc.hybrid_coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_coef_probs_8x8,
pbi->common.fc.coef_probs_8x8);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_8x8,
@@ -1599,10 +1757,10 @@
pbi->common.fc.coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16,
pbi->common.fc.hybrid_coef_probs_16x16);
+ vp9_copy(pbi->common.fc.pre_coef_probs_32x32,
+ pbi->common.fc.coef_probs_32x32);
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);
-#endif
vp9_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob);
vp9_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob);
vp9_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob);
@@ -1612,16 +1770,15 @@
pbi->common.fc.pre_interintra_prob = pbi->common.fc.interintra_prob;
#endif
pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc;
- vp9_zero(pbi->common.fc.coef_counts);
- vp9_zero(pbi->common.fc.hybrid_coef_counts);
+ vp9_zero(pbi->common.fc.coef_counts_4x4);
+ vp9_zero(pbi->common.fc.hybrid_coef_counts_4x4);
vp9_zero(pbi->common.fc.coef_counts_8x8);
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);
+ vp9_zero(pbi->common.fc.coef_counts_32x32);
vp9_zero(pbi->common.fc.ymode_counts);
-#if CONFIG_SUPERBLOCKS
vp9_zero(pbi->common.fc.sb_ymode_counts);
-#endif
vp9_zero(pbi->common.fc.uv_mode_counts);
vp9_zero(pbi->common.fc.bmode_counts);
vp9_zero(pbi->common.fc.i8x8_mode_counts);
@@ -1660,12 +1817,8 @@
vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
- // Resset the macroblock mode info context to the start of the list
- xd->mode_info_context = pc->mi;
- xd->prev_mode_info_context = pc->prev_mi;
-
/* Decode a row of superblocks */
- for (mb_row = 0; mb_row < pc->mb_rows; mb_row += 2) {
+ for (mb_row = 0; mb_row < pc->mb_rows; mb_row += 4) {
decode_sb_row(pbi, pc, mb_row, xd, &residual_bc);
}
corrupt_tokens |= xd->corrupted;
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decodframe.h ('k') | source/libvpx/vp9/decoder/vp9_dequantize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698