-o support for jpg and png.
[swftools.git] / src / swfdump.c
index de52058..c9f910c 100644 (file)
@@ -104,6 +104,7 @@ int args_callback_option(char*name,char*val)
     }
     else {
         printf("Unknown option: -%s\n", name);
+       exit(1);
     }
 
     return 0;
@@ -116,7 +117,7 @@ void args_callback_usage(char*name)
 {    
     printf("Usage: %s [-at] file.swf\n", name);
     printf("\t-h , --help\t\t Print help and exit\n");
-    printf("\t-e , --html\t\t Create a html embedding the file (simple, but useful)\n");
+    printf("\t-e , --html\t\t Create html output embedding the file (simple, but useful)\n");
     printf("\t-X , --width\t\t Prints out a string of the form \"-X width\"\n");
     printf("\t-Y , --height\t\t Prints out a string of the form \"-Y height\"\n");
     printf("\t-r , --rate\t\t Prints out a string of the form \"-r rate\"\n");
@@ -451,6 +452,21 @@ void dumperror(const char* format, ...)
        printf("==== Error: %s ====\n", buf);
 }
 
+static char strbuf[800];
+static int bufpos=0;
+
+char* timestring(double f)
+{
+    int hours   = (int)(f/3600);
+    int minutes = (int)((f-hours*3600)/60);
+    int seconds = (int)((f-hours*3600-minutes*60));
+    int useconds = (int)((f-(int)f)*1000+0.5);
+    bufpos+=100;
+    bufpos%=800;
+    sprintf(&strbuf[bufpos], "%02d:%02d:%02d,%03d",hours,minutes,seconds,useconds);
+    return &strbuf[bufpos];
+}
+
 int main (int argc,char ** argv)
 { 
     TAG*tag;
@@ -638,7 +654,23 @@ int main (int argc,char ** argv)
             printf(" frees object %04d", swf_GetPlaceID(tag));
         }
        else if(tag->id == ST_STARTSOUND) {
-           printf(" starts id %04d", swf_GetPlaceID(tag));
+           U8 flags;
+           U16 id;
+           id = swf_GetU16(tag);
+           flags = swf_GetU8(tag);
+           if(flags & 32)
+               printf(" stops sound with id %04d", id);
+           else
+               printf(" starts sound with id %04d", id);
+           if(flags & 16)
+               printf(" (if not already playing)");
+           if(flags & 1)
+               swf_GetU32(tag);
+           if(flags & 2)
+               swf_GetU32(tag);
+           if(flags & 4) {
+               printf(" looping %d times", swf_GetU16(tag));
+           }
        }
        else if(tag->id == ST_FRAMELABEL) {
            int l = strlen(tag->data);
@@ -669,9 +701,12 @@ int main (int argc,char ** argv)
                }
            }
            if(nframe == frame)
-               printf(" %d", frame);
+               printf(" %d (%s)", frame, timestring(frame*(256.0/(swf.frameRate+0.1))));
            else
-               printf(" %d-%d", frame, nframe);
+               printf(" %d-%d (%s-%s)", frame, nframe,
+                       timestring(frame*(256.0/(swf.frameRate+0.1))),
+                       timestring(nframe*(256.0/(swf.frameRate+0.1)))
+                       );
            if(label)
                printf(" (label \"%s\")", label);
            if(issprite) {spriteframe++; spriteframelabel = 0;}