/* * 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 /*! * \brief The stucture of quantities related to each spatial and temporal layer. * \ingroup SVC */ LAYER_CONTEXT; /*! * \brief The stucture of SVC. * \ingroup SVC */ SVC; struct AV1_COMP; struct EncodeFrameInput; /*!\brief Initialize layer context data from init_config(). * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * * \remark Nothing returned. Set cpi->svc. */ void av1_init_layer_context(struct AV1_COMP *const cpi); /*!\brief Allocate layer context data. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * \param[in] num_layers Number of layers to be allocated * * \remark Allocates memory for cpi->svc.layer_context. * \return True on success, false on allocation failure. */ bool av1_alloc_layer_context(struct AV1_COMP *cpi, int num_layers); /*!\brief Update the layer context from a change_config() call. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * \param[in] target_bandwidth Total target bandwidth * * \remark Nothing returned. Buffer level for each layer is set. */ void av1_update_layer_context_change_config(struct AV1_COMP *const cpi, const int64_t target_bandwidth); /*!\brief Prior to encoding the frame, update framerate-related quantities for the current temporal layer. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * * \remark Nothing returned. Frame related quantities for current temporal layer are updated. */ void av1_update_temporal_layer_framerate(struct AV1_COMP *const cpi); /*!\brief Prior to check if reference is lower spatial layer at the same * timestamp/superframe. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * \param[in] ref_frame Reference frame * * \return True if the ref_frame if lower spatial layer, otherwise false. */ bool av1_check_ref_is_low_spatial_res_super_frame(struct AV1_COMP *const cpi, int ref_frame); /*!\brief Prior to encoding the frame, set the layer context, for the current layer to be encoded, to the cpi struct. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * * \remark Nothing returned. Layer context for current layer is set. */ void av1_restore_layer_context(struct AV1_COMP *const cpi); /*!\brief Save the layer context after encoding the frame. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure */ void av1_save_layer_context(struct AV1_COMP *const cpi); /*!\brief Free the memory used for cyclic refresh in layer context. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure */ void av1_free_svc_cyclic_refresh(struct AV1_COMP *const cpi); /*!\brief Reset on key frame: reset counters, references and buffer updates. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * \param[in] is_key Whether current layer is key frame */ void av1_svc_reset_temporal_layers(struct AV1_COMP *const cpi, int is_key); /*!\brief Before encoding, set resolutions and allocate compressor data. * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure */ void av1_one_pass_cbr_svc_start_layer(struct AV1_COMP *const cpi); /*!\brief Get primary reference frame for current layer * * \ingroup SVC * \callgraph * \callergraph * * \param[in] cpi Top level encoder structure * * \return The primary reference frame for current layer. */ int av1_svc_primary_ref_frame(const struct AV1_COMP *const cpi); /*!\brief Get resolution for current layer. * * \ingroup SVC * \param[in] width_org Original width, unscaled * \param[in] height_org Original height, unscaled * \param[in] num Numerator for the scale ratio * \param[in] den Denominator for the scale ratio * \param[in] width_out Output width, scaled for current layer * \param[in] height_out Output height, scaled for current layer * * \remark Nothing is returned. Instead the scaled width and height are set. */ 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_