From b20d0777a883b75ee443d82de52f8806aee9ede6 Mon Sep 17 00:00:00 2001
From: Wei-ting Lin <weitinglin@google.com>
Date: Mon, 15 Aug 2016 13:52:18 -0700
Subject: [PATCH] Change the B-frame coding structure.

Originally we can have a BRF right before an overlay frame (in
display order), which might be unnecessary since we already has a
quality backward reference frame (ARF).
This patch avoids such a coding structure and improves the RD
performance by 0.086% in Avg in the lowres dataset, and 0.153 in
Avg in the midres dataset.

In the lowres dataset, significant gains are obtained for the
following sequences:

mobisode2_240p: 0.563%
keiba_240p: 0.440%
bus_cif: 0.336%
soccer_cif: 0.333%

And the performance drops only in the following four video sequences:

motherdaughter_cif: 0.028%
bqsquare_240p: 0.017%
basketballpass_240p: 0.015%
bowing_cif: 0.006%

Change-Id: Ic94f648ba8e52eb0014933d484fb247610a9ae05
---
 vp10/encoder/firstpass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vp10/encoder/firstpass.c b/vp10/encoder/firstpass.c
index f705bf8fad..317b689422 100644
--- a/vp10/encoder/firstpass.c
+++ b/vp10/encoder/firstpass.c
@@ -1725,8 +1725,9 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits,
       bipred_frame_index++;
       // Check whether the next bi-predictive frame group would entirely be
       // included within the current golden frame group.
+      // In addition, we need to avoid coding a BRF right before an ARF.
       if (bipred_frame_index == 1 &&
-          (i + 1 + cur_brf_src_offset) >=
+          (i + 2 + cur_brf_src_offset) >=
               (rc->baseline_gf_interval - rc->source_alt_ref_pending)) {
         bipred_group_end = 1;
       }
-- 
GitLab