xref: /aosp_15_r20/external/libaom/av1/encoder/svc_layercontext.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2019, 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_SVC_LAYERCONTEXT_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom_scale/yv12config.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/aq_cyclicrefresh.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/encoder.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/ratectrl.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 /*!
25*77c1e3ccSAndroid Build Coastguard Worker  * \brief The stucture of quantities related to each spatial and temporal layer.
26*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
27*77c1e3ccSAndroid Build Coastguard Worker  */
28*77c1e3ccSAndroid Build Coastguard Worker typedef struct {
29*77c1e3ccSAndroid Build Coastguard Worker   /*!\cond */
30*77c1e3ccSAndroid Build Coastguard Worker   RATE_CONTROL rc;
31*77c1e3ccSAndroid Build Coastguard Worker   PRIMARY_RATE_CONTROL p_rc;
32*77c1e3ccSAndroid Build Coastguard Worker   int framerate_factor;
33*77c1e3ccSAndroid Build Coastguard Worker   int64_t layer_target_bitrate;  // In bits per second.
34*77c1e3ccSAndroid Build Coastguard Worker   int scaling_factor_num;
35*77c1e3ccSAndroid Build Coastguard Worker   int scaling_factor_den;
36*77c1e3ccSAndroid Build Coastguard Worker   int64_t target_bandwidth;
37*77c1e3ccSAndroid Build Coastguard Worker   int64_t spatial_layer_target_bandwidth;
38*77c1e3ccSAndroid Build Coastguard Worker   double framerate;
39*77c1e3ccSAndroid Build Coastguard Worker   int avg_frame_size;
40*77c1e3ccSAndroid Build Coastguard Worker   int max_q;
41*77c1e3ccSAndroid Build Coastguard Worker   int min_q;
42*77c1e3ccSAndroid Build Coastguard Worker   int frames_from_key_frame;
43*77c1e3ccSAndroid Build Coastguard Worker   /*!\endcond */
44*77c1e3ccSAndroid Build Coastguard Worker 
45*77c1e3ccSAndroid Build Coastguard Worker   /*!
46*77c1e3ccSAndroid Build Coastguard Worker    * Cyclic refresh parameters (aq-mode=3), that need to be updated per-frame.
47*77c1e3ccSAndroid Build Coastguard Worker    */
48*77c1e3ccSAndroid Build Coastguard Worker   int sb_index;
49*77c1e3ccSAndroid Build Coastguard Worker   /*!
50*77c1e3ccSAndroid Build Coastguard Worker    * Segmentation map
51*77c1e3ccSAndroid Build Coastguard Worker    */
52*77c1e3ccSAndroid Build Coastguard Worker   int8_t *map;
53*77c1e3ccSAndroid Build Coastguard Worker   /*!
54*77c1e3ccSAndroid Build Coastguard Worker    * Number of blocks on segment 1
55*77c1e3ccSAndroid Build Coastguard Worker    */
56*77c1e3ccSAndroid Build Coastguard Worker   int actual_num_seg1_blocks;
57*77c1e3ccSAndroid Build Coastguard Worker 
58*77c1e3ccSAndroid Build Coastguard Worker   /*!
59*77c1e3ccSAndroid Build Coastguard Worker    * Number of blocks on segment 2
60*77c1e3ccSAndroid Build Coastguard Worker    */
61*77c1e3ccSAndroid Build Coastguard Worker   int actual_num_seg2_blocks;
62*77c1e3ccSAndroid Build Coastguard Worker   /*!
63*77c1e3ccSAndroid Build Coastguard Worker    * Counter used to detect scene change.
64*77c1e3ccSAndroid Build Coastguard Worker    */
65*77c1e3ccSAndroid Build Coastguard Worker   int counter_encode_maxq_scene_change;
66*77c1e3ccSAndroid Build Coastguard Worker 
67*77c1e3ccSAndroid Build Coastguard Worker   /*!
68*77c1e3ccSAndroid Build Coastguard Worker    * Speed settings for each layer.
69*77c1e3ccSAndroid Build Coastguard Worker    */
70*77c1e3ccSAndroid Build Coastguard Worker   uint8_t speed;
71*77c1e3ccSAndroid Build Coastguard Worker   /*!
72*77c1e3ccSAndroid Build Coastguard Worker    * GF group index.
73*77c1e3ccSAndroid Build Coastguard Worker    */
74*77c1e3ccSAndroid Build Coastguard Worker   unsigned char group_index;
75*77c1e3ccSAndroid Build Coastguard Worker   /*!
76*77c1e3ccSAndroid Build Coastguard Worker    * If current layer is key frame.
77*77c1e3ccSAndroid Build Coastguard Worker    */
78*77c1e3ccSAndroid Build Coastguard Worker   int is_key_frame;
79*77c1e3ccSAndroid Build Coastguard Worker   /*!
80*77c1e3ccSAndroid Build Coastguard Worker    * Maximum motion magnitude of previous encoded layer.
81*77c1e3ccSAndroid Build Coastguard Worker    */
82*77c1e3ccSAndroid Build Coastguard Worker   int max_mv_magnitude;
83*77c1e3ccSAndroid Build Coastguard Worker } LAYER_CONTEXT;
84*77c1e3ccSAndroid Build Coastguard Worker 
85*77c1e3ccSAndroid Build Coastguard Worker /*!
86*77c1e3ccSAndroid Build Coastguard Worker  * \brief The stucture of SVC.
87*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
88*77c1e3ccSAndroid Build Coastguard Worker  */
89*77c1e3ccSAndroid Build Coastguard Worker typedef struct SVC {
90*77c1e3ccSAndroid Build Coastguard Worker   /*!\cond */
91*77c1e3ccSAndroid Build Coastguard Worker   int spatial_layer_id;
92*77c1e3ccSAndroid Build Coastguard Worker   int temporal_layer_id;
93*77c1e3ccSAndroid Build Coastguard Worker   int number_spatial_layers;
94*77c1e3ccSAndroid Build Coastguard Worker   int number_temporal_layers;
95*77c1e3ccSAndroid Build Coastguard Worker   int prev_number_spatial_layers;
96*77c1e3ccSAndroid Build Coastguard Worker   int use_flexible_mode;
97*77c1e3ccSAndroid Build Coastguard Worker   int ksvc_fixed_mode;
98*77c1e3ccSAndroid Build Coastguard Worker   /*!\endcond */
99*77c1e3ccSAndroid Build Coastguard Worker 
100*77c1e3ccSAndroid Build Coastguard Worker   /*!\cond */
101*77c1e3ccSAndroid Build Coastguard Worker   double base_framerate;
102*77c1e3ccSAndroid Build Coastguard Worker   unsigned int current_superframe;
103*77c1e3ccSAndroid Build Coastguard Worker   int skip_mvsearch_last;
104*77c1e3ccSAndroid Build Coastguard Worker   int skip_mvsearch_gf;
105*77c1e3ccSAndroid Build Coastguard Worker   int skip_mvsearch_altref;
106*77c1e3ccSAndroid Build Coastguard Worker   int spatial_layer_fb[REF_FRAMES];
107*77c1e3ccSAndroid Build Coastguard Worker   int temporal_layer_fb[REF_FRAMES];
108*77c1e3ccSAndroid Build Coastguard Worker   int num_encoded_top_layer;
109*77c1e3ccSAndroid Build Coastguard Worker   int first_layer_denoise;
110*77c1e3ccSAndroid Build Coastguard Worker   YV12_BUFFER_CONFIG source_last_TL0;
111*77c1e3ccSAndroid Build Coastguard Worker   int mi_cols_full_resoln;
112*77c1e3ccSAndroid Build Coastguard Worker   int mi_rows_full_resoln;
113*77c1e3ccSAndroid Build Coastguard Worker   /*!\endcond */
114*77c1e3ccSAndroid Build Coastguard Worker 
115*77c1e3ccSAndroid Build Coastguard Worker   /*!
116*77c1e3ccSAndroid Build Coastguard Worker    * Layer context used for rate control in CBR mode.
117*77c1e3ccSAndroid Build Coastguard Worker    * An array. The index for spatial layer `sl` and temporal layer `tl` is
118*77c1e3ccSAndroid Build Coastguard Worker    * sl * number_temporal_layers + tl.
119*77c1e3ccSAndroid Build Coastguard Worker    */
120*77c1e3ccSAndroid Build Coastguard Worker   LAYER_CONTEXT *layer_context;
121*77c1e3ccSAndroid Build Coastguard Worker 
122*77c1e3ccSAndroid Build Coastguard Worker   /*!
123*77c1e3ccSAndroid Build Coastguard Worker    * Number of layers allocated for layer_context. If nonzero, must be greater
124*77c1e3ccSAndroid Build Coastguard Worker    * than or equal to number_spatial_layers * number_temporal_layers.
125*77c1e3ccSAndroid Build Coastguard Worker    */
126*77c1e3ccSAndroid Build Coastguard Worker   int num_allocated_layers;
127*77c1e3ccSAndroid Build Coastguard Worker 
128*77c1e3ccSAndroid Build Coastguard Worker   /*!
129*77c1e3ccSAndroid Build Coastguard Worker    * EIGHTTAP_SMOOTH or BILINEAR
130*77c1e3ccSAndroid Build Coastguard Worker    */
131*77c1e3ccSAndroid Build Coastguard Worker   InterpFilter downsample_filter_type[AOM_MAX_SS_LAYERS];
132*77c1e3ccSAndroid Build Coastguard Worker 
133*77c1e3ccSAndroid Build Coastguard Worker   /*!
134*77c1e3ccSAndroid Build Coastguard Worker    * Downsample_filter_phase: = 0 will do sub-sampling (no weighted average),
135*77c1e3ccSAndroid Build Coastguard Worker    * = 8 will center the target pixel and get a symmetric averaging filter.
136*77c1e3ccSAndroid Build Coastguard Worker    */
137*77c1e3ccSAndroid Build Coastguard Worker   int downsample_filter_phase[AOM_MAX_SS_LAYERS];
138*77c1e3ccSAndroid Build Coastguard Worker 
139*77c1e3ccSAndroid Build Coastguard Worker   /*!
140*77c1e3ccSAndroid Build Coastguard Worker    * Force zero-mv in mode search for the spatial/inter-layer reference.
141*77c1e3ccSAndroid Build Coastguard Worker    */
142*77c1e3ccSAndroid Build Coastguard Worker   int force_zero_mode_spatial_ref;
143*77c1e3ccSAndroid Build Coastguard Worker 
144*77c1e3ccSAndroid Build Coastguard Worker   /*!
145*77c1e3ccSAndroid Build Coastguard Worker    * Flag to indicate that current spatial layer has a lower quality layer
146*77c1e3ccSAndroid Build Coastguard Worker    * (at the same timestamp) that can be used as a reference.
147*77c1e3ccSAndroid Build Coastguard Worker    * Lower quality layer refers to the same resolution but encoded at
148*77c1e3ccSAndroid Build Coastguard Worker    * different/lower bitrate.
149*77c1e3ccSAndroid Build Coastguard Worker    */
150*77c1e3ccSAndroid Build Coastguard Worker   int has_lower_quality_layer;
151*77c1e3ccSAndroid Build Coastguard Worker 
152*77c1e3ccSAndroid Build Coastguard Worker   /*!
153*77c1e3ccSAndroid Build Coastguard Worker    * Flag to indicate the frame drop mode for SVC: one of the two settings:
154*77c1e3ccSAndroid Build Coastguard Worker    * AOM_LAYER_DROP (default) or AOM_FULL_SUPERFRAME_DROP.
155*77c1e3ccSAndroid Build Coastguard Worker    */
156*77c1e3ccSAndroid Build Coastguard Worker   AOM_SVC_FRAME_DROP_MODE framedrop_mode;
157*77c1e3ccSAndroid Build Coastguard Worker 
158*77c1e3ccSAndroid Build Coastguard Worker   /*!
159*77c1e3ccSAndroid Build Coastguard Worker    * Flag to indicate if frame was dropped for a given spatial_layer_id on
160*77c1e3ccSAndroid Build Coastguard Worker    * previous superframe.
161*77c1e3ccSAndroid Build Coastguard Worker    */
162*77c1e3ccSAndroid Build Coastguard Worker   bool last_layer_dropped[AOM_MAX_SS_LAYERS];
163*77c1e3ccSAndroid Build Coastguard Worker 
164*77c1e3ccSAndroid Build Coastguard Worker   /*!
165*77c1e3ccSAndroid Build Coastguard Worker    * Flag to indicate if a previous spatial was dropped for the same superframe.
166*77c1e3ccSAndroid Build Coastguard Worker    */
167*77c1e3ccSAndroid Build Coastguard Worker   bool drop_spatial_layer[AOM_MAX_SS_LAYERS];
168*77c1e3ccSAndroid Build Coastguard Worker } SVC;
169*77c1e3ccSAndroid Build Coastguard Worker 
170*77c1e3ccSAndroid Build Coastguard Worker struct AV1_COMP;
171*77c1e3ccSAndroid Build Coastguard Worker struct EncodeFrameInput;
172*77c1e3ccSAndroid Build Coastguard Worker 
173*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Initialize layer context data from init_config().
174*77c1e3ccSAndroid Build Coastguard Worker  *
175*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
176*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
177*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
178*77c1e3ccSAndroid Build Coastguard Worker  *
179*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
180*77c1e3ccSAndroid Build Coastguard Worker  *
181*77c1e3ccSAndroid Build Coastguard Worker  * \remark  Nothing returned. Set cpi->svc.
182*77c1e3ccSAndroid Build Coastguard Worker  */
183*77c1e3ccSAndroid Build Coastguard Worker void av1_init_layer_context(struct AV1_COMP *const cpi);
184*77c1e3ccSAndroid Build Coastguard Worker 
185*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Allocate layer context data.
186*77c1e3ccSAndroid Build Coastguard Worker  *
187*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
188*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
189*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
190*77c1e3ccSAndroid Build Coastguard Worker  *
191*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
192*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       num_layers  Number of layers to be allocated
193*77c1e3ccSAndroid Build Coastguard Worker  *
194*77c1e3ccSAndroid Build Coastguard Worker  * \remark  Allocates memory for cpi->svc.layer_context.
195*77c1e3ccSAndroid Build Coastguard Worker  * \return  True on success, false on allocation failure.
196*77c1e3ccSAndroid Build Coastguard Worker  */
197*77c1e3ccSAndroid Build Coastguard Worker bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers);
198*77c1e3ccSAndroid Build Coastguard Worker 
199*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Update the layer context from a change_config() call.
200*77c1e3ccSAndroid Build Coastguard Worker  *
201*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
202*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
203*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
204*77c1e3ccSAndroid Build Coastguard Worker  *
205*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
206*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       target_bandwidth  Total target bandwidth
207*77c1e3ccSAndroid Build Coastguard Worker  *
208*77c1e3ccSAndroid Build Coastguard Worker  * \remark  Nothing returned. Buffer level for each layer is set.
209*77c1e3ccSAndroid Build Coastguard Worker  */
210*77c1e3ccSAndroid Build Coastguard Worker void av1_update_layer_context_change_config(struct AV1_COMP *const cpi,
211*77c1e3ccSAndroid Build Coastguard Worker                                             const int64_t target_bandwidth);
212*77c1e3ccSAndroid Build Coastguard Worker 
213*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Prior to encoding the frame, update framerate-related quantities
214*77c1e3ccSAndroid Build Coastguard Worker           for the current temporal layer.
215*77c1e3ccSAndroid Build Coastguard Worker  *
216*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
217*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
218*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
219*77c1e3ccSAndroid Build Coastguard Worker  *
220*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
221*77c1e3ccSAndroid Build Coastguard Worker  *
222*77c1e3ccSAndroid Build Coastguard Worker  * \remark  Nothing returned. Frame related quantities for current temporal
223*77c1e3ccSAndroid Build Coastguard Worker  layer are updated.
224*77c1e3ccSAndroid Build Coastguard Worker  */
225*77c1e3ccSAndroid Build Coastguard Worker void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi);
226*77c1e3ccSAndroid Build Coastguard Worker 
227*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Prior to check if reference is lower spatial layer at the same
228*77c1e3ccSAndroid Build Coastguard Worker  *        timestamp/superframe.
229*77c1e3ccSAndroid Build Coastguard Worker  *
230*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
231*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
232*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
233*77c1e3ccSAndroid Build Coastguard Worker  *
234*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
235*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       ref_frame Reference frame
236*77c1e3ccSAndroid Build Coastguard Worker  *
237*77c1e3ccSAndroid Build Coastguard Worker  * \return  True if the ref_frame if lower spatial layer, otherwise false.
238*77c1e3ccSAndroid Build Coastguard Worker  */
239*77c1e3ccSAndroid Build Coastguard Worker bool av1_check_ref_is_low_spatial_res_super_frame(struct AV1_COMP *const cpi,
240*77c1e3ccSAndroid Build Coastguard Worker                                                   int ref_frame);
241*77c1e3ccSAndroid Build Coastguard Worker 
242*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Prior to encoding the frame, set the layer context, for the current
243*77c1e3ccSAndroid Build Coastguard Worker  layer to be encoded, to the cpi struct.
244*77c1e3ccSAndroid Build Coastguard Worker  *
245*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
246*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
247*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
248*77c1e3ccSAndroid Build Coastguard Worker  *
249*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
250*77c1e3ccSAndroid Build Coastguard Worker  *
251*77c1e3ccSAndroid Build Coastguard Worker  * \remark  Nothing returned. Layer context for current layer is set.
252*77c1e3ccSAndroid Build Coastguard Worker  */
253*77c1e3ccSAndroid Build Coastguard Worker void av1_restore_layer_context(struct AV1_COMP *const cpi);
254*77c1e3ccSAndroid Build Coastguard Worker 
255*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Save the layer context after encoding the frame.
256*77c1e3ccSAndroid Build Coastguard Worker  *
257*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
258*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
259*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
260*77c1e3ccSAndroid Build Coastguard Worker  *
261*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
262*77c1e3ccSAndroid Build Coastguard Worker  */
263*77c1e3ccSAndroid Build Coastguard Worker void av1_save_layer_context(struct AV1_COMP *const cpi);
264*77c1e3ccSAndroid Build Coastguard Worker 
265*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Free the memory used for cyclic refresh in layer context.
266*77c1e3ccSAndroid Build Coastguard Worker  *
267*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
268*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
269*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
270*77c1e3ccSAndroid Build Coastguard Worker  *
271*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
272*77c1e3ccSAndroid Build Coastguard Worker  */
273*77c1e3ccSAndroid Build Coastguard Worker void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi);
274*77c1e3ccSAndroid Build Coastguard Worker 
275*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Reset on key frame: reset counters, references and buffer updates.
276*77c1e3ccSAndroid Build Coastguard Worker  *
277*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
278*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
279*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
280*77c1e3ccSAndroid Build Coastguard Worker  *
281*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
282*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       is_key  Whether current layer is key frame
283*77c1e3ccSAndroid Build Coastguard Worker  */
284*77c1e3ccSAndroid Build Coastguard Worker void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key);
285*77c1e3ccSAndroid Build Coastguard Worker 
286*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Before encoding, set resolutions and allocate compressor data.
287*77c1e3ccSAndroid Build Coastguard Worker  *
288*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
289*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
290*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
291*77c1e3ccSAndroid Build Coastguard Worker  *
292*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
293*77c1e3ccSAndroid Build Coastguard Worker  */
294*77c1e3ccSAndroid Build Coastguard Worker void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi);
295*77c1e3ccSAndroid Build Coastguard Worker 
296*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get primary reference frame for current layer
297*77c1e3ccSAndroid Build Coastguard Worker  *
298*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
299*77c1e3ccSAndroid Build Coastguard Worker  * \callgraph
300*77c1e3ccSAndroid Build Coastguard Worker  * \callergraph
301*77c1e3ccSAndroid Build Coastguard Worker  *
302*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       cpi  Top level encoder structure
303*77c1e3ccSAndroid Build Coastguard Worker  *
304*77c1e3ccSAndroid Build Coastguard Worker  * \return  The primary reference frame for current layer.
305*77c1e3ccSAndroid Build Coastguard Worker  */
306*77c1e3ccSAndroid Build Coastguard Worker int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi);
307*77c1e3ccSAndroid Build Coastguard Worker 
308*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get resolution for current layer.
309*77c1e3ccSAndroid Build Coastguard Worker  *
310*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup SVC
311*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       width_org    Original width, unscaled
312*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       height_org   Original height, unscaled
313*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       num          Numerator for the scale ratio
314*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       den          Denominator for the scale ratio
315*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       width_out    Output width, scaled for current layer
316*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]       height_out   Output height, scaled for current layer
317*77c1e3ccSAndroid Build Coastguard Worker  *
318*77c1e3ccSAndroid Build Coastguard Worker  * \remark Nothing is returned. Instead the scaled width and height are set.
319*77c1e3ccSAndroid Build Coastguard Worker  */
320*77c1e3ccSAndroid Build Coastguard Worker void av1_get_layer_resolution(const int width_org, const int height_org,
321*77c1e3ccSAndroid Build Coastguard Worker                               const int num, const int den, int *width_out,
322*77c1e3ccSAndroid Build Coastguard Worker                               int *height_out);
323*77c1e3ccSAndroid Build Coastguard Worker 
324*77c1e3ccSAndroid Build Coastguard Worker void av1_set_svc_fixed_mode(struct AV1_COMP *const cpi);
325*77c1e3ccSAndroid Build Coastguard Worker 
326*77c1e3ccSAndroid Build Coastguard Worker void av1_svc_check_reset_layer_rc_flag(struct AV1_COMP *const cpi);
327*77c1e3ccSAndroid Build Coastguard Worker 
328*77c1e3ccSAndroid Build Coastguard Worker void av1_svc_set_last_source(struct AV1_COMP *const cpi,
329*77c1e3ccSAndroid Build Coastguard Worker                              struct EncodeFrameInput *frame_input,
330*77c1e3ccSAndroid Build Coastguard Worker                              YV12_BUFFER_CONFIG *prev_source);
331*77c1e3ccSAndroid Build Coastguard Worker 
332*77c1e3ccSAndroid Build Coastguard Worker void av1_svc_update_buffer_slot_refreshed(struct AV1_COMP *const cpi);
333*77c1e3ccSAndroid Build Coastguard Worker 
334*77c1e3ccSAndroid Build Coastguard Worker int av1_svc_get_min_ref_dist(const struct AV1_COMP *cpi);
335*77c1e3ccSAndroid Build Coastguard Worker 
336*77c1e3ccSAndroid Build Coastguard Worker void av1_svc_set_reference_was_previous(struct AV1_COMP *cpi);
337*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
338*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
339*77c1e3ccSAndroid Build Coastguard Worker #endif
340*77c1e3ccSAndroid Build Coastguard Worker 
341*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
342