[Freeswitch-svn] [commit] r7600 - in freeswitch/trunk: libs/voipcodecs/src libs/voipcodecs/src/voipcodecs src/mod/codecs/mod_voipcodecs

Freeswitch SVN brian at freeswitch.org
Tue Feb 12 19:44:51 EST 2008


Author: brian
Date: Tue Feb 12 19:44:51 2008
New Revision: 7600

Modified:
   freeswitch/trunk/libs/voipcodecs/src/gsm0610_decode.c
   freeswitch/trunk/libs/voipcodecs/src/gsm0610_encode.c
   freeswitch/trunk/libs/voipcodecs/src/gsm0610_local.h
   freeswitch/trunk/libs/voipcodecs/src/voipcodecs/gsm0610.h
   freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c

Log:
update voipcodecs

Modified: freeswitch/trunk/libs/voipcodecs/src/gsm0610_decode.c
==============================================================================
--- freeswitch/trunk/libs/voipcodecs/src/gsm0610_decode.c	(original)
+++ freeswitch/trunk/libs/voipcodecs/src/gsm0610_decode.c	Tue Feb 12 19:44:51 2008
@@ -26,7 +26,7 @@
  * This code is based on the widely used GSM 06.10 code available from
  * http://kbs.cs.tu-berlin.de/~jutta/toast.html
  *
- * $Id: gsm0610_decode.c,v 1.15 2008/02/09 15:31:36 steveu Exp $
+ * $Id: gsm0610_decode.c,v 1.16 2008/02/12 12:27:48 steveu Exp $
  */
 
 /*! \file */
@@ -310,50 +310,49 @@
 }
 /*- End of function --------------------------------------------------------*/
 
-int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int quant)
+int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int len)
 {
     gsm0610_frame_t frame[2];
-    const uint8_t *c;
     int bytes;
+    int samples;
     int i;
 
-    c = code;
-    for (i = 0;  i < quant;  i++)
+    samples = 0;
+    for (i = 0;  i < len;  i += bytes)
     {
         switch (s->packing)
         {
         default:
         case GSM0610_PACKING_NONE:
-            if ((bytes = gsm0610_unpack_none(frame, c)) >= 0)
+            if ((bytes = gsm0610_unpack_none(frame, &code[i])) >= 0)
             {
-                decode_a_frame(s, amp, frame);
-                amp += GSM0610_FRAME_LEN;
+                decode_a_frame(s, &amp[samples], frame);
+                samples += GSM0610_FRAME_LEN;
             }
             break;
         case GSM0610_PACKING_WAV49:
-            if ((bytes = gsm0610_unpack_wav49(frame, c)) >= 0)
+            if ((bytes = gsm0610_unpack_wav49(frame, &code[i])) >= 0)
             {
-                decode_a_frame(s, amp, frame);
-                amp += GSM0610_FRAME_LEN;
-                decode_a_frame(s, amp, frame + 1);
-                amp += GSM0610_FRAME_LEN;
+                decode_a_frame(s, &amp[samples], frame);
+                samples += GSM0610_FRAME_LEN;
+                decode_a_frame(s, &amp[samples], frame + 1);
+                samples += GSM0610_FRAME_LEN;
             }
             break;
         case GSM0610_PACKING_VOIP:
-            if ((bytes = gsm0610_unpack_voip(frame, c)) >= 0)
+            if ((bytes = gsm0610_unpack_voip(frame, &code[i])) >= 0)
             {
-                decode_a_frame(s, amp, frame);
-                amp += GSM0610_FRAME_LEN;
+                decode_a_frame(s, &amp[samples], frame);
+                samples += GSM0610_FRAME_LEN;
             }
             break;
         }
         /*endswitch*/
         if (bytes < 0)
             return 0;
-        c += bytes;
     }
-    /*endwhile*/
-    return quant*GSM0610_FRAME_LEN;
+    /*endfor*/
+    return samples;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/

Modified: freeswitch/trunk/libs/voipcodecs/src/gsm0610_encode.c
==============================================================================
--- freeswitch/trunk/libs/voipcodecs/src/gsm0610_encode.c	(original)
+++ freeswitch/trunk/libs/voipcodecs/src/gsm0610_encode.c	Tue Feb 12 19:44:51 2008
@@ -26,7 +26,7 @@
  * This code is based on the widely used GSM 06.10 code available from
  * http://kbs.cs.tu-berlin.de/~jutta/toast.html
  *
- * $Id: gsm0610_encode.c,v 1.18 2008/02/09 15:31:36 steveu Exp $
+ * $Id: gsm0610_encode.c,v 1.19 2008/02/12 12:27:48 steveu Exp $
  */
 
 /*! \file */
@@ -156,6 +156,7 @@
         for (k = 0;  k < 13;  k++)
             c[i++] = (uint8_t) s->xMc[j][k];
     }
+    /*endfor*/
     return 76;
 }
 /*- End of function --------------------------------------------------------*/
@@ -206,6 +207,7 @@
         *c++ = sr >> 7;
         sr = (sr >> 3) | (s->xMc[i][12] << 13);
     }
+    /*endfor*/
 
     s++;
     sr = (sr >> 6) | (s->LARc[0] << 10);
