FFmpeg
Loading...
Searching...
No Matches
diracdsp.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Kyosuke Kawakami
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <string.h>
22
23#include "checkasm.h"
24
25#include "libavcodec/diracdsp.h"
26
29
30#define RANDOMIZE_DESTS(name, size) \
31 do { \
32 int i; \
33 for (i = 0; i < size; ++i) { \
34 uint16_t r = rnd(); \
35 AV_WN16A(name##0 + i, r); \
36 AV_WN16A(name##1 + i, r); \
37 } \
38 } while (0)
39
40#define RANDOMIZE_BUFFER8(name, size) \
41 do { \
42 int i; \
43 for (i = 0; i < size; ++i) { \
44 uint8_t r = rnd(); \
45 name[i] = r; \
46 } \
47 } while (0)
48
49#define OBMC_STRIDE 32
50#define XBLEN_MAX 32
51#define YBLEN_MAX 64
52
53static void check_add_obmc(size_t func_index, int xblen)
54{
56 LOCAL_ALIGNED_16(uint16_t, _dst0, [XBLEN_MAX * YBLEN_MAX + 4]);
57 LOCAL_ALIGNED_16(uint16_t, _dst1, [XBLEN_MAX * YBLEN_MAX + 4]);
58 LOCAL_ALIGNED_16(uint8_t, obmc_weight, [XBLEN_MAX * YBLEN_MAX]);
59
60 // Ensure that they accept unaligned buffer.
61 // Not using LOCAL_ALIGNED_8 because it might make 16 byte aligned buffer.
62 uint16_t *dst0 = _dst0 + 4;
63 uint16_t *dst1 = _dst1 + 4;
64
65 int yblen;
67
69
70 if (check_func(h.add_dirac_obmc[func_index], "diracdsp.add_dirac_obmc_%d", xblen)) {
71 declare_func(void, uint16_t *dst, const uint8_t *src, ptrdiff_t stride,
72 const uint8_t *obmc_weight, int yblen);
73
77
78 yblen = 1 + (rnd() % YBLEN_MAX);
79 call_ref(dst0, src, xblen, obmc_weight, yblen);
80 call_new(dst1, src, xblen, obmc_weight, yblen);
81 if (memcmp(dst0, dst1, yblen * xblen))
82 fail();
83
84 bench_new(dst1, src, xblen, obmc_weight, YBLEN_MAX);
85 }
86}
87
89{
90 check_add_obmc(0, 8);
91 check_add_obmc(1, 16);
92 check_add_obmc(2, 32);
93 report("diracdsp");
94}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define rnd
Definition checkasm.h:136
#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
av_cold void ff_diracdsp_init(DiracDSPContext *c)
Definition diracdsp.c:226
#define LOCAL_ALIGNED_16(t, v,...)
#define stride
#define OBMC_STRIDE
Definition diracdsp.c:49
#define XBLEN_MAX
Definition diracdsp.c:50
#define RANDOMIZE_DESTS(name, size)
Definition diracdsp.c:30
#define RANDOMIZE_BUFFER8(name, size)
Definition diracdsp.c:40
void checkasm_check_diracdsp(void)
Definition diracdsp.c:88
#define YBLEN_MAX
Definition diracdsp.c:51
static void check_add_obmc(size_t func_index, int xblen)
Definition diracdsp.c:53
#define src
Definition vp8dsp.c:248