FFmpeg
Modules | Macros
Buffer Comparison Utilities

Functions and macros for comparing multi-dimensional buffers. More...

Modules

 Internal Implementation Details
 Internal functions and structures not part of the public API.
 

Macros

#define CHECKASM_ALIGN(x)   x __attribute__((aligned(CHECKASM_ALIGNMENT)))
 Declare a variable with platform-specific alignment requirements. More...
 
#define checkasm_check2d(type, ...)   checkasm_check2(type, __VA_ARGS__, 0, 0, 0)
 Compare two 2D buffers and fail test if different. More...
 
#define checkasm_check2d_padded(type, ...)   checkasm_check2(type, __VA_ARGS__)
 Compare two 2D buffers, including padding regions (detect over-write) More...
 
#define BUF_RECT(type, name, w, h)
 
#define CLEAR_BUF_RECT(name)   CLEAR_BUF(name##_buf)
 Clear a rectangular buffer (including padding) More...
 
#define INITIALIZE_BUF_RECT(name)   INITIALIZE_BUF(name##_buf)
 Initialize a rectangular buffer (including padding) with pathological values. More...
 
#define RANDOMIZE_BUF_RECT(name)   RANDOMIZE_BUF(name##_buf)
 Randomize a rectangular buffer (including padding) More...
 
#define checkasm_check_rect(rect1, ...)   checkasm_check2d(rect1##_type, rect1, __VA_ARGS__)
 Compare two rectangular buffers. More...
 
#define checkasm_check_rect_padded(rect1, ...)   checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 1, 1, 8)
 Compare two rectangular buffers including padding. More...
 
#define checkasm_check_rect_padded_align(rect1, ...)   checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 8)
 Compare two rectangular buffers, with custom alignment (over-write) More...
 
#define CHECK_BUF_RECT(buf1, buf2, w, h)
 Compare two rectangular buffers (convenience macro) More...
 

Detailed Description

Functions and macros for comparing multi-dimensional buffers.

These utilities compare 2D buffers (with stride support) and detect differences, including in padding regions. Used to verify that optimized implementations produce bit-identical output to reference implementations.

Macro Definition Documentation

◆ CHECKASM_ALIGN

#define CHECKASM_ALIGN (   x)    x __attribute__((aligned(CHECKASM_ALIGNMENT)))

Declare a variable with platform-specific alignment requirements.

Parameters
xVariable declaration
Note
This must be applied to each buffer individually!
// correct
CHECKASM_ALIGN(uint8_t buf1[64*64]);
CHECKASM_ALIGN(uint8_t buf2[64*64]);
// wrong
CHECKASM_ALIGN(uint8_t buf1[64*64], buf2[64*64]);

Definition at line 408 of file utils.h.

◆ checkasm_check2d

#define checkasm_check2d (   type,
  ... 
)    checkasm_check2(type, __VA_ARGS__, 0, 0, 0)

Compare two 2D buffers and fail test if different.

Parameters
typeElement type (e.g., uint8_t, int, float)
buf1First buffer pointer to compare
stride1First buffer stride in bytes
buf2Second buffer pointer to compare
stride2Second buffer stride in bytes
wWidth of the buffers in elements
hHeight of the buffers in lines
nameName of the buffer (for error reporting)
...Extra parameters (e.g. max_ulp for checkasm_check2d(float_ulp, ...))
Note
This will automatically print a hexdump of the differing regions on failure, if verbose mode is enabled.
CHECKASM_ALIGN(uint8_t buf1[64][64]);
CHECKASM_ALIGN(uint8_t buf2[64][64]);
const ptrdiff_t stride = sizeof(buf1[0]);
for (int h = 8; h <= 64; h <<= 1) {
for (int w = 8; w <= 64; w <<= 1) {
if (checkasm_check_func(..., "myfunc_%dx%d", w, h)) {
checkasm_call_ref(buf1, strude, w, h);
checkasm_call_new(buf2, strude, w, h);
checkasm_check2d(uint8_t, buf1, stride, buf2, stride, w, h, "buffer");
}
}

Definition at line 482 of file utils.h.

◆ checkasm_check2d_padded

#define checkasm_check2d_padded (   type,
  ... 
)    checkasm_check2(type, __VA_ARGS__)

Compare two 2D buffers, including padding regions (detect over-write)

Parameters
typeElement type (e.g., uint8_t, int, float)
buf1First buffer pointer to compare
stride1First buffer stride in bytes
buf2Second buffer pointer to compare
stride2Second buffer stride in bytes
wWidth of the buffers in elements
hHeight of the buffers in lines
nameName of the buffer (for error reporting)
...Extra parameters (e.g. max_ulp for checkasm_check2d_padded(float_ulp, ...))
align_wHorizontal alignment of the allowed over-write (elements)
align_hVertical alignment of the allowed over-write (lines), or 0 to disable top/bottom overwrite checks.
paddingNumber of extra elements/lines of padding to check (past the alignment boundaries)
See also
checkasm_check2d(), checkasm_check_rect_padded()

