- t = swf_InsertTag(t,ST_DEFINESHAPE);
-
- swf_ShapeNew(&s);
- swf_GetMatrix(NULL,&m);
- m.sx = 20*0x10000;
- m.sy = 20*0x10000;
- fs = swf_ShapeAddBitmapFillStyle(s,&m,id,0);
-
- swf_SetU16(t,id+1); // id
-
-
- r.xmin = r.ymin = 0;
- r.xmax = cinfo.output_width*20;
- r.ymax = cinfo.output_height*20;
- swf_SetRect(t,&r);
-
- swf_SetShapeHeader(t,s);
-
- swf_ShapeSetAll(t,s,0,0,0,fs,0);
- swf_ShapeSetLine(t,s,r.xmax,0);
- swf_ShapeSetLine(t,s,0,r.ymax);
- swf_ShapeSetLine(t,s,-r.xmax,0);
- swf_ShapeSetLine(t,s,0,-r.ymax);
-
- swf_ShapeSetEnd(t);
-
- t = swf_InsertTag(t,ST_REMOVEOBJECT2);
- swf_SetU16(t,1); // depth
-
- t = swf_InsertTag(t,ST_PLACEOBJECT2);
-
- swf_GetMatrix(NULL,&m);
- m.tx = (swf->movieSize.xmax-(int)cinfo.output_width*20)/2;
- m.ty = (swf->movieSize.ymax-(int)cinfo.output_height*20)/2;
- swf_ObjectPlace(t,id+1,1,&m,NULL,NULL);
-
- t = swf_InsertTag(t,ST_SHOWFRAME);
-
- jpeg_finish_decompress(&cinfo);
- fclose(f);
-
- return t;
+ free(buf);
+ *pic2 = pic;
+ 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 = 0;
+ m.ty = 0;
+ fs = swf_ShapeAddBitmapFillStyle(s, &m, global.next_id, 1);
+ global.next_id++;
+ swf_SetU16(t, global.next_id); // id
+ r.xmin = 0;
+ r.ymin = 0;
+ 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.sx = (int)(0x10000 * global.scale);
+ m.sy = (int)(0x10000 * global.scale);
+
+ if(custom_move) {
+ m.tx = move_x*20;
+ m.ty = move_y*20;
+ } else {
+ m.tx = (movie_width - (width * global.scale * 20)) / 2;
+ m.ty = (movie_height - (height * global.scale * 20)) / 2;
+ }
+ swf_ObjectPlace(t, global.next_id, 1, &m, NULL, NULL);
+ global.next_id++;
+ t = swf_InsertTag(t, ST_SHOWFRAME);
+ }
+ frame++;
+
+ return t;