Refactor iteration over neighbours for OBMC
There are six pieces of code in reconinter.c and two in rdopt.c which
iterate over the blocks along the top or left edge of the current
block for OBMC. Before this patch, each bit of code has its own
implementation of the iteration, which is reasonably finicky to get
right.
This patch factors out that logic into a pair of helpers
(foreach_overlappable_nb_above and foreach_overlappable_nb_left). The
functions take a "fun" parameter, which contains the loop body. Note
that the iteration is too complicated for us to be able to define a
macro that could be used like
FOREACH_NB_ABOVE(rel_pos, nb_size, nb_mi) { ... }
While C's syntax doesn't seem to let you do that, once the compiler's
optimisation pass is done inlining everything, the results are
essentially the same.
The iteration logic is also slightly generalised: the old code checked
whether a block was shorter or narrower than 8 pixels by comparing a
block size with BLOCK_8X8. This doesn't work when you have a 4x16 or
16x4 block because e.g. BLOCK_16X4 is not less than BLOCK_8X8. This
generalisation is (unsurprisingly) needed in order to to support 16x4
or 4x16 blocks.
This patch doesn't address the CONFIG_NCOBMC functions in reconinter.c
that do prediction from right and bottom edges.
This patch shouldn't affect the generated bitstream in any way: the
code is supposed to be equivalent.
Change-Id: I9e5a116b012c18645604a7d98fb98be99697d363
diff --git a/av1/av1_common.mk b/av1/av1_common.mk
index 1b44434..560bfd4 100644
--- a/av1/av1_common.mk
+++ b/av1/av1_common.mk
@@ -118,6 +118,10 @@
AV1_COMMON_SRCS-yes += common/cfl.c
endif
+ifeq ($(CONFIG_MOTION_VAR),yes)
+AV1_COMMON_SRCS-yes += common/obmc.h
+endif
+
ifeq ($(CONFIG_PVQ),yes)
# PVQ from daala
AV1_COMMON_SRCS-yes += common/pvq.c