roentgen b75cab
/* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Copyright (c) 1988-1997 Sam Leffler
roentgen b75cab
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
roentgen b75cab
 *
roentgen b75cab
 * Permission to use, copy, modify, distribute, and sell this software and 
roentgen b75cab
 * its documentation for any purpose is hereby granted without fee, provided
roentgen b75cab
 * that (i) the above copyright notices and this permission notice appear in
roentgen b75cab
 * all copies of the software and related documentation, and (ii) the names of
roentgen b75cab
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
roentgen b75cab
 * publicity relating to the software without the specific, prior written
roentgen b75cab
 * permission of Sam Leffler and Silicon Graphics.
roentgen b75cab
 * 
roentgen b75cab
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
roentgen b75cab
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
roentgen b75cab
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
roentgen b75cab
 * 
roentgen b75cab
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
roentgen b75cab
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
roentgen b75cab
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
roentgen b75cab
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
roentgen b75cab
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
roentgen b75cab
 * OF THIS SOFTWARE.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * TIFF Library
roentgen b75cab
 *
roentgen b75cab
 * Builtin Compression Scheme Configuration Support.
roentgen b75cab
 */
roentgen b75cab
#include "tiffiop.h"
roentgen b75cab
roentgen b75cab
static int NotConfigured(TIFF*, int);
roentgen b75cab
roentgen b75cab
#ifndef LZW_SUPPORT
roentgen b75cab
#define TIFFInitLZW NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef PACKBITS_SUPPORT
roentgen b75cab
#define TIFFInitPackBits NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef THUNDER_SUPPORT
roentgen b75cab
#define TIFFInitThunderScan NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef NEXT_SUPPORT
roentgen b75cab
#define TIFFInitNeXT NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef JPEG_SUPPORT
roentgen b75cab
#define TIFFInitJPEG NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef OJPEG_SUPPORT
roentgen b75cab
#define TIFFInitOJPEG NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef CCITT_SUPPORT
roentgen b75cab
#define TIFFInitCCITTRLE NotConfigured
roentgen b75cab
#define TIFFInitCCITTRLEW NotConfigured
roentgen b75cab
#define TIFFInitCCITTFax3 NotConfigured
roentgen b75cab
#define TIFFInitCCITTFax4 NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef JBIG_SUPPORT
roentgen b75cab
#define TIFFInitJBIG NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef ZIP_SUPPORT
roentgen b75cab
#define TIFFInitZIP NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef PIXARLOG_SUPPORT
roentgen b75cab
#define TIFFInitPixarLog NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef LOGLUV_SUPPORT
roentgen b75cab
#define TIFFInitSGILog NotConfigured
roentgen b75cab
#endif
roentgen b75cab
#ifndef LZMA_SUPPORT
roentgen b75cab
#define TIFFInitLZMA NotConfigured
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Compression schemes statically built into the library.
roentgen b75cab
 */
roentgen b75cab
#ifdef VMS
roentgen b75cab
const TIFFCodec _TIFFBuiltinCODECS[] = {
roentgen b75cab
#else
roentgen b75cab
TIFFCodec _TIFFBuiltinCODECS[] = {
roentgen b75cab
#endif
roentgen b75cab
    { "None",		COMPRESSION_NONE,	TIFFInitDumpMode },
roentgen b75cab
    { "LZW",		COMPRESSION_LZW,	TIFFInitLZW },
roentgen b75cab
    { "PackBits",	COMPRESSION_PACKBITS,	TIFFInitPackBits },
roentgen b75cab
    { "ThunderScan",	COMPRESSION_THUNDERSCAN,TIFFInitThunderScan },
roentgen b75cab
    { "NeXT",		COMPRESSION_NEXT,	TIFFInitNeXT },
roentgen b75cab
    { "JPEG",		COMPRESSION_JPEG,	TIFFInitJPEG },
roentgen b75cab
    { "Old-style JPEG",	COMPRESSION_OJPEG,	TIFFInitOJPEG },
roentgen b75cab
    { "CCITT RLE",	COMPRESSION_CCITTRLE,	TIFFInitCCITTRLE },
roentgen b75cab
    { "CCITT RLE/W",	COMPRESSION_CCITTRLEW,	TIFFInitCCITTRLEW },
roentgen b75cab
    { "CCITT Group 3",	COMPRESSION_CCITTFAX3,	TIFFInitCCITTFax3 },
roentgen b75cab
    { "CCITT Group 4",	COMPRESSION_CCITTFAX4,	TIFFInitCCITTFax4 },
roentgen b75cab
    { "ISO JBIG",	COMPRESSION_JBIG,	TIFFInitJBIG },
roentgen b75cab
    { "Deflate",	COMPRESSION_DEFLATE,	TIFFInitZIP },
roentgen b75cab
    { "AdobeDeflate",   COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, 
roentgen b75cab
    { "PixarLog",	COMPRESSION_PIXARLOG,	TIFFInitPixarLog },
roentgen b75cab
    { "SGILog",		COMPRESSION_SGILOG,	TIFFInitSGILog },
roentgen b75cab
    { "SGILog24",	COMPRESSION_SGILOG24,	TIFFInitSGILog },
roentgen b75cab
    { "LZMA",		COMPRESSION_LZMA,	TIFFInitLZMA },
roentgen b75cab
    { NULL,             0,                      NULL }
roentgen b75cab
};
roentgen b75cab
roentgen b75cab
static int
roentgen b75cab
_notConfigured(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
roentgen b75cab
        char compression_code[20];
roentgen b75cab
        
roentgen b75cab
        sprintf( compression_code, "%d", tif->tif_dir.td_compression );
roentgen b75cab
	TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
roentgen b75cab
                     "%s compression support is not configured", 
roentgen b75cab
                     c ? c->name : compression_code );
roentgen b75cab
	return (0);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static int
roentgen b75cab
NotConfigured(TIFF* tif, int scheme)
roentgen b75cab
{
roentgen b75cab
	(void) scheme;
roentgen b75cab
roentgen b75cab
	tif->tif_fixuptags = _notConfigured;
roentgen b75cab
	tif->tif_decodestatus = FALSE;
roentgen b75cab
	tif->tif_setupdecode = _notConfigured;
roentgen b75cab
	tif->tif_encodestatus = FALSE;
roentgen b75cab
	tif->tif_setupencode = _notConfigured;
roentgen b75cab
	return (1);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
/************************************************************************/
roentgen b75cab
/*                       TIFFIsCODECConfigured()                        */
roentgen b75cab
/************************************************************************/
roentgen b75cab
roentgen b75cab
/**
roentgen b75cab
 * Check whether we have working codec for the specific coding scheme.
roentgen b75cab
 *
roentgen b75cab
 * @return returns 1 if the codec is configured and working. Otherwise
roentgen b75cab
 * 0 will be returned.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
TIFFIsCODECConfigured(uint16 scheme)
roentgen b75cab
{
roentgen b75cab
	const TIFFCodec* codec = TIFFFindCODEC(scheme);
roentgen b75cab
roentgen b75cab
	if(codec == NULL) {
roentgen b75cab
		return 0;
roentgen b75cab
	}
roentgen b75cab
	if(codec->init == NULL) {
roentgen b75cab
		return 0;
roentgen b75cab
	}
roentgen b75cab
	if(codec->init != NotConfigured){
roentgen b75cab
		return 1;
roentgen b75cab
	}
roentgen b75cab
	return 0;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Local Variables:
roentgen b75cab
 * mode: c
roentgen b75cab
 * c-basic-offset: 8
roentgen b75cab
 * fill-column: 78
roentgen b75cab
 * End:
roentgen b75cab
 */