X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Frfxswf.c;h=f48045848ba02a88947643be8c4c09c1a8dc30f9;hb=3c7acbedb30491cc7e7e827f06853bc18ec91759;hp=0563e8170ad0e8337bc764160db962d8cd781b0b;hpb=fb6171381f99ab5cccd467a4fdca1488aadd6916;p=swftools.git diff --git a/lib/rfxswf.c b/lib/rfxswf.c index 0563e81..f480458 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -250,7 +250,7 @@ int swf_SetRGB(TAG * t,RGBA * col) void swf_GetRGB(TAG * t, RGBA * col) { RGBA dummy; - if(!col); + if(!col) col = &dummy; col->r = swf_GetU8(t); col->g = swf_GetU8(t); @@ -299,22 +299,35 @@ void swf_GetGradient(TAG * tag, GRADIENT * gradient, char alpha) } } +int swf_CountUBits(U32 v,int nbits) +{ int n = 32; + U32 m = 0x80000000; + if(v == 0x00000000) n = 0; + else + while (!(v&m)) + { n--; + m>>=1; + } + return (n>nbits)?n:nbits; +} + int swf_CountBits(U32 v,int nbits) { int n = 33; U32 m = 0x80000000; - if (!v) n = 0; else if (v&m) - { while (v&m) + { if(v == 0xffffffff) n = 1; + else + while (v&m) { n--; m>>=1; - if (!m) break; } } else - { while (!(v&m)) + { if(v == 0x00000000) n = 0; + else + while (!(v&m)) { n--; m>>=1; - if (!m) break; } } return (n>nbits)?n:nbits; @@ -640,6 +653,30 @@ TAG * swf_InsertTag(TAG * after,U16 id) // updates frames, if nescessary return t; } +TAG * swf_InsertTagBefore(SWF* swf, TAG * before,U16 id) // updates frames, if nescessary +{ TAG * t; + + t = (TAG *)malloc(sizeof(TAG)); + if (t) + { memset(t,0x00,sizeof(TAG)); + t->id = id; + + if (before) + { t->frame = before->frame; + t->next = before; + t->prev = before->prev; + before->prev = t; + if (t->prev) t->prev->next = t; + + if (id==ST_SHOWFRAME) swf_UpdateFrame(t->next,+1); + } + } + if(swf && swf->firstTag == before) { + swf->firstTag = t; + } + return t; +} + void swf_ClearTag(TAG * t) { if (t->data) free(t->data); @@ -1119,6 +1156,9 @@ int swf_WriteSWF2(struct writer_t*writer, SWF * swf) // Writes SWF to file, swf_SetU16(&t2, swf->frameCount); l = swf_GetTagLen(&t2)+8; } + if(swf->compressed == 8) { + l -= 8; + } fileSize = l+len; if(len) {// don't touch headers without tags @@ -1148,6 +1188,7 @@ int swf_WriteSWF2(struct writer_t*writer, SWF * swf) // Writes SWF to file, writer = &zwriter; } } + swf_SetRect(&t1,&swf->movieSize); swf_SetU16(&t1,swf->frameRate); swf_SetU16(&t1,swf->frameCount); @@ -1254,3 +1295,4 @@ void swf_FreeTags(SWF * swf) // Frees all malloc'ed memory for t #include "modules/swfbits.c" #include "modules/swfaction.c" #include "modules/swfsound.c" +#include "h.263/swfvideo.c"