1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_ARM_FFT_TEST_UTIL_H_ 12 #define WEBRTC_ARM_FFT_TEST_UTIL_H_ 13 14 #include <stdio.h> 15 16 #include "dl/sp/src/test/compare.h" 17 18 /* Command line options */ 19 struct Options { 20 /* 21 * Set to non-zero if test is only for real signals. This is just 22 * for printing out the correct usage message. 23 */ 24 int real_only_; 25 26 /* Debugging output level, used in test and non-test mode */ 27 int verbose_; 28 29 /* Test mode where all tests are run. */ 30 int test_mode_; 31 32 /* Run forward FFT tests (in test mode) */ 33 int do_forward_tests_; 34 35 /* Run inverse FFT tests (in test mode) */ 36 int do_inverse_tests_; 37 38 /* Minimum FFT order for test mode */ 39 int min_fft_order_; 40 41 /* Maximum FFT order for test mode */ 42 int max_fft_order_; 43 44 /* FFT Order */ 45 int fft_log_size_; 46 47 /* Forward FFT scale factor, only for for fixed-point routines */ 48 int scale_factor_; 49 50 /* Signal type to use for testing */ 51 int signal_type_; 52 53 /* Signal amplitude */ 54 float signal_value_; 55 56 /* Set if the command line options set a value for signalValue */ 57 int signal_value_given_; 58 }; 59 60 /* 61 * Information about a test that is known to fail. 62 */ 63 struct KnownTestFailures { 64 /* FFT order of the test */ 65 int fft_order_; 66 67 /* Set to non-zero for inverse FFT case. Otherwise, it's forward FFT */ 68 int is_inverse_fft_test_; 69 70 /* The test signal used */ 71 int signal_type_; 72 }; 73 74 struct TestInfo { 75 /* True if test is for real signals */ 76 int real_only_; 77 78 /* Max FFT order to be tested */ 79 int max_fft_order_; 80 81 /* Min FFT order to be tested */ 82 int min_fft_order_; 83 84 /* True if forward FFT tests should be run */ 85 int do_forward_tests_; 86 87 /* True if inverse FFT tests should be run */ 88 int do_inverse_tests_; 89 90 /* SNR threshold for forward FFT tests */ 91 float forward_threshold_; 92 93 /* SNR threshold for inverse FFT tests */ 94 float inverse_threshold_; 95 96 /* 97 * Array of known test failures. Should either be 0 or point to 98 * an array of known failures, terminated by a test case with 99 * negative fftOrder. 100 */ 101 struct KnownTestFailures* known_failures_; 102 }; 103 104 /* 105 * Set default options for the command line options. Must be called 106 * before call |processCommandLine| 107 */ 108 void SetDefaultOptions(struct Options* options, int real_only, 109 int max_fft_order); 110 111 /* 112 * Process the command line options 113 */ 114 void ProcessCommandLine(struct Options* options, int argc, char* argv[], 115 const char* summary); 116 117 /* 118 * Print command line options and their values, for debugging. 119 */ 120 void DumpOptions(FILE*, const struct Options* options); 121 122 /* 123 * Run FFT test for one case. May or may not include both forward and 124 * inverse tests. 125 */ 126 void TestOneFFT(int fft_log_size, int signal_type, float signal_value, 127 const struct TestInfo* info, const char* message); 128 129 /* 130 * Run one forward FFT test of the given size, signal type, and amplitude 131 */ 132 float RunOneForwardTest(int fft_log_size, int signal_type, 133 float signal_value, struct SnrResult* snr); 134 135 /* 136 * Run one inverse FFT test of the given size, signal type, and amplitude 137 */ 138 float RunOneInverseTest(int fft_log_size, int signal_type, 139 float signal_value, struct SnrResult* snr); 140 141 /* 142 * Run all FFT tests, as specified by |info| 143 */ 144 int RunAllTests(const struct TestInfo* info); 145 146 /* 147 * Returns the program name, for debugging. 148 */ 149 char* ProgramName(char*); 150 151 /* 152 * Return true if the specified FFT test is a known failure. 153 */ 154 int IsKnownFailure(int fft_order, int is_forward_fft, int signal_type, 155 struct KnownTestFailures* known_failures); 156 157 /* 158 * Neatly print the contents of an array to stdout. 159 */ 160 void DumpArrayReal16(const char* array_name, int count, const OMX_S16* array); 161 void DumpArrayReal32(const char* array_name, int count, const OMX_S32* array); 162 void DumpArrayComplex16(const char* array_name, int count, 163 const OMX_SC16* array); 164 void DumpArrayComplex32(const char* array_name, int count, 165 const OMX_SC32* array); 166 void DumpArrayFloat(const char* array_name, int count, const OMX_F32* array); 167 void DumpArrayComplexFloat(const char* array_name, int count, 168 const OMX_FC32* array); 169 #endif 170