From 3930fc6e3a0140197559ffdafb288b8837161ba2 Mon Sep 17 00:00:00 2001 From: Joris Van Damme Date: Thu, 28 Jun 2007 12:44:28 +0000 Subject: [PATCH] BigTIFF upgrade: changed indent from spaced to tabs in tif_jbig.c --- libtiff/tif_jbig.c | 384 ++++++++++++++++++++++----------------------- 1 file changed, 192 insertions(+), 192 deletions(-) diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c index fe91d4f0..601255f8 100644 --- a/libtiff/tif_jbig.c +++ b/libtiff/tif_jbig.c @@ -1,4 +1,4 @@ -/* $Id: tif_jbig.c,v 1.10 2007-06-23 01:06:07 joris Exp $ */ +/* $Id: tif_jbig.c,v 1.11 2007-06-28 12:44:28 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -39,13 +39,13 @@ typedef struct { - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spend receiving in seconds */ - char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */ + uint32 recvparams; /* encoded Class 2 session params */ + char* subaddress; /* subaddress string */ + uint32 recvtime; /* time spend receiving in seconds */ + char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */ - TIFFVGetMethod vgetparent; - TIFFVSetMethod vsetparent; + TIFFVGetMethod vgetparent; + TIFFVSetMethod vsetparent; } JBIGState; #define GetJBIGState(tif) ((JBIGState*)(tif)->tif_data) @@ -55,151 +55,151 @@ typedef struct #define FIELD_RECVTIME (FIELD_CODEC+2) #define FIELD_FAXDCS (FIELD_CODEC+3) -static const TIFFFieldInfo jbigFieldInfo[] = +static const TIFFFieldInfo jbigFieldInfo[] = { - {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, TIFF_SETGET_UINT32, ddd TIFF_SETGET_UNDEFINED, FIELD_RECVPARAMS, TRUE, FALSE, "FaxRecvParams", NULL}, - {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, TIFF_SETGET_ASCII, ddd TIFF_SETGET_UNDEFINED, FIELD_SUBADDRESS, TRUE, FALSE, "FaxSubAddress", NULL}, - {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, TIFF_SETGET_UINT32, ddd TIFF_SETGET_UNDEFINED, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime", NULL}, - {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, TIFF_SETGET_ASCII, ddd TIFF_SETGET_UNDEFINED, FIELD_FAXDCS, TRUE, FALSE, "FaxDcs", NULL}, + {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_RECVPARAMS, TRUE, FALSE, "FaxRecvParams", NULL}, + {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_SUBADDRESS, TRUE, FALSE, "FaxSubAddress", NULL}, + {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime", NULL}, + {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_FAXDCS, TRUE, FALSE, "FaxDcs", NULL}, }; static int JBIGSetupDecode(TIFF* tif) { - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFError("JBIG", "Multistrip images not supported in decoder"); - return 0; - } + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFError("JBIG", "Multistrip images not supported in decoder"); + return 0; + } - return 1; + return 1; } static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, uint16 s) { - struct jbg_dec_state decoder; - int decodeStatus = 0; - unsigned char* pImage = NULL; + struct jbg_dec_state decoder; + int decodeStatus = 0; + unsigned char* pImage = NULL; (void) size, (void) s; - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize); ddd - } + } - jbg_dec_init(&decoder); + jbg_dec_init(&decoder); #if defined(HAVE_JBG_NEWLEN) jbg_newlen(tif->tif_rawdata, tif->tif_rawdatasize); ddd - /* - * I do not check the return status of jbg_newlen because even if this - * function fails it does not necessarily mean that decoding the image - * will fail. It is generally only needed for received fax images - * that do not contain the actual length of the image in the BIE - * header. I do not log when an error occurs because that will cause - * problems when converting JBIG encoded TIFF's to - * PostScript. As long as the actual image length is contained in the - * BIE header jbg_dec_in should succeed. - */ + /* + * I do not check the return status of jbg_newlen because even if this + * function fails it does not necessarily mean that decoding the image + * will fail. It is generally only needed for received fax images + * that do not contain the actual length of the image in the BIE + * header. I do not log when an error occurs because that will cause + * problems when converting JBIG encoded TIFF's to + * PostScript. As long as the actual image length is contained in the + * BIE header jbg_dec_in should succeed. + */ #endif /* HAVE_JBG_NEWLEN */ - decodeStatus = jbg_dec_in(&decoder, tif->tif_rawdata, + decodeStatus = jbg_dec_in(&decoder, tif->tif_rawdata, tif->tif_rawdatasize, NULL); ddd - if (JBG_EOK != decodeStatus) - { - TIFFError("JBIG", "Error (%d) decoding: %s", - decodeStatus, jbg_strerror(decodeStatus, JBG_EN)); - return 0; - } - - pImage = jbg_dec_getimage(&decoder, 0); - _TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder)); - jbg_dec_free(&decoder); - return 1; + if (JBG_EOK != decodeStatus) + { + TIFFError("JBIG", "Error (%d) decoding: %s", + decodeStatus, jbg_strerror(decodeStatus, JBG_EN)); + return 0; + } + + pImage = jbg_dec_getimage(&decoder, 0); + _TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder)); + jbg_dec_free(&decoder); + return 1; } static int JBIGSetupEncode(TIFF* tif) { - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFError("JBIG", "Multistrip images not supported in encoder"); - return 0; - } + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFError("JBIG", "Multistrip images not supported in encoder"); + return 0; + } - return 1; + return 1; } static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, uint16 s) { - (void) s; - while (cc > 0) - { - tsize_t n = cc; + (void) s; + while (cc > 0) + { + tsize_t n = cc; if (tif->tif_rawcc + n > tif->tif_rawdatasize) ddd - { + { n = tif->tif_rawdatasize - tif->tif_rawcc; ddd - } + } - assert(n > 0); - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; ddd - pp += n; - cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && ddd - !TIFFFlushData1(tif)) - { - return (-1); - } - } + assert(n > 0); + _TIFFmemcpy(tif->tif_rawcp, pp, n); + tif->tif_rawcp += n; + tif->tif_rawcc += n; ddd + pp += n; + cc -= n; + if (tif->tif_rawcc >= tif->tif_rawdatasize && ddd + !TIFFFlushData1(tif)) + { + return (-1); + } + } - return (1); + return (1); } static void JBIGOutputBie(unsigned char* buffer, size_t len, void *userData) { - TIFF* tif = (TIFF*)userData; + TIFF* tif = (TIFF*)userData; - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { - TIFFReverseBits(buffer, len); ddd - } + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { + TIFFReverseBits(buffer, len); ddd + } - JBIGCopyEncodedData(tif, buffer, len, 0); + JBIGCopyEncodedData(tif, buffer, len, 0); } static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, uint16 s) { - TIFFDirectory* dir = &tif->tif_dir; - struct jbg_enc_state encoder; + TIFFDirectory* dir = &tif->tif_dir; + struct jbg_enc_state encoder; (void) size, (void) s; - jbg_enc_init(&encoder, - dir->td_imagewidth, - dir->td_imagelength, - 1, - &buffer, - JBIGOutputBie, - tif); - /* - * jbg_enc_out does the "real" encoding. As data is encoded, - * JBIGOutputBie is called, which writes the data to the directory. - */ - jbg_enc_out(&encoder); - jbg_enc_free(&encoder); + jbg_enc_init(&encoder, + dir->td_imagewidth, + dir->td_imagelength, + 1, + &buffer, + JBIGOutputBie, + tif); + /* + * jbg_enc_out does the "real" encoding. As data is encoded, + * JBIGOutputBie is called, which writes the data to the directory. + */ + jbg_enc_out(&encoder); + jbg_enc_free(&encoder); - return 1; + return 1; } static void JBIGCleanup(TIFF* tif) { - JBIGState *sp = GetJBIGState(tif); + JBIGState *sp = GetJBIGState(tif); - assert(sp != 0); + assert(sp != 0); - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; _TIFFfree(tif->tif_data); tif->tif_data = NULL; @@ -209,101 +209,101 @@ static void JBIGCleanup(TIFF* tif) static void JBIGPrintDir(TIFF* tif, FILE* fd, long flags) { - JBIGState* codec = GetJBIGState(tif); - (void)flags; + JBIGState* codec = GetJBIGState(tif); + (void)flags; - if (TIFFFieldSet(tif, FIELD_RECVPARAMS)) - { - fprintf(fd, - " Fax Receive Parameters: %08lx\n", - (unsigned long)codec->recvparams); - } + if (TIFFFieldSet(tif, FIELD_RECVPARAMS)) + { + fprintf(fd, + " Fax Receive Parameters: %08lx\n", + (unsigned long)codec->recvparams); + } - if (TIFFFieldSet(tif, FIELD_SUBADDRESS)) - { - fprintf(fd, - " Fax SubAddress: %s\n", - codec->subaddress); - } + if (TIFFFieldSet(tif, FIELD_SUBADDRESS)) + { + fprintf(fd, + " Fax SubAddress: %s\n", + codec->subaddress); + } - if (TIFFFieldSet(tif, FIELD_RECVTIME)) - { - fprintf(fd, - " Fax Receive Time: %lu secs\n", - (unsigned long)codec->recvtime); - } + if (TIFFFieldSet(tif, FIELD_RECVTIME)) + { + fprintf(fd, + " Fax Receive Time: %lu secs\n", + (unsigned long)codec->recvtime); + } - if (TIFFFieldSet(tif, FIELD_FAXDCS)) - { - fprintf(fd, - " Fax DCS: %s\n", - codec->faxdcs); - } + if (TIFFFieldSet(tif, FIELD_FAXDCS)) + { + fprintf(fd, + " Fax DCS: %s\n", + codec->faxdcs); + } } static int JBIGVGetField(TIFF* tif, ttag_t tag, va_list ap) { - JBIGState* codec = GetJBIGState(tif); + JBIGState* codec = GetJBIGState(tif); - switch (tag) - { + switch (tag) + { case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = codec->recvparams; - break; - + *va_arg(ap, uint32*) = codec->recvparams; + break; + case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = codec->subaddress; - break; + *va_arg(ap, char**) = codec->subaddress; + break; case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = codec->recvtime; - break; + *va_arg(ap, uint32*) = codec->recvtime; + break; case TIFFTAG_FAXDCS: - *va_arg(ap, char**) = codec->faxdcs; - break; + *va_arg(ap, char**) = codec->faxdcs; + break; - default: - return (*codec->vgetparent)(tif, tag, ap); - } + default: + return (*codec->vgetparent)(tif, tag, ap); + } - return 1; + return 1; } static int JBIGVSetField(TIFF* tif, ttag_t tag, va_list ap) { - JBIGState* codec = GetJBIGState(tif); + JBIGState* codec = GetJBIGState(tif); - switch (tag) - { + switch (tag) + { case TIFFTAG_FAXRECVPARAMS: - codec->recvparams = (uint32) va_arg(ap, uint32); - break; + codec->recvparams = (uint32) va_arg(ap, uint32); + break; case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&codec->subaddress, va_arg(ap, char*)); - break; + _TIFFsetString(&codec->subaddress, va_arg(ap, char*)); + break; case TIFFTAG_FAXRECVTIME: codec->recvtime = (uint32) va_arg(ap, uint32); - break; + break; - case TIFFTAG_FAXDCS: - _TIFFsetString(&codec->faxdcs, va_arg(ap, char*)); - break; + case TIFFTAG_FAXDCS: + _TIFFsetString(&codec->faxdcs, va_arg(ap, char*)); + break; - default: - return (*codec->vsetparent)(tif, tag, ap); - } + default: + return (*codec->vsetparent)(tif, tag, ap); + } - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; + TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + return 1; } int TIFFInitJBIG(TIFF* tif, int scheme) { - JBIGState* codec = NULL; + JBIGState* codec = NULL; assert(scheme == COMPRESSION_JBIG); @@ -317,50 +317,50 @@ int TIFFInitJBIG(TIFF* tif, int scheme) return 0; } - /* Allocate memory for the JBIGState structure.*/ - tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState)); - if (tif->tif_data == NULL) - { - TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState"); - return 0; - } - _TIFFmemset(tif->tif_data, 0, sizeof(JBIGState)); - codec = GetJBIGState(tif); + /* Allocate memory for the JBIGState structure.*/ + tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState)); + if (tif->tif_data == NULL) + { + TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState"); + return 0; + } + _TIFFmemset(tif->tif_data, 0, sizeof(JBIGState)); + codec = GetJBIGState(tif); - /* Initialize codec private fields */ - codec->recvparams = 0; - codec->subaddress = NULL; - codec->faxdcs = NULL; - codec->recvtime = 0; + /* Initialize codec private fields */ + codec->recvparams = 0; + codec->subaddress = NULL; + codec->faxdcs = NULL; + codec->recvtime = 0; - /* + /* * Override parent get/set field methods. */ - codec->vgetparent = tif->tif_tagmethods.vgetfield; - codec->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vgetfield = JBIGVGetField; - tif->tif_tagmethods.vsetfield = JBIGVSetField; ddd - tif->tif_tagmethods.printdir = JBIGPrintDir; + codec->vgetparent = tif->tif_tagmethods.vgetfield; + codec->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vgetfield = JBIGVGetField; + tif->tif_tagmethods.vsetfield = JBIGVSetField; ddd + tif->tif_tagmethods.printdir = JBIGPrintDir; - /* - * These flags are set so the JBIG Codec can control when to reverse - * bits and when not to and to allow the jbig decoder and bit reverser - * to write to memory when necessary. - */ - tif->tif_flags |= TIFF_NOBITREV; - tif->tif_flags &= ~TIFF_MAPPED; + /* + * These flags are set so the JBIG Codec can control when to reverse + * bits and when not to and to allow the jbig decoder and bit reverser + * to write to memory when necessary. + */ + tif->tif_flags |= TIFF_NOBITREV; + tif->tif_flags &= ~TIFF_MAPPED; /* Setup the function pointers for encode, decode, and cleanup. */ tif->tif_fixuptags = JBIGFixupTags; ddd - tif->tif_setupdecode = JBIGSetupDecode; - tif->tif_decodestrip = JBIGDecode; ddd + tif->tif_setupdecode = JBIGSetupDecode; + tif->tif_decodestrip = JBIGDecode; ddd - tif->tif_setupencode = JBIGSetupEncode; - tif->tif_encodestrip = JBIGEncode; ddd - - tif->tif_cleanup = JBIGCleanup; + tif->tif_setupencode = JBIGSetupEncode; + tif->tif_encodestrip = JBIGEncode; ddd - return 1; + tif->tif_cleanup = JBIGCleanup; + + return 1; } #endif /* JBIG_SUPPORT */