2 Allows to extract parts of the swf into a new file.
4 Part of the swftools package.
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
25 #include "../lib/rfxswf.h"
26 #include "../lib/args.h"
27 #include "../lib/log.h"
31 #define _ZLIB_INCLUDED_
36 char * destfilename = "output.swf";
40 char* extractframes = 0;
41 char* extractjpegids = 0;
42 char* extractfontids = 0;
43 char* extractpngids = 0;
44 char* extractsoundids = 0;
47 char* extractname = 0;
50 char originalplaceobjects = 0;
55 struct options_t options[] =
75 int args_callback_option(char*name,char*val)
77 if(!strcmp(name, "V")) {
78 printf("swfextract - part of %s %s\n", PACKAGE, VERSION);
81 else if(!strcmp(name, "o")) {
85 else if(!strcmp(name, "i")) {
89 fprintf(stderr, "You can only supply either name or id\n");
94 else if(!strcmp(name, "n")) {
98 fprintf(stderr, "You can only supply either name or id\n");
103 else if(!strcmp(name, "v")) {
107 else if(!strcmp(name, "m")) {
112 else if(!strcmp(name, "j")) {
114 fprintf(stderr, "Only one --jpegs argument is allowed. (Try to use a range, e.g. -j 1,2,3)\n");
118 extractjpegids = val;
121 else if(!strcmp(name, "F")) {
123 fprintf(stderr, "Only one --font argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
127 extractfontids = val;
130 else if(!strcmp(name, "s")) {
131 if(extractsoundids) {
132 fprintf(stderr, "Only one --sound argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
136 extractsoundids = val;
139 #ifdef _ZLIB_INCLUDED_
140 else if(!strcmp(name, "p")) {
142 fprintf(stderr, "Only one --png argument is allowed. (Try to use a range, e.g. -p 1,2,3)\n");
150 else if(!strcmp(name, "f")) {
155 else if(!strcmp(name, "P")) {
156 originalplaceobjects = 1;
159 else if(!strcmp(name, "0")) {
163 else if(!strcmp(name, "w")) {
168 printf("Unknown option: -%s\n", name);
174 int args_callback_longoption(char*name,char*val)
176 return args_long2shortoption(options, name, val);
178 void args_callback_usage(char*name)
180 printf("Usage: %s [-v] [-n name] [-ijf ids] file.swf\n", name);
181 printf("\t-v , --verbose\t\t\t Be more verbose\n");
182 printf("\t-o , --output filename\t\t set output filename\n");
183 printf("\t-V , --version\t\t\t Print program version and exit\n\n");
184 printf("SWF Subelement extraction:\n");
185 printf("\t-n , --name name\t\t instance name of the object (SWF Define) to extract\n");
186 printf("\t-i , --id ID\t\t\t ID of the object, shape or movieclip to extract\n");
187 printf("\t-f , --frame frames\t\t frame numbers to extract\n");
188 printf("\t-w , --hollow\t\t\t hollow mode: don't remove empty frames\n");
189 printf("\t \t\t\t (use with -f)\n");
190 printf("\t-P , --placeobject\t\t\t Insert original placeobject into output file\n");
191 printf("\t \t\t\t (use with -i)\n");
192 printf("SWF Font/Text extraction:\n");
193 printf("\t-F , --font ID\t\t\t Extract font(s)\n");
194 printf("Picture extraction:\n");
195 printf("\t-j , --jpeg ID\t\t\t Extract JPEG picture(s)\n");
196 #ifdef _ZLIB_INCLUDED_
197 printf("\t-p , --pngs ID\t\t\t Extract PNG picture(s)\n");
200 printf("Sound extraction:\n");
201 printf("\t-m , --mp3\t\t\t Extract main mp3 stream\n");
202 printf("\t-s , --sound ID\t\t\t Extract Sound(s)\n");
204 int args_callback_command(char*name,char*val)
207 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
214 U8 mainr,maing,mainb;
215 /* 1 = used, not expanded,
217 5 = wanted, not expanded
224 int extractname_id = -1;
226 void idcallback(void*data)
228 if(!(used[GET16(data)]&1)) {
230 used[GET16(data)] |= 1;
234 void enumerateIDs(TAG*tag, void(*callback)(void*))
240 data = (U8*)malloc(len);
241 PUT16(data, (tag->id<<6)+63);
242 *(U8*)&data[2] = tag->len;
243 *(U8*)&data[3] = tag->len>>8;
244 *(U8*)&data[4] = tag->len>>16;
245 *(U8*)&data[5] = tag->len>>24;
246 memcpy(&data[6], tag->data, tag->len);
249 data = (U8*)malloc(len);
250 PUT16(data, (tag->id<<6)+tag->len);
251 memcpy(&data[2], tag->data, tag->len);
253 map_ids_mem(data, len, callback);
255 int num = swf_GetNumUsedIDs(tag);
256 int *ptr = malloc(sizeof(int)*num);
258 swf_GetUsedIDs(tag, ptr);
260 callback(&tag->data[ptr[t]]);
263 void moveToZero(TAG*tag)
265 if(!swf_isPlaceTag(tag))
268 swf_GetPlaceObject(tag, &obj);
271 swf_ResetTag(tag, tag->id);
272 swf_SetPlaceObject(tag, &obj);
275 void extractTag(SWF*swf, char*filename)
287 memset(&newswf,0x00,sizeof(SWF)); // set global movie parameters
289 newswf.fileVersion = swf->fileVersion;
290 newswf.frameRate = swf->frameRate;
291 newswf.movieSize = swf->movieSize;
292 if(movetozero && originalplaceobjects) {
293 newswf.movieSize.xmax = swf->movieSize.xmax - swf->movieSize.xmin;
294 newswf.movieSize.ymax = swf->movieSize.ymax - swf->movieSize.ymin;
295 newswf.movieSize.xmin = 0;
296 newswf.movieSize.ymin = 0;
299 newswf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
300 desttag = newswf.firstTag;
304 swf_SetRGB(desttag,&rgb);
306 swf_GetRect(0, &objectbbox);
310 for(t=0;t<65536;t++) {
311 if(used[t] && !(used[t]&2)) {
313 msg("<warning> ID %d is referenced, but never defined.", t);
314 } else if(tags[t]->id==ST_DEFINESPRITE) {
316 while(tag->id != ST_END)
318 enumerateIDs(tag, idcallback);
323 enumerateIDs(tags[t], idcallback);
330 srctag = swf->firstTag;
333 while(srctag && (srctag->id || sprite)) {
338 if(srctag->id == ST_END) {
341 if(srctag->id == ST_DEFINESPRITE)
343 if(swf_isDefiningTag(srctag)) {
344 int id = swf_GetDefineID(srctag);
348 b = swf_GetDefineBBox(srctag);
349 swf_ExpandRect2(&objectbbox, &b);
352 if ((((swf_isPlaceTag(srctag) && originalplaceobjects)
353 || srctag->id == ST_STARTSOUND) && (used[swf_GetPlaceID(srctag)]&4) ) ||
354 (swf_isPseudoDefiningTag(srctag) && used[swf_GetDefineID(srctag)]) ||
361 if(srctag->id == ST_REMOVEOBJECT) {
362 if(!used[swf_GetPlaceID(srctag)])
367 TAG*ttag = (TAG*)malloc(sizeof(TAG));
368 desttag = swf_InsertTag(desttag, srctag->id);
369 desttag->len = desttag->memsize = srctag->len;
370 desttag->data = malloc(srctag->len);
371 memcpy(desttag->data, srctag->data, srctag->len);
372 if(movetozero && swf_isPlaceTag(desttag)) {
379 srctag = srctag->next;
382 if(!extractframes && !hollow) {
383 if(!originalplaceobjects && (extractids||extractname_id>=0)) {
389 memset(&bbox, 0, sizeof(SRECT));
391 for(t=0;t<65536;t++) {
392 if(is_in_range(t, extractids)) {
399 printf("warning! You should use the -P when extracting multiple objects\n");
403 /* if there is only one object, we will scale it.
404 So let's figure out its bounding box */
405 TAG*tag = swf->firstTag;
407 if(swf_isDefiningTag(tag) && tag->id != ST_DEFINESPRITE) {
408 if(swf_GetDefineID(tag) == id)
409 bbox = swf_GetDefineBBox(tag);
414 newswf.movieSize.xmin = 0;
415 newswf.movieSize.ymin = 0;
416 newswf.movieSize.xmax = 512*20;
417 newswf.movieSize.ymax = 512*20;
419 if((objectbbox.xmin|objectbbox.ymin|objectbbox.xmax|objectbbox.ymax)!=0)
420 newswf.movieSize = objectbbox;
423 if(extractname_id>=0) {
424 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
425 swf_ObjectPlace(desttag, extractname_id, extractname_id, 0,0,extractname);
427 for(t=0;t<65536;t++) {
428 if(is_in_range(t, extractids)) {
430 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
431 swf_GetMatrix(0, &m);
433 int width = bbox.xmax - bbox.xmin;
434 int height = bbox.ymax - bbox.ymin;
435 int max = width>height?width:height;
439 m.sx = (512*20*65536)/max;
440 m.sy = (512*20*65536)/max;
442 //newswf.movieSize = swf_TurnRect(newswf.movieSize, &m);
444 swf_ObjectPlace(desttag, t, t, &m,0,0);
449 desttag = swf_InsertTag(desttag,ST_SHOWFRAME);
451 desttag = swf_InsertTag(desttag,ST_END);
453 f = open(filename, O_TRUNC|O_WRONLY|O_CREAT|O_BINARY, 0644);
454 if FAILED(swf_WriteSWF(f,&newswf)) fprintf(stderr,"WriteSWF() failed.\n");
457 swf_FreeTags(&newswf); // cleanup
460 int isOfType(int t, TAG*tag)
463 if(t == 0 && (tag->id == ST_DEFINESHAPE ||
464 tag->id == ST_DEFINESHAPE2 ||
465 tag->id == ST_DEFINESHAPE3)) {
468 if(t==1 && tag->id == ST_DEFINESPRITE) {
471 if(t == 2 && (tag->id == ST_DEFINEBITS ||
472 tag->id == ST_DEFINEBITSJPEG2 ||
473 tag->id == ST_DEFINEBITSJPEG3)) {
476 if(t == 3 && (tag->id == ST_DEFINEBITSLOSSLESS ||
477 tag->id == ST_DEFINEBITSLOSSLESS2)) {
480 if(t == 4 && (tag->id == ST_DEFINESOUND)) {
483 if(t == 5 && (tag->id == ST_DEFINEFONT || tag->id == ST_DEFINEFONT2)) {
489 void listObjects(SWF*swf)
495 char*names[] = {"Shape", "MovieClip", "JPEG", "PNG", "Sound", "Font"};
496 char*options[] = {"-i", "-i", "-j", "-p", "-s", "-F"};
498 printf("Objects in file %s:\n",filename);
500 for(t=0;t<sizeof(names)/sizeof(names[0]);t++) {
502 int lastid = -2, lastprint=-1;
507 if(tag->id == ST_SOUNDSTREAMHEAD || tag->id == ST_SOUNDSTREAMHEAD2)
516 printf(" [%s] %d %s%s: ID(s) ", options[t], nr, names[t], nr>1?"s":"");
521 char show = isOfType(t,tag);
527 id = swf_GetDefineID(tag);
532 if(first || !follow) {
537 if(lastprint + 1 == lastid)
538 printf(", %d, %d", lastid, id);
540 printf("-%d, %d", lastid, id);
550 if(lastprint + 1 == lastid)
551 printf(", %d", lastid);
553 printf("-%d", lastid);
559 printf(" [-f] %d Frames: ID(s) 0-%d\n", frame, frame);
561 printf(" [-f] 1 Frame: ID(s) 0\n");
564 printf(" [-m] 1 MP3 Soundstream\n");
567 void handlefont(SWF*swf, TAG*tag)
572 char*filename = name;
575 id = swf_GetDefineID(tag);
576 sprintf(name, "font%d.swf", id);
578 filename = destfilename;
581 swf_FontExtract(swf, id, &f);
583 printf("Couldn't extract font %d\n", id);
587 swf_FontCreateLayout(f);
589 swf_WriteFont(f, filename);
596 void handlejpegtables(TAG*tag)
598 if(tag->id == ST_JPEGTABLES) {
599 jpegtables = tag->data;
600 jpegtablessize = tag->len;
604 FILE* save_fopen(char* name, char* mode)
606 FILE*fi = fopen(name, mode);
608 fprintf(stderr, "Error: Couldn't open %s\n", name);
614 int findjpegboundary(U8*data, int len)
629 /* extract jpeg data out of a tag */
630 void handlejpeg(TAG*tag)
633 char*filename = name;
636 sprintf(name, "pic%d.jpg", GET16(tag->data));
638 filename = destfilename;
639 if(!strcmp(filename,"output.swf"))
640 filename = "output.jpg";
642 /* swf jpeg images have two streams, which both start with ff d8 and
643 end with ff d9. The following code handles sorting the middle
644 <ff d9 ff d8> bytes out, so that one stream remains */
645 if(tag->id == ST_DEFINEBITSJPEG && tag->len>2 && jpegtables) {
646 fi = save_fopen(filename, "wb");
647 fwrite(jpegtables, 1, jpegtablessize-2, fi); //don't write end tag (ff,d8)
648 fwrite(&tag->data[2+2], tag->len-2-2, 1, fi); //don't write start tag (ff,d9)
651 else if(tag->id == ST_DEFINEBITSJPEG2 && tag->len>2) {
653 int pos = findjpegboundary(&tag->data[2], tag->len-2);
656 fi = save_fopen(filename, "wb");
657 fwrite(&tag->data[2], pos-2, 1, fi);
658 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
661 fi = save_fopen(filename, "wb");
662 fwrite(&tag->data[2], end-2, 1, fi);
666 else if(tag->id == ST_DEFINEBITSJPEG3 && tag->len>6) {
667 U32 end = GET32(&tag->data[2])+6;
668 int pos = findjpegboundary(&tag->data[6], tag->len-6);
672 fi = save_fopen(filename, "wb");
673 fwrite(&tag->data[6], pos-6, 1, fi);
674 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
678 int id = GET16(tag->data);
679 fprintf(stderr, "Object %d is not a JPEG picture!\n",id);
684 #ifdef _ZLIB_INCLUDED_
687 static U32*crc32_table = 0;
688 static void make_crc32_table(void)
693 crc32_table = (U32*)malloc(1024);
695 for (t = 0; t < 256; t++) {
698 for (s = 0; s < 8; s++) {
699 c = (0xedb88320L*(c&1)) ^ (c >> 1);
704 static inline void png_write_byte(FILE*fi, U8 byte)
706 fwrite(&byte,1,1,fi);
707 mycrc32 = crc32_table[(mycrc32 ^ byte) & 0xff] ^ (mycrc32 >> 8);
709 static void png_start_chunk(FILE*fi, char*type, int len)
711 U8 mytype[4]={0,0,0,0};
712 U32 mylen = REVERSESWAP32(len);
713 memcpy(mytype,type,strlen(type));
714 fwrite(&mylen, 4, 1, fi);
716 png_write_byte(fi,mytype[0]);
717 png_write_byte(fi,mytype[1]);
718 png_write_byte(fi,mytype[2]);
719 png_write_byte(fi,mytype[3]);
721 static void png_write_bytes(FILE*fi, U8*bytes, int len)
725 png_write_byte(fi,bytes[t]);
727 static void png_write_dword(FILE*fi, U32 dword)
729 png_write_byte(fi,dword>>24);
730 png_write_byte(fi,dword>>16);
731 png_write_byte(fi,dword>>8);
732 png_write_byte(fi,dword);
734 static void png_end_chunk(FILE*fi)
736 U32 tmp = REVERSESWAP32((mycrc32^0xffffffff));
741 /* extract a lossless image (png) out of a tag
742 This routine was originally meant to be a one-pager. I just
743 didn't know png is _that_ much fun. :) -mk
745 void handlelossless(TAG*tag)
748 char*filename = name;
763 U8 head[] = {137,80,78,71,13,10,26,10};
765 char alpha = tag->id == ST_DEFINEBITSLOSSLESS2;
773 if(tag->id != ST_DEFINEBITSLOSSLESS &&
774 tag->id != ST_DEFINEBITSLOSSLESS2) {
775 int id = GET16(tag->data);
776 fprintf(stderr, "Object %d is not a PNG picture!\n",id);
781 format = swf_GetU8(tag);
782 if(format == 3) bpp = 8;
783 if(format == 4) bpp = 16;
784 if(format == 5) bpp = 32;
785 if(format!=3 && format!=5) {
787 fprintf(stderr, "Can't handle 16-bit palette images yet (image %d)\n",id);
789 fprintf(stderr, "Unknown image type %d in image %d\n", format, id);
792 width = swf_GetU16(tag);
793 height = swf_GetU16(tag);
794 if(format == 3) cols = swf_GetU8(tag) + 1;
795 // this is what format means according to the flash specification. (which is
797 // if(format == 4) cols = swf_GetU16(tag) + 1;
798 // if(format == 5) cols = swf_GetU32(tag) + 1;
801 msg("<verbose> Width %d", width);
802 msg("<verbose> Height %d", height);
803 msg("<verbose> Format %d", format);
804 msg("<verbose> Cols %d", cols);
805 msg("<verbose> Bpp %d", bpp);
807 datalen = (width*height*bpp/8+cols*8);
812 data = malloc(datalen);
813 error = uncompress (data, &datalen, &tag->data[tag->pos], tag->len-tag->pos);
814 } while(error == Z_BUF_ERROR);
816 fprintf(stderr, "Zlib error %d (image %d)\n", error, id);
819 msg("<verbose> Uncompressed image is %d bytes (%d colormap)", datalen, (3+alpha)*cols);
822 data2 = malloc(datalen2);
823 palette = (RGBA*)malloc(cols*sizeof(RGBA));
825 for(t=0;t<cols;t++) {
826 palette[t].r = data[pos++];
827 palette[t].g = data[pos++];
828 palette[t].b = data[pos++];
830 palette[t].a = data[pos++];
834 sprintf(name, "pic%d.png", id);
836 filename = destfilename;
837 if(!strcmp(filename,"output.swf"))
838 filename = "output.png";
840 fi = save_fopen(filename, "wb");
841 fwrite(head,sizeof(head),1,fi);
843 png_start_chunk(fi, "IHDR", 13);
844 png_write_dword(fi,width);
845 png_write_dword(fi,height);
846 png_write_byte(fi,8);
848 png_write_byte(fi,3); //indexed
849 else if(format == 5 && alpha==0)
850 png_write_byte(fi,2); //rgb
851 else if(format == 5 && alpha==1)
852 png_write_byte(fi,6); //rgba
855 png_write_byte(fi,0); //compression mode
856 png_write_byte(fi,0); //filter mode
857 png_write_byte(fi,0); //interlace mode
861 png_start_chunk(fi, "PLTE", 768);
864 png_write_byte(fi,palette[t].r);
865 png_write_byte(fi,palette[t].g);
866 png_write_byte(fi,palette[t].b);
871 /* write alpha palette */
872 png_start_chunk(fi, "tRNS", 256);
874 png_write_byte(fi,palette[t].a);
882 int srcwidth = width * (bpp/8);
883 datalen3 = (width*4+5)*height;
884 data3 = (U8*)malloc(datalen3);
885 for(y=0;y<height;y++)
887 data3[pos2++]=0; //filter type
890 // 32 bit to 24 bit "conversion"
891 for(x=0;x<width;x++) {
892 data3[pos2++]=data[pos+1];
893 data3[pos2++]=data[pos+2];
894 data3[pos2++]=data[pos+3];
895 pos+=4; //ignore padding byte
898 for(x=0;x<width;x++) {
899 data3[pos2++]=data[pos+1];
900 data3[pos2++]=data[pos+2];
901 data3[pos2++]=data[pos+3];
902 data3[pos2++]=data[pos+0]; //alpha
908 for(x=0;x<srcwidth;x++)
909 data3[pos2++]=data[pos++];
912 pos+=((srcwidth+3)&~3)-srcwidth; //align
917 if(compress (data2, &datalen2, data3, datalen3) != Z_OK) {
918 fprintf(stderr, "zlib error in pic %d\n", id);
921 msg("<verbose> Compressed data is %d bytes", datalen2);
922 png_start_chunk(fi, "IDAT", datalen2);
923 png_write_bytes(fi,data2,datalen2);
925 png_start_chunk(fi, "IEND", 0);
935 void handlesoundstream(TAG*tag)
937 char*filename = "output.mp3";
939 filename = destfilename;
940 if(!strcmp(filename,"output.swf"))
941 filename = "output.mp3";
944 case ST_SOUNDSTREAMHEAD:
945 if((tag->data[1]&0x30) == 0x20) { //mp3 compression
946 mp3file = fopen(filename, "wb");
947 msg("<notice> Writing mp3 data to %s",filename);
950 msg("<error> Soundstream is not mp3");
952 case ST_SOUNDSTREAMHEAD2:
953 if((tag->data[1]&0x30) == 0x20) {//mp3 compression
954 mp3file = fopen(filename, "wb");
955 msg("<notice> Writing mp3 data to %s",filename);
958 msg("<error> Soundstream is not mp3 (2)");
960 case ST_SOUNDSTREAMBLOCK:
962 fwrite(&tag->data[4],tag->len-4,1,mp3file);
967 void handledefinesound(TAG*tag)
977 int rate,bits,stereo;
978 char*rates[] = {"5500","11025","22050","44100"};
979 id = swf_GetU16(tag); //id
981 flags = swf_GetU8(tag);
987 samples = swf_GetU32(tag);
991 if(format == 2) { // mp3
992 swf_GetU16(tag); //numsamples_seek
994 } else if(format == 0) { // raw
995 printf("Sound is RAW, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
996 // TODO: convert to WAV
998 } else if(format == 1) { // adpcm
999 printf("Sound is ADPCM, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
1000 extension = "adpcm";
1002 sprintf(buf, "sound%d.%s", id, extension);
1003 if(numextracts==1) {
1004 filename = destfilename;
1005 if(!strcmp(filename,"output.swf")) {
1006 sprintf(buf, "output.%s", extension);
1010 fi = save_fopen(filename, "wb");
1011 fwrite(&tag->data[tag->pos], tag->len - tag->pos, 1, fi);
1015 int main (int argc,char ** argv)
1024 char listavailable = 0;
1025 processargs(argc, argv);
1027 if(!extractframes && !extractids && ! extractname && !extractjpegids && !extractpngids
1028 && !extractmp3 && !extractsoundids && !extractfontids)
1031 if(!originalplaceobjects && movetozero) {
1032 fprintf(stderr, "Error: -0 (--movetozero) can only be used in conjunction with -P (--placeobject)\n");
1038 fprintf(stderr, "You must supply a filename.\n");
1041 initLog(0,-1,0,0,-1, verbose);
1043 f = open(filename,O_RDONLY|O_BINARY);
1047 perror("Couldn't open file: ");
1050 if (swf_ReadSWF(f,&swf) < 0)
1052 fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
1071 tagused = (char*)malloc(tagnum);
1072 memset(tagused, 0, tagnum);
1073 memset(used, 0, 65536);
1074 memset(depths, 0, 65536);
1079 if(swf_isAllowedSpriteTag(tag)) {
1081 if(extractframes && is_in_range(frame, extractframes)) {
1083 if(tag->id == ST_PLACEOBJECT || tag->id == ST_PLACEOBJECT2) {
1084 depths[swf_GetDepth(tag)] = 1;
1086 if(tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) {
1087 int depth = swf_GetDepth(tag);
1090 depths[swf_GetDepth(tag)] = 0;
1093 if((tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) &&
1094 (depths[swf_GetDepth(tag)]) && hollow) {
1096 depths[swf_GetDepth(tag)] = 0;
1100 enumerateIDs(tag, idcallback);
1102 tagused[tagnum] = 1;
1106 if(tag->id == ST_SOUNDSTREAMHEAD ||
1107 tag->id == ST_SOUNDSTREAMHEAD2 ||
1108 tag->id == ST_SOUNDSTREAMBLOCK) {
1110 handlesoundstream(tag);
1113 if(tag->id == ST_JPEGTABLES)
1114 handlejpegtables(tag);
1116 if(swf_isDefiningTag(tag)) {
1117 int id = swf_GetDefineID(tag);
1119 if(extractids && is_in_range(id, extractids)) {
1123 if(extractfontids && is_in_range(id, extractfontids)) {
1124 handlefont(&swf, tag);
1126 if(extractjpegids && is_in_range(id, extractjpegids)) {
1129 if(extractsoundids && is_in_range(id, extractsoundids)) {
1130 handledefinesound(tag);
1132 #ifdef _ZLIB_INCLUDED_
1133 if(extractpngids && is_in_range(id, extractpngids)) {
1134 handlelossless(tag);
1138 else if (tag->id == ST_SETBACKGROUNDCOLOR) {
1139 mainr = tag->data[0];
1140 maing = tag->data[1];
1141 mainb = tag->data[2];
1143 else if(swf_isPlaceTag(tag) && tag->id != ST_PLACEOBJECT ) {
1144 char*name = swf_GetName(tag);
1145 if(name && extractname && !strcmp(name, extractname)) {
1146 int id = swf_GetPlaceID(tag);
1149 if(originalplaceobjects) {
1150 tagused[tagnum] = 1;
1152 depths[swf_GetDepth(tag)] = 1;
1153 extractname_id = id;
1156 else if(tag->id == ST_SHOWFRAME) {
1159 tagused[tagnum] = 1;
1164 if(tag->id == ST_DEFINESPRITE) {
1165 while(tag->id != ST_END) {
1174 extractTag(&swf, destfilename);