-int CheckInputFile(char * fname,char ** realname)
-{ struct jpeg_decompress_struct cinfo;
- struct jpeg_error_mgr jerr;
- FILE * f;
- char * s = malloc(strlen(fname)+5);
- int width, height;
-
- if (!s) exit(2);
- (*realname) = s;
- strcpy(s,fname);
-
- // Check whether file exists (with typical extensions)
-
- if ((f=fopen(s,"rb"))==NULL)
- { sprintf(s,"%s.jpg",fname);
- if ((f=fopen(s,"rb"))==NULL)
- { sprintf(s,"%s.jpeg",fname);
- if ((f=fopen(s,"rb"))==NULL)
- { sprintf(s,"%s.JPG",fname);
- if ((f=fopen(s,"rb"))==NULL)
- { sprintf(s,"%s.JPEG",fname);
- if ((f=fopen(s,"rb"))==NULL)
- return -1;
- }
- }
+
+int frame = 0;
+TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int quality,
+ int width, int height)
+{
+ SHAPE *s;
+ SRECT r;
+ MATRIX m;
+ int fs;
+ int movie_width = swf->movieSize.xmax - swf->movieSize.xmin;
+ int movie_height = swf->movieSize.ymax - swf->movieSize.ymin;
+
+ if(global.mx) {
+ int sizex, sizey;
+ RGBA * pic2;
+ SWFPLACEOBJECT obj;
+ int quant=0;
+ getJPEG(sname, &sizex, &sizey, &pic2);
+ if(sizex != stream.owidth || sizey != stream.oheight) {
+ fprintf(stderr, "All images must have the same dimensions if using -m!");
+ exit(1);
+ }
+
+ t = swf_InsertTag(t, ST_VIDEOFRAME);
+ swf_SetU16(t, 0xf00d);
+ quant = 1+(30-(30*quality)/100);
+ if(!(frame%20)) {
+ swf_SetVideoStreamIFrame(t, &stream, pic2, quant);
+ } else {
+ swf_SetVideoStreamPFrame(t, &stream, pic2, quant);
+ }
+
+ t = swf_InsertTag(t, ST_PLACEOBJECT2);
+ swf_GetPlaceObject(0, &obj);
+ if(frame==0) {
+ obj.depth = 1;
+ obj.id = 0xf00d;
+ } else {
+ obj.depth = 1;
+ obj.move = 1;
+ obj.ratio = frame;
+ }
+ swf_SetPlaceObject(t,&obj);
+
+ t = swf_InsertTag(t, ST_SHOWFRAME);
+ } else {
+ t = swf_InsertTag(t, ST_DEFINEBITSJPEG2);
+ swf_SetU16(t, global.next_id); // id
+ swf_SetJPEGBits(t,sname,quality);
+
+ t = swf_InsertTag(t, ST_DEFINESHAPE);
+ swf_ShapeNew(&s);
+ swf_GetMatrix(NULL, &m);
+ if (global.fit_to_movie) {
+ m.sx = 0x10000 * movie_width / width;
+ m.sy = 0x10000 * movie_height / height;
+ width = movie_width / 20;
+ height = movie_height / 20;
+ } else {
+ m.sx = 20 * 0x10000;
+ m.sy = 20 * 0x10000;
+ }
+ m.tx = global.xoffset * 20;
+ m.ty = global.yoffset * 20;
+ fs = swf_ShapeAddBitmapFillStyle(s, &m, global.next_id, 1);
+ global.next_id++;
+ swf_SetU16(t, global.next_id); // id
+ r.xmin = global.xoffset * 20;
+ r.ymin = global.yoffset * 20;
+ r.xmax = r.xmin + width * 20;
+ r.ymax = r.ymin + height * 20;
+ swf_SetRect(t, &r);
+ swf_SetShapeHeader(t, s);
+ swf_ShapeSetAll(t, s, r.xmin, r.ymin, 0, fs, 0);
+ swf_ShapeSetLine(t, s, r.xmax - r.xmin, 0);
+ swf_ShapeSetLine(t, s, 0, r.ymax - r.ymin);
+ swf_ShapeSetLine(t, s, -r.xmax + r.xmin, 0);
+ swf_ShapeSetLine(t, s, 0, -r.ymax + r.ymin);
+ swf_ShapeSetEnd(t);
+
+ if(frame) {
+ t = swf_InsertTag(t, ST_REMOVEOBJECT2);
+ swf_SetU16(t, 1); // depth
+ }
+
+ t = swf_InsertTag(t, ST_PLACEOBJECT2);
+ swf_GetMatrix(NULL, &m);
+ m.tx = (movie_width - width * 20) / 2;
+ m.ty = (movie_height - height * 20) / 2;
+ swf_ObjectPlace(t, global.next_id, 1, &m, NULL, NULL);
+ global.next_id++;
+ t = swf_InsertTag(t, ST_SHOWFRAME);
+ }
+ frame++;
+
+ return t;
+}
+
+int CheckInputFile(image_t* i, char *fname, char **realname)
+{
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ FILE *f;
+ char *s = malloc(strlen(fname) + 5);
+ int width, height;
+
+ if (!s)
+ exit(2);
+ (*realname) = s;
+ strcpy(s, fname);
+
+ // Check whether file exists (with typical extensions)
+
+ if ((f = fopen(s, "rb")) == NULL) {
+ sprintf(s, "%s.jpg", fname);
+ if ((f = fopen(s, "rb")) == NULL) {
+ sprintf(s, "%s.jpeg", fname);
+ if ((f = fopen(s, "rb")) == NULL) {
+ sprintf(s, "%s.JPG", fname);
+ if ((f = fopen(s, "rb")) == NULL) {
+ sprintf(s, "%s.JPEG", fname);
+ if ((f = fopen(s, "rb")) == NULL)
+ return -1;
+ }
+ }
+ }