shithub: sox

Download patch

ref: 68127910df453e134bf18fc55146a00bf12725a4
parent: d1fe487ae34312b4549074cd080454b46888f743
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sun Aug 26 10:45:07 EDT 2012

Read Ogg Vorbis files with any number of channels

Reading an Ogg Vorbis file with 3, 5, 6, etc. (any non-power of two)
channels terminated early after a few hundred samples (Debian
bug #672567).

In this situation, there always remained a few unused bytes in the read
buffer, as its size (4096 bytes) wasn't evenly divisible by the number of
channels. Still, ov_read() got called with this practically exhausted
buffer and failed.

To solve this, the buffer is created so that it always can hold an integer
number of wide samples, deviating slightly from the default size if
necessary.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672567

--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,8 @@
   o Fix pipe file-type detection regression. (robs)
   o MAUD write fixes. [3507927] (Carl Eric Codere and Ulrich Klauer)
   o Fix crash when seeking within a FLAC file. [3476843] (Eric Wong)
+  o Fix Ogg Vorbis files with certain numbers of channels being
+    truncated. (Ulrich Klauer)
 
 Audio device drivers:
 
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -131,6 +131,7 @@
 
   /* Setup buffer */
   vb->buf_len = DEF_BUF_LEN;
+  vb->buf_len -= vb->buf_len % (vi->channels*2); /* 2 bytes per sample */
   vb->buf = lsx_calloc(vb->buf_len, sizeof(char));
   vb->start = vb->end = 0;