#endif // HAVE_ZLIB_H
#endif // HAVE_LIBZ
+#define LAME
+#include "lame/lame.h"
+
+#include "./bitio.h"
+
// internal constants
#define MALLOC_SIZE 128
{
#ifdef DEBUG_RFXSWF
fprintf(stderr,"Fatal Error: malloc()/realloc() failed (1). (%d bytes)\n", newmem);
+ *(int*)0=0;
#endif
return 0;
}
return res;
}
-/* reader/writer stuff - from ../src/bitio.c */
-#include "./bitio.c"
-
S32 swf_GetSBits(TAG * t,int nbits)
{ U32 res = swf_GetBits(t,nbits);
if (res&(1<<(nbits-1))) res|=(0xffffffff<<nbits);
nbits = swf_CountBits(r->xmax,nbits);
nbits = swf_CountBits(r->ymin,nbits);
nbits = swf_CountBits(r->ymax,nbits);
+ if(nbits>=32) {
+ fprintf(stderr, "rfxswf: Warning: num_bits overflow in swf_SetRect\n");
+ nbits=31;
+ }
swf_SetBits(t,nbits,5);
swf_SetBits(t,r->xmin,nbits);
fprintf(stderr, "Error: Sprite has no ID!");
return;
}
+ if(t->len>4) {
+ /* sprite is already folded */
+ return;
+ }
t->pos = 0;
id = swf_GetU16(t);
t1.next->prev = NULL;
}
- return 0;
+ return reader->pos;
}
int swf_ReadSWF(int handle, SWF * swf)
return swf_ReadSWF2(&reader, swf);
}
-int swf_WriteSWF2(struct writer_t*writer, SWF * swf, bool compress) // Writes SWF to file, returns length or <0 if fails
+int swf_WriteSWF2(struct writer_t*writer, SWF * swf) // Writes SWF to file, returns length or <0 if fails
{ U32 len;
TAG * t;
int frameCount=0;
swf->frameCount = frameCount;
}
- if(compress) {
+ if(swf->compressed) {
char*id = "CWS";
writer->write(writer, id, 3);
}
PUT32(b4, swf->fileSize);
writer->write(writer, b4, 4);
- if(compress) {
+ if(swf->compressed) {
writer_init_zlibdeflate(&zwriter, writer);
writer = &zwriter;
}
int swf_WriteSWF(int handle, SWF * swf) // Writes SWF to file, returns length or <0 if fails
{
struct writer_t writer;
+ swf->compressed = 0;
if(handle<0)
- return swf_WriteSWF2(&writer, swf, FALSE);
+ return swf_WriteSWF2(&writer, swf);
writer_init_filewriter(&writer, handle);
- return swf_WriteSWF2(&writer, swf, FALSE);
+ return swf_WriteSWF2(&writer, swf);
}
int swf_WriteSWC(int handle, SWF * swf) // Writes SWF to file, returns length or <0 if fails
{
struct writer_t writer;
+ swf->compressed = 1;
if(handle<0)
- return swf_WriteSWF2(&writer, swf, TRUE);
+ return swf_WriteSWF2(&writer, swf);
writer_init_filewriter(&writer, handle);
- return swf_WriteSWF2(&writer, swf, TRUE);
+ return swf_WriteSWF2(&writer, swf);
}
+int swf_WriteHeader2(struct writer_t*writer,SWF * swf)
+{
+ SWF myswf;
+ memcpy(&myswf,swf,sizeof(SWF));
+ myswf.firstTag = 0;
+ return swf_WriteSWF2(writer, &myswf);
+}
int swf_WriteHeader(int handle,SWF * swf)
{