changeset 192:0303ba213e1c

libgsmefr/dtx_dec.c: perf opt
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 03 Jan 2023 04:51:51 +0000
parents 7bc011aceb7f
children cf39a90f5196
files libgsmefr/dtx_dec.c
diffstat 1 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmefr/dtx_dec.c	Tue Jan 03 04:31:11 2023 +0000
+++ b/libgsmefr/dtx_dec.c	Tue Jan 03 04:51:51 2023 +0000
@@ -110,7 +110,7 @@
        mitted) are also classified here; they will be discarded later
        and provided with "NO TRANSMISSION"-flag */
 
-    if ((sub (SID_flag, 2) == 0) && (bfi == 0))
+    if ((SID_flag == 2) && (bfi == 0))
     {
         frame_type = VALID_SID_FRAME;                   move16 (); 
     }
@@ -131,40 +131,40 @@
     /* Previous frame was classified as a speech frame */
     if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0)
     {
-        if (sub (frame_type, VALID_SID_FRAME) == 0)
+        if (frame_type == VALID_SID_FRAME)
         {
             st->rxdtx_ctrl = RX_FIRST_SID_UPDATE;
         }
-        else if (sub (frame_type, INVALID_SID_FRAME) == 0)
+        else if (frame_type == INVALID_SID_FRAME)
         {
             st->rxdtx_ctrl = RX_FIRST_SID_UPDATE
                            | RX_INVALID_SID_FRAME;
         }
-        else if (sub (frame_type, UNUSABLE_FRAME) == 0)
+        else if (frame_type == UNUSABLE_FRAME)
         {
             st->rxdtx_ctrl = RX_SP_FLAG;
         }
-        else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0)
+        else if (frame_type == GOOD_SPEECH_FRAME)
         {
             st->rxdtx_ctrl = RX_SP_FLAG;
         }
     }
     else
     {
-        if (sub (frame_type, VALID_SID_FRAME) == 0)
+        if (frame_type == VALID_SID_FRAME)
         {
             st->rxdtx_ctrl = RX_CONT_SID_UPDATE;
         }
-        else if (sub (frame_type, INVALID_SID_FRAME) == 0)
+        else if (frame_type == INVALID_SID_FRAME)
         {
             st->rxdtx_ctrl = RX_CONT_SID_UPDATE
                            | RX_INVALID_SID_FRAME;
         }
-        else if (sub (frame_type, UNUSABLE_FRAME) == 0)
+        else if (frame_type == UNUSABLE_FRAME)
         {
             st->rxdtx_ctrl = RX_CNI_BFI;
         }
-        else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0)
+        else if (frame_type == GOOD_SPEECH_FRAME)
         {
             /* If the previous frame (during CNI period) was muted,
                raise the RX_PREV_DTX_MUTING flag */
@@ -199,15 +199,15 @@
         {
             st->prev_SID_frames_lost = 0;
 
-            if (sub (frame_type, VALID_SID_FRAME) == 0)
+            if (frame_type == VALID_SID_FRAME)
             {
                 st->rx_dtx_state = 0;
             }
-            else if (sub (frame_type, INVALID_SID_FRAME) == 0)
+            else if (frame_type == INVALID_SID_FRAME)
             {
-                if (sub(st->rx_dtx_state, (CN_INT_PERIOD - 1)) < 0)
+                if (st->rx_dtx_state < (CN_INT_PERIOD - 1))
                 {
-                    st->rx_dtx_state = add(st->rx_dtx_state, 1);
+                    st->rx_dtx_state++;
                 }
             }
         }
@@ -215,15 +215,15 @@
         /* Bad frame received in CNI mode */
         if ((st->rxdtx_ctrl & RX_CNI_BFI) != 0)
         {
-            if (sub (st->rx_dtx_state, (CN_INT_PERIOD - 1)) < 0)
+            if (st->rx_dtx_state < (CN_INT_PERIOD - 1))
             {
-                st->rx_dtx_state = add (st->rx_dtx_state, 1);
+                st->rx_dtx_state++;
             }
 
             /* If an unusable frame is received during CNI period
                when TAF == 1, the frame is classified as a lost
                SID frame */
-            if (sub (TAF, 1) == 0)
+            if (TAF == 1)
             {
                 st->rxdtx_ctrl = st->rxdtx_ctrl | RX_LOST_SID_FRAME;
                 st->prev_SID_frames_lost = add (st->prev_SID_frames_lost, 1);
@@ -233,7 +233,7 @@
                 st->rxdtx_ctrl = st->rxdtx_ctrl | RX_NO_TRANSMISSION;
             }
 
-            if (sub (st->prev_SID_frames_lost, 1) > 0)
+            if (st->prev_SID_frames_lost > 1)
             {
                 st->rxdtx_ctrl = st->rxdtx_ctrl | RX_DTX_MUTING;
             }
@@ -251,7 +251,7 @@
     }
     else
     {
-        if (sub (st->rxdtx_N_elapsed, DTX_ELAPSED_THRESHOLD) > 0)
+        if (st->rxdtx_N_elapsed > DTX_ELAPSED_THRESHOLD)
         {
             st->rxdtx_ctrl |= RX_UPD_SID_QUANT_MEM;
             st->rxdtx_N_elapsed = 0;
@@ -264,7 +264,7 @@
         }
         else
         {
-            st->rxdtx_aver_period = sub (st->rxdtx_aver_period, 1);
+            st->rxdtx_aver_period--;
         }
     }
 
@@ -300,13 +300,13 @@
     /* Circular buffer */
     st->gain_code_old_rx[st->buf_p_rx] = new_gain_code;
 
-    if (sub (st->buf_p_rx, (4 * DTX_HANGOVER - 1)) == 0)
+    if (st->buf_p_rx == (4 * DTX_HANGOVER - 1))
     {
         st->buf_p_rx = 0;
     }
     else
     {
-        st->buf_p_rx = add (st->buf_p_rx, 1);
+        st->buf_p_rx++;
     }
 
     return;