1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2021, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_TXB_RDOPT_UTILS_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_TXB_RDOPT_UTILS_H_
14*77c1e3ccSAndroid Build Coastguard Worker
15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encodetxb.h"
16*77c1e3ccSAndroid Build Coastguard Worker
17*77c1e3ccSAndroid Build Coastguard Worker static const int golomb_bits_cost[32] = {
18*77c1e3ccSAndroid Build Coastguard Worker 0, 512, 512 * 3, 512 * 3, 512 * 5, 512 * 5, 512 * 5, 512 * 5,
19*77c1e3ccSAndroid Build Coastguard Worker 512 * 7, 512 * 7, 512 * 7, 512 * 7, 512 * 7, 512 * 7, 512 * 7, 512 * 7,
20*77c1e3ccSAndroid Build Coastguard Worker 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9,
21*77c1e3ccSAndroid Build Coastguard Worker 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9, 512 * 9
22*77c1e3ccSAndroid Build Coastguard Worker };
23*77c1e3ccSAndroid Build Coastguard Worker
24*77c1e3ccSAndroid Build Coastguard Worker static const int golomb_cost_diff[32] = {
25*77c1e3ccSAndroid Build Coastguard Worker 0, 512, 512 * 2, 0, 512 * 2, 0, 0, 0, 512 * 2, 0, 0, 0, 0, 0, 0, 0,
26*77c1e3ccSAndroid Build Coastguard Worker 512 * 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
27*77c1e3ccSAndroid Build Coastguard Worker };
28*77c1e3ccSAndroid Build Coastguard Worker
29*77c1e3ccSAndroid Build Coastguard Worker // Look up table of individual cost of coefficient by its quantization level.
30*77c1e3ccSAndroid Build Coastguard Worker // determined based on Laplacian distribution conditioned on estimated context
31*77c1e3ccSAndroid Build Coastguard Worker static const int costLUT[15] = { -1143, 53, 545, 825, 1031,
32*77c1e3ccSAndroid Build Coastguard Worker 1209, 1393, 1577, 1763, 1947,
33*77c1e3ccSAndroid Build Coastguard Worker 2132, 2317, 2501, 2686, 2871 };
34*77c1e3ccSAndroid Build Coastguard Worker
35*77c1e3ccSAndroid Build Coastguard Worker static const int const_term = (1 << AV1_PROB_COST_SHIFT);
36*77c1e3ccSAndroid Build Coastguard Worker
37*77c1e3ccSAndroid Build Coastguard Worker static const int loge_par = ((14427 << AV1_PROB_COST_SHIFT) + 5000) / 10000;
38*77c1e3ccSAndroid Build Coastguard Worker
get_dqv(const int16_t * dequant,int coeff_idx,const qm_val_t * iqmatrix)39*77c1e3ccSAndroid Build Coastguard Worker static inline int get_dqv(const int16_t *dequant, int coeff_idx,
40*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t *iqmatrix) {
41*77c1e3ccSAndroid Build Coastguard Worker int dqv = dequant[!!coeff_idx];
42*77c1e3ccSAndroid Build Coastguard Worker if (iqmatrix != NULL)
43*77c1e3ccSAndroid Build Coastguard Worker dqv =
44*77c1e3ccSAndroid Build Coastguard Worker ((iqmatrix[coeff_idx] * dqv) + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
45*77c1e3ccSAndroid Build Coastguard Worker return dqv;
46*77c1e3ccSAndroid Build Coastguard Worker }
47*77c1e3ccSAndroid Build Coastguard Worker
get_coeff_dist(tran_low_t tcoeff,tran_low_t dqcoeff,int shift,const qm_val_t * qmatrix,int coeff_idx)48*77c1e3ccSAndroid Build Coastguard Worker static inline int64_t get_coeff_dist(tran_low_t tcoeff, tran_low_t dqcoeff,
49*77c1e3ccSAndroid Build Coastguard Worker int shift, const qm_val_t *qmatrix,
50*77c1e3ccSAndroid Build Coastguard Worker int coeff_idx) {
51*77c1e3ccSAndroid Build Coastguard Worker int64_t diff = (tcoeff - dqcoeff) * (1 << shift);
52*77c1e3ccSAndroid Build Coastguard Worker if (qmatrix == NULL) {
53*77c1e3ccSAndroid Build Coastguard Worker return diff * diff;
54*77c1e3ccSAndroid Build Coastguard Worker }
55*77c1e3ccSAndroid Build Coastguard Worker // When AOM_DIST_METRIC_QM_PSNR is enabled, this mirrors the rate-distortion
56*77c1e3ccSAndroid Build Coastguard Worker // computation done in av1_block_error_qm, improving visual quality.
57*77c1e3ccSAndroid Build Coastguard Worker // The maximum value of `shift` is 2, `tcoeff` and `dqcoeff` are at most 22
58*77c1e3ccSAndroid Build Coastguard Worker // bits, and AOM_QM_BITS is 5, so `diff` should fit in 29-bits. The
59*77c1e3ccSAndroid Build Coastguard Worker // multiplication `diff * diff` then does not risk overflowing.
60*77c1e3ccSAndroid Build Coastguard Worker diff *= qmatrix[coeff_idx];
61*77c1e3ccSAndroid Build Coastguard Worker const int64_t error =
62*77c1e3ccSAndroid Build Coastguard Worker (diff * diff + (1 << (2 * AOM_QM_BITS - 1))) >> (2 * AOM_QM_BITS);
63*77c1e3ccSAndroid Build Coastguard Worker return error;
64*77c1e3ccSAndroid Build Coastguard Worker }
65*77c1e3ccSAndroid Build Coastguard Worker
get_eob_cost(int eob,const LV_MAP_EOB_COST * txb_eob_costs,const LV_MAP_COEFF_COST * txb_costs,TX_CLASS tx_class)66*77c1e3ccSAndroid Build Coastguard Worker static int get_eob_cost(int eob, const LV_MAP_EOB_COST *txb_eob_costs,
67*77c1e3ccSAndroid Build Coastguard Worker const LV_MAP_COEFF_COST *txb_costs, TX_CLASS tx_class) {
68*77c1e3ccSAndroid Build Coastguard Worker int eob_extra;
69*77c1e3ccSAndroid Build Coastguard Worker const int eob_pt = av1_get_eob_pos_token(eob, &eob_extra);
70*77c1e3ccSAndroid Build Coastguard Worker int eob_cost = 0;
71*77c1e3ccSAndroid Build Coastguard Worker const int eob_multi_ctx = (tx_class == TX_CLASS_2D) ? 0 : 1;
72*77c1e3ccSAndroid Build Coastguard Worker eob_cost = txb_eob_costs->eob_cost[eob_multi_ctx][eob_pt - 1];
73*77c1e3ccSAndroid Build Coastguard Worker
74*77c1e3ccSAndroid Build Coastguard Worker if (av1_eob_offset_bits[eob_pt] > 0) {
75*77c1e3ccSAndroid Build Coastguard Worker const int eob_ctx = eob_pt - 3;
76*77c1e3ccSAndroid Build Coastguard Worker const int eob_shift = av1_eob_offset_bits[eob_pt] - 1;
77*77c1e3ccSAndroid Build Coastguard Worker const int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
78*77c1e3ccSAndroid Build Coastguard Worker eob_cost += txb_costs->eob_extra_cost[eob_ctx][bit];
79*77c1e3ccSAndroid Build Coastguard Worker const int offset_bits = av1_eob_offset_bits[eob_pt];
80*77c1e3ccSAndroid Build Coastguard Worker if (offset_bits > 1) eob_cost += av1_cost_literal(offset_bits - 1);
81*77c1e3ccSAndroid Build Coastguard Worker }
82*77c1e3ccSAndroid Build Coastguard Worker return eob_cost;
83*77c1e3ccSAndroid Build Coastguard Worker }
84*77c1e3ccSAndroid Build Coastguard Worker
get_golomb_cost(int abs_qc)85*77c1e3ccSAndroid Build Coastguard Worker static inline int get_golomb_cost(int abs_qc) {
86*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc >= 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
87*77c1e3ccSAndroid Build Coastguard Worker const int r = abs_qc - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
88*77c1e3ccSAndroid Build Coastguard Worker const int length = get_msb(r) + 1;
89*77c1e3ccSAndroid Build Coastguard Worker return av1_cost_literal(2 * length - 1);
90*77c1e3ccSAndroid Build Coastguard Worker }
91*77c1e3ccSAndroid Build Coastguard Worker return 0;
92*77c1e3ccSAndroid Build Coastguard Worker }
93*77c1e3ccSAndroid Build Coastguard Worker
get_br_cost(tran_low_t level,const int * coeff_lps)94*77c1e3ccSAndroid Build Coastguard Worker static inline int get_br_cost(tran_low_t level, const int *coeff_lps) {
95*77c1e3ccSAndroid Build Coastguard Worker const int base_range = AOMMIN(level - 1 - NUM_BASE_LEVELS, COEFF_BASE_RANGE);
96*77c1e3ccSAndroid Build Coastguard Worker return coeff_lps[base_range] + get_golomb_cost(level);
97*77c1e3ccSAndroid Build Coastguard Worker }
98*77c1e3ccSAndroid Build Coastguard Worker
get_br_cost_with_diff(tran_low_t level,const int * coeff_lps,int * diff)99*77c1e3ccSAndroid Build Coastguard Worker static inline int get_br_cost_with_diff(tran_low_t level, const int *coeff_lps,
100*77c1e3ccSAndroid Build Coastguard Worker int *diff) {
101*77c1e3ccSAndroid Build Coastguard Worker const int base_range = AOMMIN(level - 1 - NUM_BASE_LEVELS, COEFF_BASE_RANGE);
102*77c1e3ccSAndroid Build Coastguard Worker int golomb_bits = 0;
103*77c1e3ccSAndroid Build Coastguard Worker if (level <= COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS)
104*77c1e3ccSAndroid Build Coastguard Worker *diff += coeff_lps[base_range + COEFF_BASE_RANGE + 1];
105*77c1e3ccSAndroid Build Coastguard Worker
106*77c1e3ccSAndroid Build Coastguard Worker if (level >= COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS) {
107*77c1e3ccSAndroid Build Coastguard Worker int r = level - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
108*77c1e3ccSAndroid Build Coastguard Worker if (r < 32) {
109*77c1e3ccSAndroid Build Coastguard Worker golomb_bits = golomb_bits_cost[r];
110*77c1e3ccSAndroid Build Coastguard Worker *diff += golomb_cost_diff[r];
111*77c1e3ccSAndroid Build Coastguard Worker } else {
112*77c1e3ccSAndroid Build Coastguard Worker golomb_bits = get_golomb_cost(level);
113*77c1e3ccSAndroid Build Coastguard Worker *diff += (r & (r - 1)) == 0 ? 1024 : 0;
114*77c1e3ccSAndroid Build Coastguard Worker }
115*77c1e3ccSAndroid Build Coastguard Worker }
116*77c1e3ccSAndroid Build Coastguard Worker
117*77c1e3ccSAndroid Build Coastguard Worker return coeff_lps[base_range] + golomb_bits;
118*77c1e3ccSAndroid Build Coastguard Worker }
119*77c1e3ccSAndroid Build Coastguard Worker
get_two_coeff_cost_simple(int ci,tran_low_t abs_qc,int coeff_ctx,const LV_MAP_COEFF_COST * txb_costs,int bhl,TX_CLASS tx_class,const uint8_t * levels,int * cost_low)120*77c1e3ccSAndroid Build Coastguard Worker static AOM_FORCE_INLINE int get_two_coeff_cost_simple(
121*77c1e3ccSAndroid Build Coastguard Worker int ci, tran_low_t abs_qc, int coeff_ctx,
122*77c1e3ccSAndroid Build Coastguard Worker const LV_MAP_COEFF_COST *txb_costs, int bhl, TX_CLASS tx_class,
123*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *levels, int *cost_low) {
124*77c1e3ccSAndroid Build Coastguard Worker // this simple version assumes the coeff's scan_idx is not DC (scan_idx != 0)
125*77c1e3ccSAndroid Build Coastguard Worker // and not the last (scan_idx != eob - 1)
126*77c1e3ccSAndroid Build Coastguard Worker assert(ci > 0);
127*77c1e3ccSAndroid Build Coastguard Worker int cost = txb_costs->base_cost[coeff_ctx][AOMMIN(abs_qc, 3)];
128*77c1e3ccSAndroid Build Coastguard Worker int diff = 0;
129*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc <= 3) diff = txb_costs->base_cost[coeff_ctx][abs_qc + 4];
130*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc) {
131*77c1e3ccSAndroid Build Coastguard Worker cost += av1_cost_literal(1);
132*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc > NUM_BASE_LEVELS) {
133*77c1e3ccSAndroid Build Coastguard Worker const int br_ctx = get_br_ctx(levels, ci, bhl, tx_class);
134*77c1e3ccSAndroid Build Coastguard Worker int brcost_diff = 0;
135*77c1e3ccSAndroid Build Coastguard Worker cost += get_br_cost_with_diff(abs_qc, txb_costs->lps_cost[br_ctx],
136*77c1e3ccSAndroid Build Coastguard Worker &brcost_diff);
137*77c1e3ccSAndroid Build Coastguard Worker diff += brcost_diff;
138*77c1e3ccSAndroid Build Coastguard Worker }
139*77c1e3ccSAndroid Build Coastguard Worker }
140*77c1e3ccSAndroid Build Coastguard Worker *cost_low = cost - diff;
141*77c1e3ccSAndroid Build Coastguard Worker
142*77c1e3ccSAndroid Build Coastguard Worker return cost;
143*77c1e3ccSAndroid Build Coastguard Worker }
144*77c1e3ccSAndroid Build Coastguard Worker
get_coeff_cost_eob(int ci,tran_low_t abs_qc,int sign,int coeff_ctx,int dc_sign_ctx,const LV_MAP_COEFF_COST * txb_costs,int bhl,TX_CLASS tx_class)145*77c1e3ccSAndroid Build Coastguard Worker static inline int get_coeff_cost_eob(int ci, tran_low_t abs_qc, int sign,
146*77c1e3ccSAndroid Build Coastguard Worker int coeff_ctx, int dc_sign_ctx,
147*77c1e3ccSAndroid Build Coastguard Worker const LV_MAP_COEFF_COST *txb_costs,
148*77c1e3ccSAndroid Build Coastguard Worker int bhl, TX_CLASS tx_class) {
149*77c1e3ccSAndroid Build Coastguard Worker int cost = 0;
150*77c1e3ccSAndroid Build Coastguard Worker cost += txb_costs->base_eob_cost[coeff_ctx][AOMMIN(abs_qc, 3) - 1];
151*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc != 0) {
152*77c1e3ccSAndroid Build Coastguard Worker if (ci == 0) {
153*77c1e3ccSAndroid Build Coastguard Worker cost += txb_costs->dc_sign_cost[dc_sign_ctx][sign];
154*77c1e3ccSAndroid Build Coastguard Worker } else {
155*77c1e3ccSAndroid Build Coastguard Worker cost += av1_cost_literal(1);
156*77c1e3ccSAndroid Build Coastguard Worker }
157*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc > NUM_BASE_LEVELS) {
158*77c1e3ccSAndroid Build Coastguard Worker int br_ctx;
159*77c1e3ccSAndroid Build Coastguard Worker br_ctx = get_br_ctx_eob(ci, bhl, tx_class);
160*77c1e3ccSAndroid Build Coastguard Worker cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
161*77c1e3ccSAndroid Build Coastguard Worker }
162*77c1e3ccSAndroid Build Coastguard Worker }
163*77c1e3ccSAndroid Build Coastguard Worker return cost;
164*77c1e3ccSAndroid Build Coastguard Worker }
165*77c1e3ccSAndroid Build Coastguard Worker
get_coeff_cost_general(int is_last,int ci,tran_low_t abs_qc,int sign,int coeff_ctx,int dc_sign_ctx,const LV_MAP_COEFF_COST * txb_costs,int bhl,TX_CLASS tx_class,const uint8_t * levels)166*77c1e3ccSAndroid Build Coastguard Worker static inline int get_coeff_cost_general(int is_last, int ci, tran_low_t abs_qc,
167*77c1e3ccSAndroid Build Coastguard Worker int sign, int coeff_ctx,
168*77c1e3ccSAndroid Build Coastguard Worker int dc_sign_ctx,
169*77c1e3ccSAndroid Build Coastguard Worker const LV_MAP_COEFF_COST *txb_costs,
170*77c1e3ccSAndroid Build Coastguard Worker int bhl, TX_CLASS tx_class,
171*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *levels) {
172*77c1e3ccSAndroid Build Coastguard Worker int cost = 0;
173*77c1e3ccSAndroid Build Coastguard Worker if (is_last) {
174*77c1e3ccSAndroid Build Coastguard Worker cost += txb_costs->base_eob_cost[coeff_ctx][AOMMIN(abs_qc, 3) - 1];
175*77c1e3ccSAndroid Build Coastguard Worker } else {
176*77c1e3ccSAndroid Build Coastguard Worker cost += txb_costs->base_cost[coeff_ctx][AOMMIN(abs_qc, 3)];
177*77c1e3ccSAndroid Build Coastguard Worker }
178*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc != 0) {
179*77c1e3ccSAndroid Build Coastguard Worker if (ci == 0) {
180*77c1e3ccSAndroid Build Coastguard Worker cost += txb_costs->dc_sign_cost[dc_sign_ctx][sign];
181*77c1e3ccSAndroid Build Coastguard Worker } else {
182*77c1e3ccSAndroid Build Coastguard Worker cost += av1_cost_literal(1);
183*77c1e3ccSAndroid Build Coastguard Worker }
184*77c1e3ccSAndroid Build Coastguard Worker if (abs_qc > NUM_BASE_LEVELS) {
185*77c1e3ccSAndroid Build Coastguard Worker int br_ctx;
186*77c1e3ccSAndroid Build Coastguard Worker if (is_last)
187*77c1e3ccSAndroid Build Coastguard Worker br_ctx = get_br_ctx_eob(ci, bhl, tx_class);
188*77c1e3ccSAndroid Build Coastguard Worker else
189*77c1e3ccSAndroid Build Coastguard Worker br_ctx = get_br_ctx(levels, ci, bhl, tx_class);
190*77c1e3ccSAndroid Build Coastguard Worker cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
191*77c1e3ccSAndroid Build Coastguard Worker }
192*77c1e3ccSAndroid Build Coastguard Worker }
193*77c1e3ccSAndroid Build Coastguard Worker return cost;
194*77c1e3ccSAndroid Build Coastguard Worker }
195*77c1e3ccSAndroid Build Coastguard Worker
get_qc_dqc_low(tran_low_t abs_qc,int sign,int dqv,int shift,tran_low_t * qc_low,tran_low_t * dqc_low)196*77c1e3ccSAndroid Build Coastguard Worker static inline void get_qc_dqc_low(tran_low_t abs_qc, int sign, int dqv,
197*77c1e3ccSAndroid Build Coastguard Worker int shift, tran_low_t *qc_low,
198*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqc_low) {
199*77c1e3ccSAndroid Build Coastguard Worker tran_low_t abs_qc_low = abs_qc - 1;
200*77c1e3ccSAndroid Build Coastguard Worker *qc_low = (-sign ^ abs_qc_low) + sign;
201*77c1e3ccSAndroid Build Coastguard Worker assert((sign ? -abs_qc_low : abs_qc_low) == *qc_low);
202*77c1e3ccSAndroid Build Coastguard Worker tran_low_t abs_dqc_low = (abs_qc_low * dqv) >> shift;
203*77c1e3ccSAndroid Build Coastguard Worker *dqc_low = (-sign ^ abs_dqc_low) + sign;
204*77c1e3ccSAndroid Build Coastguard Worker assert((sign ? -abs_dqc_low : abs_dqc_low) == *dqc_low);
205*77c1e3ccSAndroid Build Coastguard Worker }
206*77c1e3ccSAndroid Build Coastguard Worker
update_coeff_eob_fast(int * eob,int shift,const int16_t * dequant_ptr,const int16_t * scan,const tran_low_t * coeff_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr)207*77c1e3ccSAndroid Build Coastguard Worker static inline void update_coeff_eob_fast(int *eob, int shift,
208*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr,
209*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan,
210*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr,
211*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr,
212*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr) {
213*77c1e3ccSAndroid Build Coastguard Worker // TODO(sarahparker) make this work for aomqm
214*77c1e3ccSAndroid Build Coastguard Worker int eob_out = *eob;
215*77c1e3ccSAndroid Build Coastguard Worker int zbin[2] = { dequant_ptr[0] + ROUND_POWER_OF_TWO(dequant_ptr[0] * 70, 7),
216*77c1e3ccSAndroid Build Coastguard Worker dequant_ptr[1] + ROUND_POWER_OF_TWO(dequant_ptr[1] * 70, 7) };
217*77c1e3ccSAndroid Build Coastguard Worker
218*77c1e3ccSAndroid Build Coastguard Worker for (int i = *eob - 1; i >= 0; i--) {
219*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
220*77c1e3ccSAndroid Build Coastguard Worker const int qcoeff = qcoeff_ptr[rc];
221*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc];
222*77c1e3ccSAndroid Build Coastguard Worker const int coeff_sign = AOMSIGN(coeff);
223*77c1e3ccSAndroid Build Coastguard Worker int64_t abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
224*77c1e3ccSAndroid Build Coastguard Worker
225*77c1e3ccSAndroid Build Coastguard Worker if (((abs_coeff << (1 + shift)) < zbin[rc != 0]) || (qcoeff == 0)) {
226*77c1e3ccSAndroid Build Coastguard Worker eob_out--;
227*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = 0;
228*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = 0;
229*77c1e3ccSAndroid Build Coastguard Worker } else {
230*77c1e3ccSAndroid Build Coastguard Worker break;
231*77c1e3ccSAndroid Build Coastguard Worker }
232*77c1e3ccSAndroid Build Coastguard Worker }
233*77c1e3ccSAndroid Build Coastguard Worker
234*77c1e3ccSAndroid Build Coastguard Worker *eob = eob_out;
235*77c1e3ccSAndroid Build Coastguard Worker }
236*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_ENCODER_TXB_RDOPT_UTILS_H_
237