Commit 76332aa8 authored by Romain Vimont's avatar Romain Vimont Committed by Romain Vimont

Avoid negative block offset in setup_mvref_list()

The code was inspired by libaom, which calls scan_blk_mbmi()
unconditionally:
<https://aomedia.googlesource.com/aom/+/9a7e8768d39793963725da754e61d8115e2404d0/av1/common/mvref_common.c#490>
<https://aomedia.googlesource.com/aom/+/9a7e8768d39793963725da754e61d8115e2404d0/av1/common/mvref_common.c#549>

However, the boundaries are checked in the implementation of
scan_blk_mbmi():
<https://aomedia.googlesource.com/aom/+/9a7e8768d39793963725da754e61d8115e2404d0/av1/common/mvref_common.c#251>

Check that the given offset will not make the resulting block offsets
negative (and wrap).

Fixes <https://github.com/xiph/rav1e/issues/1103>.
parent 1b33845c
...@@ -2533,7 +2533,7 @@ impl ContextWriter { ...@@ -2533,7 +2533,7 @@ impl ContextWriter {
&mut newmv_count, bsize, is_compound); &mut newmv_count, bsize, is_compound);
col_match |= found_match; col_match |= found_match;
} }
if has_tr(bo, bsize) { if has_tr(bo, bsize) && bo.y > 0 {
let found_match = self.scan_blk_mbmi(bo.with_offset(target_n4_w as isize, -1), ref_frames, mv_stack, let found_match = self.scan_blk_mbmi(bo.with_offset(target_n4_w as isize, -1), ref_frames, mv_stack,
&mut newmv_count, is_compound); &mut newmv_count, is_compound);
row_match |= found_match; row_match |= found_match;
...@@ -2546,7 +2546,7 @@ impl ContextWriter { ...@@ -2546,7 +2546,7 @@ impl ContextWriter {
/* Scan the second outer area. */ /* Scan the second outer area. */
let mut far_newmv_count: usize = 0; // won't be used let mut far_newmv_count: usize = 0; // won't be used
let found_match = self.scan_blk_mbmi( let found_match = bo.x > 0 && bo.y > 0 && self.scan_blk_mbmi(
bo.with_offset(-1, -1), ref_frames, mv_stack, &mut far_newmv_count, is_compound bo.with_offset(-1, -1), ref_frames, mv_stack, &mut far_newmv_count, is_compound
); );
row_match |= found_match; row_match |= found_match;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment