cl_cosmo(3dm) cl_cosmo(3dm)
cl_cosmo - Cosmo Compress JPEG Accelerator (in the Compression Library)
#include <dmedia/cl.h>
Cosmo Compress is an optional hardware accelerator for JPEG image
compression. The programming interface to Cosmo is via the standard
Compression Library. For overviews of the JPEG standard and the CL API,
see jpeg(4) and CLintro(3dm).
Cosmo Compress implements a subset of the JPEG standard optimized for
video originated images. This subset is baseline JPEG, interleaved
YCrCb, 8-bits per component. Cosmo Compress is capable of compressing
and decompressing to and from memory, or to and from a special video
connection to IndyVideo, Galileo Video, or Indigo2 Video.
Cosmo also supports an arbitrary scale down and clip of images being
decompressed. This scaling happens without any performance penalty and
produces high quality results.
PROGRAMMING COSMO COMPRESS [Toc] [Back] Cosmo Compress is programmed via the Compression Library (CL) utilizing
the base CL API as well as JPEG-specific and Cosmo-specific parameters.
USING COSMO [Toc] [Back]
The Cosmo Compress JPEG Codec is invoked by specifying CL_JPEG_COSMO as
the scheme argument to clOpenCompressor. Only one application can have
Cosmo open at a time. An error will be returned to the program if
another application has Cosmo open.
SETTING UP TRANSFERS [Toc] [Back]
Cosmo is capable of four different modes of operation. External video
can be compressed to a memory buffer, a memory buffer can be decompressed
and sent out to external video, an image in memory can be compressed to
memory, and a compressed image can be decompressed to memory. Video data
is always treated as non-interleaved fields.
Memory to memory transfers may be initiated using the standard CL calls.
The size of the uncompressed image must not be larger than a PAL video
field (768x288). The uncompressed data format must be CL_FORMAT_XBGR.
Transfers to and from external video should use the CL direct buffered
interface specifying CL_EXTERNAL_DEVICE as the frameBuffer parameter to
clCompress or clDecompress. Additionally, the call to clDecompress or
clCompress should either be made by a separate thread within the program
or with CL_CONTINUOUS_NONBLOCK as the frame count parameter since it will
not return until the transfer is complete.
Page 1
cl_cosmo(3dm) cl_cosmo(3dm)
PARAMETERS : GENERAL CL
The following general CL parameters are useful for Cosmo. For more
information, see CLintro(3dm).
CL_IMAGE_WIDTH [Toc] [Back]
Uncompressed image width, in pixels. When transfering to or from
external video using NTSC timing, the width must be 640. When
transfering to or from external video using PAL timing, the width
must be 768. The maximum width in memory to memory transfers is
768. The width must always be a multiple of 16. With IndyVideo601
option or Galileo on Indigo2, both CCIR 525 and CCIR 625 sizes are
supported.
CL_IMAGE_HEIGHT [Toc] [Back]
Uncompressed image height in pixels. Since Cosmo deals in fields
which represent every other line of a video frame, the image height
is half of the full frame height. The height must always be a
multiple of 8. The external video port on Cosmo transmits 243 lines
per field in NTSC mode which is not a multiple of 8. Applications
should therefore either specify 240 or 248 as the height for NTSC.
The height for PAL should be 288. With IndyVideo601 option or
Galileo on Indigo2, both CCIR 525 and CCIR 625 sizes are supported.
CL_INTERNAL_IMAGE_WIDTH [Toc] [Back]
Width of compressed image. This is normally the same as
CL_IMAGE_WIDTH, but may be different when scaling is used. Cosmo
has two types of image scaling capability. When decompressing from
memory to memory, the image may be downsized from the original.
This mode of scaling is enabled by setting CL_IMAGE_WIDTH to the
desired reduced size while setting CL_INTERNAL_IMAGE_WIDTH to the
original size contained in the JPEG data. When compressing or
decompressing from external video, Cosmo supports a limited form of
scaling. If the CL_IMAGE_WIDTH is set to the width of the video
field (either 640 or 768), and CL_INTERNAL_IMAGE_WIDTH is set to one
half of that (either 320 or 384), then Cosmo will scale the image by
a factor of two. It is only necessary to set this parameter if one
of these two types of scaling is desired.
CL_INTERNAL_IMAGE_HEIGHT [Toc] [Back]
Height of compressed image. This is normally the same as
CL_IMAGE_HEIGHT, but may be different when scaling is used. See the
discussion of CL_INTERNAL_IMAGE_WIDTH above.
CL_FORMAT [Toc] [Back]
When decompressing or compressing to or from memory, Cosmo only
recognizes 32-bit RGB pixels which are called CL_FORMAT_XBGR by the
CL.
CL_ALGORITHM_ID [Toc] [Back]
The algorithm identifier for Cosmo is CL_JPEG_COSMO.
Page 2
cl_cosmo(3dm) cl_cosmo(3dm)
CL_ORIENTATION [Toc] [Back]
Cosmo treats images as ``top down'' and has no support for flipping
images.
CL_ENABLE_IMAGEINFO [Toc] [Back]
Setting this parameter to ``TRUE'' enables the
clGetNextImageInfo(3dm) CL function which can be used to retrieve
time stamp and other information about compressed fields. In the
case of Cosmo compressing from external video, the time stamp
returned represents the time at which the first line of the
uncompressed field arrived at the Cosmo board.
PARAMETERS : JPEG
The following JPEG parameters may also be used. See cl_jpeg(3dm) for
descriptions.
CL_JPEG_QUALITY_FACTOR [Toc] [Back]
CL_JPEG_QUANTIZATION_TABLES [Toc] [Back]
CL_JPEG_STREAM_HEADERS [Toc] [Back]
PARAMETERS : COSMO
These parameters are specific to Cosmo.
CL_COSMO_VIDEO_TRANSFER_MODE [Toc] [Back]
Type: CL_ENUM_VALUE
When transfering to or from external video, the video
may be played continuously or single stepped a field or frame
at a time. Cosmo has three different transfer modes.
CL_COSMO_VIDEO_TRANSFER_AUTO_1_FIELD, and
CL_COSMO_VIDEO_TRANSFER_AUTO_2_FIELD put the board in continuous
mode. CL_COSMO_VIDEO_TRANSFER_MANUAL puts the board in single step
mode. In any mode, the frame output is either composed of (every)
single field replicated twice, or two different fields.
CL_COSMO_VIDEO_MANUAL_CONTROL [Toc] [Back]
Type: CL_ENUM_VALUE
When the video transfer mode is set to manual, the output is
advanced one step by setting this parameter to
CL_COSMO_VIDEO_MANUAL_ADVANCE. In order for the frame to actually
advance, there must be a decompressed frame in Cosmo's output queue.
CL_COSMO_CODEC_CONTROL [Toc] [Back]
Type: CL_ENUM_VALUE
Setting to CL_COSMO_STOP will cause compression or decompression
to halt. If clCompress or clDecompress had been called with
CL_CONTINUOUS_BLOCK, it will now return. If clCompress
or clDecompress had been called with CL_CONTINUOUS_NONBLOCK,
the associated thread will terminate.
Page 3
cl_cosmo(3dm) cl_cosmo(3dm)
CL_COSMO_VIDEO_INPUT_CONTROL [Toc] [Back]
This is used to control how the external video device sends
timing information to Cosmo. It is only needed when using Cosmo
with the IndyVideo/Galileo 601 Option. It may be set to either
CL_COSMO_VIDEO_INPUT_PORT0, or CL_COSMO_VIDEO_INPUT_PORT1.
CONNECTING TO VIDEO [Toc] [Back]
When using external video with Cosmo, special attention needs to be given
to the video synchronization setting of the video device. When
capturing, the video synchronization should be set to ``slave''. When
playing back, it should be set to either ``internal'' or ``genlock''.
Cosmo interfaces with the external video via two vl nodes, one for
sending video from Cosmo to the video board, and one for sending video
and timing information from the video board to Cosmo. When playing back
to external video, both nodes have to be used, one providing video timing
to Cosmo, the other connecting Cosmo output to the video device. Video
from IndyVideo/Galileo is sent on port 2 and video from Cosmo to
IndyVideo/Galileo is sent back on port 1.
The following will set play back from Cosmo, into a window with
simultaneous video output.
/*
* Assume svr is the server from vlOpenVideo(3),
* and dev is device number for the ``ev1'' device
* obtained via vlGetDeviceList(3).
*/
/*
* First, make sure the timing is set to internal
* or genlock
*/
devNode = vlGetNode( svr, VL_DEVICE, VL_ANY );
path = vlCreatePath( svr, dev, devNode, devNode );
vlSetupPaths( svr, &path, 1, VL_SHARE, VL_READ_ONLY );
vlGetControl( svr, path, devNode, VL_SYNC, &val );
if (val.intVal == VL_SYNC_SLAVE) {
val.intVal = VL_SYNC_INTERNAL;
vlSetControl( svr, path, devNode, VL_SYNC, &val );
}
vlDestroyPath(svr, path);
/*
* Now set up the video transfer paths
*/
cosmosrc = vlGetNode( svr, VL_SRC, VL_VIDEO, 1 );
cosmodrn = vlGetNode( svr, VL_DRN, VL_VIDEO, 2 );
videodrn = vlGetNode( svr, VL_DRN, VL_VIDEO, 0 );
windowdrn = vlGetNode( svr, VL_DRN, VL_SCREEN, VL_ANY );
Page 4
cl_cosmo(3dm) cl_cosmo(3dm)
path = vlCreatePath( svr, dev, cosmosrc, windowdrn );
vlAddNode( svr, path, videodrn );
vlAddNode( svr, path, cosmodrn );
vlSetupPaths( svr, &path, 1, VL_SHARE, VL_SHARE );
/*
* Set window for windowdrn
*/
val.intVal = windowId;
vlSetControl( svr, path, windowdrn, VL_WINDOW, &val );
vlBeginTransfer( svr, path, 0, NULL );
See galileo(7) and vl(3dm) for more information.
/usr/include/dmedia/cl.h
jpeg(4), CLintro(3dm), cl_jpeg(3dm),
vl(3dm), galileo(7)
PPPPaaaaggggeeee 5555 [ Back ]
|