diff options
Diffstat (limited to 'vp9/decoder/vp9_decodframe.c')
-rw-r--r-- | vp9/decoder/vp9_decodframe.c | 319 |
1 files changed, 129 insertions, 190 deletions
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 3ee0f6174..3e4e5aa6b 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -220,45 +220,19 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *mb) { } } -#if CONFIG_CODE_NONZEROCOUNT -static void propagate_nzcs(VP9_COMMON *cm, MACROBLOCKD *xd) { - MODE_INFO *m = xd->mode_info_context; - BLOCK_SIZE_TYPE sb_type = m->mbmi.sb_type; - const int mis = cm->mode_info_stride; - int n; - if (sb_type == BLOCK_SIZE_SB64X64) { - for (n = 0; n < 16; ++n) { - int i = n >> 2; - int j = n & 3; - if (i == 0 && j == 0) continue; - vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs, - 384 * sizeof(m->mbmi.nzcs[0])); - } - } else if (sb_type == BLOCK_SIZE_SB32X32) { - for (n = 0; n < 4; ++n) { - int i = n >> 1; - int j = n & 1; - if (i == 0 && j == 0) continue; - vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs, - 384 * sizeof(m->mbmi.nzcs[0])); - } - } -} -#endif - static void decode_16x16(MACROBLOCKD *xd) { const TX_TYPE tx_type = get_tx_type_16x16(xd, 0); vp9_dequant_iht_add_16x16_c(tx_type, xd->plane[0].qcoeff, - xd->block[0].dequant, xd->dst.y_buffer, - xd->dst.y_stride, xd->plane[0].eobs[0]); + xd->block[0].dequant, xd->plane[0].dst.buf, + xd->plane[0].dst.stride, xd->plane[0].eobs[0]); vp9_dequant_idct_add_8x8(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs[0]); vp9_dequant_idct_add_8x8(xd->plane[2].qcoeff, xd->block[20].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs[0]); } @@ -275,7 +249,7 @@ static void decode_8x8(MACROBLOCKD *xd) { int16_t *q = BLOCK_OFFSET(xd->plane[0].qcoeff, idx, 16); int16_t *dq = xd->block[0].dequant; uint8_t *dst = *(xd->block[ib].base_dst) + xd->block[ib].dst; - int stride = xd->dst.y_stride; + int stride = xd->plane[0].dst.stride; if (mode == I8X8_PRED) { BLOCKD *b = &xd->block[ib]; int i8x8mode = b->bmi.as_mode.first; @@ -287,8 +261,8 @@ static void decode_8x8(MACROBLOCKD *xd) { } } else { vp9_dequant_idct_add_y_block_8x8(xd->plane[0].qcoeff, - xd->block[0].dequant, xd->dst.y_buffer, - xd->dst.y_stride, xd); + xd->block[0].dequant, xd->plane[0].dst.buf, + xd->plane[0].dst.stride, xd); } // chroma @@ -315,16 +289,16 @@ static void decode_8x8(MACROBLOCKD *xd) { } } else if (mode == SPLITMV) { xd->itxm_add_uv_block(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, xd->plane[1].eobs); + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs); xd->itxm_add_uv_block(xd->plane[2].qcoeff, xd->block[16].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, xd->plane[2].eobs); + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs); } else { vp9_dequant_idct_add_8x8(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs[0]); vp9_dequant_idct_add_8x8(xd->plane[2].qcoeff, xd->block[16].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs[0]); } } @@ -396,27 +370,27 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, vp9_reader *r) { #endif vp9_build_intra_predictors_sbuv_s(xd, BLOCK_SIZE_MB16X16); xd->itxm_add_uv_block(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, xd->plane[1].eobs); + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs); xd->itxm_add_uv_block(xd->plane[2].qcoeff, xd->block[16].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, xd->plane[2].eobs); + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs); } else if (mode == SPLITMV || get_tx_type_4x4(xd, 0) == DCT_DCT) { xd->itxm_add_y_block(xd->plane[0].qcoeff, xd->block[0].dequant, - xd->dst.y_buffer, xd->dst.y_stride, xd); + xd->plane[0].dst.buf, xd->plane[0].dst.stride, xd); xd->itxm_add_uv_block(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, xd->plane[1].eobs); + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs); xd->itxm_add_uv_block(xd->plane[2].qcoeff, xd->block[16].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, xd->plane[2].eobs); + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs); } else { for (i = 0; i < 16; i++) { tx_type = get_tx_type_4x4(xd, i); dequant_add_y(xd, tx_type, i); } xd->itxm_add_uv_block(xd->plane[1].qcoeff, xd->block[16].dequant, - xd->dst.u_buffer, xd->dst.uv_stride, + xd->plane[1].dst.buf, xd->plane[1].dst.stride, xd->plane[1].eobs); xd->itxm_add_uv_block(xd->plane[2].qcoeff, xd->block[16].dequant, - xd->dst.v_buffer, xd->dst.uv_stride, + xd->plane[2].dst.buf, xd->plane[1].dst.stride, xd->plane[2].eobs); } } @@ -430,10 +404,11 @@ static INLINE void decode_sby_32x32(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < y_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> bwl; - const int y_offset = (y_idx * 32) * mb->dst.y_stride + (x_idx * 32); + const int y_offset = (y_idx * 32) * mb->plane[0].dst.stride + (x_idx * 32); vp9_dequant_idct_add_32x32(BLOCK_OFFSET(mb->plane[0].qcoeff, n, 1024), mb->block[0].dequant , - mb->dst.y_buffer + y_offset, mb->dst.y_stride, + mb->plane[0].dst.buf + y_offset, + mb->plane[0].dst.stride, mb->plane[0].eobs[n * 64]); } } @@ -446,15 +421,18 @@ static INLINE void decode_sbuv_32x32(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < uv_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> (bwl - 1); - const int uv_offset = (y_idx * 32) * mb->dst.uv_stride + (x_idx * 32); + const int uv_offset = (y_idx * 32) * mb->plane[1].dst.stride + + (x_idx * 32); vp9_dequant_idct_add_32x32(BLOCK_OFFSET(mb->plane[1].qcoeff, n, 1024), mb->block[16].dequant, - mb->dst.u_buffer + uv_offset, - mb->dst.uv_stride, mb->plane[1].eobs[n * 64]); + mb->plane[1].dst.buf + uv_offset, + mb->plane[1].dst.stride, + mb->plane[1].eobs[n * 64]); vp9_dequant_idct_add_32x32(BLOCK_OFFSET(mb->plane[2].qcoeff, n, 1024), mb->block[20].dequant, - mb->dst.v_buffer + uv_offset, - mb->dst.uv_stride, mb->plane[2].eobs[n * 64]); + mb->plane[2].dst.buf + uv_offset, + mb->plane[1].dst.stride, + mb->plane[2].eobs[n * 64]); } } @@ -467,14 +445,14 @@ static INLINE void decode_sby_16x16(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < y_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> bwl; - const int y_offset = (y_idx * 16) * mb->dst.y_stride + (x_idx * 16); + const int y_offset = (y_idx * 16) * mb->plane[0].dst.stride + (x_idx * 16); const TX_TYPE tx_type = get_tx_type_16x16(mb, (y_idx * (4 * bw) + x_idx) * 4); vp9_dequant_iht_add_16x16_c(tx_type, BLOCK_OFFSET(mb->plane[0].qcoeff, n, 256), mb->block[0].dequant, - mb->dst.y_buffer + y_offset, - mb->dst.y_stride, + mb->plane[0].dst.buf + y_offset, + mb->plane[0].dst.stride, mb->plane[0].eobs[n * 16]); } } @@ -490,14 +468,16 @@ static INLINE void decode_sbuv_16x16(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < uv_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> (bwl - 1); - const int uv_offset = (y_idx * 16) * mb->dst.uv_stride + (x_idx * 16); + const int uv_offset = (y_idx * 16) * mb->plane[1].dst.stride + (x_idx * 16); vp9_dequant_idct_add_16x16(BLOCK_OFFSET(mb->plane[1].qcoeff, n, 256), mb->block[16].dequant, - mb->dst.u_buffer + uv_offset, mb->dst.uv_stride, + mb->plane[1].dst.buf + uv_offset, + mb->plane[1].dst.stride, mb->plane[1].eobs[n * 16]); vp9_dequant_idct_add_16x16(BLOCK_OFFSET(mb->plane[2].qcoeff, n, 256), mb->block[20].dequant, - mb->dst.v_buffer + uv_offset, mb->dst.uv_stride, + mb->plane[2].dst.buf + uv_offset, + mb->plane[1].dst.stride, mb->plane[2].eobs[n * 16]); } } @@ -512,14 +492,15 @@ static INLINE void decode_sby_8x8(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < y_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> bwl; - const int y_offset = (y_idx * 8) * xd->dst.y_stride + (x_idx * 8); + const int y_offset = (y_idx * 8) * xd->plane[0].dst.stride + (x_idx * 8); const TX_TYPE tx_type = get_tx_type_8x8(xd, (y_idx * (2 * bw) + x_idx) * 2); vp9_dequant_iht_add_8x8_c(tx_type, BLOCK_OFFSET(xd->plane[0].qcoeff, n, 64), xd->block[0].dequant, - xd->dst.y_buffer + y_offset, xd->dst.y_stride, + xd->plane[0].dst.buf + y_offset, + xd->plane[0].dst.stride, xd->plane[0].eobs[n * 4]); } } @@ -534,14 +515,16 @@ static INLINE void decode_sbuv_8x8(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < uv_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> (bwl - 1); - const int uv_offset = (y_idx * 8) * xd->dst.uv_stride + (x_idx * 8); + const int uv_offset = (y_idx * 8) * xd->plane[1].dst.stride + (x_idx * 8); vp9_dequant_idct_add_8x8(BLOCK_OFFSET(xd->plane[1].qcoeff, n, 64), xd->block[16].dequant, - xd->dst.u_buffer + uv_offset, xd->dst.uv_stride, + xd->plane[1].dst.buf + uv_offset, + xd->plane[1].dst.stride, xd->plane[1].eobs[n * 4]); vp9_dequant_idct_add_8x8(BLOCK_OFFSET(xd->plane[2].qcoeff, n, 64), xd->block[20].dequant, - xd->dst.v_buffer + uv_offset, xd->dst.uv_stride, + xd->plane[2].dst.buf + uv_offset, + xd->plane[1].dst.stride, xd->plane[2].eobs[n * 4]); } } @@ -555,18 +538,19 @@ static INLINE void decode_sby_4x4(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < y_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> bwl; - const int y_offset = (y_idx * 4) * xd->dst.y_stride + (x_idx * 4); + const int y_offset = (y_idx * 4) * xd->plane[0].dst.stride + (x_idx * 4); const TX_TYPE tx_type = get_tx_type_4x4(xd, n); if (tx_type == DCT_DCT) { xd->itxm_add(BLOCK_OFFSET(xd->plane[0].qcoeff, n, 16), xd->block[0].dequant, - xd->dst.y_buffer + y_offset, xd->dst.y_stride, + xd->plane[0].dst.buf + y_offset, xd->plane[0].dst.stride, xd->plane[0].eobs[n]); } else { vp9_dequant_iht_add_c(tx_type, BLOCK_OFFSET(xd->plane[0].qcoeff, n, 16), - xd->block[0].dequant, xd->dst.y_buffer + y_offset, - xd->dst.y_stride, xd->plane[0].eobs[n]); + xd->block[0].dequant, + xd->plane[0].dst.buf + y_offset, + xd->plane[0].dst.stride, xd->plane[0].eobs[n]); } } } @@ -580,13 +564,15 @@ static INLINE void decode_sbuv_4x4(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { for (n = 0; n < uv_count; n++) { const int x_idx = n & (bw - 1); const int y_idx = n >> (bwl - 1); - const int uv_offset = (y_idx * 4) * xd->dst.uv_stride + (x_idx * 4); + const int uv_offset = (y_idx * 4) * xd->plane[1].dst.stride + (x_idx * 4); xd->itxm_add(BLOCK_OFFSET(xd->plane[1].qcoeff, n, 16), xd->block[16].dequant, - xd->dst.u_buffer + uv_offset, xd->dst.uv_stride, xd->plane[1].eobs[n]); + xd->plane[1].dst.buf + uv_offset, xd->plane[1].dst.stride, + xd->plane[1].eobs[n]); xd->itxm_add(BLOCK_OFFSET(xd->plane[2].qcoeff, n, 16), xd->block[20].dequant, - xd->dst.v_buffer + uv_offset, xd->dst.uv_stride, xd->plane[2].eobs[n]); + xd->plane[2].dst.buf + uv_offset, xd->plane[1].dst.stride, + xd->plane[2].eobs[n]); } } @@ -632,9 +618,6 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col, if (mi->mbmi.mb_skip_coeff) { vp9_reset_sb_tokens_context(xd, bsize); -#if CONFIG_CODE_NONZEROCOUNT - vpx_memset(mi->mbmi.nzcs, 0, 384 * sizeof(mi->mbmi.nzcs[0])); -#endif } else { // re-initialize macroblock dequantizer before detokenization if (xd->segmentation_enabled) @@ -669,10 +652,6 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col, } } } - -#if CONFIG_CODE_NONZEROCOUNT - propagate_nzcs(&pbi->common, xd); -#endif } // TODO(jingning): Need to merge SB and MB decoding. The MB decoding currently @@ -705,7 +684,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd, xd->mode_info_context->mbmi.mode, tx_size, xd->mode_info_context->mbmi.interp_filter); #endif - vp9_build_inter_predictors_mb(xd, mb_row, mb_col); + vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16); } if (xd->mode_info_context->mbmi.mb_skip_coeff) { @@ -715,7 +694,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd, if (xd->segmentation_enabled) mb_init_dequantizer(pbi, xd); - if (!bool_error(r)) { + if (!vp9_reader_has_error(r)) { #if CONFIG_NEWBINTRAMODES if (mode != I4X4_PRED) #endif @@ -727,7 +706,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd, mode != I4X4_PRED && mode != SPLITMV && mode != I8X8_PRED && - !bool_error(r)) { + !vp9_reader_has_error(r)) { xd->mode_info_context->mbmi.mb_skip_coeff = 1; } else { #if 0 // def DEC_DEBUG @@ -758,21 +737,21 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd, 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("%3d ", xd->plane[0].dst.buf[i * xd->plane[0].dst.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("%3d ", xd->plane[1].dst.buf[i * xd->plane[1].dst.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("%3d ", xd->plane[2].dst.buf[i * xd->plane[1].dst.stride + j]); printf("\n"); } fflush(stdout); @@ -820,9 +799,9 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, set_mb_row(cm, xd, mb_row, bh); set_mb_col(cm, xd, mb_col, bw); - xd->dst.y_buffer = dst_fb->y_buffer + recon_yoffset; - xd->dst.u_buffer = dst_fb->u_buffer + recon_uvoffset; - xd->dst.v_buffer = dst_fb->v_buffer + recon_uvoffset; + xd->plane[0].dst.buf = dst_fb->y_buffer + recon_yoffset; + xd->plane[1].dst.buf = dst_fb->u_buffer + recon_uvoffset; + xd->plane[2].dst.buf = dst_fb->v_buffer + recon_uvoffset; } static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) { @@ -836,8 +815,8 @@ static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) { const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[fb_idx]; xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame - 1]; xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame - 1]; - setup_pred_block(&xd->pre, cfg, mb_row, mb_col, - &xd->scale_factor[0], &xd->scale_factor_uv[0]); + setup_pre_planes(xd, cfg, NULL, mb_row, mb_col, + xd->scale_factor, xd->scale_factor_uv); xd->corrupted |= cfg->corrupted; if (mbmi->second_ref_frame > INTRA_FRAME) { @@ -846,8 +825,8 @@ static void set_refs(VP9D_COMP *pbi, int mb_row, int mb_col) { const YV12_BUFFER_CONFIG *second_cfg = &cm->yv12_fb[second_fb_idx]; xd->scale_factor[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1]; xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1]; - setup_pred_block(&xd->second_pre, second_cfg, mb_row, mb_col, - &xd->scale_factor[1], &xd->scale_factor_uv[1]); + setup_pre_planes(xd, NULL, second_cfg, mb_row, mb_col, + xd->scale_factor, xd->scale_factor_uv); xd->corrupted |= second_cfg->corrupted; } } @@ -867,7 +846,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mb_row, int mb_col, else decode_mb(pbi, xd, mb_row, mb_col, r); - xd->corrupted |= bool_error(r); + xd->corrupted |= vp9_reader_has_error(r); } static void decode_modes_sb(VP9D_COMP *pbi, int mb_row, int mb_col, @@ -958,7 +937,7 @@ static void setup_token_decoder(VP9D_COMP *pbi, "Truncated packet or corrupt partition " "%d length", 1); - if (vp9_start_decode(r, data, partition_size)) + if (vp9_reader_init(r, data, partition_size)) vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, "Failed to allocate bool decoder %d", 1); } @@ -983,45 +962,35 @@ static void init_frame(VP9D_COMP *pbi) { xd->corrupted = 0; } -#if CONFIG_CODE_NONZEROCOUNT -static void read_nzc_probs_common(VP9_COMMON *cm, - vp9_reader *rd, +#if CONFIG_CODE_ZEROGROUP +static void read_zpc_probs_common(VP9_COMMON *cm, + vp9_reader* bc, TX_SIZE tx_size) { - int c, r, b, t; - int tokens, nodes; - vp9_prob *nzc_probs; - vp9_prob upd; - - if (!get_nzc_used(tx_size)) return; - if (!vp9_read_bit(rd)) return; + int r, b, p, n; + vp9_zpc_probs *zpc_probs; + vp9_prob upd = ZPC_UPDATE_PROB; + if (!get_zpc_used(tx_size)) return; + if (!vp9_read_bit(bc)) return; if (tx_size == TX_32X32) { - tokens = NZC32X32_TOKENS; - nzc_probs = cm->fc.nzc_probs_32x32[0][0][0]; - upd = NZC_UPDATE_PROB_32X32; + zpc_probs = &cm->fc.zpc_probs_32x32; } else if (tx_size == TX_16X16) { - tokens = NZC16X16_TOKENS; - nzc_probs = cm->fc.nzc_probs_16x16[0][0][0]; - upd = NZC_UPDATE_PROB_16X16; + zpc_probs = &cm->fc.zpc_probs_16x16; } else if (tx_size == TX_8X8) { - tokens = NZC8X8_TOKENS; - nzc_probs = cm->fc.nzc_probs_8x8[0][0][0]; - upd = NZC_UPDATE_PROB_8X8; + zpc_probs = &cm->fc.zpc_probs_8x8; } else { - tokens = NZC4X4_TOKENS; - nzc_probs = cm->fc.nzc_probs_4x4[0][0][0]; - upd = NZC_UPDATE_PROB_4X4; + zpc_probs = &cm->fc.zpc_probs_4x4; } - nodes = tokens - 1; - for (c = 0; c < MAX_NZC_CONTEXTS; ++c) { - for (r = 0; r < REF_TYPES; ++r) { - for (b = 0; b < BLOCK_TYPES; ++b) { - int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b; - int offset_nodes = offset * nodes; - for (t = 0; t < nodes; ++t) { - vp9_prob *p = &nzc_probs[offset_nodes + t]; - if (vp9_read(rd, upd)) { - *p = read_prob_diff_update(rd, *p); + for (r = 0; r < REF_TYPES; ++r) { + for (b = 0; b < ZPC_BANDS; ++b) { + for (p = 0; p < ZPC_PTOKS; ++p) { + for (n = 0; n < ZPC_NODES; ++n) { + vp9_prob *q = &(*zpc_probs)[r][b][p][n]; +#if USE_ZPC_EXTRA == 0 + if (n == 1) continue; +#endif + if (vp9_read(bc, upd)) { + *q = read_prob_diff_update(bc, *q); } } } @@ -1029,41 +998,17 @@ static void read_nzc_probs_common(VP9_COMMON *cm, } } -static void read_nzc_pcat_probs(VP9_COMMON *cm, vp9_reader *r) { - int c, t, b; - vp9_prob upd = NZC_UPDATE_PROB_PCAT; - if (!(get_nzc_used(TX_4X4) || get_nzc_used(TX_8X8) || - get_nzc_used(TX_16X16) || get_nzc_used(TX_32X32))) - return; - if (!vp9_read_bit(r)) { - return; - } - for (c = 0; c < MAX_NZC_CONTEXTS; ++c) { - for (t = 0; t < NZC_TOKENS_EXTRA; ++t) { - int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA]; - for (b = 0; b < bits; ++b) { - vp9_prob *p = &cm->fc.nzc_pcat_probs[c][t][b]; - if (vp9_read(r, upd)) { - *p = read_prob_diff_update(r, *p); - } - } - } - } -} - -static void read_nzc_probs(VP9_COMMON *cm, vp9_reader *r) { - read_nzc_probs_common(cm, r, TX_4X4); +static void read_zpc_probs(VP9_COMMON *cm, + vp9_reader* bc) { + read_zpc_probs_common(cm, bc, TX_4X4); if (cm->txfm_mode != ONLY_4X4) - read_nzc_probs_common(cm, r, TX_8X8); + read_zpc_probs_common(cm, bc, TX_8X8); if (cm->txfm_mode > ALLOW_8X8) - read_nzc_probs_common(cm, r, TX_16X16); + read_zpc_probs_common(cm, bc, TX_16X16); if (cm->txfm_mode > ALLOW_16X16) - read_nzc_probs_common(cm, r, TX_32X32); -#ifdef NZC_PCAT_UPDATE - read_nzc_pcat_probs(cm, r); -#endif + read_zpc_probs_common(cm, bc, TX_32X32); } -#endif // CONFIG_CODE_NONZEROCOUNT +#endif // CONFIG_CODE_ZEROGROUP static void read_coef_probs_common(VP9D_COMP *pbi, vp9_reader *r, @@ -1082,11 +1027,7 @@ static void read_coef_probs_common(VP9D_COMP *pbi, for (j = 0; j < REF_TYPES; j++) { for (k = 0; k < COEF_BANDS; k++) { for (l = 0; l < PREV_COEF_CONTEXTS; l++) { -#if CONFIG_CODE_NONZEROCOUNT - const int mstart = get_nzc_used(tx_size); -#else const int mstart = 0; -#endif if (l >= 3 && k == 0) continue; @@ -1381,18 +1322,16 @@ static void update_frame_context(VP9D_COMP *pbi) { vp9_zero(fc->interintra_counts); #endif -#if CONFIG_CODE_NONZEROCOUNT - vp9_copy(fc->pre_nzc_probs_4x4, fc->nzc_probs_4x4); - vp9_copy(fc->pre_nzc_probs_8x8, fc->nzc_probs_8x8); - vp9_copy(fc->pre_nzc_probs_16x16, fc->nzc_probs_16x16); - vp9_copy(fc->pre_nzc_probs_32x32, fc->nzc_probs_32x32); - vp9_copy(fc->pre_nzc_pcat_probs, fc->nzc_pcat_probs); - - vp9_zero(fc->nzc_counts_4x4); - vp9_zero(fc->nzc_counts_8x8); - vp9_zero(fc->nzc_counts_16x16); - vp9_zero(fc->nzc_counts_32x32); - vp9_zero(fc->nzc_pcat_counts); +#if CONFIG_CODE_ZEROGROUP + vp9_copy(fc->pre_zpc_probs_4x4, fc->zpc_probs_4x4); + vp9_copy(fc->pre_zpc_probs_8x8, fc->zpc_probs_8x8); + vp9_copy(fc->pre_zpc_probs_16x16, fc->zpc_probs_16x16); + vp9_copy(fc->pre_zpc_probs_32x32, fc->zpc_probs_32x32); + + vp9_zero(fc->zpc_counts_4x4); + vp9_zero(fc->zpc_counts_8x8); + vp9_zero(fc->zpc_counts_16x16); + vp9_zero(fc->zpc_counts_32x32); #endif } @@ -1536,7 +1475,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { pc->width, pc->height, VP9BORDERINPIXELS); - if (vp9_start_decode(&header_bc, data, first_partition_size)) + if (vp9_reader_init(&header_bc, data, first_partition_size)) vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, "Failed to allocate bool decoder 0"); @@ -1544,17 +1483,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { pc->clamp_type = (CLAMP_TYPE)vp9_read_bit(&header_bc); pc->error_resilient_mode = vp9_read_bit(&header_bc); - setup_segmentation(pc, xd, &header_bc); - - setup_pred_probs(pc, &header_bc); - xd->lossless = vp9_read_bit(&header_bc); - pc->txfm_mode = xd->lossless ? ONLY_4X4 : read_txfm_mode(&header_bc); - if (pc->txfm_mode == TX_MODE_SELECT) { - pc->prob_tx[0] = vp9_read_prob(&header_bc); - pc->prob_tx[1] = vp9_read_prob(&header_bc); - pc->prob_tx[2] = vp9_read_prob(&header_bc); - } setup_loopfilter(pc, xd, &header_bc); @@ -1620,6 +1549,17 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { vpx_memcpy(&pc->fc, &pc->frame_contexts[pc->frame_context_idx], sizeof(pc->fc)); + setup_segmentation(pc, xd, &header_bc); + + setup_pred_probs(pc, &header_bc); + + pc->txfm_mode = xd->lossless ? ONLY_4X4 : read_txfm_mode(&header_bc); + if (pc->txfm_mode == TX_MODE_SELECT) { + pc->prob_tx[0] = vp9_read_prob(&header_bc); + pc->prob_tx[1] = vp9_read_prob(&header_bc); + pc->prob_tx[2] = vp9_read_prob(&header_bc); + } + // Read inter mode probability context updates if (pc->frame_type != KEY_FRAME) { int i, j; @@ -1647,15 +1587,14 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { update_frame_context(pbi); read_coef_probs(pbi, &header_bc); -#if CONFIG_CODE_NONZEROCOUNT - read_nzc_probs(&pbi->common, &header_bc); +#if CONFIG_CODE_ZEROGROUP + read_zpc_probs(&pbi->common, &header_bc); #endif // Initialize xd pointers. Any reference should do for xd->pre, so use 0. - vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->active_ref_idx[0]], - sizeof(YV12_BUFFER_CONFIG)); - vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], - sizeof(YV12_BUFFER_CONFIG)); + setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL, + 0, 0, NULL, NULL); + setup_dst_planes(xd, &pc->yv12_fb[pc->new_fb_idx], 0, 0); // Create the segmentation map structure and set to 0 if (!pc->last_frame_seg_map) @@ -1687,7 +1626,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { // Collect information about decoder corruption. // 1. Check first boolean decoder for errors. // 2. Check the macroblock information - pc->yv12_fb[pc->new_fb_idx].corrupted = bool_error(&header_bc) | + pc->yv12_fb[pc->new_fb_idx].corrupted = vp9_reader_has_error(&header_bc) | corrupt_tokens; if (!pbi->decoded_key_frame) { @@ -1700,8 +1639,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { vp9_adapt_coef_probs(pc); -#if CONFIG_CODE_NONZEROCOUNT - vp9_adapt_nzc_probs(pc); +#if CONFIG_CODE_ZEROGROUP + vp9_adapt_zpc_probs(pc); #endif } |