FFmpeg
Loading...
Searching...
No Matches
vf_mpdecimate.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
23
24#define STRIDE 32
25
26static void check_sad16(int depth)
27{
28 LOCAL_ALIGNED_32(uint16_t, src1, [STRIDE * 9]);
29 LOCAL_ALIGNED_32(uint16_t, src2, [STRIDE * 9]);
30 const int mask = (1 << depth) - 1;
31
32 declare_func(int, const uint8_t *src1, ptrdiff_t stride1,
33 const uint8_t *src2, ptrdiff_t stride2);
34
35 for (int i = 0; i < STRIDE * 9; i++) {
36 src1[i] = rnd() & mask;
37 src2[i] = rnd() & mask;
38 }
39 if (depth == 16) {
40 /* largest possible SAD */
41 for (int i = 0; i < STRIDE * 9; i++) {
42 src1[i] = 0;
43 src2[i] = 0xffff;
44 }
45 }
46
47 if (check_func(ff_mpdecimate_get_sad16_fn(), "sad_8x8_16_%d", depth)) {
48 /* blocks are not aligned in the filter */
49 for (int off = 0; off < 2; off++) {
50 const uint8_t *p1 = (const uint8_t *)(src1 + off * 3);
51 const uint8_t *p2 = (const uint8_t *)(src2 + off * 5);
52 int ref = call_ref(p1, STRIDE * 2, p2, STRIDE * 2);
53 int new = call_new(p1, STRIDE * 2, p2, STRIDE * 2);
54 if (ref != new) {
55 fprintf(stderr, "sad_8x8_16_%d: %d != %d\n", depth, ref, new);
56 fail();
57 }
58 }
59 bench_new((const uint8_t *)src1, STRIDE * 2,
60 (const uint8_t *)src2, STRIDE * 2);
61 }
62}
63
65{
66 static const int depths[] = { 10, 12, 15, 16 };
67
68 for (int i = 0; i < FF_ARRAY_ELEMS(depths); i++)
69 check_sad16(depths[i]);
70 report("sad_8x8_16");
71}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define rnd
Definition checkasm.h:141
#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 STRIDE
Definition cavsdsp.c:37
av_pixelutils_sad_fn ff_mpdecimate_get_sad16_fn(void)
Get the SAD function for 8x8 blocks of 16-bit samples.
static const uint16_t mask[17]
Definition lzw.c:38
#define LOCAL_ALIGNED_32(t, v,...)
#define FF_ARRAY_ELEMS(a)
#define src1
Definition h264pred.c:141
static void check_sad16(int depth)
void checkasm_check_mpdecimate(void)
static int ref[MAX_W *MAX_W]