2
0

tif_codec.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */
  2. /*
  3. * Copyright (c) 1988-1997 Sam Leffler
  4. * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  5. *
  6. * Permission to use, copy, modify, distribute, and sell this software and
  7. * its documentation for any purpose is hereby granted without fee, provided
  8. * that (i) the above copyright notices and this permission notice appear in
  9. * all copies of the software and related documentation, and (ii) the names of
  10. * Sam Leffler and Silicon Graphics may not be used in any advertising or
  11. * publicity relating to the software without the specific, prior written
  12. * permission of Sam Leffler and Silicon Graphics.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  15. * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  16. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  17. *
  18. * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  19. * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20. * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
  22. * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  23. * OF THIS SOFTWARE.
  24. */
  25. /*
  26. * TIFF Library
  27. *
  28. * Builtin Compression Scheme Configuration Support.
  29. */
  30. #include "tiffiop.h"
  31. static int NotConfigured(TIFF*, int);
  32. #ifndef LZW_SUPPORT
  33. #define TIFFInitLZW NotConfigured
  34. #endif
  35. #ifndef PACKBITS_SUPPORT
  36. #define TIFFInitPackBits NotConfigured
  37. #endif
  38. #ifndef THUNDER_SUPPORT
  39. #define TIFFInitThunderScan NotConfigured
  40. #endif
  41. #ifndef NEXT_SUPPORT
  42. #define TIFFInitNeXT NotConfigured
  43. #endif
  44. #ifndef JPEG_SUPPORT
  45. #define TIFFInitJPEG NotConfigured
  46. #endif
  47. #ifndef OJPEG_SUPPORT
  48. #define TIFFInitOJPEG NotConfigured
  49. #endif
  50. #ifndef CCITT_SUPPORT
  51. #define TIFFInitCCITTRLE NotConfigured
  52. #define TIFFInitCCITTRLEW NotConfigured
  53. #define TIFFInitCCITTFax3 NotConfigured
  54. #define TIFFInitCCITTFax4 NotConfigured
  55. #endif
  56. #ifndef JBIG_SUPPORT
  57. #define TIFFInitJBIG NotConfigured
  58. #endif
  59. #ifndef ZIP_SUPPORT
  60. #define TIFFInitZIP NotConfigured
  61. #endif
  62. #ifndef PIXARLOG_SUPPORT
  63. #define TIFFInitPixarLog NotConfigured
  64. #endif
  65. #ifndef LOGLUV_SUPPORT
  66. #define TIFFInitSGILog NotConfigured
  67. #endif
  68. #ifndef LZMA_SUPPORT
  69. #define TIFFInitLZMA NotConfigured
  70. #endif
  71. /*
  72. * Compression schemes statically built into the library.
  73. */
  74. #ifdef VMS
  75. const TIFFCodec _TIFFBuiltinCODECS[] = {
  76. #else
  77. TIFFCodec _TIFFBuiltinCODECS[] = {
  78. #endif
  79. { "None", COMPRESSION_NONE, TIFFInitDumpMode },
  80. { "LZW", COMPRESSION_LZW, TIFFInitLZW },
  81. { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits },
  82. { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan },
  83. { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT },
  84. { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG },
  85. { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG },
  86. { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE },
  87. { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW },
  88. { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 },
  89. { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 },
  90. { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG },
  91. { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP },
  92. { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },
  93. { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
  94. { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
  95. { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
  96. { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA },
  97. { NULL, 0, NULL }
  98. };
  99. static int
  100. _notConfigured(TIFF* tif)
  101. {
  102. const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
  103. char compression_code[20];
  104. sprintf( compression_code, "%d", tif->tif_dir.td_compression );
  105. TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
  106. "%s compression support is not configured",
  107. c ? c->name : compression_code );
  108. return (0);
  109. }
  110. static int
  111. NotConfigured(TIFF* tif, int scheme)
  112. {
  113. (void) scheme;
  114. tif->tif_fixuptags = _notConfigured;
  115. tif->tif_decodestatus = FALSE;
  116. tif->tif_setupdecode = _notConfigured;
  117. tif->tif_encodestatus = FALSE;
  118. tif->tif_setupencode = _notConfigured;
  119. return (1);
  120. }
  121. /************************************************************************/
  122. /* TIFFIsCODECConfigured() */
  123. /************************************************************************/
  124. /**
  125. * Check whether we have working codec for the specific coding scheme.
  126. *
  127. * @return returns 1 if the codec is configured and working. Otherwise
  128. * 0 will be returned.
  129. */
  130. int
  131. TIFFIsCODECConfigured(uint16 scheme)
  132. {
  133. const TIFFCodec* codec = TIFFFindCODEC(scheme);
  134. if(codec == NULL) {
  135. return 0;
  136. }
  137. if(codec->init == NULL) {
  138. return 0;
  139. }
  140. if(codec->init != NotConfigured){
  141. return 1;
  142. }
  143. return 0;
  144. }
  145. /*
  146. * Local Variables:
  147. * mode: c
  148. * c-basic-offset: 8
  149. * fill-column: 78
  150. * End:
  151. */