AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2008.11.01 07:10 "example of (standalone) TIFFRegisterCODEC", by Brad Hards
2008.11.14 08:14 "Re: example of (standalone) TIFFRegisterCODEC", by Brad Hards
2008.11.14 16:18 "Re: example of (standalone) TIFFRegisterCODEC", by Frank Warmerdam
2008.11.14 23:32 "Re: example of (standalone) TIFFRegisterCODEC", by Brad Hards
2008.11.16 00:39 "Re: example of (standalone) TIFFRegisterCODEC", by Frank Warmerdam
2008.12.13 10:30 "Re: example of (standalone) TIFFRegisterCODEC", by Brad Hards
2008.12.13 15:18 "Re: example of (standalone) TIFFRegisterCODEC", by Frank Warmerdam
2008.12.13 16:35 "Re: example of (standalone) TIFFRegisterCODEC", by Bob Friesenhahn
2008.12.13 19:12 "Re: example of (standalone) TIFFRegisterCODEC", by Gene Amtower
2008.12.13 21:52 "Re: example of (standalone) TIFFRegisterCODEC", by Bob Friesenhahn
2008.12.14 00:07 "Re: example of (standalone) TIFFRegisterCODEC", by Brad Hards
2008.12.14 05:47 "Re: example of (standalone) TIFFRegisterCODEC", by Bob Friesenhahn
2008.11.14 16:53 "Re: example of (standalone) TIFFRegisterCODEC", by Comsquare Martin Osieka

2008.12.13 10:30 "Re: example of (standalone) TIFFRegisterCODEC", by Brad Hards

On Sunday 16 November 2008 11:39:41 am you wrote:
> Brad Hards wrote:
> > I think the way to fix this is to complete the abstraction in libtiff. My
> > current thinking is that there should be accessors for each thing that a
> > codec needs to do (e.g. to set function pointers or obtain data). Those
> > accessors would go into tiffio.h or perhaps into a new tiffcodec.h. This
> > would be intended for external codecs (although there wouldn't be
> > anything stopping built-in codecs using the API additions if desired).
> I have not reviewed the details of the interface between libtiff and
> codecs. Generally speaking making CODECs pluggable without private
> knowledge of the internals of libtiff seems like a good idea.  From what I
> have seen, some of the CODECs end up dipping quite deep into libtiff -
> perhaps mostly because of hacky things about the bugs related to the
> compression formats.  So I'm not sure how achievable it is to abstract the
> interface cleanly.
I'm not sure yet. Certainly decode only looks like it might be feasible.

> Assuming the plan makes sense, there is still the issue who of will do the
> work and who will take responsibility for integrating the changes into
> libtiff. I am concerned it may imply a lot of work, and churn at a time
> when we are not doing so well at making the leap to bigtiff with some other
> major internal overhauls done at the same time.  But if you want to take a
> crack at it, I'm confident that the team would at least consider the
> changes.
I've started working on this. It isn't done yet.

If possible, I'd like some feedback on the direction I'm taking.

So far, I've added a new header ("tiffcodec.h") which is reproduced
below. The content is a combination of stuff extracted from tiffio.h
and some new content. There is an implementation behind this,
but its mostly trivial.

Most of the new content just registers codec handler functions.
The last couple of functions are ways to get raw data out 
without using tif_rawcc / tiff_rawcp.

The movement of the old code could break external users
of those functions. However it seems unlikely that there are
many, if any, given how hard it is to use.

Brad

/*                                                                                        
 * Copyright (c) 1988-1997 Sam Leffler                                                    
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.                                         
 *                                                                                        
 * Permission to use, copy, modify, distribute, and sell this software and                
 * its documentation for any purpose is hereby granted without fee, provided              
 * that (i) the above copyright notices and this permission notice appear in              
 * all copies of the software and related documentation, and (ii) the names of            
 * Sam Leffler and Silicon Graphics may not be used in any advertising or                 
 * publicity relating to the software without the specific, prior written                 
 * permission of Sam Leffler and Silicon Graphics.                                        
 *                                                                                        
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,                     
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY                       
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.                       
 *                                                                                        
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR                        
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,                
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,                 
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF              
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE                 
 * OF THIS SOFTWARE.                                                                      
 */                                                                                       

