[xiph-commits] r8374 - experimental/dholth/oggpy
dholth at motherfish-iii.xiph.org
dholth at motherfish-iii.xiph.org
Sun Dec 12 10:56:58 PST 2004
Author: dholth
Date: 2004-12-12 10:56:57 -0800 (Sun, 12 Dec 2004)
New Revision: 8374
Modified:
experimental/dholth/oggpy/theora_wrappers.cc
experimental/dholth/oggpy/theora_wrappers.h
experimental/dholth/oggpy/theoracc.h
experimental/dholth/oggpy/theorapy.cpp
Log:
updates. probably broke name of tostrings.
Modified: experimental/dholth/oggpy/theora_wrappers.cc
===================================================================
--- experimental/dholth/oggpy/theora_wrappers.cc 2004-12-11 19:48:50 UTC (rev 8373)
+++ experimental/dholth/oggpy/theora_wrappers.cc 2004-12-12 18:56:57 UTC (rev 8374)
@@ -4,15 +4,15 @@
* 10 Mar. 2004
*/
-#include "theora_wrappers.h"
#include <theora/theora.h>
#include <string.h>
#include <boost/version.hpp>
+#include "theora_wrappers.h"
using namespace ogg;
using namespace boost::python;
-
+/* unused
boost::python::list get_comments(ogg::theora::comment *vco)
{
boost::python::list comments;
@@ -28,3 +28,59 @@
return comments;
}
+*/
+
+
+PyObject* wtostrings (ogg::theora::yuv_image *yuv)
+{
+ int crop_offset=0;
+ int i;
+
+ PyObject *ystring;
+ PyObject *ustring;
+ PyObject *vstring;
+
+ ystring = PyString_FromStringAndSize(NULL, yuv->y_width*yuv->y_height);
+ ustring = PyString_FromStringAndSize(NULL, yuv->uv_width*yuv->uv_height);
+ vstring = PyString_FromStringAndSize(NULL, yuv->uv_width*yuv->uv_height);
+
+ char *y;
+ char *u;
+ char *v;
+
+ y = PyString_AS_STRING(ystring);
+ u = PyString_AS_STRING(ustring);
+ v = PyString_AS_STRING(vstring);
+
+ //crop_offset=theora_info::offset_x+yuv->y_stride*theora_info::offset_y;
+ for(i=0; i < yuv->y_height; i++)
+ {
+ std::memcpy(y+i*yuv->y_width,
+ yuv->y+crop_offset+yuv->y_stride*i,
+ yuv->y_width);
+ }
+
+ //crop_offset=theora_info::offset_x/2+yuv->y_stride*theora_info::offset_y/2;
+ for(i=0; i < yuv->uv_height; i++)
+ {
+ std::memcpy(u+i*yuv->uv_width,
+ yuv->u+crop_offset+yuv->uv_stride*i,
+ yuv->uv_width);
+
+ std::memcpy(v+i*yuv->uv_width,
+ yuv->v+crop_offset+yuv->uv_stride*i,
+ yuv->uv_width);
+ }
+
+ PyObject *tuple;
+ tuple = PyTuple_New(3);
+
+ if (tuple != NULL) {
+ PyTuple_SET_ITEM(tuple, 0, ystring);
+ PyTuple_SET_ITEM(tuple, 1, ustring);
+ PyTuple_SET_ITEM(tuple, 2, vstring);
+ }
+
+ return tuple;
+}
+
Modified: experimental/dholth/oggpy/theora_wrappers.h
===================================================================
--- experimental/dholth/oggpy/theora_wrappers.h 2004-12-11 19:48:50 UTC (rev 8373)
+++ experimental/dholth/oggpy/theora_wrappers.h 2004-12-12 18:56:57 UTC (rev 8374)
@@ -1,10 +1,13 @@
-/* Functions needed for Python to interface with theoracc
- *
+/* Functions needed specifically for
+ * Python's interface with theora/theoracc
+ * (wrappers that are useful from C++
+ * go in theoracc.cc)
+ *
* Daniel Holth <dholth at fastmail.fm>, 2004
*/
-#ifndef VORBISPY_WRAPPERS_H
-#define VORBISPY_WRAPPERS_H
+#ifndef THEORAPY_WRAPPERS_H
+#define THEORAPY_WRAPPERS_H
#include "oggcc.h"
#include "theoracc.h"
@@ -13,6 +16,8 @@
/// Return a list of all the comments in a theora comment object.
///
/// Less important now that we have query_index.
-boost::python::str get_comment(ogg::theora::comment *tco);
+// boost::python::str get_comment(ogg::theora::comment *tco);
+// "Wrapper" (w)tostrings until tested.
+PyObject* wtostrings(ogg::theora::yuv_image *yuv);
#endif
Modified: experimental/dholth/oggpy/theoracc.h
===================================================================
--- experimental/dholth/oggpy/theoracc.h 2004-12-11 19:48:50 UTC (rev 8373)
+++ experimental/dholth/oggpy/theoracc.h 2004-12-12 18:56:57 UTC (rev 8374)
@@ -146,75 +146,6 @@
{
public:
yuv_buffer *get_data() { return (yuv_buffer*)this; }
-
- PyObject* tostring (info &theora_info) {
- int crop_offset=0;
- int i,j;
- char y[this->y_width*this->y_height];
- char u[this->y_width*this->y_height];
- char v[this->y_width*this->y_height];
- char data[this->y_width*this->y_height*3];
-
- crop_offset=theora_info.offset_x+this->y_stride*theora_info.offset_y;
- for(i=0;i<this->y_height;i++){
- std::memcpy(y+i*this->y_width,
- this->y+crop_offset+this->y_stride*i,this->y_width);
- }
- if(this->uv_width < this->y_width)
- crop_offset=theora_info.offset_x/2+this->y_stride*theora_info.offset_y/2;
- for(i=0; i < this->uv_height; i++) {
- std::memcpy(u+i * this->uv_width,
- this->u+crop_offset + this->uv_stride * i, this->uv_width);
- std::memcpy(v+i * this->uv_width,
- this->v + crop_offset + this->uv_stride * i, this->uv_width);
- }
-
- for(i=0;i < this->uv_height; i++) {
- for(j=0; j < this->uv_width; j++) {
- int uv_count = (i/2) * (j/2);
- data[i*j*3] = y[i * j];
- data[i*j*3+1] = u[uv_count];
- data[i*j*3+2] = v[uv_count];
- }
- }
- return PyString_FromStringAndSize(data, this->y_width * this->y_height * 3);
- }
-
- PyObject* tostrings (info &theora_info) {
- int i;
- int crop_offset = 0;
- char y[this->y_width * this->y_height];
- char u[this->uv_width * this->uv_height];
- char v[this->uv_width * this->uv_height];
- PyObject *tuple;
-
- crop_offset=theora_info.offset_x + this->y_stride * theora_info.offset_y;
- for(i = 0; i < this->y_height; i++) {
- std::memcpy(y + i * this->y_width,
- this->y + crop_offset + this->y_stride * i, this->y_width);
- }
- if(this->uv_width < this->y_width)
- crop_offset=theora_info.offset_x/2 + this->y_stride * theora_info.offset_y/2;
- for(i=0; i < this->uv_height; i++) {
- std::memcpy(u + i * this->uv_width,
- this->u + crop_offset + this->uv_stride * i, this->uv_width);
- std::memcpy(v + i * this->uv_width,
- this->v + crop_offset + this->uv_stride * i, this->uv_width);
- }
-
-
- tuple = PyTuple_New(3);
- if (tuple == NULL)
- return NULL;
-
- PyTuple_SET_ITEM(tuple, 0,
- PyString_FromStringAndSize(y, this->y_width * this->y_height));
- PyTuple_SET_ITEM(tuple, 1,
- PyString_FromStringAndSize(u, this->uv_width * this->uv_height));
- PyTuple_SET_ITEM(tuple, 2,
- PyString_FromStringAndSize(v, this->uv_width * this->uv_height));
- return tuple;
- }
};
Modified: experimental/dholth/oggpy/theorapy.cpp
===================================================================
--- experimental/dholth/oggpy/theorapy.cpp 2004-12-11 19:48:50 UTC (rev 8373)
+++ experimental/dholth/oggpy/theorapy.cpp 2004-12-12 18:56:57 UTC (rev 8374)
@@ -6,6 +6,7 @@
// Includes ====================================================================
#include <theora/theora.h>
#include <theoracc.h>
+#include "theora_wrappers.h"
// Using =======================================================================
using namespace boost::python;
@@ -81,8 +82,8 @@
.def_readwrite("y", &yuv_buffer::y)
.def_readwrite("u", &yuv_buffer::u)
.def_readwrite("v", &yuv_buffer::v)
- .def("tostring", &ogg::theora::yuv_image::tostring)
- .def("tostrings", &ogg::theora::yuv_image::tostrings)
+ // .def("tostrings", &ogg::theora::yuv_image::tostrings)
+ .def("wtostrings", &wtostrings)
;
def("version_number", &ogg::theora::version_number);
More information about the commits
mailing list