FFmpeg
Loading...
Searching...
No Matches
Buffer Comparison Utilities

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

Topics

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

Macros

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

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)
Value:
x __attribute__((aligned(CHECKASM_ALIGNMENT)))
static int aligned(int val)
Definition dashdec.c:178
#define CHECKASM_ALIGNMENT
Definition platform.h:55

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]);
#define CHECKASM_ALIGN(x)
Declare a variable with platform-specific alignment requirements.
Definition utils.h:486

Definition at line 486 of file utils.h.

◆ checkasm_check2d

#define checkasm_check2d ( type,
... )
Value:
checkasm_check2(type, __VA_ARGS__, 0, 0, 0)
#define checkasm_check2(type,...)
Definition utils.h:526
cl_device_type type

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");
}
}
#define checkasm_check2d(type,...)
Compare two 2D buffers and fail test if different.
Definition utils.h:560
uint8_t w
Definition llvidencdsp.c:39
#define stride
#define checkasm_call_ref(...)
Call the reference implementation.
Definition test.h:367
#define checkasm_call_new(...)
Call the implementation being tested with validation.
Definition test.h:382
#define checkasm_check_func(func,...)
Check if a function should be tested and set up function references.
Definition test.h:77

Definition at line 560 of file utils.h.

◆ checkasm_check2d_padded

#define checkasm_check2d_padded ( type,
... )
Value:
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 582 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
#define DECL_CHECK_FUNC(NAME, TYPE)
Definition utils.h:494
#define checkasm_check_impl(type)
Definition utils.h:524
ptrdiff_t _stride
const char * name
Definition qsvenc.c:142

Definition at line 683 of file utils.h.

Referenced by check_mc().

◆ CLEAR_BUF_RECT

#define CLEAR_BUF_RECT ( name)
Value:
#define CLEAR_BUF(buf)
Clear a fixed size buffer (convenience macro)
Definition utils.h:332

Clear a rectangular buffer (including padding)

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

Definition at line 701 of file utils.h.

Referenced by check_mc().

◆ INITIALIZE_BUF_RECT

#define INITIALIZE_BUF_RECT ( name)
Value:
#define INITIALIZE_BUF(buf)
Fill a fixed size buffer with pathological test data (convenience macro)
Definition utils.h:347

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

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

Definition at line 709 of file utils.h.

◆ RANDOMIZE_BUF_RECT

#define RANDOMIZE_BUF_RECT ( name)
Value:
#define RANDOMIZE_BUF(buf)
Fill a fixed size buffer with random data (convenience macro)
Definition utils.h:339

Randomize a rectangular buffer (including padding)

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

Definition at line 717 of file utils.h.

◆ checkasm_check_rect

#define checkasm_check_rect ( rect1,
... )
Value:
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 726 of file utils.h.

◆ checkasm_check_rect_padded

#define checkasm_check_rect_padded ( rect1,
... )
Value:
checkasm_check2d_padded(rect1##_type, rect1, __VA_ARGS__, 1, 1, 8)
#define checkasm_check2d_padded(type,...)
Compare two 2D buffers, including padding regions (detect over-write)
Definition utils.h:582

Compare two rectangular buffers including padding.

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

Definition at line 735 of file utils.h.

Referenced by check_mc().

◆ checkasm_check_rect_padded_align

#define checkasm_check_rect_padded_align ( rect1,
... )
Value:
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);
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define checkasm_check_rect_padded_align(rect1,...)
Compare two rectangular buffers, with custom alignment (over-write)
Definition utils.h:751
#define src
Definition vp8dsp.c:248

Definition at line 751 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)
#define checkasm_check_rect_padded(rect1,...)
Compare two rectangular buffers including padding.
Definition utils.h:735

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 763 of file utils.h.