From d0c255a3b63de4982e15f1c1c169ebdb08d4163c Mon Sep 17 00:00:00 2001 From: kramm Date: Wed, 12 Mar 2008 19:06:48 +0000 Subject: [PATCH] reworked compression handling logic --- avi2swf/v2swf.c | 2 +- lib/devices/swf.c | 9 ++------- lib/example/protect.c | 6 ++---- lib/h.263/swfvideo.c | 4 ++-- lib/python/SWF.c | 16 ++++------------ src/gif2swf.c | 11 +++-------- src/jpeg2swf.c | 9 ++------- src/png2swf.c | 9 ++------- src/swfc.c | 2 -- src/swfcombine.c | 5 +++-- 10 files changed, 21 insertions(+), 52 deletions(-) diff --git a/avi2swf/v2swf.c b/avi2swf/v2swf.c index 7d24c21..182821a 100644 --- a/avi2swf/v2swf.c +++ b/avi2swf/v2swf.c @@ -1064,7 +1064,7 @@ void v2swf_backpatch(v2swf_t*v2swf, char*filename) close(fi); fi = open(filename, O_WRONLY|O_BINARY|O_TRUNC|O_CREAT, 0666); if(fi>=0) { - swf_WriteSWC(fi, &tmp); + swf_WriteSWF(fi, &tmp); close(fi); msg("v2swf_backpatch %s - fix header: success\n", filename); } diff --git a/lib/devices/swf.c b/lib/devices/swf.c index 205163f..05567ae 100644 --- a/lib/devices/swf.c +++ b/lib/devices/swf.c @@ -1278,13 +1278,8 @@ int swfresult_save(gfxresult_t*gfx, const char*filename) return -1; } - if(swf->compressed) { - if FAILED(swf_WriteSWC(fi,swf)) - msg(" WriteSWC() failed.\n"); - } else { - if FAILED(swf_WriteSWF(fi,swf)) - msg(" WriteSWF() failed.\n"); - } + if FAILED(swf_WriteSWF(fi,swf)) + msg(" WriteSWF() failed.\n"); if(filename) close(fi); diff --git a/lib/example/protect.c b/lib/example/protect.c index e6127d1..2bf2f70 100644 --- a/lib/example/protect.c +++ b/lib/example/protect.c @@ -74,10 +74,8 @@ int main(int argn,char ** argv) if(fi<0) { fprintf(stderr, "couldn't create output file %s", outfilename); } - if(swf.compressed) - {if(swf_WriteSWC(fi, &swf)<0) fprintf(stderr, "WriteSWC() failed.\n");} - else - {if(swf_WriteSWF(fi, &swf)<0) fprintf(stderr, "WriteSWF() failed.\n");} + if(swf_WriteSWF(fi, &swf)<0) + fprintf(stderr, "WriteSWF() failed.\n"); close(fi); diff --git a/lib/h.263/swfvideo.c b/lib/h.263/swfvideo.c index 1b075ff..ae31564 100644 --- a/lib/h.263/swfvideo.c +++ b/lib/h.263/swfvideo.c @@ -1499,7 +1499,7 @@ void mkblack() tag = swf_InsertTag(tag, ST_END); int fi = open("black.swf", O_WRONLY|O_CREAT|O_TRUNC, 0644); - if(swf_WriteSWC(fi,&swf)<0) { + if(swf_WriteSWF(fi,&swf)<0) { fprintf(stderr,"WriteSWF() failed.\n"); } close(fi); @@ -1634,7 +1634,7 @@ int main(int argn, char*argv[]) tag = swf_InsertTag(tag, ST_END); fi = open("video3.swf", O_WRONLY|O_CREAT|O_TRUNC, 0644); - if(swf_WriteSWC(fi,&swf)<0) { + if(swf_WriteSWF(fi,&swf)<0) { fprintf(stderr,"WriteSWF() failed.\n"); } close(fi); diff --git a/lib/python/SWF.c b/lib/python/SWF.c index 55f6192..050b36a 100644 --- a/lib/python/SWF.c +++ b/lib/python/SWF.c @@ -211,18 +211,10 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs) PyErr_SetString(PyExc_Exception, setError("couldn't create output file %s", filename)); return 0; } - if(swf->compressed) { - if(swf_WriteSWC(fi, swf)<0) { - close(fi); - PyErr_SetString(PyExc_Exception, setError("WriteSWC() failed.")); - return 0; - } - } else { - if(swf_WriteSWF(fi, swf)<0) { - close(fi); - PyErr_SetString(PyExc_Exception, setError("WriteSWC() failed.")); - return 0; - } + if(swf_WriteSWF(fi, swf)<0) { + close(fi); + PyErr_SetString(PyExc_Exception, setError("WriteSWC() failed.")); + return 0; } close(fi); diff --git a/src/gif2swf.c b/src/gif2swf.c index e1379ac..6f60865 100644 --- a/src/gif2swf.c +++ b/src/gif2swf.c @@ -1,6 +1,6 @@ /* -*- mode: c; tab-width: 4; -*- ---------------------------[for (x)emacs]-- - $Id: gif2swf.c,v 1.6 2007/01/13 17:26:47 kramm Exp $ + $Id: gif2swf.c,v 1.7 2008/03/12 19:13:31 kramm Exp $ GIF to SWF converter tool Part of the swftools package. @@ -184,13 +184,8 @@ int MovieFinish(SWF * swf, TAG * t, char *sname) if FAILED (swf_WriteCGI(swf)) fprintf(stderr, "WriteCGI() failed.\n"); } else { - if (global.version >= 6) { - if (swf_WriteSWC(f, swf) < 0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } else { - if (swf_WriteSWF(f, swf) < 0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } + if (swf_WriteSWF(f, swf) < 0) + fprintf(stderr, "Unable to write output file: %s\n", sname); if (f != so) close(f); } diff --git a/src/jpeg2swf.c b/src/jpeg2swf.c index 7c1298f..544e7c9 100644 --- a/src/jpeg2swf.c +++ b/src/jpeg2swf.c @@ -136,13 +136,8 @@ int MovieFinish(SWF * swf, TAG * t, char *sname) sname = "output.swf"; handle = open(sname, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666); } - if(global.version >= 6) { - if (swf_WriteSWC(handle, swf)<0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } else { - if (swf_WriteSWF(handle, swf)<0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } + if (swf_WriteSWF(handle, swf)<0) + fprintf(stderr, "Unable to write output file: %s\n", sname); if (handle != so) close(handle); diff --git a/src/png2swf.c b/src/png2swf.c index 0878543..ffca258 100644 --- a/src/png2swf.c +++ b/src/png2swf.c @@ -100,13 +100,8 @@ int MovieFinish(SWF * swf, TAG * t, char *sname) if(global.do_cgi) { if FAILED(swf_WriteCGI(swf)) fprintf(stderr,"WriteCGI() failed.\n"); } else { - if(global.version >= 6) { - if (swf_WriteSWC(f, swf)<0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } else { - if (swf_WriteSWF(f, swf)<0) - fprintf(stderr, "Unable to write output file: %s\n", sname); - } + if (swf_WriteSWF(f, swf)<0) + fprintf(stderr, "Unable to write output file: %s\n", sname); if (f != so) close(f); } diff --git a/src/swfc.c b/src/swfc.c index 1875129..c07a8a0 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -1039,8 +1039,6 @@ static void s_endSWF() } if(do_cgi) {if(swf_WriteCGI(swf)<0) syntaxerror("WriteCGI() failed.\n");} - else if(swf->compressed) - {if(swf_WriteSWC(fi, swf)<0) syntaxerror("WriteSWC() failed.\n");} else {if(swf_WriteSWF(fi, swf)<0) syntaxerror("WriteSWF() failed.\n");} diff --git a/src/swfcombine.c b/src/swfcombine.c index 9ada1a6..b4dbfb9 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -1283,9 +1283,10 @@ int main(int argn, char *argv[]) if(config.zlib) { if(newswf.fileVersion < 6) newswf.fileVersion = 6; - swf_WriteSWC(fi, &newswf); + newswf.compressed = 1; + swf_WriteSWF(fi, &newswf); } else { - newswf.compressed = 0; + newswf.compressed = -1; // don't compress swf_WriteSWF(fi, &newswf); } close(fi); -- 1.7.10.4