+ static char *kwlist[] = {"image", "quant", NULL};
+ int quant=7;
+ PyObject* array = 0;
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i", kwlist, &array, &quant))
+ return NULL;
+
+ signed char* movex = malloc(fi->stream->bbx * fi->stream->bby * 1);
+ signed char* movey = malloc(fi->stream->bbx * fi->stream->bby * 1);
+ RGBA** pics = (RGBA**)malloc(fi->stream->bbx * fi->stream->bby * sizeof(void*));
+ signed char* itx=movex;
+ signed char* ity=movey;
+ RGBA**pic=pics;
+ int x,y;
+ if(!array || !PySequence_Check(array))
+ return PY_ERROR("Not an array");
+ if(PySequence_Length(array) < fi->stream->bby)
+ return PY_ERROR("Array (y) has to have at least %d elements, but has only %d ", fi->stream->bby, PySequence_Length(array));
+ for(y=0;y<fi->stream->bby;y++) {
+ PyObject*line = PySequence_GetItem(array, y);
+ if(!line || !PySequence_Check(line))
+ return PY_ERROR("Not an array of arrays");
+ if(PySequence_Length(line) < fi->stream->bbx)
+ return PY_ERROR("Inner arrays (x) have to be at least %d long- %dth is only %d", fi->stream->bbx, y, PySequence_Length(line));
+
+ for(x=0;x<fi->stream->bbx;x++) {
+ PyObject*pixel = PySequence_GetItem(line, x);
+ PyObject*xy = 0;
+ PyObject*image = 0;
+
+ if(!pixel) {
+ xy = image = 0;
+ } else {
+ if(PyComplex_Check(pixel)) {
+ xy = pixel; image = 0;
+ } else if(PyString_Check(pixel)) {
+ xy = 0; image = pixel;
+ } else if(PyTuple_Check(pixel)) {
+ int size = PyTuple_GET_SIZE(pixel);
+ if(size!=2) return PY_ERROR("Tuples have to have size 2 (xy,img)");
+ xy = PyTuple_GetItem(pixel, 0);
+ if(!xy) return 0;
+ if(!PyComplex_Check(xy)) return PY_ERROR("Tuples must be (COMPLEX,string)");
+ image = PyTuple_GetItem(pixel, 1);
+ if(!image) return 0;
+ if(!PyString_Check(image)) return PY_ERROR("Tuples must be (complex,STRING)");
+ }
+ }
+
+ *itx = *ity = 0;
+ *pic= 0;
+
+ if(xy) {
+ *itx = (signed char)PyComplex_RealAsDouble(pixel);
+ *ity = (signed char)PyComplex_ImagAsDouble(pixel);
+ }
+ if(image) {
+ char*string;
+ int size;
+ PyString_AsStringAndSize(image,&string,&size);
+ if(size<256*3) {
+ return PY_ERROR("image strings must be >= 256*3");
+ }
+ *pic = malloc(sizeof(RGBA)*16*16);
+ int t;
+ for(t=0;t<16*16;t++) {
+ (*pic)[t].r = string[t*3];
+ (*pic)[t].g = string[t*3+1];
+ (*pic)[t].b = string[t*3+2];
+ (*pic)[t].a = 255;
+ }
+ }
+ itx++;
+ ity++;
+ pic++;
+ }
+ }
+
+ PyObject*tag = tag_new(&videoframe_tag);
+ tag_internals_t*itag = tag_getinternals(tag);
+
+ TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
+ swf_SetU16(t,0); /* id */
+ swf_SetVideoStreamMover(t, fi->stream, movex, movey,(void**)pics, quant);
+
+ itag->tag = t;
+ tagmap_addMapping(itag->tagmap, 0, self);
+
+ for(x=0;x<fi->stream->bbx*fi->stream->bby;x++) {
+ if(pics[x]) {
+ free(pics[x]);pics[x] = 0;
+ }
+ }
+
+ free(movex);
+ free(movey);
+ free(pics);
+
+ return tag;