sipxmedialib  Version 3.3
MpDspUtilsShift.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2007 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 // Author: Alexander Chemeris <Alexander DOT Chemeris AT SIPez DOT com>
12 
13 #ifndef _MpDspUtilsShift_h_
14 #define _MpDspUtilsShift_h_
15 
23 /* ============================ INLINE METHODS ============================ */
24 
25 void MpDspUtils::shl16_I(int32_t &a, unsigned scale)
26 {
27  a = shl16(a, scale);
28 }
29 
30 int32_t MpDspUtils::shl16(int32_t a, unsigned scale)
31 {
32  const int32_t thresold = INT16_MAX>>scale;
33  return (a>=thresold) ? INT16_MAX :
34  a<-thresold ? -INT16_MAX :
35  a<<scale;
36 }
37 
38 void MpDspUtils::shl32_I(int32_t &a, unsigned scale)
39 {
40  a = shl32(a, scale);
41 }
42 
43 int32_t MpDspUtils::shl32(int32_t a, unsigned scale)
44 {
45  const int32_t thresold = INT32_MAX>>scale;
46  return (a>=thresold) ? INT32_MAX :
47  a<-thresold ? -INT32_MAX :
48  a<<scale;
49 }
50 
51 #endif // _MpDspUtilsShift_h_
static void shl16_I(int32_t &a, unsigned scale)
Definition: MpDspUtilsShift.h:25
static int32_t shl16(int32_t a, unsigned scale)
Definition: MpDspUtilsShift.h:30
static void shl32_I(int32_t &a, unsigned scale)
Definition: MpDspUtilsShift.h:38
static int32_t shl32(int32_t a, unsigned scale)
Definition: MpDspUtilsShift.h:43