/Sources/sdk/sccio.h
C Header | 1931 lines | 1260 code | 275 blank | 396 comment | 0 complexity | 032e338ec5c490e8e24eaa2f6c5d58fa MD5 | raw file
Large files files are truncated, but you can click here to view the full file
1/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. 2All rights reserved. */ 3 4 /* 5 | SCC Viewer Technology - Include 6 | 7 | Include: SCCIO.H 8 | Environment: Portable 9 | Function: Defines for redirectable IO in Viewer Technology 10 | 11 */ 12 13#ifndef SCCIO_H 14#define SCCIO_H 15 16#ifdef WINDOWS 17#ifndef SCC_PACK_SET 18#define SCC_PACK_SET 1 19#define SCC_PACKED_BY_SCCIO_H 1 20#pragma pack(push,8) 21#endif /* SCC_PACK_SET */ 22#endif /* WINDOWS */ 23 24#include "baseio.h" /* defines the basic IO abstraction (BASEIO struct) */ 25 26#ifdef __cplusplus 27extern "C" 28{ 29#endif 30 31#include "sccrc4.h" 32 33#ifdef WIN32 34#define IO_OSHANDLETYPE VTHANDLE 35#endif /*WIN32*/ 36 37#ifdef UNIX 38#if defined(_DARWIN_SOURCE) 39#if defined(__OBJC__) 40typedef NSFileHandle *IO_OSHANDLETYPE; 41#else 42typedef VTLPVOID IO_OSHANDLETYPE; 43#endif /* __OBJC__ */ 44#else 45#define IO_OSHANDLETYPE int 46#endif /* Mac OS X */ 47#endif /*UNIX*/ 48 49#ifdef NLM 50#define IO_OSHANDLETYPE int 51#endif /*NLM*/ 52 53 54 /* 55 | Defines for dwType in IOOPEN function 56 */ 57 58#define IOTYPE_DOSPATH 1 59#define IOTYPE_OEMPATH IOTYPE_DOSPATH 60#define IOTYPE_ANSIPATH 2 61#define IOTYPE_MACPATH 3 62#define IOTYPE_UNICODEPATH 4 63#define IOTYPE_MACFSSPEC 5 64#define IOTYPE_MACHFS 6 65#define IOTYPE_TEMP 7 66#define IOTYPE_RANGE 8 67#define IOTYPE_SECONDARY 9 68#define IOTYPE_ISTREAM 10 69#define IOTYPE_SUBSTREAM 11 70#define IOTYPE_SUBSTORAGE 12 71#define IOTYPE_REDIRECT 13 72#define IOTYPE_ISTORAGE 14 73#define IOTYPE_UNIXPATH 15 74#define IOTYPE_SUBOBJECT 16 75#define IOTYPE_REMOTEFILTERACCESS 17 76#define IOTYPE_CHUNKER 18 77#define IOTYPE_COMPRESS 19 78#define IOTYPE_SECONDARYFULL 20 79#define IOTYPE_IOSPEC 21 /* reserved */ 80#define IOTYPE_MEMORY 22 81/*** for using an open file handle, See sccda.c ***/ 82#define IOTYPE_HANDLE 23 83/*** IOTYPE_URL reserved for Transformation Server */ 84#define IOTYPE_URL 24 85#define IOTYPE_FITEMP 25 86#define IOTYPE_PATH 26 /* generic file system path (used by transformation server) */ 87#define IOTYPE_LOCATOR 27 /* IOLOCATOR path */ 88#define IOTYPE_LINKEDOBJECT 28 /* Linked object (attachment). */ 89#define IOTYPE_ARCHIVEOBJECT 29 /* Used in DAOpenDocument to open Archive Nodes*/ 90 91/* These IOTYPEs were added to support writable OLE2 using 92* Microsoft's interface. 93*/ 94#define IOTYPE_MSTREAM 30 95#define IOTYPE_MSTORAGE 31 96#define IOTYPE_MROOTSTORAGE 32 97 98/* These IOTYPEs were added to support writable OLE2 using 99* our portable interface. 100*/ 101#define IOTYPE_OLE2STREAM 33 102#define IOTYPE_OLE2STORAGE 34 103#define IOTYPE_OLE2ROOTSTORAGE 35 104 105/* added to support OLE Package embeddings */ 106#define IOTYPE_OLEPACKAGE 36 107 108/* added for DASaveObject */ 109#define IOTYPE_OBJECT 37 110 111/* added for in-memory temp files */ 112#define IOTYPE_PHYSICALTEMP 38 113 114/* support for zip archive files */ 115#define IOTYPE_ZIPFILE 39 116#define IOTYPE_ZIPNODE 40 117 118/* support for cab files */ 119#define IOTYPE_CABINET 41 120#define IOTYPE_CABFILE 42 121 122 123 124#ifdef WINDOWS 125#define IOTYPE_WIN32VPATH IOTYPE_ANSIPATH 126#endif 127 128#ifdef UNIX 129#define IOTYPE_WIN32VPATH IOTYPE_UNIXPATH 130#endif 131 132#ifdef NLM 133#define IOTYPE_WIN32VPATH IOTYPE_DOSPATH 134#endif 135 136 137 138 139 /*** Only used by DA to request opening a file requested through DASaveTreeNode */ 140#define IOTYPE_USERREQUEST 29 141 142 143 /* 144 | Structures passed to IOOPEN function 145 */ 146 147typedef struct IOSPECMACHFStag 148{ 149 short vRefNum; 150 VTLONG dirId; 151 VTTCHAR fileName[256]; 152} IOSPECMACHFS, * PIOSPECMACHFS; 153 154typedef struct IOSPECRANGEtag 155{ 156 HIOFILE hRefFile; 157#ifdef SCCFEATURE_64BITIO 158 VTOFF_T dwFirstByte; 159 VTOFF_T dwLastByte; 160#else 161 VTDWORD dwFirstByte; 162 VTDWORD dwLastByte; 163#endif 164} IOSPECRANGE, * PIOSPECRANGE; 165 166typedef struct IOSPECCOMPRESStag 167{ 168 HIOFILE hRefFile; 169 VTDWORD dwFlags; 170 VTDWORD dwType; /* type of compression */ 171 VTDWORD dwReserved1; 172 VTDWORD dwReserved2; 173 VTDWORD dwReserved3; 174 VTSYSVAL pResPointer1; 175} IOSPECCOMPRESS, * PIOSPECCOMPRESS; 176 177typedef struct IOSPECSECONDARYtag 178{ 179 HIOFILE hRefFile; 180 VTTCHAR szFileName[256]; 181} IOSPECSECONDARY, * PIOSPECSECONDARY; 182 183typedef struct IOSPECSUBSTREAMtag 184{ 185 HIOFILE hRefStorage; 186 VTTCHAR szStreamName[256]; 187} IOSPECSUBSTREAM, * PIOSPECSUBSTREAM; 188 189typedef struct IOSPECSUBSTORAGEtag 190{ 191 HIOFILE hRefStorage; 192 VTTCHAR szStorageName[256]; 193} IOSPECSUBSTORAGE, * PIOSPECSUBSTORAGE; 194 195typedef struct IOSPECMROOTSTORAGEtag 196{ 197 /* Through NTFS, the maximum filename size is 255 UNICODE 198 * characters plus the terminator. 199 */ 200 HIOFILE hRefFile; 201 VTTCHAR szFileName[512]; 202 VTDWORD dwFlags; 203} 204IOSPECMROOTSTORAGE, * PIOSPECMROOTSTORAGE; 205 206typedef struct IOSPECMSTREAMtag 207{ 208 HIOFILE hRefStorage; 209 /* Maximum stream name size is 31 UNICODE characters 210 * plus the terminator. 211 */ 212 VTTCHAR szStreamName[256]; 213} 214IOSPECMSTREAM, * PIOSPECMSTREAM; 215 216typedef struct IOSPECMSTORAGEtag 217{ 218 HIOFILE hRefStorage; 219 /* Maximum storage name size is 31 UNICODE characters 220 * plus the terminator. 221 */ 222 VTTCHAR szStorageName[256]; 223} 224IOSPECMSTORAGE, * PIOSPECMSTORAGE; 225 226/* Parameters to the IOGetInfo() / IOSetInfo() calls for Microsoft OLE2. */ 227#define IOSETINFO_OLE2CLSID 1 228 229/* These mirror the STGM defines in objbase.h */ 230#define SCC_STGM_CREATE 0x00001000L 231#define SCC_STGM_DIRECT 0x00000000L 232#define SCC_STGM_READWRITE 0x00000002L 233#define SCC_STGM_SHARE_EXCLUSIVE 0x00000010L 234#define SCC_STGM_SHARE_DENY_WRITE 0x00000020L 235#define SCC_STGM_DELETEONRELEASE 0x04000000L 236 237typedef struct IOSPECOLE2ROOTSTORAGEtag 238 { 239 HIOFILE hRefFile; 240 VTTCHAR szFileName[512]; 241 VTDWORD dwFlags; 242 } IOSPECOLE2ROOTSTORAGE, * PIOSPECOLE2ROOTSTORAGE; 243 244/* When opening an OLE2 root storage, we can wrap the provided 245* reference file and not re-open it on OLE2 document open and 246* not close it on OLE2 document close. Normal behavior is to 247* create/open a new file that the OLE2 document owns and let it 248* close it on document close. 249*/ 250#define SCC_WRAP_REFERENCE_FILE 0x00000001 251 252typedef struct IOSPECOLE2STREAMtag 253 { 254 HIOFILE hRefStorage; 255 VTTCHAR szStreamName[256]; 256 } IOSPECOLE2STREAM, * PIOSPECOLE2STREAM; 257 258typedef struct IOSPECOLE2STORAGEtag 259 { 260 HIOFILE hRefStorage; 261 VTTCHAR szStorageName[256]; 262 } IOSPECOLE2STORAGE, * PIOSPECOLE2STORAGE; 263 264typedef struct IOSPECSUBOBJECTtag 265{ 266 VTDWORD dwStructSize; 267 VTSYSPARAM hDoc; /* VTHDOC is Defined in SCCDA.H, which is not included here */ 268 VTDWORD dwObjectId; 269 VTDWORD dwStreamId; 270 VTDWORD dwReserved1; 271 VTDWORD dwReserved2; 272} IOSPECSUBOBJECT, * PIOSPECSUBOBJECT; 273 274/* used to access items in zip archive files, 275 * added for MS Office 12 support */ 276typedef struct IOSPECZIPNODEtag 277{ 278 HIOFILE hRefFile; /* zip file (block I/O) */ 279 280 VTCHAR szNodeName[512]; 281} IOSPECZIPNODE, * PIOSPECZIPNODE; 282 283/* used to access items in cabinet archive files */ 284typedef struct IOSPECCABFILEtag 285{ 286 HIOFILE hRefFile; /* cab file (block I/O) */ 287 288 VTWORD wFlags; /* see values below */ 289 VTWORD wFileIndex; /* file index */ 290 VTWORD wszFileName[512];/* null terminated file name */ 291} IOSPECCABFILE, * PIOSPECCABFILE; 292/* possible values for IOSPECCABNODE.dwFlags */ 293#define IO_CABFLAG_INDEX 0x0000 294#define IO_CABFLAG_NAME 0x0001 295 296/* used for archive objects in DA */ 297typedef struct IOSPECARCHIVEOBJECTtag 298{ 299 VTDWORD dwStructSize; 300 VTSYSPARAM hDoc; /* Parent Doc hDoc. VTHDOC is Defined in SCCDA.H, which is not included here */ 301 VTDWORD dwNodeId; /* Node ID */ 302 VTDWORD dwStreamId; /* I'm not sure if this is necessary */ 303 VTDWORD dwReserved1; /* Must always be 0 */ 304 VTDWORD dwReserved2; /* Must always be 0 */ 305} IOSPECARCHIVEOBJECT, * PIOSPECARCHIVEOBJECT; 306 307 308/* 309 Linked objects. 310*/ 311typedef struct IOSPECLINKEDOBJECTtag 312{ 313 VTDWORD dwStructSize; 314 VTSYSPARAM hDoc; /* VTHDOC is Defined in SCCDA.H, which is not included here */ 315 VTDWORD dwObjectId; /* Object identifier. */ 316 VTDWORD dwType; /* Linked Object type. (SO_LOCATORTYPE_*) */ 317 VTDWORD dwParam1; /* Parameter for DoSpecial call. */ 318 VTDWORD dwParam2; /* Parameter for DoSpecial call. */ 319 VTDWORD dwReserved1; /* Unused. */ 320 VTDWORD dwReserved2; /* Unused. */ 321} IOSPECLINKEDOBJECT, * PIOSPECLINKEDOBJECT; 322 323#define IO_FILEOPEN 0x0001 324#define IO_FILEISTEMP 0x0002 325 326typedef struct IOLOCATORSEGMENTtag 327{ 328 VTDWORD dwType; /* Locator type (SO_LOCATORTYPE_* from sodefs.h) */ 329 VTSYSPARAM param1; /* Parameter 1, use depends on locator segment type: 330 OLEPATH, FILENAME, HYPERLINK, BOOKMARK: Pointer to double-byte string 331 SECTION: Section number 332 TAGREFERENCE: Tag ID 333 DOSPECIAL: Optional parameter 334 RANGE: Offset 335 WINDOWSRESOURCE: Resource type 336 COMPRESSION: Compression type */ 337 VTSYSPARAM param2; /* Parameter 2, use depends on locator segment type: 338 OLEPATH, FILENAME, HYPERLINK, BOOKMARK: Length of double-byte string 339 DOSPECIAL: Optional parameter 340 RANGE: Length 341 WINDOWSRESOURCE: Resource ID 342 COMPRESSION: Compression flags */ 343} IOLOCATORSEGMENT, * PIOLOCATORSEGMENT; 344 345typedef struct IOLOCATORtag 346{ 347 VTDWORD dwStructSize; /* sizeof(IOLOCATOR) */ 348 VTSYSPARAM hDoc; /* VTHDOC is Defined in SCCDA.H, which is not included here */ 349 VTDWORD dwSegmentCount; /* Number of segments in this locator */ 350 IOLOCATORSEGMENT* pSegments; /* Pointer to an array of locator segments */ 351} IOLOCATOR, * PIOLOCATOR; 352 353#define IOLOCATOR_MAXSEGMENTS 256 354 355 /* 356 | Structure used for specifying the date and time of a file. 357 */ 358typedef struct IODATETIMEtag 359{ 360 VTDWORD dwYear; /* Year A.D. */ 361 VTDWORD dwMonth; /* Month, Jan == 1 */ 362 VTDWORD dwDay; /* Day of month */ 363 VTDWORD dwTime; /* Number of miliseconds since midnight */ 364}IODATETIME, * PIODATETIME; 365 366typedef struct IORFAREQUESTtag 367{ 368 VTDWORD dwReserved1; 369 VTDWORD dwReserved2; 370 VTDWORD dwReserved3; 371 VTDWORD dwReserved4; 372} IORFAREQUEST, * PIORFAREQUEST; 373/* LOWORD of request is one of the following: */ 374#define RAREQ_CHUNKERDATA 1 375#define RAREQ_RAWDATA 2 376 377 378typedef IOERR (IO_ENTRYMODPTR IOGETREMOTEDATAPROC) (HIOFILE hFile, PIORFAREQUEST pRequest, VTVOID * *ppData, VTDWORD *pdwDataSize); 379typedef IOERR (IO_ENTRYMODPTR IOCLOSEREMOTEDATAPROC)(HIOFILE hFile); 380typedef IOERR (IO_ENTRYMODPTR IOOPENREMOTESUBOBJECTPROC)(HIOFILE hFile, VTDWORD dwObjectId, VTDWORD dwStreamId, VTDWORD dwReserved1, VTDWORD dwReserved2, VTDWORD * pdwSpecType, VTVOID * *pSpec); 381 382typedef struct IOBASERFAtag /* Remote Filter Access */ 383{ 384 IOGETREMOTEDATAPROC pGetRemoteData; 385 IOCLOSEREMOTEDATAPROC pCloseRemoteData; 386 IOOPENREMOTESUBOBJECTPROC pOpenRemoteSubObject; 387 VTVOID * pDummy[5]; 388} IOBASERFA, * PIOBASERFA; 389 390 391 /* 392 | Structures for different types 393 */ 394 395typedef struct IORANGEFILEtag 396{ 397 BASEIO sBaseIO; /* Underlying IO system */ 398 HIOFILE hFile; /* Underlying IO system's handle to the file */ 399 VTDWORD dwFlags; /* Info flags */ 400 VTHANDLE hThis; /* Handle to this structure */ 401#ifdef SCCFEATURE_64BITIO 402 VTOFF_T dwFirstByte; /* Offset of the begining of the logical file */ 403 VTOFF_T dwLastByte; /* Offset of the end of the logical file */ 404 VTOFF_T dwCurPos; /* Offset in this rangefile wrt dwFirstByte */ 405#else 406 VTDWORD dwFirstByte; /* Offset of the begining of the logical file */ 407 VTDWORD dwLastByte; /* Offset of the end of the logical file */ 408 VTDWORD dwCurPos; /* Offset in this rangefile wrt dwFirstByte */ 409#endif 410 VTDWORD dwSavedPos; /* Pointer position of the reference file when the range was opened */ 411} IORANGEFILE, * PIORANGEFILE; 412 413typedef struct IOCOMPRESSFILEtag 414{ 415 BASEIO sBaseIO; /* Underlying IO system */ 416 HIOFILE hFile; /* Underlying IO system's handle to the file */ 417 VTDWORD dwType; /* Type of compression */ 418 VTDWORD dwFlags; /* Info flags */ 419 VTHANDLE hThis; /* Handle to this structure */ 420 VTHANDLE hBuffer; /* Handle to a cached buffer of decompressed data */ 421 VTBYTE * pBuffer; /* pointer to cached buffer of decompressed data */ 422 VTHANDLE hData; /* Handle for data needed for decompression */ 423 VTBYTE * pData; /* pointer to data needed for decompression */ 424 VTDWORD dwBufferStartPos; /* Tell of current buffer start position */ 425 VTDWORD dwBufferSize; /* size in bytes of valid buffer */ 426 HIOFILE hTempFile; /* Temp file to store extra */ 427#ifdef SCCFEATURE_64BITIO 428 VTOFF_T dwTempFileSize; /* Current temp file size */ 429 VTOFF_T dwTempFilePos; /* Current position in the current temp file of decompressed data */ 430 VTOFF_T dwCurFilePos; /* Current absolute file position of decompressed data */ 431#else 432 VTDWORD dwTempFileSize; /* Current temp file size */ 433 VTDWORD dwTempFilePos; /* Current position in the current temp file of decompressed data */ 434 VTDWORD dwCurFilePos; /* Current absolute file position of decompressed data */ 435#endif 436 VTBYTE LastByte; /* keep the last byte read for easy bit reading */ 437 VTBYTE nBitsLeft; 438 VTHANDLE hReadBuffer; /* handle to buffer for input */ 439 VTBYTE * pReadBuffer; /* pointer to buffer for input */ 440 VTDWORD dwReadBufferSize; /* size of read buffer */ 441 VTDWORD dwReadBufferPos; /* position in the read buffer */ 442 VTDWORD dwReadBufferFilePos; /* position of start of read buffer in the file */ 443 VTBOOL bReadBufferEOF; /* is the read buffer at EOF */ 444 VTDWORD dwReserved1; 445 VTDWORD dwReserved2; 446 VTDWORD dwReserved3; 447 VTSYSVAL pResPointer1; 448} IOCOMPRESSFILE, * PIOCOMPRESSFILE; 449 450#define IO_COMPRESSREADBUFFERSIZE 16384 451/* 452| 256KB seems to be the right balance between going to the disk infrequently 453| and not having too much memory to schlep around when we do go to disk 454*/ 455#define IO_COMPRESSBUFFERSIZE 0x00040000 456 457#define IO_COMPRESSTYPE_NONE 0 458#define IO_COMPRESSTYPE_ZLIB 1 459#define IO_COMPRESSTYPE_BASE64 2 460/* LZSS Support added Nov 18, 1999 */ 461#define IO_COMPRESSTYPE_LZSS 3 462/* Nov 2, 2000 PDF Decoding and Decompression methods types */ 463#define IO_COMPRESSTYPE_ASCII85 4 464#define IO_COMPRESSTYPE_ASCIIHEX 5 465#define IO_COMPRESSTYPE_RLE 6 466#define IO_COMPRESSTYPE_FLATE 7 467#define IO_COMPRESSTYPE_LZW 8 468#define IO_COMPRESSTYPE_DCT 9 469#define IO_COMPRESSTYPE_CCITT 11 470#define IO_COMPRESSTYPE_RC4 13 471 472/* PK Implode added Sept 11, 2000, currently supports Binary only */ 473#define IO_COMPRESSTYPE_PKMPLOD 10 474/* MIF Ascii decode support */ 475#define IO_COMPRESSTYPE_MIFASCIIDECODE 12 476 477/* Same as zlib compression, but without any header information */ 478#define IO_COMPRESSTYPE_ZLIB_NOHEADER 14 479 480#define IO_COMPRESSTYPE_UUENCODED 15 481#define IO_COMPRESSTYPE_XXENCODED 16 482#define IO_COMPRESSTYPE_BINHEX 17 483#define IO_COMPRESSTYPE_YENC 18 484#define IO_COMPRESSTYPE_BTOA 19 485#define IO_COMPRESSTYPE_QUOTEDPRINTABLE 20 486#define IO_COMPRESSTYPE_UTF7 21 487#define IO_COMPRESSTYPE_COMPRESSEDRTF 22 488 489/* JBIG 2 added May 14, 2004 */ 490#define IO_COMPRESSTYPE_JBIG2 23 491/* CAB support for MSZIP decompression */ 492#define IO_COMPRESSTYPE_MSZIP 24 493/* CAB support for LZX decompression */ 494#define IO_COMPRESSTYPE_LZX 25 495 496/* Advanced Encryption Standard (AES) decryption - 9/29/09 */ 497#define IO_COMPRESSTYPE_AES128 26 498#define IO_COMPRESSTYPE_AES192 27 499#define IO_COMPRESSTYPE_AES256 28 500 501/* ZIP Crypto */ 502#define IO_COMPRESSTYPE_ZIPCRYPTO 29 503 504/* define unknown compression */ 505#define IO_COMPRESSTYPE_UNKNOWN 255 506 507 508/* 509| Structure definitions for memory mapped IO. 510*/ 511 512#define IO_MEMFILE_INITSIZE 1024 513 514typedef struct IOGENMEMFILEtag 515{ 516 VTDWORD dwSize; /* should be set to the size of this structure */ 517 VTVOID * pData; 518 VTDWORD dwDataSize; /* size of valid data */ 519 VTHANDLE hData; 520 VTDWORD dwMemSize; /* size of allocated buffer (must be >= dwDataSize) */ 521} IOGENMEMFILE, * PIOGENMEMFILE; 522 523typedef struct IOMEMORYFILEtag 524{ 525 BASEIO sBaseIO; 526 VTLPBYTE pDataStart; 527 VTLPBYTE pCurrPos; 528 VTDWORD dwDataSize; /* size of valid data */ 529 VTHANDLE hThis; 530 VTDWORD dwFlags; 531 VTHANDLE hData; 532 VTDWORD dwMemSize; /* size of allocated buffer (must be >= dwDataSize) */ 533 HIOFILE hRealFile; /* if we need a ral temp file, use this */ 534} IOMEMORYFILE, * PIOMEMORYFILE; 535 536/* 537| Structure definitions for file access callbacks 538*/ 539 540typedef struct IOREQUESTDATAtag 541{ 542 VTDWORD dwSize; /* sizeof(IOREQUESTDATA) */ 543 VTWORD wFIId; /* FI id of reference file */ 544 VTDWORD dwSpecType; /* file spec type */ 545 VTVOID *pSpec; /* pointer to a file spec */ 546 VTDWORD dwRootSpecType; /* root file spec type */ 547 VTVOID *pRootSpec; /* pointer to the root file spec */ 548 VTDWORD dwAttemptNumber; /* The number of times the callback has already been called for the currently requested item of information */ 549} IOREQUESTDATA, * PIOREQUESTDATA; 550 551/***************************************************************************** 552 * Start of Zip stuff 553 ****************************************************************************/ 554/* Entry in table that stores sorted file names contained in zip file */ 555typedef struct tagFZFILEINFO 556{ 557 VTDWORD dwNameLoc; /* offset of filename in Fzu.pNames */ 558 VTWORD wNameLen; /* length of filename */ 559 560#ifdef SCCFEATURE_64BITIO 561 VTOFF_T dwLoc; /* offset of actual file header */ 562 VTOFF_T dwDataLen; /* length of compressed data */ 563#else 564 VTDWORD dwLoc; /* offset of actual file header */ 565 VTDWORD dwDataLen; /* length of compressed data */ 566#endif 567} FZFILEINFO, * PFZFILEINFO; 568 569/* Support for Zip file I/O system */ 570typedef struct IOZIPFILEtag 571{ 572 BASEIO sBaseIO; /* Underlying IO system */ 573 574 VTHANDLE hThis; /* Handle to this structure */ 575 HIOFILE hRefFile; /* zip file */ 576 VTBOOL bCaseAware; /* filenames are case insensitive */ 577 578 VTHANDLE hFileTable; /* handle to pFileTable array */ 579 PFZFILEINFO pFileTable; /* sorted array of files in zip */ 580 VTDWORD dwFileCnt; /* number of files in zip */ 581 582 VTHANDLE hNames; /* handle to pNames */ 583 VTCHAR * pNames; /* concatenation of all filenames */ 584 VTDWORD dwNamesMax; /* allocated bytes in pNames */ 585 VTDWORD dwNamesUse; /* bytes used in pNames */ 586} IOZIPFILE, * PIOZIPFILE; 587 588/* I/O struct for opened nodes within a zip file */ 589typedef struct IOZIPNODEtag 590{ 591 BASEIO sBaseIO; /* Underlying IO system */ 592 593 VTHANDLE hThis; /* Handle to this structure */ 594 HIOFILE hRefFile; /* either .hRange or .hCompress */ 595 596 VTDWORD dwIndex; /* index into IOZIPFILE.pFileTable */ 597 HIOFILE hRange; /* handle to range file */ 598 HIOFILE hCompress; /* handle to compressed file */ 599 600 VTBYTE Buffer[512];/* space for buffered I/O */ 601#ifdef SCCFEATURE_64BITIO 602 VTOFF_T dwBufLoc; /* file location of start of buffer */ 603#else 604 VTDWORD dwBufLoc; /* file location of start of buffer */ 605#endif 606 VTDWORD dwBufCnt; /* amt of valid data in buffer */ 607#ifdef SCCFEATURE_64BITIO 608 VTOFF_T lBufPos; /* buffer offset wrt dwBufLoc */ 609 VTOFF_T dwVerify; /* for verifying buffered zip IO */ 610#else 611 VTLONG lBufPos; /* buffer offset wrt dwBufLoc */ 612 VTDWORD dwVerify; /* for verifying buffered zip IO */ 613#endif 614} IOZIPNODE, * PIOZIPNODE; 615 616/* Structure returned by IOGetInfo(IOGETINFO_ZIPRANGE) */ 617typedef struct IOZIPRANGEtag 618{ 619#ifdef SCCFEATURE_64BITIO 620 VTOFF_T dwFirstByte; 621 VTOFF_T dwLastByte; 622#else 623 VTDWORD dwFirstByte; 624 VTDWORD dwLastByte; 625#endif 626 627 VTDWORD dwCompressType; /* IO_COMPRESSTYPE_xxxx */ 628} IOZIPRANGE, * PIOZIPRANGE; 629/***************************************************************************** 630 * End of Zip stuff 631 ****************************************************************************/ 632 633/***************************************************************************** 634 * Start of CAB stuff 635 ****************************************************************************/ 636/* structure to provide access to CFDATA block structure */ 637typedef struct CABDATAtag 638{ 639 HIOFILE hRefFile; /* range I/O file */ 640 641 VTWORD wCompressedSize; /* # of compressed bytes in block */ 642 VTWORD wUncompressedSize; /* # of uncompressed bytes in block */ 643} CABDATA, * PCABDATA; 644 645/* structure to provide access to CFFILE info */ 646typedef struct CABFILEINFOtag 647{ 648 VTDWORD dwNameLoc; /* offset into CABFILE.pNames */ 649 VTDWORD dwNameLen; 650 651 VTDWORD dwFileSize; /* uncompressed size of this file in bytes */ 652 VTDWORD dwFileLoc; /* uncompressed offset of file in the folder */ 653 VTWORD wFolderIndex;/* index into the CFFOLDER area */ 654 VTWORD wDate; /* date stamp for this file */ 655 VTWORD wTime; /* time stamp for this file */ 656} CABFILEINFO, * PCABFILEINFO; 657 658typedef struct IOCABFILEtag 659{ 660 BASEIO sBaseIO; /* Underlying IO system */ 661 662 VTHANDLE hThis; /* Handle to this structure */ 663 HIOFILE hCabinet; /* handle to parent IOCABFILE */ 664 665 HIOFILE hRange; /* range within folder */ 666 667 /* IOCABINET.pFileInfo array index to obtain the cabfile info */ 668 VTWORD wFileIdx; 669} IOCABFILE, * PIOCABFILE; 670 671typedef struct IOCABFOLDERtag 672{ 673 BASEIO sBaseIO; /* Underlying IO system */ 674 675 HIOFILE hCabinet; /* handle to parent IOCABFILE */ 676 677 VTHANDLE hData; /* handle to pData array */ 678 PCABDATA pData; /* array of cab data blocks */ 679 680 VTWORD wDataIdx; /* index into folder's pDataArray */ 681 VTDWORD dwDataLoc; /* offset within current data block */ 682 683 VTDWORD dwDataOffset; /* offset for 1st CFDATA block in folder */ 684 VTWORD wDataCnt; /* # of CFDATA blocks in this folder */ 685 VTWORD wCompressType; /* compression type for CFDATAs in folder */ 686} IOCABFOLDER, * PIOCABFOLDER; 687 688/* struct facilitating access of continguous uncompressed cab folder data */ 689typedef struct CABFOLDERINFOtag 690{ 691 HIOFILE hRefFile; /* handle to either &Folder or hCompress */ 692 693 IOCABFOLDER Folder; /* underlying folder I/O handle */ 694 HIOFILE hCompress; /* valid when folder is compressed */ 695} CABFOLDERINFO, * PCABFOLDERINFO; 696 697typedef struct IOCABINETtag 698{ 699 BASEIO sBaseIO; /* Underlying IO system */ 700 701 VTHANDLE hThis; /* Handle to this structure */ 702 HIOFILE hRefFile; /* cab file */ 703 704 VTWORD wFolderCnt; /* count of folders */ 705 VTWORD wFileCnt; /* count of files */ 706 707 VTWORD wHdrReserve; /* bytes in header reserve field */ 708 VTBYTE ubFldrReserve; /* bytes in folder reserve field */ 709 VTBYTE ubDataReserve; /* bytes in data reserve field */ 710 711 VTDWORD dwFileLoc; /* offset of first file location */ 712 713 VTHANDLE hFldrInfo; /* handle to pFldrInfo array */ 714 PCABFOLDERINFO pFldrInfo; /* array of all CABFOLDERINFOs in cab */ 715 716 VTHANDLE hFileInfo; /* handle to pFileInfo array */ 717 PCABFILEINFO pFileInfo; /* array of file info structs */ 718 719 VTHANDLE hNames; /* handle to pNames */ 720 VTWCHAR* pNames; /* concatenation of all filenames */ 721 VTDWORD dwNamesMax; /* allocated bytes in pNames */ 722 VTDWORD dwNamesUse; /* bytes used in pNames */ 723 724} IOCABINET, * PIOCABINET; 725/***************************************************************************** 726 * End of CAB stuff 727 ****************************************************************************/ 728 729/* 730| Node of a Shannon-Fano tree 731| 0 is the root. 732| A zero in left field 733| means the right field is the value. 734*/ 735typedef struct SFNODEtag 736{ 737 VTLONG left; 738 VTLONG right; 739} SFNODE, * PSFNODE; 740 741#define HPSFNODE PSFNODE 742 743/* 744| Structure to store input for creating the Shannon-Fano tree. 745*/ 746typedef struct CODEINFOtag 747{ 748 VTLONG lValue; 749 VTSHORT nLength; 750} CODEINFO, * PCODEINFO; 751 752typedef struct IOZLIBDATAtag 753{ 754 VTHANDLE hLitLenTree; 755 PSFNODE pLitLenTree; 756 VTHANDLE hDistanceTree; 757 PSFNODE pDistanceTree; 758 VTHANDLE hCodeLenTree; 759 PSFNODE pCodeLenTree; 760 VTHANDLE hTree; 761 PSFNODE pTree; 762 VTBOOL bFinal; /* is this the final block? */ 763 VTBOOL bFinished; /* no more compression. eof */ 764 VTBYTE bType; /* what type of compression: 0=none, 1=fixed codes, 2=dynamic codes */ 765 VTWORD wLength; /* bytes left when bType==0 */ 766} IOZLIBDATA, * PIOZLIBDATA; 767 768 769/*********************************************************************/ 770/*********************************************************************/ 771/************************* *************************/ 772/************************* LZSS *************************/ 773/************************* *************************/ 774/*********************************************************************/ 775/*********************************************************************/ 776#define IO_CIRCBUF_SIZE 0x1000 777 778/* LZSS Support added Nov 18, 1999 */ 779typedef struct IOLZSSDATAtag 780{ 781 VTBYTE bCurFlags; /* the current lzss flags*/ 782 VTBYTE bFlagCount; /* which flag bit to look at next */ 783 VTHANDLE hCircBuf; 784 VTBYTE * pCircBuf; 785 VTWORD wCircBufPos; 786 787} IOLZSSDATA, * PIOLZSSDATA; 788 789/*********************************************************************/ 790/*********************************************************************/ 791/************************* *************************/ 792/************************* PKMPLOD *************************/ 793/************************* *************************/ 794/*********************************************************************/ 795/*********************************************************************/ 796 797/* PKMPLOD Support added Sept 11, 2000 */ 798/* these values correspond to the format, do not change */ 799#define BINARYCOMPRESSION 0 800#define ASCIICOMPRESSION 1 801#define ONEKDICTIONARY 4 802#define TWOKDICTIONARY 5 803#define FOURKDICTIONARY 6 804#define LITERALDATA 0 805#define CODEDATA 1 806 807typedef struct IOPKMPLODDATAtag 808{ 809 VTBYTE bCompressionType; /* Binary or ASCII, currently only support Binary */ 810 VTBYTE bDictionarySize; /* 1k, 2k, or 4k */ 811 VTBYTE bDataType; /* the current data type to read: literal or code */ 812 813} IOPKMPLODDATA, * PIOPKMPLODDATA; 814 815 816/*********************************************************************/ 817/*********************************************************************/ 818/***************** ********************/ 819/***************** PDF DECODING AND DECOMPRESSION ********************/ 820/***************** ********************/ 821/*********************************************************************/ 822/*********************************************************************/ 823/*********************************************************************/ 824 825/* ASCII85 decoding support added Nov 2, 2000*/ 826/*********************************************************************/ 827/*********************************************************************/ 828/************************* *************************/ 829/************************* ASCII85 *************************/ 830/************************* *************************/ 831/*********************************************************************/ 832/*********************************************************************/ 833#define ASCII85_CHARDATA_SIZE 5 /* buffer size for character data */ 834#define ASCII85_BINARYDATA_SIZE 4 /* buffer size for binary data */ 835 836typedef struct IOASCII85DATAtag 837{ 838 VTBYTE byCharData[ASCII85_CHARDATA_SIZE]; 839 VTBYTE byBinaryData[ASCII85_BINARYDATA_SIZE]; 840 VTBOOL bEOD; 841 VTBYTE byNumber; 842 VTBYTE byIndex; 843} IOASCII85DATA, * PIOASCII85DATA; 844 845typedef struct IOYENCDATAtag 846{ 847 VTBYTE Line[256]; 848 VTWORD wCurrentPosition; 849 VTWORD wUncompressedLength; 850 VTBOOL bWithinPart; 851} IOYENCDATA, * PIOYENCDATA; 852 853typedef struct IOBTOADATAtag 854{ 855 VTBYTE Line[32]; 856 VTWORD wCurrentPosition; 857 VTWORD wUncompressedLength; 858 VTDWORD dwValue; 859 VTWORD wCount; 860} IOBTOADATA, * PIOBTOADATA; 861 862typedef struct IOQPDATAtag 863{ 864 VTBYTE Line[128]; 865 VTWORD wCurrentPosition; 866 VTWORD wUncompressedLength; 867} IOQPDATA, * PIOQPDATA; 868 869typedef struct IOBinHexDATAtag 870{ 871 VTDWORD dwReadLength; 872 VTDWORD dwDataLength; 873 VTBYTE Line[8]; 874 VTWORD wCurrentPosition; 875 VTWORD wUncompressedLength; 876 VTSHORT cchLastCharacter; 877 VTWORD wRepeatCount; 878} IOBINHEXDATA, * PIOBINHEXDATA; 879 880typedef struct IOCOMPRESSEDRTFDATAtag 881{ 882 VTHANDLE hLine; 883 VTLPBYTE Line; 884 VTBYTE bFlagByte; 885 VTWORD wBitsLeft; 886 VTWORD wCurrentPosition; 887 VTWORD wPositionsBuffered; 888 VTWORD wNextWritePosition; 889 VTDWORD dwCompressedSize; 890 VTDWORD dwUnCompressedSize; 891 VTDWORD dwSignature; 892 VTDWORD dwCrc; 893} IOCOMPRESSEDRTFDATA, * PIOCOMPRESSEDRTFDATA; 894 895typedef struct IOXXEDATAtag 896{ 897 VTBYTE Line[128]; 898 VTWORD wCurrentPosition; 899 VTWORD wUncompressedLength; 900} IOXXEDATA, * PIOXXEDATA; 901 902typedef struct IOUUEDATAtag 903{ 904 VTBYTE Line[128]; 905 VTWORD wCurrentPosition; 906 VTWORD wUncompressedLength; 907} IOUUEDATA, * PIOUUEDATA; 908 909typedef struct IOBASE64DATAtag 910{ 911 VTBYTE Line[132]; 912 VTWORD wCurrentPosition; 913 VTWORD wUncompressedLength; 914} IOBASE64DATA, * PIOBASE64DATA; 915 916typedef struct IOUTF7DATAtag 917{ 918 VTWORD UnCompressedLine[128]; 919 VTBYTE Line[128]; 920 VTWORD wCurrentPosition; 921 VTWORD wUncompressedLength; 922} IOUTF7DATA, * PIOUTF7DATA; 923 924/* ASCIIHex decoding support added Nov 6, 2000*/ 925/*********************************************************************/ 926/*********************************************************************/ 927/************************* *************************/ 928/************************* ASCIIHEX *************************/ 929/************************* *************************/ 930/*********************************************************************/ 931/*********************************************************************/ 932typedef struct IOASCIIHEXDATAtag 933{ 934 VTBOOL bEOD; /* used when the least significant part is padded with '0' */ 935} IOASCIIHEXDATA, * PIOASCIIHEXDATA; 936 937 938/* Flate decoding support added Nov 17, 2000 */ 939/*********************************************************************/ 940/*********************************************************************/ 941/************************* *************************/ 942/************************* FLATE *************************/ 943/************************* *************************/ 944/*********************************************************************/ 945/*********************************************************************/ 946#define FLATE_WINDOW 32768 /* buffer size */ 947#define FLATE_MASK (FLATE_WINDOW - 1) 948#define FLATE_MAX_HUFFMAN 15 /* max Huffman code length */ 949#define FLATE_MAX_CODE_LEN_CODES 19 /* max number of code length codes */ 950#define FLATE_MAX_LIT_CODES 288 /* max number of literal codes */ 951#define FLATE_MAX_DIST_CODES 30 /* max number of distance codes */ 952#define FLATE_MAX_LENGTH 260 /* max number of length for <length, backward distance> pair */ 953 /* (it is max 258 bytes according to RFC 1951) */ 954 955/* Structure to store input for creating the Huffman tree (Huffman code table entry) */ 956typedef struct FLATECODEtag 957{ 958 VTSHORT nLength; /* produced code lengths */ 959 VTLONG lCode; /* produced codes */ 960 VTLONG lValue; /* TODO:?? */ 961} FLATECODE, * PFLATECODE; 962 963/* Huffman code table */ 964typedef struct FLATEHUFFMANTABLEtag 965{ 966 VTHANDLE hStart; /* handle to indexes of the first code of each length [IO_FLATE_MAX_HUFFMAN+2] */ 967 VTLONG* pStart; /* pointer to indexes of the first code of each length [IO_FLATE_MAX_HUFFMAN+2] */ 968 PFLATECODE pFlateCodes; 969} FLATEHUFFMANTABLE, * PFLATEHUFFMANTABLE; 970 971/* Decoding info for length and distance code words */ 972typedef struct FLATEDECODEtag 973{ 974 VTLONG lBits; /* number of extra bits */ 975 VTLONG lFirst; /* first length/distance */ 976} FLATEDECODE, * PFLATEDECODE; 977 978typedef struct IOFLATEDATAtag 979{ 980 FLATEHUFFMANTABLE sLiteralCodeTab; /* literal code table */ 981 FLATEHUFFMANTABLE sDistanceCodeTab; /* distance code table */ 982 VTHANDLE hAllCodes; /* handle to literal and distance codes. */ 983 PFLATECODE pAllCodes; /* pointer to literal and distance codes [IO_FLATE_MAX_LIT_CODES + IO_FLATE_MAX_DIST_CODES]. */ 984 VTLONG lCodeBuf; /* input buffer */ 985 VTLONG lCodeSize; /* number of bits in input buffer */ 986 VTBOOL bCompressedBlock; /* set if reading a compressed block */ 987 VTDWORD dwBlockLen; /* remaining length of uncompressed block */ 988 VTBOOL bEndOfBlock; /* set when end of block is reached */ 989 VTBOOL bEOD; /* set when end of stream is reached */ 990 VTHANDLE hDecompData; /* handle to decompressed data buffer extracted form <length, backward distance> pair. */ 991 VTBYTE * pDecompData; /* buffer which will keep extracted decompressed data */ 992 VTDWORD dwRemain; /* number valid bytes in output buffer */ 993 /* predictor support */ 994 VTWORD wSlidingWindowSize; /* calculated from CINFO flag, and used to allocate buffer for sliding window */ 995 VTHANDLE hPredictorData; /* handle to the predictor sturcture. */ 996 VTBYTE * pPredictorData; /* pointer to predictor sturcture [FLATE_MAX_LENGTH]. */ 997} IOFLATEDATA, * PIOFLATEDATA; 998 999/*********************************************************************/ 1000/*********************************************************************/ 1001/************************* *************************/ 1002/************************* LZW *************************/ 1003/************************* *************************/ 1004/*********************************************************************/ 1005/*********************************************************************/ 1006 1007#define MAX_CODE_SIZE 12 /* max number of bits that can be used. */ 1008#define MIN_CODE_SIZE 8 /* min number of bits that can be used. */ 1009#define DICT_SIZE (1 << MAX_CODE_SIZE) /* size of the dictionary table (for 12 bits = 4096). */ 1010#define CLEAR_CODE (1 << MIN_CODE_SIZE) /* 256 */ 1011#define END_OF_DATA_CODE (CLEAR_CODE + 1) /* 257 */ 1012#define FIRST_CODE (CLEAR_CODE + 2) /* 258 */ 1013#define STOP_CODE 0xFFFF /* this code determines the stop condition when traversing */ 1014 /* multiway tree. (initially was 0, but it turned out, that it was */ 1015 /* failing when parent contains 0 which should be retrieved. */ 1016 1017 1018/* This data structure defines the dictionary. Each entry in the dictionary has a code value. 1019 * which is emitted by the compressor. Each node is actually made up of two pieces: 1020 * - parent_code 1021 - character. 1022 * Code values of less than 256 are actually plain text codes. 1023 */ 1024typedef struct DICTTTREEtag 1025{ 1026 VTWORD wParentCode; 1027 VTBYTE byCharacter; 1028} LZWDICTTREE, * PLZWDICTTREE; 1029 1030typedef struct IOLZWDATAtag 1031{ 1032 VTHANDLE hDictTreeArray; 1033 PLZWDICTTREE pDictTreeArray; 1034 VTWORD wDictNextCode; /* next code to be added to the dictionary. */ 1035 VTHANDLE hDecodeStack; /* for reversing strings that come out of the tree. */ 1036 VTBYTE * pDecodeStack; 1037 VTWORD wStackPointer; 1038 VTBYTE byCurrentCodeSize; /* contains number of bits, which are currently read from the file. */ 1039 VTWORD wNextBumpCode; /* defines the code that will trigger the next jump in bits size. 511, 1023, 2047) */ 1040 1041 VTWORD wPrevCode; /* previous code rad from the input file. */ 1042 VTWORD wCurrentCode; /* current code read from the input file. */ 1043 VTBYTE byFirstChar; /* first character of the prevous code, used to construct dictionary entry. */ 1044 VTBOOL bEOD; /* set true when END_OF_DATA_CODE is reached. */ 1045 1046 VTDWORD dwBitsBuf; /* contains bits used for reading specified number of bits. */ 1047 VTDWORD dwBitsLeft; /* number of bits in dwBitsBuf (used for transforming big-endian to little-endian). */ 1048 1049 VTHANDLE hPredictorData; /* handle to the predictor sturcture. */ 1050 VTBYTE * pPredictorData; /* pointer to predictor sturcture. */ 1051} IOLZWDATA, * PIOLZWDATA; 1052 1053 1054#define IO_COMPRESSTYPE_NONE 0 1055#define IO_COMPRESSTYPE_ZLIB 1 1056#define IO_COMPRESSTYPE_BASE64 2 1057 1058/*********************************************************************/ 1059/*********************************************************************/ 1060/************************* *************************/ 1061/************************* PREDICTOR *************************/ 1062/************************* *************************/ 1063/*********************************************************************/ 1064/*********************************************************************/ 1065 1066/* Predictor types: */ 1067#define IO_PREDICTION_NONE 0 1068#define IO_PREDICTION_DEFAULT 1 /* also no prediction */ 1069#define IO_PREDICTION_TIFF 2 1070#define IO_PREDICTION_PNG_NONE 10 /* no prediction */ 1071#define IO_PREDICTION_PNG_SUB 11 1072#define IO_PREDICTION_PNG_UP 12 1073#define IO_PREDICTION_PNG_AVERAGE 13 1074#define IO_PREDICTION_PNG_PEATH 14 1075#define IO_PREDICTION_PNG_OPTIMUM 15 1076 1077/* Masks for extracting data from the reserved words. */ 1078#define PREDICTOR_MASK_COLORS 0xFF 1079#define PREDICTOR_MASK_BITS 0xFF00 1080#define PREDICTOR_MASK_EARLY 0xFF0000 1081 1082/* When predictors are used we need to keep data in sliding window. To get the size of 1083 * the slididng window CINFO flag from ZLIB header is read. Its max value can be CINFO=7, 1084 * which gives sliding window size of 32k (2pow(CINFO+8). Everything less than CINFO=7 1085 * will give smaller sliding widnow smaller and the value will be get by right shift. 1086 */ 1087#define SLIDING_WINDOW_MAX (1<<15) /* 32k */ 1088 1089/* 1090 | For transfering extra parmeters needed for prediction from IOCOMPRESSDATA, following is used: 1091 | dwReserved1 - prediction values (1 - no prediction, 2 - TIFF prediction, 10 - 15 PNG prediction) 1092 | (for more info see PDF Reference Pg. 48, and PNG specification - filter algorithms) 1093 | dwReserved2 - number of colmuns (pixels per line) 1094 | dwReserved3 - number of color components (last siginivicant byte 0xFF 1095 | dwReserved3 - bits per pixel (second byte 0xFF00) 1096 | dwReserved3 - early change (third byte 0xFF0000) 1097 | They are either repeated or extracted in this structure. 1098 */ 1099typedef struct IOPREDICTORDATAtag 1100{ 1101 VTBYTE byPredictor; /* dwReserved1 - predictor type */ 1102 VTDWORD dwWidth; /* dwReserved2 - columns (pixels per line). */ 1103 VTBYTE byColorComponents; /* dwReserved3 - number of color components (0xFF) */ 1104 VTBYTE byBitsPerComponent; /* dwReserved3 - lower byte of dwReserved3 0xFF00 */ 1105 VTBYTE byEarlyChange; /* dwReserved3 - higher byte of dwReserved3 0xFF0000 */ 1106 VTDWORD dwVals; /* dwWidth*byColorComponents. - components per line */ 1107 VTDWORD dwPixBytes; /* bytes per pixel. */ 1108 VTDWORD dwRowBytes; /* bytes per line. */ 1109 VTHANDLE hPredictorLine; /* handle to predictor line buffer */ 1110 VTBYTE * pPredictorLine; /* pointer to predictor line buffer. */ 1111 VTDWORD dwPredictorIndex; /* current index in predictor line. */ 1112 VTHANDLE hSlidingWindow; /* handle to sliding window buffer */ 1113 VTBYTE * pSlidingWindow; /* pointer to sliding widnow buffer */ 1114 VTWORD wSlidingIndex; /* current index in sliding window. */ 1115 VTWORD wSlidingMask; /* contains mask for wrapping of index in Sliding window (as circular buffer). */ 1116} IOPREDICTORDATA, * PIOPREDICTORDATA; 1117 1118 1119/*********************************************************************/ 1120/*********************************************************************/ 1121/************************* *************************/ 1122/************************* DCT *************************/ 1123/************************* *************************/ 1124/*********************************************************************/ 1125/*********************************************************************/ 1126 1127/* 1128 | For transfering extra parmeters needed for DCT from IOCOMPRESSDATA, following is used: 1129 | dwReserved1 - whether ColorTransform parameter is defined in the dictionary 1130 | (0 - not defined in the dictionary, 1131 | 1 - defined in the dictionary with value stored in 1132 | dwReserved2) 1133 | dwReserved2 - ColorTransform integer (0 - no color transformation, 1134 | 1 - apply color transformation) 1135 | 1136 | ColorTransform integer is a code specifying the transformation to be performed on the 1137 | sample values: 1138 | 0 No transformation. 1139 | 1 If the image has three color components, transform RGB values to YUV before 1140 | encoding and from YUV to RGB after decoding. If the image has four components, 1141 | transform CMYK values to YUVK before encoding and from YUVK to CMYK after 1142 | decoding. This option is ignored if the image has one or two color components. 1143 | The default value of ColorTransform is 1 if the image has three components and 0 otherwise. 1144 | In other words, conversion between RGB and YUV is performed for all three-component images 1145 | unless explicitly disabled by setting ColorTransform to 0. Additionally, the encoding 1146 | algorithm inserts an Adobedefined marker code in the encoded data indicating the ColorTransform 1147 | value used. If present, this marker code overrides the ColorTransform value given to DCTDecode. 1148 | Thus it is necessary to specify ColorTransform only when decoding data that does not contain 1149 | the Adobe-defined marker code. 1150 */ 1151 1152 1153/* 1154 * JPEG markers consist of one or more 0xFF bytes, followed by a marker 1155 * code byte (which is not an FF). Here are the marker codes of interest 1156 * in this program. (See jdmarker.c for a more complete list.) 1157 */ 1158 1159/* Note: codes C4 and CC are NOT SOF markers */ 1160 1161typedef enum DCT_MARKERtag 1162{ /* NON-DIFFERENTIAL HUFFMAN */ 1163 SOF0 = 0xc0, /* Baseline DCT */ 1164 SOF1 = 0xc1, /* Extended sequential DCT */ 1165 SOF2 = 0xc2, /* Progressive DCT */ 1166 SOF3 = 0xc3, /* Spatial DPCM */ 1167 1168 /* DIFFERENTIAL HUFFMAN */ 1169 SOF5 = 0xc5, /* Differential sequential DCT */ 1170 SOF6 = 0xc6, /* Differential progressive DCT */ 1171 SOF7 = 0xc7, /* Differential spatial */ 1172 1173 /* NON-DIFFERENTIAL ARITHMETIC */ 1174 JPG = 0xc8, /* Reserved for JPEG extensions */ 1175 SOF9 = 0xc9, /* Extended sequential DCT */ 1176 SOF10 = 0xca, /* Progressive DCT */ 1177 SOF11 = 0xcb, /* Spatial DPCM */ 1178 1179 /* DIFFERENTIAL ARITHMETIC */ 1180 SOF13 = 0xcd, /* Differential sequential DCT */ 1181 SOF14 = 0xce, /* Differential progressive DCT */ 1182 SOF15 = 0xcf, /* Differential spatial */ 1183 1184 DHT = 0xc4, /* Define Huffman table */ 1185 DAC = 0xcc, /* Define Arithmetic conditioning */ 1186 1187 RST0 = 0xd0, /* Restart with modulo 8 count 0 */ 1188 RST1 = 0xd1, /* Restart with modulo 8 count 1 */ 1189 RST2 = 0xd2, /* Restart with modulo 8 count 2 */ 1190 RST3 = 0xd3, /* Restart with modulo 8 count 3 */ 1191 RST4 = 0xd4, /* Restart with modulo 8 count 4 */ 1192 RST5 = 0xd5, /* Restart with modulo 8 count 5 */ 1193 RST6 = 0xd6, /* Restart with modulo 8 count 6 */ 1194 RST7 = 0xd7, /* Restart with modulo 8 count 7 */ 1195 1196 SOI = 0xd8, /* Start of image */ 1197 EOI = 0xd9, /* End of image */ 1198 SOS = 0xda, /* Start of scan */ 1199 DQT = 0xdb, /* Define quantization table(s) */ 1200 DNL = 0xdc, /* Define number of lines */ 1201 DRI = 0xdd, /* Define restart interval */ 1202 DHP = 0xde, /* Define hierarchical progression*/ 1203 EXP = 0xdf, /* Expand reference image(s) */ 1204 1205 /* RESERVED APPLICATION SEGMENTS 0xFFE0-0xFFEF */ 1206 APP0 = 0xe0, /* Application Data */ 1207 APP1 = 0xe1, 1208 APP2 = 0xe2, 1209 APP3 = 0xe3, 1210 APP4 = 0xe4, 1211 APP5 = 0xe5, 1212 APP6 = 0xe6, 1213 APP7 = 0xe7, 1214 APP8 = 0xe8, 1215 APP9 = 0xe9, 1216 APP10 = 0xea, 1217 APP11 = 0xeb, 1218 APP12 = 0xec, 1219 APP13 = 0xed, 1220 APP14 = 0xee, /* Adobe Application-Specific JPEG Marker */ 1221 APP15 = 0xef, 1222 1223 /* RESERVED JPEG EXTENSIONS 0xFFF0-0xFFFD */ 1224 JPG0 = 0xf0, 1225 JPG13 = 0xfd, 1226 1227 COM = 0xfe, /* Comment */ 1228 1229 TEM = 0x01, /* Temp. private use arithmetic */ 1230 1231 MARKER_ERROR = 0x100 1232 1233 /* RESERVED 0xFF02-0xFFBF */ 1234} DCT_MARKER; 1235 1236#define DCTSIZE 8 /* T…
Large files files are truncated, but you can click here to view the full file