1b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/* ------------------------------------------------------------------
2b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Copyright (C) 1998-2009 PacketVideo
3b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber *
4b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * you may not use this file except in compliance with the License.
6b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * You may obtain a copy of the License at
7b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber *
8b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber *
10b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Unless required by applicable law or agreed to in writing, software
11b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * express or implied.
14b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * See the License for the specific language governing permissions
15b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * and limitations under the License.
16b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * -------------------------------------------------------------------
17b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber */
18b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/****************************************************************************************
19b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberPortions of this file are derived from the following 3GPP standard:
20b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
21b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    3GPP TS 26.073
22b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    Available from http://www.3gpp.org
24b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
25b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberPermission to distribute, modify and use this file under the standard license
27b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huberterms listed above has been obtained from the copyright holder.
28b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber****************************************************************************************/
29b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*
30b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
31b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber INPUT AND OUTPUT DEFINITIONS
32b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
33b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Inputs:
34b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    L_var1 = 32 bit long signed integer (Word32) whose value falls
35b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber             in the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
36b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
37b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Local Stores/Buffers/Pointers Needed:
38b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    None
39b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
40b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Global Stores/Buffers/Pointers Needed:
41b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    None
42b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
43b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Outputs:
44b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    L_var1 = 32-bit negation of input
45b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
46b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Pointers and Buffers Modified:
47b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    None
48b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
49b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Local Stores Modified:
50b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    None
51b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
52b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Global Stores Modified:
53b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    None
54b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
55b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
56b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber FUNCTION DESCRIPTION
57b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
58b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber This function negates the 32 bit variable, L_var1, with saturation; saturate
59b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber in the case where input is -2147483648 (0x8000 0000).
60b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
61b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
62b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber REQUIREMENTS
63b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
64b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber None
65b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
66b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
67b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber REFERENCES
68b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
69b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber [1] basicop2.c, ETS Version 2.0.0, February 8, 1999
70b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
71b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
72b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber PSEUDO-CODE
73b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
74b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberWord32 L_negate (Word32 L_var1)
75b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber{
76b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    Word32 L_var_out;
77b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
78b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1;
79b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#if (WMOPS)
80b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    multiCounter[currCounter].L_negate++;
81b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#endif
82b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    return (L_var_out);
83b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber}
84b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
85b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
86b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber RESOURCES USED
87b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber   When the code is written for a specific target processor the
88b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber     the resources used should be documented below.
89b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
90b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber STACK USAGE: [stack count for this module] + [variable to represent
91b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber          stack usage for each subroutine called]
92b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
93b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber     where: [stack usage variable] = stack usage for [subroutine
94b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber         name] (see [filename].ext)
95b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
96b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber DATA MEMORY USED: x words
97b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
98b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber PROGRAM MEMORY USED: x words
99b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
100b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber CLOCK CYCLES: [cycle count equation for this module] + [variable
101b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber           used to represent cycle count for each subroutine
102b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber           called]
103b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
104b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber     where: [cycle count variable] = cycle count for [subroutine
105b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber        name] (see [filename].ext)
106b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
107b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------
108b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber*/
109b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
110b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
111b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
112b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; INCLUDES
113b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
114b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#include    "basic_op.h"
115b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
116b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
117b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; MACROS
118b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Define module specific macros here
119b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
120b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
121b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
122b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; DEFINES
123b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Include all pre-processor statements here. Include conditional
124b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; compile variables also.
125b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
126b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
127b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
128b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; LOCAL FUNCTION DEFINITIONS
129b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Function Prototype declaration
130b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
131b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
132b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
133b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; LOCAL STORE/BUFFER/POINTER DEFINITIONS
134b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Variable declaration - defined here and used outside this module
135b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
136b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
137b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
138b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; EXTERNAL FUNCTION REFERENCES
139b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Declare functions defined elsewhere and referenced in this module
140b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
141b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
142b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
143b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
144b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; Declare variables used in this module but defined elsewhere
145b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
146b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
147b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*----------------------------------------------------------------------------
148b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; FUNCTION CODE
149b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/
150b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberWord32 L_negate(register Word32 L_var1)
151b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber{
152b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    /*----------------------------------------------------------------------------
153b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ; Define all local variables
154b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ----------------------------------------------------------------------------*/
155b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
156b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    /*----------------------------------------------------------------------------
157b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ; Function body here
158b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ----------------------------------------------------------------------------*/
159b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    L_var1 = (L_var1 == MIN_32) ? MAX_32 : -L_var1;
160b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
161b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    /*----------------------------------------------------------------------------
162b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ; Return nothing or data or data pointer
163b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    ----------------------------------------------------------------------------*/
164b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber    return (L_var1);
165b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber}
166b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber
167