Appendix E. Example Programs

This appendix introduces and gives the code for Sirius Video example VL programs:

The directory /usr/dmedia/bin/SIRIUS contains the Sirius Video executables explained in this chapter. To follow instructions in this chapter, switch to this directory.


Note: For general guidelines in using the VL for Sirius Video, see Chapter 2, “Programming Sirius Video,” earlier in this guide.

Source for these programs is


Note: If Sirius Video and Multi-Channel Option are installed on the same VME section of your system, Sirius Video is unable to use utilities that send graphics to video. These utilities are gfxvidkeytovid, gfxtogfx, gfxtovid, and gfxvidtovid. The first of these utilities is discussed in this appendix; the others are discussed in the Video Library section of the Digital Media Programming Guide.

These example programs construct VL paths between the nodes in their names and demonstrate how to control Sirius Video features. All but the last of these programs require that the Sirius Video board be attached to a system with RealityEngine graphics via the CPI and DG1 options.


Note: To keep these examples as simple as possible, event handling is not implemented.


sir_memtovid.c

sir_memtovid is the primary means of transferring a frame from memory to the video output. It uses the Video Library to route a sequence of RGB images through the Sirius Video board to the video output in a burst.

Video output timing and format must be set beforehand in vcp. The files are read in numerically increasing order, using the base filename prefix supplied on the command line. The first filename generated is either <prefix>_00000.rgb or <prefix>_00000.rgba, depending on whether or not alpha was requested. The default starting file number 00000 can be changed with the -N option argument.

Usage:

sir_memtovid [-ac# -F# -hln# -N# -pPr# -t# -T] <base filename prefix>

where

-a  

reads the files along with the alpha information also

-c#  

specifies the number of frames to read and transfer

-F#  

gives the file format

  • 1: Silicon Graphics RGB frames (the default)

  • 2: Silicon Graphics RGB fields

-h 

prints a usage message

-l 

runs the frames continuously in a movie loop

-n# 

specifies the video device to be used, as reported by vlinfo

-N#  

changes the default file naming order to begin with the specified number

-p  

causes the program to pause at the end of the transfer until a character is typed, at which point vlEndTransfer() is called and the path is destroyed

-P  

prefills the ring buffer before the start of the transfer with as much data as it can hold, which is useful for a triggered transfer

-r#  

specifies in frames the number of ring buffer elements to allocate; the maximum of 100 fields (50 frames) can be increased if you recompile the source and change the maximum

-t#  

specifies the external trigger source (GPI or V-LAN input) that initiates the output DMA sequence

-T 

requests that a pair of GPI notify events be generated at the start (GPI_1 output) and end (GPI_2 output) of the transfer}

sir_vidtomem.c

sir_vidtomem sends frames from the video output to memory. It can write frames to graphics via lrectwrite or to disk as disk files. This program uses the Video Library to grab a sequence of still video images through the Sirius Video board into host memory, and optionally to graphics or disk files.

Video input timing and format must be set beforehand in vcp. The files are generated in numerically increasing order, using the base filename prefix supplied on the command line. The first filename generated is either <prefix>_00000.rgb or <prefix>_00000.rgba, depending on whether or not alpha was requested. The default starting file number 00000 can be changed with the -N option argument.

Usage:

sir_vidtomem [-ac# -dF# -hn# -N# -r# -t# -v# -w] <base filename prefix>

where

-a  

also saves the alpha channel

-c#  

specifies the number of frames to transfer and write

-d 

displays the captured video data to graphics (field data is line-replicated)

-F#  

gives the file format

  • 1: Silicon Graphics RGB frames (the default)

  • 2: Silicon Graphics RGB fields

-h 

prints a usage message

-n# 

specifies the video device to be used, as reported by vlinfo

-N#  

changes the default file naming order to begin with the specified number

-r#  

specifies in frames the number of ring buffer elements to allocate; the maximum of 100 fields (50 frames) can be increased if you recompile the source and change the maximum

-t#  

specifies the external trigger source (GPI or V-LAN input) that initiates the input DMA sequence

-T 

requests that a pair of GPI notify events be generated at the start (GPI_1 output) and end (GPI_2 output) of the transfer

-v#  

sets the input video node to be used, overriding the default set via vcp; set timing and format for the node in vcp

-w  

inhibits the file-writing operation so that you can view the video on the graphics screen with the -d option, with no file I/O overhead}

