X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjpeg2swf.c;h=7c23147d377ea0d5d7589b3d7d6a684e6666f090;hb=48d48fa9f1a7173381258b6e0f1765bc84c0a7a1;hp=7ce2899a1be1231c086335ec613940fced722217;hpb=4a57b21eacb62c8e674b5aac169706e36968b7bc;p=swftools.git diff --git a/src/jpeg2swf.c b/src/jpeg2swf.c index 7ce2899..7c23147 100644 --- a/src/jpeg2swf.c +++ b/src/jpeg2swf.c @@ -7,10 +7,20 @@ Copyright (c) 2001 Rainer Böhme Copyright (c) 2002,2003 Matthias Kramm - This file is distributed under the GPL, see file COPYING for details - -*/ - + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include #include @@ -23,7 +33,7 @@ struct { int quality; - int framerate; + float framerate; int max_image_width; int max_image_height; int force_width; @@ -32,6 +42,7 @@ struct { int verbose; char *outfile; int mx; + int version; } global; typedef struct _image { @@ -44,15 +55,15 @@ image_t image[MAX_INPUT_FILES]; VIDEOSTREAM stream; -TAG *MovieStart(SWF * swf, int framerate, int dx, int dy) +TAG *MovieStart(SWF * swf, float framerate, int dx, int dy) { TAG *t; RGBA rgb; memset(swf, 0x00, sizeof(SWF)); - swf->fileVersion = 4; - swf->frameRate = (25600 / framerate); + swf->fileVersion = global.version; + swf->frameRate = (int)(256.0 * framerate); swf->movieSize.xmax = dx * 20; swf->movieSize.ymax = dy * 20; @@ -82,8 +93,14 @@ int MovieFinish(SWF * swf, TAG * t, char *sname) sname = "output.swf"; handle = open(sname, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666); } - if (swf_WriteSWF(handle, swf)<0) - fprintf(stderr, "Unable to write output file: %s\n", sname); + 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 (handle != so) close(handle); @@ -194,7 +211,7 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int quality, t = swf_InsertTag(t, ST_VIDEOFRAME); swf_SetU16(t, 0xf00d); quant = 1+(30-(30*quality)/100); - if(!(frame&127)) { + if(!(frame%20)) { swf_SetVideoStreamIFrame(t, &stream, pic2, quant); } else { swf_SetVideoStreamPFrame(t, &stream, pic2, quant); @@ -223,6 +240,8 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int quality, swf_GetMatrix(NULL, &m); m.sx = 20 * 0x10000; m.sy = 20 * 0x10000; + m.tx = -10; + m.ty = -10; fs = swf_ShapeAddBitmapFillStyle(s, &m, id, 0); swf_SetU16(t, id + 1); // id r.xmin = r.ymin = 0; @@ -237,8 +256,10 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int quality, swf_ShapeSetLine(t, s, 0, -r.ymax); swf_ShapeSetEnd(t); - t = swf_InsertTag(t, ST_REMOVEOBJECT2); - swf_SetU16(t, 1); // depth + if(frame) { + t = swf_InsertTag(t, ST_REMOVEOBJECT2); + swf_SetU16(t, 1); // depth + } t = swf_InsertTag(t, ST_PLACEOBJECT2); swf_GetMatrix(NULL, &m); @@ -328,8 +349,8 @@ int args_callback_option(char *arg, char *val) case 'r': if (val) - global.framerate = atoi(val); - if ((global.framerate < 1) ||(global.framerate > 5000)) { + global.framerate = atof(val); + if ((global.framerate < 1.0/256) || (global.framerate >= 256.0)) { if (VERBOSE(1)) fprintf(stderr, "Error: You must specify a valid framerate between 1 and 10000.\n"); @@ -358,6 +379,11 @@ int args_callback_option(char *arg, char *val) case 'm': global.mx = 1; + global.version = 6; + return 0; + + case 'z': + global.version = 6; return 0; case 'Y': @@ -384,14 +410,17 @@ int args_callback_option(char *arg, char *val) return res; } -struct options_t options[] = { {"q", "quality"}, +static struct options_t options[] = { {"o", "output"}, {"m", "mx"}, +{"q", "quality"}, {"r", "rate"}, -{"v", "verbose"}, +{"z", "zlib"}, {"X", "width"}, {"Y", "height"}, +{"v", "verbose"}, {"V", "version"}, +{0,0} }; int args_callback_longoption(char *name, char *val) @@ -422,29 +451,19 @@ int args_callback_command(char *arg, char *next) // actually used as filename void args_callback_usage(char *name) { - printf - ("Usage: %s [-options [value]] imagefiles[.jpg]|[.jpeg] [...]\n", - name); - printf - ("-o outputfile --output explicitly specify output file. (otherwise, output.swf will be used)\n"); - printf - ("-m --mx Use Flash MX H.263 compression (use for correlated images)\n"); - printf - ("-q quality --quality Set compression quality (1-100, 1=worst, 100=best)\n"); - printf - ("-r framerate --rate Set movie framerate (100/sec)\n"); - printf - ("-o outputfile --output Set name for SWF output file\n"); - printf - ("-X pixel --width Force movie width to pixel (default: autodetect)\n"); - printf - ("-Y pixel --height Force movie height to pixel (default: autodetect)\n"); - printf - ("-v level --verbose Set verbose level (0=quiet, 1=default, 2=debug)\n"); - printf - ("-V --version Print version information and exit\n"); - printf - ("The following options can be set independently for each image: -q -s\n"); + printf("\n"); + printf("Usage: %s [-options [value]] imagefiles[.jpg]|[.jpeg] [...]\n", name); + printf("\n"); + printf("-o , --output Explicitly specify output file. (otherwise, output.swf will be used)\n"); + printf("-m , --mx Use Flash MX H.263 compression (use for correlated images)\n"); + printf("-q , --quality Set compression quality (1-100, 1=worst, 100=best)\n"); + printf("-r , --rate Set movie framerate (frames per second)\n"); + printf("-z , --zlib Enable Flash 6 (MX) Zlib Compression\n"); + printf("-X , --width Force movie width to (default: autodetect)\n"); + printf("-Y , --height Force movie height to (default: autodetect)\n"); + printf("-v , --verbose Set verbose level to (0=quiet, 1=default, 2=debug)\n"); + printf("-V , --version Print version information and exit\n"); + printf("\n"); } @@ -456,8 +475,9 @@ int main(int argc, char **argv) memset(&global, 0x00, sizeof(global)); global.quality = 60; - global.framerate = 100; + global.framerate = 1.0; global.verbose = 1; + global.version = 4; processargs(argc, argv);