FFmpeg
Loading...
Searching...
No Matches
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"
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
35static 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) {
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;
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 }
63 }
64}
65
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}
#define STRIDE
Definition aacpsdsp.c:28
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
const pixel * src2
#define WIDTH
Definition c93.c:45
#define HEIGHT
Definition c93.c:46
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
Definition scene_sad.c:59
static const uint16_t mask[17]
Definition lzw.c:38
#define LOCAL_ALIGNED_32(t, v,...)
Scene SAD functions.
#define FF_ARRAY_ELEMS(a)
#define src1
Definition h264pred.c:141
void checkasm_check_scene_sad(void)
Definition scene_sad.c:66
#define randomize_buffers(type, buf, size, mask)
Definition scene_sad.c:27
static void check_scene_sad(int depth)
Definition scene_sad.c:35
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89