if (bits->bytePtr+((nbBits+bits->bitPtr)>>3) >= bits->buf_size) { speex_warning("Buffer too small to pack bits"); if (bits->owner) { char *tmp = speex_realloc(bits->bytes, ((bits->buf_size+5)*3)>>1); if (tmp) { for (i=bits->buf_size;i<(((bits->buf_size+5)*3)>>1);i++) tmp[i]=0; bits->buf_size=((bits->buf_size+5)*3)>>1; bits->bytes=tmp; } else { speex_warning("Could not resize input buffer: not packing"); return; } } else { speex_warning("Do not own input buffer: not packing"); return; } }
void speex_bits_pack(SpeexBits *bits, int data, int nbBits){   unsigned int d=data;   /*FIXME: check for overflow*/   while(nbBits)   {      int bit;      bit = (d>>(nbBits-1))&1;      bits->bytes[bits->bytePtr] |= bit<<(7-bits->bitPtr);      bits->bitPtr++;      if (bits->bitPtr==8)      {         bits->bitPtr=0;         bits->bytePtr++;      }      bits->nbBits++;      nbBits--;   }}