changeset 22:f4420403219a

pcmu2efr: change linear input gen to support 2nd frame
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 May 2024 03:40:27 +0000
parents 3eb407b08b4c
children 2628a34fe75b
files pcmu2efr/gen-amrefr.c pcmu2efr/gen-efr.c pcmu2efr/gen160.c
diffstat 3 files changed, 20 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/pcmu2efr/gen-amrefr.c	Sun May 12 03:15:23 2024 +0000
+++ b/pcmu2efr/gen-amrefr.c	Sun May 12 03:40:27 2024 +0000
@@ -1,5 +1,5 @@
 /*
- * The code in this module takes linear_inputs[][] from gen160.c
+ * The code in this module takes linear_input_array[] from gen160.c
  * and generates EFR-format frames by way of libtwamr encoder.
  */
 
@@ -9,7 +9,7 @@
 #include <gsm_efr.h>
 #include <tw_amr.h>
 
-extern uint16_t linear_inputs[160][160];
+extern uint16_t linear_input_array[480];
 
 uint8_t amr_efr[160][31];
 
@@ -27,7 +27,8 @@
 	}
 	for (m = 0; m < 160; m++) {
 		amr_encoder_reset(st, 0, 0);
-		amr_encode_frame(st, MR122, (const int16_t *) linear_inputs[m],
+		amr_encode_frame(st, MR122,
+				 (const int16_t *) linear_input_array + 160 - m,
 				 &amr_frame);
 		EFR_params2frame(amr_frame.param, amr_efr[m]);
 	}
--- a/pcmu2efr/gen-efr.c	Sun May 12 03:15:23 2024 +0000
+++ b/pcmu2efr/gen-efr.c	Sun May 12 03:40:27 2024 +0000
@@ -1,5 +1,5 @@
 /*
- * The code in this module takes linear_inputs[][] from gen160.c
+ * The code in this module takes linear_input_array[] from gen160.c
  * and generates standard EFR-encoded frames.
  */
 
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <gsm_efr.h>
 
-extern uint16_t linear_inputs[160][160];
+extern uint16_t linear_input_array[480];
 
 uint8_t standard_efr[160][31];
 
@@ -25,7 +25,7 @@
 	}
 	for (m = 0; m < 160; m++) {
 		EFR_encoder_reset(st, 0);
-		EFR_encode_frame(st, (const int16_t *) linear_inputs[m],
+		EFR_encode_frame(st, (const int16_t *) linear_input_array+160-m,
 				 standard_efr[m], (int *) 0, (int *) 0);
 	}
 	free(st);
--- a/pcmu2efr/gen160.c	Sun May 12 03:15:23 2024 +0000
+++ b/pcmu2efr/gen160.c	Sun May 12 03:40:27 2024 +0000
@@ -1,6 +1,10 @@
 /*
  * The code in this module generates 160 versions of linearized seqsyncu,
  * shifted by one sample each, intended for feeding to EFR and AMR encoders.
+ *
+ * Update: the new version generates a linear array of 480 16-bit PCM samples,
+ * where the first 160 are 0x0008, followed by two copies of linearized
+ * seqsyncu.
  */
 
 #include <stdint.h>
@@ -8,34 +12,18 @@
 extern const uint8_t seqsyncu_last_frame[160];
 extern const uint16_t pcmu_decode_table[256];
 
-uint16_t linear_inputs[160][160];
-
-static void
-gen_first_seq(void)
-{
-	unsigned n;
-
-	for (n = 0; n < 160; n++)
-		linear_inputs[0][n] = pcmu_decode_table[seqsyncu_last_frame[n]];
-}
-
-static void
-gen_sequence_m(unsigned m)
-{
-	unsigned n, s;
-
-	for (n = 0; n < m; n++)
-		linear_inputs[m][n] = 0x0008;
-	for (s = 0; n < 160; n++, s++)
-		linear_inputs[m][n] = linear_inputs[0][s];
-}
+uint16_t linear_input_array[480];
 
 void
 generate_linear_inputs(void)
 {
-	unsigned m;
+	unsigned n;
+	uint16_t lin;
 
-	gen_first_seq();
-	for (m = 1; m < 160; m++)
-		gen_sequence_m(m);
+	for (n = 0; n < 160; n++) {
+		lin = pcmu_decode_table[seqsyncu_last_frame[n]];
+		linear_input_array[n] = 0x0008;
+		linear_input_array[160+n] = lin;
+		linear_input_array[320+n] = lin;
+	}
 }