FFmpeg
fdctdsp.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 <string.h>
20 
21 #include "checkasm.h"
22 
23 #include "libavcodec/avcodec.h"
24 #include "libavcodec/fdctdsp.h"
25 
26 #include "libavutil/common.h"
27 #include "libavutil/internal.h"
28 #include "libavutil/mem_internal.h"
29 
30 static int int16_cmp_off_by_n(const int16_t *ref, const int16_t *test, size_t n, int accuracy)
31 {
32  for (size_t i = 0; i < n; i++) {
33  if (abs(ref[i] - test[i]) > accuracy)
34  return 1;
35  }
36  return 0;
37 }
38 
39 static void check_fdct(void)
40 {
41  LOCAL_ALIGNED_16(int16_t, block0, [64]);
42  LOCAL_ALIGNED_16(int16_t, block1, [64]);
43 
44  AVCodecContext avctx = {
46  .dct_algo = FF_DCT_AUTO,
47  };
49 
50  ff_fdctdsp_init(&h, &avctx);
51 
52  if (check_func(h.fdct, "fdct")) {
53  declare_func(void, int16_t *);
54  for (int i = 0; i < 64; i++) {
55  uint8_t r = rnd();
56  block0[i] = r;
57  block1[i] = r;
58  }
59  call_ref(block0);
61  if (int16_cmp_off_by_n(block0, block1, 64, 2))
62  fail();
64  }
65 }
66 
68 {
69  check_fdct();
70  report("fdctdsp");
71 }
checkasm_check_fdctdsp
void checkasm_check_fdctdsp(void)
Definition: fdctdsp.c:67
r
const char * r
Definition: vf_curves.c:127
mem_internal.h
check_fdct
static void check_fdct(void)
Definition: fdctdsp.c:39
check_func
#define check_func(func,...)
Definition: checkasm.h:177
test
Definition: idctdsp.c:35
call_ref
#define call_ref(...)
Definition: checkasm.h:192
FDCTDSPContext
Definition: fdctdsp.h:28
fail
#define fail()
Definition: checkasm.h:186
checkasm.h
rnd
#define rnd()
Definition: checkasm.h:170
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:150
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1575
call_new
#define call_new(...)
Definition: checkasm.h:295
abs
#define abs(x)
Definition: cuda_runtime.h:35
int16_cmp_off_by_n
static int int16_cmp_off_by_n(const int16_t *ref, const int16_t *test, size_t n, int accuracy)
Definition: fdctdsp.c:30
block1
static int16_t block1[64]
Definition: dct.c:120
report
#define report
Definition: checkasm.h:189
bench_new
#define bench_new(...)
Definition: checkasm.h:366
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ff_fdctdsp_init
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
Definition: fdctdsp.c:25
internal.h
common.h
fdctdsp.h
avcodec.h
AVCodecContext
main external API structure.
Definition: avcodec.h:445
FF_DCT_AUTO
#define FF_DCT_AUTO
Definition: avcodec.h:1535
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:181
h
h
Definition: vp9dsp_template.c:2038