Files
platform-external-webrtc/webrtc/common_audio/real_fourier_openmax.cc
henrikg 91d6edef35 Add RTC_ prefix to (D)CHECKs and related macros.
We must remove dependency on Chromium, i.e. we can't use Chromium's base/logging.h. That means we need to define these macros in WebRTC also when doing Chromium builds. And this causes redefinition.

Alternative solutions:
* Check if we already have defined e.g. CHECK, and don't define them in that case. This makes us depend on include order in Chromium, which is not acceptable.
* Don't allow using the macros in WebRTC headers. Error prone since if someone adds it there by mistake it may compile fine, but later break if a header in added or order is changed in Chromium. That will be confusing and hard to enforce.
* Ensure that headers that are included by an embedder don't include our macros. This would require some heavy refactoring to be maintainable and enforcable.
* Changes in Chromium for this is obviously not an option.

BUG=chromium:468375
NOTRY=true

Review URL: https://codereview.webrtc.org/1335923002

Cr-Commit-Position: refs/heads/master@{#9964}
2015-09-17 07:24:51 +00:00

70 lines
2.0 KiB
C++

/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/common_audio/real_fourier_openmax.h"
#include <cstdlib>
#include "dl/sp/api/omxSP.h"
#include "webrtc/base/checks.h"
namespace webrtc {
using std::complex;
namespace {
// Creates and initializes the Openmax state. Transfers ownership to caller.
OMXFFTSpec_R_F32* CreateOpenmaxState(int order) {
RTC_CHECK_GE(order, 1);
// The omx implementation uses this macro to check order validity.
RTC_CHECK_LE(order, TWIDDLE_TABLE_ORDER);
OMX_INT buffer_size;
OMXResult r = omxSP_FFTGetBufSize_R_F32(order, &buffer_size);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
OMXFFTSpec_R_F32* omx_spec = malloc(buffer_size);
RTC_DCHECK(omx_spec);
r = omxSP_FFTInit_R_F32(omx_spec, order);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
return omx_spec;
}
} // namespace
RealFourierOpenmax::RealFourierOpenmax(int fft_order)
: order_(fft_order),
omx_spec_(CreateOpenmaxState(order_)) {
}
RealFourierOpenmax::~RealFourierOpenmax() {
free(omx_spec_);
}
void RealFourierOpenmax::Forward(const float* src, complex<float>* dest) const {
// This cast is well-defined since C++11. See "Non-static data members" at:
// http://en.cppreference.com/w/cpp/numeric/complex
OMXResult r =
omxSP_FFTFwd_RToCCS_F32(src, reinterpret_cast<OMX_F32*>(dest), omx_spec_);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
}
void RealFourierOpenmax::Inverse(const complex<float>* src, float* dest) const {
OMXResult r =
omxSP_FFTInv_CCSToR_F32(reinterpret_cast<const OMX_F32*>(src), dest,
omx_spec_);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
}
} // namespace webrtc