From ae7d53202e70b943c3a2abe928bfe8233a6c355a Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 27 Aug 2018 16:17:29 -0700 Subject: Assign target bits for multi-layer ARF system Keep the ARF and P frame rate allocation distribution. All the intermediate ARFs are treated same as regular P frames. Change-Id: I7807b8e6a8f19b6e1b09b9b7d119b3c88ef90b67 --- vp9/encoder/vp9_firstpass.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'vp9/encoder') diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 38e1d37cc..2c36e06ee 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2369,7 +2369,7 @@ static void find_arf_order(GF_GROUP *gf_group, int *layer_depth, find_arf_order(gf_group, layer_depth, index_counter, depth + 1, mid + 1, end); } -static void define_gf_group_structure(VP9_COMP *cpi) { +static int define_gf_group_structure(VP9_COMP *cpi) { RATE_CONTROL *const rc = &cpi->rc; TWO_PASS *const twopass = &cpi->twopass; GF_GROUP *const gf_group = &twopass->gf_group; @@ -2444,7 +2444,7 @@ static void define_gf_group_structure(VP9_COMP *cpi) { (void)layer_depth; - return; + return frame_index; } // Note index of the first normal inter frame int eh group (not gf kf arf) @@ -2494,6 +2494,8 @@ static void define_gf_group_structure(VP9_COMP *cpi) { // Note whether multi-arf was enabled this group for next time. cpi->multi_arf_last_grp_enabled = cpi->multi_arf_enabled; + + return frame_index; } static void allocate_gf_multi_arf_bits(VP9_COMP *cpi, int64_t gf_group_bits, @@ -2664,7 +2666,7 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, double this_frame_score = 1.0; // Define the GF structure and specify - define_gf_group_structure(cpi); + int gop_frames = define_gf_group_structure(cpi); key_frame = cpi->common.frame_type == KEY_FRAME; @@ -2702,6 +2704,27 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits, else normal_frame_bits = (int)total_group_bits; + if (cpi->multi_layer_arf) { + int idx; + target_frame_size = normal_frame_bits; + target_frame_size = + clamp(target_frame_size, 0, VPXMIN(max_bits, (int)total_group_bits)); + + for (idx = frame_index; idx < gop_frames; ++idx) { + if (gf_group->update_type[idx] == USE_BUF_FRAME) + gf_group->bit_allocation[idx] = 0; + else + gf_group->bit_allocation[idx] = target_frame_size; + } + gf_group->bit_allocation[idx] = 0; + + for (idx = 0; idx < gop_frames; ++idx) + if (gf_group->update_type[idx] == LF_UPDATE) break; + gf_group->first_inter_index = idx; + + return; + } + if (oxcf->vbr_corpus_complexity) { av_score = get_distribution_av_err(cpi, twopass); tot_norm_frame_score = calculate_group_score(cpi, av_score, normal_frames); -- cgit v1.2.3