1da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com/*
2da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
4da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  Use of this source code is governed by a BSD-style license
5da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  that can be found in the LICENSE file in the root of the source
6da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  tree. An additional intellectual property rights grant can be found
7da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  in the file PATENTS.  All contributing project authors may
8da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *  be found in the AUTHORS file in the root of the source tree.
9da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
10da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com */
11da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
12da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com#include "dl/api/omxtypes.h"
13da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com#include "dl/sp/api/x86SP.h"
14da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com#include "dl/sp/api/omxSP.h"
15da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
16da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com/**
17da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Function: omxSP_FFTGetBufSize_R_F32
18da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
19da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Description:
20da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Computes the size of the specification structure required for the length
21da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * 2^order real FFT and IFFT functions.
22da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
23da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Remarks:
24da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * This function is used in conjunction with the 32-bit functions
25da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * <FFTFwd_RToCCS_F32_Sfs> and <FFTInv_CCSToR_F32_Sfs>.
26da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
27da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Parameters:
28da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * [in]  order       base-2 logarithm of the length; valid in the range
29da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *                    [1,12]. ([1,15] if BIG_FFT_TABLE is defined.)
30da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * [out] pSize	   pointer to the number of bytes required for the
31da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *			   specification structure.
32da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
33da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Return Value:
34da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com * Standard omxError result. See enumeration for possible result codes.
35da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com *
36da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com */
37da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
38da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.comOMXResult omxSP_FFTGetBufSize_R_F32(OMX_INT order, OMX_INT *pSize) {
395fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  OMX_INT n_by_2;
405fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  OMX_INT n;
415fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org
42da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com  if (!pSize || (order < 1) || (order > TWIDDLE_TABLE_ORDER))
43da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com    return OMX_Sts_BadArgErr;
44da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
455fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  n_by_2 = 1 << (order - 1);
465fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  n = n_by_2 << 1;
47da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
485fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  *pSize = sizeof(X86FFTSpec_R_FC32) +
495fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           // Twiddle factors.
505fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           sizeof(OMX_F32) * (n << 1) +
515fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           // Ping Pong buffer for doing the n/2 point complex FFT.
525fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           // pBuf1
535fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           sizeof(OMX_F32) * n + 4 +
545fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           // pBuf2
555fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           sizeof(OMX_F32) * n + 4 +
565fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           // Extra bytes to get 32 byte alignment of ptwiddle, pBuf1
575fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org           62;
58da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com
595fedace167496de2a3d165f11fa97ca09d58b5a5turaj@webrtc.org  return OMX_Sts_NoErr;
60da04d4f8ef493ab7bf1fbdaffe206899f03681c2rtoy@google.com}
61