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_GOP_STRUCTURE_H_ 13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_GOP_STRUCTURE_H_ 14*77c1e3ccSAndroid Build Coastguard Worker 15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h" 16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/ratectrl.h" 17*77c1e3ccSAndroid Build Coastguard Worker 18*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 19*77c1e3ccSAndroid Build Coastguard Worker extern "C" { 20*77c1e3ccSAndroid Build Coastguard Worker #endif 21*77c1e3ccSAndroid Build Coastguard Worker /*!\cond */ 22*77c1e3ccSAndroid Build Coastguard Worker struct AV1_COMP; 23*77c1e3ccSAndroid Build Coastguard Worker struct EncodeFrameParams; 24*77c1e3ccSAndroid Build Coastguard Worker 25*77c1e3ccSAndroid Build Coastguard Worker #define MIN_ARF_GF_BOOST 240 26*77c1e3ccSAndroid Build Coastguard Worker #define NORMAL_BOOST 100 27*77c1e3ccSAndroid Build Coastguard Worker 28*77c1e3ccSAndroid Build Coastguard Worker /*!\endcond */ 29*77c1e3ccSAndroid Build Coastguard Worker 30*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Set up the Group-Of-Pictures structure for this GF_GROUP. 31*77c1e3ccSAndroid Build Coastguard Worker * 32*77c1e3ccSAndroid Build Coastguard Worker *\ingroup rate_control 33*77c1e3ccSAndroid Build Coastguard Worker * 34*77c1e3ccSAndroid Build Coastguard Worker * This function defines the Group-Of-Pictures structure for this GF_GROUP. 35*77c1e3ccSAndroid Build Coastguard Worker * This involves deciding where to place the various FRAME_UPDATE_TYPEs in 36*77c1e3ccSAndroid Build Coastguard Worker * the group. It does this primarily by updateing entries in 37*77c1e3ccSAndroid Build Coastguard Worker * cpi->twopass.gf_group.update_type[]. 38*77c1e3ccSAndroid Build Coastguard Worker * 39*77c1e3ccSAndroid Build Coastguard Worker * \param[in] cpi Top - level encoder instance structure 40*77c1e3ccSAndroid Build Coastguard Worker * 41*77c1e3ccSAndroid Build Coastguard Worker * \remark No return value but this function updates group data structures. 42*77c1e3ccSAndroid Build Coastguard Worker */ 43*77c1e3ccSAndroid Build Coastguard Worker void av1_gop_setup_structure(struct AV1_COMP *cpi); 44*77c1e3ccSAndroid Build Coastguard Worker 45*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Distributes bits to frames in a group 46*77c1e3ccSAndroid Build Coastguard Worker * 47*77c1e3ccSAndroid Build Coastguard Worker *\ingroup rate_control 48*77c1e3ccSAndroid Build Coastguard Worker * 49*77c1e3ccSAndroid Build Coastguard Worker * This function decides on the allocation of bits between the different 50*77c1e3ccSAndroid Build Coastguard Worker * frames and types of frame in a GF/ARF group. 51*77c1e3ccSAndroid Build Coastguard Worker * 52*77c1e3ccSAndroid Build Coastguard Worker * \param[in] cpi Top - level encoder instance structure 53*77c1e3ccSAndroid Build Coastguard Worker * \param[in] rc Rate control data 54*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_group GF/ARF group data structure 55*77c1e3ccSAndroid Build Coastguard Worker * \param[in] is_key_frame Indicates if the first frame in the group is 56*77c1e3ccSAndroid Build Coastguard Worker * also a key frame. 57*77c1e3ccSAndroid Build Coastguard Worker * \param[in] use_arf Are ARF frames enabled or is this a GF only 58*77c1e3ccSAndroid Build Coastguard Worker * uni-directional group. 59*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_group_bits Bits available to be allocated. 60*77c1e3ccSAndroid Build Coastguard Worker * 61*77c1e3ccSAndroid Build Coastguard Worker * \remark No return but updates the rate control and group data structures 62*77c1e3ccSAndroid Build Coastguard Worker * to reflect the allocation of bits. 63*77c1e3ccSAndroid Build Coastguard Worker */ 64*77c1e3ccSAndroid Build Coastguard Worker void av1_gop_bit_allocation(const AV1_COMP *cpi, RATE_CONTROL *const rc, 65*77c1e3ccSAndroid Build Coastguard Worker GF_GROUP *gf_group, int is_key_frame, int use_arf, 66*77c1e3ccSAndroid Build Coastguard Worker int64_t gf_group_bits); 67*77c1e3ccSAndroid Build Coastguard Worker 68*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Check whether a frame in the GOP is a forward key frame 69*77c1e3ccSAndroid Build Coastguard Worker * 70*77c1e3ccSAndroid Build Coastguard Worker *\ingroup rate_control 71*77c1e3ccSAndroid Build Coastguard Worker * 72*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_group GF/ARF group data structure 73*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_frame_index GOP index 74*77c1e3ccSAndroid Build Coastguard Worker * 75*77c1e3ccSAndroid Build Coastguard Worker * \return Return 1 if it is a forward key frame, otherwise return 0 76*77c1e3ccSAndroid Build Coastguard Worker */ 77*77c1e3ccSAndroid Build Coastguard Worker int av1_gop_check_forward_keyframe(const GF_GROUP *gf_group, 78*77c1e3ccSAndroid Build Coastguard Worker int gf_frame_index); 79*77c1e3ccSAndroid Build Coastguard Worker 80*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Check whether a frame in the GOP is the second arf 81*77c1e3ccSAndroid Build Coastguard Worker * 82*77c1e3ccSAndroid Build Coastguard Worker *\ingroup rate_control 83*77c1e3ccSAndroid Build Coastguard Worker * 84*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_group GF/ARF group data structure 85*77c1e3ccSAndroid Build Coastguard Worker * \param[in] gf_frame_index GOP index 86*77c1e3ccSAndroid Build Coastguard Worker * 87*77c1e3ccSAndroid Build Coastguard Worker * \return Return 1 if it is the second arf 88*77c1e3ccSAndroid Build Coastguard Worker */ 89*77c1e3ccSAndroid Build Coastguard Worker int av1_gop_is_second_arf(const GF_GROUP *gf_group, int gf_frame_index); 90*77c1e3ccSAndroid Build Coastguard Worker 91*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 92*77c1e3ccSAndroid Build Coastguard Worker } // extern "C" 93*77c1e3ccSAndroid Build Coastguard Worker #endif 94*77c1e3ccSAndroid Build Coastguard Worker 95*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_ENCODER_GOP_STRUCTURE_H_ 96