[xiph-cvs] cvs commit: ogg-python2/src _ogg2module.c pyoggpackbuff.c

Arc arc at xiph.org
Sun Nov 30 13:03:35 PST 2003



arc         03/11/30 16:03:35

  Modified:    .        setup.py
               include/pyogg pyogg2.h
               src      _ogg2module.c pyoggpackbuff.c
  Log:
  Getting the bitpacker setup, I think it works now

Revision  Changes    Path
1.2       +1 -1      ogg-python2/setup.py

Index: setup.py
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/setup.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- setup.py	29 Nov 2003 09:21:56 -0000	1.1
+++ setup.py	30 Nov 2003 21:03:34 -0000	1.2
@@ -45,7 +45,7 @@
                                 'src/pyoggpacket.c',
                                 'src/pyoggstreamstate.c',
                                 'src/pyoggpage.c',
-###                                'src/pyoggpackbuff.c',
+                                'src/pyoggpackbuff.c',
                                 'src/pyoggsyncstate.c',
                                 'src/general.c'],
                        define_macros = [('VERSION_MAJOR', VERSION_MAJOR),

<p><p>1.4       +3 -0      ogg-python2/include/pyogg/pyogg2.h

Index: pyogg2.h
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/include/pyogg/pyogg2.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pyogg2.h	30 Nov 2003 06:32:08 -0000	1.3
+++ pyogg2.h	30 Nov 2003 21:03:34 -0000	1.4
@@ -27,4 +27,7 @@
 int arg_to_int32(PyObject *intobj, ogg_int32_t *val);
 PyObject * Py_TrueFalse(int value);
 
+/* This is temporary, until libogg2 is more complete */
+ogg_buffer_state *ogg_buffer_create(void);
+
 #endif // __PYOGG_H__

<p><p>1.3       +3 -3      ogg-python2/src/_ogg2module.c

Index: _ogg2module.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/_ogg2module.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- _ogg2module.c	29 Nov 2003 18:49:20 -0000	1.2
+++ _ogg2module.c	30 Nov 2003 21:03:34 -0000	1.3
@@ -8,14 +8,14 @@
 #include "pyoggstreamstate.h"
 #include "pyoggsyncstate.h"
 #include "pyoggpacket.h"
-/* #include "pyoggpackbuff.h" */
+#include "pyoggpackbuff.h"
 #include "pyoggpage.h"
 
 static PyMethodDef Ogg_methods[] = {
   {"OggStreamState", PyOggStreamState_New, 
    METH_VARARGS, PyOggStreamState_Doc},
-  /* {"OggPackBuff", PyOggPackBuffer_New,
-   METH_VARARGS, PyOggPackBuffer_Doc}, */
+  {"OggPackBuff", PyOggPackBuffer_New,
+   METH_VARARGS, PyOggPackBuffer_Doc},
   {"OggSyncState", PyOggSyncState_New,
    METH_VARARGS, PyOggSyncState_Doc},
   {NULL, NULL}

<p><p>1.2       +51 -43    ogg-python2/src/pyoggpackbuff.c

Index: pyoggpackbuff.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/pyoggpackbuff.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pyoggpackbuff.c	29 Nov 2003 09:21:57 -0000	1.1
+++ pyoggpackbuff.c	30 Nov 2003 21:03:34 -0000	1.2
@@ -88,55 +88,57 @@
   {NULL, NULL}  
 };
 
-static void
-PyOggPackBuffer_Dealloc(PyObject *self)
-{
-  oggpack_writeclear(PyOggPackBuffer_AsOggPackBuffer(self));
-  PyObject_DEL(self);
-}
-
-static PyObject*
-PyOggPackBuffer_Getattr(PyObject *self, char *name)
-{
-  return Py_FindMethod(PyOggPackBuffer_methods, self, name);
-}
 
 PyObject *
 PyOggPackBuffer_New(PyObject *self, PyObject *args) 
 {
+  PyOggPacketObject *packetobj;
   PyOggPackBufferObject *ret;
-  oggpack_buffer *buffer;
-  ogg_buffer_state *buffstate;
 
-  if (!PyArg_ParseTuple(args, "")) 
-    return NULL;
+  packetobj = NULL;
+
+  if ( !PyArg_ParseTuple(args, "|O!", &PyOggPacket_Type,
+                         (PyObject *) &packetobj) ) return NULL;
 
   ret = (PyOggPackBufferObject *) PyObject_NEW(PyOggPackBufferObject,
-                                               &PyOggPackBuffer_type);
-  if (ret == NULL)
-    return NULL;
+                                               &PyOggPackBuffer_Type);
+  if (ret == NULL) return NULL;
+  ret->buffer = PyMem_Malloc(oggpack_buffersize());
 
-  oggpack_writeinit(buffer, buffstate);
+  if ( packetobj ) { 
+    oggpack_readinit(ret->buffer, PyOggPacket_AsOggPacket(packetobj)->packet);
+    return (PyObject *)ret;
+  } 
+  oggpack_writeinit(ret->buffer, ogg_buffer_create());
   return (PyObject *)ret;
-  }
+}
 
