swfvideo.o is now compiled separately.
[swftools.git] / lib / rfxswf.c
index 34487f1..ae14268 100644 (file)
@@ -250,7 +250,7 @@ int swf_SetRGB(TAG * t,RGBA * col)
 void swf_GetRGB(TAG * t, RGBA * col)
 {
     RGBA dummy;
-    if(!col);
+    if(!col)
        col = &dummy;
     col->r = swf_GetU8(t);
     col->g = swf_GetU8(t);
@@ -299,22 +299,35 @@ void swf_GetGradient(TAG * tag, GRADIENT * gradient, char alpha)
     }
 }
 
+int swf_CountUBits(U32 v,int nbits)
+{ int n = 32;
+  U32 m = 0x80000000;
+  if(v == 0x00000000) n = 0; 
+  else
+    while (!(v&m))
+    { n--;
+      m>>=1;
+    } 
+  return (n>nbits)?n:nbits;
+}
+
 int swf_CountBits(U32 v,int nbits)
 { int n = 33;
   U32 m = 0x80000000;
-  if (!v) n = 0; else
   if (v&m)
-  { while (v&m)
+  { if(v == 0xffffffff) n = 1;
+    else 
+    while (v&m)
     { n--;
       m>>=1;
-      if (!m) break;
     } 
   }
   else
-  { while (!(v&m))
+  { if(v == 0x00000000) n = 0; 
+    else
+    while (!(v&m))
     { n--;
       m>>=1;
-      if (!m) break;
     } 
   }
   return (n>nbits)?n:nbits;
@@ -1209,8 +1222,10 @@ int  swf_WriteSWF(int handle, SWF * swf)     // Writes SWF to file, returns leng
 {
   struct writer_t writer;
   swf->compressed = 0;
-  if(handle<0)
+  if(handle<0) {
+    writer_init_nullwriter(&writer);
     return swf_WriteSWF2(&writer, swf);
+  }
   writer_init_filewriter(&writer, handle);
   return swf_WriteSWF2(&writer, swf);
 }
@@ -1219,8 +1234,10 @@ int  swf_WriteSWC(int handle, SWF * swf)     // Writes SWF to file, returns leng
 {
   struct writer_t writer;
   swf->compressed = 1;
-  if(handle<0)
+  if(handle<0) {
+    writer_init_nullwriter(&writer);
     return swf_WriteSWF2(&writer, swf);
+  }
   writer_init_filewriter(&writer, handle);
   return swf_WriteSWF2(&writer, swf);
 }
@@ -1282,4 +1299,3 @@ void swf_FreeTags(SWF * swf)                 // Frees all malloc'ed memory for t
 #include "modules/swfbits.c"
 #include "modules/swfaction.c"
 #include "modules/swfsound.c"
-#include "h.263/swfvideo.c"