From 9f900a1c6404464edd23d2d43a3ab1f390ec8af7 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" <rbultje@google.com> Date: Thu, 22 Mar 2012 10:03:14 -0700 Subject: [PATCH] Only enable compound prediction if multiple reference frames are present. Change-Id: Ia52ac825400eb83ff663e3a05a3fe0b3526bac9a --- vp8/encoder/encodeframe.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index cf32685b0b..b9b100b8f5 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -854,6 +854,32 @@ static void encode_frame_internal(VP8_COMP *cpi) } +static int check_dual_ref_flags(VP8_COMP *cpi) +{ + MACROBLOCKD *xd = &cpi->mb.e_mbd; + int ref_flags = cpi->ref_frame_flags; + + if (segfeature_active(xd, 1, SEG_LVL_REF_FRAME)) + { + if ((ref_flags & (VP8_LAST_FLAG | VP8_GOLD_FLAG)) == (VP8_LAST_FLAG | VP8_GOLD_FLAG) && + check_segref(xd, 1, LAST_FRAME)) + return 1; + if ((ref_flags & (VP8_GOLD_FLAG | VP8_ALT_FLAG )) == (VP8_GOLD_FLAG | VP8_ALT_FLAG ) && + check_segref(xd, 1, GOLDEN_FRAME)) + return 1; + if ((ref_flags & (VP8_ALT_FLAG | VP8_LAST_FLAG)) == (VP8_ALT_FLAG | VP8_LAST_FLAG) && + check_segref(xd, 1, ALTREF_FRAME)) + return 1; + return 0; + } + else + { + return (!!(ref_flags & VP8_GOLD_FLAG) + + !!(ref_flags & VP8_LAST_FLAG) + + !!(ref_flags & VP8_ALT_FLAG) ) >= 2; + } +} + void vp8_encode_frame(VP8_COMP *cpi) { if (cpi->sf.RD) @@ -884,7 +910,8 @@ void vp8_encode_frame(VP8_COMP *cpi) if (cpi->rd_prediction_type_threshes[frame_type][1] > cpi->rd_prediction_type_threshes[frame_type][0] && cpi->rd_prediction_type_threshes[frame_type][1] > - cpi->rd_prediction_type_threshes[frame_type][2]) + cpi->rd_prediction_type_threshes[frame_type][2] && + check_dual_ref_flags(cpi)) pred_type = COMP_PREDICTION_ONLY; else if (cpi->rd_prediction_type_threshes[frame_type][0] > cpi->rd_prediction_type_threshes[frame_type][1] && -- GitLab