[xiph-commits] r8251 - experimental/dholth/oggpy

dholth at motherfish-iii.xiph.org dholth at motherfish-iii.xiph.org
Mon Nov 22 17:28:33 PST 2004


Author: dholth
Date: 2004-11-22 17:28:32 -0800 (Mon, 22 Nov 2004)
New Revision: 8251

Added:
   experimental/dholth/oggpy/Makefile
   experimental/dholth/oggpy/makeclass.py
   experimental/dholth/oggpy/oggcc.cc
   experimental/dholth/oggpy/oggcc.h
   experimental/dholth/oggpy/oggpy.pyste
   experimental/dholth/oggpy/setup.py
   experimental/dholth/oggpy/vorbies.py
Log:
tla base-0


Added: experimental/dholth/oggpy/Makefile
===================================================================
--- experimental/dholth/oggpy/Makefile	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/Makefile	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,6 @@
+all:
+	touch oggcc.cc
+	python ./setup.py build
+
+doc:
+	doxygen

Added: experimental/dholth/oggpy/makeclass.py
===================================================================
--- experimental/dholth/oggpy/makeclass.py	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/makeclass.py	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+import sre
+import string
+from pprint import pprint
+import vorbies
+
+declarations = """\
+extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
+extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
+
+extern int      ogg_sync_init(ogg_sync_state *oy);
+extern int      ogg_sync_clear(ogg_sync_state *oy);
+extern int      ogg_sync_reset(ogg_sync_state *oy);
+extern int	ogg_sync_destroy(ogg_sync_state *oy);
+
+extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
+extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
+extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
+extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
+extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
+extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
+
+extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
+extern int      ogg_stream_clear(ogg_stream_state *os);
+extern int      ogg_stream_reset(ogg_stream_state *os);
+extern int      ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
+extern int      ogg_stream_destroy(ogg_stream_state *os);
+extern int      ogg_stream_eos(ogg_stream_state *os);
+
+extern void     ogg_page_checksum_set(ogg_page *og);
+
+extern int      ogg_page_version(ogg_page *og);
+extern int      ogg_page_continued(ogg_page *og);
+extern int      ogg_page_bos(ogg_page *og);
+extern int      ogg_page_eos(ogg_page *og);
+extern ogg_int64_t  ogg_page_granulepos(ogg_page *og);
+extern int      ogg_page_serialno(ogg_page *og);
+extern long     ogg_page_pageno(ogg_page *og);
+extern int      ogg_page_packets(ogg_page *og);
+
+extern void     ogg_packet_clear(ogg_packet *op);
+"""
+
+declarations = vorbies.vorbis
+
+if __name__ == "__main__":
+    pre = sre.compile("\s+|(\()|(,)|;|(\))")
+
+    parse0 = []
+
+    for line in [x for x in declarations.splitlines() if x.strip()]:
+        items =  pre.split(line)
+        items = [i for i in items if i]
+        items = [i.strip() for i in items if i.strip() and i != "extern"]
+        print items
+        parse0.append(items)
+
+    pprint(parse0)
+
+    parse1 = [(item[item.index('(')+1], item) for item in parse0]
+    parse1.sort()
+    pprint(parse1)
+    parse2 = [item[1] for item in parse1]
+    parse2 = [(item[0:1] + item[1:] + [" { return "] + item[1:] + [" };"]) for item in parse2]
+    parse3 = [string.join(item, ' ') for item in parse2]
+
+    for line in parse3:
+        print line


Property changes on: experimental/dholth/oggpy/makeclass.py
___________________________________________________________________
Name: svn:executable
   + *

Added: experimental/dholth/oggpy/oggcc.cc
===================================================================
--- experimental/dholth/oggpy/oggcc.cc	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/oggcc.cc	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,8 @@
+/* Friendly C++ wrapper for libogg
+ *
+ * Daniel Holth
+ * 19 Jan. 2004
+ */
+
+#include "oggcc.h"
+

