| AOMedia AV1 Codec

svc_layercontext.h
1/*
2 * Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
12#define AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
13
14#include "aom_scale/yv12config.h"
15#include "av1/encoder/aq_cyclicrefresh.h"
16#include "av1/encoder/encoder.h"
17#include "av1/encoder/ratectrl.h"
18
19#ifdef __cplusplus
20 extern "C" {
21#endif
22
27 typedef struct {
29 RATE_CONTROL rc;
30 PRIMARY_RATE_CONTROL p_rc;
31 int framerate_factor;
32 int64_t layer_target_bitrate; // In bits per second.
33 int scaling_factor_num;
34 int scaling_factor_den;
35 int64_t target_bandwidth;
36 int64_t spatial_layer_target_bandwidth;
37 double framerate;
38 int avg_frame_size;
39 int max_q;
40 int min_q;
41 int frames_from_key_frame;
47 int sb_index;
51 int8_t *map;
55 int actual_num_seg1_blocks;
56
60 int actual_num_seg2_blocks;
64 int counter_encode_maxq_scene_change;
65
69 uint8_t speed;
73 unsigned char group_index;
77 int is_key_frame;
81 int max_mv_magnitude;
82} LAYER_CONTEXT;
83
88 typedef struct SVC {
90 int spatial_layer_id;
91 int temporal_layer_id;
92 int number_spatial_layers;
93 int number_temporal_layers;
94 int prev_number_spatial_layers;
95 int use_flexible_mode;
96 int ksvc_fixed_mode;
100 double base_framerate;
101 unsigned int current_superframe;
102 int skip_mvsearch_last;
103 int skip_mvsearch_gf;
104 int skip_mvsearch_altref;
105 int spatial_layer_fb[REF_FRAMES];
106 int temporal_layer_fb[REF_FRAMES];
107 int num_encoded_top_layer;
108 int first_layer_denoise;
109 YV12_BUFFER_CONFIG source_last_TL0;
110 int mi_cols_full_resoln;
111 int mi_rows_full_resoln;
119 LAYER_CONTEXT *layer_context;
120
125 int num_allocated_layers;
126
130 InterpFilter downsample_filter_type[AOM_MAX_SS_LAYERS];
131
136 int downsample_filter_phase[AOM_MAX_SS_LAYERS];
137
141 int force_zero_mode_spatial_ref;
142
149 int has_lower_quality_layer;
150} SVC;
151
152 struct AV1_COMP;
153 struct EncodeFrameInput;
154
165 void av1_init_layer_context(struct AV1_COMP *const cpi);
166
179 bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers);
180
192 void av1_update_layer_context_change_config(struct AV1_COMP *const cpi,
193 const int64_t target_bandwidth);
194
207 void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi);
208
220 void av1_restore_layer_context(struct AV1_COMP *const cpi);
221
230 void av1_save_layer_context(struct AV1_COMP *const cpi);
231
240 void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi);
241
251 void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key);
252
261 void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi);
262
273 int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi);
274
287 void av1_get_layer_resolution(const int width_org, const int height_org,
288 const int num, const int den, int *width_out,
289 int *height_out);
290
291 void av1_set_svc_fixed_mode(struct AV1_COMP *const cpi);
292
293 void av1_svc_check_reset_layer_rc_flag(struct AV1_COMP *const cpi);
294
295 void av1_svc_set_last_source(struct AV1_COMP *const cpi,
296 struct EncodeFrameInput *frame_input,
297 YV12_BUFFER_CONFIG *prev_source);
298
299 void av1_svc_update_buffer_slot_refreshed(struct AV1_COMP *const cpi);
300
301 int av1_svc_get_min_ref_dist(const struct AV1_COMP *cpi);
302
303 void av1_svc_set_reference_was_previous(struct AV1_COMP *cpi);
304#ifdef __cplusplus
305} // extern "C"
306#endif
307
308#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:180
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:371
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: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:292
av1_alloc_layer_context
bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers)
Allocate layer context data.
Definition svc_layercontext.c:86
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:25
SVC
struct SVC SVC
The stucture of SVC.
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:359
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:398
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:384
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:101
AOM_MAX_SS_LAYERS
#define AOM_MAX_SS_LAYERS
Definition aomcx.h:1657
AV1_COMP
Top level encoder structure.
Definition encoder.h:2872
EncodeFrameInput
Input frames and last input frame.
Definition encoder.h:3661
LAYER_CONTEXT
The stucture of quantities related to each spatial and temporal layer.
Definition svc_layercontext.h:27
LAYER_CONTEXT::actual_num_seg1_blocks
int actual_num_seg1_blocks
Definition svc_layercontext.h:55
LAYER_CONTEXT::sb_index
int sb_index
Definition svc_layercontext.h:47
LAYER_CONTEXT::counter_encode_maxq_scene_change
int counter_encode_maxq_scene_change
Definition svc_layercontext.h:64
LAYER_CONTEXT::speed
uint8_t speed
Definition svc_layercontext.h:69
LAYER_CONTEXT::actual_num_seg2_blocks
int actual_num_seg2_blocks
Definition svc_layercontext.h:60
LAYER_CONTEXT::max_mv_magnitude
int max_mv_magnitude
Definition svc_layercontext.h:81
LAYER_CONTEXT::is_key_frame
int is_key_frame
Definition svc_layercontext.h:77
LAYER_CONTEXT::group_index
unsigned char group_index
Definition svc_layercontext.h:73
LAYER_CONTEXT::map
int8_t * map
Definition svc_layercontext.h:51
PRIMARY_RATE_CONTROL
Primary Rate Control parameters and status.
Definition ratectrl.h:288
RATE_CONTROL
Rate Control parameters and status.
Definition ratectrl.h:134
SVC
The stucture of SVC.
Definition svc_layercontext.h:88
SVC::num_allocated_layers
int num_allocated_layers
Definition svc_layercontext.h:125
SVC::force_zero_mode_spatial_ref
int force_zero_mode_spatial_ref
Definition svc_layercontext.h:141
SVC::has_lower_quality_layer
int has_lower_quality_layer
Definition svc_layercontext.h:149
SVC::layer_context
LAYER_CONTEXT * layer_context
Definition svc_layercontext.h:119
SVC::downsample_filter_type
InterpFilter downsample_filter_type[4]
Definition svc_layercontext.h:130
SVC::downsample_filter_phase
int downsample_filter_phase[4]
Definition svc_layercontext.h:136
yv12_buffer_config
YV12 frame buffer data structure.
Definition yv12config.h:44