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");
117 /* TODO: count number of IDs in val range */
119 extractjpegids = val;
122 else if(!strcmp(name, "F")) {
124 fprintf(stderr, "Only one --font argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
128 extractfontids = val;
131 else if(!strcmp(name, "s")) {
132 if(extractsoundids) {
133 fprintf(stderr, "Only one --sound argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
137 extractsoundids = val;
140 #ifdef _ZLIB_INCLUDED_
141 else if(!strcmp(name, "p")) {
143 fprintf(stderr, "Only one --png argument is allowed. (Try to use a range, e.g. -p 1,2,3)\n");
151 else if(!strcmp(name, "f")) {
156 else if(!strcmp(name, "P")) {
157 originalplaceobjects = 1;
160 else if(!strcmp(name, "0")) {
164 else if(!strcmp(name, "w")) {
169 printf("Unknown option: -%s\n", name);
175 int args_callback_longoption(char*name,char*val)
177 return args_long2shortoption(options, name, val);
179 void args_callback_usage(char*name)
181 printf("Usage: %s [-v] [-n name] [-ijf ids] file.swf\n", name);
182 printf("\t-v , --verbose\t\t\t Be more verbose\n");
183 printf("\t-o , --output filename\t\t set output filename\n");
184 printf("\t-V , --version\t\t\t Print program version and exit\n\n");
185 printf("SWF Subelement extraction:\n");
186 printf("\t-n , --name name\t\t instance name of the object (SWF Define) to extract\n");
187 printf("\t-i , --id ID\t\t\t ID of the object, shape or movieclip to extract\n");
188 printf("\t-f , --frame frames\t\t frame numbers to extract\n");
189 printf("\t-w , --hollow\t\t\t hollow mode: don't remove empty frames\n");
190 printf("\t \t\t\t (use with -f)\n");
191 printf("\t-P , --placeobject\t\t\t Insert original placeobject into output file\n");
192 printf("\t \t\t\t (use with -i)\n");
193 printf("SWF Font/Text extraction:\n");
194 printf("\t-F , --font ID\t\t\t Extract font(s)\n");
195 printf("Picture extraction:\n");
196 printf("\t-j , --jpeg ID\t\t\t Extract JPEG picture(s)\n");
197 #ifdef _ZLIB_INCLUDED_
198 printf("\t-p , --pngs ID\t\t\t Extract PNG picture(s)\n");
201 printf("Sound extraction:\n");
202 printf("\t-m , --mp3\t\t\t Extract main mp3 stream\n");
203 printf("\t-s , --sound ID\t\t\t Extract Sound(s)\n");
205 int args_callback_command(char*name,char*val)
208 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
215 U8 mainr,maing,mainb;
216 /* 1 = used, not expanded,
218 5 = wanted, not expanded
225 int extractname_id = -1;
227 void idcallback(void*data)
229 if(!(used[GET16(data)]&1)) {
231 used[GET16(data)] |= 1;
235 void enumerateIDs(TAG*tag, void(*callback)(void*))
241 data = (U8*)malloc(len);
242 PUT16(data, (tag->id<<6)+63);
243 *(U8*)&data[2] = tag->len;
244 *(U8*)&data[3] = tag->len>>8;
245 *(U8*)&data[4] = tag->len>>16;
246 *(U8*)&data[5] = tag->len>>24;
247 memcpy(&data[6], tag->data, tag->len);
250 data = (U8*)malloc(len);
251 PUT16(data, (tag->id<<6)+tag->len);
252 memcpy(&data[2], tag->data, tag->len);
254 map_ids_mem(data, len, callback);
256 int num = swf_GetNumUsedIDs(tag);
257 int *ptr = malloc(sizeof(int)*num);
259 swf_GetUsedIDs(tag, ptr);
261 callback(&tag->data[ptr[t]]);
264 void moveToZero(TAG*tag)
266 if(!swf_isPlaceTag(tag))
269 swf_GetPlaceObject(tag, &obj);
272 swf_ResetTag(tag, tag->id);
273 swf_SetPlaceObject(tag, &obj);
276 void extractTag(SWF*swf, char*filename)
288 memset(&newswf,0x00,sizeof(SWF)); // set global movie parameters
290 newswf.fileVersion = swf->fileVersion;
291 newswf.frameRate = swf->frameRate;
292 newswf.movieSize = swf->movieSize;
293 if(movetozero && originalplaceobjects) {
294 newswf.movieSize.xmax = swf->movieSize.xmax - swf->movieSize.xmin;
295 newswf.movieSize.ymax = swf->movieSize.ymax - swf->movieSize.ymin;
296 newswf.movieSize.xmin = 0;
297 newswf.movieSize.ymin = 0;
300 newswf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
301 desttag = newswf.firstTag;
305 swf_SetRGB(desttag,&rgb);
307 swf_GetRect(0, &objectbbox);
311 for(t=0;t<65536;t++) {
312 if(used[t] && !(used[t]&2)) {
314 msg("<warning> ID %d is referenced, but never defined.", t);
315 } else if(tags[t]->id==ST_DEFINESPRITE) {
317 while(tag->id != ST_END)
319 enumerateIDs(tag, idcallback);
324 enumerateIDs(tags[t], idcallback);
331 srctag = swf->firstTag;
334 while(srctag && (srctag->id || sprite)) {
339 if(srctag->id == ST_END) {
342 if(srctag->id == ST_DEFINESPRITE)
344 if(srctag->id == ST_JPEGTABLES)
346 if(swf_isDefiningTag(srctag)) {
347 int id = swf_GetDefineID(srctag);
351 b = swf_GetDefineBBox(srctag);
352 swf_ExpandRect2(&objectbbox, &b);
355 if ((((swf_isPlaceTag(srctag) && originalplaceobjects)
356 || srctag->id == ST_STARTSOUND) && (used[swf_GetPlaceID(srctag)]&4) ) ||
357 (swf_isPseudoDefiningTag(srctag) && used[swf_GetDefineID(srctag)]) ||
364 if(srctag->id == ST_REMOVEOBJECT) {
365 if(!used[swf_GetPlaceID(srctag)])
370 TAG*ttag = (TAG*)malloc(sizeof(TAG));
371 desttag = swf_InsertTag(desttag, srctag->id);
372 desttag->len = desttag->memsize = srctag->len;
373 desttag->data = malloc(srctag->len);
374 memcpy(desttag->data, srctag->data, srctag->len);
375 if(movetozero && swf_isPlaceTag(desttag)) {
382 srctag = srctag->next;
385 if(!extractframes && !hollow) {
386 if(!originalplaceobjects && (extractids||extractname_id>=0)) {
392 memset(&bbox, 0, sizeof(SRECT));
394 for(t=0;t<65536;t++) {
395 if(is_in_range(t, extractids)) {
402 printf("warning! You should use the -P when extracting multiple objects\n");
406 /* if there is only one object, we will scale it.
407 So let's figure out its bounding box */
408 TAG*tag = swf->firstTag;
410 if(swf_isDefiningTag(tag) && tag->id != ST_DEFINESPRITE) {
411 if(swf_GetDefineID(tag) == id)
412 bbox = swf_GetDefineBBox(tag);
417 newswf.movieSize.xmin = 0;
418 newswf.movieSize.ymin = 0;
419 newswf.movieSize.xmax = 512*20;
420 newswf.movieSize.ymax = 512*20;
422 if((objectbbox.xmin|objectbbox.ymin|objectbbox.xmax|objectbbox.ymax)!=0)
423 newswf.movieSize = objectbbox;
426 if(extractname_id>=0) {
427 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
428 swf_ObjectPlace(desttag, extractname_id, extractname_id, 0,0,extractname);
430 for(t=0;t<65536;t++) {
431 if(is_in_range(t, extractids)) {
433 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
434 swf_GetMatrix(0, &m);
436 int width = bbox.xmax - bbox.xmin;
437 int height = bbox.ymax - bbox.ymin;
438 int max = width>height?width:height;
442 m.sx = (512*20*65536)/max;
443 m.sy = (512*20*65536)/max;
445 //newswf.movieSize = swf_TurnRect(newswf.movieSize, &m);
447 swf_ObjectPlace(desttag, t, t, &m,0,0);
452 desttag = swf_InsertTag(desttag,ST_SHOWFRAME);
454 desttag = swf_InsertTag(desttag,ST_END);
456 f = open(filename, O_TRUNC|O_WRONLY|O_CREAT|O_BINARY, 0644);
457 if FAILED(swf_WriteSWF(f,&newswf)) fprintf(stderr,"WriteSWF() failed.\n");
460 swf_FreeTags(&newswf); // cleanup
463 int isOfType(int t, TAG*tag)
466 if(t == 0 && (tag->id == ST_DEFINESHAPE ||
467 tag->id == ST_DEFINESHAPE2 ||
468 tag->id == ST_DEFINESHAPE3)) {
471 if(t==1 && tag->id == ST_DEFINESPRITE) {
474 if(t == 2 && (tag->id == ST_DEFINEBITS ||
475 tag->id == ST_DEFINEBITSJPEG2 ||
476 tag->id == ST_DEFINEBITSJPEG3)) {
479 if(t == 3 && (tag->id == ST_DEFINEBITSLOSSLESS ||
480 tag->id == ST_DEFINEBITSLOSSLESS2)) {
483 if(t == 4 && (tag->id == ST_DEFINESOUND)) {
486 if(t == 5 && (tag->id == ST_DEFINEFONT || tag->id == ST_DEFINEFONT2)) {
492 void listObjects(SWF*swf)
498 char*names[] = {"Shape", "MovieClip", "JPEG", "PNG", "Sound", "Font"};
499 char*options[] = {"-i", "-i", "-j", "-p", "-s", "-F"};
501 printf("Objects in file %s:\n",filename);
503 for(t=0;t<sizeof(names)/sizeof(names[0]);t++) {
505 int lastid = -2, lastprint=-1;
510 if(tag->id == ST_SOUNDSTREAMHEAD || tag->id == ST_SOUNDSTREAMHEAD2)
519 printf(" [%s] %d %s%s: ID(s) ", options[t], nr, names[t], nr>1?"s":"");
524 char show = isOfType(t,tag);
530 id = swf_GetDefineID(tag);
535 if(first || !follow) {
540 if(lastprint + 1 == lastid)
541 printf(", %d, %d", lastid, id);
543 printf("-%d, %d", lastid, id);
553 if(lastprint + 1 == lastid)
554 printf(", %d", lastid);
556 printf("-%d", lastid);
562 printf(" [-f] %d Frames: ID(s) 0-%d\n", frame, frame);
564 printf(" [-f] 1 Frame: ID(s) 0\n");
567 printf(" [-m] 1 MP3 Soundstream\n");
570 void handlefont(SWF*swf, TAG*tag)
575 char*filename = name;
578 id = swf_GetDefineID(tag);
579 sprintf(name, "font%d.swf", id);
581 filename = destfilename;
584 swf_FontExtract(swf, id, &f);
586 printf("Couldn't extract font %d\n", id);
590 swf_FontCreateLayout(f);
592 swf_WriteFont(f, filename);
599 void handlejpegtables(TAG*tag)
601 if(tag->id == ST_JPEGTABLES) {
602 jpegtables = tag->data;
603 jpegtablessize = tag->len;
607 FILE* save_fopen(char* name, char* mode)
609 FILE*fi = fopen(name, mode);
611 fprintf(stderr, "Error: Couldn't open %s\n", name);
617 int findjpegboundary(U8*data, int len)
632 /* extract jpeg data out of a tag */
633 void handlejpeg(TAG*tag)
636 char*filename = name;
639 sprintf(name, "pic%d.jpg", GET16(tag->data));
641 filename = destfilename;
642 if(!strcmp(filename,"output.swf"))
643 filename = "output.jpg";
645 /* swf jpeg images have two streams, which both start with ff d8 and
646 end with ff d9. The following code handles sorting the middle
647 <ff d9 ff d8> bytes out, so that one stream remains */
648 if(tag->id == ST_DEFINEBITSJPEG && tag->len>2 && jpegtables) {
649 fi = save_fopen(filename, "wb");
650 fwrite(jpegtables, 1, jpegtablessize-2, fi); //don't write end tag (ff,d8)
651 fwrite(&tag->data[2+2], tag->len-2-2, 1, fi); //don't write start tag (ff,d9)
654 else if(tag->id == ST_DEFINEBITSJPEG2 && tag->len>2) {
656 int pos = findjpegboundary(&tag->data[2], tag->len-2);
659 fi = save_fopen(filename, "wb");
660 fwrite(&tag->data[2], pos-2, 1, fi);
661 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
664 fi = save_fopen(filename, "wb");
665 fwrite(&tag->data[2], end-2, 1, fi);
669 else if(tag->id == ST_DEFINEBITSJPEG3 && tag->len>6) {
670 U32 end = GET32(&tag->data[2])+6;
671 int pos = findjpegboundary(&tag->data[6], tag->len-6);
675 fi = save_fopen(filename, "wb");
676 fwrite(&tag->data[6], pos-6, 1, fi);
677 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
681 int id = GET16(tag->data);
682 fprintf(stderr, "Object %d is not a JPEG picture!\n",id);
687 #ifdef _ZLIB_INCLUDED_
690 static U32*crc32_table = 0;
691 static void make_crc32_table(void)
696 crc32_table = (U32*)malloc(1024);
698 for (t = 0; t < 256; t++) {
701 for (s = 0; s < 8; s++) {
702 c = (0xedb88320L*(c&1)) ^ (c >> 1);
707 static inline void png_write_byte(FILE*fi, U8 byte)
709 fwrite(&byte,1,1,fi);
710 mycrc32 = crc32_table[(mycrc32 ^ byte) & 0xff] ^ (mycrc32 >> 8);
712 static void png_start_chunk(FILE*fi, char*type, int len)
714 U8 mytype[4]={0,0,0,0};
715 U32 mylen = REVERSESWAP32(len);
716 memcpy(mytype,type,strlen(type));
717 fwrite(&mylen, 4, 1, fi);
719 png_write_byte(fi,mytype[0]);
720 png_write_byte(fi,mytype[1]);
721 png_write_byte(fi,mytype[2]);
722 png_write_byte(fi,mytype[3]);
724 static void png_write_bytes(FILE*fi, U8*bytes, int len)
728 png_write_byte(fi,bytes[t]);
730 static void png_write_dword(FILE*fi, U32 dword)
732 png_write_byte(fi,dword>>24);
733 png_write_byte(fi,dword>>16);
734 png_write_byte(fi,dword>>8);
735 png_write_byte(fi,dword);
737 static void png_end_chunk(FILE*fi)
739 U32 tmp = REVERSESWAP32((mycrc32^0xffffffff));
744 /* extract a lossless image (png) out of a tag
745 This routine was originally meant to be a one-pager. I just
746 didn't know png is _that_ much fun. :) -mk
748 void handlelossless(TAG*tag)
751 char*filename = name;
766 U8 head[] = {137,80,78,71,13,10,26,10};
768 char alpha = tag->id == ST_DEFINEBITSLOSSLESS2;
776 if(tag->id != ST_DEFINEBITSLOSSLESS &&
777 tag->id != ST_DEFINEBITSLOSSLESS2) {
778 int id = GET16(tag->data);
779 fprintf(stderr, "Object %d is not a PNG picture!\n",id);
784 format = swf_GetU8(tag);
785 if(format == 3) bpp = 8;
786 if(format == 4) bpp = 16;
787 if(format == 5) bpp = 32;
788 if(format!=3 && format!=5) {
790 fprintf(stderr, "Can't handle 16-bit palette images yet (image %d)\n",id);
792 fprintf(stderr, "Unknown image type %d in image %d\n", format, id);
795 width = swf_GetU16(tag);
796 height = swf_GetU16(tag);
797 if(format == 3) cols = swf_GetU8(tag) + 1;
798 // this is what format means according to the flash specification. (which is
800 // if(format == 4) cols = swf_GetU16(tag) + 1;
801 // if(format == 5) cols = swf_GetU32(tag) + 1;
804 msg("<verbose> Width %d", width);
805 msg("<verbose> Height %d", height);
806 msg("<verbose> Format %d", format);
807 msg("<verbose> Cols %d", cols);
808 msg("<verbose> Bpp %d", bpp);
810 datalen = (width*height*bpp/8+cols*8);
815 data = malloc(datalen);
816 error = uncompress (data, &datalen, &tag->data[tag->pos], tag->len-tag->pos);
817 } while(error == Z_BUF_ERROR);
819 fprintf(stderr, "Zlib error %d (image %d)\n", error, id);
822 msg("<verbose> Uncompressed image is %d bytes (%d colormap)", datalen, (3+alpha)*cols);
825 data2 = malloc(datalen2);
826 palette = (RGBA*)malloc(cols*sizeof(RGBA));
828 for(t=0;t<cols;t++) {
829 palette[t].r = data[pos++];
830 palette[t].g = data[pos++];
831 palette[t].b = data[pos++];
833 palette[t].a = data[pos++];
837 sprintf(name, "pic%d.png", id);
839 filename = destfilename;
840 if(!strcmp(filename,"output.swf"))
841 filename = "output.png";
843 fi = save_fopen(filename, "wb");
844 fwrite(head,sizeof(head),1,fi);
846 png_start_chunk(fi, "IHDR", 13);
847 png_write_dword(fi,width);
848 png_write_dword(fi,height);
849 png_write_byte(fi,8);
851 png_write_byte(fi,3); //indexed
852 else if(format == 5 && alpha==0)
853 png_write_byte(fi,2); //rgb
854 else if(format == 5 && alpha==1)
855 png_write_byte(fi,6); //rgba
858 png_write_byte(fi,0); //compression mode
859 png_write_byte(fi,0); //filter mode
860 png_write_byte(fi,0); //interlace mode
864 png_start_chunk(fi, "PLTE", 768);
867 png_write_byte(fi,palette[t].r);
868 png_write_byte(fi,palette[t].g);
869 png_write_byte(fi,palette[t].b);
874 /* write alpha palette */
875 png_start_chunk(fi, "tRNS", 256);
877 png_write_byte(fi,palette[t].a);
885 int srcwidth = width * (bpp/8);
886 datalen3 = (width*4+5)*height;
887 data3 = (U8*)malloc(datalen3);
888 for(y=0;y<height;y++)
890 data3[pos2++]=0; //filter type
893 // 32 bit to 24 bit "conversion"
894 for(x=0;x<width;x++) {
895 data3[pos2++]=data[pos+1];
896 data3[pos2++]=data[pos+2];
897 data3[pos2++]=data[pos+3];
898 pos+=4; //ignore padding byte
901 for(x=0;x<width;x++) {
902 data3[pos2++]=data[pos+1];
903 data3[pos2++]=data[pos+2];
904 data3[pos2++]=data[pos+3];
905 data3[pos2++]=data[pos+0]; //alpha
911 for(x=0;x<srcwidth;x++)
912 data3[pos2++]=data[pos++];
915 pos+=((srcwidth+3)&~3)-srcwidth; //align
920 if(compress (data2, &datalen2, data3, datalen3) != Z_OK) {
921 fprintf(stderr, "zlib error in pic %d\n", id);
924 msg("<verbose> Compressed data is %d bytes", datalen2);
925 png_start_chunk(fi, "IDAT", datalen2);
926 png_write_bytes(fi,data2,datalen2);
928 png_start_chunk(fi, "IEND", 0);
938 void handlesoundstream(TAG*tag)
940 char*filename = "output.mp3";
942 filename = destfilename;
943 if(!strcmp(filename,"output.swf"))
944 filename = "output.mp3";
947 case ST_SOUNDSTREAMHEAD:
948 if((tag->data[1]&0x30) == 0x20) { //mp3 compression
949 mp3file = fopen(filename, "wb");
950 msg("<notice> Writing mp3 data to %s",filename);
953 msg("<error> Soundstream is not mp3");
955 case ST_SOUNDSTREAMHEAD2:
956 if((tag->data[1]&0x30) == 0x20) {//mp3 compression
957 mp3file = fopen(filename, "wb");
958 msg("<notice> Writing mp3 data to %s",filename);
961 msg("<error> Soundstream is not mp3 (2)");
963 case ST_SOUNDSTREAMBLOCK:
965 fwrite(&tag->data[4],tag->len-4,1,mp3file);
970 void handledefinesound(TAG*tag)
980 int rate,bits,stereo;
981 char*rates[] = {"5500","11025","22050","44100"};
982 id = swf_GetU16(tag); //id
984 flags = swf_GetU8(tag);
990 samples = swf_GetU32(tag);
994 if(format == 2) { // mp3
995 swf_GetU16(tag); //numsamples_seek
997 } else if(format == 0) { // raw
998 printf("Sound is RAW, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
999 // TODO: convert to WAV
1001 } else if(format == 1) { // adpcm
1002 printf("Sound is ADPCM, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
1003 extension = "adpcm";
1005 sprintf(buf, "sound%d.%s", id, extension);
1006 if(numextracts==1) {
1007 filename = destfilename;
1008 if(!strcmp(filename,"output.swf")) {
1009 sprintf(buf, "output.%s", extension);
1013 fi = save_fopen(filename, "wb");
1014 fwrite(&tag->data[tag->pos], tag->len - tag->pos, 1, fi);
1018 int main (int argc,char ** argv)
1027 char listavailable = 0;
1028 processargs(argc, argv);
1030 if(!extractframes && !extractids && ! extractname && !extractjpegids && !extractpngids
1031 && !extractmp3 && !extractsoundids && !extractfontids)
1034 if(!originalplaceobjects && movetozero) {
1035 fprintf(stderr, "Error: -0 (--movetozero) can only be used in conjunction with -P (--placeobject)\n");
1041 fprintf(stderr, "You must supply a filename.\n");
1044 initLog(0,-1,0,0,-1, verbose);
1046 f = open(filename,O_RDONLY|O_BINARY);
1050 perror("Couldn't open file: ");
1053 if (swf_ReadSWF(f,&swf) < 0)
1055 fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
1074 tagused = (char*)malloc(tagnum);
1075 memset(tagused, 0, tagnum);
1076 memset(used, 0, 65536);
1077 memset(depths, 0, 65536);
1082 if(swf_isAllowedSpriteTag(tag)) {
1084 if(extractframes && is_in_range(frame, extractframes)) {
1086 if(tag->id == ST_PLACEOBJECT || tag->id == ST_PLACEOBJECT2) {
1087 depths[swf_GetDepth(tag)] = 1;
1089 if(tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) {
1090 int depth = swf_GetDepth(tag);
1093 depths[swf_GetDepth(tag)] = 0;
1096 if((tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) &&
1097 (depths[swf_GetDepth(tag)]) && hollow) {
1099 depths[swf_GetDepth(tag)] = 0;
1103 enumerateIDs(tag, idcallback);
1105 tagused[tagnum] = 1;
1109 if(tag->id == ST_SOUNDSTREAMHEAD ||
1110 tag->id == ST_SOUNDSTREAMHEAD2 ||
1111 tag->id == ST_SOUNDSTREAMBLOCK) {
1113 handlesoundstream(tag);
1116 if(tag->id == ST_JPEGTABLES)
1117 handlejpegtables(tag);
1119 if(swf_isDefiningTag(tag)) {
1120 int id = swf_GetDefineID(tag);
1122 if(extractids && is_in_range(id, extractids)) {
1126 if(extractfontids && is_in_range(id, extractfontids)) {
1127 handlefont(&swf, tag);
1129 if(extractjpegids && is_in_range(id, extractjpegids)) {
1132 if(extractsoundids && is_in_range(id, extractsoundids)) {
1133 handledefinesound(tag);
1135 #ifdef _ZLIB_INCLUDED_
1136 if(extractpngids && is_in_range(id, extractpngids)) {
1137 handlelossless(tag);
1141 else if (tag->id == ST_SETBACKGROUNDCOLOR) {
1142 mainr = tag->data[0];
1143 maing = tag->data[1];
1144 mainb = tag->data[2];
1146 else if(swf_isPlaceTag(tag) && tag->id != ST_PLACEOBJECT ) {
1147 char*name = swf_GetName(tag);
1148 if(name && extractname && !strcmp(name, extractname)) {
1149 int id = swf_GetPlaceID(tag);
1152 if(originalplaceobjects) {
1153 tagused[tagnum] = 1;
1155 depths[swf_GetDepth(tag)] = 1;
1156 extractname_id = id;
1159 else if(tag->id == ST_SHOWFRAME) {
1162 tagused[tagnum] = 1;
1167 if(tag->id == ST_DEFINESPRITE) {
1168 while(tag->id != ST_END) {
1177 extractTag(&swf, destfilename);