clamp.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /****************************************************************************
  2. *
  3. * Module Title : clamp.c
  4. *
  5. * Description : c
  6. *
  7. * AUTHOR : Jim Bankoski
  8. *
  9. *****************************************************************************
  10. * Revision History
  11. *
  12. * 1.09 YWX 26-Sep-01 Changed the default bandHeight from 5 to 4
  13. * 1.08 YWX 23-Jul-00 Changed horizontal scaling function names
  14. * 1.07 JBB 04 Dec 00 Added new Center vs Scale Bits
  15. * 1.06 YWX 01-Dec-00 Removed bi-cubic scale functions
  16. * 1.05 YWX 18-Oct-00 Added 1-2 scale functions
  17. * 1.04 YWX 11-Oct-00 Added ratio check to determine scaling or centering
  18. * 1.03 YWX 09-Oct-00 Added functions that do differen scaling in horizontal
  19. * and vertical directions
  20. * 1.02 YWX 04-Oct-00 Added 3-5 scaling functions
  21. * 1.01 YWX 03-Oct-00 Added a set of 4-5 scaling functions
  22. * 1.00 JBB 15 Sep 00 New Configuration baseline.
  23. *
  24. *****************************************************************************
  25. */
  26. /****************************************************************************
  27. * Header Files
  28. *****************************************************************************
  29. */
  30. #include "postp.h"
  31. #include <stdio.h>
  32. /****************************************************************************
  33. * Imported
  34. *****************************************************************************
  35. */
  36. void ClampLevels_C(
  37. POSTPROC_INSTANCE *pbi,
  38. INT32 BlackClamp, // number of values to clamp from 0
  39. INT32 WhiteClamp, // number of values to clamp from 255
  40. UINT8 *Src, // reconstruction buffer : passed in
  41. UINT8 *Dst // postprocessing buffer : passed in
  42. )
  43. {
  44. unsigned char clamped[255];
  45. int width = pbi->HFragments*8;
  46. int height = pbi->VFragments*8; // Y plane will be done in two passes
  47. UINT8 *SrcPtr = Src + pbi->ReconYDataOffset;
  48. UINT8 *DestPtr = Dst + pbi->ReconYDataOffset;
  49. UINT32 LineLength = pbi->YStride * 2; // pitch is doubled for interlacing
  50. // set up clamping table so we can avoid ifs while clamping
  51. int i;
  52. for(i=0;i<255;i++)
  53. {
  54. if(i<BlackClamp)
  55. clamped[i] = BlackClamp;
  56. if(i>WhiteClamp)
  57. clamped[i] = WhiteClamp;
  58. }
  59. Block = 0;
  60. // clamping is for y only!
  61. for ( row = 0 ; row < height ; row ++)
  62. {
  63. for (col = 0; col < width ; col ++)
  64. {
  65. SrcPtr[col]=clamped[DestPtr[col]];
  66. }
  67. SrcPtr += LineLength;
  68. DestPtr += LineLength;
  69. }
  70. }
  71. /****************************************************************************
  72. * Module constants.
  73. *****************************************************************************
  74. */
  75. /****************************************************************************
  76. * Exported Global Variables
  77. *****************************************************************************
  78. */
  79. /****************************************************************************
  80. * Module Static Variables
  81. *****************************************************************************
  82. */