Added: experimental/dholth/oggpy/oggcc.h
===================================================================
--- experimental/dholth/oggpy/oggcc.h	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/oggcc.h	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,202 @@
+/* oggcc.h
+ *
+ * A straightforward C++ wrapper for libogg.
+ *
+ * Daniel Holth <dholth at fastmail.fm>
+ * 19 Jan. 2004
+ */
+
+#ifndef OGGCC_H
+#define OGGCC_H
+
+#include <ogg/ogg.h>
+#include <vorbis/codec.h>
+
+namespace ogg {
+
+  class packet {
+    public:
+      ogg_packet data;
+      
+      void clear ()               { ogg_packet_clear(&this->data); }
+  };
+
+  class page {
+    public:
+      ogg_page data;
+      
+      int bos ( )                 { return ogg_page_bos(&this->data); }
+      int continued ( )           { return ogg_page_continued(&this->data); }
+      int eos ( )                 { return ogg_page_eos(&this->data); }
+      int packets ( )             { return ogg_page_packets(&this->data); }
+      int serialno ( )            { return ogg_page_serialno(&this->data); }
+      int version ( )             { return ogg_page_version(&this->data); }
+      long pageno ( )             { return ogg_page_pageno(&this->data); }
+      ogg_int64_t granulepos ( )  { return ogg_page_granulepos(&this->data); }
+      void checksum_set ( )       { return ogg_page_checksum_set(&this->data); }
+  };
+
+  class stream {
+    public:
+      ogg_stream_state data;
+      
+      int clear ( )                       { return ogg_stream_clear(&this->data); }
+      int destroy ( )	                    { return ogg_stream_destroy(&this->data); }
+      int eos ( )	                        { return ogg_stream_eos(&this->data); }
+      int flush ( ogg_page *og )  	      { return ogg_stream_flush(&this->data, og); }
+      int init ( int serialno )	          { return ogg_stream_init(&this->data, serialno); }
+      int packetin ( ogg_packet *op )	    { return ogg_stream_packetin(&this->data, op); }
+      int packetout ( ogg_packet *op )	  { return ogg_stream_packetout(&this->data, op); }
+      int packetpeek ( ogg_packet *op )	  { return ogg_stream_packetpeek(&this->data, op); }
+      int pagein  ( ogg_page *og )	      { return ogg_stream_pagein(&this->data, og); }
+      int pageout ( ogg_page *og )	      { return ogg_stream_pageout(&this->data, og); }
+      int reset   ( )	                    { return ogg_stream_reset(&this->data); }
+      int reset_serialno ( int serialno )	{ return ogg_stream_reset_serialno(&this->data, serialno); }
+  };
+
+  class sync {
+    public:
+      ogg_sync_state data;
+      
+      char *buffer    ( long size )	      { return ogg_sync_buffer (&this->data, size); }
+      int   clear     ( )	                { return ogg_sync_clear (&this->data); }
+      int   destroy   ( )	                { return ogg_sync_destroy (&this->data); }
+      int   init      ( )             	  { return ogg_sync_init (&this->data); }
+      int   pageout   ( ogg_page *og )	  { return ogg_sync_pageout (&this->data, og); }
+      int   reset     ( )	                { return ogg_sync_reset (&this->data); }
+      int   wrote     ( long bytes )	    { return ogg_sync_wrote (&this->data, bytes); }
+      long  pageseek  ( ogg_page *og )	  { return ogg_sync_pageseek (&this->data, og); }
+  };
+
+  
+  namespace vorbis {
+
+    class block {
+      public:
+        vorbis_block data;
+
+        int analysis ( vorbis_block *vb , ogg_packet *op )  {
+          return vorbis_analysis ( &this->data, op );  }
+        
+        int bitrate_addblock ( vorbis_block *vb )  {
+          return vorbis_bitrate_addblock ( &this->data ); }
+        
+        int block_clear ( vorbis_block *vb )  {
+          return vorbis_block_clear ( &this->data ); }
+        
+        int synthesis ( vorbis_block *vb, ogg_packet *op )  {
+          return vorbis_synthesis ( &this->data, op ); }
+        
+        int synthesis_trackonly ( vorbis_block *vb, ogg_packet *op )  {
+          return vorbis_synthesis_trackonly ( &this->data, op ); }
+    };
+
+    
+    class comment {
+      public:
+        vorbis_comment data;
+
+        char *comment_query ( vorbis_comment *vc, char *tag , int count )  {
+          return vorbis_comment_query ( &this->data, tag, count ); }
+
+        int comment_query_count ( vorbis_comment *vc, char *tag )  {
+          return vorbis_comment_query_count ( &this->data, tag ); }
+
+        int commentheader_out ( vorbis_comment *vc, ogg_packet *op )  {
+          return vorbis_commentheader_out ( &this->data, op ); }
+
+        void comment_add ( vorbis_comment *vc, char *comment )  {
+          vorbis_comment_add ( &this->data, comment ); }
+
+        void comment_add_tag ( vorbis_comment *vc, char *tag , char *contents )  {
+          vorbis_comment_add_tag ( &this->data, tag, contents ); }
+
+        void comment_clear ( vorbis_comment *vc )  {
+          vorbis_comment_clear ( &this->data ); }
+
+        void comment_init ( vorbis_comment *vc )  {
+          vorbis_comment_init ( &this->data ); }
+    };
+
+    
+    class dsp {
+      public:
+        vorbis_dsp_state data;
+
+        double granule_time ( vorbis_dsp_state *v, ogg_int64_t granulepos )  {
+          return vorbis_granule_time ( &this->data, granulepos ); }
+
+        float **analysis_buffer ( vorbis_dsp_state *v, int vals )  {
+          return vorbis_analysis_buffer ( &this->data, vals ); }
+
+        int analysis_blockout ( vorbis_dsp_state *v, vorbis_block *vb )  {
+          return vorbis_analysis_blockout ( &this->data, vb ); }
+
+        int analysis_headerout ( vorbis_dsp_state *v, vorbis_comment *vc , ogg_packet *op , ogg_packet *op_comm , ogg_packet *op_code )  {
+          return vorbis_analysis_headerout ( &this->data, vc , op , op_comm , op_code ); }
+
+        int analysis_init ( vorbis_dsp_state *v, vorbis_info *vi )  {
+          return vorbis_analysis_init ( &this->data, vi ); }
+
+        int analysis_wrote ( vorbis_dsp_state *v, int vals )  {
+          return vorbis_analysis_wrote ( &this->data, vals ); }
+
+        int bitrate_flushpacket ( vorbis_dsp_state *vd, ogg_packet *op )  {
+          return vorbis_bitrate_flushpacket ( &this->data, op ); }
+
+        int block_init ( vorbis_dsp_state *v, vorbis_block *vb )  {
+          return vorbis_block_init ( &this->data, vb ); }
+
+        int synthesis_blockin ( vorbis_dsp_state *v, vorbis_block *vb )  {
+          return vorbis_synthesis_blockin ( &this->data, vb ); }
+
+        int synthesis_init ( vorbis_dsp_state *v, vorbis_info *vi )  {
+          return vorbis_synthesis_init ( &this->data, vi ); }
+
+        int synthesis_lapout ( vorbis_dsp_state *v, float ***pcm )  {
+          return vorbis_synthesis_lapout ( &this->data, pcm ); }
+
+        int synthesis_pcmout ( vorbis_dsp_state *v, float ***pcm )  {
+          return vorbis_synthesis_pcmout ( &this->data, pcm ); }
+
+        int synthesis_read ( vorbis_dsp_state *v, int samples )  {
+          return vorbis_synthesis_read ( &this->data, samples ); }
+
+        int synthesis_restart ( vorbis_dsp_state *v )  {
+          return vorbis_synthesis_restart ( &this->data ); }
+
+        void dsp_clear ( vorbis_dsp_state *v )  {
+          vorbis_dsp_clear ( &this->data ); }
+    };
+
+
+    class info {
+      public:
+        vorbis_info data;
+
+        int info_blocksize ( int zo )  {
+          return vorbis_info_blocksize ( &this->data, zo );  }
+
+        int synthesis_halfrate ( int flag )  {
+          return vorbis_synthesis_halfrate ( &this->data, flag );  }
+
+        int synthesis_halfrate_p ( )  {
+          return vorbis_synthesis_halfrate_p ( &this->data );  }
+
+        int synthesis_headerin ( vorbis_comment *vc, ogg_packet *op )  {
+          return vorbis_synthesis_headerin ( &this->data, vc, op );  }
+
+        long packet_blocksize ( ogg_packet *op )  {
+          return vorbis_packet_blocksize ( &this->data, op );  }
+
+        void info_clear ( )  {
+          return vorbis_info_clear ( &this->data );  }
+
+        void info_init ( )  {
+          return vorbis_info_init ( &this->data );  }
+
+    };
+  };
+};
+
+#endif