#ifndef _TIFFCODEC_
#define _TIFFCODEC_

#if defined(__cplusplus)
extern "C" {            
#endif                  

/*
 * A CODEC is a software package that implements decoding,
 * encoding, or decoding+encoding of a compression algorithm.
 * The library provides a collection of builtin codecs.      
 * More codecs may be registered through calls to the library
 * and/or the builtin implementations may be overridden.     
 */                                                          
typedef int (*TIFFInitMethod)(TIFF*, int);                   
typedef struct {                                             
        char* name;                                          
        uint16 scheme;                                       
        TIFFInitMethod init;                                 
} TIFFCodec;                                                 

extern const TIFFCodec* TIFFFindCODEC(uint16);
extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
extern void TIFFUnRegisterCODEC(TIFFCodec*);
extern int TIFFIsCODECConfigured(uint16);
extern TIFFCodec* TIFFGetConfiguredCODECs(void);

typedef void (*TIFFVoidMethod)(TIFF*);
typedef int (*TIFFBoolMethod)(TIFF*);
typedef int (*TIFFPreMethod)(TIFF*, uint16);
typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, tmsize_t size, uint16 sample);
typedef int (*TIFFSeekMethod)(TIFF*, uint32);
typedef void (*TIFFPostMethod)(TIFF* tif, uint8* buf, tmsize_t size);
typedef uint32 (*TIFFStripMethod)(TIFF*, uint32);
typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*);

extern void TIFFCodecRegisterFixupTags( TIFF *tif, TIFFBoolMethod fixupTagsMethod );
extern void TIFFCodecRegisterSetupDecode( TIFF *tif, TIFFBoolMethod setupDecodeMethod );
extern void TIFFCodecRegisterPreDecode( TIFF *tif, TIFFPreMethod preDecodeMethod );
extern void TIFFCodecRegisterPostDecode( TIFF *tif, TIFFPostMethod preDecodeMethod );
extern void TIFFCodecRegisterSetupEncode( TIFF *tif, TIFFBoolMethod setupEncodeMethod );
extern void TIFFCodecRegisterPreEncode( TIFF *tif, TIFFPreMethod preEncodeMethod );
extern void TIFFCodecRegisterPostEncode( TIFF *tif, TIFFBoolMethod postEncodeMethod );
extern void TIFFCodecRegisterDecodeRow( TIFF *tif, TIFFCodeMethod decodeRowMethod );
extern void TIFFCodecRegisterEncodeRow( TIFF *tif, TIFFCodeMethod encodeRowMethod );
extern void TIFFCodecRegisterDecodeStrip( TIFF *tif, TIFFCodeMethod decodeStripMethod );
extern void TIFFCodecRegisterEncodeStrip( TIFF *tif, TIFFCodeMethod encodeStripMethod );
extern void TIFFCodecRegisterDecodeTile( TIFF *tif, TIFFCodeMethod decodeTileMethod );
extern void TIFFCodecRegisterEncodeTile( TIFF *tif, TIFFCodeMethod encodeTileMethod );
extern void TIFFCodecRegisterClose( TIFF *tif, TIFFVoidMethod closeMethod );
extern void TIFFCodecRegisterSeek( TIFF *tif, TIFFSeekMethod seekMethod );
extern void TIFFCodecRegisterCleanup( TIFF *tif, TIFFVoidMethod cleanupMethod );
extern void TIFFCodecRegisterDefStripSize( TIFF *tif, TIFFStripMethod defStripSizeMethod );
extern void TIFFCodecRegisterDefTileSize( TIFF *tif, TIFFTileMethod defTileSizeMethod );

uint8* TIFFGetRawData( TIFF *tif, tmsize_t cc );
tmsize_t TIFFRawBytesAvailable( TIFF *tif );

#if defined(__cplusplus)
}
#endif

#endif  /* _TIFFCODEC_ */

/* vim: set ts=8 sts=8 sw=8 noet: */