int vp9_decode_block_tokens(MACROBLOCKD *xd, int plane, const scan_order *sc, int x, int y, TX_SIZE tx_size, vpx_reader *r, int seg_id) { struct macroblockd_plane *const pd = &xd->plane[plane]; const int16_t *const dequant = pd->seg_dequant[seg_id]; int eob; ENTROPY_CONTEXT *a = pd->above_context + x; ENTROPY_CONTEXT *l = pd->left_context + y; int ctx; int ctx_shift_a = 0; int ctx_shift_l = 0; switch (tx_size) { case TX_4X4: ctx = a[0] != 0; ctx += l[0] != 0; eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size, dequant, ctx, sc->scan, sc->neighbors, r); a[0] = l[0] = (eob > 0); break; case TX_8X8: get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_8X8); ctx = !!*(const uint16_t *)a; ctx += !!*(const uint16_t *)l; eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size, dequant, ctx, sc->scan, sc->neighbors, r); *(uint16_t *)a = ((eob > 0) * 0x0101) >> ctx_shift_a; *(uint16_t *)l = ((eob > 0) * 0x0101) >> ctx_shift_l; break; case TX_16X16: get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_16X16); ctx = !!*(const uint32_t *)a; ctx += !!*(const uint32_t *)l; eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size, dequant, ctx, sc->scan, sc->neighbors, r); *(uint32_t *)a = ((eob > 0) * 0x01010101) >> ctx_shift_a; *(uint32_t *)l = ((eob > 0) * 0x01010101) >> ctx_shift_l; break; case TX_32X32: get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_32X32); // NOTE: casting to uint64_t here is safe because the default memory // alignment is at least 8 bytes and the TX_32X32 is aligned on 8 byte // boundaries. ctx = !!*(const uint64_t *)a; ctx += !!*(const uint64_t *)l; eob = decode_coefs(xd, get_plane_type(plane), pd->dqcoeff, tx_size, dequant, ctx, sc->scan, sc->neighbors, r); *(uint64_t *)a = ((eob > 0) * 0x0101010101010101ULL) >> ctx_shift_a; *(uint64_t *)l = ((eob > 0) * 0x0101010101010101ULL) >> ctx_shift_l; break; default: assert(0 && "Invalid transform size."); eob = 0; break; } return eob; }
int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, int plane, int block, BLOCK_SIZE plane_bsize, int x, int y, TX_SIZE tx_size, vp9_reader *r) { struct macroblockd_plane *const pd = &xd->plane[plane]; const int ctx = get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y); const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block); const int eob = decode_coefs(cm, xd, pd->plane_type, BLOCK_OFFSET(pd->dqcoeff, block), tx_size, pd->dequant, ctx, so->scan, so->neighbors, r); vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y); return eob; }
int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd, int plane, int block, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, vp9_reader *r) { struct macroblockd_plane *const pd = &xd->plane[plane]; const int seg_eob = get_tx_eob(&cm->seg, xd->mi_8x8[0]->mbmi.segment_id, tx_size); int aoff, loff, eob, pt; txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); pt = get_entropy_context(tx_size, pd->above_context + aoff, pd->left_context + loff); eob = decode_coefs(cm, xd, r, block, pd->plane_type, seg_eob, BLOCK_OFFSET(pd->qcoeff, block), tx_size, pd->dequant, pt); set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, aoff, loff); pd->eobs[block] = eob; return eob; }