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;
54 struct options_t options[] =
73 int args_callback_option(char*name,char*val)
75 if(!strcmp(name, "V")) {
76 printf("swfextract - part of %s %s\n", PACKAGE, VERSION);
79 else if(!strcmp(name, "o")) {
83 else if(!strcmp(name, "i")) {
87 fprintf(stderr, "You can only supply either name or id\n");
92 else if(!strcmp(name, "n")) {
96 fprintf(stderr, "You can only supply either name or id\n");
101 else if(!strcmp(name, "v")) {
105 else if(!strcmp(name, "m")) {
110 else if(!strcmp(name, "j")) {
112 fprintf(stderr, "Only one --jpegs argument is allowed. (Try to use a range, e.g. -j 1,2,3)\n");
116 extractjpegids = val;
119 else if(!strcmp(name, "F")) {
121 fprintf(stderr, "Only one --font argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
125 extractfontids = val;
128 else if(!strcmp(name, "s")) {
129 if(extractsoundids) {
130 fprintf(stderr, "Only one --sound argument is allowed. (Try to use a range, e.g. -s 1,2,3)\n");
134 extractsoundids = val;
137 #ifdef _ZLIB_INCLUDED_
138 else if(!strcmp(name, "p")) {
140 fprintf(stderr, "Only one --png argument is allowed. (Try to use a range, e.g. -p 1,2,3)\n");
148 else if(!strcmp(name, "f")) {
153 else if(!strcmp(name, "P")) {
154 originalplaceobjects = 1;
157 else if(!strcmp(name, "w")) {
162 printf("Unknown option: -%s\n", name);
168 int args_callback_longoption(char*name,char*val)
170 return args_long2shortoption(options, name, val);
172 void args_callback_usage(char*name)
174 printf("Usage: %s [-v] [-n name] [-ijf ids] file.swf\n", name);
175 printf("\t-v , --verbose\t\t\t Be more verbose\n");
176 printf("\t-o , --output filename\t\t set output filename\n");
177 printf("\t-V , --version\t\t\t Print program version and exit\n\n");
178 printf("SWF Subelement extraction:\n");
179 printf("\t-n , --name name\t\t instance name of the object (SWF Define) to extract\n");
180 printf("\t-i , --id ID\t\t\t ID of the object, shape or movieclip to extract\n");
181 printf("\t-f , --frame frames\t\t frame numbers to extract\n");
182 printf("\t-w , --hollow\t\t\t hollow mode: don't remove empty frames\n");
183 printf("\t \t\t\t (use with -f)\n");
184 printf("\t-P , --placeobject\t\t\t Insert original placeobject into output file\n");
185 printf("\t \t\t\t (use with -i)\n");
186 printf("SWF Font/Text extraction:\n");
187 printf("\t-F , --font ID\t\t\t Extract font(s)\n");
188 printf("Picture extraction:\n");
189 printf("\t-j , --jpeg ID\t\t\t Extract JPEG picture(s)\n");
190 #ifdef _ZLIB_INCLUDED_
191 printf("\t-p , --pngs ID\t\t\t Extract PNG picture(s)\n");
194 printf("Sound extraction:\n");
195 printf("\t-m , --mp3\t\t\t Extract main mp3 stream\n");
196 printf("\t-s , --sound ID\t\t\t Extract Sound(s)\n");
198 int args_callback_command(char*name,char*val)
201 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
208 U8 mainr,maing,mainb;
209 /* 1 = used, not expanded,
211 5 = wanted, not expanded
218 int extractname_id = -1;
220 void idcallback(void*data)
222 if(!(used[GET16(data)]&1)) {
224 used[GET16(data)] |= 1;
228 void enumerateIDs(TAG*tag, void(*callback)(void*))
234 data = (U8*)malloc(len);
235 PUT16(data, (tag->id<<6)+63);
236 *(U8*)&data[2] = tag->len;
237 *(U8*)&data[3] = tag->len>>8;
238 *(U8*)&data[4] = tag->len>>16;
239 *(U8*)&data[5] = tag->len>>24;
240 memcpy(&data[6], tag->data, tag->len);
243 data = (U8*)malloc(len);
244 PUT16(data, (tag->id<<6)+tag->len);
245 memcpy(&data[2], tag->data, tag->len);
247 map_ids_mem(data, len, callback);
249 int num = swf_GetNumUsedIDs(tag);
250 int *ptr = malloc(sizeof(int)*num);
252 swf_GetUsedIDs(tag, ptr);
254 callback(&tag->data[ptr[t]]);
257 void extractTag(SWF*swf, char*filename)
269 memset(&newswf,0x00,sizeof(SWF)); // set global movie parameters
271 newswf.fileVersion = swf->fileVersion;
272 newswf.frameRate = swf->frameRate;
273 newswf.movieSize = swf->movieSize;
275 newswf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
276 desttag = newswf.firstTag;
280 swf_SetRGB(desttag,&rgb);
282 swf_GetRect(0, &objectbbox);
286 for(t=0;t<65536;t++) {
287 if(used[t] && !(used[t]&2)) {
289 msg("<warning> ID %d is referenced, but never defined.", t);
290 } else if(tags[t]->id==ST_DEFINESPRITE) {
292 while(tag->id != ST_END)
294 enumerateIDs(tag, idcallback);
299 enumerateIDs(tags[t], idcallback);
306 srctag = swf->firstTag;
309 while(srctag && (srctag->id || sprite)) {
314 if(srctag->id == ST_END) {
317 if(srctag->id == ST_DEFINESPRITE)
319 if(swf_isDefiningTag(srctag)) {
320 int id = swf_GetDefineID(srctag);
324 b = swf_GetDefineBBox(srctag);
325 swf_ExpandRect2(&objectbbox, &b);
328 if (((((srctag->id == ST_PLACEOBJECT || srctag->id == ST_PLACEOBJECT2) && originalplaceobjects)
329 || srctag->id == ST_STARTSOUND) && (used[swf_GetPlaceID(srctag)]&4) ) ||
330 (swf_isPseudoDefiningTag(srctag) && used[swf_GetDefineID(srctag)]) ||
337 if(srctag->id == ST_REMOVEOBJECT) {
338 if(!used[swf_GetPlaceID(srctag)])
343 TAG*ttag = (TAG*)malloc(sizeof(TAG));
344 desttag = swf_InsertTag(desttag, srctag->id);
345 desttag->len = desttag->memsize = srctag->len;
346 desttag->data = malloc(srctag->len);
347 memcpy(desttag->data, srctag->data, srctag->len);
352 srctag = srctag->next;
355 if(!extractframes && !hollow) {
356 if(!originalplaceobjects && (extractids||extractname_id>=0)) {
362 memset(&bbox, 0, sizeof(SRECT));
363 for(t=0;t<65536;t++) {
364 if(is_in_range(t, extractids)) {
370 printf("warning! You should use the -P when extracting multiple objects\n");
372 /* if there is only one object, we will scale it.
373 So let's figure out it's bounding box */
374 TAG*tag = swf->firstTag;
376 if(swf_isDefiningTag(tag) && tag->id != ST_DEFINESPRITE) {
377 if(swf_GetDefineID(tag) == id)
378 bbox = swf_GetDefineBBox(tag);
385 if((objectbbox.xmin|objectbbox.ymin|objectbbox.xmax|objectbbox.ymax)!=0)
386 newswf.movieSize = objectbbox;
387 if(extractname_id>=0) {
388 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
389 swf_ObjectPlace(desttag, extractname_id, extractname_id, 0,0,extractname);
391 for(t=0;t<65536;t++) {
392 if(is_in_range(t, extractids)) {
394 desttag = swf_InsertTag(desttag, ST_PLACEOBJECT2);
395 swf_GetMatrix(0, &m);
397 int width = bbox.xmax - bbox.xmin;
398 int height = bbox.ymax - bbox.ymin;
399 int max = width>height?width:height;
403 m.sx = (512*20*65536)/max;
404 m.sy = (512*20*65536)/max;
406 newswf.movieSize = swf_TurnRect(newswf.movieSize, &m);
408 swf_ObjectPlace(desttag, t, t, &m,0,0);
413 desttag = swf_InsertTag(desttag,ST_SHOWFRAME);
415 desttag = swf_InsertTag(desttag,ST_END);
417 f = open(filename, O_TRUNC|O_WRONLY|O_CREAT|O_BINARY, 0644);
418 if FAILED(swf_WriteSWF(f,&newswf)) fprintf(stderr,"WriteSWF() failed.\n");
421 swf_FreeTags(&newswf); // cleanup
424 int isOfType(int t, TAG*tag)
427 if(t == 0 && (tag->id == ST_DEFINESHAPE ||
428 tag->id == ST_DEFINESHAPE2 ||
429 tag->id == ST_DEFINESHAPE3)) {
432 if(t==1 && tag->id == ST_DEFINESPRITE) {
435 if(t == 2 && (tag->id == ST_DEFINEBITS ||
436 tag->id == ST_DEFINEBITSJPEG2 ||
437 tag->id == ST_DEFINEBITSJPEG3)) {
440 if(t == 3 && (tag->id == ST_DEFINEBITSLOSSLESS ||
441 tag->id == ST_DEFINEBITSLOSSLESS2)) {
444 if(t == 4 && (tag->id == ST_DEFINESOUND)) {
447 if(t == 5 && (tag->id == ST_DEFINEFONT || tag->id == ST_DEFINEFONT2)) {
453 void listObjects(SWF*swf)
459 char*names[] = {"Shape", "MovieClip", "JPEG", "PNG", "Sound", "Font"};
460 char*options[] = {"-i", "-i", "-j", "-p", "-s", "-F"};
462 printf("Objects in file %s:\n",filename);
464 for(t=0;t<sizeof(names)/sizeof(names[0]);t++) {
466 int lastid = -2, lastprint=-1;
471 if(tag->id == ST_SOUNDSTREAMHEAD || tag->id == ST_SOUNDSTREAMHEAD2)
480 printf(" [%s] %d %s%s: ID(s) ", options[t], nr, names[t], nr>1?"s":"");
485 char show = isOfType(t,tag);
491 id = swf_GetDefineID(tag);
496 if(first || !follow) {
501 if(lastprint + 1 == lastid)
502 printf(", %d, %d", lastid, id);
504 printf("-%d, %d", lastid, id);
514 if(lastprint + 1 == lastid)
515 printf(", %d", lastid);
517 printf("-%d", lastid);
523 printf(" [-f] %d Frames: ID(s) 0-%d\n", frame, frame);
525 printf(" [-f] 1 Frame: ID(s) 0\n");
528 printf(" [-m] 1 MP3 Soundstream\n");
531 void handlefont(SWF*swf, TAG*tag)
536 char*filename = name;
539 id = swf_GetDefineID(tag);
540 sprintf(name, "font%d.swf", id);
542 filename = destfilename;
545 swf_FontExtract(swf, id, &f);
547 printf("Couldn't extract font %d\n", id);
551 swf_FontCreateLayout(f);
553 swf_WriteFont(f, filename);
560 void handlejpegtables(TAG*tag)
562 if(tag->id == ST_JPEGTABLES) {
563 jpegtables = tag->data;
564 jpegtablessize = tag->len;
568 FILE* save_fopen(char* name, char* mode)
570 FILE*fi = fopen(name, mode);
572 fprintf(stderr, "Error: Couldn't open %s\n", name);
578 int findjpegboundary(U8*data, int len)
593 /* extract jpeg data out of a tag */
594 void handlejpeg(TAG*tag)
597 char*filename = name;
600 sprintf(name, "pic%d.jpg", GET16(tag->data));
602 filename = destfilename;
603 if(!strcmp(filename,"output.swf"))
604 filename = "output.jpg";
606 /* swf jpeg images have two streams, which both start with ff d8 and
607 end with ff d9. The following code handles sorting the middle
608 <ff d9 ff d8> bytes out, so that one stream remains */
609 if(tag->id == ST_DEFINEBITSJPEG && tag->len>2 && jpegtables) {
610 fi = save_fopen(filename, "wb");
611 fwrite(jpegtables, 1, jpegtablessize-2, fi); //don't write end tag (ff,d8)
612 fwrite(&tag->data[2+2], tag->len-2-2, 1, fi); //don't write start tag (ff,d9)
615 else if(tag->id == ST_DEFINEBITSJPEG2 && tag->len>2) {
617 int pos = findjpegboundary(&tag->data[2], tag->len-2);
620 fi = save_fopen(filename, "wb");
621 fwrite(&tag->data[2], pos-2, 1, fi);
622 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
625 fi = save_fopen(filename, "wb");
626 fwrite(&tag->data[2], end-2, 1, fi);
630 else if(tag->id == ST_DEFINEBITSJPEG3 && tag->len>6) {
631 U32 end = GET32(&tag->data[2])+6;
632 int pos = findjpegboundary(&tag->data[6], tag->len-6);
636 fi = save_fopen(filename, "wb");
637 fwrite(&tag->data[6], pos-6, 1, fi);
638 fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
642 int id = GET16(tag->data);
643 fprintf(stderr, "Object %d is not a JPEG picture!\n",id);
648 #ifdef _ZLIB_INCLUDED_
651 static U32*crc32_table = 0;
652 static void make_crc32_table(void)
657 crc32_table = (U32*)malloc(1024);
659 for (t = 0; t < 256; t++) {
662 for (s = 0; s < 8; s++) {
663 c = (0xedb88320L*(c&1)) ^ (c >> 1);
668 static inline void png_write_byte(FILE*fi, U8 byte)
670 fwrite(&byte,1,1,fi);
671 mycrc32 = crc32_table[(mycrc32 ^ byte) & 0xff] ^ (mycrc32 >> 8);
673 static void png_start_chunk(FILE*fi, char*type, int len)
675 U8 mytype[4]={0,0,0,0};
676 U32 mylen = REVERSESWAP32(len);
677 memcpy(mytype,type,strlen(type));
678 fwrite(&mylen, 4, 1, fi);
680 png_write_byte(fi,mytype[0]);
681 png_write_byte(fi,mytype[1]);
682 png_write_byte(fi,mytype[2]);
683 png_write_byte(fi,mytype[3]);
685 static void png_write_bytes(FILE*fi, U8*bytes, int len)
689 png_write_byte(fi,bytes[t]);
691 static void png_write_dword(FILE*fi, U32 dword)
693 png_write_byte(fi,dword>>24);
694 png_write_byte(fi,dword>>16);
695 png_write_byte(fi,dword>>8);
696 png_write_byte(fi,dword);
698 static void png_end_chunk(FILE*fi)
700 U32 tmp = REVERSESWAP32((mycrc32^0xffffffff));
705 /* extract a lossless image (png) out of a tag
706 This routine was originally meant to be a one-pager. I just
707 didn't know png is _that_ much fun. :) -mk
709 void handlelossless(TAG*tag)
712 char*filename = name;
727 U8 head[] = {137,80,78,71,13,10,26,10};
729 char alpha = tag->id == ST_DEFINEBITSLOSSLESS2;
737 if(tag->id != ST_DEFINEBITSLOSSLESS &&
738 tag->id != ST_DEFINEBITSLOSSLESS2) {
739 int id = GET16(tag->data);
740 fprintf(stderr, "Object %d is not a PNG picture!\n",id);
745 format = swf_GetU8(tag);
746 if(format == 3) bpp = 8;
747 if(format == 4) bpp = 16;
748 if(format == 5) bpp = 32;
749 if(format!=3 && format!=5) {
751 fprintf(stderr, "Can't handle 16-bit palette images yet (image %d)\n",id);
753 fprintf(stderr, "Unknown image type %d in image %d\n", format, id);
756 width = swf_GetU16(tag);
757 height = swf_GetU16(tag);
758 if(format == 3) cols = swf_GetU8(tag) + 1;
759 // this is what format means according to the flash specification. (which is
761 // if(format == 4) cols = swf_GetU16(tag) + 1;
762 // if(format == 5) cols = swf_GetU32(tag) + 1;
765 msg("<verbose> Width %d", width);
766 msg("<verbose> Height %d", height);
767 msg("<verbose> Format %d", format);
768 msg("<verbose> Cols %d", cols);
769 msg("<verbose> Bpp %d", bpp);
771 datalen = (width*height*bpp/8+cols*8);
776 data = malloc(datalen);
777 error = uncompress (data, &datalen, &tag->data[tag->pos], tag->len-tag->pos);
778 } while(error == Z_BUF_ERROR);
780 fprintf(stderr, "Zlib error %d (image %d)\n", error, id);
783 msg("<verbose> Uncompressed image is %d bytes (%d colormap)", datalen, (3+alpha)*cols);
786 data2 = malloc(datalen2);
787 palette = (RGBA*)malloc(cols*sizeof(RGBA));
789 for(t=0;t<cols;t++) {
790 palette[t].r = data[pos++];
791 palette[t].g = data[pos++];
792 palette[t].b = data[pos++];
794 palette[t].a = data[pos++];
798 sprintf(name, "pic%d.png", id);
800 filename = destfilename;
801 if(!strcmp(filename,"output.swf"))
802 filename = "output.png";
804 fi = save_fopen(filename, "wb");
805 fwrite(head,sizeof(head),1,fi);
807 png_start_chunk(fi, "IHDR", 13);
808 png_write_dword(fi,width);
809 png_write_dword(fi,height);
810 png_write_byte(fi,8);
812 png_write_byte(fi,3); //indexed
813 else if(format == 5 && alpha==0)
814 png_write_byte(fi,2); //rgb
815 else if(format == 5 && alpha==1)
816 png_write_byte(fi,6); //rgba
819 png_write_byte(fi,0); //compression mode
820 png_write_byte(fi,0); //filter mode
821 png_write_byte(fi,0); //interlace mode
825 png_start_chunk(fi, "PLTE", 768);
828 png_write_byte(fi,palette[t].r);
829 png_write_byte(fi,palette[t].g);
830 png_write_byte(fi,palette[t].b);
835 /* write alpha palette */
836 png_start_chunk(fi, "tRNS", 256);
838 png_write_byte(fi,palette[t].a);
846 int srcwidth = width * (bpp/8);
847 datalen3 = (width*4+5)*height;
848 data3 = (U8*)malloc(datalen3);
849 for(y=0;y<height;y++)
851 data3[pos2++]=0; //filter type
854 // 32 bit to 24 bit "conversion"
855 for(x=0;x<width;x++) {
856 data3[pos2++]=data[pos+1];
857 data3[pos2++]=data[pos+2];
858 data3[pos2++]=data[pos+3];
859 pos+=4; //ignore padding byte
862 for(x=0;x<width;x++) {
863 data3[pos2++]=data[pos+1];
864 data3[pos2++]=data[pos+2];
865 data3[pos2++]=data[pos+3];
866 data3[pos2++]=data[pos+0]; //alpha
872 for(x=0;x<srcwidth;x++)
873 data3[pos2++]=data[pos++];
876 pos+=((srcwidth+3)&~3)-srcwidth; //align
881 if(compress (data2, &datalen2, data3, datalen3) != Z_OK) {
882 fprintf(stderr, "zlib error in pic %d\n", id);
885 msg("<verbose> Compressed data is %d bytes", datalen2);
886 png_start_chunk(fi, "IDAT", datalen2);
887 png_write_bytes(fi,data2,datalen2);
889 png_start_chunk(fi, "IEND", 0);
899 void handlesoundstream(TAG*tag)
901 char*filename = "output.mp3";
903 filename = destfilename;
904 if(!strcmp(filename,"output.swf"))
905 filename = "output.mp3";
908 case ST_SOUNDSTREAMHEAD:
909 if((tag->data[1]&0x30) == 0x20) { //mp3 compression
910 mp3file = fopen(filename, "wb");
911 msg("<notice> Writing mp3 data to %s",filename);
914 msg("<error> Soundstream is not mp3");
916 case ST_SOUNDSTREAMHEAD2:
917 if((tag->data[1]&0x30) == 0x20) {//mp3 compression
918 mp3file = fopen(filename, "wb");
919 msg("<notice> Writing mp3 data to %s",filename);
922 msg("<error> Soundstream is not mp3 (2)");
924 case ST_SOUNDSTREAMBLOCK:
926 fwrite(&tag->data[4],tag->len-4,1,mp3file);
931 void handledefinesound(TAG*tag)
941 int rate,bits,stereo;
942 char*rates[] = {"5500","11025","22050","44100"};
943 id = swf_GetU16(tag); //id
945 flags = swf_GetU8(tag);
951 samples = swf_GetU32(tag);
955 if(format == 2) { // mp3
956 swf_GetU16(tag); //numsamples_seek
958 } else if(format == 0) { // raw
959 printf("Sound is RAW, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
960 // TODO: convert to WAV
962 } else if(format == 1) { // adpcm
963 printf("Sound is ADPCM, format: %s samples/sec, %d bit, %s\n", rates[rate], bits, stereo?"stereo":"mono");
966 sprintf(buf, "sound%d.%s", id, extension);
968 filename = destfilename;
969 if(!strcmp(filename,"output.swf")) {
970 sprintf(buf, "output.%s", extension);
974 fi = save_fopen(filename, "wb");
975 fwrite(&tag->data[tag->pos], tag->len - tag->pos, 1, fi);
979 int main (int argc,char ** argv)
988 char listavailable = 0;
989 processargs(argc, argv);
991 if(!extractframes && !extractids && ! extractname && !extractjpegids && !extractpngids
992 && !extractmp3 && !extractsoundids && !extractfontids)
997 fprintf(stderr, "You must supply a filename.\n");
1000 initLog(0,-1,0,0,-1, verbose);
1002 f = open(filename,O_RDONLY|O_BINARY);
1006 perror("Couldn't open file: ");
1009 if (swf_ReadSWF(f,&swf) < 0)
1011 fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
1030 tagused = (char*)malloc(tagnum);
1031 memset(tagused, 0, tagnum);
1032 memset(used, 0, 65536);
1033 memset(depths, 0, 65536);
1038 if(swf_isAllowedSpriteTag(tag)) {
1040 if(extractframes && is_in_range(frame, extractframes)) {
1042 if(tag->id == ST_PLACEOBJECT || tag->id == ST_PLACEOBJECT2) {
1043 depths[swf_GetDepth(tag)] = 1;
1045 if(tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) {
1046 int depth = swf_GetDepth(tag);
1049 depths[swf_GetDepth(tag)] = 0;
1052 if((tag->id == ST_REMOVEOBJECT || tag->id == ST_REMOVEOBJECT2) &&
1053 (depths[swf_GetDepth(tag)]) && hollow) {
1055 depths[swf_GetDepth(tag)] = 0;
1059 enumerateIDs(tag, idcallback);
1061 tagused[tagnum] = 1;
1065 if(tag->id == ST_SOUNDSTREAMHEAD ||
1066 tag->id == ST_SOUNDSTREAMHEAD2 ||
1067 tag->id == ST_SOUNDSTREAMBLOCK) {
1069 handlesoundstream(tag);
1072 if(tag->id == ST_JPEGTABLES)
1073 handlejpegtables(tag);
1075 if(swf_isDefiningTag(tag)) {
1076 int id = swf_GetDefineID(tag);
1078 if(extractids && is_in_range(id, extractids)) {
1082 if(extractfontids && is_in_range(id, extractfontids)) {
1083 handlefont(&swf, tag);
1085 if(extractjpegids && is_in_range(id, extractjpegids)) {
1088 if(extractsoundids && is_in_range(id, extractsoundids)) {
1089 handledefinesound(tag);
1091 #ifdef _ZLIB_INCLUDED_
1092 if(extractpngids && is_in_range(id, extractpngids)) {
1093 handlelossless(tag);
1097 else if (tag->id == ST_SETBACKGROUNDCOLOR) {
1098 mainr = tag->data[0];
1099 maing = tag->data[1];
1100 mainb = tag->data[2];
1102 else if(tag->id == ST_PLACEOBJECT2) {
1103 char*name = swf_GetName(tag);
1104 if(name && extractname && !strcmp(name, extractname)) {
1105 int id = swf_GetPlaceID(tag);
1108 tagused[tagnum] = 1;
1109 depths[swf_GetDepth(tag)] = 1;
1110 extractname_id = id;
1113 else if(tag->id == ST_SHOWFRAME) {
1116 tagused[tagnum] = 1;
1121 if(tag->id == ST_DEFINESPRITE) {
1122 while(tag->id != ST_END) {
1131 extractTag(&swf, destfilename);