@@ -249,6 +251,7 @@
         sr = (sr >> 3) | (s->xMc[i][12] << 13);
         *c++ = sr >> 8;
     }
+    /*endfor*/
     return 65;
 }
 /*- End of function --------------------------------------------------------*/
@@ -295,41 +298,39 @@
              | ((s->xMc[i][11] & 0x7) << 3)
              |  (s->xMc[i][12] & 0x7);
     }
+    /*endfor*/
     return 33;
 }
 /*- End of function --------------------------------------------------------*/
 
-int gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int quant)
+int gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int len)
 {
     gsm0610_frame_t frame[2];
-    uint8_t *c;
+    int bytes;
     int i;
 
-    c = code;
-    for (i = 0;  i < quant;  i++)
+    bytes = 0;
+    for (i = 0;  i < len;  i += GSM0610_FRAME_LEN)
     {
-        encode_a_frame(s, frame, amp);
+        encode_a_frame(s, frame, &amp[i]);
         switch (s->packing)
         {
-        case GSM0610_PACKING_NONE:
-            c += gsm0610_pack_none(c, frame);
-            amp += GSM0610_FRAME_LEN;
-            break;
         case GSM0610_PACKING_WAV49:
-            amp += GSM0610_FRAME_LEN;
-            encode_a_frame(s, frame + 1, amp);
-            amp += GSM0610_FRAME_LEN;
-            c += gsm0610_pack_wav49(c, frame);
+            i += GSM0610_FRAME_LEN;
+            encode_a_frame(s, frame + 1, &amp[i]);
+            bytes += gsm0610_pack_wav49(&code[bytes], frame);
             break;
         case GSM0610_PACKING_VOIP:
-            c += gsm0610_pack_voip(c, frame);
-            amp += GSM0610_FRAME_LEN;
+            bytes += gsm0610_pack_voip(&code[bytes], frame);
+            break;
+        default:
+            bytes += gsm0610_pack_none(&code[bytes], frame);
             break;
         }
         /*endswitch*/
     }
-    /*endwhile*/
-    return (int) (c - code);
+    /*endfor*/
+    return bytes;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/

Modified: freeswitch/trunk/libs/voipcodecs/src/gsm0610_local.h
==============================================================================
--- freeswitch/trunk/libs/voipcodecs/src/gsm0610_local.h	(original)
+++ freeswitch/trunk/libs/voipcodecs/src/gsm0610_local.h	Tue Feb 12 19:44:51 2008
@@ -1,5 +1,5 @@
 /*
- * SpanDSP - a series of DSP components for telephony
+ * VoIPcodecs - a series of DSP components for telephony
  *
  * gsm0610_local.h - GSM 06.10 full rate speech codec.
  *

Modified: freeswitch/trunk/libs/voipcodecs/src/voipcodecs/gsm0610.h
==============================================================================
--- freeswitch/trunk/libs/voipcodecs/src/voipcodecs/gsm0610.h	(original)
+++ freeswitch/trunk/libs/voipcodecs/src/voipcodecs/gsm0610.h	Tue Feb 12 19:44:51 2008
@@ -23,11 +23,11 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: gsm0610.h,v 1.14 2008/02/09 15:31:36 steveu Exp $
+ * $Id: gsm0610.h,v 1.15 2008/02/12 12:27:48 steveu Exp $
  */
 
-#if !defined(_SPANDSP_GSM0610_H_)
-#define _SPANDSP_GSM0610_H_
+#if !defined(_VOIPCODECS_GSM0610_H_)
+#define _VOIPCODECS_GSM0610_H_
 
 /*! \page gsm0610_page GSM 06.10 encoding and decoding
 \section gsm0610_page_sec_1 What does it do?
@@ -128,17 +128,17 @@
     \param s The GSM 06.10 context.
     \param code The GSM 06.10 data produced.
     \param amp The audio sample buffer.
-    \param quant The number of samples in the buffer.
+    \param len The number of samples in the buffer.
     \return The number of bytes of GSM 06.10 data produced. */
-int gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int quant);
+int gsm0610_encode(gsm0610_state_t *s, uint8_t code[], const int16_t amp[], int len);
 
 /*! Decode a buffer of GSM 06.10 data to linear PCM.
     \param s The GSM 06.10 context.
     \param amp The audio sample buffer.
     \param code The GSM 06.10 data.
-    \param quant The number of frames of GSM 06.10 data to be decoded.
+    \param len The number of bytes of GSM 06.10 data to be decoded.
     \return The number of samples returned. */
-int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int quant);
+int gsm0610_decode(gsm0610_state_t *s, int16_t amp[], const uint8_t code[], int len);
 
 int gsm0610_pack_none(uint8_t c[], const gsm0610_frame_t *s);
 

Modified: freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c	Tue Feb 12 19:44:51 2008
@@ -158,7 +158,7 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	*encoded_data_len = gsm0610_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 320);
+	*encoded_data_len = gsm0610_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -176,7 +176,7 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	*decoded_data_len = (2 * gsm0610_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len / 33));
+	*decoded_data_len = (2 * gsm0610_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
 
 	return SWITCH_STATUS_SUCCESS;
 }



More information about the Freeswitch-svn mailing list