Mercurial > libavcodec.hg
annotate mathops.h @ 9670:5c929c37e1a0 libavcodec
Move AMR-WB-specific code to the AMR-WB section of the file.
Fixes compilation when AMR-NB #includes are not available on the system.
author | diego |
---|---|
date | Tue, 19 May 2009 17:31:56 +0000 |
parents | 005cf8ba225f |
children | f1f95c604b56 |
rev | line source |
---|---|
3733 | 1 /* |
2 * simple math operations | |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
8627
diff
changeset
|
3 * Copyright (c) 2001, 2002 Fabrice Bellard |
3733 | 4 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al |
5 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
3733 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
3733 | 12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
3733 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3733
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3733 | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 */ | |
7760 | 22 #ifndef AVCODEC_MATHOPS_H |
23 #define AVCODEC_MATHOPS_H | |
3733 | 24 |
6763 | 25 #include "libavutil/common.h" |
5162 | 26 |
8759
4cea2f47219a
re-enable mid_pred asm on x86_64. (broke in r16681)
lorenm
parents:
8629
diff
changeset
|
27 #if ARCH_X86 |
3733 | 28 |
8430 | 29 #include "x86/mathops.h" |
3733 | 30 |
8590 | 31 #elif ARCH_ARM |
3733 | 32 |
8359 | 33 #include "arm/mathops.h" |
3733 | 34 |
8590 | 35 #elif ARCH_PPC |
3733 | 36 |
37 #include "ppc/mathops.h" | |
38 | |
8590 | 39 #elif ARCH_BFIN |
5615 | 40 |
41 #include "bfin/mathops.h" | |
42 | |
3733 | 43 #endif |
44 | |
45 /* generic implementation */ | |
46 | |
47 #ifndef MULL | |
8201 | 48 # define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) |
3733 | 49 #endif |
50 | |
51 #ifndef MULH | |
52 //gcc 3.4 creates an incredibly bloated mess out of this | |
53 //# define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) | |
54 | |
4283
d6f83e2f8804
rename always_inline to av_always_inline and move to common.h
mru
parents:
4112
diff
changeset
|
55 static av_always_inline int MULH(int a, int b){ |
3733 | 56 return ((int64_t)(a) * (int64_t)(b))>>32; |
57 } | |
58 #endif | |
59 | |
60 #ifndef MUL64 | |
61 # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) | |
62 #endif | |
63 | |
7255 | 64 #ifndef MAC64 |
65 # define MAC64(d, a, b) ((d) += MUL64(a, b)) | |
66 #endif | |
67 | |
68 #ifndef MLS64 | |
69 # define MLS64(d, a, b) ((d) -= MUL64(a, b)) | |
70 #endif | |
71 | |
3733 | 72 /* signed 16x16 -> 32 multiply add accumulate */ |
73 #ifndef MAC16 | |
74 # define MAC16(rt, ra, rb) rt += (ra) * (rb) | |
75 #endif | |
76 | |
77 /* signed 16x16 -> 32 multiply */ | |
78 #ifndef MUL16 | |
79 # define MUL16(ra, rb) ((ra) * (rb)) | |
80 #endif | |
81 | |
7255 | 82 #ifndef MLS16 |
83 # define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb)) | |
84 #endif | |
85 | |
8627
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
86 /* median of 3 */ |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
87 #ifndef mid_pred |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
88 #define mid_pred mid_pred |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
89 static inline av_const int mid_pred(int a, int b, int c) |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
90 { |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
91 #if 0 |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
92 int t= (a-b)&((a-b)>>31); |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
93 a-=t; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
94 b+=t; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
95 b-= (b-c)&((b-c)>>31); |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
96 b+= (a-b)&((a-b)>>31); |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
97 |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
98 return b; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
99 #else |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
100 if(a>b){ |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
101 if(c>b){ |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
102 if(c>a) b=a; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
103 else b=c; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
104 } |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
105 }else{ |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
106 if(b>c){ |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
107 if(c>a) b=c; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
108 else b=a; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
109 } |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
110 } |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
111 return b; |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
112 #endif |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
113 } |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
114 #endif |
d6bab465b82c
moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents:
8590
diff
changeset
|
115 |
9096 | 116 #ifndef sign_extend |
117 static inline av_const int sign_extend(int val, unsigned bits) | |
118 { | |
119 return (val << (INT_BIT - bits)) >> (INT_BIT - bits); | |
120 } | |
121 #endif | |
122 | |
7760 | 123 #endif /* AVCODEC_MATHOPS_H */ |
3733 | 124 |