[Ffmpeg-cvslog] CVS: ffmpeg/libavformat 4xm.c, 1.19, 1.20 matroska.c, 1.14, 1.15

Michael Niedermayer CVS michael
Tue Jul 19 17:32:45 CEST 2005


Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv5388

Modified Files:
	4xm.c matroska.c 
Log Message:
more non portable float parsing code ...


Index: 4xm.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/4xm.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- 4xm.c	17 Jul 2005 22:24:35 -0000	1.19
+++ 4xm.c	19 Jul 2005 15:32:43 -0000	1.20
@@ -75,26 +75,6 @@
     float fps;
 } FourxmDemuxContext;
 
-static float get_le_float(unsigned char *buffer)
-{
-    float f;
-    unsigned char *float_buffer = (unsigned char *)&f;
-
-#ifdef WORDS_BIGENDIAN
-    float_buffer[0] = buffer[3];
-    float_buffer[1] = buffer[2];
-    float_buffer[2] = buffer[1];
-    float_buffer[3] = buffer[0];
-#else
-    float_buffer[0] = buffer[0];
-    float_buffer[1] = buffer[1];
-    float_buffer[2] = buffer[2];
-    float_buffer[3] = buffer[3];
-#endif
-
-    return f;
-}
-
 static int fourxm_probe(AVProbeData *p)
 {
     if (p->buf_size < 12)
@@ -147,7 +127,7 @@
         size = LE_32(&header[i + 4]);
 
         if (fourcc_tag == std__TAG) {
-            fourxm->fps = get_le_float(&header[i + 12]);
+            fourxm->fps = av_int2flt(LE_32(&header[i + 12]));
         } else if (fourcc_tag == vtrk_TAG) {
             /* check that there is enough data */
             if (size != vtrk_SIZE) {

Index: matroska.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/matroska.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- matroska.c	17 Jul 2005 22:24:35 -0000	1.14
+++ matroska.c	19 Jul 2005 15:32:43 -0000	1.15
@@ -609,42 +609,21 @@
         return res;
     size = rlength;
 
-    if (size != 4 && size != 8 && size != 10) {
+    if (size == 4) {
+        *num= av_int2flt(get_be32(pb));
+    } else if(size==8){
+        *num= av_int2dbl(get_be64(pb));
+    } else if(size==10){
+        av_log(matroska->ctx, AV_LOG_ERROR,
+               "FIXME! 10-byte floats unimplemented\n");
+        return AVERROR_UNKNOWN;
+    } else{
         offset_t pos = url_ftell(pb);
         av_log(matroska->ctx, AV_LOG_ERROR,
                "Invalid float element size %d at position %llu (0x%llx)\n",
                size, pos, pos);
         return AVERROR_INVALIDDATA;
     }
-    if (size == 10) {
-        av_log(matroska->ctx, AV_LOG_ERROR,
-               "FIXME! 10-byte floats unimplemented\n");
-        return AVERROR_UNKNOWN;
-    }
-
-    if (size == 4) {
-        float f;
-
-        while (size-- > 0)
-#ifdef WORDS_BIGENDIAN
-            ((uint8_t *) &f)[3 - size] = get_byte(pb);
-#else
-            ((uint8_t *) &f)[size] = get_byte(pb);
-#endif
-
-        *num = f;
-    } else {
-        double d;
-
-        while (size-- > 0)
-#ifdef WORDS_BIGENDIAN
-            ((uint8_t *) &d)[7 - size] = get_byte(pb);
-#else
-            ((uint8_t *) &d)[size] = get_byte(pb);
-#endif
-
-        *num = d;
-    }
 
     return 0;
 }





More information about the ffmpeg-cvslog mailing list