svc_layercontext.h
/*
* Copyright (c) 2019, Alliance for Open Media. All rights reserved.
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
#define AOM_AV1_ENCODER_SVC_LAYERCONTEXT_H_
#include "aom_scale/yv12config.h"
#include "av1/encoder/aq_cyclicrefresh.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/ratectrl.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
RATE_CONTROL rc;
PRIMARY_RATE_CONTROL p_rc;
int framerate_factor;
int64_t layer_target_bitrate; // In bits per second.
int scaling_factor_num;
int scaling_factor_den;
int64_t target_bandwidth;
int64_t spatial_layer_target_bandwidth;
double framerate;
int avg_frame_size;
int max_q;
int min_q;
int frames_from_key_frame;
int sb_index;
int8_t *map;
int actual_num_seg1_blocks;
int actual_num_seg2_blocks;
int counter_encode_maxq_scene_change;
uint8_t speed;
unsigned char group_index;
int is_key_frame;
int max_mv_magnitude;
} LAYER_CONTEXT;
typedef struct SVC {
int spatial_layer_id;
int temporal_layer_id;
int number_spatial_layers;
int number_temporal_layers;
int prev_number_spatial_layers;
int prev_number_temporal_layers;
int use_flexible_mode;
int ksvc_fixed_mode;
double base_framerate;
unsigned int current_superframe;
int skip_mvsearch_last;
int skip_mvsearch_gf;
int skip_mvsearch_altref;
int spatial_layer_fb[REF_FRAMES];
int temporal_layer_fb[REF_FRAMES];
int num_encoded_top_layer;
int first_layer_denoise;
YV12_BUFFER_CONFIG source_last_TL0;
LAYER_CONTEXT *layer_context;
int num_allocated_layers;
InterpFilter downsample_filter_type[AOM_MAX_SS_LAYERS];
int downsample_filter_phase[AOM_MAX_SS_LAYERS];
int force_zero_mode_spatial_ref;
int has_lower_quality_layer;
AOM_SVC_FRAME_DROP_MODE framedrop_mode;
bool last_layer_dropped[AOM_MAX_SS_LAYERS];
bool drop_spatial_layer[AOM_MAX_SS_LAYERS];
} SVC;
struct AV1_COMP;
struct EncodeFrameInput;
void av1_init_layer_context(struct AV1_COMP *const cpi);
bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers);
void av1_update_layer_context_change_config(struct AV1_COMP *const cpi,
const int64_t target_bandwidth);
void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi);
bool av1_check_ref_is_low_spatial_res_super_frame(struct AV1_COMP *const cpi,
int ref_frame);
void av1_restore_layer_context(struct AV1_COMP *const cpi);
void av1_save_layer_context(struct AV1_COMP *const cpi);
void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi);
void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key);
void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi);
int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi);
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);
void av1_set_svc_fixed_mode(struct AV1_COMP *const cpi);
void av1_svc_check_reset_layer_rc_flag(struct AV1_COMP *const cpi);
void av1_svc_set_last_source(struct AV1_COMP *const cpi,
struct EncodeFrameInput *frame_input,
YV12_BUFFER_CONFIG *prev_source);
void av1_svc_update_buffer_slot_refreshed(struct AV1_COMP *const cpi);
int av1_svc_get_min_ref_dist(const struct AV1_COMP *cpi);
void av1_svc_set_reference_was_previous(struct AV1_COMP *cpi);
#ifdef __cplusplus
} // extern "C"
#endif
#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:186
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:401
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:225
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:215
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:315
av1_alloc_layer_context
bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers)
Allocate layer context data.
Definition svc_layercontext.c:90
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:389
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:433
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:414
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:106
AOM_SVC_FRAME_DROP_MODE
AOM_SVC_FRAME_DROP_MODE
Frame drop modes for spatial/quality layer SVC.
Definition aomcx.h:1899
AOM_MAX_SS_LAYERS
#define AOM_MAX_SS_LAYERS
Definition aomcx.h:1824
AV1_COMP
Top level encoder structure.
Definition encoder.h:2897
EncodeFrameInput
Input frames and last input frame.
Definition encoder.h:3735
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:313
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:166
SVC::last_layer_dropped
bool last_layer_dropped[4]
Definition svc_layercontext.h:161
SVC::framedrop_mode
AOM_SVC_FRAME_DROP_MODE framedrop_mode
Definition svc_layercontext.h:155
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