anchor.diff:              (exp (ash val -8)))
           (ash m (- exp 9)))
         (- (exp2s (1+ (logxor #xffff val))))))
  +
  +
   ;; Next two functions are just a KLUDGE and almost copy functionality of the bitreader.
   ;; Try to develop more flexible bitreader instead
  +(declaim (ftype (function (reader) bit-value) residual-read-bit))
   (defun residual-read-bit (reader)
  +  (declare (optimize #+easy-audio-unsafe-code
  +                     (safety 0) (speed 3)))
     (with-accessors ((ibyte bitreader::reader-ibyte)
                      (ibit  bitreader::reader-ibit)
                      (end   bitreader::reader-end)) reader
  
positive.code:             (incf ibit)))
        (error 'bitreader-eof :bitreader reader))))
  
  (defun residual-read-bits (bits reader)
    (let ((result 0)
          (already-read 0))
      (with-accessors ((ibit  bitreader::reader-ibit)
                       (ibyte bitreader::reader-ibyte)
                       (end   bitreader::reader-end)) reader
        (dotimes (i (ceiling (+ bits ibit) 8))
          (if (= ibyte end) (error 'bitreader-eof :bitreader reader))
          (let ((bits-to-add (min bits (- 8 ibit))))
            (setq result (logior result (ash (ldb
                                              (byte bits-to-add ibit)
                                              (aref (bitreader::reader-buffer reader) ibyte))
                                             already-read))
                  bits (- bits bits-to-add)
                  already-read (+ already-read bits-to-add))
  
  
negative.code:                     ibyte (1+ ibyte))))))
      result))
  
  ;; From flac reader
  (declaim (ftype (function (t) non-negative-fixnum)
  		read-unary-coded-integer)
  	 (inline read-unary-coded-integer))
  (defun read-unary-coded-integer (bitreader)
    "Read an unary coded integer from bitreader
     1 bit is considered as arithmetical 1,
     0 bit signals termination"
    (do ((res 0 (1+ res)))
        ((= (residual-read-bit bitreader) 0) res)
      (declare (type (ub 32) res)) ()))
  
  (declaim (ftype (function (t) non-negative-fixnum) read-zero-run-length))
  (defun read-zero-run-length (reader)
    (declare (optimize (speed 3)))
    (let ((ones-num (read-unary-coded-integer reader)))
      (if (/= ones-num 0)
          (let ((shift (the (integer 0 32) ; as to format limits
                            (1- ones-num))))
            (logior (ash 1 shift)
                    (residual-read-bits shift reader))) 0)))
  
  