From d1520a6cfd8189d7c5a9e3be4f376d4c13bf8fce Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 28 May 2016 14:11:10 +0200 Subject: avutil/softfloat: Document public constants and a few public functions Signed-off-by: Michael Niedermayer --- libavutil/softfloat.h | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'libavutil') 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; -- cgit v1.2.3