2 #include "primitives.h"
9 //----------------------------------------------------------------------------
11 typedef struct _font_internal
15 staticforward tag_internals_t font_tag;
17 static int font_parse(tag_internals_t*self)
19 font_internal_t*font = (font_internal_t*)self->data;
21 PyErr_SetString(PyExc_Exception, setError("Font parsing not implemented yet"));
24 static void font_dealloc(tag_internals_t*self)
26 font_internal_t*font = (font_internal_t*)self->data;
28 swf_FontFree(font->font);
32 static int font_fillTAG(tag_internals_t*self)
34 font_internal_t*fi = (font_internal_t*)self->data;
37 self->tag = swf_InsertTag(0, ST_DEFINEFONT2);
38 swf_FontSetDefine2(self->tag, fi->font);
41 static PyObject* f_DefineFont(PyObject* self, PyObject* args, PyObject* kwargs)
43 static char *kwlist[] = {"filename", NULL};
48 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &filename))
51 font = swf_LoadFont(filename);
53 PyErr_SetString(PyExc_Exception, setError("Could not load %s", filename));
57 tag = tag_new(&font_tag);
58 tag_internals_t*itag = tag_getinternals(tag);
59 font_internal_t*fi = (font_internal_t*)itag->data;
62 return (PyObject*)tag;
64 static SWFFONT* font_getSWFFONT(PyObject*self)
66 PY_ASSERT_TYPE(self, &TagClass);
67 tag_internals_t*itag = tag_getinternals(self);
68 font_internal_t*fi = (font_internal_t*)itag->data;
71 static tag_internals_t font_tag =
74 fillTAG: font_fillTAG,
75 dealloc: font_dealloc,
79 datasize: sizeof(font_internal_t),
81 //----------------------------------------------------------------------------
83 typedef struct _placeobject_internal
86 } placeobject_internal_t;
87 staticforward tag_internals_t placeobject_tag;
89 static void po_dealloc(tag_internals_t*self)
91 placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
93 swf_PlaceObjectFree(pi->po);
97 static int po_parse(tag_internals_t*self)
99 placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
101 PyErr_SetString(PyExc_Exception, setError("Font parsing not implemented yet"));
104 static int po_fillTAG(tag_internals_t*self)
106 placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
107 self->tag = swf_InsertTag(0, ST_PLACEOBJECT2);
108 swf_SetPlaceObject(self->tag, pi->po);
111 static PyObject* po_create(PyObject* self, PyObject* args, PyObject* kwargs,char move)
113 static char *kwlist[] = {"character", "depth", "matrix", "colortransform", "ratio", "name", "clipdepth", "action", NULL};
115 PyObject*character = 0;
124 po = malloc(sizeof(SWFPLACEOBJECT));
125 memset(po, 0, sizeof(SWFPLACEOBJECT));
127 swf_GetPlaceObject(0, po);
130 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O!O!isiO!", kwlist,
133 &MatrixClass, &matrix,
134 &CXFormClass, &cxform,
138 &ActionClass, &action
143 po->clipdepth = clipdepth;
147 if(clipdepth) po->clipdepth = clipdepth;
148 if(matrix) po->matrix = matrix_getMatrix(matrix);
149 if(cxform) po->cxform = colortransform_getCXForm(cxform);
150 if(action) po->actions = action_getAction(action);
153 tag = tag_new(&placeobject_tag);
154 tag_internals_t*itag = tag_getinternals(tag);
155 placeobject_internal_t*pi = (placeobject_internal_t*)itag->data;
158 pi->po->id = tagmap_add(itag->tagmap,(PyObject*)character);
163 mylog("+%08x(%d) PlaceObject %08x(%d)\n", (int)tag, tag->ob_refcnt, character, character->ob_refcnt);
165 return (PyObject*)tag;
167 static PyObject* f_PlaceObject(PyObject* self, PyObject* args, PyObject* kwargs)
169 return po_create(self, args, kwargs, 0);
171 static PyObject* f_MoveObject(PyObject* self, PyObject* args, PyObject* kwargs)
173 return po_create(self, args, kwargs, 1);
175 static tag_internals_t placeobject_tag =
183 datasize: sizeof(placeobject_internal_t),
185 //----------------------------------------------------------------------------
186 staticforward tag_internals_t bgcolor_tag;
187 static PyObject* tag_setbackgroundcolor_getrgb(PyObject * self, PyObject*other)
189 tag_internals_t*itag = tag_getinternals(self);
191 r = itag->tag->data[0];
192 g = itag->tag->data[1];
193 b = itag->tag->data[2];
194 return Py_BuildValue("(iii)", r,g,b);
196 static PyMethodDef setbgcolor_methods[] =
197 {{"getRGB", tag_setbackgroundcolor_getrgb, METH_VARARGS, "get's the color set by this tag"},
198 {NULL, NULL, 0, NULL}
200 static PyObject* f_SetBackgroundColor(PyObject* self, PyObject* args, PyObject* kwargs)
202 static char *kwlist[] = {"color", NULL};
207 tag = tag_new(&bgcolor_tag);
208 tag_internals_t*itag = tag_getinternals(tag);
210 /* 1st try- copy constructor */
211 if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &ColorClass, &color)) {
213 /* 2nd try- color's contructor */
214 color = f_Color(NULL, args, kwargs);
219 itag->tag = swf_InsertTag(0, ST_SETBACKGROUNDCOLOR);
220 RGBA rgba = color_getRGBA(color);
221 swf_SetU8(itag->tag, rgba.r);
222 swf_SetU8(itag->tag, rgba.g);
223 swf_SetU8(itag->tag, rgba.b);
224 mylog(" %08x(%d) SetBackgroundColor(%02x,%02x,%02x) (colorobj=%08x(%d))\n", (int)tag, tag->ob_refcnt, rgba.r, rgba.g, rgba.b, color, color->ob_refcnt);
226 return (PyObject*)tag;
228 static tag_internals_t bgcolor_tag =
235 tagfunctions: setbgcolor_methods,
238 //----------------------------------------------------------------------------
239 staticforward tag_internals_t protect_tag;
240 static PyObject* f_Protect(PyObject* self, PyObject* args, PyObject* kwargs)
242 static char *kwlist[] = {"password", NULL};
245 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &password))
248 PyObject*tag = tag_new(&protect_tag);
249 tag_internals_t*itag = tag_getinternals(tag);
250 itag->tag = swf_InsertTag(0, ST_PROTECT);
252 swf_SetPassword(itag->tag, password);
254 mylog("+%08x(%d) f_Protect", (int)tag, tag->ob_refcnt);
255 return (PyObject*)tag;
257 static tag_internals_t protect_tag =
267 //----------------------------------------------------------------------------
268 staticforward tag_internals_t showframe_tag;
269 static PyObject* f_ShowFrame(PyObject* self, PyObject* args, PyObject* kwargs)
271 static char *kwlist[] = {"name", NULL};
273 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &name))
276 PyObject*tag = tag_new(&showframe_tag);
277 tag_internals_t*itag = tag_getinternals(tag);
278 itag->tag = swf_InsertTag(0, ST_SHOWFRAME);
279 mylog("+%08x(%d) f_ShowFrame", (int)tag, tag->ob_refcnt);
280 return (PyObject*)tag;
282 static tag_internals_t showframe_tag =
292 //----------------------------------------------------------------------------
293 staticforward tag_internals_t removeobject_tag;
294 static PyObject* f_RemoveObject(PyObject* self, PyObject* args, PyObject* kwargs)
296 static char *kwlist[] = {"depth", NULL};
298 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &depth))
301 PyObject*tag = tag_new(&removeobject_tag);
302 tag_internals_t*itag = tag_getinternals(tag);
303 itag->tag = swf_InsertTag(0, ST_REMOVEOBJECT);
304 swf_SetU16(itag->tag, depth);
305 mylog("+%08x(%d) f_RemoveObject", (int)tag, tag->ob_refcnt);
306 return (PyObject*)tag;
308 static tag_internals_t removeobject_tag =
318 //----------------------------------------------------------------------------
319 staticforward tag_internals_t sprite_tag;
320 typedef struct _sprite_internal
325 static int sprite_fillTAG(tag_internals_t*self)
327 mylog("+%08x(?) sprite_fillTAG", (int)self);
329 sprite_internal_t*si = (sprite_internal_t*)self->data;
331 TAG*sprite = swf_InsertTag(0, ST_DEFINESPRITE);
332 swf_SetU16(sprite, 0); //id
333 swf_SetU16(sprite, 0); //frames
335 TAG*tag = taglist_getTAGs2(si->taglist, self->tagmap, 0);
337 /* pass through exception */
341 while(tag2->next) tag2 = tag2->next;
342 swf_InsertTag(tag2, ST_END);
347 swf_FoldSprite(sprite);
352 static PyObject* f_Sprite(PyObject* self, PyObject* args, PyObject* kwargs)
354 static char *kwlist[] = {"name", NULL};
356 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &name))
359 PyObject*tag = tag_new(&sprite_tag);
360 tag_internals_t*itag = tag_getinternals(tag);
361 sprite_internal_t*si = (sprite_internal_t*)itag->data;
362 si->taglist = taglist_new();
363 mylog("+%08x(%d) f_DefineSprite", (int)tag, tag->ob_refcnt);
364 return (PyObject*)tag;
366 static PyObject* sprite_getattr(tag_internals_t*self,char*a)
368 sprite_internal_t*si = (sprite_internal_t*)self->data;
369 if(!strcmp(a, "tags")) {
370 Py_INCREF(si->taglist);
375 static int sprite_setattr(tag_internals_t*self,char*a, PyObject*obj)
377 sprite_internal_t*si = (sprite_internal_t*)self->data;
379 swf_DeleteTag(self->tag);
382 if(!strcmp(a, "tags")) {
383 PY_ASSERT_TYPE(obj,&TagListClass);
384 Py_DECREF(si->taglist);
386 Py_INCREF(si->taglist);
391 static tag_internals_t sprite_tag =
394 fillTAG: sprite_fillTAG,
396 getattr: sprite_getattr,
397 setattr: sprite_setattr,
399 datasize: sizeof(sprite_internal_t),
401 //----------------------------------------------------------------------------
402 staticforward tag_internals_t end_tag;
403 static tag_internals_t end_tag =
413 //----------------------------------------------------------------------------
414 staticforward tag_internals_t text_tag;
416 typedef struct _text_internal
424 staticforward tag_internals_t placeobject_tag;
426 static int text_fillTAG(tag_internals_t*self)
428 text_internal_t*ti = (text_internal_t*)self->data;
429 self->tag= swf_InsertTag(0, ST_DEFINETEXT2);
430 swf_SetU16(self->tag, /*ID*/0);
431 ti->bbox = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size);
434 static PyObject* text_getattr(tag_internals_t*self,char*a)
436 text_internal_t*si = (text_internal_t*)self->data;
437 if(!strcmp(a, "bbox")) {
438 return f_BBox2(si->bbox);
442 static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs)
444 static char *kwlist[] = {"font", "text", "size", "color", NULL};
449 RGBA rgba = {255,0,0,0};
453 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Oi|O!", kwlist, &TagClass, &font, &otext, &size, &ColorClass, &color))
455 if(PyUnicode_Check(otext)) {
456 text = PyString_AS_STRING(PyUnicode_AsUTF8String(otext));
457 } else if(PyString_Check(otext)) {
458 text = PyString_AS_STRING(otext);
462 rgba = color_getRGBA(color);
464 mylog("DefineText: text = %s", text);
466 tag = tag_new(&text_tag);
467 tag_internals_t* itag = tag_getinternals(tag);
468 text_internal_t*ti = (text_internal_t*)itag->data;
470 ti->swffont = font_getSWFFONT(font);
471 int font_id = tagmap_add(itag->tagmap, font); // add dependency on font
472 ti->swffont->id = font_id; // for swf_SetDefineTexts
473 ti->text = strdup(text);
477 return (PyObject*)tag;
479 static tag_internals_t text_tag =
482 fillTAG: text_fillTAG,
484 getattr: text_getattr,
487 datasize: sizeof(text_internal_t),
489 //----------------------------------------------------------------------------
490 staticforward tag_internals_t image_tag;
492 typedef struct _image_internal
502 staticforward tag_internals_t image_tag;
504 static int image_fillTAG(tag_internals_t*self)
506 image_internal_t*ti = (image_internal_t*)self->data;
507 self->tag= swf_InsertTag(0, ST_DEFINEBITSLOSSLESS2);
508 swf_SetU16(self->tag, /*ID*/0);
509 swf_SetLosslessBits(self->tag, ti->width, ti->height, ti->rgba, BMF_32BIT);
512 static void image_dealloc(tag_internals_t*self)
514 image_internal_t*pi = (image_internal_t*)self->data;
516 free(pi->rgba);pi->rgba = 0;
519 static int imagetag_getWidth(PyObject* self)
521 tag_internals_t*itag = tag_getinternals(self);
522 image_internal_t*pi = (image_internal_t*)itag->data;
525 static int imagetag_getHeight(PyObject* self)
527 tag_internals_t*itag = tag_getinternals(self);
528 image_internal_t*pi = (image_internal_t*)itag->data;
531 static PyObject* f_DefineImage(PyObject* self, PyObject* args, PyObject* kwargs)
533 static char *kwlist[] = {"image"};
535 PyObject*tag = tag_new(&image_tag);
537 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &image))
540 tag = tag_new(&image_tag);
541 tag_internals_t* itag = tag_getinternals(tag);
542 image_internal_t*ti = (image_internal_t*)itag->data;
544 ti->rgba = image_toRGBA(image);
545 if(!ti->rgba) // pass through exception
547 ti->width = image_getWidth(image);
548 ti->height = image_getHeight(image);
552 ti->size = ti->width*ti->height;
554 return (PyObject*)tag;
556 static tag_internals_t image_tag =
559 fillTAG: image_fillTAG,
560 dealloc: image_dealloc,
564 datasize: sizeof(image_internal_t),
566 //----------------------------------------------------------------------------
567 staticforward tag_internals_t shape_tag;
569 typedef struct _shape_internal
573 staticforward tag_internals_t shape_tag;
575 static int shape_fillTAG(tag_internals_t*self)
577 shape_internal_t*ti = (shape_internal_t*)self->data;
578 self->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
579 swf_SetU16(self->tag, /*ID*/0);
580 swf_SetShape2(self->tag, ti->shape);
583 static void shape_dealloc(tag_internals_t*self)
585 shape_internal_t*pi = (shape_internal_t*)self->data;
587 swf_Shape2Free(pi->shape);
591 static PyObject* f_DefineImageShape(PyObject* self, PyObject* args, PyObject* kwargs)
593 static char *kwlist[] = {"image"};
595 PyObject*tag = tag_new(&shape_tag);
598 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &TagClass, &image))
601 tag = tag_new(&shape_tag);
602 tag_internals_t* itag = tag_getinternals(tag);
603 shape_internal_t*ti = (shape_internal_t*)itag->data;
604 ti->shape = 0; /*HACK*/
606 int width = imagetag_getWidth(image);
607 int height = imagetag_getHeight(image);
608 int id = tagmap_add(itag->tagmap, image);
609 itag->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
610 swf_SetU16(itag->tag, 0);
611 swf_ShapeSetBitmapRect(itag->tag, id, width, height);
612 return (PyObject*)tag;
614 static tag_internals_t shape_tag =
617 fillTAG: shape_fillTAG,
618 dealloc: shape_dealloc,
622 datasize: sizeof(shape_internal_t),
624 //----------------------------------------------------------------------------
626 typedef struct _videostream_internal
630 } videostream_internal_t;
631 staticforward tag_internals_t videostream_tag;
632 staticforward tag_internals_t videoframe_tag;
634 static int videostream_parse(tag_internals_t*self)
636 videostream_internal_t*videostream = (videostream_internal_t*)self->data;
638 PyErr_SetString(PyExc_Exception, setError("videostream parsing not implemented yet"));
641 static void videostream_dealloc(tag_internals_t*self)
643 videostream_internal_t*videostream = (videostream_internal_t*)self->data;
644 if(videostream->stream) {
645 swf_VideoStreamClear(videostream->stream);
646 free(videostream->stream);
647 videostream->stream = 0;
650 static int videostream_fillTAG(tag_internals_t*self)
652 videostream_internal_t*fi = (videostream_internal_t*)self->data;
655 PyErr_SetString(PyExc_Exception, setError("videostream filling not implemented"));
658 static PyObject* f_DefineVideoStream(PyObject* self, PyObject* args, PyObject* kwargs)
660 PyObject*tag = tag_new(&videostream_tag);
662 int width=0,height=0,frames=65535;
663 static char *kwlist[] = {"width", "height", "frames", NULL};
664 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i", kwlist, &width, &height, &frames))
667 tag_internals_t*itag = tag_getinternals(tag);
668 videostream_internal_t*fi = (videostream_internal_t*)itag->data;
669 fi->stream = malloc(sizeof(VIDEOSTREAM));
670 memset(fi->stream, 0, sizeof(VIDEOSTREAM));
672 TAG*t = swf_InsertTag(0, ST_DEFINEVIDEOSTREAM);
673 swf_SetU16(t, 0); /* id */
674 swf_SetVideoStreamDefine(t, fi->stream, frames, width, height);
676 fi->lastiframe = -65536;
677 return (PyObject*)tag;
679 static VIDEOSTREAM* videostream_getVIDEOSTREAM(PyObject*self)
681 PY_ASSERT_TYPE(self, &TagClass);
682 tag_internals_t*itag = tag_getinternals(self);
683 videostream_internal_t*fi = (videostream_internal_t*)itag->data;
686 static PyObject* videostream_getbwidth(PyObject*self, PyObject*args)
688 tag_internals_t*itag = tag_getinternals(self);
689 videostream_internal_t*fi = (videostream_internal_t*)itag->data;
690 int width = fi->stream->bbx;
691 return Py_BuildValue("i", width);
693 static PyObject* videostream_getbheight(PyObject*self, PyObject*args)
695 tag_internals_t*itag = tag_getinternals(self);
696 videostream_internal_t*fi = (videostream_internal_t*)itag->data;
697 int height = fi->stream->bby;
698 return Py_BuildValue("i", height);
700 static PyObject* videostream_addBlackFrame(PyObject*self, PyObject*args, PyObject*kwargs)
702 tag_internals_t*_itag = tag_getinternals(self);
703 videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
705 TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
707 PyObject*tag = tag_new(&videoframe_tag);
708 tag_internals_t*itag = tag_getinternals(tag);
710 swf_SetU16(t,0); /* id */
711 swf_SetVideoStreamBlackFrame(t, fi->stream);
712 fi->lastiframe = fi->stream->frame;
715 tagmap_addMapping(itag->tagmap, 0, self);
718 static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwargs)
720 tag_internals_t*_itag = tag_getinternals(self);
721 videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
724 char*type=0; // none, "i", "p"
726 static char *kwlist[] = {"image", "quant", "type", NULL};
727 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|is", kwlist, &image, &quant, &type))
729 if(fi->stream->width != image_getWidth(image)) {
730 PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getWidth(image), fi->stream->width));return 0;
732 if(fi->stream->height != image_getHeight(image)) {
733 PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getHeight(image), fi->stream->height));return 0;
735 PyObject*tag = tag_new(&videoframe_tag);
736 tag_internals_t*itag = tag_getinternals(tag);
738 RGBA*pic = image_toRGBA(image);
742 /*{ int f,j=0,i=0,rr,gg,bb;
745 char*filename="test.ppm";
746 printf("Creating %s %dx%d\n",filename, 512,512);
747 o=fopen(filename, "wb");
748 fprintf(o,"P6\n%d %d\n255\n",512, 512);
754 fprintf(o,"%c%c%c",rr,gg,bb);
761 TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
762 if((type && (type[0]=='I' || type[0]=='i')) || (type==0 && fi->lastiframe+64 < fi->stream->frame)) {
763 swf_SetU16(t,0); /* id */
764 swf_SetVideoStreamIFrame(t, fi->stream, pic, quant);
765 fi->lastiframe = fi->stream->frame;
768 swf_SetVideoStreamPFrame(t, fi->stream, pic, quant);
771 tagmap_addMapping(itag->tagmap, 0, self);
775 static PyObject* videostream_addDistortionFrame(PyObject*self, PyObject*args, PyObject*kwargs)
777 tag_internals_t*_itag = tag_getinternals(self);
778 videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
780 static char *kwlist[] = {"image", "quant", NULL};
783 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i", kwlist, &array, &quant))
786 signed char* movex = malloc(fi->stream->bbx * fi->stream->bby * 1);
787 signed char* movey = malloc(fi->stream->bbx * fi->stream->bby * 1);
788 RGBA** pics = (RGBA**)malloc(fi->stream->bbx * fi->stream->bby * sizeof(void*));
789 signed char* itx=movex;
790 signed char* ity=movey;
793 if(!array || !PySequence_Check(array))
794 return PY_ERROR("Not an array");
795 if(PySequence_Length(array) < fi->stream->bby)
796 return PY_ERROR("Array (y) has to have at least %d elements, but has only %d ", fi->stream->bby, PySequence_Length(array));
797 for(y=0;y<fi->stream->bby;y++) {
798 PyObject*line = PySequence_GetItem(array, y);
799 if(!line || !PySequence_Check(line))
800 return PY_ERROR("Not an array of arrays");
801 if(PySequence_Length(line) < fi->stream->bbx)
802 return PY_ERROR("Inner arrays (x) have to be at least %d long- %dth is only %d", fi->stream->bbx, y, PySequence_Length(line));
804 for(x=0;x<fi->stream->bbx;x++) {
805 PyObject*pixel = PySequence_GetItem(line, x);
812 if(PyComplex_Check(pixel)) {
813 xy = pixel; image = 0;
814 } else if(PyString_Check(pixel)) {
815 xy = 0; image = pixel;
816 } else if(PyTuple_Check(pixel)) {
817 int size = PyTuple_GET_SIZE(pixel);
818 if(size!=2) return PY_ERROR("Tuples have to have size 2 (xy,img)");
819 xy = PyTuple_GetItem(pixel, 0);
821 if(!PyComplex_Check(xy)) return PY_ERROR("Tuples must be (COMPLEX,string)");
822 image = PyTuple_GetItem(pixel, 1);
824 if(!PyString_Check(image)) return PY_ERROR("Tuples must be (complex,STRING)");
832 *itx = (signed char)PyComplex_RealAsDouble(pixel);
833 *ity = (signed char)PyComplex_ImagAsDouble(pixel);
838 PyString_AsStringAndSize(image,&string,&size);
840 return PY_ERROR("image strings must be >= 256*3");
842 *pic = malloc(sizeof(RGBA)*16*16);
844 for(t=0;t<16*16;t++) {
845 (*pic)[t].r = string[t*3];
846 (*pic)[t].g = string[t*3+1];
847 (*pic)[t].b = string[t*3+2];
857 PyObject*tag = tag_new(&videoframe_tag);
858 tag_internals_t*itag = tag_getinternals(tag);
860 TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
861 swf_SetU16(t,0); /* id */
862 swf_SetVideoStreamMover(t, fi->stream, movex, movey,(void**)pics, quant);
865 tagmap_addMapping(itag->tagmap, 0, self);
867 for(x=0;x<fi->stream->bbx*fi->stream->bby;x++) {
869 free(pics[x]);pics[x] = 0;
879 static PyMethodDef videostream_methods[] =
880 {{"xblocks", videostream_getbwidth, METH_VARARGS, "get's the number of horizontal blocks"},
881 {"yblocks", videostream_getbheight, METH_VARARGS, "get's the number of vertical blocks"},
882 {"addFrame", (PyCFunction)videostream_addFrame, METH_KEYWORDS, "add a Video Frame"},
883 {"addBlackFrame", (PyCFunction)videostream_addBlackFrame, METH_KEYWORDS, "add a black Video Frame"},
884 {"addDistortionFrame", (PyCFunction)videostream_addDistortionFrame, METH_KEYWORDS, "add a MVD frame"},
885 {NULL, NULL, 0, NULL}
888 static tag_internals_t videostream_tag =
890 parse: videostream_parse,
891 fillTAG: videostream_fillTAG,
892 dealloc: videostream_dealloc,
895 tagfunctions: videostream_methods,
896 datasize: sizeof(videostream_internal_t),
899 //============================================================================
901 static tag_internals_t videoframe_tag =
912 //============================================================================
914 static PyMethodDef TagMethods[] =
917 {"BackgroundColor", (PyCFunction)f_SetBackgroundColor, METH_KEYWORDS, "Create a SetBackGroundColor Tag."},
918 {"Protect", (PyCFunction)f_Protect, METH_KEYWORDS, "Create a Protect Tag."},
919 {"Font", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."},
920 {"Text", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."},
921 {"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."},
922 {"RemoveObject", (PyCFunction)f_RemoveObject, METH_KEYWORDS, "Create a RemoveObject Tag."},
923 {"MoveObject", (PyCFunction)f_MoveObject, METH_KEYWORDS, "Create a PlaceObject Move Tag."},
924 {"VideoStream", (PyCFunction)f_DefineVideoStream, METH_KEYWORDS, "Create a Videostream."},
925 {"Image", (PyCFunction)f_DefineImage, METH_KEYWORDS, "Create an SWF Image Tag."},
926 {"ImageShape", (PyCFunction)f_DefineImageShape, METH_KEYWORDS, "Create an SWF Image Shape Tag."},
927 {"ShowFrame", (PyCFunction)f_ShowFrame, METH_KEYWORDS, "Create an SWF Show Frame Tag."},
928 {"Sprite", (PyCFunction)f_Sprite, METH_KEYWORDS, "Create an SWF Sprite Tag."},
929 {NULL, NULL, 0, NULL}
931 PyMethodDef* tags_getMethods()
933 TagClass.ob_type = &PyType_Type;
935 register_tag(ST_PLACEOBJECT,&placeobject_tag);
936 register_tag(ST_PLACEOBJECT2,&placeobject_tag);
937 register_tag(ST_REMOVEOBJECT,&removeobject_tag);
938 register_tag(ST_REMOVEOBJECT2,&removeobject_tag);
939 register_tag(ST_SETBACKGROUNDCOLOR,&bgcolor_tag);
940 register_tag(ST_DEFINEFONT,&font_tag);
941 register_tag(ST_PROTECT,&protect_tag);
942 register_tag(ST_DEFINETEXT,&text_tag);
943 register_tag(ST_DEFINEBITSJPEG,&image_tag);
944 register_tag(ST_DEFINEBITSJPEG2,&image_tag);
945 register_tag(ST_DEFINEBITSJPEG3,&image_tag);
946 register_tag(ST_DEFINEBITSLOSSLESS,&image_tag);
947 register_tag(ST_DEFINEBITSLOSSLESS2,&image_tag);
948 register_tag(ST_SHOWFRAME,&showframe_tag);
949 register_tag(ST_DEFINEVIDEOSTREAM,&videostream_tag);
950 register_tag(ST_VIDEOFRAME,&videoframe_tag);
951 register_tag(ST_DEFINESPRITE,&sprite_tag);
952 register_tag(ST_END,&end_tag);