diff options
author | Martin Storsjö <martin@martin.st> | 2021-05-13 09:33:21 +0300 |
---|---|---|
committer | Jean-Baptiste Kempf <jb@videolan.org> | 2021-05-13 11:49:02 +0300 |
commit | 3aac025204602810c5bf33cbad6ac1bf157487cc (patch) | |
tree | 54bcb2f2c39f7e4d0377f51c5bdbc952ed89a214 /tests | |
parent | 1cf1b309bb2c40e25582f2ace6917d84e45f354b (diff) |
arm64: filmgrain16: Guard against out of range pixels in the gather function
In 16 bpc, the pixels are 16 bit integers, but valid pixels only
are up to 12 bits, and the scaling buffer only contains 4096
elements.
The src pixels are, normally, supposed to be valid pixels, but when
processing blocks of 32 pixels at a time, it can operate on
uninitialized pixels past the right edge.
Before: Cortex A53 A72 A73 Apple M1
fgy_32x32xn_16bpc_neon: 10372.5 8194.4 8612.1 24.2
After:
fgy_32x32xn_16bpc_neon: 10837.9 8469.5 8885.1 24.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/checkasm/filmgrain.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/checkasm/filmgrain.c b/tests/checkasm/filmgrain.c index eadf2ad..3db2f61 100644 --- a/tests/checkasm/filmgrain.c +++ b/tests/checkasm/filmgrain.c @@ -183,10 +183,6 @@ static void check_fgy_sbrow(const Dav1dFilmGrainDSPContext *const dsp) { generate_scaling(bitdepth_from_max(bitdepth_max), fg_data[0].y_points, fg_data[0].num_y_points, scaling); - for (int y = 0; y < 32; y++) - for (int x = 0; x < 128; x++) - src[y * PXSTRIDE(stride) + x] = rnd() & bitdepth_max; - fg_data[0].clip_to_restricted_range = rnd() & 1; fg_data[0].scaling_shift = (rnd() & 3) + 8; for (fg_data[0].overlap_flag = 0; fg_data[0].overlap_flag <= 1; @@ -204,6 +200,14 @@ static void check_fgy_sbrow(const Dav1dFilmGrainDSPContext *const dsp) { row_num = rnd() & 0x7ff; } + for (int y = 0; y < 32; y++) { + // Src pixels past the right edge can be uninitialized + for (int x = 0; x < 128; x++) + src[y * PXSTRIDE(stride) + x] = rnd(); + for (int x = 0; x < w; x++) + src[y * PXSTRIDE(stride) + x] &= bitdepth_max; + } + CLEAR_PIXEL_RECT(c_dst); CLEAR_PIXEL_RECT(a_dst); call_ref(c_dst, src, stride, fg_data, w, scaling, grain_lut, h, @@ -275,12 +279,6 @@ static void check_fguv_sbrow(const Dav1dFilmGrainDSPContext *const dsp) { dsp->generate_grain_uv[layout_idx](grain_lut[1], grain_lut[0], fg_data, uv_pl HIGHBD_TAIL_SUFFIX); - for (int y = 0; y < 32; y++) - for (int x = 0; x < 128; x++) - src[y * PXSTRIDE(stride) + x] = rnd() & bitdepth_max; - for (int y = 0; y < 32; y++) - for (int x = 0; x < 128; x++) - luma_src[y * PXSTRIDE(lstride) + x] = rnd() & bitdepth_max; if (csfl) { fg_data[0].num_y_points = 2 + (rnd() % 13); const int pad = 0xff / fg_data[0].num_y_points; @@ -325,6 +323,18 @@ static void check_fguv_sbrow(const Dav1dFilmGrainDSPContext *const dsp) { row_num = rnd() & 0x7ff; } + for (int y = 0; y < 32; y++) { + // Src pixels past the right edge can be uninitialized + for (int x = 0; x < 128; x++) { + src[y * PXSTRIDE(stride) + x] = rnd(); + luma_src[y * PXSTRIDE(lstride) + x] = rnd(); + } + for (int x = 0; x < w; x++) + src[y * PXSTRIDE(stride) + x] &= bitdepth_max; + for (int x = 0; x < (w << ss_x); x++) + luma_src[y * PXSTRIDE(lstride) + x] &= bitdepth_max; + } + CLEAR_PIXEL_RECT(c_dst); CLEAR_PIXEL_RECT(a_dst); call_ref(c_dst, src, stride, fg_data, w, scaling, grain_lut[1], h, |