-  if (PyArg_ParseTuple(args, "O!", &PyOggPacket_Type,
-                       (PyObject *) &packetobj)) {
-    oggpack_readinit(&ret->ob, packetobj->op.packet,
-                     packetobj->op.bytes);
-    return (PyObject *)ret;
-  }
 
-    return NULL;
+static void
+PyOggPackBuffer_Dealloc(PyObject *self)
+{
+  oggpack_writeclear(PyOggPackBuffer_AsOggPackBuffer(self));
+  PyMem_Free(PyOggPackBuffer_AsOggPackBuffer(self));
+  PyObject_DEL(self);
+}
+
+static PyObject*
+PyOggPackBuffer_Getattr(PyObject *self, char *name)
+{
+  return Py_FindMethod(PyOggPackBuffer_methods, self, name);
 }
 
+
 static PyObject *
 PyOggPackBuffer_Reset(PyObject *self, PyObject *args)
 {
   if (!PyArg_ParseTuple(args, ""))
     return NULL;
 
+/* I believe this needs to, now, return the current buffer for a new
+   one through one of the init functions.  
   oggpack_reset(PyOggPackBuffer_AsOggPackBuffer(self));
+*/
   Py_INCREF(Py_None);
   return Py_None;
 }
@@ -154,8 +156,10 @@
     return NULL;
   }
 
-  ret = oggpack_look(PyOggPackBuffer_AsOggPackBuffer(self), bits);
-  return PyLong_FromLong(ret);
+  if ( oggpack_look(PyOggPackBuffer_AsOggPackBuffer(self), bits, &ret) )
+    return PyLong_FromLong(ret);
+  PyErr_SetString(PyExc_ValueError, "I DONT KNOW! PyOggPackBuffer_Look");
+  return NULL;
 }
 
 static PyObject *
@@ -228,9 +232,10 @@
     return NULL;
   }
 
-  ret = oggpack_read(PyOggPackBuffer_AsOggPackBuffer(self),  bits);
-
-  return PyInt_FromLong(ret);
+  if ( oggpack_read(PyOggPackBuffer_AsOggPackBuffer(self), bits, &ret) )
+    return PyInt_FromLong(ret);
+  PyErr_SetString(PyExc_ValueError, "I DONT KNOW! PyOggPackBuffer_Read");
+  return NULL;
 }
 
 static PyObject *
@@ -273,19 +278,23 @@
 static PyObject *
 PyOggPackBuffer_Export(PyObject *self, PyObject *args)
 {
-  ogg_packet op;
+  ogg_packet *op;
+  PyOggPacketObject *packetobj;
 
   if (!PyArg_ParseTuple(args, ""))
     return NULL;
 
-  op.packet = oggpack_get_buffer(PyOggPackBuffer_AsOggPackBuffer(self));
-  op.bytes = oggpack_bytes(PyOggPackBuffer_AsOggPackBuffer(self));
-  op.b_o_s = 0;
-  op.e_o_s = 0;
-  op.granulepos = 0;
-  op.packetno = 0;
+  packetobj = PyOggPacket_Alloc();
+  op = packetobj->packet;
+
+  op->packet = oggpack_writebuffer(PyOggPackBuffer_AsOggPackBuffer(self));
+  op->bytes = oggpack_bytes(PyOggPackBuffer_AsOggPackBuffer(self));
+  op->b_o_s = 0;
+  op->e_o_s = 0;
+  op->granulepos = 0;
+  op->packetno = 0;
 
-  return py_ogg_packet_from_packet(&op);
+  return (PyObject *) packetobj;
 }
   
 
@@ -295,8 +304,7 @@
   oggpack_buffer *ob = PyOggPackBuffer_AsOggPackBuffer(self);
   char buf[256];
 
-  sprintf(buf, "<OggPackBuff, endbyte = %ld, endbit = %d at %p>", ob->endbyte,
-					ob->endbit, self);
+  sprintf(buf, "<OggPackBuff at %p>", self);
   return PyString_FromString(buf);
 }
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list