Mercurial > libavutil.hg
comparison softfloat.h @ 633:8c48a1b999a3 libavutil
spelling/grammar/consistency review part I
author | diego |
---|---|
date | Wed, 28 Jan 2009 00:16:05 +0000 |
parents | bd4052d9050c |
children |
comparison
equal
deleted
inserted
replaced
632:f9884e1112d0 | 633:8c48a1b999a3 |
---|---|
70 return (SoftFloat){a.exp+t, a.mant>>t}; | 70 return (SoftFloat){a.exp+t, a.mant>>t}; |
71 #endif | 71 #endif |
72 } | 72 } |
73 | 73 |
74 /** | 74 /** |
75 * | 75 * @return Will not be more denormalized than a+b. So if either input is |
76 * @return will not be more denormalized then a+b, so if either input is | 76 * normalized, then the output will not be worse then the other input. |
77 * normalized then the output will not be worse then the other input | 77 * If both are normalized, then the output will be normalized. |
78 * if both are normalized then the output will be normalized | |
79 */ | 78 */ |
80 static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ | 79 static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ |
81 a.exp += b.exp; | 80 a.exp += b.exp; |
82 a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS; | 81 a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS; |
83 return av_normalize1_sf(a); | 82 return av_normalize1_sf(a); |
84 } | 83 } |
85 | 84 |
86 /** | 85 /** |
87 * | 86 * b has to be normalized and not zero. |
88 * b has to be normalized and not zero | 87 * @return Will not be more denormalized than a. |
89 * @return will not be more denormalized then a | |
90 */ | 88 */ |
91 static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ | 89 static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ |
92 a.exp -= b.exp+1; | 90 a.exp -= b.exp+1; |
93 a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; | 91 a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; |
94 return av_normalize1_sf(a); | 92 return av_normalize1_sf(a); |
115 static inline av_const SoftFloat av_int2sf(int v, int frac_bits){ | 113 static inline av_const SoftFloat av_int2sf(int v, int frac_bits){ |
116 return av_normalize_sf((SoftFloat){ONE_BITS-frac_bits, v}); | 114 return av_normalize_sf((SoftFloat){ONE_BITS-frac_bits, v}); |
117 } | 115 } |
118 | 116 |
119 /** | 117 /** |
120 * | 118 * Rounding is to -inf. |
121 * rounding is to -inf | |
122 */ | 119 */ |
123 static inline av_const int av_sf2int(SoftFloat v, int frac_bits){ | 120 static inline av_const int av_sf2int(SoftFloat v, int frac_bits){ |
124 v.exp += frac_bits - ONE_BITS; | 121 v.exp += frac_bits - ONE_BITS; |
125 if(v.exp >= 0) return v.mant << v.exp ; | 122 if(v.exp >= 0) return v.mant << v.exp ; |
126 else return v.mant >>(-v.exp); | 123 else return v.mant >>(-v.exp); |