added (long) GPL headers.
[swftools.git] / lib / modules / swfdump.c
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 void swf_DumpHeader(FILE * f,SWF * swf)
25 { if (!f) f = stderr;
26   fprintf(f,"File size\t%u\n",swf->fileSize);
27   fprintf(f,"Movie width\t%u\n",(swf->movieSize.xmax - swf->movieSize.xmin)/20);
28   fprintf(f,"Movie height\t%u\n",(swf->movieSize.ymax - swf->movieSize.ymin)/20);
29   fprintf(f,"Frame rate\t%u.%u\n",swf->frameRate>>8,swf->frameRate&0xff);
30   fprintf(f,"Frame count\t%u\n",swf->frameCount);
31 }
32
33 void swf_DumpMatrix(FILE * f,MATRIX * m)
34 { if (!f) f = stderr;
35   fprintf(f,"[%08x][%08x]\n",m->sx,m->r1);
36   fprintf(f,"[%08x][%08x]\n",m->r0,m->sy);
37   fprintf(f," %08x, %08x\n",m->tx,m->ty);
38 }
39
40 void swf_DumpTag(FILE * f,TAG * t)
41 { int i;
42   if (!f) f = stderr;
43   for (i=0;i<t->len;i++)
44   { if (!(i&15)) fprintf(f,"\n");
45     fprintf(f,"%02x ",t->data[i]);
46   }
47   fprintf(f,"\n");
48 }
49
50 void swf_DumpFont(SWFFONT * font)
51 {
52     printf("ID: %d\n", font->id);
53     printf("Version: %d\n", font->version);
54     printf("name: %s\n", font->name);
55     printf("characters: %d\n", font->numchars);
56     printf("biggest mapped ascii value: %d\n", font->maxascii);
57     printf("layout: %s\n", font->layout?"yes":"no");
58     if(font->layout)
59     {
60         printf(" ascent:%d\n", font->layout->ascent);
61         printf(" descent:%d\n", font->layout->descent);
62         printf(" leading:%d\n", font->layout->leading);
63         printf(" bounds: (not shown)\n");
64         printf(" kerning records:%d\n", font->layout->kerningcount);
65         printf(" kerning records: (not shown)\n");
66     }
67     printf("style: %d\n", font->style);
68     printf("encoding: %d\n", font->encoding);
69     printf("language: %d\n", font->language);
70 }
71
72 char* swf_TagGetName(TAG*tag)
73 {
74     switch(tag->id)
75     {
76         case ST_END:
77             return "END";
78         case ST_SHOWFRAME:
79             return "SHOWFRAME";
80         case ST_DEFINESHAPE:
81             return "DEFINESHAPE";
82         case ST_FREECHARACTER:
83             return "FREECHARACTER";
84         case ST_PLACEOBJECT:
85             return "PLACEOBJECT";
86         case ST_REMOVEOBJECT:
87             return "REMOVEOBJECT";
88         case ST_DEFINEBITS:
89             return "DEFINEBITS";
90         case ST_DEFINEBUTTON:
91             return "DEFINEBUTTON";
92         case ST_JPEGTABLES:
93             return "JPEGTABLES";
94         case ST_SETBACKGROUNDCOLOR:
95             return "SETBACKGROUNDCOLOR";
96         case ST_DEFINEFONT:
97             return "DEFINEFONT";
98         case ST_DEFINETEXT:
99             return "DEFINETEXT";
100         case ST_DEFINEEDITTEXT:
101             return "DEFINEEDITTEXT";
102         case ST_DOACTION:
103             return "DOACTION";
104         case ST_DEFINEFONTINFO:
105             return "DEFINEFONTINFO";
106         case ST_DEFINESOUND:
107             return "DEFINESOUND";
108         case ST_STARTSOUND:
109             return "STARTSOUND";
110         case ST_DEFINEBUTTONSOUND:
111             return "DEFINEBUTTONSOUND";
112         case ST_SOUNDSTREAMHEAD:
113             return "SOUNDSTREAMHEAD";
114         case ST_SOUNDSTREAMBLOCK:
115             return "SOUNDSTREAMBLOCK";
116         case ST_DEFINEBITSLOSSLESS:
117             return "DEFINEBITSLOSSLESS";
118         case ST_DEFINEBITSJPEG2:
119             return "DEFINEBITSJPEG2";
120         case ST_DEFINESHAPE2:
121             return "DEFINESHAPE2";
122         case ST_DEFINEBUTTONCXFORM:
123             return "DEFINEBUTTONCXFORM";
124         case ST_PROTECT:
125             return "PROTECT";
126         case ST_PLACEOBJECT2:
127             return "PLACEOBJECT2";
128         case ST_REMOVEOBJECT2:
129             return "REMOVEOBJECT2";
130         case ST_DEFINESHAPE3:
131             return "DEFINESHAPE3";
132         case ST_DEFINETEXT2:
133             return "DEFINETEXT2";
134         case ST_DEFINEBUTTON2:
135             return "DEFINEBUTTON2";
136         case ST_DEFINEBITSJPEG3:
137             return "DEFINEBITSJPEG3";
138         case ST_DEFINEBITSLOSSLESS2:
139             return "DEFINEBITSLOSSLESS2";
140         case ST_DEFINESPRITE:
141             return "DEFINESPRITE";
142         case ST_NAMECHARACTER:
143             return "NAMECHARACTER";
144         case ST_SERIALNUMBER:
145             return "SERIALNUMBER";
146         case ST_GENERATORTEXT:
147             return "GENERATORTEXT";
148         case ST_FRAMELABEL:
149             return "FRAMELABEL";
150         case ST_SOUNDSTREAMHEAD2:
151             return "SOUNDSTREAMHEAD2";
152         case ST_DEFINEMORPHSHAPE:
153             return "DEFINEMORPHSHAPE";
154         case ST_DEFINEFONT2:
155             return "DEFINEFONT2";
156         case ST_TEMPLATECOMMAND:
157             return "TEMPLATECOMMAND";
158         case ST_GENERATOR3:
159             return "GENERATOR3";
160         case ST_EXTERNALFONT:
161             return "EXTERNALFONT";
162         case ST_EXPORTASSETS:
163             return "EXPORTASSETS";
164         case ST_IMPORTASSETS:
165             return "IMPORTASSETS";
166         case ST_ENABLEDEBUGGER:
167             return "ENABLEDEBUGGER";
168         case ST_REFLEX:
169             return "REFLEX";
170         case ST_DOINITACTION:
171             return "DOINITACTION";
172         case ST_DEFINEMOVIE:
173             return "DEFINEMOVIE";
174         case ST_DEFINEVIDEOSTREAM:
175             return "DEFINEVIDEOSTREAM";
176         case ST_VIDEOFRAME:
177             return "VIDEOFRAME";
178         case ST_DEFINEFONTINFO2:
179             return "DEFINEFONTINFO2";
180         case ST_FREEALL:
181             return "FREEALL";
182         case ST_MX4:
183             return "MX4";
184     }
185     return 0;
186 }