home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :RO24STV-vd)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; RO24STV-vd.Lisp
- ;;
- ;; Copyright ⌐ 1990 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; video digitizer object for controling RasterOps 364 video digitizer boards
- ;; Note: 24STV boards require access to a resource file containing their driver.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :RO-vd
- :+Devices
- :Records-u
- :Traps-u
- :Resources-u
- )
-
- (export '(RO24STV-vd
- ))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (defconstant RO24STV-drvr-name ".RasterOps24STVPIP1.1d3"))
-
-
- (defclass RO24STV-vd (RO-vd)
- ((drvr-refnum :allocation :class)
- (ref-count :initform 0
- :allocation :class)
- (red-inhibit :initarg :red-inhibit
- :accessor red-inhibit)
- (green-inhibit :initarg :green-inhibit
- :accessor green-inhibit)
- (blue-inhibit :initarg :blue-inhibit
- :accessor blue-inhibit))
- (:default-initargs
- :board-id RO24STV-board-id
- ;default values determined empically
- :hue #.(ash 0 8)
- :saturation #.(ash 59 8)
- :red-inhibit nil
- :green-inhibit nil
- :blue-inhibit nil
- ))
-
- (defmethod initialize-instance :after ((vd RO24STV-vd) &rest initargs)
- (declare (dynamic-extent initargs)
- (ignore initargs))
- (when (minusp (slot-value vd 'ref-count))
- (setf (slot-value vd 'ref-count) 0)
- (error "ref-count class slot went negative - now reset to zero")))
-
- (defmethod vd-init :before ((vd RO24STV-vd))
- (when (zerop (slot-value vd 'ref-count))
- (setf (slot-value vd 'drvr-refnum) (RO24STV-open-driver))
- (ROvd-reset vd))
- (incf (slot-value vd 'ref-count)))
-
- (defmethod vd-dispose :after ((vd RO24STV-vd))
- (decf (slot-value vd 'ref-count))
- (when (zerop (slot-value vd 'ref-count))
- (let ((refnum (slot-value vd 'drvr-refnum)))
- (slot-makunbound vd 'drvr-refnum)
- (trap-nz-echeck (#~CloseDriver refnum)))))
-
- (defmethod vd-set-hue ((vd RO24STV-vd) hue)
- (ROvd-set-hue vd (ash hue -9))
- hue)
-
- (defmethod vd-set-input-standard ((vd RO24STV-vd) standard)
- (RO24STVvd-set-input-type vd standard)
- standard)
-
- (defmethod vd-get-input-standard ((vd RO24STV-vd))
- (RO24STVvd-get-input-type vd))
-
- ;;;;;;;;;;
- ;;RO24STV uses a 0-255 range for hue,saturation
- ;; ash +/- 8 converts to/from the QuickTime range (0-65535)
-
- (defmethod vd-set-hue ((vd RO24STV-vd) hue)
- (ROvd-set-hue vd (ash hue -8))
- hue)
-
- (defmethod vd-get-hue ((vd RO24STV-vd))
- (ash (ROvd-get-hue vd) 8))
-
- #| un-comment if your board supports saturation.
-
- (defmethod vd-set-saturation ((vd RO24STV-vd) saturation)
- (ROvd-set-saturation vd (ash saturation -8))
- saturation)
-
- (defmethod vd-get-saturation ((vd RO24STV-vd))
- (ash (ROvd-get-saturation vd) 8))
- |#
-
- (defmethod vd-install-settings :after ((vd RO24STV-vd))
- (RO24STVvd-select-board vd (card-num vd))
- (RO24STVvd-set-red-inhibit vd (red-inhibit vd))
- (RO24STVvd-set-green-inhibit vd (green-inhibit vd))
- (RO24STVvd-set-blue-inhibit vd (blue-inhibit vd)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;RO24STV specific settings
-
- (defmethod (setf red-inhibit) :after (inhibit-p (vd RO24STV-vd))
- (when (vd-digitizing-p vd)
- (RO24STVvd-set-red-inhibit vd inhibit-p)))
-
- (defmethod (setf green-inhibit) :after (inhibit-p (vd RO24STV-vd))
- (when (vd-digitizing-p vd)
- (RO24STVvd-set-green-inhibit vd inhibit-p)))
-
- (defmethod (setf blue-inhibit) :after (inhibit-p (vd RO24STV-vd))
- (when (vd-digitizing-p vd)
- (RO24STVvd-set-blue-inhibit vd inhibit-p)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; RO24STV functions
-
- (defun RO24STV-open-driver ()
- (with-pstrs ((RO24STV-drvr-name_p RO24STV-drvr-name))
- (rlet ((refNum_p :integer))
- (unless (zerop (#~OpenDriver RO24STV-drvr-name_p refNum_p))
- (error "Unable to open 24STV driver.~%Make sure it's rsrc file is open."))
- (%get-signed-word refNum_p))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;Control calls
-
- ;;For more information on the various parameters see the Signetics Philips
- ;;Components Video Handbook, July 1990, pp. 93-136
-
- (defmethod RO24STVvd-set-aperture ((vd RO24STV-vd) aperture-factor)
- ;set the aperture factor
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (ecase aperture-factor
- (:zero 0)
- (:quarter 1)
- (:half 2)
- (:one 3))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9056 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-color-killer ((vd RO24STV-vd) on-p)
- ;enable or disable the automatic color killer
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9049 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-bandpass-type ((vd RO24STV-vd) bandpass-type)
- ;set the bandpass type
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (ecase bandpass-type
- (0 0)
- (1 1)
- (2 2)
- (3 3))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9054 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-bypass-digitize-LUT ((vd RO24STV-vd) on-p)
- ;enable or disable bypass of the digitize LUT
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9046 csParamPtr))))
-
-
-
- (defmethod RO24STVvd-set-color-key-mask ((vd RO24STV-vd)
- topLeft botRight
- red-value green-value blue-value
- match-p
- mask)
- ;allows you enable or disable live video within a specified rectangle
- ;whenever a pixel matches (or does not match) a specified 24-bit color value
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (point-v topLeft)
- (:csParam 1) (point-h topLeft)
- (:csParam 2) (point-v botRight)
- (:csParam 3) (point-h botRight)
- (:csParam 4) red-value
- (:csParam 5) green-value
- (:csParam 6) blue-value
- (:csParam 7) (if match-p 1 0)
- (:csParam 8) (ecase mask (:graphics 0) (:video 1))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9060 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-coring ((vd RO24STV-vd) LSB-variance)
- ;set the coring
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (ecase LSB-variance
- (0 0)
- (1 1)
- (2 2)
- (3 3))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9055 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-cross-color-reduction ((vd RO24STV-vd) on-p)
- ;enable or disable SECAM cross color reduction
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9050 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-input-type ((vd RO24STV-vd) input-type)
- ;set the input type
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (ecase input-type
- (:NTSC 0)
- (:PAL 1)
- (:SECAM 2))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9038 csParamPtr))))
-
-
- (defmethod RO24STVvd-load-digitize-LUT ((vd RO24STV-vd) table)
- ;loads a LUT
- (rlet ((csParamPtr :ROCsParam
- :ptr table))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9044 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-LUMA-delay-compensation ((vd RO24STV-vd) delay-compensation)
- ;set the LUMA delay compensation
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) delay-compensation))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9051 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-mask-enable ((vd RO24STV-vd) on-p)
- ;Enable or disable the mask. When the mask is enabled the state of the mask at
- ;each pixel determines whether live video or graphics is shown.
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9043 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-mask-readback ((vd RO24STV-vd) on-p)
- ;MaskReadback controls whether the mask is read back during a read operation
- ;from the frame buffer. Usually, this should be enabled only when the mask is
- ;enabled. This function is provided to prevent the cursor from turning off live
- ;video whenever the cursor moves over a live video region. Disable mask
- ;readback if you're going to read data from the frame buffer, e.g., with CopyBits
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9042 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-prefilter ((vd RO24STV-vd) on-p)
- ;enable or disable the prefilter
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if on-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9042 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-red-inhibit ((vd RO24STV-vd) inhibit-p)
- ;controls writing of the red video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9019 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-green-inhibit ((vd RO24STV-vd) inhibit-p)
- ;controls writing the green video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9020 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-blue-inhibit ((vd RO24STV-vd) inhibit-p)
- ;conrols writing the blue video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9021 csParamPtr))))
-
-
- (defmethod RO24STVvd-select-board ((vd RO24STV-vd) card-num)
- ;sets the card the driver is using
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) card-num))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9053 csParamPtr))))
-
-
- (defmethod RO24STVvd-set-vert-noise-reduction ((vd RO24STV-vd) mode)
- ; mode = :normal, :searching, :auto, or :bypassed
- ;set the vertical noise reduction mode
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (ecase mode
- (:normal 0)
- (:searching 1)
- (:auto 2)
- (:bypassed 3))))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9052 csParamPtr))))
-
-
- (defmethod RO24STVvd-write-DMSD ((vd RO24STV-vd) register value)
- ;writes a byte to the specified register of the Digital Multi-Standard Decoder chip
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) register
- (:csParam 1) value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9041 csParamPtr))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;Status calls
-
- ;;For more information on the various parameters see the Signetics Philips
- ;;Components Video Handbook, July 1990, pp. 93-136
-
-
- (defmethod RO24STVvd-get-AGC-response ((vd RO24STV-vd))
- ;returns the Automatic Gain Control response
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9048 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-get-aperture ((vd RO24STV-vd))
- ;returns the aperture
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9048 csParamPtr))
- (ecase (pref csParamPtr (:ROCsParam.csParam 0))
- (0 :zero)
- (1 :quarter)
- (2 :half)
- (3 :one))))
-
-
- (defmethod RO24STVvd-auto-color-killer-p ((vd RO24STV-vd))
- ;returns the automatic color killer state
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9049 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
-
- (defmethod RO24STVvd-get-bandpass ((vd RO24STV-vd))
- ;returns the bandpass type
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9054 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-get-board-count ((vd RO24STV-vd))
- ;returns the number of 24STV boards in the machine
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) 1))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9040 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-get-bypass-digitize-LUT ((vd RO24STV-vd))
- ;returns the bypass digitize LUT state
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9046 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-get-coring ((vd RO24STV-vd))
- ;returns the coring value
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9055 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-cross-color-reduction-p ((vd RO24STV-vd))
- ;returns the cross color reduction state
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9050 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
-
- (defmethod RO24STVvd-get-digitize-LUT ((vd RO24STV-vd))
- ;returns the digitize LUT
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9044 csParamPtr))
- (pref csParamPtr :ROCsParam.ptr)))
-
-
- (defmethod RO24STVvd-get-input-type ((vd RO24STV-vd))
- ;returns the current type of video input accepted by the board
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9038 csParamPtr))
- (ecase (pref csParamPtr (:ROCsParam.csParam 0))
- (0 :NTSC)
- (1 :PAL)
- (2 :SECAM))))
-
-
- (defmethod RO24STVvd-get-LUMA-delay-compensation ((vd RO24STV-vd))
- ;returns the LUMA compensation value
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9051 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
-
- (defmethod RO24STVvd-mask-enable-p ((vd RO24STV-vd))
- ;returns whether the graphics/video mask is enabled
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9043 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
-
- (defmethod RO24STVvd-mask-readback-p ((vd RO24STV-vd))
- ;returns whether the graphics/video mask readback is enabled
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9042 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
-
- (defmethod RO24STVvd-get-max-destination-size ((vd RO24STV-vd))
- ;returns maximum size of the live video that can be digitized
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9059 csParamPtr))
- (make-point (pref csParamPtr (:ROCsParam.csParam 0))
- (pref csParamPtr (:ROCsParam.csParam 1)))))
-
- (defmethod RO24STVvd-prefileter-p ((vd RO24STV-vd))
- ;returns whether the prefilter is enabled
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9053 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO24STVvd-get-noise-reduction ((vd RO24STV-vd))
- ;returns the vertical noise reduction mode
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9052 csParamPtr))
- (ecase (pref csParamPtr (:ROCsParam.csParam 0))
- (0 :normal)
- (1 :searching)
- (2 :auto)
- (3 :bypassed))))
-
- (defmethod RO24STVvd-redad-DMSD ((vd RO24STV-vd) register)
- ;returns the value of the specified Digital Multi-Standard Decoder chip
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) register))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9041 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 1))))
-
- (defmethod RO24STVvd-red-inhibited-p ((vd RO24STV-vd))
- ;returns t if the red video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9019 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO24STVvd-green-inhibited-p ((vd RO24STV-vd))
- ;returns t if the green video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9020 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO24STVvd-blue-inhibited-p ((vd RO24STV-vd))
- ;returns t if the blue video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9021 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
-
- ;; a modest example
-
- (oou-dependencies :video-digitizer-svm
- :Resources-u)
-
- (open-res-file "oou:MCLs-funniest-home-videos;RO24STV-driver.rsrc")
-
- (defclass vsview (video-digitizer-svm simple-view) () )
-
-
- (progn
- (setf *test-w*
- (make-instance 'window
- :window-type :document
- :view-position #@(10 40)
- :view-size #@(320 300)
- :window-title "video demo"
- :color-p t
- ))
- (add-subviews *test-w* (make-instance 'vsview
- :view-position #@(10 10)
- :view-size #@(300 250)
- :view-nick-name :vview
- :digitizer-class 'RO24STV-vd
- )))
-
- (start-digitizing (view-named :vview *test-w*))
-
- (stop-digitizing (view-named :vview *test-w*))
-
- |#