1/*
2 ** Copyright 2003-2010, VisualOn, Inc.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 **     http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16
17/***********************************************************************
18*       File: scale.c                                                  *
19*                                                                      *
20*       Description: Scale signal to get maximum of dynamic            *
21*                                                                      *
22************************************************************************/
23
24#include "typedef.h"
25#include "basic_op.h"
26
27void Scale_sig(
28        Word16 x[],                           /* (i/o) : signal to scale               */
29        Word16 lg,                            /* (i)   : size of x[]                   */
30        Word16 exp                            /* (i)   : exponent: x = round(x << exp) */
31          )
32{
33    Word32 i;
34    Word32 L_tmp;
35    if(exp > 0)
36    {
37        for (i = lg - 1 ; i >= 0; i--)
38        {
39            L_tmp = L_shl2(x[i], 16 + exp);
40            x[i] = extract_h(L_add(L_tmp, 0x8000));
41        }
42    }
43    else
44    {
45        exp = -exp;
46        for (i = lg - 1; i >= 0; i--)
47        {
48            L_tmp = x[i] << 16;
49            L_tmp >>= exp;
50            x[i] = (L_tmp + 0x8000)>>16;
51        }
52    }
53    return;
54}
55
56
57
58