aboutsummaryrefslogtreecommitdiffstats
path: root/libSBRdec/src/arm/env_calc_arm.cpp
blob: 8fa3718aa75ec8528aa2d617dc20457a4f655065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/********************************  Fraunhofer IIS  ***************************

                        (C) Copyright Fraunhofer IIS (2010)
                               All Rights Reserved

    Please be advised that this software and/or program delivery is
    Confidential Information of Fraunhofer and subject to and covered by the

    Fraunhofer IIS Software Evaluation Agreement
    between Google Inc. and  Fraunhofer
    effective and in full force since March 1, 2012.

    You may use this software and/or program only under the terms and
    conditions described in the above mentioned Fraunhofer IIS Software
    Evaluation Agreement. Any other and/or further use requires a separate agreement.


   $Id$
   Author(s):   Arthur Tritthart
   Description: (ARM optimised) SBR domain coding

   This software and/or program is protected by copyright law and international
   treaties. Any reproduction or distribution of this software and/or program,
   or any portion of it, may result in severe civil and criminal penalties, and
   will be prosecuted to the maximum extent possible under law.

******************************************************************************/
#ifndef INCLUSION_GUARD_CALC_ENV_ARM
#define INCLUSION_GUARD_CALC_ENV_ARM


/*!
  \brief   Compute maximal value of a complex array (re/im) of a given width
           Negative values are temporarily logically or'ed with 0xFFFFFFFF
           instead of negating the value, if the sign bit is set.
  \param   maxVal  Preset maximal value
  \param   reTmp   real input signal
  \param   imTmp   imaginary input signal
  \return  new maximal value
*/

#ifdef FUNCTION_FDK_get_maxval
__asm FIXP_DBL FDK_get_maxval (FIXP_DBL maxVal, FIXP_DBL *reTmp, FIXP_DBL *imTmp, int width )
{

  /* Register map:
     r0    maxVal
     r1    reTmp
     r2    imTmp
     r3    width
     r4    real
     r5    imag
  */
    PUSH    {r4-r5}

    MOVS    r3, r3, ASR #1
    ADC     r3, r3, #0
    BCS     FDK_get_maxval_loop_2nd_part
    BEQ     FDK_get_maxval_loop_end

FDK_get_maxval_loop
    LDR     r4, [r1], #4
    LDR     r5, [r2], #4
    EOR     r4, r4, r4, ASR #31
    EOR     r5, r5, r5, ASR #31
    ORR     r0, r0, r4
    ORR     r0, r0, r5

FDK_get_maxval_loop_2nd_part
    LDR     r4, [r1], #4
    LDR     r5, [r2], #4
    EOR     r4, r4, r4, ASR #31
    EOR     r5, r5, r5, ASR #31
    ORR     r0, r0, r4
    ORR     r0, r0, r5

    SUBS    r3, r3, #1
    BNE     FDK_get_maxval_loop

FDK_get_maxval_loop_end
    POP     {r4-r5}
    BX      lr
}
#endif /* FUNCTION_FDK_get_maxval */

#endif /* INCLUSION_GUARD_CALC_ENV_ARM */