Remove nz/eob related uncalled functions Change-Id: I12471d18544a9634c28ed139b7211c9af0762927
diff --git a/av1/common/enums.h b/av1/common/enums.h index 0ed9e78..470f4d7 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -243,10 +243,6 @@ #define MAX_TX_DEPTH (TX_SIZES - TX_SIZE_CTX_MIN) -#if CONFIG_CTX1D -#define MAX_HVTX_SIZE (1 << 5) -#endif // CONFIG_CTX1D - #define MAX_TX_SIZE_LOG2 (5 + CONFIG_TX64X64) #define MAX_TX_SIZE (1 << MAX_TX_SIZE_LOG2) #define MIN_TX_SIZE_LOG2 2
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h index ad969a7..8f9510f 100644 --- a/av1/common/txb_common.h +++ b/av1/common/txb_common.h
@@ -553,77 +553,4 @@ void av1_init_lv_map(AV1_COMMON *cm); -#if CONFIG_CTX1D -static INLINE void get_eob_vert(int16_t *eob_ls, const tran_low_t *tcoeff, - int w, int h) { - for (int c = 0; c < w; ++c) { - eob_ls[c] = 0; - for (int r = h - 1; r >= 0; --r) { - int coeff_idx = r * w + c; - if (tcoeff[coeff_idx] != 0) { - eob_ls[c] = r + 1; - break; - } - } - } -} - -static INLINE void get_eob_horiz(int16_t *eob_ls, const tran_low_t *tcoeff, - int w, int h) { - for (int r = 0; r < h; ++r) { - eob_ls[r] = 0; - for (int c = w - 1; c >= 0; --c) { - int coeff_idx = r * w + c; - if (tcoeff[coeff_idx] != 0) { - eob_ls[r] = c + 1; - break; - } - } - } -} - -static INLINE int get_empty_line_ctx(int line_idx, int16_t *eob_ls) { - if (line_idx > 0) { - int prev_eob = eob_ls[line_idx - 1]; - if (prev_eob == 0) { - return 1; - } else if (prev_eob < 3) { - return 2; - } else if (prev_eob < 6) { - return 3; - } else { - return 4; - } - } else { - return 0; - } -} - -#define MAX_POS_CTX 8 -static const int pos_ctx[MAX_HVTX_SIZE] = { - 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, -}; -static INLINE int get_hv_eob_ctx(int line_idx, int pos, int16_t *eob_ls) { - if (line_idx > 0) { - int prev_eob = eob_ls[line_idx - 1]; - int diff = pos + 1 - prev_eob; - int abs_diff = abs(diff); - int ctx_idx = pos_ctx[abs_diff]; - assert(ctx_idx < MAX_POS_CTX); - if (diff < 0) { - ctx_idx += MAX_POS_CTX; - assert(ctx_idx >= MAX_POS_CTX); - assert(ctx_idx < 2 * MAX_POS_CTX); - } - return ctx_idx; - } else { - int ctx_idx = MAX_POS_CTX + MAX_POS_CTX + pos_ctx[pos]; - assert(ctx_idx < HV_EOB_CONTEXTS); - assert(HV_EOB_CONTEXTS == MAX_POS_CTX * 3); - return ctx_idx; - } -} -#endif // CONFIG_CTX1D - #endif // AV1_COMMON_TXB_COMMON_H_
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c index d7732e5..d0134f5 100644 --- a/av1/decoder/decodetxb.c +++ b/av1/decoder/decodetxb.c
@@ -45,216 +45,6 @@ return x - 1; } -static INLINE int read_nz_map(aom_reader *const r, uint8_t *const levels, - const int plane, const int16_t *const scan, - const TX_SIZE tx_size, const TX_TYPE tx_type, - FRAME_CONTEXT *const fc, - FRAME_COUNTS *const counts) { - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int height = tx_size_high[tx_size]; -#if CONFIG_CTX1D - const int width = tx_size_wide[tx_size]; - const int eob_offset = width + height; - const TX_CLASS tx_class = get_tx_class(tx_type); - const int seg_eob = - (tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset; -#else - const int seg_eob = tx_size_2d[tx_size]; -#endif - const PLANE_TYPE plane_type = get_plane_type(plane); - unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] = - (counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL; - int c; - for (c = 0; c < seg_eob; ++c) { - int is_nz; - int coeff_ctx = get_nz_map_ctx(levels, c, scan, bwl, height, tx_type, 1); - int eob_ctx = get_eob_ctx(scan[c], txs_ctx, tx_type); - - if (c < seg_eob - 1) { - is_nz = av1_read_record_bin( - counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2, - ACCT_STR); - } else { - is_nz = 1; - } - - // set non-zero coefficient map. - levels[scan[c]] = is_nz; - - if (c == seg_eob - 1) { - ++c; - break; - } - - if (counts) ++(*nz_map_count)[coeff_ctx][is_nz]; - - if (is_nz) { - int is_eob = av1_read_record_bin( - counts, r, fc->eob_flag_cdf[txs_ctx][plane_type][eob_ctx], 2, - ACCT_STR); - if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob]; - if (is_eob) break; - } - } - return AOMMIN(seg_eob, c + 1); -} - -#if CONFIG_CTX1D -static INLINE int read_nz_map_vert(aom_reader *r, uint8_t *levels, int plane, - const int16_t *scan, const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type, - FRAME_CONTEXT *fc, FRAME_COUNTS *counts) { - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - int eob = 0; -#if !LV_MAP_PROB - aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type]; -#endif - for (int col = 0; col < width; ++col) { - int el_ctx = get_empty_line_ctx(col, eob_ls); -#if LV_MAP_PROB - int empty_line = av1_read_record_bin( - counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2, - ACCT_STR); -#else - int empty_line = aom_read( - r, fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx], ACCT_STR); -#endif - if (counts) - ++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][empty_line]; - if (!empty_line) { - int row; - for (row = 0; row < height; ++row) { - if (row + 1 != height) { - int coeff_idx = row * width + col; - int scan_idx = iscan[coeff_idx]; - int coeff_ctx = - get_nz_map_ctx(levels, scan_idx, scan, bwl, height, tx_type, 1); -#if LV_MAP_PROB - int is_nz = av1_read_record_bin( - counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2, - ACCT_STR); -#else - int is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR); -#endif - if (counts) ++counts->nz_map[txs_ctx][plane_type][coeff_ctx][is_nz]; - levels[coeff_idx] = is_nz; - if (is_nz) { - eob = AOMMAX(eob, iscan[coeff_idx] + 1); - if (row + 1 != height) { - int eob_ctx = get_hv_eob_ctx(col, row, eob_ls); -#if LV_MAP_PROB - int is_eob = av1_read_record_bin( - counts, r, - fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2, - ACCT_STR); -#else - int is_eob = aom_read( - r, fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx], - ACCT_STR); -#endif - if (counts) - ++counts - ->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx][is_eob]; - if (is_eob) break; - } - } - } else { - int coeff_idx = row * width + col; - levels[coeff_idx] = 1; - eob = AOMMAX(eob, iscan[coeff_idx] + 1); - } - } - eob_ls[col] = AOMMIN(height, row + 1); - } else { - eob_ls[col] = 0; - } - } - return eob; -} - -static INLINE int read_nz_map_horiz(aom_reader *r, uint8_t *levels, int plane, - const int16_t *scan, const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type, - FRAME_CONTEXT *fc, FRAME_COUNTS *counts) { - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - int eob = 0; -#if !LV_MAP_PROB - aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type]; -#endif - for (int row = 0; row < height; ++row) { - int el_ctx = get_empty_line_ctx(row, eob_ls); -#if LV_MAP_PROB - int empty_line = av1_read_record_bin( - counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2, - ACCT_STR); -#else - int empty_line = aom_read( - r, fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx], ACCT_STR); -#endif - if (counts) - ++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][empty_line]; - if (!empty_line) { - int col; - for (col = 0; col < width; ++col) { - if (col + 1 != width) { - int coeff_idx = row * width + col; - int scan_idx = iscan[coeff_idx]; - int coeff_ctx = - get_nz_map_ctx(levels, scan_idx, scan, bwl, height, tx_type, 1); -#if LV_MAP_PROB - int is_nz = av1_read_record_bin( - counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2, - ACCT_STR); -#else - int is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR); -#endif - if (counts) ++counts->nz_map[txs_ctx][plane_type][coeff_ctx][is_nz]; - levels[coeff_idx] = is_nz; - if (is_nz) { - eob = AOMMAX(eob, iscan[coeff_idx] + 1); - int eob_ctx = get_hv_eob_ctx(row, col, eob_ls); -#if LV_MAP_PROB - int is_eob = av1_read_record_bin( - counts, r, - fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2, - ACCT_STR); -#else - int is_eob = - aom_read(r, fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx], - ACCT_STR); -#endif - if (counts) - ++counts->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx][is_eob]; - if (is_eob) break; - } - } else { - int coeff_idx = row * width + col; - levels[coeff_idx] = 1; - eob = AOMMAX(eob, iscan[coeff_idx] + 1); - } - } - eob_ls[row] = AOMMIN(width, col + 1); - } else { - eob_ls[row] = 0; - } - } - return eob; -} -#endif - static INLINE int rec_eob_pos(int16_t eob_token, int16_t extra) { int eob = k_eob_group_start[eob_token]; if (eob > 2) {
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index f5ba47c..f9f7533 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -244,126 +244,6 @@ txb_info->dqcoeff[coeff_idx] = qcoeff_to_dqcoeff(qc, dqv, txb_info->shift); } -#if CONFIG_CTX1D -static INLINE void write_nz_map_vert(aom_writer *w, const tran_low_t *tcoeff, - uint16_t eob, int plane, - const int16_t *scan, const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type, - FRAME_CONTEXT *fc) { - (void)eob; - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_vert(eob_ls, tcoeff, width, height); -#if !LV_MAP_PROB - aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type]; -#endif - for (int c = 0; c < width; ++c) { - int16_t veob = eob_ls[c]; - assert(veob <= height); - int el_ctx = get_empty_line_ctx(c, eob_ls); -#if LV_MAP_PROB - aom_write_bin(w, veob == 0, - fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2); -#else - aom_write(w, veob == 0, - fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx]); -#endif - if (veob) { - for (int r = 0; r < veob; ++r) { - if (r + 1 != height) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = tcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(tcoeff, scan_idx, scan, bwl, height, tx_type, 0); -#if LV_MAP_PROB - aom_write_bin(w, is_nz, - fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2); -#else - aom_write(w, is_nz, nz_map[coeff_ctx]); -#endif - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(c, r, eob_ls); -#if LV_MAP_PROB - aom_write_bin( - w, r == veob - 1, - fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2); -#else - aom_write(w, r == veob - 1, - fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx]); -#endif - } - } - } - } - } -} - -static INLINE void write_nz_map_horiz(aom_writer *w, const tran_low_t *tcoeff, - uint16_t eob, int plane, - const int16_t *scan, const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type, - FRAME_CONTEXT *fc) { - (void)scan; - (void)eob; - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_horiz(eob_ls, tcoeff, width, height); -#if !LV_MAP_PROB - aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type]; -#endif - for (int r = 0; r < height; ++r) { - int16_t heob = eob_ls[r]; - int el_ctx = get_empty_line_ctx(r, eob_ls); -#if LV_MAP_PROB - aom_write_bin(w, heob == 0, - fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2); -#else - aom_write(w, heob == 0, - fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx]); -#endif - if (heob) { - for (int c = 0; c < heob; ++c) { - if (c + 1 != width) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = tcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(tcoeff, scan_idx, scan, bwl, height, tx_type, 0); -#if LV_MAP_PROB - aom_write_bin(w, is_nz, - fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2); -#else - aom_write(w, is_nz, nz_map[coeff_ctx]); -#endif - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(r, c, eob_ls); -#if LV_MAP_PROB - aom_write_bin( - w, c == heob - 1, - fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2); -#else - aom_write(w, c == heob - 1, - fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx]); -#endif - } - } - } - } - } -} -#endif - void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, aom_writer *w, int blk_row, int blk_col, int block, int plane, TX_SIZE tx_size, const tran_low_t *tcoeff, @@ -630,122 +510,6 @@ return coeff_base[abs_qc == level]; } -int get_nz_eob_map_cost(const LV_MAP_COEFF_COST *coeff_costs, - const tran_low_t *qcoeff, uint16_t eob, int plane, - const int16_t *scan, TX_SIZE tx_size, TX_TYPE tx_type) { - (void)plane; - TX_SIZE txs_ctx = get_txsize_context(tx_size); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int height = tx_size_high[tx_size]; -#if CONFIG_CTX1D - const TX_CLASS tx_class = get_tx_class(tx_type); - const int width = tx_size_wide[tx_size]; - const int eob_offset = width + height; - const int seg_eob = - (tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset; -#else - const int seg_eob = tx_size_2d[tx_size]; -#endif - int cost = 0; - for (int c = 0; c < eob; ++c) { - tran_low_t v = qcoeff[scan[c]]; - int is_nz = (v != 0); - if (c + 1 != seg_eob) { - int coeff_ctx = get_nz_map_ctx(qcoeff, c, scan, bwl, height, tx_type, 0); - cost += coeff_costs->nz_map_cost[coeff_ctx][is_nz]; - if (is_nz) { - int eob_ctx = get_eob_ctx(scan[c], txs_ctx, tx_type); - cost += coeff_costs->eob_cost[eob_ctx][c == (eob - 1)]; - } - } - } - return cost; -} - -#if CONFIG_CTX1D -static INLINE int get_nz_eob_map_cost_vert(const LV_MAP_COEFF_COST *coeff_costs, - const tran_low_t *qcoeff, - uint16_t eob, int plane, - const int16_t *scan, - const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type) { - (void)tx_size; - (void)scan; - (void)eob; - (void)plane; - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_vert(eob_ls, qcoeff, width, height); - int cost = 0; - for (int c = 0; c < width; ++c) { - int16_t veob = eob_ls[c]; - assert(veob <= height); - int el_ctx = get_empty_line_ctx(c, eob_ls); - cost += coeff_costs->empty_line_cost[tx_class][el_ctx][veob == 0]; - if (veob) { - for (int r = 0; r < veob; ++r) { - if (r + 1 != height) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = qcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(qcoeff, scan_idx, scan, bwl, height, tx_type, 0); - cost += coeff_costs->nz_map_cost[coeff_ctx][is_nz]; - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(c, r, eob_ls); - cost += coeff_costs->hv_eob_cost[tx_class][eob_ctx][r == veob - 1]; - } - } - } - } - } - return cost; -} - -static INLINE int get_nz_eob_map_cost_horiz( - const LV_MAP_COEFF_COST *coeff_costs, const tran_low_t *qcoeff, - uint16_t eob, int plane, const int16_t *scan, const int16_t *iscan, - TX_SIZE tx_size, TX_TYPE tx_type) { - (void)tx_size; - (void)scan; - (void)eob; - (void)plane; - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_horiz(eob_ls, qcoeff, width, height); - int cost = 0; - for (int r = 0; r < height; ++r) { - int16_t heob = eob_ls[r]; - assert(heob <= width); - int el_ctx = get_empty_line_ctx(r, eob_ls); - cost += coeff_costs->empty_line_cost[tx_class][el_ctx][heob == 0]; - if (heob) { - for (int c = 0; c < heob; ++c) { - if (c + 1 != width) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = qcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(qcoeff, scan_idx, scan, bwl, height, tx_type, 0); - cost += coeff_costs->nz_map_cost[coeff_ctx][is_nz]; - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(r, c, eob_ls); - cost += coeff_costs->hv_eob_cost[tx_class][eob_ctx][c == heob - 1]; - } - } - } - } - } - return cost; -} -#endif - int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, int blk_row, int blk_col, int block, TX_SIZE tx_size, TXB_CTX *txb_ctx) { @@ -2101,149 +1865,6 @@ av1_set_contexts(xd, pd, plane, tx_size, cul_level, blk_col, blk_row); } -static INLINE void av1_update_nz_eob_counts(FRAME_CONTEXT *fc, - FRAME_COUNTS *counts, uint16_t eob, - const tran_low_t *tcoeff, int plane, - TX_SIZE tx_size, TX_TYPE tx_type, - const int16_t *scan) { - const PLANE_TYPE plane_type = get_plane_type(plane); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int height = tx_size_high[tx_size]; - TX_SIZE txsize_ctx = get_txsize_context(tx_size); -#if CONFIG_CTX1D - const int width = tx_size_wide[tx_size]; - const int eob_offset = width + height; - const TX_CLASS tx_class = get_tx_class(tx_type); - const int seg_eob = - (tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset; -#else - const int seg_eob = tx_size_2d[tx_size]; -#endif - unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] = - &counts->nz_map[txsize_ctx][plane_type]; - for (int c = 0; c < eob; ++c) { - tran_low_t v = tcoeff[scan[c]]; - int is_nz = (v != 0); - int coeff_ctx = get_nz_map_ctx(tcoeff, c, scan, bwl, height, tx_type, 0); - int eob_ctx = get_eob_ctx(scan[c], txsize_ctx, tx_type); - - if (c == seg_eob - 1) break; - - ++(*nz_map_count)[coeff_ctx][is_nz]; - update_bin(fc->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz, 2); - - if (is_nz) { - ++counts->eob_flag[txsize_ctx][plane_type][eob_ctx][c == (eob - 1)]; - update_bin(fc->eob_flag_cdf[txsize_ctx][plane_type][eob_ctx], - c == (eob - 1), 2); - } - } -} - -#if CONFIG_CTX1D -static INLINE void av1_update_nz_eob_counts_vert( - FRAME_CONTEXT *fc, FRAME_COUNTS *counts, uint16_t eob, - const tran_low_t *tcoeff, int plane, TX_SIZE tx_size, TX_TYPE tx_type, - const int16_t *scan, const int16_t *iscan) { - (void)eob; - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_vert(eob_ls, tcoeff, width, height); - unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] = - &counts->nz_map[txs_ctx][plane_type]; - for (int c = 0; c < width; ++c) { - int16_t veob = eob_ls[c]; - assert(veob <= height); - int el_ctx = get_empty_line_ctx(c, eob_ls); - ++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][veob == 0]; -#if LV_MAP_PROB - update_bin(fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], - veob == 0, 2); -#endif - if (veob) { - for (int r = 0; r < veob; ++r) { - if (r + 1 != height) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = tcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(tcoeff, scan_idx, scan, bwl, height, tx_type, 0); - ++(*nz_map_count)[coeff_ctx][is_nz]; -#if LV_MAP_PROB - update_bin(fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], is_nz, 2); -#endif - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(c, r, eob_ls); - ++counts->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx] - [r == veob - 1]; -#if LV_MAP_PROB - update_bin(fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], - r == veob - 1, 2); -#endif - } - } - } - } - } -} - -static INLINE void av1_update_nz_eob_counts_horiz( - FRAME_CONTEXT *fc, FRAME_COUNTS *counts, uint16_t eob, - const tran_low_t *tcoeff, int plane, TX_SIZE tx_size, TX_TYPE tx_type, - const int16_t *scan, const int16_t *iscan) { - (void)eob; - (void)scan; - const TX_SIZE txs_ctx = get_txsize_context(tx_size); - const PLANE_TYPE plane_type = get_plane_type(plane); - const TX_CLASS tx_class = get_tx_class(tx_type); - const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; - const int width = tx_size_wide[tx_size]; - const int height = tx_size_high[tx_size]; - int16_t eob_ls[MAX_HVTX_SIZE]; - get_eob_horiz(eob_ls, tcoeff, width, height); - unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] = - &counts->nz_map[txs_ctx][plane_type]; - for (int r = 0; r < height; ++r) { - int16_t heob = eob_ls[r]; - int el_ctx = get_empty_line_ctx(r, eob_ls); - ++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][heob == 0]; -#if LV_MAP_PROB - update_bin(fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], - heob == 0, 2); -#endif - if (heob) { - for (int c = 0; c < heob; ++c) { - if (c + 1 != width) { - int coeff_idx = r * width + c; - int scan_idx = iscan[coeff_idx]; - int is_nz = tcoeff[coeff_idx] != 0; - int coeff_ctx = - get_nz_map_ctx(tcoeff, scan_idx, scan, bwl, height, tx_type, 0); - ++(*nz_map_count)[coeff_ctx][is_nz]; -#if LV_MAP_PROB - update_bin(fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], is_nz, 2); -#endif - if (is_nz) { - int eob_ctx = get_hv_eob_ctx(r, c, eob_ls); - ++counts->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx] - [c == heob - 1]; -#if LV_MAP_PROB - update_bin(fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], - c == heob - 1, 2); -#endif - } - } - } - } - } -} -#endif // CONFIG_CTX1D - void av1_update_and_record_txb_context(int plane, int block, int blk_row, int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {