diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-05-15 14:46:08 +0300 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2022-05-16 00:51:57 +0300 |
commit | eebaccdae5c27f6d0360851b867beca6c0a102a4 (patch) | |
tree | 16d2333e300530193fdde4a55ec2e913a0ed5909 | |
parent | coding: cosmetic: move 'dtx_prev' to the scope where it's used (diff) | |
download | libosmocore-eebaccdae5c27f6d0360851b867beca6c0a102a4.tar.xz libosmocore-eebaccdae5c27f6d0360851b867beca6c0a102a4.zip |
coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()
Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90
Related: SYS#5853
-rw-r--r-- | src/coding/gsm0503_coding.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 329a0764..6f19ed92 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -2187,12 +2187,15 @@ int gsm0503_tch_afs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, osmo_sbit2ubit(cBd, cB, 456); *dtx = gsm0503_detect_afs_dtx_frame(n_errors, n_bits_total, cBd); - if (dtx_prev == AFS_SID_UPDATE && *dtx == AMR_OTHER) { + switch (*dtx) { + case AMR_OTHER: /* NOTE: The AFS_SID_UPDATE frame is splitted into * two half rate frames. If the id marker frame * (AFS_SID_UPDATE) is detected the following frame * contains the actual comfort noised data part of * (AFS_SID_UPDATE_CN). */ + if (dtx_prev != AFS_SID_UPDATE) + break; *dtx = AFS_SID_UPDATE_CN; extract_afs_sid_update(sid_update_enc, cB); @@ -2212,16 +2215,18 @@ int gsm0503_tch_afs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, tch_amr_reassemble(tch_data, conv, 39); len = 5; goto out; - } else if (*dtx == AFS_SID_FIRST) { + case AFS_SID_FIRST: tch_amr_sid_update_append(sid_first_dummy, 0, (codec_mode_req) ? codec[*ft] : codec[id]); tch_amr_reassemble(tch_data, conv, 39); len = 5; goto out; - } else if (*dtx == AFS_ONSET) { + case AFS_ONSET: len = 0; goto out; + default: + break; } } @@ -2662,12 +2667,15 @@ int gsm0503_tch_ahs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, int odd, osmo_sbit2ubit(cBd, cB, 456); *dtx = gsm0503_detect_ahs_dtx_frame(n_errors, n_bits_total, cBd); - if (dtx_prev == AHS_SID_UPDATE && *dtx == AMR_OTHER) { + switch (*dtx) { + case AMR_OTHER: /* NOTE: The AHS_SID_UPDATE frame is splitted into * two half rate frames. If the id marker frame * (AHS_SID_UPDATE) is detected the following frame * contains the actual comfort noised data part of * (AHS_SID_UPDATE_CN). */ + if (dtx_prev != AHS_SID_UPDATE) + break; *dtx = AHS_SID_UPDATE_CN; osmo_conv_decode_ber(&gsm0503_tch_axs_sid_update, @@ -2686,19 +2694,22 @@ int gsm0503_tch_ahs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, int odd, tch_amr_reassemble(tch_data, conv, 39); len = 5; goto out; - } else if (*dtx == AHS_SID_FIRST_P2) { + case AHS_SID_FIRST_P2: tch_amr_sid_update_append(sid_first_dummy, 0, (codec_mode_req) ? codec[*ft] : codec[id]); tch_amr_reassemble(tch_data, sid_first_dummy, 39); len = 5; goto out; - } else if (*dtx == AHS_SID_UPDATE || *dtx == AHS_ONSET - || *dtx == AHS_SID_FIRST_INH - || *dtx == AHS_SID_UPDATE_INH - || *dtx == AHS_SID_FIRST_P1) { + case AHS_SID_UPDATE: + case AHS_ONSET: + case AHS_SID_FIRST_INH: + case AHS_SID_UPDATE_INH: + case AHS_SID_FIRST_P1: len = 0; goto out; + default: + break; } } |