anchor.diff:            (setf (dbref *ws* dptr 5) (descale (minus tmp12 tmp1) +shift-1+))
             (setf (dbref *ws* dptr 3) (descale (plus tmp13 tmp0) +shift-1+))
             (setf (dbref *ws* dptr 4) (descale (minus tmp13 tmp0) +shift-1+)))
  -    
  +
       (loop for row across block ;iterating over rows
  -	  for inrow across *ws*
  -	  if (not (find-if-not #'zerop inrow :start 1)) do
  -	  (setf dcval (dct-limit (descale (svref inrow 0) 4)))
  -	  (setf (svref row 0) dcval)
  -	  (setf (svref row 1) dcval)
  -	  (setf (svref row 2) dcval)
  -	  (setf (svref row 3) dcval)
  -	  (setf (svref row 4) dcval)
  -	  (setf (svref row 5) dcval)
  -	  (setf (svref row 6) dcval)
  -	  (setf (svref row 7) dcval)
  -	  else do
  -	  (setf z2 (svref inrow 2))
  -	  (setf z3 (svref inrow 6))
  -	  (setf z1 (mul (plus z2 z3) +FIX-0-541196100+))
  -	  (setf tmp2 (plus z1 (mul z3 (- +FIX-1-847759065+))))
  -	  (setf tmp3 (plus z1 (mul z2 +FIX-0-765366865+)))
  -	  (setf tmp0 (ash (plus (svref inrow 0) (svref inrow 4)) dct-shift))
  -	  (setf tmp1 (ash (minus (svref inrow 0) (svref inrow 4)) dct-shift))
  -	  (setf tmp10 (plus tmp0 tmp3))
  -	  (setf tmp13 (minus tmp0 tmp3))
  -	  (setf tmp11 (plus tmp1 tmp2))
  -	  (setf tmp12 (minus tmp1 tmp2))
  -	  (setf tmp0 (svref inrow 7))
  -	  (setf tmp1 (svref inrow 5))
  -	  (setf tmp2 (svref inrow 3))
  -	  (setf tmp3 (svref inrow 1))
  -	  (setf z1 (plus tmp0 tmp3))
  -	  (setf z2 (plus tmp1 tmp2))
  -	  (setf z3 (plus tmp0 tmp2))
  -	  (setf z4 (plus tmp1 tmp3))
  -	  (setf z5 (mul (plus z3 z4) +FIX-1-175875602+))
  -	  (setf tmp0 (mul tmp0 +FIX-0-298631336+))
  -	  (setf tmp1 (mul tmp1 +FIX-2-053119869+))
  -	  (setf tmp2 (mul tmp2 +FIX-3-072711026+))
  -	  (setf tmp3 (mul tmp3 +FIX-1-501321110+))
  -	  (setf z1 (mul z1 (- +FIX-0-899976223+)))
  -	  (setf z2 (mul z2 (- +FIX-2-562915447+)))
  -	  (setf z3 (mul z3 (- +FIX-1-961570560+)))
  -	  (setf z4 (mul z4 (- +FIX-0-390180644+)))
  -	  (incf z3 z5)
  -	  (incf z4 z5)
  -	  (incf tmp0 (plus z1 z3))
  -	  (incf tmp1 (plus z2 z4))
  -	  (incf tmp2 (plus z2 z3))
  -	  (incf tmp3 (plus z1 z4))
  -	  (setf (svref row 0) (dct-limit (descale (plus tmp10 tmp3) +shift+4+)))
  -	  (setf (svref row 7) (dct-limit (descale (minus tmp10 tmp3) +shift+4+)))
  -	  (setf (svref row 1) (dct-limit (descale (plus tmp11 tmp2) +shift+4+)))
  -	  (setf (svref row 6) (dct-limit (descale (minus tmp11 tmp2) +shift+4+)))
  -	  (setf (svref row 2) (dct-limit (descale (plus tmp12 tmp1) +shift+4+)))
  -	  (setf (svref row 5) (dct-limit (descale (minus tmp12 tmp1) +shift+4+)))
  -	  (setf (svref row 3) (dct-limit (descale (plus tmp13 tmp0) +shift+4+)))
  -	  (setf (svref row 4) (dct-limit (descale (minus tmp13 tmp0) +shift+4+))))))
  +          for inrow across *ws*
  +          if (not (find-if-not #'zerop inrow :start 1)) do
  +          (setf dcval (dct-limit (descale (svref inrow 0) 4)))
  +          (setf (svref row 0) dcval)
  +          (setf (svref row 1) dcval)
  +          (setf (svref row 2) dcval)
  +          (setf (svref row 3) dcval)
  +          (setf (svref row 4) dcval)
  +          (setf (svref row 5) dcval)
  +          (setf (svref row 6) dcval)
  +          (setf (svref row 7) dcval)
  +          else do
  +          (setf z2 (svref inrow 2))
  +          (setf z3 (svref inrow 6))
  +          (setf z1 (mul (plus z2 z3) +FIX-0-541196100+))
  +          (setf tmp2 (plus z1 (mul z3 (- +FIX-1-847759065+))))
  +          (setf tmp3 (plus z1 (mul z2 +FIX-0-765366865+)))
  +          (setf tmp0 (ash (plus (svref inrow 0) (svref inrow 4)) dct-shift))
  +          (setf tmp1 (ash (minus (svref inrow 0) (svref inrow 4)) dct-shift))
  +          (setf tmp10 (plus tmp0 tmp3))
  +          (setf tmp13 (minus tmp0 tmp3))
  +          (setf tmp11 (plus tmp1 tmp2))
  +          (setf tmp12 (minus tmp1 tmp2))
  +          (setf tmp0 (svref inrow 7))
  +          (setf tmp1 (svref inrow 5))
  +          (setf tmp2 (svref inrow 3))
  +          (setf tmp3 (svref inrow 1))
  +          (setf z1 (plus tmp0 tmp3))
  +          (setf z2 (plus tmp1 tmp2))
  +          (setf z3 (plus tmp0 tmp2))
  +          (setf z4 (plus tmp1 tmp3))
  +          (setf z5 (mul (plus z3 z4) +FIX-1-175875602+))
  +          (setf tmp0 (mul tmp0 +FIX-0-298631336+))
  +          (setf tmp1 (mul tmp1 +FIX-2-053119869+))
  +          (setf tmp2 (mul tmp2 +FIX-3-072711026+))
  +          (setf tmp3 (mul tmp3 +FIX-1-501321110+))
  +          (setf z1 (mul z1 (- +FIX-0-899976223+)))
  +          (setf z2 (mul z2 (- +FIX-2-562915447+)))
  +          (setf z3 (mul z3 (- +FIX-1-961570560+)))
  +          (setf z4 (mul z4 (- +FIX-0-390180644+)))
  +          (incf z3 z5)
  +          (incf z4 z5)
  +          (incf tmp0 (plus z1 z3))
  +          (incf tmp1 (plus z2 z4))
  +          (incf tmp2 (plus z2 z3))
  +          (incf tmp3 (plus z1 z4))
  +          (setf (svref row 0) (dct-limit (descale (plus tmp10 tmp3) +shift+4+)))
  +          (setf (svref row 7) (dct-limit (descale (minus tmp10 tmp3) +shift+4+)))
  +          (setf (svref row 1) (dct-limit (descale (plus tmp11 tmp2) +shift+4+)))
  +          (setf (svref row 6) (dct-limit (descale (minus tmp11 tmp2) +shift+4+)))
  +          (setf (svref row 2) (dct-limit (descale (plus tmp12 tmp1) +shift+4+)))
  +          (setf (svref row 5) (dct-limit (descale (minus tmp12 tmp1) +shift+4+)))
  +          (setf (svref row 3) (dct-limit (descale (plus tmp13 tmp0) +shift+4+)))
  +          (setf (svref row 4) (dct-limit (descale (minus tmp13 tmp0) +shift+4+))))))
   
   ;;; Places decoded block into the image buffer, with necessary upsampling
   (defun upsample (image scan block x y H V offset nwidth nw nx dend)
     "Places decoded block into the image buffer, with necessary upsampling"
     (let* ((buffer (descriptor-buffer image))
  -	 (ncomp (descriptor-ncomp image))
  -	 (xbase (plus (scan-x scan) x)); (mul (ash x 3) H)))
  -	 (ybase (plus (scan-y scan) y));(mul (ash y 3) V)))
  -	 (nxbase (mul xbase ncomp))
  -	 (nybase (mul ybase nwidth)))
  +         (ncomp (descriptor-ncomp image))
  +         (xbase (plus (scan-x scan) x)); (mul (ash x 3) H)))
  +         (ybase (plus (scan-y scan) y));(mul (ash y 3) V)))
  +         (nxbase (mul xbase ncomp))
  +         (nybase (mul ybase nwidth)))
       (declare #.*optimize*
  -	     (type (simple-vector *) block buffer)
  +             (type (simple-vector *) block buffer)
                (type fixnum x y H V ncomp xbase ybase nwidth nx dend nxbase nybase offset)
                (dynamic-extent ncomp xbase ybase nxbase nybase))
       (loop for row across block
  -	  for y fixnum from ybase below (descriptor-height image) by V
  -	  for ypos fixnum from nybase by nw do
  -	  (loop for val fixnum across row
  -		for x fixnum from xbase below (descriptor-width image) by H
  -		for pos fixnum from (+ ypos offset nxbase) by nx do
  +          for y fixnum from ybase below (descriptor-height image) by V
  +          for ypos fixnum from nybase by nw do
  +          (loop for val fixnum across row
  +                for x fixnum from xbase below (descriptor-width image) by H
  +                for pos fixnum from (+ ypos offset nxbase) by nx do
                   (if (= 1 H V)
  -		    (setf (svref buffer pos) (the fixnum val))
  +                    (setf (svref buffer pos) (the fixnum val))
                     (loop for dy fixnum from 0 below V
                           for dypos fixnum from pos below dend by nwidth
                           for dxend from (mul (plus (1+ y) dy) nwidth) by nwidth do
  
positive.code:     (let ((factor (/ q-factor 64)))
        (loop for q-row across table do
              (loop for x fixnum from 0 to 7 do
                    (setf (svref q-row x) 
                          (the fixnum (round (* (svref q-row x) factor)))))))))
  
  ;;; Function that maps value into SSSS
  
negative.code:            (type (simple-vector *) inbuf zzbuf))
    "Performs inverse zigzag block arrangement"
    (loop for zrow across +zigzag-index+
          for row across zzbuf do
          (loop for pos fixnum across zrow
                for x fixnum from 0 do
                (setf (svref row x) (svref inbuf pos))))
    zzbuf)
  
  ;;; Reads in quantization tables
  