Update of /cvsroot/freevo/kaa/evas/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15215
Modified Files:
evas.c image.c
Log Message:
pixels_import can receive a tuple of planes for YV12, as well as a single
buffer. If it's a single value then it assumes it points to memory
holding the planes contiguously.
Index: image.c
===================================================================
RCS file: /cvsroot/freevo/kaa/evas/src/image.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** image.c 10 Jul 2005 20:44:35 -0000 1.1
--- image.c 31 Jul 2005 19:55:09 -0000 1.2
***************
*** 219,222 ****
--- 219,238 ----
}
+ static void *
+ _get_ptr_from_pyobject(PyObject *o)
+ {
+ void *data;
+ int len;
+
+ if (PyNumber_Check(o)) {
+ data = (void *) PyLong_AsLong(o);
+ } else {
+ if (PyObject_AsReadBuffer(o, (const void **) &data, &len) == -1)
+ return NULL;
+ }
+ return data;
+ }
+
+
PyObject *
Evas_Object_PyObject_image_pixels_import(Evas_Object_PyObject * self,
***************
*** 224,251 ****
{
Evas_Pixel_Import_Source ps;
! PyObject *buffer;
! void *data, *p;
! int i, stride, len;
!
! if (!PyArg_ParseTuple(args, "Oiii", &buffer, &ps.w, &ps.h, &ps.format))
return NULL;
! if (PyNumber_Check(buffer)) {
! data = (void *) PyLong_AsLong(buffer);
} else {
! if (PyObject_AsReadBuffer(buffer, (const void **) &data, &len) == -1)
return NULL;
}
if (ps.format == EVAS_PIXEL_FORMAT_YUV420P_601) {
ps.rows = malloc(ps.h * 2 * sizeof(void *));
! for (i = 0, stride = ps.w, p = data; i < ps.h * 2; i++, p += stride) {
ps.rows[i] = p;
if (i == ps.h)
stride >>= 1;
}
! } else
! return PyErr_SetString(PyExc_ValueError, "Invalid pixel format"),
! (PyObject *) NULL;
evas_object_image_pixels_import(self->object, &ps);
free(ps.rows);
--- 240,288 ----
{
Evas_Pixel_Import_Source ps;
! PyObject *data;
! void *p, *planes[3] = {0,0,0};
! int i, stride, len, plane;
! if (!PyArg_ParseTuple(args, "Oiii", &data, &ps.w, &ps.h, &ps.format))
return NULL;
! /* Data can be a single buffer/int pointing to memory that holds each
! plane contiguously, or a tuple of buffer/ints pointing to each
! individual plane. */
! if (!PyTuple_Check(data)) {
! if ((planes[0] = _get_ptr_from_pyobject(data)) == 0)
! return NULL;
! planes[1] = planes[0] + (ps.w * ps.h);
! planes[2] = planes[1] + ((ps.w * ps.h) >> 2);
! printf("Planes 0=%x 1=%x 2=%x\n", planes[0], planes[1], planes[2]);
} else {
! if (PySequence_Length(data) != 3) {
! PyErr_Format(PyExc_ValueError, "Invalid size for planes tuple");
return NULL;
+ }
+ for (i = 0; i < 3; i++) {
+ PyObject *o = PyTuple_GetItem(data, i);
+ if ((planes[i] = _get_ptr_from_pyobject(o)) == 0)
+ return NULL;
+ }
}
+
if (ps.format == EVAS_PIXEL_FORMAT_YUV420P_601) {
ps.rows = malloc(ps.h * 2 * sizeof(void *));
! stride = ps.w;
! for (i = 0, plane = 0, p = planes[0]; i < ps.h * 2; i++) {
ps.rows[i] = p;
if (i == ps.h)
stride >>= 1;
+ if (i == ps.h || i == ps.h+(ps.h/2))
+ p = planes[++plane];
+ else
+ p += stride;
}
! } else {
! PyErr_SetString(PyExc_ValueError, "Invalid pixel format");
! return NULL;
! }
!
evas_object_image_pixels_import(self->object, &ps);
free(ps.rows);
Index: evas.c
===================================================================
RCS file: /cvsroot/freevo/kaa/evas/src/evas.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** evas.c 14 Jul 2005 18:58:43 -0000 1.3
--- evas.c 31 Jul 2005 19:55:09 -0000 1.4
***************
*** 54,58 ****
return ret;
}
-
return 0;
}
--- 54,57 ----
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog