shithub: opus

Download patch

ref: ff838439391411f895a1efecf07aee9e16cfa1d4
parent: ff98202e0a40cb4209ff85e2df3edcc3efc3d59f
author: Andrew Allen <bitllama@google.com>
date: Tue Nov 7 08:26:23 EST 2017

Fix matrix export via CTL func.

Ensure matrix is properly exported from
projection encoder.

Change-Id: I5ede77e4f4d0dc82074e2230780777af542a416e
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>

--- a/src/opus_projection_decoder.c
+++ b/src/opus_projection_decoder.c
@@ -103,7 +103,7 @@
 
   /* Assign demixing matrix. */
   st->demixing_matrix_size_in_bytes = expected_matrix_size;
-  mapping_matrix_init(get_demixing_matrix(st), nb_input_streams, channels, 0,
+  mapping_matrix_init(get_demixing_matrix(st), channels, nb_input_streams, 0,
     buf, demixing_matrix_size);
 
   /* Set trivial mapping so each input channel pairs with a matrix column. */
--- a/src/opus_projection_encoder.c
+++ b/src/opus_projection_encoder.c
@@ -361,7 +361,7 @@
   break;
   case OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST:
   {
-    int i;
+    int i, j, k, l;
     int nb_input_streams;
     int nb_output_streams;
     unsigned char *external_char;
@@ -388,10 +388,14 @@
     }
 
     /* Copy demixing matrix subset to output destination. */
-    for (i = 0; i < nb_input_streams * nb_output_streams; i++)
-    {
-      external_char[2*i] = (unsigned char)internal_short[i];
-      external_char[2*i+1] = (unsigned char)(internal_short[i] >> 8);
+    l = 0;
+    for (i = 0; i < nb_input_streams; i++) {
+      for (j = 0; j < nb_output_streams; j++) {
+        k = demixing_matrix->rows * i + j;
+        external_char[2*l] = (unsigned char)internal_short[k];
+        external_char[2*l+1] = (unsigned char)(internal_short[k] >> 8);
+        l++;
+      }
     }
   }
   break;