From 30b68dc4d9d219f77e73bbd1db59dd41fd27d1eb Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 9 Dec 2007 09:44:33 +0000 Subject: [PATCH 1/1] flash9 tags implementation --- lib/devices/swf.c | 7 +++++-- lib/modules/swfdump.c | 6 ++++++ lib/modules/swftools.c | 3 +++ lib/rfxswf.c | 3 ++- lib/rfxswf.h | 5 +++++ src/swfdump.c | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/devices/swf.c b/lib/devices/swf.c index d0ac1c4..872d0a9 100644 --- a/lib/devices/swf.c +++ b/lib/devices/swf.c @@ -853,7 +853,7 @@ void swf_endframe(gfxdevice_t*dev) if(!i->pagefinished) endpage(dev); - if(i->config_insertstoptag) { + if( (i->swf->fileVersion <= 8) && (i->config_insertstoptag) ) { ActionTAG*atag=0; atag = action_Stop(atag); atag = action_End(atag); @@ -1174,7 +1174,6 @@ void wipeSWF(SWF*swf) } } - void swfoutput_finalize(gfxdevice_t*dev) { swfoutput_internal*i = (swfoutput_internal*)dev->internal; @@ -1251,6 +1250,10 @@ void swfoutput_finalize(gfxdevice_t*dev) i->swf->compressed = 1; } + /* Initialize AVM2 if it is a Flash9 file */ + if(i->config_flashversion>=9 && i->config_insertstoptag) { + AVM2_InsertStops(i->swf); + } // if(i->config_reordertags) // swf_Optimize(i->swf); } diff --git a/lib/modules/swfdump.c b/lib/modules/swfdump.c index 0773f1f..b2a6698 100644 --- a/lib/modules/swfdump.c +++ b/lib/modules/swfdump.c @@ -145,6 +145,8 @@ char* swf_TagGetName(TAG*tag) return "DEFINEEDITTEXT"; case ST_DOACTION: return "DOACTION"; + case ST_DOABC: + return "DOABC"; case ST_DEFINEFONTINFO: return "DEFINEFONTINFO"; case ST_DEFINESOUND: @@ -205,6 +207,10 @@ char* swf_TagGetName(TAG*tag) return "EXTERNALFONT"; case ST_EXPORTASSETS: return "EXPORTASSETS"; + case ST_SYMBOLCLASS: + return "SYMBOLCLASS"; + case ST_DEFINEBINARY: + return "DEFINEBINARY"; case ST_IMPORTASSETS: return "IMPORTASSETS"; case ST_ENABLEDEBUGGER: diff --git a/lib/modules/swftools.c b/lib/modules/swftools.c index 6c37762..f763897 100644 --- a/lib/modules/swftools.c +++ b/lib/modules/swftools.c @@ -241,6 +241,7 @@ static int swf_definingtagids[] = ST_DEFINEBUTTON2, ST_DEFINESOUND, ST_DEFINEVIDEOSTREAM, + ST_DEFINEBINARY, -1 }; @@ -253,6 +254,7 @@ static int swf_spritetagids[] = ST_REMOVEOBJECT, ST_REMOVEOBJECT2, ST_DOACTION, + ST_DOABC, ST_STARTSOUND, ST_FRAMELABEL, ST_SOUNDSTREAMHEAD, @@ -604,6 +606,7 @@ void enumerateUsedIDs(TAG * tag, int base, void (*callback)(TAG*, int, void*), v case ST_FREECHARACTER: /* unusual tags, which all start with an ID */ case ST_NAMECHARACTER: + case ST_DEFINEBINARY: case ST_GENERATORTEXT: callback(tag, tag->pos + base, callback_data); break; diff --git a/lib/rfxswf.c b/lib/rfxswf.c index a6071c4..adbdc5a 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1314,7 +1314,7 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return if(swf->fileVersion >= 9) { if (swf->firstTag && swf->firstTag->id != ST_FILEATTRIBUTES) { - U32 flags = 0x8; // | 128 = usenetwork, | 8 = hasmetadata + U32 flags = 0x8; // | 128 = usenetwork, | 16 = Actionscript3 | 8 = hasmetadata swf_SetU32(swf_InsertTagBefore(swf, swf->firstTag,ST_FILEATTRIBUTES),flags); } } @@ -1532,6 +1532,7 @@ void swf_FreeTags(SWF * swf) // Frees all malloc'ed memory for t #include "modules/swfcgi.c" #include "modules/swfbits.c" #include "modules/swfaction.c" +#include "modules/swfabc.c" #include "modules/swfsound.c" #include "modules/swfdraw.c" #include "modules/swfrender.c" diff --git a/lib/rfxswf.h b/lib/rfxswf.h index d33c268..67046f2 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -326,11 +326,14 @@ SRECT swf_TurnRect(SRECT r, MATRIX* m); #define ST_DEFINEFONTALIGNZONES 73 /* version 8 */ #define ST_CSMTEXTSETTINGS 74 /* version 8 */ #define ST_DEFINEFONT3 75 /* version 8 */ +#define ST_SYMBOLCLASS 76 /* version 9 */ #define ST_METADATA 77 /* version 8 */ #define ST_DEFINESCALINGGRID 78 /* version 8 */ +#define ST_DOABC 82 /* version 9 */ #define ST_DEFINESHAPE4 83 /* version 8 */ #define ST_DEFINEMORPHSHAPE2 84 /* version 8 */ #define ST_SCENEDESCRIPTION 86 /* version 9 */ +#define ST_DEFINEBINARY 87 /* version 9 */ /* custom tags- only valid for swftools */ #define ST_REFLEX 777 /* to identify generator software */ @@ -1062,6 +1065,8 @@ void swf_SetFilter(TAG*tag, FILTER*f); FILTER*swf_GetFilter(TAG*tag); FILTER*swf_NewFilter(U8 type); +void AVM2_InsertStops(SWF*swf); + #ifdef __cplusplus } #endif diff --git a/src/swfdump.c b/src/swfdump.c index 1793ba0..35dc77e 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -1281,7 +1281,7 @@ int main (int argc,char ** argv) if(tag->len) dumperror("End Tag not empty"); } - else if(tag->id == ST_EXPORTASSETS) { + else if(tag->id == ST_EXPORTASSETS || tag->id == ST_SYMBOLCLASS) { handleExportAssets(tag, myprefix); } else if(tag->id == ST_DOACTION && action) { -- 1.7.10.4