Logo Search packages:      
Sourcecode: randomsound version File versions  Download package

debias.c

Go to the documentation of this file.
/** @file debias.c
 *
 * Implementation of a von-neumann debiassing of a random bitstream.
 */

#include "debias.h"

int
00009 transfer_bits_and_debias(BitBuffer from, BitBuffer to)
{
  BitField bits;
  int bits_xfered = 0;
  while (bitbuffer_available_bits(from) >= 2) {
    if (bitbuffer_extract_bits(from, &bits, 2) != 2)
      return bits_xfered;
    if ((bits & 3) == 1 || (bits & 3) == 2) {
      if (bitbuffer_add_bits(to, bits, 1) != 1)
        return bits_xfered;
      bits_xfered++;
    }
  }
  return bits_xfered;
}

Generated by  Doxygen 1.6.0   Back to index