public int readGolomb(int divisor){
  int q=0;
  while (readBit() == 1) {
    q++;
  }
  int bit=31 - Integer.numberOfLeadingZeros(divisor - 1);
  int r=0;
  if (bit >= 0) {
    int cutOff=(2 << bit) - divisor;
    for (; bit > 0; bit--) {
      r=(r << 1) + readBit();
    }
    if (r >= cutOff) {
      r=(r << 1) + readBit() - cutOff;
    }
  }
  return q * divisor + r;
}

public int readGolomb ( int divisor ) { int q = 0 ; while ( readBit ( ) == 1 ) { q ++ ; } int bit = 31 - Integer . numberOfLeadingZeros ( divisor - 1 ) ; int r = 0 ; if ( bit >= 0 ) { int cutOff = ( 2 << bit ) - divisor ; for ( ; bit > 0 ; bit -- ) { r = ( r << 1 ) + readBit ( ) ; } if ( r >= cutOff ) { r = ( r << 1 ) + readBit ( ) - cutOff ; } } return q * divisor + r ; }
read a value that is stored as a golomb code .