sir_vlan.c

sir_vlan, a Sirius Video configuration and command tool, performs the basic V-LAN operations of initializing the on-board V-LAN controller, querying controller status, and sending V-LAN commands to it.

Usage:

ir_vlan [-n <video device number>] [-achiqr]

where

-a  

checks the V-LAN initialization status

-c  

executes a single V-LAN command

-h 

prints usage information

-i 

initializes the V-LAN subsystem, which must be done after you select the timing for video output and before any other V-LAN commands

-q 

causes operation in quiet mode, so that no status messages are printed

-r 

executes commands repeatedly; it must be used with the -c flag}

gfxvidkeytovid.c

This demo program for the chroma key generator sets input, video output, grab area, blender functions, values, ranges, and softness parameters for each component (A, B, and C). It also creates special keys in a proprietary color space.


Note: If Sirius Video and Multi-Channel Option are installed on the same VME section of your system, Sirius Video is unable to use this program.

Usage:

gfxvidkeytovid [-a] [-b] [-c] [-r] [-s][-v#] [-x#] [-y#] [-w#] [-h#] [-n#]

where

-a  

is the value of the R or V component

-b 

is the value of the G or Y component

-c  

is the value of the B or U component

-r 

is the range for all components

-s  

is the softness value for all components

-v# 

is the video input device number, as reported by vlinfo

-x#  

is the left position for the grab area

-y# 

is the top position for the grab area

-w#  

is the width of the grab area

-h# 

is the height of the grab area

-n# 

is the video output device number, as reported by vlinfo}

vidtogfx.c

vidtogfx continuously captures a stream of live video from a video source and displays it via the Iris GL in a window on the attached RealityEngine graphics display.

The video source can be selected via a command-line option, or via the default input device control on vcp(1). For the -v option, the valid video source numbers and their mappings can be seen from the output of vlinfo(1).

Usage:

vidtogfx [-n <video device number>] [-v <input>]

where -n# selects the video device to be used, as reported by vlinfo, and -v# specifies the input stream as reported by vlinfo.}

vidtotex.c

vidtotex continuously captures a stream of live video from a video source and repeatedly loads it into an Iris GL texture map. Those texture maps are then used to texture a polygon in an Iris GL window on the RealityEngine graphics display, which gives the appearance of a pane of live video.

The video source can be selected via a command-line option, or via the default input device control on vcp(1). For the -v option, the valid video source numbers and their mappings can be seen from the output of vlinfo(1).

Usage:

vidtotex [-n <video device number>] [-v <input>]

where -n# selects the video device to be used, as reported by vlinfo, and -v# specifies the input stream as reported by vlinfo. The default device is 0, the first Sirius board detected by the kernel. The devices are numbered in the order that they are probed and detected by the kernel.


Note: The demo program /usr/dmedia/bin/SIRIUS/shatter takes this video texturing ability somewhat further and demonstrates a live video textured polygon that you can scale, rotate, and shatter as if it were a pane of glass.


vidtovid.c

vidtovid continuously captures a stream of live video from a video source and displays it on the Sirius Video output. The video source can be selected via a command line option, or via the default input device control on vcp(1). For the -v option, the valid video source numbers and their mappings can be seen from the output of vlinfo(1).

Usage:

vidtovid [-n <video device number>] [-v <input>] 

where -n# selects the video device to be used, as reported by vlinfo, and -v# specifies the input stream as reported by vlinfo. The default device is 0, the first Sirius board detected by the kernel. The devices are numbered in the order that they are probed and detected by the kernel.}