FFmpeg
tests
checkasm
scene_sad.c
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
*/
18
19
#include "
checkasm.h
"
20
#include "
libavfilter/scene_sad.h
"
21
#include "
libavutil/mem_internal.h
"
22
23
#define WIDTH 256
24
#define HEIGHT 256
25
#define STRIDE WIDTH
26
27
#define randomize_buffers(type, buf, size, mask) \
28
do { \
29
int j; \
30
type *tmp_buf = (type *) buf; \
31
for (j = 0; j < size; j++) \
32
tmp_buf[j] = rnd() & mask; \
33
} while (0)
34
35
static
void
check_scene_sad
(
int
depth)
36
{
37
LOCAL_ALIGNED_32
(uint8_t,
src1
, [
WIDTH
*
HEIGHT
* 2]);
38
LOCAL_ALIGNED_32
(uint8_t,
src2
, [
WIDTH
*
HEIGHT
* 2]);
39
declare_func
(
void
,
const
uint8_t *
src1
, ptrdiff_t stride1,
40
const
uint8_t *
src2
, ptrdiff_t stride2,
41
ptrdiff_t
width
, ptrdiff_t
height
, uint64_t *sum);
42
43
const
int
width
=
WIDTH
>> (depth > 8);
44
int
mask
= (1 << depth) - 1;
45
if
(depth <= 8) {
46
randomize_buffers
(uint8_t,
src1
,
width
*
HEIGHT
,
mask
);
47
randomize_buffers
(uint8_t,
src2
,
width
*
HEIGHT
,
mask
);
48
}
else
if
(depth <= 16) {
49
randomize_buffers
(uint16_t,
src1
,
width
*
HEIGHT
,
mask
);
50
randomize_buffers
(uint16_t,
src2
,
width
*
HEIGHT
,
mask
);
51
}
52
53
if
(
check_func
(
ff_scene_sad_get_fn
(depth),
"scene_sad%d"
, depth)) {
54
uint64_t sum1, sum2;
55
call_ref
(
src1
,
STRIDE
,
src2
,
STRIDE
,
width
,
HEIGHT
, &sum1);
56
call_new
(
src1
,
STRIDE
,
src2
,
STRIDE
,
width
,
HEIGHT
, &sum2);
57
if
(sum1 != sum2) {
58
fprintf(stderr,
"scene_sad%d: sum mismatch: %llu != %llu\n"
,
59
depth, (
unsigned
long
long
) sum1, (
unsigned
long
long
) sum2);
60
fail
();
61
}
62
bench_new
(
src1
,
STRIDE
,
src2
,
STRIDE
,
WIDTH
,
HEIGHT
, &sum2);
63
}
64
}
65
66
void
checkasm_check_scene_sad
(
void
)
67
{
68
const
int
depths[] = { 8, 10, 12, 14, 15, 16 };
69
for
(
int
i
= 0;
i
<
FF_ARRAY_ELEMS
(depths);
i
++) {
70
check_scene_sad
(depths[
i
]);
71
report
(
"scene_sad%d"
, depths[
i
]);
72
}
73
}
mem_internal.h
src1
const pixel * src1
Definition:
h264pred_template.c:420
mask
int mask
Definition:
mediacodecdec_common.c:154
check_func
#define check_func(func,...)
Definition:
checkasm.h:190
call_ref
#define call_ref(...)
Definition:
checkasm.h:205
fail
#define fail()
Definition:
checkasm.h:199
checkasm.h
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition:
sinewin_tablegen.c:29
checkasm_check_scene_sad
void checkasm_check_scene_sad(void)
Definition:
scene_sad.c:66
call_new
#define call_new(...)
Definition:
checkasm.h:308
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition:
mem_internal.h:132
STRIDE
#define STRIDE
Definition:
scene_sad.c:25
scene_sad.h
check_scene_sad
static void check_scene_sad(int depth)
Definition:
scene_sad.c:35
height
#define height
Definition:
dsp.h:89
report
#define report
Definition:
checkasm.h:202
bench_new
#define bench_new(...)
Definition:
checkasm.h:379
i
#define i(width, name, range_min, range_max)
Definition:
cbs_h2645.c:256
src2
const pixel * src2
Definition:
h264pred_template.c:421
HEIGHT
#define HEIGHT
Definition:
scene_sad.c:24
randomize_buffers
#define randomize_buffers(type, buf, size, mask)
Definition:
scene_sad.c:27
ff_scene_sad_get_fn
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
Definition:
scene_sad.c:59
WIDTH
#define WIDTH
Definition:
scene_sad.c:23
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:194
width
#define width
Definition:
dsp.h:89
Generated on Mon Aug 4 2025 19:22:52 for FFmpeg by
1.8.17