FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
jpeg2000dsp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 James Almer
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 #include "libavcodec/jpeg2000dsp.h"
23 #include "libavutil/common.h"
24 #include "libavutil/internal.h"
25 #include "libavutil/intreadwrite.h"
26 
27 #define BUF_SIZE 512
28 
29 #define randomize_buffers() \
30  do { \
31  int i; \
32  for (i = 0; i < BUF_SIZE*3; i++) \
33  src[i] = rnd(); \
34  } while (0)
35 
36 #define randomize_buffers_float() \
37  do { \
38  int i; \
39  for (i = 0; i < BUF_SIZE*3; i++) \
40  src[i] = (float)rnd() / (UINT_MAX >> 5); \
41  } while (0)
42 
43 static void check_rct_int(void)
44 {
48  int32_t *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0];
49  int32_t *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1];
50  int32_t *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2];
51 
52  declare_func(void, void *src0, void *src1, void *src2, int csize);
53 
55  memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
56  memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
57  call_ref(ref0, ref1, ref2, BUF_SIZE);
58  call_new(new0, new1, new2, BUF_SIZE);
59  if (memcmp(ref0, new0, BUF_SIZE * sizeof(*src)) ||
60  memcmp(ref1, new1, BUF_SIZE * sizeof(*src)) ||
61  memcmp(ref2, new2, BUF_SIZE * sizeof(*src)))
62  fail();
63  memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
64  bench_new(new0, new1, new2, BUF_SIZE);
65 }
66 
67 static void check_ict_float(void)
68 {
69  LOCAL_ALIGNED_32(float, src, [BUF_SIZE*3]);
70  LOCAL_ALIGNED_32(float, ref, [BUF_SIZE*3]);
71  LOCAL_ALIGNED_32(float, new, [BUF_SIZE*3]);
72  float *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0];
73  float *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1];
74  float *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2];
75 
76  declare_func(void, void *src0, void *src1, void *src2, int csize);
77 
79  memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
80  memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
81  call_ref(ref0, ref1, ref2, BUF_SIZE);
82  call_new(new0, new1, new2, BUF_SIZE);
83  if (!float_near_abs_eps_array(ref0, new0, 1.0e-5, BUF_SIZE) ||
84  !float_near_abs_eps_array(ref1, new1, 1.0e-5, BUF_SIZE) ||
85  !float_near_abs_eps_array(ref2, new2, 1.0e-5, BUF_SIZE))
86  fail();
87  memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
88  bench_new(new0, new1, new2, BUF_SIZE);
89 }
90 
92 {
94 
96 
97  if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
98  check_rct_int();
99  if (check_func(h.mct_decode[FF_DWT97], "jpeg2000_ict_float"))
100  check_ict_float();
101 
102  report("mct_decode");
103 }
void(* mct_decode[FF_DWT_NB])(void *src0, void *src1, void *src2, int csize)
Definition: jpeg2000dsp.h:30
#define randomize_buffers_float()
Definition: jpeg2000dsp.c:36
int float_near_abs_eps_array(const float *a, const float *b, float eps, unsigned len)
Definition: checkasm.c:308
av_cold void ff_jpeg2000dsp_init(Jpeg2000DSPContext *c)
Definition: jpeg2000dsp.c:93
#define src
Definition: vp8dsp.c:254
#define report
Definition: checkasm.h:120
static void check_ict_float(void)
Definition: jpeg2000dsp.c:67
static void check_rct_int(void)
Definition: jpeg2000dsp.c:43
#define declare_func(ret,...)
Definition: checkasm.h:112
#define fail()
Definition: checkasm.h:117
common internal API header
int32_t
#define call_ref(...)
Definition: checkasm.h:123
#define src1
Definition: h264pred.c:139
#define check_func(func,...)
Definition: checkasm.h:108
#define src0
Definition: h264pred.c:138
#define BUF_SIZE
Definition: jpeg2000dsp.c:27
#define LOCAL_ALIGNED_32(t, v,...)
Definition: internal.h:137
common internal and external API header
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
#define randomize_buffers()
Definition: jpeg2000dsp.c:29
#define bench_new(...)
Definition: checkasm.h:250
#define call_new(...)
Definition: checkasm.h:190
void checkasm_check_jpeg2000dsp(void)
Definition: jpeg2000dsp.c:91