Added: experimental/dholth/oggpy/oggpy.pyste
===================================================================
--- experimental/dholth/oggpy/oggpy.pyste	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/oggpy.pyste	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,7 @@
+oggpy = AllFromHeader("oggcc.h")
+
+exclude(oggpy.sync_state.data)
+exclude(oggpy.sync_state.buffer)
+exclude(oggpy.packet.data)
+exclude(oggpy.page.data)
+exclude(oggpy.stream.data)

Added: experimental/dholth/oggpy/setup.py
===================================================================
--- experimental/dholth/oggpy/setup.py	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/setup.py	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# oggpy 
+
+from distutils.core import setup
+from distutils.extension import Extension
+
+# edit to point to your boost::python installation
+boost = "/home/dholth/opt/include/boost-1_31"
+
+description = """oggpy provides alternative python bindings for ogg."""
+
+classifiers="""\
+Development Status :: 3 - Alpha
+License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+Operating System :: POSIX :: Linux
+Programming Language :: C++
+Programming Language :: Python
+Topic :: Software Development :: Libraries :: Python Modules
+Topic :: Multimedia :: Sound/Audio
+"""
+
+setup(name="oggpy",
+      version="0.0",
+      description="Boost.Python interface for ogg",
+      long_description=description,
+      author="Daniel Holth",
+      author_email="dholth at fastmail.fm",
+      url="http://dingoskidneys.com/shoutpy/",
+      platforms="linux",
+      license="GNU LGPL",
+      classifiers=filter(None, classifiers.splitlines()),
+      ext_modules=[Extension("oggpy", ["oggcc.cc", "oggpy.cpp"],
+                             libraries=["ogg", "vorbis", "boost_python-gcc"],
+                             include_dirs=[boost])])


