2 main routine for swfcombine(1), a tool for merging .swf-files.
4 Part of the swftools package.
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8 This file is distributed under the GPL, see file COPYING for details */
14 #include "../lib/rfxswf.h"
15 #include "../lib/args.h"
16 #include "../lib/log.h"
17 #include "../config.h"
43 struct config_t config;
45 char * master_filename = 0;
46 char * master_name = 0;
47 char * slave_filename[128];
48 char * slave_name[128];
51 float slave_scalex[128];
52 float slave_scaley[128];
53 char slave_isframe[128];
56 char * outputname = "output.swf";
58 int args_callback_option(char*name,char*val) {
64 else if(!strcmp(name,"l"))
69 else if (!strcmp(name, "o"))
74 else if (!strcmp(name, "v"))
79 else if (!strcmp(name, "a"))
84 else if (!strcmp(name, "A"))
89 else if (!strcmp(name, "x"))
91 config.movex = atoi(val);
94 else if (!strcmp(name, "y"))
96 config.movey = atoi(val);
99 else if (!strcmp(name, "m"))
104 else if (!strcmp(name, "f"))
109 else if (!strcmp(name, "d"))
114 else if (!strcmp(name, "z"))
119 else if (!strcmp(name, "r"))
121 config.framerate = atoi(val)*256/100;
124 else if (!strcmp(name, "X"))
126 config.sizex = atoi(val)*20;
130 else if (!strcmp(name, "Y"))
132 config.sizey = atoi(val)*20;
136 else if (!strcmp(name, "s"))
138 config.scalex = config.scaley = atoi(val)/100.0;
141 else if (!strcmp(name, "t") || !strcmp(name, "T"))
143 if(master_filename) {
144 fprintf(stderr, "error with arguments. Try --help.\n");
148 if(!strcmp(name,"T"))
150 master_filename = "__none__";
153 else if (!strcmp(name, "V"))
155 printf("swfcombine - part of %s %s\n", PACKAGE, VERSION);
160 fprintf(stderr, "Unknown option: -%s\n", name);
165 struct options_t options[] =
187 int args_callback_longoption(char*name,char*val) {
188 return args_long2shortoption(options, name, val);
191 int args_callback_command(char*name, char*val) {
192 char*myname = strdup(name);
194 filename = strchr(myname, '=');
199 // argument has no explicit name field. guess one from the file name
200 char*path = strrchr(myname, '/');
201 char*ext = strrchr(myname, '.');
202 if(!path) path = myname;
209 if(!master_filename) {
210 master_filename = filename;
211 master_name = myname;
213 logf("<verbose> slave entity %s (named \"%s\")\n", filename, myname);
215 slave_filename[numslaves] = filename;
216 slave_name[numslaves] = myname;
217 slave_movex[numslaves] = config.movex;
218 slave_movey[numslaves] = config.movey;
219 slave_scalex[numslaves] = config.scalex;
220 slave_scaley[numslaves] = config.scaley;
221 slave_isframe[numslaves] = config.isframe;
223 config.movex = config.movey = 0;
224 config.scalex = config.scaley = 1.0;
230 void args_callback_usage(char*name)
232 printf("Usage: %s [-rXYomlcv] [-f] masterfile [-xysf] [(name1|#id1)=]slavefile1 .. [-xysf] [(nameN|#idN)=]slavefileN\n", name);
233 printf("OR: %s [-rXYomv] --stack[1] [-xysf] [(name1|#id1)=]slavefile1 .. [-xysf] [(nameN|#idN)=]slavefileN\n", name);
234 printf("OR: %s [-rXYov] --cat [-xysf] [(name1|#id1)=]slavefile1 .. [-xysf] [(nameN|#idN)=]slavefileN\n", name);
235 printf("OR: %s [-rXYomlcv] --dummy [-xys] [file]\n", name);
237 printf("-o outputfile --output explicitly specify output file. (otherwise, output.swf will be used\n");
238 printf("-t --stack place each slave in a seperate frame (no master movie)\n");
239 printf("-T --stack1 place each slave in the first frame (no master movie)\n");
240 printf("-m --merge Don't store the slaves in Sprites/MovieClips\n");
241 printf("-a --cat concatenate all slave files (no master movie)\n");
242 printf("-l --overlay Don't remove any master objects, only overlay new objects\n");
243 printf("-c --clip Clip the slave objects by the corresponding master objects\n");
244 printf("-v --verbose Use more than one -v for greater effect \n");
245 printf("-d --dummy Don't require slave objects \n");
246 printf("-f --frame The following identifier is a frame or framelabel, not an id or objectname\n");
247 printf("-x xpos --movex x Adjust position of slave by xpos twips (1/20 pixel)\n");
248 printf("-y ypos --movey y Adjust position of slave by ypos twips (1/20 pixel)\n");
249 printf("-s scale --scale Adjust size of slave by scale%\n");
250 printf("-r framerate --rate Set movie framerate (100 frames/sec)\n");
251 printf("-X width --width Force movie width to scale (default: use master width (not with -t))\n");
252 printf("-Y height --height Force movie height to scale (default: use master height (not with -t))\n");
253 printf("-z zlib --zlib Enable Flash 6 (MX) Zlib Compression\n");
256 static void makestackmaster(SWF*swf)
262 memset(&box, 0, sizeof(box));
264 /* scan all slaves for bounding box */
265 for(t=0;t<numslaves;t++)
269 int fi=open(slave_filename[t],O_RDONLY);
270 if(fi<0 || swf_ReadSWF(fi, &head)<0) {
271 logf("<fatal> Couldn't open/read %s.", slave_filename[t]);
275 logf("<verbose> File %s has bounding box %d:%d:%d:%d\n",
277 head.movieSize.xmin, head.movieSize.ymin,
278 head.movieSize.xmax, head.movieSize.ymax);
279 if(head.fileVersion > fileversion)
280 fileversion = head.fileVersion;
282 box = head.movieSize;
284 if(head.movieSize.xmin < box.xmin)
285 box.xmin = head.movieSize.xmin;
286 if(head.movieSize.ymin < box.ymin)
287 box.ymin = head.movieSize.ymin;
288 if(head.movieSize.xmax > box.xmax)
289 box.xmax = head.movieSize.xmax;
290 if(head.movieSize.ymax > box.ymax)
291 box.ymax = head.movieSize.ymax;
293 logf("<verbose> New master bounding box is %d:%d:%d:%d\n",
299 memset(swf, 0, sizeof(SWF));
301 swf->firstTag = swf_InsertTag(tag, ST_SETBACKGROUNDCOLOR);
307 for(t=0;t<numslaves;t++)
310 sprintf(buf, "Frame%02d", t);
311 slave_name[t] = strdup(buf);
313 tag = swf_InsertTag(tag, ST_DEFINESPRITE);
314 swf_SetU16(tag, t+1);
316 tag = swf_InsertTag(tag, ST_END);
317 tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
318 swf_ObjectPlace(tag, t+1, 1+t,0,0, slave_name[t]);
320 if(!config.stack1 || t == numslaves-1) {
321 tag = swf_InsertTag(tag, ST_SHOWFRAME);
326 tag = swf_InsertTag(tag, ST_REMOVEOBJECT2);
327 swf_SetU16(tag, 1+t);
330 tag = swf_InsertTag(tag, ST_END);
333 static char* slavename = 0;
334 static int slaveid = -1;
335 static int slaveframe = -1;
336 static char masterbitmap[65536];
338 #define FLAGS_WRITEDEFINES 1
339 #define FLAGS_WRITENONDEFINES 2
340 #define FLAGS_WRITESPRITE 4
341 #define FLAGS_WRITESLAVE 8
343 int get_free_id(char*bitmap)
354 void jpeg_assert(SWF*master, SWF*slave)
356 /* TODO: if there's a jpegtable found, store it
357 and handle it together with the flash file
360 /* check that master and slave don't have both
361 jpegtables (which would be fatal) */
363 TAG *mpos=0, *spos=0;
366 mtag = master->firstTag;
367 stag = slave->firstTag;
370 if(mtag->id == ST_JPEGTABLES)
376 if(stag->id == ST_JPEGTABLES)
382 if(spos->len == mpos->len &&
383 !memcmp(spos->data, mpos->data, mpos->len))
385 // ok, both have jpegtables, but they're identical.
386 // delete one and don't throw an error
392 logf("<error> Master and slave have incompatible JPEGTABLES.");
396 TAG* write_sprite_defines(TAG*tag, SWF*sprite)
398 TAG*rtag = sprite->firstTag;
399 while(rtag && rtag->id!=ST_END) {
400 if(!swf_isAllowedSpriteTag(rtag)) {
401 logf("<debug> processing sprite tag %02x", tag->id);
402 if(swf_isDefiningTag(rtag))
404 logf("<debug> [sprite defs] write tag %02x (%d bytes in body)",
406 tag = swf_InsertTag(tag, rtag->id);
407 swf_SetBlock(tag, rtag->data, rtag->len);
409 else if(swf_isPseudoDefiningTag(rtag))
411 logf("<debug> [sprite defs] write tag %02x (%d bytes in body)",
413 tag = swf_InsertTag(tag, rtag->id);
414 swf_SetBlock(tag, rtag->data, rtag->len);
420 /* if we get here, jpeg_assert has already run,
421 ensuring this is the only one of it's kind,
422 so we may safely write it out */
423 tag = swf_InsertTag(tag, rtag->id);
424 swf_SetBlock(tag, rtag->data, rtag->len);
426 case ST_EXPORTASSETS:
427 logf("<debug> deliberately ignoring EXPORTASSETS tag");
429 case ST_ENABLEDEBUGGER:
430 logf("<debug> deliberately ignoring ENABLEDEBUGGER tag");
432 case ST_SETBACKGROUNDCOLOR:
433 logf("<debug> deliberately ignoring BACKGROUNDCOLOR tag");
438 logf("<notice> found tag %d. This is a Generator template, isn't it?", tag->id);
441 logf("<notice> funny tag: %d is neither defining nor sprite", tag->id);
450 void changedepth(TAG*tag, int add)
452 /* fucking byteorders */
453 if(tag->id == ST_PLACEOBJECT)
454 PUT16(&tag->data[2],GET16(&tag->data[2])+add);
455 if(tag->id == ST_PLACEOBJECT2)
456 PUT16(&tag->data[1],GET16(&tag->data[1])+add);
457 if(tag->id == ST_REMOVEOBJECT)
458 PUT16(&tag->data[2],GET16(&tag->data[2])+add);
459 if(tag->id == ST_REMOVEOBJECT2)
460 PUT16(&tag->data[0],GET16(&tag->data[0])+add);
463 void matrix_adjust(MATRIX*m)
465 m->sx = (int)(m->sx*config.scalex);
466 m->sy = (int)(m->sy*config.scaley);
467 m->r0 = (int)(m->r0*config.scalex);
468 m->r1 = (int)(m->r1*config.scaley);
469 m->tx += config.movex;
470 m->ty += config.movey;
473 void write_changepos(TAG*output, TAG*tag)
475 if(config.movex || config.movey || config.scalex != 1 || config.scaley != 1)
479 case ST_PLACEOBJECT2: {
482 swf_GetMatrix(0, &m);
484 flags = swf_GetU8(tag);
485 swf_SetU8(output, flags|4);
486 swf_SetU16(output, swf_GetU16(tag)); //depth
489 swf_SetU16(output, swf_GetU16(tag)); //id
492 swf_GetMatrix(tag, &m);
494 swf_SetMatrix(output, &m);
496 //swf_ResetReadBits(tag);
497 swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos);
500 case ST_PLACEOBJECT: {
502 swf_SetU16(output, swf_GetU16(tag)); //id
503 swf_SetU16(output, swf_GetU16(tag)); //depth
505 swf_GetMatrix(tag, &m);
507 swf_SetMatrix(output, &m);
509 //swf_ResetReadBits(tag);
510 swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos);
514 swf_SetBlock(output, tag->data, tag->len);
519 swf_SetBlock(output, tag->data, tag->len);
523 TAG* write_sprite(TAG*tag, SWF*sprite, int spriteid, int replaceddefine)
525 TAG* definespritetag;
529 definespritetag = tag = swf_InsertTag(tag, ST_DEFINESPRITE);
530 swf_SetU16(tag, spriteid);
531 swf_SetU16(tag, sprite->frameCount);
532 logf ("<notice> sprite id is %d", spriteid);
534 tmp = sprite->frameCount;
535 logf("<debug> %d frames to go",tmp);
538 tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
539 swf_SetU8(tag, 2+64); //flags: character+clipdepth
540 swf_SetU16(tag, 0); //depth
541 swf_SetU16(tag, replaceddefine); //id
542 swf_SetU16(tag, 65535); //clipdepth
545 if(config.overlay && !config.isframe) {
546 tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
547 swf_SetU8(tag, 2); //flags: character
548 swf_SetU16(tag, 0); //depth
549 swf_SetU16(tag, replaceddefine); //id
552 rtag = sprite->firstTag;
553 while(rtag && rtag->id!=ST_END)
555 if (swf_isAllowedSpriteTag(rtag)) {
557 logf("<debug> [sprite main] write tag %02x (%d bytes in body)",
558 rtag->id, rtag->len);
559 tag = swf_InsertTag(tag, rtag->id);
560 write_changepos(tag, rtag);
562 changedepth(tag, +1);
564 if(tag->id == ST_SHOWFRAME)
567 logf("<debug> %d frames to go",tmp);
572 tag = swf_InsertTag(tag, ST_END);
576 static char tag_ok_for_slave(int id)
578 if(id == ST_SETBACKGROUNDCOLOR)
583 TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefine, int flags)
588 int slavewritten = 0;
590 TAG* rtag = master->firstTag;
591 TAG* stag = slave->firstTag;
593 while(rtag && rtag->id!=ST_END)
595 if(rtag->id == ST_SHOWFRAME && outputslave)
597 while(stag && stag->id!=ST_END) {
598 if(stag->id == ST_SHOWFRAME) {
603 if(tag_ok_for_slave(stag->id)) {
604 tag = swf_InsertTag(tag, stag->id);
605 swf_SetBlock(tag, stag->data, stag->len);
610 if(rtag->id == ST_SHOWFRAME)
615 if(swf_isDefiningTag(rtag) && (flags&FLAGS_WRITEDEFINES))
617 logf("<debug> [master] write tag %02x (%d bytes in body)",
618 rtag->id, rtag->len);
619 if(swf_GetDefineID(rtag) == spriteid && !config.isframe)
623 tag = swf_InsertTag(tag, rtag->id);
624 swf_SetBlock(tag, rtag->data, rtag->len);
625 swf_SetDefineID(tag, replaceddefine);
627 /* don't write this tag */
628 logf("<verbose> replacing tag %d id %d with sprite", rtag->id
632 if(flags&FLAGS_WRITESPRITE)
634 tag = write_sprite_defines(tag, slave);
635 tag = write_sprite(tag, slave, spriteid, replaceddefine);
637 if(flags&FLAGS_WRITESLAVE)
642 tag = swf_InsertTag(tag, rtag->id);
643 swf_SetBlock(tag, rtag->data, rtag->len);
646 if(frame == slaveframe)
648 if(flags&FLAGS_WRITESLAVE) {
652 if((flags&FLAGS_WRITESPRITE) && !slavewritten)
654 int id = get_free_id(masterbitmap);
657 logf("<fatal> Can't combine --clip and --frame");
660 tag = write_sprite_defines(tag, slave);
661 tag = write_sprite(tag, slave, id, -1);
663 tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
664 swf_SetU8(tag, 2); //flags: id
665 swf_SetU16(tag, depth);
671 if(!swf_isDefiningTag(rtag) && (flags&FLAGS_WRITENONDEFINES))
676 case ST_PLACEOBJECT2:
677 if(frame == slaveframe && !config.overlay)
679 case ST_REMOVEOBJECT:
680 // case ST_REMOVEOBJECT2:
681 /* place/removetags for the object we replaced
682 should be discarded, too, as the object to insert
685 if(spriteid>=0 && swf_GetPlaceID(rtag) == spriteid &&
686 !config.isframe && config.merge)
691 logf("<debug> [master] write tag %02x (%d bytes in body)",
692 rtag->id, rtag->len);
693 tag = swf_InsertTag(tag, rtag->id);
694 swf_SetBlock(tag, rtag->data, rtag->len);
701 while(stag && stag->id!=ST_END)
703 if(tag_ok_for_slave(stag->id)) {
704 tag = swf_InsertTag(tag, stag->id);
705 swf_SetBlock(tag, stag->data, stag->len);
709 if(!slavewritten && config.isframe && (flags&(FLAGS_WRITESLAVE|FLAGS_WRITESPRITE)))
712 logf("<warning> Frame %d doesn't exist in file. No substitution will occur",
715 logf("<warning> Frame \"%s\" doesn't exist in file. No substitution will occur",
721 void catcombine(SWF*master, char*slave_name, SWF*slave, SWF*newswf)
728 logf("<fatal> Can't combine --cat and --frame");
732 tag = master->firstTag;
735 if(swf_isDefiningTag(tag)) {
736 int defineid = swf_GetDefineID(tag);
737 logf("<debug> tagid %02x defines object %d", tag->id, defineid);
738 masterbitmap[defineid] = 1;
742 swf_Relocate(slave, masterbitmap);
743 jpeg_assert(master, slave);
745 memcpy(newswf, master, sizeof(SWF));
746 tag = newswf->firstTag = swf_InsertTag(0, ST_REFLEX);
748 depths = malloc(65536);
750 logf("<fatal> Couldn't allocate %d bytes of memory", 65536);
753 memset(depths, 0, 65536);
754 mtag = master->firstTag;
759 logf("<debug> [master] write tag %02x (%d bytes in body)",
760 mtag->id, mtag->len);
762 case ST_PLACEOBJECT2:
764 case ST_PLACEOBJECT: {
765 depth = swf_GetDepth(mtag);
769 case ST_REMOVEOBJECT: {
770 depth = swf_GetDepth(mtag);
774 case ST_REMOVEOBJECT2: {
775 depth = swf_GetDepth(mtag);
780 tag = swf_InsertTag(tag, mtag->id);
781 swf_SetBlock(tag, mtag->data, mtag->len);
789 tag = swf_InsertTag(tag, ST_REMOVEOBJECT2);
794 stag = slave->firstTag;
797 logf("<debug> [slave] write tag %02x (%d bytes in body)",
798 stag->id, stag->len);
799 tag = swf_InsertTag(tag, stag->id);
800 swf_SetBlock(tag, stag->data, stag->len);
805 void normalcombine(SWF*master, char*slave_name, SWF*slave, SWF*newswf)
808 int replaceddefine = -1;
811 TAG * tag = master->firstTag;
816 if(swf_isDefiningTag(tag)) {
817 int defineid = swf_GetDefineID(tag);
818 logf("<debug> tagid %02x defines object %d", tag->id, defineid);
819 masterbitmap[defineid] = 1;
820 } else if(tag->id == ST_PLACEOBJECT2) {
821 char * name = swf_GetName(tag);
822 int id = swf_GetPlaceID(tag);
825 logf("<verbose> tagid %02x places object %d named \"%s\"", tag->id, id, name);
827 logf("<verbose> tagid %02x places object %d (no name)", tag->id, id);
829 if ((name && slavename && !strcmp(name,slavename)) ||
830 (!slavename && id==slaveid)) {
833 logf("<notice> Slave file attached to object %d.", id);
836 } else if(tag->id == ST_SHOWFRAME) {
837 if(slaveframe>=0 && frame==slaveframe) {
838 logf("<notice> Slave file attached to frame %d.", frame);
841 } else if(tag->id == ST_FRAMELABEL) {
842 char * name = tag->data;
843 if(name && slavename && config.isframe && !strcmp(name, slavename)) {
845 logf("<notice> Slave file attached to frame %d (%s).", frame, name);
851 if (spriteid<0 && !config.isframe) {
853 if(strcmp(slavename,"!!dummy!!"))
854 logf("<warning> Didn't find anything named %s in file. No substitutions will occur.", slavename);
857 logf("<warning> Didn't find id %d in file. No substitutions will occur.", slaveid);
858 spriteid = get_free_id(masterbitmap);
861 swf_Relocate (slave, masterbitmap);
862 jpeg_assert(slave, master);
865 replaceddefine = get_free_id(masterbitmap);
869 memcpy(newswf, master, sizeof(SWF));
870 newswf->firstTag = tag = swf_InsertTag(0, ST_REFLEX);
872 if (config.antistream) {
874 logf("<fatal> Can't combine --antistream and --merge");
876 tag = write_sprite_defines(tag, slave);
877 tag = write_sprite(tag, slave, spriteid, replaceddefine);
878 tag = write_master(tag, master, slave, spriteid, replaceddefine, FLAGS_WRITEDEFINES);
879 tag = write_master(tag, master, slave, spriteid, replaceddefine, FLAGS_WRITENONDEFINES);
882 tag = write_master(tag, master, slave, spriteid, replaceddefine,
883 FLAGS_WRITEDEFINES|FLAGS_WRITENONDEFINES|FLAGS_WRITESLAVE);
885 tag = write_master(tag, master, slave, spriteid, replaceddefine,
886 FLAGS_WRITEDEFINES|FLAGS_WRITENONDEFINES|FLAGS_WRITESPRITE);
890 void combine(SWF*master, char*slave_name, SWF*slave, SWF*newswf)
892 slavename = slave_name;
899 if(slavename[0] == '#')
901 slaveid = atoi(&slavename[1]);
908 if(slavename && slavename[0]!='#' && (sscanf(slavename, "%d", &tmp) ==
909 strlen(slavename))) {
910 /* if the name the slave should replace
911 consists only of digits and the -f
912 option is given, it probably is not
913 a frame name but a frame number.
920 slaveframe = slaveid;
923 /* if id wasn't given as either #number or number,
924 the name is a frame label. BTW: The user wouldn't have
925 needed to supply the -f option in this case */
929 logf("<debug> move x (%d)", config.movex);
930 logf("<debug> move y (%d)", config.movey);
931 logf("<debug> scale x (%f)", config.scalex);
932 logf("<debug> scale y (%f)", config.scaley);
933 logf("<debug> is frame (%d)", config.isframe);
935 memset(masterbitmap, 0, sizeof(masterbitmap));
938 return catcombine(master, slave_name, slave, newswf);
940 return normalcombine(master, slave_name, slave, newswf);
943 int main(int argn, char *argv[])
952 config.antistream = 0;
953 config.alloctest = 0;
966 config.framerate = 0;
972 processargs(argn, argv);
973 initLog(0,-1,0,0,-1,config.loglevel);
975 if(config.merge && config.cat) {
976 logf("<error> Can't combine --cat and --merge");
982 logf("<error> Can't combine -l and -t");
986 logf("<error> Can't combine -c and -t");
989 logf("<verbose> (stacking) %d files found\n", numslaves);
991 makestackmaster(&master);
995 logf("<verbose> master entity %s (named \"%s\")\n", master_filename, master_name);
996 fi = open(master_filename, O_RDONLY);
998 logf("<fatal> Failed to open %s\n", master_filename);
1001 ret = swf_ReadSWF(fi, &master);
1003 logf("<fatal> Failed to read from %s\n", master_filename);
1006 logf("<debug> Read %d bytes from masterfile\n", ret);
1010 for(t=0;t<numslaves;t++) {
1011 logf("<verbose> slave entity(%d) %s (%s \"%s\")\n", t+1, slave_filename[t],
1012 slave_isframe[t]?"frame":"object", slave_name[t]);
1019 logf("<error> --dummy (-d) implies there are zero slave objects. You supplied %d.", numslaves);
1023 slave_filename[0] = "!!dummy!!";
1024 slave_name[0] = "!!dummy!!";
1025 slave_isframe[0] = 0;
1028 if (config.alloctest)
1030 char*bitmap = malloc(sizeof(char)*65536);
1031 memset(bitmap, 0, 65536*sizeof(char));
1032 memset(bitmap, 1, 101*sizeof(char));
1033 swf_Relocate(&master, bitmap);
1036 // makestackmaster(&newswf);
1043 logf("<error> You must have at least two objects.");
1045 logf("<error> You must have at least one slave entity.");
1048 for(t = 0; t < numslaves; t++)
1050 config.movex = slave_movex[t];
1051 config.movey = slave_movey[t];
1052 config.scalex = slave_scalex[t];
1053 config.scaley = slave_scaley[t];
1054 config.isframe = slave_isframe[t];
1056 logf("<notice> Combine [%s]%s and [%s]%s", master_name, master_filename,
1057 slave_name[t], slave_filename[t]);
1061 fi = open(slave_filename[t], O_RDONLY);
1063 logf("<fatal> Failed to open %s\n", slave_filename[t]);
1066 ret = swf_ReadSWF(fi, &slave);
1068 logf("<fatal> Failed to read from %s\n", slave_filename[t]);
1071 logf("<debug> Read %d bytes from slavefile\n", ret);
1076 memset(&slave, 0, sizeof(slave));
1077 slave.firstTag = swf_InsertTag(0, ST_END);
1078 slave.frameRate = 0;
1079 slave.fileVersion = 4;
1080 slave.frameCount = 0;
1083 combine(&master, slave_name[t], &slave, &newswf);
1088 fi = open(outputname, O_RDWR|O_TRUNC|O_CREAT);
1091 swf_WriteSWC(fi, &newswf);
1093 newswf.compressed = 0;
1094 swf_WriteSWF(fi, &newswf);