X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fcombine.c;h=f694bcc1d3f3b853e7c12633a9a686c7c4ba78e3;hp=a6a695a4ecfb40d3feb80c5a842a9b788251ccfc;hb=55ae78f99fc68098c6e0e8d99753be9e4f7e09bc;hpb=caacc3b7bc77a04e35891f73908f9c0a7c8c64fa diff --git a/src/combine.c b/src/combine.c index a6a695a..f694bcc 100644 --- a/src/combine.c +++ b/src/combine.c @@ -12,6 +12,7 @@ #include #include #include "../lib/log.h" +#include "../lib/rfxswf.h" #include "./flash.h" #include "./reloc.h" #include "./settings.h" @@ -70,6 +71,49 @@ void changedepth(struct swf_tag*tag, int add) SWAP16(SWAP16(*(u16*)&tag->data[0]) + add); } +void jpeg_assert() +{ + /* TODO: if there's a jpegtable found, store it + and handle it together with the flash file + headers */ + /* check that master and slave don't have both + jpegtables (which would be fatal) */ + int pos; + int mpos=-1, spos=-1; + pos = 0; + while(master.tags[pos].id != 0) + { + if(master.tags[pos].id == TAGID_JPEGTABLES) + mpos = pos; + pos++; + } + pos = 0; + while(master.tags[pos].id != 0) + { + if(slave.tags[pos].id == TAGID_JPEGTABLES) + spos = pos; + pos++; + } + if(spos>=0 && mpos>=0) + { + if(slave.tags[pos].length == + master.tags[pos].length && + !memcmp(slave.tags[pos].data, master.tags[pos].data, + master.tags[pos].length)) + { + // ok, both have jpegtables, but they're identical. + // delete one and don't make an error + for(;spos=0 && mpos>=0) { + logf(" Master and slave have incompatible JPEGTABLES."); + } +} + /* applies the config move and scale parameters to * a matrix. (If settings would provide a rotation, * this would be a matrix concatenation/multiplication @@ -165,9 +209,9 @@ void write_sprite_defines(struct writer_t*w) break; } case TAGID_JPEGTABLES: - /* according to the flash specs, there may only - be one JPEGTABLES tag per swf. This is maybe - a big FIXME */ + /* if we get here, jpeg_assert has already run, + ensuring this is the only one of it's kind, + so we may safely write it out */ writer_write(w, tag->fulldata, tag->fulllength); break; case TAGID_EXPORTASSETS: @@ -456,6 +500,7 @@ uchar * catcombine(uchar*masterdata, int masterlength, char*_slavename, uchar*sl swf_relocate (slavedata, slavelength, masterids); read_swf(&slave, slavedata, slavelength); + jpeg_assert(); writer_write(&w, "FWS",3); headlength = (u32*)(writer_getpos(&w) + 1); @@ -602,8 +647,8 @@ uchar * normalcombine(uchar*masterdata, int masterlength, char*_slavename, uchar } swf_relocate (slavedata, slavelength, masterids); - read_swf(&slave, slavedata, slavelength); + jpeg_assert(); if (config.overlay) replaceddefine = get_free_id();