gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads

The original design of gsm0503_tch_hr_{en,de}code() functions contains
a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame
input and output, instead of "pure" (agnostic to outer RTP encoding)
form of 14 bytes.  We would like to change this design so that we can
feed pure 14-byte HR codec frames to the channel coding function and
get such frames back from the channel decoding function - however,
we cannot break libosmocoding API for existing users.  In the encoding
direction, make the new format our preferred one, but support the
extra-octet format for backward compatibility.

Related: OS#5688
Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index ce24650..4f1ac79 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -1586,10 +1586,10 @@
 
 static void tch_hr_disassemble(ubit_t *b_bits, const uint8_t *tch_data)
 {
-	int i, j;
+	int i;
 
-	for (i = 0, j = 8; i < 112; i++, j++)
-		b_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+	for (i = 0; i < 112; i++)
+		b_bits[i] = (tch_data[i >> 3] >> (7 - (i & 7))) & 1;
 }
 
 /* assemble a EFR codec frame in format as used inside RTP */
@@ -2065,7 +2065,10 @@
 	int i;
 
 	switch (len) {
-	case 15: /* TCH HR */
+	case GSM_HR_BYTES_RTP_RFC5993:	/* TCH HR with RFC 5993 prefix */
+		tch_data++;
+		/* fall-through */
+	case GSM_HR_BYTES:	/* TCH HR in "pure" form */
 		tch_hr_disassemble(b, tch_data);
 
 		tch_hr_b_to_d(d, b);
@@ -2086,7 +2089,6 @@
 			gsm0503_tch_burst_map(&iB[i * 114],
 				&bursts[i * 116], &h, i >> 1);
 		}
-
 		break;
 	case GSM_MACBLOCK_LEN: /* FACCH */
 		_xcch_encode_cB(cB, tch_data);
@@ -2104,7 +2106,6 @@
 			gsm0503_tch_burst_map(&iB[i * 114 + 456],
 				&bursts[i * 116], &h, 1);
 		}
-
 		break;
 	default:
 		return -1;