123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /****************************************************************************
- *
- * Module Title : clamp.c
- *
- * Description : Image pixel value clamping routines.
- *
- ***************************************************************************/
- /****************************************************************************
- * Header Files
- ****************************************************************************/
- #include "postp.h"
- /****************************************************************************
- *
- * ROUTINE : ClampLevels_C
- *
- * INPUTS : POSTPROC_INSTANCE *pbi : Pointer to post-processor instance.
- * INT32 BlackClamp, : Number of levels to clamp up from 0.
- * INT32 WhiteClamp, : Number of levels to clamp down from 255.
- * UINT8 *Src, : Pointer to input image to be clamped.
- * UINT8 *Dst : Pointer to clamped image.
- *
- * OUTPUTS : None.
- *
- * RETURNS : void
- *
- * FUNCTION : Clamps the pixel values in the input image at each
- * end of the 8-bit range.
- *
- * SPECIAL NOTES : BlackClamp/WhiteClamp are the number.of levels to
- * clamp at either end of the range. In particular, it
- * should be noted that WhiteClamp is _not_ the level
- * to clamp to at the high end of the range.
- *
- ****************************************************************************/
- void ClampLevels_C
- (
- POSTPROC_INSTANCE *pbi,
- INT32 BlackClamp,
- INT32 WhiteClamp,
- UINT8 *Src,
- UINT8 *Dst
- )
- {
- int i;
- int row,col;
- unsigned char clamped[256];
- int width = pbi->HFragments*8;
- int height = pbi->VFragments*8;
- UINT8 *SrcPtr = Src + pbi->ReconYDataOffset;
- UINT8 *DestPtr = Dst + pbi->ReconYDataOffset;
- UINT32 LineLength = pbi->YStride;
- // set up clamping table so we can avoid ifs while clamping
- for ( i=0; i<256; i++ )
- {
- clamped[i] = i;
- if ( i<BlackClamp )
- clamped[i] = BlackClamp;
- if ( i>(255-WhiteClamp) )
- clamped[i] = 255-WhiteClamp;
- }
- // clamping is for Y only!
- for ( row=0 ; row<height; row++ )
- {
- for ( col=0; col<width; col++ )
- SrcPtr[col] = clamped[DestPtr[col]];
- SrcPtr += LineLength;
- DestPtr += LineLength;
- }
- }
|