TIFF and LibTiff Mail List Archive


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

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

On Sunday 16 November 2008 11:39:41 am you 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.




#ifndef _TIFFCODEC_
#define _TIFFCODEC_

#if defined(__cplusplus)
extern "C" {


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 /* _TIFFCODEC_ */

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