X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfcombine.c;h=16589b1662ee4c0dbea90106224fd68084a133e5;hb=3cd41fca50349a2e03d5bca74fc5b38d76a4238a;hp=6fcbe64ceab7382ec567615dbbb605683870eec4;hpb=6b92e9496d0ed61b9619565ac0888bd0e3522ae2;p=swftools.git diff --git a/src/swfcombine.c b/src/swfcombine.c index 6fcbe64..16589b1 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -137,7 +137,7 @@ int args_callback_option(char*name,char*val) { { float rate = atof(val); - if ((rate < 1.0/256) ||(rate >= 256.0)) { + if ((rate < 0) ||(rate >= 256.0)) { fprintf(stderr, "Error: You must specify a valid framerate between 1/256 and 255.\n"); exit(1); } @@ -161,6 +161,16 @@ int args_callback_option(char*name,char*val) { config.scalex = config.scaley = atoi(val)/100.0; return 1; } + else if (!strcmp(name, "w")) + { + config.scalex = atoi(val)/100.0; + return 1; + } + else if (!strcmp(name, "h")) + { + config.scaley = atoi(val)/100.0; + return 1; + } else if (!strcmp(name, "t") || !strcmp(name, "T")) { if(master_filename) { @@ -306,6 +316,7 @@ static void makestackmaster(SWF*swf) exit(1); } close(fi); + swf_RemoveJPEGTables(&head); msg(" File %s has bounding box %d:%d:%d:%d\n", slave_filename[t], head.movieSize.xmin, head.movieSize.ymin, @@ -666,7 +677,7 @@ static char tag_ok_for_slave(int id) TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefine, int flags) { int outputslave = 0; - int frame = 0; + int frame = 1; int sframe = 0; int slavewritten = 0; int deletedepth = -1; @@ -686,7 +697,7 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi } if(tag_ok_for_slave(stag->id)) { tag = swf_InsertTag(tag, stag->id); - swf_SetBlock(tag, stag->data, stag->len); + write_changepos(tag, stag, config.movex, config.movey, config.scalex, config.scaley, 0); } stag = stag->next; } @@ -694,6 +705,14 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi if(rtag->id == ST_SHOWFRAME) { frame ++; + tag = swf_InsertTag(tag, ST_SHOWFRAME); + if(deletedepth>=0) { + tag = swf_InsertTag(tag, ST_REMOVEOBJECT2); + swf_SetU16(tag, deletedepth); + deletedepth=-1; + } + rtag = rtag->next; + continue; } if(swf_isDefiningTag(rtag) && (flags&FLAGS_WRITEDEFINES)) @@ -709,17 +728,19 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi swf_SetDefineID(tag, replaceddefine); } else { /* don't write this tag */ - msg(" replacing tag %d id %d with sprite", rtag->id - ,spriteid); + msg(" replacing tag %d ID %d with sprite", rtag->id ,spriteid); } if(flags&FLAGS_WRITESPRITE) { + msg(" writing sprite defines"); tag = write_sprite_defines(tag, slave); + msg(" writing sprite"); tag = write_sprite(tag, slave, spriteid, replaceddefine); } if(flags&FLAGS_WRITESLAVE) { + msg(" writing slave"); outputslave = 1; } } else { @@ -737,7 +758,7 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi { int id = get_free_id(masterbitmap); int depth = 65535; - deletedepth = 65536; + deletedepth = 65535; if(config.clip) { msg(" Can't combine --clip and --frame"); } @@ -779,11 +800,6 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi tag = swf_InsertTag(tag, rtag->id); write_changepos(tag, rtag, config.mastermovex, config.mastermovey, config.masterscalex, config.masterscaley, 1); - if(rtag->id == ST_SHOWFRAME && deletedepth) { - tag = swf_InsertTag(tag, ST_REMOVEOBJECT2); - swf_SetU16(tag, deletedepth); - deletedepth = -1; - } } } rtag = rtag->next; @@ -793,8 +809,9 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi while(stag && stag->id!=ST_END) { if(tag_ok_for_slave(stag->id)) { + msg(" [slave] write tag %02x (%d bytes in body), %.2f %.2f", rtag->id, rtag->len, config.movex /20.0, config.movey /20.0); tag = swf_InsertTag(tag, stag->id); - swf_SetBlock(tag, stag->data, stag->len); + write_changepos(tag, stag, config.movex, config.movey, config.scalex, config.scaley, 0); } stag = stag->next; } @@ -951,6 +968,15 @@ void normalcombine(SWF*master, char*slave_name, SWF*slave, SWF*newswf) char * name = swf_GetName(tag); int id = swf_GetPlaceID(tag); + { + SWFPLACEOBJECT obj; + swf_GetPlaceObject(tag, &obj); + swf_PlaceObjectFree(&obj); + if(obj.clipdepth) { + depthbitmap[obj.clipdepth] = 1; + } + } + if(name) msg(" tagid %02x places object %d named \"%s\"", tag->id, id, name); else @@ -1030,6 +1056,9 @@ void combine(SWF*master, char*slave_name, SWF*slave, SWF*newswf) slaveid = -1; slaveframe = -1; + if(!master->fileVersion && slave) + master->fileVersion = slave->fileVersion; + swf_FoldAll(master); swf_FoldAll(slave); @@ -1041,16 +1070,19 @@ void combine(SWF*master, char*slave_name, SWF*slave, SWF*newswf) if(config.isframe) { - int tmp; - if(slavename && slavename[0]!='#' && (sscanf(slavename, "%d", &tmp) == - strlen(slavename))) { - /* if the name the slave should replace - consists only of digits and the -f - option is given, it probably is not - a frame name but a frame number. - */ - slaveid = tmp; - slavename = 0; + if(slavename && slavename[0]!='#') { + int tmp; + int len; + sscanf(slavename, "%d%n", &tmp, &len); + if(len == strlen(slavename)) { + /* if the name the slave should replace + consists only of digits and the -f + option is given, it probably is not + a frame name but a frame number. + */ + slaveid = tmp; + slavename = 0; + } } if(slaveid>=0) { @@ -1121,6 +1153,11 @@ int main(int argn, char *argv[]) msg(" Can't combine --cat and --merge"); exit(1); } + + if(config.stack && config.cat) { + msg(" Can't combine --cat and --stack"); + exit(1); + } if(config.stack) { if(config.overlay) { @@ -1148,6 +1185,7 @@ int main(int argn, char *argv[]) msg(" Failed to read from %s\n", master_filename); exit(1); } + swf_RemoveJPEGTables(&master); msg(" Read %d bytes from masterfile\n", ret); close(fi); } @@ -1215,21 +1253,31 @@ int main(int argn, char *argv[]) } msg(" Read %d bytes from slavefile\n", ret); close(fi); + swf_RemoveJPEGTables(&slave); } else { memset(&slave, 0, sizeof(slave)); slave.firstTag = swf_InsertTag(0, ST_END); slave.frameRate = 0; - slave.fileVersion = 4; + slave.fileVersion = 0; slave.frameCount = 0; } combine(&master, slave_name[t], &slave, &newswf); master = newswf; } + if(config.dummy && !config.hassizex && !config.hassizey && !config.mastermovex && !config.mastermovey) { + newswf.movieSize.xmin = newswf.movieSize.xmin*config.masterscalex; + newswf.movieSize.ymin = newswf.movieSize.ymin*config.masterscaley; + newswf.movieSize.xmax = newswf.movieSize.xmax*config.masterscalex; + newswf.movieSize.ymax = newswf.movieSize.ymax*config.masterscaley; + } } + if(!newswf.fileVersion) + newswf.fileVersion = 4; + fi = open(outputname, O_BINARY|O_RDWR|O_TRUNC|O_CREAT, 0777); if(config.zlib) {