2
0

iljpgencodeint.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: iljpgencodeint.h /main/3 1995/10/23 15:56:34 rswiston $ */
  24. /**---------------------------------------------------------------------
  25. ***
  26. *** (c)Copyright 1992 Hewlett-Packard Co.
  27. ***
  28. *** RESTRICTED RIGHTS LEGEND
  29. *** Use, duplication, or disclosure by the U.S. Government is subject to
  30. *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
  31. *** Technical Data and Computer Software clause in DFARS 252.227-7013.
  32. *** Hewlett-Packard Company
  33. *** 3000 Hanover Street
  34. *** Palo Alto, CA 94304 U.S.A.
  35. *** Rights for non-DOD U.S. Government Departments and Agencies are as set
  36. *** forth in FAR 52.227-19(c)(1,2).
  37. ***
  38. ***-------------------------------------------------------------------*/
  39. #ifndef ILJPGENCODEINT_H
  40. #define ILJPGENCODEINT_H
  41. #ifndef ILJPGENCODE_H
  42. #include "iljpgencode.h"
  43. #endif
  44. #ifndef ILJPGINT_H
  45. #include "iljpgint.h"
  46. #endif
  47. /* Private data for encoding JPEG (not JIF), e.g.
  48. _iljpgEncodeInit/Execute/Cleanup().
  49. */
  50. typedef struct {
  51. float *pScale; /* from DCTScaleTables[] */
  52. int horiFactor, vertFactor; /* copied from iljpgDataRec */
  53. long width, height; /* size of input buffer */
  54. int mcuXInc, mcuYInc; /* value to inc (x,y) by, each MCU */
  55. long x, y; /* where to fetch next MCU */
  56. int lastDC; /* DC from previous 8x8 block */
  57. } iljpgECompRec, *iljpgECompPtr;
  58. typedef struct {
  59. iljpgDataPtr pData; /* data passed to _iljpgEncodeInit() */
  60. float *DCTScaleTables[4]; /* owned by iljpgendct.c */
  61. iljpgPtr pHuffPriv; /* owned by iljpgenhuff.c */
  62. iljpgECompRec compData[ILJPG_MAX_COMPS]; /* owned by iljpgencode.c */
  63. } iljpgEncodePrivRec, *iljpgEncodePrivPtr;
  64. /* Called by iljpgEncodeInit() to scale the Q table pointed to by "pSrc"
  65. into "pDst", each a 64 entry table.
  66. */
  67. ILJPG_PRIVATE_EXTERN
  68. iljpgError _iljpgEnDCTScale (
  69. iljpgPtr pSrc,
  70. float *pDst
  71. );
  72. /* DCT encode the 64 int matrix pointed to by "pSrc", storing the results back
  73. into the same matrix. "pScale" must point to the 64 float scaled/clipped
  74. Q table, as setup by _iljpgEnDCTInit().
  75. */
  76. ILJPG_PRIVATE_EXTERN
  77. _iljpgEnDCT (
  78. int *pSrc,
  79. float *pScale
  80. );
  81. /* Called by iljpgEncodeInit() to init for Huffman encoding.
  82. */
  83. ILJPG_PRIVATE_EXTERN
  84. iljpgError _iljpgEnhuffInit (
  85. iljpgEncodePrivPtr pPriv
  86. );
  87. /* Called by iljpgEncodeCleanup() to cleanup after Huffman encoding.
  88. */
  89. ILJPG_PRIVATE_EXTERN
  90. iljpgError _iljpgEnhuffCleanup (
  91. iljpgEncodePrivPtr pPriv
  92. );
  93. /* Huffman encode an 8x8 block (already zig-zagged) from "pSrc" (array of
  94. 64 ints) out to "stream", for component index "comp". The DC component
  95. (pSrc[0]) must have already had the lastDC value subtracted from it.
  96. */
  97. ILJPG_PRIVATE_EXTERN
  98. iljpgError _iljpgEnhuffExecute (
  99. iljpgEncodePrivPtr pPriv,
  100. int comp,
  101. int *pSrc,
  102. ILJPG_ENCODE_STREAM stream
  103. );
  104. /* Flush out any bits left over from Huffman encoding.
  105. */
  106. ILJPG_PRIVATE_EXTERN
  107. iljpgError _iljpgEnhuffFlush (
  108. iljpgEncodePrivPtr pPriv,
  109. ILJPG_ENCODE_STREAM stream
  110. );
  111. #endif