Utility
[EDT Digital Video Library]


Detailed Description

Various utility subroutines.

Most pci dv utility routines have a dvu_ prefix. dvu_ subroutines are not necessarily specific to the EDT digital video hardware. For example, dvu_write_rasfile could concievably be used to write a raster file from any source, not just one captured by an EDT PCI DV board. As such, dvu_ subroutines do not operate on an PdvDev device handle in their parameter lists.

There are a few utility subroutines that don't take a PdvDev device handle but do have a pdv_ prefix, and may or may not have some PCI DV specificity.

The remaining pdv_ subroutines that do take a PdvDev device handle are tagged as utility subroutines because they do not fit any other category.


Defines

#define BI_BITFIELDS   3L
#define BI_RGB   0L
#define BI_RLE4   2L
#define BI_RLE8   1L
#define BYTE   unsigned char
#define DVUFATAL   PDVLIB_MSG_FATAL
#define DWORD   unsigned long
#define LONG   long
#define RAS_MAGIC   0x59a66a95
#define RMT_EQUAL_RGB   1
#define RMT_NONE   0
#define RT_STANDARD   1
#define WIDTHBYTES(bits)   (((bits) + 31) / 32 * 4)
#define WORD   unsigned short

Functions

 dvu_exp_histeq (u_char *src, u_char *dst, int size, int depth, int cutoff)
 Perform a histogram equalization on an image, with cutoff (experimental).
void dvu_free_tables ()
 dvu_free_window (dvu_window *w)
 dvu_histeq (u_char *src, u_char *dst, int size, int depth)
 Perform a histogram equalization on an image.
dvu_window * dvu_init_window (u_char *data, int sx, int sy, int dx, int dy, int xdim, int ydim, int depth)
 dvu_load_lookup (char *filename, int depth)
void dvu_long_to_charbuf (unsigned int val, u_char *buf)
 dvu_lookup (u_char *src, u_char *dst, int size, int depth)
void dvu_perror (char *str)
dvu_window * dvu_read_window (char *fname)
dvu_window * dvu_reset_window (dvu_window *s, u_char *data, int sx, int sy, int dx, int dy)
 dvu_save_lookup (char *filename, int depth)
 dvu_winscale (dvu_window *wi, dvu_window *bi, int minbyte, int maxbyte, int doinit)
 dvu_word2byte (u_short *wbuf, u_char *bbuf, int count, int depth)
 dvu_word2byte_with_stride (u_short *wbuf, u_char *bbuf, int wstride, int bstride, int xsize, int ysize, int depth)
 dvu_wordscale (u_short *words, u_char *bytes, int count, int minbyte, int maxbyte, int doinit)
int dvu_write_bmp (char *fname, u_char *buffer, int width, int height)
 Writes an 8-bit per pixel data buffer as a grayscale Windows bitmap file.
int dvu_write_bmp_24 (char *fname, u_char *buffer, int width, int height)
 Writes a 24-bit per pixel RGB data buffer as a Windows bitmap file.
 dvu_write_image (char *fname, u_char *addr, int x_size, int y_size, int istride)
 Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform), with stride.
 dvu_write_image24 (char *fname, u_char *addr, int x_size, int y_size, int istride)
 Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file, with stride.
int dvu_write_rasfile (char *fname, u_char *addr, int x_size, int y_size)
 Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform).
int dvu_write_rasfile16 (char *fname, u_char *addr, int x_size, int y_size, int depth_bits)
 converts 1 band, 10-16 bit image to a sun raster format file and writes to a file.
 dvu_write_rasfile24 (char *fname, u_char *addr, int x_size, int y_size)
 Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file.
int dvu_write_raw (int imagesize, u_char *imagebuf, char *fname)
 Writes a 24-bit per pixel RGB data buffer as a raw data file (no formatting).
 dvu_write_window (char *fname, dvu_window *w)
int pdv_access (char *fname, int perm)
 Determines file access independent of operating system.
uchar_t * pdv_alloc (int size)
 Convenience routine to allocate memory in a system-independent way.
int pdv_bytes_per_line (int width, int depth)
 Returns bytes per line based on width and bit depth, including depth < 8.
int pdv_cl_camera_connected (PdvDev *pdv_p)
 Checks whether a camera is connected and turned on.
void pdv_free (uchar_t *ptr)
 Convenience routine to free the memory allocated with pdv_alloc.
int pdv_is_atmel (PdvDev *pdv_p)
 Infers that this device is connected to is an Atmel camera, from settings from the loaded camera config file.
int pdv_is_cameralink (PdvDev *pdv_p)
 Infers that this device is connected to is a Camera Link camera (as opposed to RS-422 or LVDS parallel), based on settings from the loaded camera config file.
