git.asbjorn.biz
/
swftools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
51d78ab
)
reworked compression handling logic
author
kramm
<kramm>
Wed, 12 Mar 2008 19:11:48 +0000
(19:11 +0000)
committer
kramm
<kramm>
Wed, 12 Mar 2008 19:11:48 +0000
(19:11 +0000)
lib/rfxswf.c
patch
|
blob
|
history
lib/rfxswf.h
patch
|
blob
|
history
diff --git
a/lib/rfxswf.c
b/lib/rfxswf.c
index
684c002
..
3de0374
100644
(file)
--- a/
lib/rfxswf.c
+++ b/
lib/rfxswf.c
@@
-1254,6
+1254,7
@@
int swf_ReadSWF2(reader_t*reader, SWF * swf) // Reads SWF to memory (malloc'ed
reader_init_zlibinflate(&zreader, reader);
reader = &zreader;
}
reader_init_zlibinflate(&zreader, reader);
reader = &zreader;
}
+ swf->compressed = 0; // derive from version number from now on
reader_GetRect(reader, &swf->movieSize);
reader->read(reader, &swf->frameRate, 2);
reader_GetRect(reader, &swf->movieSize);
reader->read(reader, &swf->frameRate, 2);
@@
-1382,11
+1383,10
@@
int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return
It also means that we don't initialize our own zlib
writer, but assume the caller provided one.
*/
It also means that we don't initialize our own zlib
writer, but assume the caller provided one.
*/
- if(swf->compressed) {
+ if(swf->compressed==1 || (swf->compressed==0 && swf->fileVersion>=6)) {
char*id = "CWS";
writer->write(writer, id, 3);
char*id = "CWS";
writer->write(writer, id, 3);
- }
- else {
+ } else {
char*id = "FWS";
writer->write(writer, id, 3);
}
char*id = "FWS";
writer->write(writer, id, 3);
}
@@
-1395,7
+1395,7
@@
int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return
PUT32(b4, swf->fileSize);
writer->write(writer, b4, 4);
PUT32(b4, swf->fileSize);
writer->write(writer, b4, 4);
- if(swf->compressed) {
+ if(swf->compressed==1 || (swf->compressed==0 && swf->fileVersion>=6)) {
writer_init_zlibdeflate(&zwriter, writer);
writer = &zwriter;
}
writer_init_zlibdeflate(&zwriter, writer);
writer = &zwriter;
}
@@
-1421,7
+1421,7
@@
int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return
{ if (swf_WriteTag2(writer, t)<0) return -1;
t = swf_NextTag(t);
}
{ if (swf_WriteTag2(writer, t)<0) return -1;
t = swf_NextTag(t);
}
- if(swf->compressed) {
+ if(swf->compressed==1 || (swf->compressed==0 && swf->fileVersion>=6) || swf->compressed==8) {
if(swf->compressed != 8) {
zwriter.finish(&zwriter);
return writer->pos - writer_lastpos;
if(swf->compressed != 8) {
zwriter.finish(&zwriter);
return writer->pos - writer_lastpos;
@@
-1437,7
+1437,6
@@
int swf_WriteSWF(int handle, SWF * swf) // Writes SWF to file, returns leng
{
writer_t writer;
int len = 0;
{
writer_t writer;
int len = 0;
- swf->compressed = 0;
if(handle<0) {
writer_init_nullwriter(&writer);
if(handle<0) {
writer_init_nullwriter(&writer);
@@
-1450,22
+1449,6
@@
int swf_WriteSWF(int handle, SWF * swf) // Writes SWF to file, returns leng
return len;
}
return len;
}
-int swf_WriteSWC(int handle, SWF * swf) // Writes SWF to file, returns length or <0 if fails
-{
- writer_t writer;
- int len = 0;
- swf->compressed = 1;
-
- if(handle<0) {
- writer_init_nullwriter(&writer);
- len = swf_WriteSWF2(&writer, swf);
- }
- writer_init_filewriter(&writer, handle);
- len = swf_WriteSWF2(&writer, swf);
- writer.finish(&writer);
- return len;
-}
-
int swf_WriteHeader2(writer_t*writer,SWF * swf)
{
SWF myswf;
int swf_WriteHeader2(writer_t*writer,SWF * swf)
{
SWF myswf;
diff --git
a/lib/rfxswf.h
b/lib/rfxswf.h
index
f63b51b
..
903efc9
100644
(file)
--- a/
lib/rfxswf.h
+++ b/
lib/rfxswf.h
@@
-28,7
+28,9
@@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#ifndef WIN32
#include <unistd.h>
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <ctype.h>
#include "../config.h"
#include <fcntl.h>
#include <ctype.h>
#include "../config.h"
@@
-162,7
+164,6
@@
int swf_ReadSWF2(reader_t*reader, SWF * swf); // Reads SWF via callback
int swf_ReadSWF(int handle,SWF * swf); // Reads SWF to memory (malloc'ed), returns length or <0 if fails
int swf_WriteSWF2(writer_t*writer, SWF * swf); // Writes SWF via callback, returns length or <0 if fails
int swf_WriteSWF(int handle,SWF * swf); // Writes SWF to file, returns length or <0 if fails
int swf_ReadSWF(int handle,SWF * swf); // Reads SWF to memory (malloc'ed), returns length or <0 if fails
int swf_WriteSWF2(writer_t*writer, SWF * swf); // Writes SWF via callback, returns length or <0 if fails
int swf_WriteSWF(int handle,SWF * swf); // Writes SWF to file, returns length or <0 if fails
-int swf_WriteSWC(int handle, SWF * swf); // for convenience, equal to swf->compressed=1;swf_WriteSWF(..)
int swf_WriteCGI(SWF * swf); // Outputs SWF with valid CGI header to stdout
void swf_FreeTags(SWF * swf); // Frees all malloc'ed memory for swf
SWF* swf_CopySWF(SWF*swf);
int swf_WriteCGI(SWF * swf); // Outputs SWF with valid CGI header to stdout
void swf_FreeTags(SWF * swf); // Frees all malloc'ed memory for swf
SWF* swf_CopySWF(SWF*swf);