xref: /aosp_15_r20/external/libaom/av1/encoder/encodetxb.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2017, 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_ENCODETXB_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_ENCODETXB_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/blockd.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/txb_common.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/block.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encoder.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/bitwriter.h"
23*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
24*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
25*77c1e3ccSAndroid Build Coastguard Worker #endif
26*77c1e3ccSAndroid Build Coastguard Worker 
27*77c1e3ccSAndroid Build Coastguard Worker /*!\cond */
28*77c1e3ccSAndroid Build Coastguard Worker #define TXB_SKIP_CTX_MASK 15
29*77c1e3ccSAndroid Build Coastguard Worker #define DC_SIGN_CTX_SHIFT 4
30*77c1e3ccSAndroid Build Coastguard Worker #define DC_SIGN_CTX_MASK 3
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker int av1_get_eob_pos_token(const int eob, int *const extra);
33*77c1e3ccSAndroid Build Coastguard Worker 
34*77c1e3ccSAndroid Build Coastguard Worker /*!\endcond */
35*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Allocate the memory resources for all the macro blocks in the current
36*77c1e3ccSAndroid Build Coastguard Worker  * coding frame.
37*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
38*77c1e3ccSAndroid Build Coastguard Worker  *
39*77c1e3ccSAndroid Build Coastguard Worker  * Each macro block will need a \ref CB_COEFF_BUFFER to store information for
40*77c1e3ccSAndroid Build Coastguard Worker  * rate-distortion optimization and entropy coding of transform coefficients.
41*77c1e3ccSAndroid Build Coastguard Worker  *
42*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi            Top-level encoder structure
43*77c1e3ccSAndroid Build Coastguard Worker  */
44*77c1e3ccSAndroid Build Coastguard Worker void av1_alloc_txb_buf(AV1_COMP *cpi);
45*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Free the memory resources for all the macro blocks in the current
46*77c1e3ccSAndroid Build Coastguard Worker  * coding frame.
47*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
48*77c1e3ccSAndroid Build Coastguard Worker  *
49*77c1e3ccSAndroid Build Coastguard Worker  * See \ref av1_alloc_txb_buf and \ref CB_COEFF_BUFFER for more details.
50*77c1e3ccSAndroid Build Coastguard Worker  *
51*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi            Top-level encoder structure
52*77c1e3ccSAndroid Build Coastguard Worker  */
53*77c1e3ccSAndroid Build Coastguard Worker void av1_free_txb_buf(AV1_COMP *cpi);
54*77c1e3ccSAndroid Build Coastguard Worker 
55*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Write quantized coefficients in a transform block into bitstream using
56*77c1e3ccSAndroid Build Coastguard Worker  * entropy coding.
57*77c1e3ccSAndroid Build Coastguard Worker  *
58*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
59*77c1e3ccSAndroid Build Coastguard Worker  *
60*77c1e3ccSAndroid Build Coastguard Worker  * This function will write the quantized coefficients in a transform block into
61*77c1e3ccSAndroid Build Coastguard Worker  * the bitstream using entropy coding.
62*77c1e3ccSAndroid Build Coastguard Worker  *
63*77c1e3ccSAndroid Build Coastguard Worker  * The coding steps are as follows.
64*77c1e3ccSAndroid Build Coastguard Worker  *
65*77c1e3ccSAndroid Build Coastguard Worker  * 1) Code the end of block position "eob", which is the scan index of the
66*77c1e3ccSAndroid Build Coastguard Worker  * last non-zero coefficient plus one.
67*77c1e3ccSAndroid Build Coastguard Worker  *
68*77c1e3ccSAndroid Build Coastguard Worker  * 2) Code the lower magnitude level (<= COEFF_BASE_RANGE + NUM_BASE_LEVELS)
69*77c1e3ccSAndroid Build Coastguard Worker  * for each coefficient in reversed scan order.
70*77c1e3ccSAndroid Build Coastguard Worker  *
71*77c1e3ccSAndroid Build Coastguard Worker  * 3) Code the sign and higher magnitude level
72*77c1e3ccSAndroid Build Coastguard Worker  * (> COEFF_BASE_RANGE + NUM_BASE_LEVELS) in forward scan order.
73*77c1e3ccSAndroid Build Coastguard Worker  *
74*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cm             Top-level structure shared by encoder and
75*77c1e3ccSAndroid Build Coastguard Worker  * decoder
76*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x              Pointer to structure holding the data for the
77*77c1e3ccSAndroid Build Coastguard Worker                                 current encoding macroblock
78*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    w              Entropy coding write pointer
79*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_row      The row index of the current transform block
80*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane
81*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_col      The col index of the current transform block
82*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane
83*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane          The index of the current plane
84*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    block          The index of the current transform block in the
85*77c1e3ccSAndroid Build Coastguard Worker  * macroblock. It's defined by number of 4x4 units that have been coded before
86*77c1e3ccSAndroid Build Coastguard Worker  * the currernt transform block
87*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    tx_size        The given transform size
88*77c1e3ccSAndroid Build Coastguard Worker  */
89*77c1e3ccSAndroid Build Coastguard Worker void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *const x,
90*77c1e3ccSAndroid Build Coastguard Worker                           aom_writer *w, int blk_row, int blk_col, int plane,
91*77c1e3ccSAndroid Build Coastguard Worker                           int block, TX_SIZE tx_size);
92*77c1e3ccSAndroid Build Coastguard Worker 
93*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Write quantized coefficients of all transform blocks in an intra
94*77c1e3ccSAndroid Build Coastguard Worker  * macroblock into the bitstream using entropy coding.
95*77c1e3ccSAndroid Build Coastguard Worker  *
96*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
97*77c1e3ccSAndroid Build Coastguard Worker  *
98*77c1e3ccSAndroid Build Coastguard Worker  * All transform blocks in the intra macroblock share the same transform size.
99*77c1e3ccSAndroid Build Coastguard Worker  *
100*77c1e3ccSAndroid Build Coastguard Worker  * This function use \ref av1_write_coeffs_txb() to code each transform block in
101*77c1e3ccSAndroid Build Coastguard Worker  * raster order.
102*77c1e3ccSAndroid Build Coastguard Worker  *
103*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cm             Top-level structure shared by encoder and
104*77c1e3ccSAndroid Build Coastguard Worker  * decoder
105*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x              Pointer to structure holding the data for the
106*77c1e3ccSAndroid Build Coastguard Worker                                 current encoding macroblock
107*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    w              Entropy coding write pointer
108*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize          Block size of the current macroblock
109*77c1e3ccSAndroid Build Coastguard Worker  */
110*77c1e3ccSAndroid Build Coastguard Worker void av1_write_intra_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
111*77c1e3ccSAndroid Build Coastguard Worker                                aom_writer *w, BLOCK_SIZE bsize);
112*77c1e3ccSAndroid Build Coastguard Worker 
113*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Pack the context info of the current transform block into an uint8_t.
114*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
115*77c1e3ccSAndroid Build Coastguard Worker  *
116*77c1e3ccSAndroid Build Coastguard Worker  * This context info will be collected and consolidated by its neighbor
117*77c1e3ccSAndroid Build Coastguard Worker  * transform blocks for coding transform block skip flag (tx_skip) and
118*77c1e3ccSAndroid Build Coastguard Worker  * the sign of DC coefficient (dc_sign).
119*77c1e3ccSAndroid Build Coastguard Worker  *
120*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    qcoeff         Buffer of quantized coefficients
121*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    scan_order     Coding order of coefficients in the transform
122*77c1e3ccSAndroid Build Coastguard Worker  * block
123*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    eob            The scan index of last non-zero coefficient plus
124*77c1e3ccSAndroid Build Coastguard Worker  * one
125*77c1e3ccSAndroid Build Coastguard Worker  */
126*77c1e3ccSAndroid Build Coastguard Worker uint8_t av1_get_txb_entropy_context(const tran_low_t *qcoeff,
127*77c1e3ccSAndroid Build Coastguard Worker                                     const SCAN_ORDER *scan_order, int eob);
128*77c1e3ccSAndroid Build Coastguard Worker 
129*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Update the probability model (cdf) and the entropy context related to
130*77c1e3ccSAndroid Build Coastguard Worker  * coefficient coding for all transform blocks in the intra macroblock.
131*77c1e3ccSAndroid Build Coastguard Worker  *
132*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
133*77c1e3ccSAndroid Build Coastguard Worker  *
134*77c1e3ccSAndroid Build Coastguard Worker  * This function will go through each transform block in the intra macorblock
135*77c1e3ccSAndroid Build Coastguard Worker  * and call \ref av1_update_and_record_txb_context to update the probability
136*77c1e3ccSAndroid Build Coastguard Worker  * model and entropy context properly.
137*77c1e3ccSAndroid Build Coastguard Worker  *
138*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi               Top-level encoder structure
139*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    td                Top-level multithreading structure
140*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    dry_run           Whether this is a dry run.
141*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize             Block size of the current macroblock
142*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    allow_update_cdf  Allowed to update probability model (cdf) or
143*77c1e3ccSAndroid Build Coastguard Worker  * not.
144*77c1e3ccSAndroid Build Coastguard Worker  */
145*77c1e3ccSAndroid Build Coastguard Worker void av1_update_intra_mb_txb_context(const AV1_COMP *cpi, ThreadData *td,
146*77c1e3ccSAndroid Build Coastguard Worker                                      RUN_TYPE dry_run, BLOCK_SIZE bsize,
147*77c1e3ccSAndroid Build Coastguard Worker                                      uint8_t allow_update_cdf);
148*77c1e3ccSAndroid Build Coastguard Worker 
149*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Update the probability model (cdf) and the entropy context related to
150*77c1e3ccSAndroid Build Coastguard Worker  * coefficient coding for a transform block.
151*77c1e3ccSAndroid Build Coastguard Worker  *
152*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
153*77c1e3ccSAndroid Build Coastguard Worker  *
154*77c1e3ccSAndroid Build Coastguard Worker  * There are regular mode and dry run for this funtion.
155*77c1e3ccSAndroid Build Coastguard Worker  *
156*77c1e3ccSAndroid Build Coastguard Worker  * Regular mode:
157*77c1e3ccSAndroid Build Coastguard Worker  *
158*77c1e3ccSAndroid Build Coastguard Worker  * The probability model (cdf) for each coding symbol in the
159*77c1e3ccSAndroid Build Coastguard Worker  * transform block will be updated.
160*77c1e3ccSAndroid Build Coastguard Worker  *
161*77c1e3ccSAndroid Build Coastguard Worker  * The entropy context of this transform block will be updated.
162*77c1e3ccSAndroid Build Coastguard Worker  *
163*77c1e3ccSAndroid Build Coastguard Worker  * Dry run:
164*77c1e3ccSAndroid Build Coastguard Worker  *
165*77c1e3ccSAndroid Build Coastguard Worker  * The probability model update will be skipped.
166*77c1e3ccSAndroid Build Coastguard Worker  *
167*77c1e3ccSAndroid Build Coastguard Worker  * The entropy context of this transform block will be updated.
168*77c1e3ccSAndroid Build Coastguard Worker  *
169*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane        The index of the current plane.
170*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    block        The index of the current transform block in the
171*77c1e3ccSAndroid Build Coastguard Worker  * macroblock. It's defined by number of 4x4 units that have been coded before
172*77c1e3ccSAndroid Build Coastguard Worker  * the currernt transform block.
173*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_row      The row index of the current transform block
174*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane.
175*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_col      The col index of the current transform block
176*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane.
177*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane_bsize  Block size for this plane. When the video source
178*77c1e3ccSAndroid Build Coastguard Worker  * uses chroma subsampling, the block size of UV planes will be smaller than the
179*77c1e3ccSAndroid Build Coastguard Worker  * block size of Y plane.
180*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    tx_size      The given transform size.
181*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    arg          This parameter will be translated into
182*77c1e3ccSAndroid Build Coastguard Worker  * tokenize_b_args, in which RUN_TYPE indicates using regular mode or dry run.
183*77c1e3ccSAndroid Build Coastguard Worker  */
184*77c1e3ccSAndroid Build Coastguard Worker void av1_update_and_record_txb_context(int plane, int block, int blk_row,
185*77c1e3ccSAndroid Build Coastguard Worker                                        int blk_col, BLOCK_SIZE plane_bsize,
186*77c1e3ccSAndroid Build Coastguard Worker                                        TX_SIZE tx_size, void *arg);
187*77c1e3ccSAndroid Build Coastguard Worker 
188*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Update the entropy context related to coefficient coding for a
189*77c1e3ccSAndroid Build Coastguard Worker  * transform block.
190*77c1e3ccSAndroid Build Coastguard Worker  *
191*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
192*77c1e3ccSAndroid Build Coastguard Worker  *
193*77c1e3ccSAndroid Build Coastguard Worker  * There are regular mode and dry run for this function.
194*77c1e3ccSAndroid Build Coastguard Worker  *
195*77c1e3ccSAndroid Build Coastguard Worker  * Regular mode:
196*77c1e3ccSAndroid Build Coastguard Worker  *
197*77c1e3ccSAndroid Build Coastguard Worker  * The entropy context of this transform block will be updated.
198*77c1e3ccSAndroid Build Coastguard Worker  *
199*77c1e3ccSAndroid Build Coastguard Worker  * Dry run:
200*77c1e3ccSAndroid Build Coastguard Worker  *
201*77c1e3ccSAndroid Build Coastguard Worker  * The probability model update will be skipped.
202*77c1e3ccSAndroid Build Coastguard Worker  *
203*77c1e3ccSAndroid Build Coastguard Worker  * The entropy context of this transform block will be updated.
204*77c1e3ccSAndroid Build Coastguard Worker  *
205*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane        The index of the current plane.
206*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    block        The index of the current transform block in the
207*77c1e3ccSAndroid Build Coastguard Worker  * macroblock. It's defined by number of 4x4 units that have been coded before
208*77c1e3ccSAndroid Build Coastguard Worker  * the currernt transform block.
209*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_row      The row index of the current transform block
210*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane.
211*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    blk_col      The col index of the current transform block
212*77c1e3ccSAndroid Build Coastguard Worker  * in the macroblock. Each unit has 4 pixels in y plane.
213*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane_bsize  Block size for this plane. When the video source
214*77c1e3ccSAndroid Build Coastguard Worker  * uses chroma subsampling, the block size of UV planes will be smaller than the
215*77c1e3ccSAndroid Build Coastguard Worker  * block size of Y plane.
216*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    tx_size      The given transform size.
217*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    arg          This parameter will be translated into
218*77c1e3ccSAndroid Build Coastguard Worker  * tokenize_b_args, in which RUN_TYPE indicates using regular mode or dry run.
219*77c1e3ccSAndroid Build Coastguard Worker  */
220*77c1e3ccSAndroid Build Coastguard Worker void av1_record_txb_context(int plane, int block, int blk_row, int blk_col,
221*77c1e3ccSAndroid Build Coastguard Worker                             BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg);
222*77c1e3ccSAndroid Build Coastguard Worker 
223*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get the corresponding \ref CB_COEFF_BUFFER of the current macro block.
224*77c1e3ccSAndroid Build Coastguard Worker  *
225*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
226*77c1e3ccSAndroid Build Coastguard Worker  *
227*77c1e3ccSAndroid Build Coastguard Worker  * The macroblock's location is described by mi_row and mi_col, row and column
228*77c1e3ccSAndroid Build Coastguard Worker  * mi indexes in the coding frame.
229*77c1e3ccSAndroid Build Coastguard Worker  *
230*77c1e3ccSAndroid Build Coastguard Worker  * Each mi unit is a 4x4 pixel block.
231*77c1e3ccSAndroid Build Coastguard Worker  *
232*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi               Top-level encoder structure.
233*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    mi_row            Row mi index of the current transform block
234*77c1e3ccSAndroid Build Coastguard Worker  * in the frame.
235*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    mi_col           Column mi index of the current transform
236*77c1e3ccSAndroid Build Coastguard Worker  * block in the frame.
237*77c1e3ccSAndroid Build Coastguard Worker  * \return       CB_COEFF_BUFFER*  Pointer of \ref CB_COEFF_BUFFER associated
238*77c1e3ccSAndroid Build Coastguard Worker  * to this macroblock.
239*77c1e3ccSAndroid Build Coastguard Worker  */
240*77c1e3ccSAndroid Build Coastguard Worker CB_COEFF_BUFFER *av1_get_cb_coeff_buffer(const struct AV1_COMP *cpi, int mi_row,
241*77c1e3ccSAndroid Build Coastguard Worker                                          int mi_col);
242*77c1e3ccSAndroid Build Coastguard Worker 
243*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Returns the entropy cost associated with skipping the current
244*77c1e3ccSAndroid Build Coastguard Worker  * transform block.
245*77c1e3ccSAndroid Build Coastguard Worker  *
246*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup coefficient_coding
247*77c1e3ccSAndroid Build Coastguard Worker  *
248*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    coeff_costs    Table of entropy cost for coefficient coding.
249*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    txb_ctx        Context info for entropy coding transform block
250*77c1e3ccSAndroid Build Coastguard Worker  * skip flag (tx_skip) and the sign of DC coefficient (dc_sign).
251*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    plane          The index of the current plane
252*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    tx_size        The transform size
253*77c1e3ccSAndroid Build Coastguard Worker  */
av1_cost_skip_txb(const CoeffCosts * coeff_costs,const TXB_CTX * const txb_ctx,int plane,TX_SIZE tx_size)254*77c1e3ccSAndroid Build Coastguard Worker static inline int av1_cost_skip_txb(const CoeffCosts *coeff_costs,
255*77c1e3ccSAndroid Build Coastguard Worker                                     const TXB_CTX *const txb_ctx, int plane,
256*77c1e3ccSAndroid Build Coastguard Worker                                     TX_SIZE tx_size) {
257*77c1e3ccSAndroid Build Coastguard Worker   const TX_SIZE txs_ctx = get_txsize_entropy_ctx(tx_size);
258*77c1e3ccSAndroid Build Coastguard Worker   const PLANE_TYPE plane_type = get_plane_type(plane);
259*77c1e3ccSAndroid Build Coastguard Worker   const LV_MAP_COEFF_COST *const coeff_costs_ =
260*77c1e3ccSAndroid Build Coastguard Worker       &coeff_costs->coeff_costs[txs_ctx][plane_type];
261*77c1e3ccSAndroid Build Coastguard Worker   return coeff_costs_->txb_skip_cost[txb_ctx->txb_skip_ctx][1];
262*77c1e3ccSAndroid Build Coastguard Worker }
263*77c1e3ccSAndroid Build Coastguard Worker 
264*77c1e3ccSAndroid Build Coastguard Worker /*!\cond */
265*77c1e3ccSAndroid Build Coastguard Worker // These numbers are empirically obtained.
266*77c1e3ccSAndroid Build Coastguard Worker static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = {
267*77c1e3ccSAndroid Build Coastguard Worker   { 17, 13 },
268*77c1e3ccSAndroid Build Coastguard Worker   { 16, 10 },
269*77c1e3ccSAndroid Build Coastguard Worker };
270*77c1e3ccSAndroid Build Coastguard Worker /*!\endcond */
271*77c1e3ccSAndroid Build Coastguard Worker 
272*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
273*77c1e3ccSAndroid Build Coastguard Worker }
274*77c1e3ccSAndroid Build Coastguard Worker #endif
275*77c1e3ccSAndroid Build Coastguard Worker 
276*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_ENCODETXB_H_
277