[FFmpeg-devel] [PATCH v2 3/3] checkasm: add hevc_deblock tests

Martin Storsjö martin at martin.st
Fri Aug 6 00:33:21 EEST 2021


On Thu, 5 Aug 2021, J. Dekker wrote:

> Signed-off-by: J. Dekker <jdek at itanimul.li>
> ---
> tests/checkasm/Makefile       |   2 +-
> tests/checkasm/checkasm.c     |   1 +
> tests/checkasm/checkasm.h     |   1 +
> tests/checkasm/hevc_deblock.c | 126 ++++++++++++++++++++++++++++++++++
> tests/fate/checkasm.mak       |   1 +
> 5 files changed, 130 insertions(+), 1 deletion(-)
> create mode 100644 tests/checkasm/hevc_deblock.c
>
> new file mode 100644
> index 0000000000..98f612921b
> --- /dev/null
> +++ b/tests/checkasm/hevc_deblock.c
> @@ -0,0 +1,126 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include <string.h>
> +
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/mem_internal.h"
> +
> +#include "libavcodec/avcodec.h"
> +#include "libavcodec/hevcdsp.h"
> +
> +#include "checkasm.h"
> +
> +static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
> +
> +#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
> +#define BUF_STRIDE (8 * 2)
> +#define BUF_LINES (8)
> +#define BUF_OFFSET (BUF_STRIDE * BUF_LINES)
> +#define BUF_SIZE (BUF_STRIDE * BUF_LINES + BUF_OFFSET * 2)
> +
> +#define randomize_buffers(buf0, buf1, size)                 \
> +    do {                                                    \
> +        uint32_t mask = pixel_mask[(bit_depth - 8) >> 1];   \
> +        int k;                                              \
> +        for (k = 0; k < size; k += 4) {                     \
> +            uint32_t r = rnd() & mask;                      \
> +            AV_WN32A(buf0 + k, r);                          \
> +            AV_WN32A(buf1 + k, r);                          \

Plain random input is pretty bad test data for deblocking, since it 
doesn't actually trigger the deblocking in most cases. To make it actually 
do the deblocking, the pixels across the edge need to have the right 
properties.

Have a look at how the vp9dsp checkasm test initializes its buffers, to 
make sure that one run actually triggers all cases once (d0+d3 >= beta, 
strong filtering, normal filtering).

(For vp9, it initializes all possible cases in one buffer, but you can 
also iterate and run the test multiple times with different input 
patterns.)

// Martin



More information about the ffmpeg-devel mailing list