Subversion Repositories AFRtranscoder

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
#ifndef _TRANSFORM_TEMPLATES_H_
2
#define _TRANSFORM_TEMPLATES_H_
3
 
4
/*--------------------------------------------------------------------------------*/
5
/* Includes */
6
/*--------------------------------------------------------------------------------*/
7
 
8
#include "test_templates.h"
9
#include <string.h>             /* memcpy() */
10
 
11
/*--------------------------------------------------------------------------------*/
12
/* Group Specific Templates */
13
/*--------------------------------------------------------------------------------*/
14
 
15
/**
16
 * Comparison SNR thresholds for the data types used in transform_tests.
17
 */
18
#define TRANSFORM_SNR_THRESHOLD_float32_t 90
19
#define TRANSFORM_SNR_THRESHOLD_q31_t     90
20
#define TRANSFORM_SNR_THRESHOLD_q15_t     30
21
 
22
#define DCT4_TRANSFORM_SNR_THRESHOLD_float32_t 80
23
#define DCT4_TRANSFORM_SNR_THRESHOLD_q31_t     75
24
#define DCT4_TRANSFORM_SNR_THRESHOLD_q15_t     11
25
 
26
/**
27
 *  Compare the outputs from the function under test and the reference
28
 *  function using SNR.
29
 */
30
#define TRANSFORM_SNR_COMPARE_INTERFACE(block_size,     \
31
                                        output_type)    \
32
    do                                                  \
33
    {                                                   \
34
        TEST_CONVERT_AND_ASSERT_SNR(                    \
35
            transform_fft_output_f32_ref,               \
36
            (output_type *) transform_fft_output_ref,   \
37
            transform_fft_output_f32_fut,               \
38
            (output_type *) transform_fft_output_fut,   \
39
            block_size,                                 \
40
            output_type,                                \
41
            TRANSFORM_SNR_THRESHOLD_##output_type       \
42
            );                                          \
43
    } while (0)
44
 
45
/**
46
 *  Compare the outputs from the function under test and the reference
47
 *  function using SNR.
48
 */
49
#define DCT_TRANSFORM_SNR_COMPARE_INTERFACE(block_size,  \
50
                                            output_type) \
51
    do                                                   \
52
    {                                                    \
53
        TEST_CONVERT_AND_ASSERT_SNR(                     \
54
            transform_fft_output_f32_ref,                \
55
            (output_type *) transform_fft_output_ref,    \
56
            transform_fft_output_f32_fut,                \
57
            (output_type *) transform_fft_output_fut,    \
58
            block_size,                                  \
59
            output_type,                                 \
60
            DCT4_TRANSFORM_SNR_THRESHOLD_##output_type   \
61
            );                                           \
62
    } while (0)                                           \
63
 
64
/**
65
 *  Specialization on #TRANSFORM_SNR_COMPARE_INTERFACE() to fix the block_size
66
 *  for complex datasets.
67
 */
68
#define TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE(block_size, output_type)  \
69
    /* Complex numbers have two components*/                            \
70
    TRANSFORM_SNR_COMPARE_INTERFACE(block_size * 2, output_type )
71
 
72
/**
73
 * This macro copys data from the input_ptr into input arrays.
74
 *
75
 * Some functions modify their input data; in order to provide the same data to
76
 * multiple tests, copies must be made so the changes from one function don't
77
 * impact the others.
78
 */
79
#define TRANSFORM_COPY_INPUTS(input_ptr,        \
80
                              bytes)            \
81
    do                                          \
82
    {                                           \
83
        memcpy(                                 \
84
            transform_fft_input_fut,            \
85
            input_ptr,                          \
86
            bytes);                             \
87
        memcpy(                                 \
88
            transform_fft_input_ref,            \
89
            input_ptr,                          \
90
            bytes);                             \
91
    } while (0)
92
 
93
/**
94
 * This macro copys data from the input_ptr into input arrays. It also creates
95
 * symmetric input data for rfft inverse.
96
 *
97
 * The 4.534234f just makes the middle entry of the array semi random.  It's
98
 * actual value doesn't seem to matter much.
99
 *
100
 * Some functions modify their input data; in order to provide the same data to
101
 * multiple tests, copies must be made so the changes from one function don't
102
 * impact the others.
103
 */
104
#define TRANSFORM_PREPARE_INVERSE_INPUTS(input_ptr,                              \
105
                              fftlen, input_type, bytes)                         \
106
    do                                                                           \
107
    {                                                                            \
108
        uint32_t i;                                                              \
109
                                                                                 \
110
        memcpy(                                                                  \
111
            transform_fft_input_fut,                                             \
112
            input_ptr,                                                           \
113
            bytes);                                                              \
114
                                                                                 \
115
        ((input_type*)transform_fft_input_fut)[1] = 0;                           \
116
        ((input_type*)transform_fft_input_fut)[fftlen + 0] = 0;                  \
117
        ((input_type*)transform_fft_input_fut)[fftlen + 1] = 0;                  \
118
        for(i=1;i<fftlen/2;i++)                                                  \
119
        {                                                                        \
120
           *((input_type*)transform_fft_input_fut + fftlen + 2*i + 0) =          \
121
               *((input_type*)transform_fft_input_fut + fftlen - 2*i + 0);       \
122
           *((input_type*)transform_fft_input_fut + fftlen + 2*i + 1) =          \
123
               -(*((input_type*)transform_fft_input_fut + fftlen - 2*i + 1));    \
124
                                                                                 \
125
        }                                                                        \
126
                                                                                 \
127
        memcpy(                                                                  \
128
            transform_fft_input_ref,                                             \
129
            transform_fft_input_fut,                                             \
130
            bytes * 2);                                                          \
131
    } while (0)
132
 
133
/**
134
 * This macro copys data from the input_ptr into the in-place input arrays.
135
 *
136
 * Some functions modify their input data; in order to provide the same data to
137
 * multiple tests, copies must be made so the changes from one function don't
138
 * impact the others.
139
 */
140
#define TRANSFORM_PREPARE_INPLACE_INPUTS_DOWNSHIFT(input_ptr,       \
141
                                         bytes,                     \
142
                                         type)                      \
143
    do                                                              \
144
    {                                                               \
145
        uint32_t i;                                                 \
146
        memcpy(                                                     \
147
            transform_fft_inplace_input_fut,                        \
148
            input_ptr,                                              \
149
            bytes);                                                 \
150
        memcpy(                                                     \
151
            transform_fft_inplace_input_ref,                        \
152
            input_ptr,                                              \
153
            bytes);                                                 \
154
        for(i=0;i<bytes/sizeof(type);i++) {                         \
155
            *((type*)transform_fft_inplace_input_fut + i) >>= 1;    \
156
            *((type*)transform_fft_inplace_input_ref + i) >>= 1;}   \
157
    } while (0)
158
 
159
/**
160
 * This macro copys data from the input_ptr into the in-place input arrays.
161
 *
162
 * Some functions modify their input data; in order to provide the same data to
163
 * multiple tests, copies must be made so the changes from one function don't
164
 * impact the others.
165
 */
166
#define TRANSFORM_PREPARE_INPLACE_INPUTS(input_ptr, \
167
                                         bytes)     \
168
    do                                              \
169
    {                                               \
170
        memcpy(                                     \
171
            transform_fft_inplace_input_fut,        \
172
            input_ptr,                              \
173
            bytes);                                 \
174
        memcpy(                                     \
175
            transform_fft_inplace_input_ref,        \
176
            input_ptr,                              \
177
            bytes);                                 \
178
    } while (0)
179
 
180
 
181
#endif /* _TRANSFORM_TEMPLATES_H_ */