int pdv_is_dvc (PdvDev *pdv_p)
 Infers that this device is connected to is a DVC camera, from settings from the loaded camera config file.
int pdv_is_hamamatsu (PdvDev *pdv_p)
 Infers that this device is connected to is a Hamamatsu camera, from settings from the loaded camera config file.
int pdv_is_kodak_i (PdvDev *pdv_p)
 Infer if it's a Redlake (formerly Roper, formerly Kodak) 'i' camera from the serial settings.
int pdv_is_simulator (PdvDev *pdv_p)
 Infers that this device is a simulator -- either a PCI DV CLS board, or a PCIe DV C-Link with simulator FPGA loaded.
void pdv_perror (char *err)
 Formats and prints a system error.
 ten2one (u_short *wbuf, u_char *bbuf, int count)

Variables

int Pdv_debug


Function Documentation

dvu_exp_histeq ( u_char *  src,
u_char *  dst,
int  size,
int  depth,
int  cutoff 
)

Perform a histogram equalization on an image, with cutoff (experimental).

Parameters:
src source buffer
dst destination buffer
size size in pixels
depth depth in bits
cutoff histogram cutoff

Definition at line 962 of file libdvu.c.

dvu_histeq ( u_char *  src,
u_char *  dst,
int  size,
int  depth 
)

Perform a histogram equalization on an image.

Parameters:
src source buffer
dst destination buffer
size size in pixels
depth depth in bits

Definition at line 806 of file libdvu.c.

int dvu_write_bmp ( char *  fname,
u_char *  buffer,
int  width,
int  height 
)

Writes an 8-bit per pixel data buffer as a grayscale Windows bitmap file.

Example

 int err=dvu_write_bmp("file.bmp", buf_p, 
           pdv_get_width(pdv_p),
           pdv_get_height(pdv_p)
         );

Parameters:
fname filename
buffer data buffer, one byte per pixel
width number of pixels (bytes) per line
height number of lines in the image
Returns:
0 on success, -1 on failure.
See also:
dvu_write_bmp_24

Definition at line 1263 of file libdvu.c.

int dvu_write_bmp_24 ( char *  fname,
u_char *  buffer,
int  width,
int  height 
)

Writes a 24-bit per pixel RGB data buffer as a Windows bitmap file.

Example

 int err=dvu_write_bmp("file.bmp", buf_p, pdv_get_width(pdv_p),
 pdv_get_height(pdv_p);

Parameters:
fname filename
buffer data buffer, one byte per pixel
width number of pixels (bytes) per line
height number of lines in the image
Returns:
0 on success, -1 on failure.
See also:
dvu_write_bmp

Definition at line 1412 of file libdvu.c.

dvu_write_image ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  istride 
)

Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform), with stride.

This function can be used to output a partial image. For example, to output the top left 100x100 pixels of the image, specify x_size of 100 and y_size * 100, and an istride of the actual width of the image.

Note:
Use dvu_write_rasfile to output a full image in the most efficient way.
Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
istride number of pixels (bytes) to skip from one the beginning of one line to the beginning of the next (this should just be the image width, unless you want something weird like a diagonally skewed image).
Returns:
0 on success, -1 on failure

Definition at line 494 of file libdvu.c.

dvu_write_image24 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  istride 
)

Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file, with stride.

Note:
To output a full image in the most efficient way, use dvu_write_rasfile24.
Parameters:
fname the name of output file
addr data buffer, three bytes per pixel (RGB)
x_size number of pixels per line
y_size number of lines in the image
istride number of pixels to skip between sucessive lines
Example
 // skip every other line
 int err=dvu_write_image24("file.ras", buf_p, 
            pdv_get_width(pdv_p),
            pdv_get_height(pdv_p) / 2, 
            pdv_get_width(pdv_p)
         );

Returns:
0 on success, -1 on failure

Definition at line 623 of file libdvu.c.

int dvu_write_rasfile ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size 
)

Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform).

Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
Returns:
0 on success, -1 on failure

Definition at line 190 of file libdvu.c.

int dvu_write_rasfile16 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  depth_bits 
)

converts 1 band, 10-16 bit image to a sun raster format file and writes to a file.

Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
depth_bits number of bits per pixel
Returns:
0 on success, -1 on failure

Definition at line 262 of file libdvu.c.

dvu_write_rasfile24 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size 
)

Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file.

Parameters:
fname file name
addr data buffer, three bytes per pixel (RGB)
x_size number of pixels per line
y_size number of lines in the image
Returns:
0 on success, -1 on failure

Definition at line 555 of file libdvu.c.

int dvu_write_raw ( int  imagesize,
u_char *  imagebuf,
char *  fname 
)

Writes a 24-bit per pixel RGB data buffer as a raw data file (no formatting).

