Ignore:
Timestamp:
Jul 26, 2006 5:04:54 PM (18 years ago)
Author:
bennylp
Message:
  • Bring speex codec up to date with their SVN trunk
  • Speex codec should work in FIXED_POINT mode when PJ_HAS_FLOATING_POINT is set to zero.
  • ulaw2linear will return zero if zero is given (this would make the VAD works better, and it also fixed click noise when call is established/hangup).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/speex/bits.c

    r278 r628  
    9494{ 
    9595   int i; 
    96    if (len > bits->buf_size) 
     96   int nchars = len / BYTES_PER_CHAR; 
     97   if (nchars > bits->buf_size) 
    9798   { 
    9899      speex_warning_int("Packet is larger than allocated buffer: ", len); 
    99100      if (bits->owner) 
    100101      { 
    101          char *tmp = (char*)speex_realloc(bits->chars, len); 
     102         char *tmp = (char*)speex_realloc(bits->chars, nchars); 
    102103         if (tmp) 
    103104         { 
    104             bits->buf_size=len; 
     105            bits->buf_size=nchars; 
    105106            bits->chars=tmp; 
    106107         } else { 
    107             len=bits->buf_size; 
     108            nchars=bits->buf_size; 
    108109            speex_warning("Could not resize input buffer: truncating input"); 
    109110         } 
    110111      } else { 
    111112         speex_warning("Do not own input buffer: truncating input"); 
    112          len=bits->buf_size; 
    113       } 
    114    } 
    115    for (i=0;i<len;i++) 
    116       bits->chars[i]=chars[i]; 
    117    bits->nbBits=len<<3; 
     113         nchars=bits->buf_size; 
     114      } 
     115   } 
     116#if (BYTES_PER_CHAR==2) 
     117/* Swap bytes to proper endian order (could be done externally) */ 
     118#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8)) 
     119#else 
     120#define HTOLS(A) (A) 
     121#endif 
     122   for (i=0;i<nchars;i++) 
     123      bits->chars[i]=HTOLS(chars[i]); 
     124 
     125   bits->nbBits=nchars<<LOG2_BITS_PER_CHAR; 
    118126   bits->charPtr=0; 
    119127   bits->bitPtr=0; 
     
    162170   pos=bits->nbBits>>LOG2_BITS_PER_CHAR; 
    163171   for (i=0;i<nchars;i++) 
    164       bits->chars[pos+i]=chars[i]; 
     172      bits->chars[pos+i]=HTOLS(chars[i]); 
    165173   bits->nbBits+=nchars<<LOG2_BITS_PER_CHAR; 
    166174} 
     
    183191   if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)) 
    184192      max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); 
    185 #if BYTES_PER_CHAR==1 
    186 #define HTOLS(A) (A) 
    187 #else 
    188 #define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8)) 
    189 #endif 
     193 
    190194   for (i=0;i<max_nchars;i++) 
    191195      chars[i]=HTOLS(bits->chars[i]); 
     
    200204      max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR); 
    201205   for (i=0;i<max_nchars;i++) 
    202       chars[i]=bits->chars[i]; 
    203     
     206      chars[i]=HTOLS(bits->chars[i]); 
     207 
    204208   if (bits->bitPtr>0) 
    205209      bits->chars[0]=bits->chars[max_nchars]; 
Note: See TracChangeset for help on using the changeset viewer.