xref: /aosp_15_r20/external/libaom/av1/encoder/intra_mode_search.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2020, 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 /*!\file
13*77c1e3ccSAndroid Build Coastguard Worker  * \brief Declares high level functions to search through intra modes.
14*77c1e3ccSAndroid Build Coastguard Worker  */
15*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_INTRA_MODE_SEARCH_H_
16*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_INTRA_MODE_SEARCH_H_
17*77c1e3ccSAndroid Build Coastguard Worker 
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encoder.h"
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
21*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
22*77c1e3ccSAndroid Build Coastguard Worker #endif
23*77c1e3ccSAndroid Build Coastguard Worker 
24*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Variables related to intra-mode search during inter frame coding.
25*77c1e3ccSAndroid Build Coastguard Worker  *
26*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
27*77c1e3ccSAndroid Build Coastguard Worker  * This is a set of variables used during intra-mode search for inter frames.
28*77c1e3ccSAndroid Build Coastguard Worker  * This includes an histogram of gradient speed features and a cache of uv
29*77c1e3ccSAndroid Build Coastguard Worker  * prediction to avoid repeated search of chroma prediction.
30*77c1e3ccSAndroid Build Coastguard Worker  */
31*77c1e3ccSAndroid Build Coastguard Worker typedef struct IntraModeSearchState {
32*77c1e3ccSAndroid Build Coastguard Worker   /*!
33*77c1e3ccSAndroid Build Coastguard Worker    * \brief The best luma intra-mode found so far
34*77c1e3ccSAndroid Build Coastguard Worker    */
35*77c1e3ccSAndroid Build Coastguard Worker   PREDICTION_MODE best_intra_mode;
36*77c1e3ccSAndroid Build Coastguard Worker 
37*77c1e3ccSAndroid Build Coastguard Worker   /** \name Speed feature variables
38*77c1e3ccSAndroid Build Coastguard Worker    * Variables to help with pruning some luma intra-modes during inter frame
39*77c1e3ccSAndroid Build Coastguard Worker    * coding process.
40*77c1e3ccSAndroid Build Coastguard Worker    */
41*77c1e3ccSAndroid Build Coastguard Worker   /**@{*/
42*77c1e3ccSAndroid Build Coastguard Worker   /*!
43*77c1e3ccSAndroid Build Coastguard Worker    * \brief Whether to terminate all intra mode search.
44*77c1e3ccSAndroid Build Coastguard Worker    */
45*77c1e3ccSAndroid Build Coastguard Worker   int skip_intra_modes;
46*77c1e3ccSAndroid Build Coastguard Worker   /*!
47*77c1e3ccSAndroid Build Coastguard Worker    * \brief Whether a directional mode is pruned.
48*77c1e3ccSAndroid Build Coastguard Worker    */
49*77c1e3ccSAndroid Build Coastguard Worker   uint8_t directional_mode_skip_mask[INTRA_MODES];
50*77c1e3ccSAndroid Build Coastguard Worker   /*!
51*77c1e3ccSAndroid Build Coastguard Worker    * \brief Whether \ref directional_mode_skip_mask is valid for pruning.
52*77c1e3ccSAndroid Build Coastguard Worker    */
53*77c1e3ccSAndroid Build Coastguard Worker   int dir_mode_skip_mask_ready;
54*77c1e3ccSAndroid Build Coastguard Worker   /**@}*/
55*77c1e3ccSAndroid Build Coastguard Worker 
56*77c1e3ccSAndroid Build Coastguard Worker   /** \name Chroma mode search cache
57*77c1e3ccSAndroid Build Coastguard Worker    * A cache of the best chroma prediction mode to avoid having to search for
58*77c1e3ccSAndroid Build Coastguard Worker    * chroma predictions repeatedly in \ref
59*77c1e3ccSAndroid Build Coastguard Worker    * av1_search_intra_uv_modes_in_interframe()
60*77c1e3ccSAndroid Build Coastguard Worker    */
61*77c1e3ccSAndroid Build Coastguard Worker   /**@{*/
62*77c1e3ccSAndroid Build Coastguard Worker   int rate_uv_intra;          /*!< \brief Total rate to transmit uv_mode */
63*77c1e3ccSAndroid Build Coastguard Worker   int rate_uv_tokenonly;      /*!< \brief Rate transmit txfm tokens */
64*77c1e3ccSAndroid Build Coastguard Worker   int64_t dist_uvs;           /*!< \brief Distortion of the uv_mode's recon */
65*77c1e3ccSAndroid Build Coastguard Worker   uint8_t skip_uvs;           /*!< \brief Whether the uv txfm is skippable */
66*77c1e3ccSAndroid Build Coastguard Worker   UV_PREDICTION_MODE mode_uv; /*!< \brief The best uv mode */
67*77c1e3ccSAndroid Build Coastguard Worker   PALETTE_MODE_INFO pmi_uv;   /*!< \brief Color map if mode_uv is palette */
68*77c1e3ccSAndroid Build Coastguard Worker   int8_t uv_angle_delta;      /*!< \brief Angle delta if mode_uv directional */
69*77c1e3ccSAndroid Build Coastguard Worker   /**@}*/
70*77c1e3ccSAndroid Build Coastguard Worker } IntraModeSearchState;
71*77c1e3ccSAndroid Build Coastguard Worker 
72*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Evaluate a given luma intra-mode for inter frames.
73*77c1e3ccSAndroid Build Coastguard Worker  *
74*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
75*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
76*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
77*77c1e3ccSAndroid Build Coastguard Worker  * This function handles an intra-mode luma prediction when the current frame
78*77c1e3ccSAndroid Build Coastguard Worker  * is an inter frame. This is the intra-mode counterpart of handle_inter_mode.
79*77c1e3ccSAndroid Build Coastguard Worker  * This function performs an intra luma prediction using the mode specified by
80*77c1e3ccSAndroid Build Coastguard Worker  * x->e_mbd.mi[0]->mode. This function does *not* support palette mode
81*77c1e3ccSAndroid Build Coastguard Worker  * prediction in the luma channel.
82*77c1e3ccSAndroid Build Coastguard Worker  *
83*77c1e3ccSAndroid Build Coastguard Worker  * \param[in,out]    intra_search_state Structure to intra search state.
84*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        cpi                Top-level encoder structure.
85*77c1e3ccSAndroid Build Coastguard Worker  * \param[in,out]    x                  Pointer to structure holding all the
86*77c1e3ccSAndroid Build Coastguard Worker  *                                      data for the current macroblock.
87*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        bsize              Current partition block size.
88*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        ref_frame_cost     The entropy cost for signaling that the
89*77c1e3ccSAndroid Build Coastguard Worker  *                                      current ref frame is an intra frame.
90*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        ctx                Structure to hold the number of 4x4 blks
91*77c1e3ccSAndroid Build Coastguard Worker  *                                      to copy tx_type and txfm_skip arrays.
92*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       rd_stats_y         Struct to keep track of the current
93*77c1e3ccSAndroid Build Coastguard Worker  *                                      intra-mode's rd_stats (luma only).
94*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        best_rd            Best RD seen for this block so far.
95*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       mode_cost_y        The cost needed to signal the current
96*77c1e3ccSAndroid Build Coastguard Worker  *                                      intra mode.
97*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       rd_y               The rdcost of the chosen mode.
98*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        best_model_rd      Best model RD seen for this block so far
99*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        top_intra_model_rd Top intra model RD seen for this
100*77c1e3ccSAndroid Build Coastguard Worker  *                                      block so far.
101*77c1e3ccSAndroid Build Coastguard Worker  *
102*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns 1 if a valid intra mode is found, 0 otherwise.
103*77c1e3ccSAndroid Build Coastguard Worker  * The corresponding values in x->e_mbd.mi[0], rd_stats_y, mode_cost_y, and
104*77c1e3ccSAndroid Build Coastguard Worker  * rd_y are also updated. Moreover, in the first evaluation with directional
105*77c1e3ccSAndroid Build Coastguard Worker  * mode, a prune_mask computed with histogram of gradient is also stored in
106*77c1e3ccSAndroid Build Coastguard Worker  * intra_search_state.
107*77c1e3ccSAndroid Build Coastguard Worker  */
108*77c1e3ccSAndroid Build Coastguard Worker int av1_handle_intra_y_mode(IntraModeSearchState *intra_search_state,
109*77c1e3ccSAndroid Build Coastguard Worker                             const AV1_COMP *cpi, MACROBLOCK *x,
110*77c1e3ccSAndroid Build Coastguard Worker                             BLOCK_SIZE bsize, unsigned int ref_frame_cost,
111*77c1e3ccSAndroid Build Coastguard Worker                             const PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats_y,
112*77c1e3ccSAndroid Build Coastguard Worker                             int64_t best_rd, int *mode_cost_y, int64_t *rd_y,
113*77c1e3ccSAndroid Build Coastguard Worker                             int64_t *best_model_rd,
114*77c1e3ccSAndroid Build Coastguard Worker                             int64_t top_intra_model_rd[]);
115*77c1e3ccSAndroid Build Coastguard Worker 
116*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Search through all chroma intra-modes for inter frames.
117*77c1e3ccSAndroid Build Coastguard Worker  *
118*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
119*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
120*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
121*77c1e3ccSAndroid Build Coastguard Worker  * This function handles intra-mode chroma prediction when the current frame
122*77c1e3ccSAndroid Build Coastguard Worker  * is an inter frame. This is done by calling \ref av1_rd_pick_intra_sbuv_mode
123*77c1e3ccSAndroid Build Coastguard Worker  * with some additional book-keeping.
124*77c1e3ccSAndroid Build Coastguard Worker  *
125*77c1e3ccSAndroid Build Coastguard Worker  * \param[in,out]    intra_search_state Structure to intra search state.
126*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        cpi                Top-level encoder structure.
127*77c1e3ccSAndroid Build Coastguard Worker  * \param[in,out]    x                  Pointer to structure holding all the
128*77c1e3ccSAndroid Build Coastguard Worker  *                                      data for the current macroblock.
129*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        bsize              Current partition block size.
130*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       rd_stats           Struct to keep track of the current
131*77c1e3ccSAndroid Build Coastguard Worker  *                                      intra-mode's rd_stats (all planes).
132*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       rd_stats_y         Struct to keep track of the current
133*77c1e3ccSAndroid Build Coastguard Worker  *                                      intra-mode's rd_stats (luma only).
134*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]       rd_stats_uv        Struct to keep track of the current
135*77c1e3ccSAndroid Build Coastguard Worker  *                                      intra-mode's rd_stats (chroma only).
136*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]        best_rd            Best RD seen for this block so far.
137*77c1e3ccSAndroid Build Coastguard Worker  *
138*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns 1 if a valid intra mode is found, 0 otherwise.
139*77c1e3ccSAndroid Build Coastguard Worker  * The corresponding values in x->e_mbd.mi[0], rd_stats(_y|_uv)  are also
140*77c1e3ccSAndroid Build Coastguard Worker  * updated. Moreover, in the first evocation of the function, the chroma intra
141*77c1e3ccSAndroid Build Coastguard Worker  * mode result is cached in intra_search_state to be used in subsequent calls.
142*77c1e3ccSAndroid Build Coastguard Worker  */
143*77c1e3ccSAndroid Build Coastguard Worker int av1_search_intra_uv_modes_in_interframe(
144*77c1e3ccSAndroid Build Coastguard Worker     IntraModeSearchState *intra_search_state, const AV1_COMP *cpi,
145*77c1e3ccSAndroid Build Coastguard Worker     MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats,
146*77c1e3ccSAndroid Build Coastguard Worker     const RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, int64_t best_rd);
147*77c1e3ccSAndroid Build Coastguard Worker 
148*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Evaluate luma palette mode for inter frames.
149*77c1e3ccSAndroid Build Coastguard Worker  *
150*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
151*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
152*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
153*77c1e3ccSAndroid Build Coastguard Worker  * This function handles luma palette mode when the current frame is an
154*77c1e3ccSAndroid Build Coastguard Worker  * inter frame.
155*77c1e3ccSAndroid Build Coastguard Worker  *
156*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    intra_search_state Structure to hold the best luma intra mode
157*77c1e3ccSAndroid Build Coastguard Worker  *                                  and cache chroma prediction for speed up.
158*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi                Top-level encoder structure.
159*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x                  Pointer to structure holding all the data
160*77c1e3ccSAndroid Build Coastguard Worker  *                                  for the current macroblock.
161*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize              Current partition block size.
162*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ref_frame_cost     The entropy cost for signaling that the
163*77c1e3ccSAndroid Build Coastguard Worker  *                                  current ref frame is an intra frame.
164*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx                Structure to hold the number of 4x4 blks to
165*77c1e3ccSAndroid Build Coastguard Worker  *                                  copy the tx_type and txfm_skip arrays.
166*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    this_rd_cost       Struct to keep track of palette mode's
167*77c1e3ccSAndroid Build Coastguard Worker  *                                  rd_stats.
168*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    best_rd            Best RD seen for this block so far.
169*77c1e3ccSAndroid Build Coastguard Worker  *
170*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns whether luma palette mode can skip the txfm. The
171*77c1e3ccSAndroid Build Coastguard Worker  * corresponding mbmi, this_rd_costs, intra_search_state, and tx_type arrays in
172*77c1e3ccSAndroid Build Coastguard Worker  * ctx are also updated.
173*77c1e3ccSAndroid Build Coastguard Worker  */
174*77c1e3ccSAndroid Build Coastguard Worker int av1_search_palette_mode(IntraModeSearchState *intra_search_state,
175*77c1e3ccSAndroid Build Coastguard Worker                             const AV1_COMP *cpi, MACROBLOCK *x,
176*77c1e3ccSAndroid Build Coastguard Worker                             BLOCK_SIZE bsize, unsigned int ref_frame_cost,
177*77c1e3ccSAndroid Build Coastguard Worker                             PICK_MODE_CONTEXT *ctx, RD_STATS *this_rd_cost,
178*77c1e3ccSAndroid Build Coastguard Worker                             int64_t best_rd);
179*77c1e3ccSAndroid Build Coastguard Worker 
180*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Evaluate luma palette mode for inter frames.
181*77c1e3ccSAndroid Build Coastguard Worker  *
182*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
183*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
184*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
185*77c1e3ccSAndroid Build Coastguard Worker  * This function handles luma palette mode when the current frame is an
186*77c1e3ccSAndroid Build Coastguard Worker  * inter frame.
187*77c1e3ccSAndroid Build Coastguard Worker  *
188*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi                Top-level encoder structure.
189*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x                  Pointer to structure holding all the data
190*77c1e3ccSAndroid Build Coastguard Worker  *                                  for the current macroblock.
191*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize              Current partition block size.
192*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ref_frame_cost     The entropy cost for signaling that the
193*77c1e3ccSAndroid Build Coastguard Worker  *                                  current ref frame is an intra frame.
194*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx                Structure to hold the number of 4x4 blks to
195*77c1e3ccSAndroid Build Coastguard Worker  *                                  copy the tx_type and txfm_skip arrays.
196*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    this_rd_cost       Struct to keep track of palette mode's
197*77c1e3ccSAndroid Build Coastguard Worker  *                                  rd_stats.
198*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    best_rd            Best RD seen for this block so far.
199*77c1e3ccSAndroid Build Coastguard Worker  */
200*77c1e3ccSAndroid Build Coastguard Worker void av1_search_palette_mode_luma(const AV1_COMP *cpi, MACROBLOCK *x,
201*77c1e3ccSAndroid Build Coastguard Worker                                   BLOCK_SIZE bsize, unsigned int ref_frame_cost,
202*77c1e3ccSAndroid Build Coastguard Worker                                   PICK_MODE_CONTEXT *ctx,
203*77c1e3ccSAndroid Build Coastguard Worker                                   RD_STATS *this_rd_cost, int64_t best_rd);
204*77c1e3ccSAndroid Build Coastguard Worker 
205*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Perform intra-mode search on luma channels for intra frames.
206*77c1e3ccSAndroid Build Coastguard Worker  *
207*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
208*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
209*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
210*77c1e3ccSAndroid Build Coastguard Worker  * This function performs intra-mode search on the luma channel when the
211*77c1e3ccSAndroid Build Coastguard Worker  * current frame is intra-only. This function does not search intrabc mode,
212*77c1e3ccSAndroid Build Coastguard Worker  * but it does search palette and filter_intra.
213*77c1e3ccSAndroid Build Coastguard Worker  *
214*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi                Top-level encoder structure.
215*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x                  Pointer to structure holding all the data
216*77c1e3ccSAndroid Build Coastguard Worker  *                                  for the current macroblock.
217*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    rate               The total rate needed to predict the current
218*77c1e3ccSAndroid Build Coastguard Worker  *                                  chroma block.
219*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    rate_tokenonly     The rate without the cost of sending the
220*77c1e3ccSAndroid Build Coastguard Worker  *                                  prediction modes.
221*77c1e3ccSAndroid Build Coastguard Worker  *                                  chroma block.
222*77c1e3ccSAndroid Build Coastguard Worker  *                                  after the reconstruction.
223*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    distortion         The chroma distortion of the best prediction
224*77c1e3ccSAndroid Build Coastguard Worker  *                                  after the reconstruction.
225*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    skippable          Whether we can skip txfm process.
226*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize              Current partition block size.
227*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    best_rd            Best RD seen for this block so far.
228*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx                Structure to hold the number of 4x4 blks to
229*77c1e3ccSAndroid Build Coastguard Worker  *                                  copy the tx_type and txfm_skip arrays.
230*77c1e3ccSAndroid Build Coastguard Worker  *
231*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns the rd_cost if this function finds a mode better than
232*77c1e3ccSAndroid Build Coastguard Worker  * best_rd, otherwise returns INT64_MAX. This also updates the mbmi, the rate
233*77c1e3ccSAndroid Build Coastguard Worker  * and distortion, and the tx_type arrays in ctx.
234*77c1e3ccSAndroid Build Coastguard Worker  */
235*77c1e3ccSAndroid Build Coastguard Worker int64_t av1_rd_pick_intra_sby_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
236*77c1e3ccSAndroid Build Coastguard Worker                                    int *rate, int *rate_tokenonly,
237*77c1e3ccSAndroid Build Coastguard Worker                                    int64_t *distortion, uint8_t *skippable,
238*77c1e3ccSAndroid Build Coastguard Worker                                    BLOCK_SIZE bsize, int64_t best_rd,
239*77c1e3ccSAndroid Build Coastguard Worker                                    PICK_MODE_CONTEXT *ctx);
240*77c1e3ccSAndroid Build Coastguard Worker 
241*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Perform intra-mode search on chroma channels.
242*77c1e3ccSAndroid Build Coastguard Worker  *
243*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup intra_mode_search
244*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
245*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
246*77c1e3ccSAndroid Build Coastguard Worker  * This function performs intra-mode search on the chroma channels. Just like
247*77c1e3ccSAndroid Build Coastguard Worker  * \ref av1_rd_pick_intra_sby_mode(), this function searches over palette mode
248*77c1e3ccSAndroid Build Coastguard Worker  * (filter_intra is not available on chroma planes). Unlike \ref
249*77c1e3ccSAndroid Build Coastguard Worker  * av1_rd_pick_intra_sby_mode() this function is used by both inter and intra
250*77c1e3ccSAndroid Build Coastguard Worker  * frames.
251*77c1e3ccSAndroid Build Coastguard Worker  *
252*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cpi                Top-level encoder structure.
253*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    x                  Pointer to structure holding all the data
254*77c1e3ccSAndroid Build Coastguard Worker  *                                  for the current macroblock.
255*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    rate               The total rate needed to predict the current
256*77c1e3ccSAndroid Build Coastguard Worker  *                                  chroma block.
257*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    rate_tokenonly     The rate without the cost of sending the
258*77c1e3ccSAndroid Build Coastguard Worker  *                                  prediction modes.
259*77c1e3ccSAndroid Build Coastguard Worker  *                                  chroma block.
260*77c1e3ccSAndroid Build Coastguard Worker  *                                  after the reconstruction.
261*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    distortion         The chroma distortion of the best prediction
262*77c1e3ccSAndroid Build Coastguard Worker  *                                  after the reconstruction.
263*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    skippable          Whether we can skip txfm process.
264*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    bsize              Current partition block size.
265*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    max_tx_size        The maximum tx_size available
266*77c1e3ccSAndroid Build Coastguard Worker  *
267*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns the rd_cost of the best uv mode found. This also updates the
268*77c1e3ccSAndroid Build Coastguard Worker  * mbmi, the rate and distortion, distortion.
269*77c1e3ccSAndroid Build Coastguard Worker  */
270*77c1e3ccSAndroid Build Coastguard Worker int64_t av1_rd_pick_intra_sbuv_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
271*77c1e3ccSAndroid Build Coastguard Worker                                     int *rate, int *rate_tokenonly,
272*77c1e3ccSAndroid Build Coastguard Worker                                     int64_t *distortion, uint8_t *skippable,
273*77c1e3ccSAndroid Build Coastguard Worker                                     BLOCK_SIZE bsize, TX_SIZE max_tx_size);
274*77c1e3ccSAndroid Build Coastguard Worker 
275*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Return the number of colors in src. Used by palette mode.
276*77c1e3ccSAndroid Build Coastguard Worker  */
277*77c1e3ccSAndroid Build Coastguard Worker void av1_count_colors(const uint8_t *src, int stride, int rows, int cols,
278*77c1e3ccSAndroid Build Coastguard Worker                       int *val_count, int *num_colors);
279*77c1e3ccSAndroid Build Coastguard Worker 
280*77c1e3ccSAndroid Build Coastguard Worker /*! \brief See \ref av1_count_colors(), but for highbd.
281*77c1e3ccSAndroid Build Coastguard Worker  */
282*77c1e3ccSAndroid Build Coastguard Worker void av1_count_colors_highbd(const uint8_t *src8, int stride, int rows,
283*77c1e3ccSAndroid Build Coastguard Worker                              int cols, int bit_depth, int *val_count,
284*77c1e3ccSAndroid Build Coastguard Worker                              int *val_count_8bit, int *num_color_bins,
285*77c1e3ccSAndroid Build Coastguard Worker                              int *num_colors);
286*77c1e3ccSAndroid Build Coastguard Worker 
287*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Initializes the \ref IntraModeSearchState struct.
288*77c1e3ccSAndroid Build Coastguard Worker  */
init_intra_mode_search_state(IntraModeSearchState * intra_search_state)289*77c1e3ccSAndroid Build Coastguard Worker static inline void init_intra_mode_search_state(
290*77c1e3ccSAndroid Build Coastguard Worker     IntraModeSearchState *intra_search_state) {
291*77c1e3ccSAndroid Build Coastguard Worker   memset(intra_search_state, 0, sizeof(*intra_search_state));
292*77c1e3ccSAndroid Build Coastguard Worker   intra_search_state->rate_uv_intra = INT_MAX;
293*77c1e3ccSAndroid Build Coastguard Worker }
294*77c1e3ccSAndroid Build Coastguard Worker 
295*77c1e3ccSAndroid Build Coastguard Worker /*! \brief set the luma intra mode and delta angles for a given mode index.
296*77c1e3ccSAndroid Build Coastguard Worker  * The total number of luma intra mode is LUMA_MODE_COUNT = 61.
297*77c1e3ccSAndroid Build Coastguard Worker  * The first 13 modes are from DC_PRED to PAETH_PRED, followed by directional
298*77c1e3ccSAndroid Build Coastguard Worker  * modes. Each of the main 8 directional modes have 6 = MAX_ANGLE_DELTA * 2
299*77c1e3ccSAndroid Build Coastguard Worker  * delta angles.
300*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    mode_idx                  mode index in intra mode decision
301*77c1e3ccSAndroid Build Coastguard Worker  *                                         process.
302*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    mbmi                      Pointer to structure holding the mode
303*77c1e3ccSAndroid Build Coastguard Worker  *                                         info for the current macroblock.
304*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    reorder_delta_angle_eval  Indicates whether to reorder the
305*77c1e3ccSAndroid Build Coastguard Worker  *                                         evaluation of delta angle modes.
306*77c1e3ccSAndroid Build Coastguard Worker  */
307*77c1e3ccSAndroid Build Coastguard Worker void set_y_mode_and_delta_angle(const int mode_idx, MB_MODE_INFO *const mbmi,
308*77c1e3ccSAndroid Build Coastguard Worker                                 int reorder_delta_angle_eval);
309*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
310*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
311*77c1e3ccSAndroid Build Coastguard Worker #endif
312*77c1e3ccSAndroid Build Coastguard Worker 
313*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_INTRA_MODE_SEARCH_H_
314