Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: celt/fixed_generic.h

Issue 28553003: Updating Opus to a pre-release of 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Removing failing file Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « celt/fixed_c6x.h ('k') | celt/kiss_fft.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (C) 2007-2009 Xiph.Org Foundation 1 /* Copyright (C) 2007-2009 Xiph.Org Foundation
2 Copyright (C) 2003-2008 Jean-Marc Valin 2 Copyright (C) 2003-2008 Jean-Marc Valin
3 Copyright (C) 2007-2008 CSIRO */ 3 Copyright (C) 2007-2008 CSIRO */
4 /** 4 /**
5 @file fixed_generic.h 5 @file fixed_generic.h
6 @brief Generic fixed-point operations 6 @brief Generic fixed-point operations
7 */ 7 */
8 /* 8 /*
9 Redistribution and use in source and binary forms, with or without 9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions 10 modification, are permitted provided that the following conditions
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 77 #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))
78 /** 32-bit arithmetic shift right where the argument can be negative */ 78 /** 32-bit arithmetic shift right where the argument can be negative */
79 #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) 79 #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
80 80
81 /** "RAW" macros, should not be used outside of this header file */ 81 /** "RAW" macros, should not be used outside of this header file */
82 #define SHR(a,shift) ((a) >> (shift)) 82 #define SHR(a,shift) ((a) >> (shift))
83 #define SHL(a,shift) SHL32(a,shift) 83 #define SHL(a,shift) SHL32(a,shift)
84 #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 84 #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
85 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 85 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
86 86
87 #define SATURATE16(x) (EXTRACT16((x)>32767 ? 32767 : (x)<-32768 ? -32768 : (x)))
88
87 /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */ 89 /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
88 #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a)))) 90 #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
89 /** Divide by two */ 91 /** Divide by two */
90 #define HALF16(x) (SHR16(x,1)) 92 #define HALF16(x) (SHR16(x,1))
91 #define HALF32(x) (SHR32(x,1)) 93 #define HALF32(x) (SHR32(x,1))
92 94
93 /** Add two 16-bit values */ 95 /** Add two 16-bit values */
94 #define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b))) 96 #define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b)))
95 /** Subtract two 16-bit values */ 97 /** Subtract two 16-bit values */
96 #define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b)) 98 #define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b))
97 /** Add two 32-bit values */ 99 /** Add two 32-bit values */
98 #define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b)) 100 #define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b))
99 /** Subtract two 32-bit values */ 101 /** Subtract two 32-bit values */
100 #define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) 102 #define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b))
101 103
102 /** 16x16 multiplication where the result fits in 16 bits */ 104 /** 16x16 multiplication where the result fits in 16 bits */
103 #define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) 105 #define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b))))
104 106
105 /* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multipl y */ 107 /* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multipl y */
106 /** 16x16 multiplication where the result fits in 32 bits */ 108 /** 16x16 multiplication where the result fits in 32 bits */
107 #define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val 16)(b))) 109 #define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val 16)(b)))
108 110
109 /** 16x16 multiply-add where the result fits in 32 bits */ 111 /** 16x16 multiply-add where the result fits in 32 bits */
110 #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) 112 #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
111 /** 16x32 multiply-add, followed by a 15-bit shift right. Results fits in 32 bit s */ 113 /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add.
114 b must fit in 31 bits.
115 Result fits in 32 bits. */
112 #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16 _16((a),((b)&0x00007fff)),15))) 116 #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16 _16((a),((b)&0x00007fff)),15)))
113 117
114 #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) 118 #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
119 #define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
115 #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) 120 #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
116 #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) 121 #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
117 #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) 122 #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
118 123
119 #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) 124 #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
120 #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) 125 #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
121 #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) 126 #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
122 127
123 /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ 128 /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */
124 #define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b)))) 129 #define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b))))
125 130
126 /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ 131 /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */
127 #define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) 132 #define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b)))
128 133
129 #endif 134 #endif
OLDNEW
« no previous file with comments | « celt/fixed_c6x.h ('k') | celt/kiss_fft.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698