{"t","text"},
{"X","width"},
{"Y","height"},
+ {"f","frames"},
{"r","rate"},
{"e","html"},
{"u","used"},
xy |= 4;
return 0;
}
+ else if(name[0]=='f') {
+ xy |= 8;
+ return 0;
+ }
else if(name[0]=='d') {
hex = 1;
return 0;
}
else {
printf("Unknown option: -%s\n", name);
+ exit(1);
}
return 0;
{
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");
+ printf("\t-f , --frames\t\t Prints out a string of the form \"-f framenum\"\n");
printf("\t-a , --action\t\t Disassemble action tags\n");
printf("\t-t , --text\t\t Show text data\n");
printf("\t-d , --hex\t\t Print hex output of tag data, too\n");
swf_FontExtract_DefineTextCallback(-1,0,tag,4, textcallback);
}
+void handleDefineSound(TAG*tag)
+{
+ U16 id = swf_GetU16(tag);
+ U8 flags = swf_GetU8(tag);
+ int compression = (flags>>4)&3;
+ int rate = (flags>>2)&3;
+ int bits = flags&2?16:8;
+ int stereo = flags&1;
+ printf(" (");
+ if(compression == 0) printf("Raw ");
+ else if(compression == 1) printf("ADPCM ");
+ else if(compression == 2) printf("MP3 ");
+ else printf("? ");
+ if(rate == 0) printf("5.5Khz ");
+ if(rate == 1) printf("11Khz ");
+ if(rate == 2) printf("22Khz ");
+ if(rate == 3) printf("44Khz ");
+ printf("%dBit ", bits);
+ if(stereo) printf("stereo");
+ else printf("mono");
+ printf(")");
+}
+
void handleDefineBits(TAG*tag)
{
U16 id;
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;
if(xy&4)
printf("-r %d", swf.frameRate*100/256);
+ if((xy&7) && (xy&8))
+ printf(" ");
+
+ if(xy&8)
+ printf("-f %d", swf.frameCount);
+
printf("\n");
return 0;
}
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);
}
}
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;}
if(!issprite) {mainframe++; framelabel = 0;}
}
+ if(tag->id == ST_SETBACKGROUNDCOLOR) {
+ U8 r = swf_GetU8(tag);
+ U8 g = swf_GetU8(tag);
+ U8 b = swf_GetU8(tag);
+ printf(" (%02x/%02x/%02x)",r,g,b);
+ }
+
if(tag->id == ST_DEFINEBITSLOSSLESS ||
tag->id == ST_DEFINEBITSLOSSLESS2) {
handleDefineBits(tag);
printf("\n");
}
+ else if(tag->id == ST_DEFINESOUND) {
+ handleDefineSound(tag);
+ printf("\n");
+ }
else if(tag->id == ST_DEFINEEDITTEXT) {
handleEditText(tag);
printf("\n");