alac.c
static uint32_t readbits_16(alac_file *alac, int bits) {
  uint32_t result;
  int new_accumulator;

  result = (alac->input_buffer[0] << 16) | (alac->input_buffer[1] << 8) | (alac->input_buffer[2]);

  /* shift left by the number of bits we've already read,
   * so that the top 'n' bits of the 24 bits we read will
   * be the return bits */
  result = result << alac->input_buffer_bitaccumulator;

  result = result & 0x00ffffff;

  /* and then only want the top 'n' bits from that, where
   * n is 'bits' */
  result = result >> (24 - bits);

  new_accumulator = (alac->input_buffer_bitaccumulator + bits);

  /* increase the buffer pointer if we've read over n bytes. */
  alac->input_buffer += (new_accumulator >> 3);

  /* and the remainder goes back into the bit accumulator */
  alac->input_buffer_bitaccumulator = (new_accumulator & 7);

  return result;
}
/* supports reading 1 to 16 bits, in big endian format */
supports reading 1 to 16 bits, in big endian format
supports reading 1 to 16 bits in big endian format
static uint32_t readbits_16(alac_file *alac, int bits) {
  uint32_t result;
  int new_accumulator;
  result = (alac->input_buffer[0] << 16) | (alac->input_buffer[1] << 8) | (alac->input_buffer[2]);
  result = result << alac->input_buffer_bitaccumulator;
  result = result & 0x00ffffff;
  result = result >> (24 - bits);
  new_accumulator = (alac->input_buffer_bitaccumulator + bits);
  alac->input_buffer += (new_accumulator >> 3);
  alac->input_buffer_bitaccumulator = (new_accumulator & 7);
  return result;
}
static uint32_t readbits_16 ( alac_file * alac , int bits ) { uint32_t result ; int new_accumulator ; result = ( alac -> input_buffer [ 0 ] << 16 ) | ( alac -> input_buffer [ 1 ] << 8 ) | ( alac -> input_buffer [ 2 ] ) ; result = result << alac -> input_buffer_bitaccumulator ; result = result & 0x00ffffff ; result = result >> ( 24 - bits ) ; new_accumulator = ( alac -> input_buffer_bitaccumulator + bits ) ; alac -> input_buffer += ( new_accumulator >> 3 ) ; alac -> input_buffer_bitaccumulator = ( new_accumulator & 7 ) ; return result ; }
supports reading 1 to 16 bits, in big endian format
supports reading 1 to 16 bits in big endian format
/* shift left by the number of bits we've already read,
   * so that the top 'n' bits of the 24 bits we read will
   * be the return bits */ /* and then only want the top 'n' bits from that, where
   * n is 'bits' */ /* increase the buffer pointer if we've read over n bytes. */ /* and the remainder goes back into the bit accumulator */