Definition at line 504 of file utils.h.

◆ BUF_RECT

#define BUF_RECT (   type,
  name,
  w,
  h 
)
Value:
DECL_CHECK_FUNC(*checkasm_check_impl_##name##_type, type) \
= checkasm_check_impl_##type; \
CHECKASM_ALIGN(type name##_buf[((h) + 32) * (CHECKASM_ROUND(w, 64) + 64) + 64]); \
const int name##_buf_w = CHECKASM_ROUND(w, 64) + 64; \
const int name##_buf_h = (h) + 32; \
ptrdiff_t name##_stride = sizeof(type) * name##_buf_w; \
(void) checkasm_check_impl(name##_type); \
(void) name##_stride; \
(void) name##_buf_h; \
type *name = name##_buf + name##_buf_w * 16 + 64

Definition at line 605 of file utils.h.

◆ CLEAR_BUF_RECT

#define CLEAR_BUF_RECT (   name)    CLEAR_BUF(name##_buf)

Clear a rectangular buffer (including padding)

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_clear()

Definition at line 623 of file utils.h.

◆ INITIALIZE_BUF_RECT

#define INITIALIZE_BUF_RECT (   name)    INITIALIZE_BUF(name##_buf)

Initialize a rectangular buffer (including padding) with pathological values.

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_init()

Definition at line 631 of file utils.h.

◆ RANDOMIZE_BUF_RECT

#define RANDOMIZE_BUF_RECT (   name)    RANDOMIZE_BUF(name##_buf)

Randomize a rectangular buffer (including padding)

Parameters
nameBuffer name (from BUF_RECT)
See also
checkasm_randomize()

Definition at line 639 of file utils.h.

◆ checkasm_check_rect

#define checkasm_check_rect (   rect1,
  ... 
)    checkasm_check2d(rect1##_type, rect1, __VA_ARGS__)

Compare two rectangular buffers.

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name
See also
checkasm_check2d()

Definition at line 648 of file utils.h.

◆ checkasm_check_rect_padded

#define checkasm_check_rect_padded (   rect1,
  ... 
)    checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 1, 1, 8)

Compare two rectangular buffers including padding.

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name
See also
checkasm_check2d()

Definition at line 657 of file utils.h.

◆ checkasm_check_rect_padded_align

#define checkasm_check_rect_padded_align (   rect1,
  ... 
)    checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 8)

Compare two rectangular buffers, with custom alignment (over-write)

Parameters
rect1First buffer (from BUF_RECT)
...rect2, stride2, w, h, name, align
See also
checkasm_check2d_padded()
// Code is allowed to over-write up to 16 elements on the right edge only
checkasm_check_rect_padded_align(src, src_stride, dst, dst_stride, w, h,
"buffer", 16, 1);

Definition at line 673 of file utils.h.

◆ CHECK_BUF_RECT

#define CHECK_BUF_RECT (   buf1,
  buf2,
  w,
  h 
)
Value:
checkasm_check_rect_padded(buf1, buf1##_stride, buf2, buf2##_stride, w, h, \
#buf1 " vs " #buf2)

Compare two rectangular buffers (convenience macro)

Parameters
buf1First buffer (from BUF_RECT)
buf2Second buffer (from BUF_RECT)
wWidth of the usable buffer region
hHeight of the usable buffer region
See also
checkasm_check_rect_padded()

Definition at line 685 of file utils.h.

checkasm_check_impl
#define checkasm_check_impl(type)
Definition: utils.h:446
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
checkasm_check_func
#define checkasm_check_func(func,...)
Check if a function should be tested and set up function references.
Definition: test.h:77
CHECKASM_ALIGN
#define CHECKASM_ALIGN(x)
Declare a variable with platform-specific alignment requirements.
Definition: utils.h:408
_stride
ptrdiff_t _stride
Definition: h264pred_template.c:411
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
DECL_CHECK_FUNC
#define DECL_CHECK_FUNC(NAME, TYPE)
Definition: utils.h:416
checkasm_check_rect_padded
#define checkasm_check_rect_padded(rect1,...)
Compare two rectangular buffers including padding.
Definition: utils.h:657
checkasm_call_ref
#define checkasm_call_ref(...)
Call the reference implementation.
Definition: test.h:366
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
checkasm_check2d
#define checkasm_check2d(type,...)
Compare two 2D buffers and fail test if different.
Definition: utils.h:482
w
uint8_t w
Definition: llvidencdsp.c:39
checkasm_call_new
#define checkasm_call_new(...)
Call the implementation being tested with validation.
Definition: test.h:381
checkasm_check_rect_padded_align
#define checkasm_check_rect_padded_align(rect1,...)
Compare two rectangular buffers, with custom alignment (over-write)
Definition: utils.h:673
h
h
Definition: vp9dsp_template.c:2070
stride
#define stride
Definition: h264pred_template.c:536
src
#define src
Definition: vp8dsp.c:248