| AOMedia AV1 Codec

svc_layercontext.h
1/*
2 * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12#ifndef AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
13#define AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
14
15#include "aom_scale/yv12config.h"
16#include "av1/encoder/aq_cyclicrefresh.h"
17#include "av1/encoder/encoder.h"
18#include "av1/encoder/ratectrl.h"
19
20#ifdef __cplusplus
21 extern "C" {
22#endif
23
28 typedef struct {
30 RATE_CONTROL rc;
31 PRIMARY_RATE_CONTROL p_rc;
32 int framerate_factor;
33 int64_t layer_target_bitrate; // In bits per second.
34 int scaling_factor_num;
35 int scaling_factor_den;
36 int64_t target_bandwidth;
37 int64_t spatial_layer_target_bandwidth;
38 double framerate;
39 int avg_frame_size;
40 int max_q;
41 int min_q;
42 int frames_from_key_frame;
44
48 int sb_index;
52 int8_t *map;
56 int actual_num_seg1_blocks;
57
61 int actual_num_seg2_blocks;
65 int counter_encode_maxq_scene_change;
66
70 uint8_t speed;
74 unsigned char group_index;
78 int is_key_frame;
82 int max_mv_magnitude;
83} LAYER_CONTEXT;
84
89 typedef struct SVC {
91 int spatial_layer_id;
92 int temporal_layer_id;
93 int number_spatial_layers;
94 int number_temporal_layers;
95 int prev_number_spatial_layers;
96 int prev_number_temporal_layers;
97 int use_flexible_mode;
98 int ksvc_fixed_mode;
100
102 double base_framerate;
103 unsigned int current_superframe;
104 int skip_mvsearch_last;
105 int skip_mvsearch_gf;
106 int skip_mvsearch_altref;
107 int spatial_layer_fb[REF_FRAMES];
108 int temporal_layer_fb[REF_FRAMES];
109 int num_encoded_top_layer;
110 int first_layer_denoise;
111 YV12_BUFFER_CONFIG source_last_TL0;
112 int mi_cols_full_resoln;
113 int mi_rows_full_resoln;
115
121 LAYER_CONTEXT *layer_context;
122
127 int num_allocated_layers;
128
132 InterpFilter downsample_filter_type[AOM_MAX_SS_LAYERS];
133
138 int downsample_filter_phase[AOM_MAX_SS_LAYERS];
139
143 int force_zero_mode_spatial_ref;
144
151 int has_lower_quality_layer;
152
157 AOM_SVC_FRAME_DROP_MODE framedrop_mode;
158
163 bool last_layer_dropped[AOM_MAX_SS_LAYERS];
164
168 bool drop_spatial_layer[AOM_MAX_SS_LAYERS];
169} SVC;
170
171 struct AV1_COMP;
172 struct EncodeFrameInput;
173
184 void av1_init_layer_context(struct AV1_COMP *const cpi);
185
198 bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers);
199
211 void av1_update_layer_context_change_config(struct AV1_COMP *const cpi,
212 const int64_t target_bandwidth);
213
226 void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi);
227
240 bool av1_check_ref_is_low_spatial_res_super_frame(struct AV1_COMP *const cpi,
241 int ref_frame);
242
254 void av1_restore_layer_context(struct AV1_COMP *const cpi);
255
264 void av1_save_layer_context(struct AV1_COMP *const cpi);
265
274 void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi);
275
285 void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key);
286
295 void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi);
296
307 int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi);
308
321 void av1_get_layer_resolution(const int width_org, const int height_org,
322 const int num, const int den, int *width_out,
323 int *height_out);
324
325 void av1_set_svc_fixed_mode(struct AV1_COMP *const cpi);
326
327 void av1_svc_check_reset_layer_rc_flag(struct AV1_COMP *const cpi);
328
329 void av1_svc_set_last_source(struct AV1_COMP *const cpi,
330 struct EncodeFrameInput *frame_input,
331 YV12_BUFFER_CONFIG *prev_source);
332
333 void av1_svc_update_buffer_slot_refreshed(struct AV1_COMP *const cpi);
334
335 int av1_svc_get_min_ref_dist(const struct AV1_COMP *cpi);
336
337 void av1_svc_set_reference_was_previous(struct AV1_COMP *cpi);
338#ifdef __cplusplus
339} // extern "C"
340#endif
341
342#endif // AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
encoder.h
Declares top-level encoder structures and functions.
av1_svc_primary_ref_frame
int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi)
Get primary reference frame for current layer.
av1_update_temporal_layer_framerate
void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi)
Prior to encoding the frame, update framerate-related quantities for the current temporal layer.
Definition svc_layercontext.c:183
av1_svc_reset_temporal_layers
void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key)
Reset on key frame: reset counters, references and buffer updates.
Definition svc_layercontext.c:398
av1_restore_layer_context
void av1_restore_layer_context(struct AV1_COMP *const cpi)
Prior to encoding the frame, set the layer context, for the current layer to be encoded,...
Definition svc_layercontext.c:222
av1_check_ref_is_low_spatial_res_super_frame
bool av1_check_ref_is_low_spatial_res_super_frame(struct AV1_COMP *const cpi, int ref_frame)
Prior to check if reference is lower spatial layer at the same timestamp/superframe.
Definition svc_layercontext.c:212
av1_save_layer_context
void av1_save_layer_context(struct AV1_COMP *const cpi)
Save the layer context after encoding the frame.
Definition svc_layercontext.c:312
av1_alloc_layer_context
bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers)
Allocate layer context data.
Definition svc_layercontext.c:89
av1_init_layer_context
void av1_init_layer_context(struct AV1_COMP *const cpi)
Initialize layer context data from init_config().
Definition svc_layercontext.c:26
av1_free_svc_cyclic_refresh
void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi)
Free the memory used for cyclic refresh in layer context.
Definition svc_layercontext.c:386
av1_one_pass_cbr_svc_start_layer
void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi)
Before encoding, set resolutions and allocate compressor data.
Definition svc_layercontext.c:430
av1_get_layer_resolution
void av1_get_layer_resolution(const int width_org, const int height_org, const int num, const int den, int *width_out, int *height_out)
Get resolution for current layer.
Definition svc_layercontext.c:411
av1_update_layer_context_change_config
void av1_update_layer_context_change_config(struct AV1_COMP *const cpi, const int64_t target_bandwidth)
Update the layer context from a change_config() call.
Definition svc_layercontext.c:104
AOM_SVC_FRAME_DROP_MODE
AOM_SVC_FRAME_DROP_MODE
Frame drop modes for spatial/quality layer SVC.
Definition aomcx.h:1851
AOM_MAX_SS_LAYERS
#define AOM_MAX_SS_LAYERS
Definition aomcx.h:1780
AV1_COMP
Top level encoder structure.
Definition encoder.h:2896
EncodeFrameInput
Input frames and last input frame.
Definition encoder.h:3705
LAYER_CONTEXT
The stucture of quantities related to each spatial and temporal layer.
Definition svc_layercontext.h:28
LAYER_CONTEXT::actual_num_seg1_blocks
int actual_num_seg1_blocks
Definition svc_layercontext.h:56
LAYER_CONTEXT::sb_index
int sb_index
Definition svc_layercontext.h:48
LAYER_CONTEXT::counter_encode_maxq_scene_change
int counter_encode_maxq_scene_change
Definition svc_layercontext.h:65
LAYER_CONTEXT::speed
uint8_t speed
Definition svc_layercontext.h:70
LAYER_CONTEXT::actual_num_seg2_blocks
int actual_num_seg2_blocks
Definition svc_layercontext.h:61
LAYER_CONTEXT::max_mv_magnitude
int max_mv_magnitude
Definition svc_layercontext.h:82
LAYER_CONTEXT::is_key_frame
int is_key_frame
Definition svc_layercontext.h:78
LAYER_CONTEXT::group_index
unsigned char group_index
Definition svc_layercontext.h:74
LAYER_CONTEXT::map
int8_t * map
Definition svc_layercontext.h:52
PRIMARY_RATE_CONTROL
Primary Rate Control parameters and status.
Definition ratectrl.h:302
RATE_CONTROL
Rate Control parameters and status.
Definition ratectrl.h:134
SVC
The stucture of SVC.
Definition svc_layercontext.h:89
SVC::drop_spatial_layer
bool drop_spatial_layer[4]
Definition svc_layercontext.h:168
SVC::last_layer_dropped
bool last_layer_dropped[4]
Definition svc_layercontext.h:163
SVC::framedrop_mode
AOM_SVC_FRAME_DROP_MODE framedrop_mode
Definition svc_layercontext.h:157
SVC::num_allocated_layers
int num_allocated_layers
Definition svc_layercontext.h:127
SVC::force_zero_mode_spatial_ref
int force_zero_mode_spatial_ref
Definition svc_layercontext.h:143
SVC::has_lower_quality_layer
int has_lower_quality_layer
Definition svc_layercontext.h:151
SVC::layer_context
LAYER_CONTEXT * layer_context
Definition svc_layercontext.h:121
SVC::downsample_filter_type
InterpFilter downsample_filter_type[4]
Definition svc_layercontext.h:132
SVC::downsample_filter_phase
int downsample_filter_phase[4]
Definition svc_layercontext.h:138