pass2_strategy.c: make av1_gop_bit_allocation static This function is unused outside of this file. The 'av1_' prefix is kept as the function is referenced in other documentation and for consistency with other `av1_gop_*` functions. This also removes the duplicate declaration in gop_structure.h. Bug: aomedia:3416 Change-Id: I9f9b3bf57460b9fe816b0590e6c775d692da9442
diff --git a/av1/encoder/gop_structure.h b/av1/encoder/gop_structure.h index 4ef43a9..92380ab 100644 --- a/av1/encoder/gop_structure.h +++ b/av1/encoder/gop_structure.h
@@ -42,29 +42,6 @@ */ void av1_gop_setup_structure(struct AV1_COMP *cpi); -/*!\brief Distributes bits to frames in a group - * - *\ingroup rate_control - * - * This function decides on the allocation of bits between the different - * frames and types of frame in a GF/ARF group. - * - * \param[in] cpi Top - level encoder instance structure - * \param[in] rc Rate control data - * \param[in] gf_group GF/ARF group data structure - * \param[in] is_key_frame Indicates if the first frame in the group is - * also a key frame. - * \param[in] use_arf Are ARF frames enabled or is this a GF only - * uni-directional group. - * \param[in] gf_group_bits Bits available to be allocated. - * - * \remark No return but updates the rate control and group data structures - * to reflect the allocation of bits. - */ -void av1_gop_bit_allocation(const AV1_COMP *cpi, RATE_CONTROL *const rc, - GF_GROUP *gf_group, int is_key_frame, int use_arf, - int64_t gf_group_bits); - /*!\brief Check whether a frame in the GOP is a forward key frame * *\ingroup rate_control
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c index 4f7330f..bb3a723 100644 --- a/av1/encoder/pass2_strategy.c +++ b/av1/encoder/pass2_strategy.c
@@ -2331,6 +2331,51 @@ rc->frames_till_gf_update_due = p_rc->baseline_gf_interval; } +// #define FIXED_ARF_BITS +#ifdef FIXED_ARF_BITS +#define ARF_BITS_FRACTION 0.75 +#endif +/*!\brief Distributes bits to frames in a group + * + *\ingroup rate_control + * + * This function decides on the allocation of bits between the different + * frames and types of frame in a GF/ARF group. + * + * \param[in] cpi Top - level encoder instance structure + * \param[in] rc Rate control data + * \param[in] gf_group GF/ARF group data structure + * \param[in] is_key_frame Indicates if the first frame in the group is + * also a key frame. + * \param[in] use_arf Are ARF frames enabled or is this a GF only + * uni-directional group. + * \param[in] gf_group_bits Bits available to be allocated. + * + * \remark No return but updates the rate control and group data structures + * to reflect the allocation of bits. + */ +static void av1_gop_bit_allocation(const AV1_COMP *cpi, RATE_CONTROL *const rc, + GF_GROUP *gf_group, int is_key_frame, + int use_arf, int64_t gf_group_bits) { + PRIMARY_RATE_CONTROL *const p_rc = &cpi->ppi->p_rc; + // Calculate the extra bits to be used for boosted frame(s) +#ifdef FIXED_ARF_BITS + int gf_arf_bits = (int)(ARF_BITS_FRACTION * gf_group_bits); +#else + int gf_arf_bits = calculate_boost_bits( + p_rc->baseline_gf_interval - (rc->frames_since_key == 0), p_rc->gfu_boost, + gf_group_bits); +#endif + + gf_arf_bits = adjust_boost_bits_for_target_level(cpi, rc, gf_arf_bits, + gf_group_bits, 1); + + // Allocate bits to each of the frames in the GF group. + allocate_gf_group_bits(gf_group, p_rc, rc, gf_group_bits, gf_arf_bits, + is_key_frame, use_arf); +} +#undef ARF_BITS_FRACTION + #define MAX_GF_BOOST 5400 #define REDUCE_GF_LENGTH_THRESH 4 #define REDUCE_GF_LENGTH_TO_KEY_THRESH 9 @@ -2678,31 +2723,6 @@ } #endif // CONFIG_THREE_PASS -// #define FIXED_ARF_BITS -#ifdef FIXED_ARF_BITS -#define ARF_BITS_FRACTION 0.75 -#endif -void av1_gop_bit_allocation(const AV1_COMP *cpi, RATE_CONTROL *const rc, - GF_GROUP *gf_group, int is_key_frame, int use_arf, - int64_t gf_group_bits) { - PRIMARY_RATE_CONTROL *const p_rc = &cpi->ppi->p_rc; - // Calculate the extra bits to be used for boosted frame(s) -#ifdef FIXED_ARF_BITS - int gf_arf_bits = (int)(ARF_BITS_FRACTION * gf_group_bits); -#else - int gf_arf_bits = calculate_boost_bits( - p_rc->baseline_gf_interval - (rc->frames_since_key == 0), p_rc->gfu_boost, - gf_group_bits); -#endif - - gf_arf_bits = adjust_boost_bits_for_target_level(cpi, rc, gf_arf_bits, - gf_group_bits, 1); - - // Allocate bits to each of the frames in the GF group. - allocate_gf_group_bits(gf_group, p_rc, rc, gf_group_bits, gf_arf_bits, - is_key_frame, use_arf); -} - // Minimum % intra coding observed in first pass (1.0 = 100%) #define MIN_INTRA_LEVEL 0.25 // Minimum ratio between the % of intra coding and inter coding in the first
diff --git a/av1/encoder/pass2_strategy.h b/av1/encoder/pass2_strategy.h index 7a0a28e..99e0851 100644 --- a/av1/encoder/pass2_strategy.h +++ b/av1/encoder/pass2_strategy.h
@@ -104,29 +104,6 @@ */ void av1_twopass_postencode_update(struct AV1_COMP *cpi); -/*!\brief Distributes bits to frames in a group - * - *\ingroup rate_control - * - * This function decides on the allocation of bits between the different - * frames and types of frame in a GF/ARF group. - * - * \param[in] cpi Top - level encoder instance structure - * \param[in] rc Rate control data - * \param[in] gf_group GF/ARF group data structure - * \param[in] is_key_frame Indicates if the first frame in the group is - * also a key frame. - * \param[in] use_arf Are ARF frames enabled or is this a GF only - * uni-directional group. - * \param[in] gf_group_bits Bits available to be allocated. - * - * \remark No return but updates the rate control and group data structures - * to reflect the allocation of bits. - */ -void av1_gop_bit_allocation(const AV1_COMP *cpi, RATE_CONTROL *const rc, - GF_GROUP *gf_group, int is_key_frame, int use_arf, - int64_t gf_group_bits); - int av1_calc_arf_boost(const TWO_PASS *twopass, const TWO_PASS_FRAME *twopass_frame, const PRIMARY_RATE_CONTROL *p_rc, FRAME_INFO *frame_info,