Example

 int err=dvu_write_raw(pdv_get_imagesize(pdv_p), buf_p, "file.raw");

Parameters:
imagesize number of bytes in the image.
imagebuf pointer to image data buffer.
fname output file name.
Returns:
0 on success, -1 on failure.

Definition at line 1527 of file libdvu.c.

int pdv_access ( char *  fname,
int  perm 
)

Determines file access independent of operating system.

This a convenience routine that maps to access() on Unix/Linux systems, and _access on Windows systems.

Parameters:
fname path name of the file to check access of.
perm permission flag(s) to test for. See access() (Unix/Linux) or _access (Windows) for valid arguments.
Example
 if (pdv_access("file.ras", F_OK))
     print("Warning: about to overwrite file %s/n", "file.ras");

Returns:
0 on success, -1 on failure.

Definition at line 7016 of file libpdv.c.

uchar_t* pdv_alloc ( int  size  ) 

Convenience routine to allocate memory in a system-independent way.

The buffer returned is page aligned. Page alignment is required for some EDT image routines and always preferred. This function uses VirtualAlloc on Windows NT/2000/XP systems, or valloc on UNIX-based systems.

Example

        unsigned char *buf = pdv_alloc(pdv_image_size(pdv_p));

Parameters:
size the number of bytes of memory to allocate
Returns:
The address of the allocated memory, or NULL on error. If NULL, use pdv_perror to print the error.
See also:
pdv_free

Definition at line 6374 of file libpdv.c.

int pdv_bytes_per_line ( int  width,
int  depth 
)

Returns bytes per line based on width and bit depth, including depth < 8.

Parameters:
width pixels per line
depth bits per pixel
Returns:
bytes per line

Definition at line 612 of file libpdv.c.

int pdv_cl_camera_connected ( PdvDev pdv_p  ) 

Checks whether a camera is connected and turned on.

Looks for an active (changing) pixel clock from the camera, and returns 1 if detected.

Note:
This subroutine only works on EDT Camera Link boards, and only those that have base mode firmware (pdvcamlk or pdvcamlk2 11/02/2006 (rev 34) or later.
Returns:
1 if active pixel clock is detected, 0 if not detected OR not supported (not camera link). Will also return 0 if firmware does not support this feature (see above).

Definition at line 8973 of file libpdv.c.

void pdv_free ( uchar_t *  ptr  ) 

Convenience routine to free the memory allocated with pdv_alloc.

Parameters:
ptr Address of memory buffer to free.

Definition at line 6387 of file libpdv.c.

int pdv_is_atmel ( PdvDev pdv_p  ) 

Infers that this device is connected to is an Atmel camera, from settings from the loaded camera config file.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for Atmel camera, 0 otherwise.
See also:
pdv_get_camera_class

Definition at line 7800 of file libpdv.c.

int pdv_is_cameralink ( PdvDev pdv_p  ) 

Infers that this device is connected to is a Camera Link camera (as opposed to RS-422 or LVDS parallel), based on settings from the loaded camera config file.

Generally useful only for applications that may use both Camera Link and the (older) AIA cameras, and that need to differentiate between the two.

Parameters:
pdv_p device handle returned by pdv_open
Returns:
1 if Camera Link, 0 otherwise

Definition at line 8743 of file libpdv.c.

int pdv_is_dvc ( PdvDev pdv_p  ) 

Infers that this device is connected to is a DVC camera, from settings from the loaded camera config file.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for DVC camera, else 0.

Definition at line 8332 of file libpdv.c.

int pdv_is_hamamatsu ( PdvDev pdv_p  ) 

Infers that this device is connected to is a Hamamatsu camera, from settings from the loaded camera config file.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for Hamamatsu camera, else 0.

Definition at line 7818 of file libpdv.c.

int pdv_is_kodak_i ( PdvDev pdv_p  ) 

Infer if it's a Redlake (formerly Roper, formerly Kodak) 'i' camera from the serial settings.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if pdv_p appears setup for Redlake, 0 otherwise.

Definition at line 7776 of file libpdv.c.

int pdv_is_simulator ( PdvDev pdv_p  ) 

Infers that this device is a simulator -- either a PCI DV CLS board, or a PCIe DV C-Link with simulator FPGA loaded.

Parameters:
pdv_p device handle returned by pdv_open
Returns:
1 if a simulator, 0 otherwise

Definition at line 8773 of file libpdv.c.

void pdv_perror ( char *  err  ) 

Formats and prints a system error.

Convenience function to format and print a system error. In UNIX implementations, the routine just turns around and makes a perror system call, with the errstr argument. NT implementations format and print the last error using GetLastError.

Definition at line 6319 of file libpdv.c.


Generated on Mon May 12 16:39:11 2008 by  doxygen 1.5.1