[xiph-commits] r11274 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Mon Apr 24 21:39:21 PDT 2006
Author: jm
Date: 2006-04-24 21:39:16 -0700 (Mon, 24 Apr 2006)
New Revision: 11274
Modified:
trunk/speex/include/speex/speex_types.h
trunk/speex/libspeex/arch.h
trunk/speex/libspeex/bits.c
Log:
TI C5x and C6x patch sent by Jim Crichton.
Modified: trunk/speex/include/speex/speex_types.h
===================================================================
--- trunk/speex/include/speex/speex_types.h 2006-04-24 22:28:46 UTC (rev 11273)
+++ trunk/speex/include/speex/speex_types.h 2006-04-25 04:39:16 UTC (rev 11274)
@@ -122,7 +122,7 @@
typedef long spx_int32_t;
typedef unsigned long spx_uint32_t;
-#elif defined(CONFIG_TI_C5X)
+#elif defined(CONFIG_TI_C6X)
typedef short spx_int16_t;
typedef unsigned short spx_uint16_t;
Modified: trunk/speex/libspeex/arch.h
===================================================================
--- trunk/speex/libspeex/arch.h 2006-04-24 22:28:46 UTC (rev 11273)
+++ trunk/speex/libspeex/arch.h 2006-04-25 04:39:16 UTC (rev 11274)
@@ -174,7 +174,7 @@
#endif
-#ifdef CONFIG_TI_C55X
+#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
/* 2 on TI C5x DSP */
#define BYTES_PER_CHAR 2
Modified: trunk/speex/libspeex/bits.c
===================================================================
--- trunk/speex/libspeex/bits.c 2006-04-24 22:28:46 UTC (rev 11273)
+++ trunk/speex/libspeex/bits.c 2006-04-25 04:39:16 UTC (rev 11274)
@@ -93,28 +93,36 @@
void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
{
int i;
- if (len > bits->buf_size)
+ int nchars = len / BYTES_PER_CHAR;
+ if (nchars > bits->buf_size)
{
speex_warning_int("Packet is larger than allocated buffer: ", len);
if (bits->owner)
{
- char *tmp = (char*)speex_realloc(bits->chars, len);
+ char *tmp = (char*)speex_realloc(bits->chars, nchars);
if (tmp)
{
- bits->buf_size=len;
+ bits->buf_size=nchars;
bits->chars=tmp;
} else {
- len=bits->buf_size;
+ nchars=bits->buf_size;
speex_warning("Could not resize input buffer: truncating input");
}
} else {
speex_warning("Do not own input buffer: truncating input");
- len=bits->buf_size;
+ nchars=bits->buf_size;
}
}
- for (i=0;i<len;i++)
- bits->chars[i]=chars[i];
- bits->nbBits=len<<3;
+#if (BYTES_PER_CHAR==2)
+/* Swap bytes to proper endian order (could be done externally) */
+#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
+#else
+#define HTOLS(A) (A)
+#endif
+ for (i=0;i<nchars;i++)
+ bits->chars[i]=HTOLS(chars[i]);
+
+ bits->nbBits=nchars<<LOG2_BITS_PER_CHAR;
bits->charPtr=0;
bits->bitPtr=0;
bits->overflow=0;
@@ -161,7 +169,7 @@
speex_bits_flush(bits);
pos=bits->nbBits>>LOG2_BITS_PER_CHAR;
for (i=0;i<nchars;i++)
- bits->chars[pos+i]=chars[i];
+ bits->chars[pos+i]=HTOLS(chars[i]);
bits->nbBits+=nchars<<LOG2_BITS_PER_CHAR;
}
@@ -182,11 +190,7 @@
if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR))
max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
-#if BYTES_PER_CHAR==1
-#define HTOLS(A) (A)
-#else
-#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
-#endif
+
for (i=0;i<max_nchars;i++)
chars[i]=HTOLS(bits->chars[i]);
return max_nchars*BYTES_PER_CHAR;
@@ -199,8 +203,8 @@
if (max_nchars > ((bits->nbBits)>>LOG2_BITS_PER_CHAR))
max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR);
for (i=0;i<max_nchars;i++)
- chars[i]=bits->chars[i];
-
+ chars[i]=HTOLS(bits->chars[i]);
+
if (bits->bitPtr>0)
bits->chars[0]=bits->chars[max_nchars];
else
More information about the commits
mailing list