fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/28121 )
Change subject: coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx() ......................................................................
coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()
Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90 Related: SYS#5853 --- M src/coding/gsm0503_coding.c 1 file changed, 20 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/21/28121/1
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 34b213c..dae3a19 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -2186,12 +2186,15 @@ const enum gsm0503_amr_dtx_frames dtx_prev = *dtx; *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); @@ -2211,16 +2214,18 @@ 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; } }
@@ -2660,12 +2665,15 @@ const enum gsm0503_amr_dtx_frames dtx_prev = *dtx; *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, @@ -2684,19 +2692,22 @@ 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; } }