[xiph-commits] r8255 - in experimental/dholth/oggpy: . tests
dholth at motherfish-iii.xiph.org
dholth at motherfish-iii.xiph.org
Mon Nov 22 18:06:41 PST 2004
Author: dholth
Date: 2004-11-22 18:06:41 -0800 (Mon, 22 Nov 2004)
New Revision: 8255
Added:
experimental/dholth/oggpy/theora_wrappers.cc
Modified:
experimental/dholth/oggpy/tests/decode.py
Log:
patch-22
Modified: experimental/dholth/oggpy/tests/decode.py
===================================================================
--- experimental/dholth/oggpy/tests/decode.py 2004-11-23 02:01:03 UTC (rev 8254)
+++ experimental/dholth/oggpy/tests/decode.py 2004-11-23 02:06:41 UTC (rev 8255)
@@ -25,11 +25,6 @@
vb = vorbispy.block()
vc = vorbispy.comment()
- audio = oss.open_audio()
- audio.stereo(1)
- audio.format(oss.AFMT_S16_LE)
- audio.speed(44100)
-
while 1:
buffer = ogg.read(BUFSIZE)
oy.write(buffer)
@@ -78,6 +73,15 @@
print >> sys.stderr, vorbispy.get_comments(vc)
+ channels = vi.get_channels()
+ rate = vi.get_rate()
+
+ audio = oss.open_audio()
+ if channels >= 2:
+ audio.stereo(1)
+ audio.format(oss.AFMT_S16_LE)
+ audio.speed(rate)
+
vd.synthesis_init(vi)
vd.block_init(vb)
@@ -103,12 +107,12 @@
while samples != None:
samples *= 32767;
wav = samples.astype('Int16')
-
- interleaved = numarray.zeros(samples.shape[1]*2, numarray.Int16)
- interleaved[0::2] = wav[0]
- interleaved[1::2] = wav[1]
+ interleaved = numarray.zeros(samples.shape[1]*channels, numarray.Int16)
+ for i in range(channels):
+ interleaved[i::channels] = wav[i]
+
# interleaved.tofile(outfile)
audio.write(interleaved.tostring())
Added: experimental/dholth/oggpy/theora_wrappers.cc
===================================================================
--- experimental/dholth/oggpy/theora_wrappers.cc 2004-11-23 02:01:03 UTC (rev 8254)
+++ experimental/dholth/oggpy/theora_wrappers.cc 2004-11-23 02:06:41 UTC (rev 8255)
@@ -0,0 +1,30 @@
+/* Extras Python needs to talk to theoracc.
+ *
+ * Daniel Holth <dholth at fastmail.fm>
+ * 10 Mar. 2004
+ */
+
+#include "theora_wrappers.h"
+#include <theora/theora.h>
+#include <string.h>
+#include <boost/version.hpp>
+
+using namespace ogg;
+using namespace boost::python;
+
+
+boost::python::list get_comments(ogg::theora::comment *vco)
+{
+ boost::python::list comments;
+ str com;
+ theora_comment *vc;
+
+ vc = vco->get_data();
+
+ for(int i=0; i < vc->comments; i++)
+ {
+ comments.append(str(vc->user_comments[i], vc->comment_lengths[i]));
+ }
+
+ return comments;
+}
More information about the commits
mailing list