1/*
2 *  Copyright (c) 2014 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
12#include "dl/api/omxtypes.h"
13#include "dl/sp/api/mipsSP.h"
14#include "dl/sp/api/omxSP.h"
15
16OMXResult omxSP_FFTGetBufSize_R_F32(OMX_INT order, OMX_INT* pSize) {
17  OMX_INT fft_size, offset_lut_size;
18
19  if (!pSize || (order < 1) || (order > TWIDDLE_TABLE_ORDER))
20    return OMX_Sts_BadArgErr;
21
22  /* For order larger than 4, compute Real FFT as Complex FFT of (order - 1). */
23  if (order > 4) {
24    fft_size = 1 << (order - 1);
25    offset_lut_size = (SUBTRANSFORM_CONST >> (16 - order)) | 1;
26  } else {
27    fft_size = 1 << order;
28    offset_lut_size = (SUBTRANSFORM_CONST >> (17 - order)) | 1;
29  }
30
31  *pSize = sizeof(MIPSFFTSpec_R_FC32) +
32           /* BitRev Table. */
33           sizeof(OMX_U16) * fft_size +
34           /* BitRevInv Table. */
35           sizeof(OMX_U16) * fft_size +
36           /* Offsets table. */
37           sizeof(OMX_U16) * offset_lut_size +
38           /* Twiddle table */
39           sizeof(OMX_F32) * (1 << (order - 2)) +
40           /* pBuf. */
41           sizeof(OMX_F32) * (fft_size << 1) +
42           /*
43            * Extra bytes to get 32 byte alignment of
44            * pBitRev, pBitRevInv, pOffset, pTwiddle and pBuf.
45            */
46           155;
47
48  return OMX_Sts_NoErr;
49}
50