Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/Source/platform/audio/android/FFTFrameOpenMAXDLAndroid.cpp

Issue 2803733002: Convert ASSERT(foo) to DCHECK(foo) in platform/audio (Closed)
Patch Set: Mechanical change from ASSERT(foo) to DCHECK(foo) Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* Copyright (C) 2013 Google Inc. All rights reserved. 1 /* Copyright (C) 2013 Google Inc. All rights reserved.
2 * 2 *
3 * Redistribution and use in source and binary forms, with or without 3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions 4 * modification, are permitted provided that the following conditions
5 * are met: 5 * are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void FFTFrame::cleanup() {} 85 void FFTFrame::cleanup() {}
86 86
87 FFTFrame::~FFTFrame() { 87 FFTFrame::~FFTFrame() {
88 if (m_forwardContext) 88 if (m_forwardContext)
89 free(m_forwardContext); 89 free(m_forwardContext);
90 if (m_inverseContext) 90 if (m_inverseContext)
91 free(m_inverseContext); 91 free(m_inverseContext);
92 } 92 }
93 93
94 void FFTFrame::doFFT(const float* data) { 94 void FFTFrame::doFFT(const float* data) {
95 ASSERT(m_forwardContext); 95 DCHECK(m_forwardContext);
96 96
97 if (m_forwardContext) { 97 if (m_forwardContext) {
98 AudioFloatArray complexFFT(m_FFTSize + 2); 98 AudioFloatArray complexFFT(m_FFTSize + 2);
99 99
100 omxSP_FFTFwd_RToCCS_F32(data, complexFFT.data(), m_forwardContext); 100 omxSP_FFTFwd_RToCCS_F32(data, complexFFT.data(), m_forwardContext);
101 101
102 unsigned len = m_FFTSize / 2; 102 unsigned len = m_FFTSize / 2;
103 103
104 // Split FFT data into real and imaginary arrays. 104 // Split FFT data into real and imaginary arrays.
105 const float* c = complexFFT.data(); 105 const float* c = complexFFT.data();
106 float* real = m_realData.data(); 106 float* real = m_realData.data();
107 float* imag = m_imagData.data(); 107 float* imag = m_imagData.data();
108 for (unsigned k = 1; k < len; ++k) { 108 for (unsigned k = 1; k < len; ++k) {
109 int index = 2 * k; 109 int index = 2 * k;
110 real[k] = c[index]; 110 real[k] = c[index];
111 imag[k] = c[index + 1]; 111 imag[k] = c[index + 1];
112 } 112 }
113 real[0] = c[0]; 113 real[0] = c[0];
114 imag[0] = c[m_FFTSize]; 114 imag[0] = c[m_FFTSize];
115 } 115 }
116 } 116 }
117 117
118 void FFTFrame::doInverseFFT(float* data) { 118 void FFTFrame::doInverseFFT(float* data) {
119 ASSERT(m_inverseContext); 119 DCHECK(m_inverseContext);
120 120
121 if (m_inverseContext) { 121 if (m_inverseContext) {
122 AudioFloatArray fftDataArray(m_FFTSize + 2); 122 AudioFloatArray fftDataArray(m_FFTSize + 2);
123 123
124 unsigned len = m_FFTSize / 2; 124 unsigned len = m_FFTSize / 2;
125 125
126 // Pack the real and imaginary data into the complex array format 126 // Pack the real and imaginary data into the complex array format
127 float* fftData = fftDataArray.data(); 127 float* fftData = fftDataArray.data();
128 const float* real = m_realData.data(); 128 const float* real = m_realData.data();
129 const float* imag = m_imagData.data(); 129 const float* imag = m_imagData.data();
130 for (unsigned k = 1; k < len; ++k) { 130 for (unsigned k = 1; k < len; ++k) {
131 int index = 2 * k; 131 int index = 2 * k;
132 fftData[index] = real[k]; 132 fftData[index] = real[k];
133 fftData[index + 1] = imag[k]; 133 fftData[index + 1] = imag[k];
134 } 134 }
135 fftData[0] = real[0]; 135 fftData[0] = real[0];
136 fftData[1] = 0; 136 fftData[1] = 0;
137 fftData[m_FFTSize] = imag[0]; 137 fftData[m_FFTSize] = imag[0];
138 fftData[m_FFTSize + 1] = 0; 138 fftData[m_FFTSize + 1] = 0;
139 139
140 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); 140 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext);
141 } 141 }
142 } 142 }
143 143
144 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { 144 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) {
145 ASSERT(log2FFTSize); 145 DCHECK(log2FFTSize);
146 ASSERT(log2FFTSize <= kMaxFFTPow2Size); 146 ASSERT(log2FFTSize <= kMaxFFTPow2Size);
147 int bufSize; 147 int bufSize;
148 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); 148 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize);
149 149
150 if (status == OMX_Sts_NoErr) { 150 if (status == OMX_Sts_NoErr) {
151 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize)); 151 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize));
152 omxSP_FFTInit_R_F32(context, log2FFTSize); 152 omxSP_FFTInit_R_F32(context, log2FFTSize);
153 return context; 153 return context;
154 } 154 }
155 155
156 return nullptr; 156 return nullptr;
157 } 157 }
158 158
159 } // namespace blink 159 } // namespace blink
160 160
161 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) 161 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698