FFmpeg
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 "checkasm.h"
22 
23 #include "libavcodec/diracdsp.h"
24 
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/mem_internal.h"
27 
28 #define RANDOMIZE_DESTS(name, size) \
29  do { \
30  int i; \
31  for (i = 0; i < size; ++i) { \
32  uint16_t r = rnd(); \
33  AV_WN16A(name##0 + i, r); \
34  AV_WN16A(name##1 + i, r); \
35  } \
36  } while (0)
37 
38 #define RANDOMIZE_BUFFER8(name, size) \
39  do { \
40  int i; \
41  for (i = 0; i < size; ++i) { \
42  uint8_t r = rnd(); \
43  name[i] = r; \
44  } \
45  } while (0)
46 
47 #define OBMC_STRIDE 32
48 #define XBLEN_MAX 32
49 #define YBLEN_MAX 64
50 
51 static void check_add_obmc(size_t func_index, int xblen)
52 {
53  LOCAL_ALIGNED_16(uint8_t, src, [XBLEN_MAX * YBLEN_MAX]);
54  LOCAL_ALIGNED_16(uint16_t, _dst0, [XBLEN_MAX * YBLEN_MAX + 4]);
55  LOCAL_ALIGNED_16(uint16_t, _dst1, [XBLEN_MAX * YBLEN_MAX + 4]);
56  LOCAL_ALIGNED_16(uint8_t, obmc_weight, [XBLEN_MAX * YBLEN_MAX]);
57 
58  // Ensure that they accept unaligned buffer.
59  // Not using LOCAL_ALIGNED_8 because it might make 16 byte aligned buffer.
60  uint16_t *dst0 = _dst0 + 4;
61  uint16_t *dst1 = _dst1 + 4;
62 
63  int yblen;
65 
67 
68  if (check_func(h.add_dirac_obmc[func_index], "diracdsp.add_dirac_obmc_%d", xblen)) {
69  declare_func(void, uint16_t*, const uint8_t*, int, const uint8_t *, int);
70 
72  RANDOMIZE_DESTS(dst, YBLEN_MAX * xblen);
73  RANDOMIZE_BUFFER8(obmc_weight, YBLEN_MAX * OBMC_STRIDE);
74 
75  yblen = 1 + (rnd() % YBLEN_MAX);
76  call_ref(dst0, src, xblen, obmc_weight, yblen);
77  call_new(dst1, src, xblen, obmc_weight, yblen);
78  if (memcmp(dst0, dst1, yblen * xblen))
79  fail();
80 
81  bench_new(dst1, src, xblen, obmc_weight, YBLEN_MAX);
82  }
83 }
84 
86 {
87  check_add_obmc(0, 8);
88  check_add_obmc(1, 16);
89  check_add_obmc(2, 32);
90  report("diracdsp");
91 }
mem_internal.h
ff_diracdsp_init
av_cold void ff_diracdsp_init(DiracDSPContext *c)
Definition: diracdsp.c:221
RANDOMIZE_DESTS
#define RANDOMIZE_DESTS(name, size)
Definition: diracdsp.c:28
check_func
#define check_func(func,...)
Definition: checkasm.h:184
call_ref
#define call_ref(...)
Definition: checkasm.h:199
fail
#define fail()
Definition: checkasm.h:193
check_add_obmc
static void check_add_obmc(size_t func_index, int xblen)
Definition: diracdsp.c:51
checkasm.h
diracdsp.h
rnd
#define rnd()
Definition: checkasm.h:177
intreadwrite.h
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:130
call_new
#define call_new(...)
Definition: checkasm.h:302
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
OBMC_STRIDE
#define OBMC_STRIDE
Definition: diracdsp.c:47
YBLEN_MAX
#define YBLEN_MAX
Definition: diracdsp.c:49
report
#define report
Definition: checkasm.h:196
bench_new
#define bench_new(...)
Definition: checkasm.h:373
DiracDSPContext
Definition: diracdsp.h:30
checkasm_check_diracdsp
void checkasm_check_diracdsp(void)
Definition: diracdsp.c:85
XBLEN_MAX
#define XBLEN_MAX
Definition: diracdsp.c:48
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:188
h
h
Definition: vp9dsp_template.c:2070
src
#define src
Definition: vp8dsp.c:248
RANDOMIZE_BUFFER8
#define RANDOMIZE_BUFFER8(name, size)
Definition: diracdsp.c:38