changeset 47:7119884f6afe

trau-parse: rudimentary AMR decoding (C-bits)
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 24 Sep 2024 18:57:56 +0000
parents f977027774cb
children 3d8cb2631812
files trau-decode/parse-main.c
diffstat 1 files changed, 45 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/trau-decode/parse-main.c	Tue Sep 24 17:02:59 2024 +0000
+++ b/trau-decode/parse-main.c	Tue Sep 24 18:57:56 2024 +0000
@@ -89,6 +89,24 @@
 }
 
 static void
+print_fr_efr_frame(c1_5)
+	unsigned c1_5;
+{
+	switch (c1_5) {
+	case 0x02:
+	case 0x1C:
+		collect_d_bits();
+		print_fr_frame(d_bits);
+		break;
+	case 0x1A:
+		collect_d_bits();
+		check_efr_crc(d_bits);
+		print_efr_frame(d_bits);
+		break;
+	}
+}
+
+static void
 print_data_subframe(nf, bits)
 	uint8_t *bits;
 {
@@ -173,6 +191,9 @@
 	case 0x1F:
 		fputs(" (E-TRAU)", stdout);
 		break;
+	case 0x06:
+		fputs(" (AMR)", stdout);
+		break;
 	}
 	putchar('\n');
 	if (c1_5 == 0x14)
@@ -186,11 +207,18 @@
 	case 0x02:
 	case 0x1C:
 	case 0x1A:
+	case 0x10:
+	case 0x0E:
 		c6_11 = bits_to_num(frame_bits + 22, 6);
 		printf("  C6-C11: %u\n", c6_11);
 		printf("  C12=%u C13=%u C14=%u C15=%u\n", frame_bits[28],
 			frame_bits[29], frame_bits[30], frame_bits[31]);
-		collect_d_bits();
+		print_fr_efr_frame(c1_5);
+		printf("  C16=%u C17=%u C18=%u C19=%u C20=%u C21=%u\n",
+			frame_bits[310], frame_bits[311], frame_bits[312],
+			frame_bits[313], frame_bits[314], frame_bits[315]);
+		printf("  T1=%u T2=%u T3=%u T4=%u\n", frame_bits[316],
+			frame_bits[317], frame_bits[318], frame_bits[319]);
 		break;
 	case 0x08:
 	case 0x09:
@@ -202,35 +230,34 @@
 			frame_bits[26], frame_bits[27], frame_bits[28],
 			frame_bits[29], frame_bits[30], frame_bits[31]);
 		print_data_frame();
-		return;
+		break;
 	case 0x1F:
 		printf("  C6-C13: %u%u%u%u%u%u%u%u\n", frame_bits[22],
 			frame_bits[23], frame_bits[24], frame_bits[25],
 			frame_bits[26], frame_bits[27], frame_bits[28],
 			frame_bits[29]);
 		printf("  M1=%u M2=%u\n", frame_bits[30], frame_bits[31]);
-		return;
+		break;
+	case 0x06:
+		c6_11 = bits_to_num(frame_bits + 22, 6);
+		printf("  C6-C11: %u\n", c6_11);
+		printf("  RIF=%u C13=%u Config_Prot=%u%u%u Msg_No=%u%u\n",
+			frame_bits[28], frame_bits[29], frame_bits[30],
+			frame_bits[31], frame_bits[33], frame_bits[34],
+			frame_bits[35]);
+		printf("  DTXd=%u TFOE=%u FClass=%u%u CMI/CMR=%u%u%u\n",
+			frame_bits[36], frame_bits[37], frame_bits[38],
+			frame_bits[39], frame_bits[40], frame_bits[41],
+			frame_bits[42]);
+		printf("  T1=%u T2=%u T3=%u T4=%u\n", frame_bits[316],
+			frame_bits[317], frame_bits[318], frame_bits[319]);
+		break;
 	default:
 		printf("  C6-C15: %u%u%u%u%u%u%u%u%u%u\n", frame_bits[22],
 			frame_bits[23], frame_bits[24], frame_bits[25],
 			frame_bits[26], frame_bits[27], frame_bits[28],
 			frame_bits[29], frame_bits[30], frame_bits[31]);
 	}
-	switch (c1_5) {
-	case 0x02:
-	case 0x1C:
-		print_fr_frame(d_bits);
-		break;
-	case 0x1A:
-		check_efr_crc(d_bits);
-		print_efr_frame(d_bits);
-		break;
-	}
-	printf("  C16=%u C17=%u C18=%u C19=%u C20=%u C21=%u\n",
-		frame_bits[310], frame_bits[311], frame_bits[312],
-		frame_bits[313], frame_bits[314], frame_bits[315]);
-	printf("  T1=%u T2=%u T3=%u T4=%u\n", frame_bits[316], frame_bits[317],
-		frame_bits[318], frame_bits[319]);
 }
 
 static int