X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfdump.c;h=de5205879886ef9664d64211268123473b586ac3;hb=4d5e2bc031fd25ce7c76fb0ba2b7da7c01d91eac;hp=c7500952412d9a436b81da30082b5c403a5eb821;hpb=9c52a1d32d8dd3cdf346696db56962f5451d3968;p=swftools.git diff --git a/src/swfdump.c b/src/swfdump.c index c750095..de52058 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -49,6 +49,7 @@ struct options_t options[] = {"t","text"}, {"X","width"}, {"Y","height"}, + {"f","frames"}, {"r","rate"}, {"e","html"}, {"u","used"}, @@ -89,6 +90,10 @@ int args_callback_option(char*name,char*val) xy |= 4; return 0; } + else if(name[0]=='f') { + xy |= 8; + return 0; + } else if(name[0]=='d') { hex = 1; return 0; @@ -115,6 +120,7 @@ void args_callback_usage(char*name) 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"); @@ -250,6 +256,29 @@ void handleText(TAG*tag) 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; @@ -393,6 +422,22 @@ void fontcallback2(U16 id,U8 * name) fontnum++; } +void hexdumpTag(TAG*tag, char* prefix) +{ + int t; + printf(" %s-=> ",prefix); + for(t=0;tlen;t++) { + printf("%02x ", tag->data[t]); + if((t && ((t&15)==15)) || (t==tag->len-1)) + { + if(t==tag->len-1) + printf("\n"); + else + printf("\n %s-=> ",prefix); + } + } +} + void dumperror(const char* format, ...) { char buf[1024]; @@ -402,7 +447,8 @@ void dumperror(const char* format, ...) vsprintf(buf, format, arglist); va_end(arglist); - printf("==== Error: %s ====\n", buf); + if(!html && !xy) + printf("==== Error: %s ====\n", buf); } int main (int argc,char ** argv) @@ -474,6 +520,12 @@ int main (int argc,char ** argv) 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; } @@ -582,6 +634,9 @@ int main (int argc,char ** argv) else if(tag->id == ST_REMOVEOBJECT2) { printf(" removes object from depth %04d", swf_GetDepth(tag)); } + else if(tag->id == ST_FREECHARACTER) { + printf(" frees object %04d", swf_GetPlaceID(tag)); + } else if(tag->id == ST_STARTSOUND) { printf(" starts id %04d", swf_GetPlaceID(tag)); } @@ -623,11 +678,22 @@ int main (int argc,char ** argv) 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"); @@ -689,7 +755,7 @@ int main (int argc,char ** argv) swf_GetUsedIDs(tag, used); printf("%s%suses IDs: ", indent, prefix); for(t=0;tpos = used[t]; + swf_SetTagPos(tag, used[t]); printf("%d%s", swf_GetU16(tag), tlen && hex) { - int t; - printf(" %s-=> ",prefix); - for(t=0;tlen;t++) { - printf("%02x ", tag->data[t]); - if((t && ((t&15)==15)) || (t==tag->len-1)) - { - if(t==tag->len-1) - printf("\n"); - else - printf("\n %s-=> ",prefix); - } - } + hexdumpTag(tag, prefix); } tag = tag->next; fflush(stdout);