Fix highbd_apply_temporal_filter unit test Applies the fixes in https://aomedia-review.googlesource.com/c/aom/+/209061 to high bit-depth unit tests. Change-Id: I6243197291d3bf1827115c228cce75515dd6b65b
diff --git a/test/temporal_filter_test.cc b/test/temporal_filter_test.cc index 4b43322..65a4c71 100644 --- a/test/temporal_filter_test.cc +++ b/test/temporal_filter_test.cc
@@ -495,7 +495,13 @@ for (int ii = 0; ii < plane_h; ii++) { for (int jj = 0; jj < plane_w; jj++) { src1p[jj] = rnd_.Rand16() & max_val; - src2p[jj] = rnd_.Rand16() & max_val; + // Keep each pixel of `src2_` within [-7, 7] of `src1_` so the + // window_error stays small in apply_temporal_filter. Otherwise + // scaled_error clamps to 7 regardless of other factors and masks bugs + // in subblock_mvs and subblock_mses handling. + do { + src2p[jj] = rnd_.Rand16() & max_val; + } while (abs(src2p[jj] - src1p[jj]) >= 8); } src1p += plane_stride; src2p += plane_stride2; @@ -613,13 +619,17 @@ std::unique_ptr<MACROBLOCKD> mbd(new (std::nothrow) MACROBLOCKD); ASSERT_NE(mbd, nullptr); mbd->bd = BD; + int plane_offset = 0; for (int plane = AOM_PLANE_Y; plane < num_planes; plane++) { - int plane_height = plane ? height >> subsampling_y : height; - int plane_stride = plane ? stride >> subsampling_x : stride; + int plane_height = + plane ? (height + subsampling_y) >> subsampling_y : height; + int plane_stride = + plane ? (stride + subsampling_x) >> subsampling_x : stride; frame_to_filter->buffers[plane] = - frame_to_filter->buffer_alloc + plane * plane_stride * plane_height; + frame_to_filter->buffer_alloc + plane_offset; mbd->plane[plane].subsampling_x = plane ? subsampling_x : 0; mbd->plane[plane].subsampling_y = plane ? subsampling_y : 0; + plane_offset += plane_height * plane_stride; } params_.ref_func(frame_to_filter.get(), mbd.get(), block_size, mb_row, @@ -662,17 +672,26 @@ height, color_fmt_str[color_fmt]); } else { - for (int i = 0, l = 0; i < height; i++) { - for (int j = 0; j < width; j++, l++) { - EXPECT_EQ(accumulator_ref[l], accumulator_mod[l]) - << "Error:" << k << " SSE Sum Test [" << width << "x" << height - << "] " << color_fmt_str[color_fmt] - << " C accumulator does not match optimized accumulator."; - EXPECT_EQ(count_ref[l], count_mod[l]) - << "Error:" << k << " SSE Sum Test [" << width << "x" << height - << "] " << color_fmt_str[color_fmt] - << " C count does not match optimized count."; + plane_offset = 0; + for (int plane = AOM_PLANE_Y; plane < num_planes; plane++) { + int plane_height = + plane ? (height + subsampling_y) >> subsampling_y : height; + int plane_stride = + plane ? (stride + subsampling_x) >> subsampling_x : stride; + for (int i = 0, l = 0; i < plane_height; i++) { + for (int j = 0; j < plane_stride; j++, l++) { + EXPECT_EQ(accumulator_ref[l + plane_offset], + accumulator_mod[l + plane_offset]) + << "Error:" << k << " SSE Sum Test [" << width << "x" << height + << "] " << color_fmt_str[color_fmt] + << " C accumulator does not match optimized accumulator."; + EXPECT_EQ(count_ref[l + plane_offset], count_mod[l + plane_offset]) + << "Error:" << k << " SSE Sum Test [" << width << "x" << height + << "] " << color_fmt_str[color_fmt] + << " count does not match optimized count."; + } } + plane_offset += plane_height * plane_stride; } } }