Simplify a condition in av1_get_spatial_seg_pred.
Given that get_segment_id() returns a nonnegative value, one can show
that prev_u < 0 || prev_l < 0 is equivalent to prev_ul < 0. Therefore
we can simplify the condition prev_ul < 0 || prev_u < 0 || prev_l < 0
to prev_ul < 0.
BUG=aomedia:2327
Change-Id: Ica8f3a001bf104c010c2adf42d2945c83e0e01e3
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index 1d69ef0..d9b30a9 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -59,9 +59,13 @@
prev_l = get_segment_id(cm, cm->cur_frame->seg_map, BLOCK_4X4, mi_row - 0,
mi_col - 1);
}
+ // This property follows from the fact that get_segment_id() returns a
+ // nonnegative value. This allows us to test for all edge cases with a simple
+ // prev_ul < 0 check.
+ assert(IMPLIES(prev_ul >= 0, prev_u >= 0 && prev_l >= 0));
// Pick CDF index based on number of matching/out-of-bounds segment IDs.
- if (prev_ul < 0 || prev_u < 0 || prev_l < 0) /* Edge case */
+ if (prev_ul < 0) /* Edge cases */
*cdf_index = 0;
else if ((prev_ul == prev_u) && (prev_ul == prev_l))
*cdf_index = 2;