Property changes on: experimental/dholth/oggpy/setup.py
___________________________________________________________________
Name: svn:executable
   + *

Added: experimental/dholth/oggpy/vorbies.py
===================================================================
--- experimental/dholth/oggpy/vorbies.py	2004-11-23 01:01:41 UTC (rev 8250)
+++ experimental/dholth/oggpy/vorbies.py	2004-11-23 01:28:32 UTC (rev 8251)
@@ -0,0 +1,43 @@
+vorbis = """\
+extern void     vorbis_info_init(vorbis_info *vi);
+extern void     vorbis_info_clear(vorbis_info *vi);
+extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
+extern void     vorbis_comment_init(vorbis_comment *vc);
+extern void     vorbis_comment_add(vorbis_comment *vc, char *comment); 
+extern void     vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents);
+extern char    *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
+extern int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
+extern void     vorbis_comment_clear(vorbis_comment *vc);
+
+extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
+extern int      vorbis_block_clear(vorbis_block *vb);
+extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
+extern double   vorbis_granule_time(vorbis_dsp_state *v, ogg_int64_t granulepos);
+
+
+extern int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int      vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
+extern int      vorbis_analysis_headerout(vorbis_dsp_state *v, vorbis_comment *vc, ogg_packet *op, ogg_packet *op_comm, ogg_packet *op_code);
+extern float  **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
+extern int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
+extern int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
+extern int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
+
+extern int      vorbis_bitrate_addblock(vorbis_block *vb);
+extern int      vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op);
+
+extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, ogg_packet *op);
+
+extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
+extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
+extern int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
+extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
+extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
+extern int      vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
+extern int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
+extern long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
+
+extern int      vorbis_synthesis_halfrate(vorbis_info *v,int flag);
+extern int      vorbis_synthesis_halfrate_p(vorbis_info *v);
+"""



More information about the commits mailing list