aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-05-28 14:11:10 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-05-28 14:24:20 +0200
commitd1520a6cfd8189d7c5a9e3be4f376d4c13bf8fce (patch)
treed1a89204dba144dde510a4c759b2c8cc355a5594
parenta64a030ba0d13f9dc3a5d82b17053eda470b43b7 (diff)
downloadffmpeg-d1520a6cfd8189d7c5a9e3be4f376d4c13bf8fce.tar.gz
avutil/softfloat: Document public constants and a few public functions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavutil/softfloat.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
index 4b895f014b..1dd5bb7e98 100644
--- a/libavutil/softfloat.h
+++ b/libavutil/softfloat.h
@@ -36,14 +36,18 @@ typedef struct SoftFloat{
int32_t exp;
}SoftFloat;
-static const SoftFloat FLOAT_0 = { 0, MIN_EXP};
-static const SoftFloat FLOAT_05 = { 0x20000000, 0};
-static const SoftFloat FLOAT_1 = { 0x20000000, 1};
-static const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16};
-static const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1};
-static const SoftFloat FLOAT_100000 = { 0x30D40000, 17};
-static const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0};
+static const SoftFloat FLOAT_0 = { 0, MIN_EXP}; ///< 0.0
+static const SoftFloat FLOAT_05 = { 0x20000000, 0}; ///< 0.5
+static const SoftFloat FLOAT_1 = { 0x20000000, 1}; ///< 1.0
+static const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16}; ///< A small value
+static const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1}; ///< 1.584893192 (10^.2)
+static const SoftFloat FLOAT_100000 = { 0x30D40000, 17}; ///< 100000
+static const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0}; ///< 0.999999
+
+/**
+ * Convert a SoftFloat to a double precision float.
+ */
static inline av_const double av_sf2double(SoftFloat v) {
v.exp -= ONE_BITS +1;
if(v.exp > 0) return (double)v.mant * (double)(1 << v.exp);
@@ -118,6 +122,12 @@ static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
return a;
}
+/**
+ * Compares two SoftFloats.
+ * @returns < 0 if the first is less
+ * > 0 if the first is greater
+ * 0 if they are equal
+ */
static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){
int t= a.exp - b.exp;
if (t <-31) return - b.mant ;
@@ -126,6 +136,10 @@ static inline av_const int av_cmp_sf(SoftFloat a, SoftFloat b){
else return a.mant ;
}
+/**
+ * Compares two SoftFloats.
+ * @returns 1 if a is greater than b, 0 otherwise
+ */
static inline av_const int av_gt_sf(SoftFloat a, SoftFloat b)
{
int t= a.exp - b.exp;
@@ -135,6 +149,9 @@ static inline av_const int av_gt_sf(SoftFloat a, SoftFloat b)
else return a.mant > 0 ;
}
+/**
+ * @returns the sum of 2 SoftFloats.
+ */
static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
int t= a.exp - b.exp;
if (t <-31) return b;