Fix self-guided filter tests

Patch https://aomedia-review.googlesource.com/c/8387/ introduced
some bugs into the self-guided filter correctness test. One bug
was fixed in https://aomedia-review.googlesource.com/c/8445/ ,
but another surfaced while developing
https://aomedia-review.googlesource.com/c/8480/

This patch tidies up the relevant code to make it clearer,
and should fix the remaining bug(s).

Change-Id: I7a5957b02f0ad309aa4081c72d490d7369c8d90a
1 file changed