ref: 459905b93f6bd3cdd4f4bb4820475f90ec5f49fe
parent: e65f9e8bcef72711133b1ef7109856c9de05e8d1
author: Jingning Han <jingning@google.com>
date: Fri Sep 21 04:24:24 EDT 2018
Rework is_compound_allowed logic at encoder Allow the encoder to fully utilize the decoder's capability to handle both 1 fwd + 2 bwd case and 2 fwd + 1 bw case. Change-Id: I3f984d52552ddb701b80b042d979f8fe09dd3a80
--- a/vp9/common/vp9_pred_common.c
+++ b/vp9/common/vp9_pred_common.c
@@ -13,6 +13,14 @@
#include "vp9/common/vp9_pred_common.h"
#include "vp9/common/vp9_seg_common.h"
+int vp9_compound_reference_allowed(const VP9_COMMON *cm) {
+ int i;
+ for (i = 1; i < REFS_PER_FRAME; ++i)
+ if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) return 1;
+
+ return 0;
+}
+
void vp9_setup_compound_reference_mode(VP9_COMMON *cm) {
if (cm->ref_frame_sign_bias[LAST_FRAME] ==
cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -145,6 +145,8 @@
return cm->fc->single_ref_prob[vp9_get_pred_context_single_ref_p2(xd)][1];
}
+int vp9_compound_reference_allowed(const VP9_COMMON *cm);
+
void vp9_setup_compound_reference_mode(VP9_COMMON *cm);
// Returns a context number for the given MB prediction signal
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -45,14 +45,6 @@
#define MAX_VP9_HEADER_SIZE 80
-static int is_compound_reference_allowed(const VP9_COMMON *cm) {
- int i;
- for (i = 1; i < REFS_PER_FRAME; ++i)
- if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) return 1;
-
- return 0;
-}
-
static int read_is_valid(const uint8_t *start, size_t len, const uint8_t *end) {
return len != 0 && len <= (size_t)(end - start);
}
@@ -100,7 +92,7 @@
static REFERENCE_MODE read_frame_reference_mode(const VP9_COMMON *cm,
vpx_reader *r) {
- if (is_compound_reference_allowed(cm)) {
+ if (vp9_compound_reference_allowed(cm)) {
return vpx_read_bit(r)
? (vpx_read_bit(r) ? REFERENCE_MODE_SELECT : COMPOUND_REFERENCE)
: SINGLE_REFERENCE;
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -5480,14 +5480,11 @@
// side behavior is where the ALT ref buffer has opposite sign bias to
// the other two.
if (!frame_is_intra_only(cm)) {
- if ((cm->ref_frame_sign_bias[ALTREF_FRAME] ==
- cm->ref_frame_sign_bias[GOLDEN_FRAME]) ||
- (cm->ref_frame_sign_bias[ALTREF_FRAME] ==
- cm->ref_frame_sign_bias[LAST_FRAME])) {
- cpi->allow_comp_inter_inter = 0;
- } else {
+ if (vp9_compound_reference_allowed(cm)) {
cpi->allow_comp_inter_inter = 1;
vp9_setup_compound_reference_mode(cm);
+ } else {
+ cpi->allow_comp_inter_inter = 0;
}
}