1 /* swfdump.c
2
3 Dump / debug functions
4
5 Extension module for the rfxswf library.
6 Part of the swftools package.
7
8 Copyright (c) 2001 Rainer B�hme <rfxswf@reflex-studio.de>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "../rfxswf.h"
27
swf_DumpHeader(FILE * f,SWF * swf)28 void swf_DumpHeader(FILE * f,SWF * swf)
29 { if (!f) f = stderr;
30 fprintf(f,"File size\t%u\n",swf->fileSize);
31 fprintf(f,"Movie width\t%u\n",(swf->movieSize.xmax - swf->movieSize.xmin)/20);
32 fprintf(f,"Movie height\t%u\n",(swf->movieSize.ymax - swf->movieSize.ymin)/20);
33 fprintf(f,"Frame rate\t%u.%u\n",swf->frameRate>>8,swf->frameRate&0xff);
34 fprintf(f,"Frame count\t%u\n",swf->frameCount);
35 }
36
swf_DumpMatrix(FILE * f,MATRIX * m)37 void swf_DumpMatrix(FILE * f,MATRIX * m)
38 { if (!f) f = stderr;
39 /*fprintf(f,"[%08x][%08x]\n",m->sx,m->r1);
40 fprintf(f,"[%08x][%08x]\n",m->r0,m->sy);
41 fprintf(f," %08x, %08x\n",m->tx,m->ty);*/
42 fprintf(f,"[%08x][%08x] %5.2f %5.2f %5.2f\n",m->sx,m->r1, m->sx/65536.0,m->r1/65536.0, m->tx/20.0);
43 fprintf(f,"[%08x][%08x] %5.2f %5.2f %5.2f\n",m->r0,m->sy, m->r0/65536.0,m->sy/65536.0, m->ty/20.0 );
44 fprintf(f," %08x, %08x \n",m->tx,m->ty);
45 }
46
swf_DumpGradient(FILE * f,GRADIENT * g)47 void swf_DumpGradient(FILE * f,GRADIENT * g)
48 { if (!f) f = stderr;
49 fprintf(f, "%d gradient steps\n", g->num);
50 int t;
51 for(t=0;t<g->num;t++) {
52 RGBA c = g->rgba[t];
53 fprintf(f, "%d) %02x%02x%02x%02x at %d\n", t, c.r,c.g,c.b,c.a, g->ratios[t]);
54 }
55 }
56
swf_DumpTag(FILE * f,TAG * t)57 void swf_DumpTag(FILE * f,TAG * t)
58 { int i;
59 if (!f) f = stderr;
60 for (i=0;i<t->len;i++)
61 { if (!(i&15)) fprintf(f,"\n");
62 fprintf(f,"%02x ",t->data[i]);
63 }
64 fprintf(f,"\n");
65 }
66
swf_DumpSWF(FILE * f,SWF * swf)67 void swf_DumpSWF(FILE * f, SWF*swf)
68 {
69 TAG* tag = swf->firstTag;
70 fprintf(f, "vvvvvvvvvvvvvvvvvvvvv\n");
71 while(tag) {
72 printf("%8d %s\n", tag->len, swf_TagGetName(tag));
73 tag = tag->next;
74 }
75 fprintf(f, "^^^^^^^^^^^^^^^^^^^^^\n");
76 }
77
swf_DumpFont(SWFFONT * font)78 void swf_DumpFont(SWFFONT * font)
79 {
80 printf("ID: %d\n", font->id);
81 printf("Version: %d\n", font->version);
82 printf("name: %s\n", font->name);
83 printf("characters: %d\n", font->numchars);
84 printf("biggest mapped ascii value: %d\n", font->maxascii);
85 printf("layout: %s\n", font->layout?"yes":"no");
86 if(font->layout)
87 {
88 printf(" ascent:%d\n", font->layout->ascent);
89 printf(" descent:%d\n", font->layout->descent);
90 printf(" leading:%d\n", font->layout->leading);
91 printf(" bounds: (not shown)\n");
92 printf(" kerning records:%d\n", font->layout->kerningcount);
93 printf(" kerning records: (not shown)\n");
94 }
95 printf("style: %d\n", font->style);
96 printf("encoding: %d\n", font->encoding);
97 printf("language: %d\n", font->language);
98 }
99
swf_DumpShape(SHAPE2 * shape2)100 void swf_DumpShape(SHAPE2*shape2)
101 {
102 SHAPELINE*l = shape2->lines;
103 while(l) {
104 if(l->type == moveTo) {
105 //printf("fill %d/%d line %d\n", l->fillstyle0, l->fillstyle1, l->linestyle);
106 printf("moveTo %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
107 }
108 if(l->type == lineTo) {
109 //printf("fill %d/%d line %d\n", l->fillstyle0, l->fillstyle1, l->linestyle);
110 printf("lineTo %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
111 }
112 if(l->type == splineTo) {
113 //printf("fill %d/%d line %d\n", l->fillstyle0, l->fillstyle1, l->linestyle);
114 printf("splineTo %.2f,%.2f %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->sx/20.0, l->sy/20.0, l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
115 }
116 l = l->next;
117 }
118 }
119
swf_TagGetName(TAG * tag)120 char* swf_TagGetName(TAG*tag)
121 {
122 switch(tag->id)
123 {
124 case ST_END:
125 return "END";
126 case ST_SHOWFRAME:
127 return "SHOWFRAME";
128 case ST_DEFINESHAPE:
129 return "DEFINESHAPE";
130 case ST_FREECHARACTER:
131 return "FREECHARACTER";
132 case ST_PLACEOBJECT:
133 return "PLACEOBJECT";
134 case ST_REMOVEOBJECT:
135 return "REMOVEOBJECT";
136 case ST_DEFINEBITSJPEG:
137 return "DEFINEBITSJPEG";
138 case ST_DEFINEBUTTON:
139 return "DEFINEBUTTON";
140 case ST_JPEGTABLES:
141 return "JPEGTABLES";
142 case ST_SETBACKGROUNDCOLOR:
143 return "SETBACKGROUNDCOLOR";
144 case ST_DEFINEFONT:
145 return "DEFINEFONT";
146 case ST_DEFINETEXT:
147 return "DEFINETEXT";
148 case ST_DEFINEEDITTEXT:
149 return "DEFINEEDITTEXT";
150 case ST_DOACTION:
151 return "DOACTION";
152 case ST_DOABC:
153 return "DOABC";
154 case ST_RAWABC:
155 return "RAWABC";
156 case ST_DEFINEFONTINFO:
157 return "DEFINEFONTINFO";
158 case ST_DEFINESOUND:
159 return "DEFINESOUND";
160 case ST_STARTSOUND:
161 return "STARTSOUND";
162 case ST_DEFINEBUTTONSOUND:
163 return "DEFINEBUTTONSOUND";
164 case ST_SOUNDSTREAMHEAD:
165 return "SOUNDSTREAMHEAD";
166 case ST_SOUNDSTREAMBLOCK:
167 return "SOUNDSTREAMBLOCK";
168 case ST_DEFINEBITSLOSSLESS:
169 return "DEFINEBITSLOSSLESS";
170 case ST_DEFINEBITSJPEG2:
171 return "DEFINEBITSJPEG2";
172 case ST_DEFINESHAPE2:
173 return "DEFINESHAPE2";
174 case ST_DEFINEBUTTONCXFORM:
175 return "DEFINEBUTTONCXFORM";
176 case ST_PROTECT:
177 return "PROTECT";
178 case ST_PLACEOBJECT2:
179 return "PLACEOBJECT2";
180 case ST_REMOVEOBJECT2:
181 return "REMOVEOBJECT2";
182 case ST_DEFINESHAPE3:
183 return "DEFINESHAPE3";
184 case ST_DEFINETEXT2:
185 return "DEFINETEXT2";
186 case ST_DEFINEBUTTON2:
187 return "DEFINEBUTTON2";
188 case ST_DEFINEBITSJPEG3:
189 return "DEFINEBITSJPEG3";
190 case ST_DEFINEBITSLOSSLESS2:
191 return "DEFINEBITSLOSSLESS2";
192 case ST_DEFINESPRITE:
193 return "DEFINESPRITE";
194 case ST_NAMECHARACTER:
195 return "NAMECHARACTER";
196 case ST_SERIALNUMBER:
197 return "SERIALNUMBER";
198 case ST_GENERATORTEXT:
199 return "GENERATORTEXT";
200 case ST_FRAMELABEL:
201 return "FRAMELABEL";
202 case ST_SOUNDSTREAMHEAD2:
203 return "SOUNDSTREAMHEAD2";
204 case ST_DEFINEMORPHSHAPE:
205 return "DEFINEMORPHSHAPE";
206 case ST_DEFINEMORPHSHAPE2:
207 return "DEFINEMORPHSHAPE2";
208 case ST_DEFINEFONT2:
209 return "DEFINEFONT2";
210 case ST_TEMPLATECOMMAND:
211 return "TEMPLATECOMMAND";
212 case ST_GENERATOR3:
213 return "GENERATOR3";
214 case ST_EXTERNALFONT:
215 return "EXTERNALFONT";
216 case ST_EXPORTASSETS:
217 return "EXPORTASSETS";
218 case ST_SYMBOLCLASS:
219 return "SYMBOLCLASS";
220 case ST_DEFINEBINARY:
221 return "DEFINEBINARY";
222 case ST_IMPORTASSETS:
223 return "IMPORTASSETS";
224 case ST_ENABLEDEBUGGER:
225 return "ENABLEDEBUGGER";
226 case ST_DOINITACTION:
227 return "DOINITACTION";
228 case ST_DEFINEMOVIE:
229 return "DEFINEMOVIE";
230 case ST_DEFINEVIDEOSTREAM:
231 return "DEFINEVIDEOSTREAM";
232 case ST_VIDEOFRAME:
233 return "VIDEOFRAME";
234 case ST_DEFINEFONTINFO2:
235 return "DEFINEFONTINFO2";
236 case ST_FILEATTRIBUTES:
237 return "FILEATTRIBUTES";
238 case ST_IMPORTASSETS2:
239 return "IMPORTASSETS2";
240 case ST_DEFINESCALINGGRID:
241 return "DEFINESCALINGGRID";
242 case ST_DEFINESHAPE4:
243 return "DEFINESHAPE4";
244 case ST_DEFINEFONT3:
245 return "DEFINEFONT3";
246 case ST_DEFINEFONTALIGNZONES:
247 return "DEFINEFONTALIGNZONES";
248 case ST_DEFINEFONTNAME:
249 return "DEFINEFONTNAME";
250 case ST_CSMTEXTSETTINGS:
251 return "CSMTEXTSETTINGS";
252 case ST_FREEALL:
253 return "FREEALL";
254 case ST_MX4:
255 return "MX4";
256 case ST_SCRIPTLIMITS:
257 return "SCRIPTLIMITS";
258 case ST_SETTABINDEX:
259 return "SETTABINDEX";
260 case ST_ENABLEDEBUGGER2:
261 return "ENABLEDEBUGGER2";
262 case ST_PLACEOBJECT3:
263 return "PLACEOBJECT3";
264 case ST_METADATA:
265 return "METADATA";
266 case ST_SCENEDESCRIPTION:
267 return "SCENEDESCRIPTION";
268
269 case ST_REFLEX:
270 return "REFLEX";
271 case ST_GLYPHNAMES:
272 return "GLYPHNAMES";
273 }
274 return 0;
275 }
276