[Ffmpeg-cvslog] CVS: ffmpeg/libavutil intfloat_readwrite.c, 1.5, 1.6 intfloat_readwrite.h, 1.1, 1.2

Michael Niedermayer CVS michael
Thu Feb 2 16:21:21 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg/libavutil
In directory mail:/var2/tmp/cvs-serv7282/libavutil

Modified Files:
	intfloat_readwrite.c intfloat_readwrite.h 
Log Message:
AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)


Index: intfloat_readwrite.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavutil/intfloat_readwrite.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- intfloat_readwrite.c	30 Jan 2006 23:32:13 -0000	1.5
+++ intfloat_readwrite.c	2 Feb 2006 15:21:19 -0000	1.6
@@ -38,6 +38,23 @@
     return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
 }
 
+double av_ext2dbl(const AVExtFloat ext){
+    uint64_t m = 0;
+    int e, i;
+
+    for (i = 0; i < 8; i++)
+        m |= (uint64_t)ext.mantissa[i]<<(56-(i<<3));
+    e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];
+    if (e == 0x7fff && m)
+        return 0.0/0.0;
+    e -= 16383 + 63;        /* In IEEE 80 bits, the whole (i.e. 1.xxxx)
+                             * mantissa bit is written as opposed to the
+                             * single and double precision formats */
+    if (ext.exponent[0]&0x80)
+        return ldexp(-m, e);
+    return ldexp(m, e);
+}
+
 int64_t av_dbl2int(double d){
     int e;
     if     ( !d) return 0;
@@ -53,3 +70,29 @@
     d= frexp(d, &e);
     return (d<0)<<31 | (e+126)<<23 | (int64_t)((fabs(d)-0.5)*(1<<24));
 }
+
+AVExtFloat av_dbl2ext(double d){
+    struct AVExtFloat ext;
+    int e, i; double f; uint64_t m;
+
+    f = fabs(frexp(d, &e));
+    if (f >= 0.5 && f < 1) {
+        e += 16382;
+        ext.exponent[0] = e>>8;
+        ext.exponent[1] = e;
+        m = (uint64_t)ldexp(f, 64);
+        for (i=0; i < 8; i++)
+            ext.mantissa[i] = m>>(56-(i<<3));
+    } else if (f == 0.0) {
+        memset (&ext, 0, 10);
+    } else {
+        ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;
+        memset (&ext.mantissa, 0, 8);
+        if (f != 1/0.0)
+            ext.mantissa[0] = ~0;
+    }
+    if (d < 0)
+        ext.exponent[0] |= 0x80;
+    return ext;
+}
+

Index: intfloat_readwrite.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavutil/intfloat_readwrite.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- intfloat_readwrite.h	1 Aug 2005 20:07:04 -0000	1.1
+++ intfloat_readwrite.h	2 Feb 2006 15:21:19 -0000	1.2
@@ -3,9 +3,17 @@
 
 #include "common.h"
 
+/* IEEE 80 bits extended float */
+typedef struct AVExtFloat  {
+    uint8_t exponent[2];
+    uint8_t mantissa[8];
+} AVExtFloat;
+
 double av_int2dbl(int64_t v);
 float av_int2flt(int32_t v);
+double av_ext2dbl(const AVExtFloat ext);
 int64_t av_dbl2int(double d);
 int32_t av_flt2int(float d);
+AVExtFloat av_dbl2ext(double d);
 
 #endif /* INTFLOAT_READWRITE_H */





More information about the ffmpeg-cvslog mailing list