shithub: libopusenc

Download patch

ref: c42727cd6490b2cc5835c26a7864462fb712bd41
parent: 29f199297544180aeda949fdb75274ec4cb0f684
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Fri May 12 14:24:17 EDT 2017

Properly support > 8 channels

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -48,8 +48,6 @@
 /* Bump this when we change the ABI. */
 #define OPE_ABI_VERSION 0
 
-#define MAX_CHANNELS 8
-
 #define LPC_PADDING 120
 #define LPC_ORDER 24
 #define LPC_INPUT 480
@@ -527,7 +525,7 @@
   return OPE_OK;
 }
 
-#define CONVERT_BUFFER 256
+#define CONVERT_BUFFER 4096
 
 /* Add/encode any number of int16 samples to the file. */
 int ope_encoder_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel) {
@@ -543,8 +541,8 @@
     spx_uint32_t in_samples, out_samples;
     out_samples = BUFFER_SAMPLES-enc->buffer_end;
     if (enc->re != NULL) {
-      float buf[CONVERT_BUFFER*MAX_CHANNELS];
-      in_samples = MIN(CONVERT_BUFFER, samples_per_channel);
+      float buf[CONVERT_BUFFER];
+      in_samples = MIN(CONVERT_BUFFER/channels, samples_per_channel);
       for (i=0;i<channels*(int)in_samples;i++) {
         buf[i] = (1.f/32768)*pcm[i];
       }