home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / compresn / dvpeg / src1b / jquant.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-28  |  1.9 KB  |  62 lines

  1. /*
  2.  * jquant2.c
  3.  *
  4.  * Copyright (C) 1991, 1992, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file contains 2-pass color quantization (color mapping) routines.
  9.  * These routines are invoked via the methods color_quant_prescan,
  10.  * color_quant_doit, and color_quant_init/term.
  11.  */
  12.  
  13. #include "jinclude.h"
  14.  
  15. #ifdef QUANT_2PASS_SUPPORTED
  16.  
  17.  
  18. #define Y_SCALE 2        /* scale Y distances up by this much */
  19.  
  20. #define MAXNUMCOLORS  (MAXJSAMPLE+1) /* maximum size of colormap */
  21.  
  22.  
  23. #ifndef HIST_Y_BITS        /* so you can override from Makefile */
  24. #define HIST_Y_BITS  6        /* bits of precision in Y histogram */
  25. #endif
  26. #ifndef HIST_C_BITS        /* so you can override from Makefile */
  27. #define HIST_C_BITS  5        /* bits of precision in Cb/Cr histogram */
  28. #endif
  29.  
  30. #define HIST_Y_ELEMS  (1<<HIST_Y_BITS) /* # of elements along histogram axes */
  31. #define HIST_C_ELEMS  (1<<HIST_C_BITS)
  32.  
  33. #define Y_SHIFT  (BITS_IN_JSAMPLE-HIST_Y_BITS)
  34. #define C_SHIFT  (BITS_IN_JSAMPLE-HIST_C_BITS)
  35.  
  36.  
  37. #ifndef BOX_Y_LOG        /* so you can override from Makefile */
  38. #define BOX_Y_LOG  (HIST_Y_BITS-3) /* log2(hist cells in update box, Y axis) */
  39. #endif
  40. #ifndef BOX_C_LOG        /* so you can override from Makefile */
  41. #define BOX_C_LOG  (HIST_C_BITS-3) /* log2(hist cells in update box, C axes) */
  42. #endif
  43.  
  44. #define BOX_Y_ELEMS  (1<<BOX_Y_LOG) /* # of hist cells in update box */
  45. #define BOX_C_ELEMS  (1<<BOX_C_LOG)
  46.  
  47. #define BOX_Y_SHIFT  (Y_SHIFT + BOX_Y_LOG)
  48. #define BOX_C_SHIFT  (C_SHIFT + BOX_C_LOG)
  49.  
  50.  
  51.   /* Nominal steps between cell centers ("x" in Thomas article) */
  52. #define STEP_Y  ((1 << Y_SHIFT) * Y_SCALE)
  53. #define STEP_C  (1 << C_SHIFT)
  54.  
  55. #ifdef EIGHT_BIT_SAMPLES
  56. typedef INT16 FSERROR;        /* 16 bits should be enough */
  57. #else
  58. typedef INT32 FSERROR;        /* may need more than 16 bits? */
  59. #endif
  60.  
  61.  
  62. #endif