From 55ae78f99fc68098c6e0e8d99753be9e4f7e09bc Mon Sep 17 00:00:00 2001 From: kramm Date: Mon, 7 Jan 2002 15:21:30 +0000 Subject: [PATCH] * jpegtables handling * #include "../lib/rrxswf.h" --- src/combine.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- src/flash.h | 1 + src/reloc.c | 1 + 3 files changed, 51 insertions(+), 4 deletions(-) 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(); diff --git a/src/flash.h b/src/flash.h index 1a185c5..96e48cd 100644 --- a/src/flash.h +++ b/src/flash.h @@ -11,6 +11,7 @@ #define __flash_h__ #include "types.h" +#include "../lib/rfxswf.h" #define TAGID_END 0 #define TAGID_SHOWFRAME 1 diff --git a/src/reloc.c b/src/reloc.c index c716b90..e239675 100644 --- a/src/reloc.c +++ b/src/reloc.c @@ -9,6 +9,7 @@ This file is distributed under the GPL, see file COPYING for details */ #include "flash.h" +#include "../lib/rfxswf.h" static struct swffile file; -- 1.7.10.4