Blame html/internals.html

Packit 7838c8
<HTML>
Packit 7838c8
<HEAD>
Packit 7838c8
<TITLE>
Packit 7838c8
Modifying The TIFF Library
Packit 7838c8
</TITLE>
Packit 7838c8
</HEAD>
Packit 7838c8
<BODY BGCOLOR=white> 
Packit 7838c8
<FONT FACE="Arial, Helvetica, Sans">
Packit 7838c8

Packit 7838c8
Packit 7838c8
Modifying The TIFF Library
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

Packit 7838c8
This chapter provides information about the internal structure of
Packit 7838c8
the library, how to control the configuration when building it, and
Packit 7838c8
how to add new support to the library.
Packit 7838c8
The following sections are found in this chapter:
Packit 7838c8
Packit 7838c8
    Packit 7838c8
  • Library Configuration
  • Packit 7838c8
  • General Portability Comments
  • Packit 7838c8
  • Types and Portability
  • Packit 7838c8
  • Adding New Tags
  • Packit 7838c8
  • Adding New Builtin Codecs
  • Packit 7838c8
  • Adding New Codec-private Tags
  • Packit 7838c8
  • Other Comments
  • Packit 7838c8
    Packit 7838c8
    Packit 7838c8
    Packit 7838c8


    Library Configuration

    Packit 7838c8
    Packit 7838c8
    Information on compiling the library is given
    Packit 7838c8
    elsewhere in this documentation.
    Packit 7838c8
    This section describes the low-level mechanisms used to control
    Packit 7838c8
    the optional parts of the library that are configured at build
    Packit 7838c8
    time.   Control is based on
    Packit 7838c8
    a collection of C defines that are specified either on the compiler
    Packit 7838c8
    command line or in a configuration file such as <TT>port.h</TT>
    Packit 7838c8
    (as generated by the <TT>configure</TT> script for UNIX systems)
    Packit 7838c8
    or tiffconf.h.
    Packit 7838c8
    Packit 7838c8

    Packit 7838c8
    Configuration defines are split into three areas:
    Packit 7838c8
      Packit 7838c8
    • those that control which compression schemes are
    • Packit 7838c8
          configured as part of the builtin codecs,
      Packit 7838c8
    • those that control support for groups of tags that
    • Packit 7838c8
          are considered optional, and
      Packit 7838c8
    • those that control operating system or machine-specific support.
    • Packit 7838c8
      Packit 7838c8
      Packit 7838c8

      Packit 7838c8
      If the define <TT>COMPRESSION_SUPPORT</TT> is not defined
      Packit 7838c8
      then a default set of compression schemes is automatically
      Packit 7838c8
      configured:
      Packit 7838c8
        Packit 7838c8
      • CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771),
      • Packit 7838c8
      • the Macintosh PackBits algorithm (compression 32773),
      • Packit 7838c8
      • a 4-bit run-length encoding scheme from ThunderScan (compression 32809),
      • Packit 7838c8
      • a 2-bit encoding scheme used by NeXT (compression 32766), and
      • Packit 7838c8
      • two experimental schemes intended for images with high dynamic range
      • Packit 7838c8
        (compression 34676 and 34677).
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Packit 7838c8
        To override the default compression behaviour define
        Packit 7838c8
        <TT>COMPRESSION_SUPPORT</TT> and then one or more additional defines
        Packit 7838c8
        to enable configuration of the appropriate codecs (see the table
        Packit 7838c8
        below); e.g.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        #define	COMPRESSION_SUPPORT
        Packit 7838c8
        #define	CCITT_SUPPORT
        Packit 7838c8
        #define	PACKBITS_SUPPORT
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Several other compression schemes are configured separately from
        Packit 7838c8
        the default set because they depend on ancillary software
        Packit 7838c8
        packages that are not distributed with <TT>libtiff</TT>.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Support for JPEG compression is controlled by <TT>JPEG_SUPPORT</TT>.
        Packit 7838c8
        The JPEG codec that comes with <TT>libtiff</TT> is designed for
        Packit 7838c8
        use with release 5 or later of the Independent JPEG Group's freely
        Packit 7838c8
        available software distribution.
        Packit 7838c8
        This software can be retrieved from the directory
        Packit 7838c8
        ftp.uu.net:/graphics/jpeg/.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        NOTE: 
        Packit 7838c8
        Enabling JPEG support automatically enables support for
        Packit 7838c8
        the TIFF 6.0 colorimetry and YCbCr-related tags.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Experimental support for the deflate algorithm is controlled by
        Packit 7838c8
        <TT>DEFLATE_SUPPORT</TT>.
        Packit 7838c8
        The deflate codec that comes with <TT>libtiff</TT> is designed
        Packit 7838c8
        for use with version 0.99 or later of the freely available
        Packit 7838c8
        <TT>libz</TT> library written by Jean-loup Gailly and Mark Adler.
        Packit 7838c8
        The data format used by this library is described
        Packit 7838c8
        in the files
        Packit 7838c8
        zlib-3.1.doc,
        Packit 7838c8
        and
        Packit 7838c8
        deflate-1.1.doc,
        Packit 7838c8
        available in the directory
        Packit 7838c8
        ftp.uu.net:/pub/archiving/zip/doc.
        Packit 7838c8
        The library can be retried from the directory
        Packit 7838c8
        ftp.uu.net:/pub/archiving/zip/zlib/
        Packit 7838c8
        (or try quest.jpl.nasa.gov:/beta/zlib/).
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        NOTE: 
        Packit 7838c8
        The deflate algorithm is experimental.  Do not expect
        Packit 7838c8
        to exchange files using this compression scheme;
        Packit 7838c8
        it is included only because the similar, and more common,
        Packit 7838c8
        LZW algorithm is claimed to be governed by licensing restrictions.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        By default tiffconf.h defines
        Packit 7838c8
        <TT>COLORIMETRY_SUPPORT</TT>, 
        Packit 7838c8
        <TT>YCBCR_SUPPORT</TT>,
        Packit 7838c8
        and 
        Packit 7838c8
        <TT>CMYK_SUPPORT</TT>.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        DefineDescription
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>CCITT_SUPPORT</TT>
        Packit 7838c8
        CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4,
        Packit 7838c8
            and 32771)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>PACKBITS_SUPPORT</TT>
        Packit 7838c8
        Macintosh PackBits algorithm (compression 32773)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>LZW_SUPPORT</TT>
        Packit 7838c8
        Lempel-Ziv & Welch (LZW) algorithm (compression 5)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>THUNDER_SUPPORT</TT>
        Packit 7838c8
        4-bit
        Packit 7838c8
        run-length encoding scheme from ThunderScan (compression 32809)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>NEXT_SUPPORT</TT>
        Packit 7838c8
        2-bit encoding scheme used by NeXT (compression 32766)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>OJPEG_SUPPORT</TT>
        Packit 7838c8
        obsolete JPEG scheme defined in the 6.0 spec (compression 6)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>JPEG_SUPPORT</TT>
        Packit 7838c8
        current JPEG scheme defined in TTN2 (compression 7)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>ZIP_SUPPORT</TT>
        Packit 7838c8
        experimental Deflate scheme (compression 32946)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>PIXARLOG_SUPPORT</TT>
        Packit 7838c8
        Pixar's compression scheme for high-resolution color images (compression 32909)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>SGILOG_SUPPORT</TT>
        Packit 7838c8
        SGI's compression scheme for high-resolution color images (compression 34676 and 34677)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>COLORIMETRY_SUPPORT</TT>
        Packit 7838c8
        support for the TIFF 6.0 colorimetry tags
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>YCBCR_SUPPORT</TT>
        Packit 7838c8
        support for the TIFF 6.0 YCbCr-related tags
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>CMYK_SUPPORT</TT>
        Packit 7838c8
        support for the TIFF 6.0 CMYK-related tags
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>ICC_SUPPORT</TT>
        Packit 7838c8
        support for the ICC Profile tag; see
        Packit 7838c8
        The ICC Profile Format Specification,
        Packit 7838c8
        Annex B.3 "Embedding ICC Profiles in TIFF Files";
        Packit 7838c8
        available at
        Packit 7838c8
        http://www.color.org
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8


        General Portability Comments

        Packit 7838c8
        Packit 7838c8
        This software is developed on Silicon Graphics UNIX
        Packit 7838c8
        systems (big-endian, MIPS CPU, 32-bit ints,
        Packit 7838c8
        IEEE floating point). 
        Packit 7838c8
        The <TT>configure</TT> shell script generates the appropriate
        Packit 7838c8
        include files and make files for UNIX systems.
        Packit 7838c8
        Makefiles exist for non-UNIX platforms that the
        Packit 7838c8
        code runs on -- this work has mostly been done by other people.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        In general, the code is guaranteed to work only on SGI machines.
        Packit 7838c8
        In practice it is highly portable to any 32-bit or 64-bit system and much
        Packit 7838c8
        work has been done to insure portability to 16-bit systems.
        Packit 7838c8
        If you encounter portability problems please return fixes so
        Packit 7838c8
        that future distributions can be improved.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        The software is written to assume an ANSI C compilation environment.
        Packit 7838c8
        If your compiler does not support ANSI function prototypes, <TT>const</TT>,
        Packit 7838c8
        and <TT><stdarg.h></TT> then you will have to make modifications to the
        Packit 7838c8
        software.  In the past I have tried to support compilers without <TT>const</TT>
        Packit 7838c8
        and systems without <TT><stdarg.h></TT>, but I am
        Packit 7838c8
        no longer interested in these
        Packit 7838c8
        antiquated environments.  With the general availability of
        Packit 7838c8
        the freely available GCC compiler, I
        Packit 7838c8
        see no reason to incorporate modifications to the software for these
        Packit 7838c8
        purposes.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        An effort has been made to isolate as many of the
        Packit 7838c8
        operating system-dependencies
        Packit 7838c8
        as possible in two files: tiffcomp.h and
        Packit 7838c8
        libtiff/tif_<os>.c.  The latter file contains
        Packit 7838c8
        operating system-specific routines to do I/O and I/O-related operations.
        Packit 7838c8
        The UNIX (tif_unix.c),
        Packit 7838c8
        Macintosh (tif_apple.c),
        Packit 7838c8
        and VMS (tif_vms.c)
        Packit 7838c8
        code has had the most use;
        Packit 7838c8
        the MS/DOS support (tif_msdos.c) assumes
        Packit 7838c8
        some level of UNIX system call emulation (i.e.
        Packit 7838c8
        <TT>open</TT>,
        Packit 7838c8
        <TT>read</TT>,
        Packit 7838c8
        <TT>write</TT>,
        Packit 7838c8
        <TT>fstat</TT>,
        Packit 7838c8
        <TT>malloc</TT>,
        Packit 7838c8
        <TT>free</TT>).
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Native CPU byte order is determined on the fly by
        Packit 7838c8
        the library and does not need to be specified.
        Packit 7838c8
        The <TT>HOST_FILLORDER</TT> and <TT>HOST_BIGENDIAN</TT>
        Packit 7838c8
        definitions are not currently used, but may be employed by
        Packit 7838c8
        codecs for optimization purposes.
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        The following defines control general portability:
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>BSDTYPES</TT>
        Packit 7838c8
        Define this if your system does NOT define the
        Packit 7838c8
        		usual BSD typedefs: <TT>u_char</TT>,
        Packit 7838c8
        		<TT>u_short</TT>, <TT>u_int</TT>, <TT>u_long</TT>.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>HAVE_IEEEFP</TT>
        Packit 7838c8
        Define this as 0 or 1 according to the floating point
        Packit 7838c8
        		format suported by the machine.  If your machine does
        Packit 7838c8
        		not support IEEE floating point then you will need to
        Packit 7838c8
        		add support to tif_machdep.c to convert between the
        Packit 7838c8
        		native format and IEEE format.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>HAVE_MMAP</TT>
        Packit 7838c8
        Define this if there is mmap-style support for
        Packit 7838c8
        mapping files into memory (used only to read data).
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>HOST_FILLORDER</TT>
        Packit 7838c8
        Define the native CPU bit order: one of <TT>FILLORDER_MSB2LSB</TT>
        Packit 7838c8
         or <TT>FILLORDER_LSB2MSB</TT>
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        <TT>HOST_BIGENDIAN</TT>
        Packit 7838c8
        Define the native CPU byte order: 1 if big-endian (Motorola)
        Packit 7838c8
         or 0 if little-endian (Intel); this may be used
        Packit 7838c8
         in codecs to optimize code
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        On UNIX systems <TT>HAVE_MMAP</TT> is defined through the running of
        Packit 7838c8
        the <TT>configure</TT> script; otherwise support for memory-mapped
        Packit 7838c8
        files is disabled.
        Packit 7838c8
        Note that tiffcomp.h defines <TT>HAVE_IEEEFP</TT> to be
        Packit 7838c8
        1 (<TT>BSDTYPES</TT> is not defined).
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8


        Types and Portability

        Packit 7838c8
        Packit 7838c8
        The software makes extensive use of C typedefs to promote portability.
        Packit 7838c8
        Two sets of typedefs are used, one for communication with clients
        Packit 7838c8
        of the library and one for internal data structures and parsing of the
        Packit 7838c8
        TIFF format.  There are interactions between these two to be careful
        Packit 7838c8
        of, but for the most part you should be able to deal with portability
        Packit 7838c8
        purely by fiddling with the following machine-dependent typedefs:
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        uint8
        Packit 7838c8
        8-bit unsigned integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        int8
        Packit 7838c8
        8-bit signed integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        uint16
        Packit 7838c8
        16-bit unsigned integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        int16
        Packit 7838c8
        16-bit signed integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        uint32
        Packit 7838c8
        32-bit unsigned integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        int32
        Packit 7838c8
        32-bit signed integer
        Packit 7838c8
        tiff.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        dblparam_t
        Packit 7838c8
        promoted type for floats
        Packit 7838c8
        tiffcomp.h
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        (to clarify <TT>dblparam_t</TT>, it is the type that float parameters are
        Packit 7838c8
        promoted to when passed by value in a function call.)
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        The following typedefs are used throughout the library and interfaces
        Packit 7838c8
        to refer to certain objects whose size is dependent on the TIFF image
        Packit 7838c8
        structure:
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef unsigned int ttag_t;	directory tag
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef uint16 tdir_t;		directory index
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef uint16 tsample_t;	sample number
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef uint32 tstrip_t;	strip number
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef uint32 ttile_t;		tile number
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef int32 tsize_t;		i/o size in bytes
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef void* tdata_t;		image data ref
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef void* thandle_t;	client data handle
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef int32 toff_t;		file offset (should be off_t)
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        typedef unsigned char* tidata_t; internal image data
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8

        Packit 7838c8
        Note that <TT>tstrip_t</TT>, <TT>ttile_t</TT>, and <TT>tsize_t</TT>
        Packit 7838c8
        are constrained to be
        Packit 7838c8
        no more than 32-bit quantities by 32-bit fields they are stored
        Packit 7838c8
        in in the TIFF image.  Likewise <TT>tsample_t</TT> is limited by the 16-bit
        Packit 7838c8
        field used to store the <TT>SamplesPerPixel</TT> tag.  <TT>tdir_t</TT>
        Packit 7838c8
        constrains
        Packit 7838c8
        the maximum number of IFDs that may appear in an image and may
        Packit 7838c8
        be an arbitrary size (without penalty).  <TT>ttag_t</TT> must be either
        Packit 7838c8
        <TT>int</TT>, <TT>unsigned int</TT>, pointer, or <TT>double</TT>
        Packit 7838c8
        because the library uses a varargs
        Packit 7838c8
        interface and ANSI C restricts the type of the parameter before an
        Packit 7838c8
        ellipsis to be a promoted type.  <TT>toff_t</TT> is defined as
        Packit 7838c8
        <TT>int32</TT> because
        Packit 7838c8
        TIFF file offsets are (unsigned) 32-bit quantities.  A signed
        Packit 7838c8
        value is used because some interfaces return -1 on error (sigh).
        Packit 7838c8
        Finally, note that <TT>tidata_t</TT> is used internally to the library to
        Packit 7838c8
        manipulate internal data.  User-specified data references are
        Packit 7838c8
        passed as opaque handles and only cast at the lowest layers where
        Packit 7838c8
        their type is presumed.
        Packit 7838c8
        Packit 7838c8
        Packit 7838c8


        General Comments

        Packit 7838c8
        Packit 7838c8
        The library is designed to hide as much of the details of TIFF from
        Packit 7838c8
        applications as
        Packit 7838c8
        possible.  In particular, TIFF directories are read in their entirety
        Packit 7838c8
        into an internal format.  Only the tags known by the library are
        Packit 7838c8
        available to a user and certain tag data may be maintained that a user
        Packit 7838c8
        does not care about (e.g. transfer function tables).
        Packit 7838c8
        Packit 7838c8


        Adding New Builtin Codecs

        Packit 7838c8
        Packit 7838c8
        To add builtin support for a new compression algorithm, you can either
        Packit 7838c8
        use the "tag-extension" trick to override the handling of the
        Packit 7838c8
        TIFF Compression tag (see Adding New Tags), 
        Packit 7838c8
        or do the following to add support directly to the core library:
        Packit 7838c8
        Packit 7838c8
          Packit 7838c8
        1. Define the tag value in tiff.h.
        2. Packit 7838c8
        3. Edit the file tif_codec.c to add an entry to the
        4. Packit 7838c8
             _TIFFBuiltinCODECS array (see how other algorithms are handled).
          Packit 7838c8
        5. Add the appropriate function prototype declaration to
        6. Packit 7838c8
             tiffiop.h (close to the bottom).
          Packit 7838c8
        7. Create a file with the compression scheme code, by convention files
        8. Packit 7838c8
             are named tif_*.c (except perhaps on some systems where the
          Packit 7838c8
             tif_ prefix pushes some filenames over 14 chars.
          Packit 7838c8
        9. Edit Makefile.in (and any other Makefiles)
        10. Packit 7838c8
             to include the new source file.
          Packit 7838c8
          Packit 7838c8
          Packit 7838c8

          Packit 7838c8
          A codec, say <TT>foo</TT>, can have many different entry points:
          Packit 7838c8
          Packit 7838c8
          Packit 7838c8
          TIFFInitfoo(tif, scheme)/* initialize scheme and setup entry points in tif */
          Packit 7838c8
          fooSetupDecode(tif)	/* called once per IFD after tags has been frozen */
          Packit 7838c8
          fooPreDecode(tif, sample)/* called once per strip/tile, after data is read,
          Packit 7838c8
          			    but before the first row is decoded */
          Packit 7838c8
          fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
          Packit 7838c8
              fooDecodeRow(...)	/* called to decode a single scanline */
          Packit 7838c8
              fooDecodeStrip(...)	/* called to decode an entire strip */
          Packit 7838c8
              fooDecodeTile(...)	/* called to decode an entire tile */
          Packit 7838c8
          fooSetupEncode(tif)	/* called once per IFD after tags has been frozen */
          Packit 7838c8
          fooPreEncode(tif, sample)/* called once per strip/tile, before the first row in
          Packit 7838c8
          			    a strip/tile is encoded */
          Packit 7838c8
          fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
          Packit 7838c8
              fooEncodeRow(...)	/* called to decode a single scanline */
          Packit 7838c8
              fooEncodeStrip(...)	/* called to decode an entire strip */
          Packit 7838c8
              fooEncodeTile(...)	/* called to decode an entire tile */
          Packit 7838c8
          fooPostEncode(tif)	/* called once per strip/tile, just before data is written */
          Packit 7838c8
          fooSeek(tif, row)	/* seek forwards row scanlines from the beginning
          Packit 7838c8
          			   of a strip (row will always be >0 and <rows/strip */
          Packit 7838c8
          fooCleanup(tif)		/* called when compression scheme is replaced by user */
          Packit 7838c8
          Packit 7838c8
          Packit 7838c8

          Packit 7838c8
          Note that the encoding and decoding variants are only needed when
          Packit 7838c8
          a compression algorithm is dependent on the structure of the data.
          Packit 7838c8
          For example, Group 3 2D encoding and decoding maintains a reference
          Packit 7838c8
          scanline.  The sample parameter identifies which sample is to be
          Packit 7838c8
          encoded or decoded if the image is organized with <TT>PlanarConfig</TT>=2
          Packit 7838c8
          (separate planes).  This is important for algorithms such as JPEG.
          Packit 7838c8
          If <TT>PlanarConfig</TT>=1 (interleaved), then sample will always be 0.
          Packit 7838c8
          Packit 7838c8


          Other Comments

          Packit 7838c8
          Packit 7838c8
          The library handles most I/O buffering.  There are two data buffers
          Packit 7838c8
          when decoding data: a raw data buffer that holds all the data in a
          Packit 7838c8
          strip, and a user-supplied scanline buffer that compression schemes
          Packit 7838c8
          place decoded data into.  When encoding data the data in the
          Packit 7838c8
          user-supplied scanline buffer is encoded into the raw data buffer (from
          Packit 7838c8
          where it is written).  Decoding routines should never have to explicitly
          Packit 7838c8
          read data -- a full strip/tile's worth of raw data is read and scanlines
          Packit 7838c8
          never cross strip boundaries.  Encoding routines must be cognizant of
          Packit 7838c8
          the raw data buffer size and call <TT>TIFFFlushData1()</TT> when necessary.
          Packit 7838c8
          Note that any pending data is automatically flushed when a new strip/tile is
          Packit 7838c8
          started, so there's no need do that in the tif_postencode routine (if
          Packit 7838c8
          one exists).  Bit order is automatically handled by the library when
          Packit 7838c8
          a raw strip or tile is filled.  If the decoded samples are interpreted
          Packit 7838c8
          by the decoding routine before they are passed back to the user, then
          Packit 7838c8
          the decoding logic must handle byte-swapping by overriding the
          Packit 7838c8
          <TT>tif_postdecode</TT>
          Packit 7838c8
          routine (set it to <TT>TIFFNoPostDecode</TT>) and doing the required work
          Packit 7838c8
          internally.  For an example of doing this look at the horizontal
          Packit 7838c8
          differencing code in the routines in tif_predict.c.
          Packit 7838c8
          Packit 7838c8

          Packit 7838c8
          The variables <TT>tif_rawcc</TT>, <TT>tif_rawdata</TT>, and
          Packit 7838c8
          <TT>tif_rawcp</TT> in a <TT>TIFF</TT> structure
          Packit 7838c8
          are associated with the raw data buffer.  <TT>tif_rawcc</TT> must be non-zero
          Packit 7838c8
          for the library to automatically flush data.  The variable
          Packit 7838c8
          <TT>tif_scanlinesize</TT> is the size a user's scanline buffer should be.  The
          Packit 7838c8
          variable <TT>tif_tilesize</TT> is the size of a tile for tiled images.  This
          Packit 7838c8
          should not normally be used by compression routines, except where it
          Packit 7838c8
          relates to the compression algorithm.  That is, the <TT>cc</TT> parameter to the
          Packit 7838c8
          <TT>tif_decode*</TT> and <TT>tif_encode*</TT>
          Packit 7838c8
          routines should be used in terminating
          Packit 7838c8
          decompression/compression.  This ensures these routines can be used,
          Packit 7838c8
          for example, to decode/encode entire strips of data.
          Packit 7838c8
          Packit 7838c8

          Packit 7838c8
          In general, if you have a new compression algorithm to add, work from
          Packit 7838c8
          the code for an existing routine.  In particular,
          Packit 7838c8
          tif_dumpmode.c
          Packit 7838c8
          has the trivial code for the "nil" compression scheme,
          Packit 7838c8
          tif_packbits.c is a
          Packit 7838c8
          simple byte-oriented scheme that has to watch out for buffer
          Packit 7838c8
          boundaries, and tif_lzw.c has the LZW scheme that has the most
          Packit 7838c8
          complexity -- it tracks the buffer boundary at a bit level.
          Packit 7838c8
          Of course, using a private compression scheme (or private tags) limits
          Packit 7838c8
          the portability of your TIFF files.
          Packit 7838c8
          Packit 7838c8

          Packit 7838c8

          Packit 7838c8
          Packit 7838c8
          Last updated: $Date: 2016-09-25 20:05:44 $
          Packit 7838c8
          Packit 7838c8
          </BODY>
          Packit 7838c8
          Packit 7838c8
          </HTML>