anchor.diff:     (buffer :accessor buffer :type '(unsigned-byte 8))
      (avi :accessor avi :initarg :avi)))
   
  +(defmethod initialize-ring ((rec stream-record) ring-length frame-size element-type)
  +  (setf (chunk-queue rec) (make-list ring-length))
  +  (loop for chunk on (chunk-queue rec) do
  +       (setf (car chunk) (make-instance 'chunk :frame (make-array frame-size :element-type element-type))))
  +  (setf (cdr (last (chunk-queue rec))) (chunk-queue rec)
  +	(rcursor rec) (chunk-queue rec)
  +	(wcursor rec) (cdr (chunk-queue rec))))
  +
   (defmethod stream-playback-start ((rec stream-record))
     (bt:acquire-lock (vacancy-lock (car (rcursor rec)))))
   
  
positive.code:     (setf (jpeg::descriptor-byte-reader (jpeg-descriptor rec)) #'(lambda () (read-byte is)))
      (jpeg:read-dht (jpeg-descriptor rec)))
    (setf (buffer rec) (make-array (suggested-buffer-size rec) :element-type '(unsigned-byte 8))
  	(jpeg:descriptor-source-cache (jpeg-descriptor rec)) (buffer rec)
  	(chunk-queue rec) (make-list (max 5 (* 1 (floor (rate rec) (scale rec)))))) ;at least 5 chunks to prevent cursor deadlocks
    (loop for chunk on (chunk-queue rec) do
         (setf (car chunk) (make-instance 'chunk :frame (jpeg:allocate-buffer (height (avi rec)) (width (avi rec)) 3))))
    (setf (cdr (last (chunk-queue rec))) (chunk-queue rec)
  	(rcursor rec) (chunk-queue rec)
  	(wcursor rec) (cdr (chunk-queue rec))))
  
  (defclass audio-stream-record (stream-record)
    ((compression-code :accessor compression-code)
  
negative.code:   (find-if #'(lambda (x) (and (eql (type-of x) 'audio-stream-record)
  			      (eql (compression-code x) +pcmi-uncompressed+))) (stream-records avi)))
  
  (defmethod prime-all-streams ((avi avi-mjpeg-stream))
    ;; the playback shouldn't start before 1st frame is decoded
    (loop for rec in (stream-records avi) do
         (bt:acquire-lock (vacancy-lock (car (wcursor rec))))))
  
  
  (defmethod decode ((avi avi-mjpeg-stream))
    (with-open-file (stream (filename avi) :direction :input :element-type '(unsigned-byte 8))
      ;; read AVI header first
  