ftp.nice.ch/pub/next/developer/objc/appkit/JPEGology.1.0.s.tar.gz#/jpeg/JpegDecode.h

This is JpegDecode.h in view mode; [Download] [Up]

/*

      File: JpegDecode.h

      Release: 1.0

      Written by Georges CHAN

      Purpose: declare JpegDecode class lib methods.

      Copyright, All right reserved.

      Date: September 92.

      Feel free to use this class in your application,
      but do not modify the source code.

      This file is provided to all registered user.

      Note: The author disclaims all warranties with regard to this
            software, including all implied warranties or merchantability,
            in no event shall the author be liable for any special,
            indirect or consequential damages or any damages whatsoever
            resulting from loss of use, data or profits, whether in an
            action of contract, negligence or other tortuous action,
            arising out of or in connection with the use of this software.
*/

// MARKER CONSTANT VALUES
#define SOF0  0xc0     // Start Of Frame 0 (baseline DCT Huff)
#define SOF1  0xc1     // Start Of Frame 1 (extended seq DCT Huff)
#define SOF2  0xc2     // Start Of Frame 2 (progressive DCT Huff)
#define SOF3  0xc3     // Start Of Frame 3 (spacial lossless Huff)
#define SOF5  0xc5     // Start Of Frame 5 (differential seq DCT Huff)
#define SOF6  0xc6     // Start Of Frame 6 (differential progressive DCT Huff)
#define SOF7  0xc7     // Start Of Frame 7 (differential spatial Huff)
#define SOF8  0xc8     // Start Of Frame 8
#define SOF9  0xc9     // Start Of Frame 9 (extended seq DCT arithmetic)
#define SOF10 0xca     // Start Of Frame 10 (progressive DCT arithmetic)
#define SOF11 0xcb     // Start Of Frame 11 (spatial lossless arithmetic)
#define SOF13 0xcd     // Start Of Frame 13 (differential seq DCT arithmetic)
#define SOF14 0xce     // Start Of Frame 14 (differential progressive DCT arithmetic)
#define SOF15 0xcf     // Start Of Frame 15 (differential spatial arithmetic)

#define RST0  0xd0
#define RST1  0xd1
#define RST2  0xd2
#define RST3  0xd3
#define RST4  0xd4
#define RST5  0xd5
#define RST6  0xd6
#define RST7  0xd7

#define APP0  0xe0     // application 0 marker 
#define APP15 0xef     // application 15 marker

#define DAC   0xcc     // Definitions AC coef Table marker
#define DHT   0xc4     // Definitions Huffman Table marker
#define DQT   0xdb     // Definitions Quantization Table marker
#define DRI   0xdd

#define JPG   0xc8

#define SOI   0xd8     // Start Of Image

#define EOI   0xd9

#define SOS   0xda

#define TEM   1


/* CONSTANT SIZE */
#define MAXQT 4        // maximum number of quantization tables allowed
#define MAXACT 4       // maximum number of arithmetic code tables
#define MAXDHT 4       // maximum number of huffman tables allowed

#define MAXCOMP 4      // maximum number of components allowed
#define MAXCOMPSCAN 4  // maximum number of components per scan

#define MATSIZE 64     // number of elements in a block matrix
#define DCTSIZE 8      // size of DCT block (8x8)

#define BITPERPIXEL 8  // number of bits in each component of a pixel
#define MAXVAL 255     // maximum value of each pixel channel
#define MIDVAL 128     // middle value of each pixel channel

#define DC 0           // mode for filling DC huffman table
#define AC 1           // mode for filling AC huffman table

#define GRAY  0        // constant for picture of gray color space
#define YIQ   1        // constant for picture of YIQ color space
#define YCBCR 2        // constant for picture of YCbCr color space
#define CMYK  3        // constant for picture of CMYK color space

struct Htable
       {
         int valpos[16],
             min[16],
             max[18];
         unsigned char value[256];
       };

typedef struct Htable huffTable;

#import <objc/Object.h>
#import <appkit/graphics.h>

@interface JpegDecode:Object
{
   int fd,                      // file descriptor for input file
       bitsLeft,                // no of bits available in buffer safe 
       safe,                    // value of data in buffer 
       restartInterval,         // value for restart interval
       resetCount,              // count down for resetting
       bitPPixel,               // number of bits per pixel
       compScan,                // number of components per scan
       imageWidth,              // width of the image
       imageHeight,             // height of the image
       noComponent,             // number of components for image
       hFact[MAXQT],            // horizontal sampling factor of each component
       vFact[MAXQT],            // vertical sampling factor of each component
       maxhFact,                // maximum horizontal factor
       maxvFact,                // maximum vertical factor
       qTno[MAXQT],             // quantization table number
       dcTabNo[MAXDHT],         // dc table number
       acTabNo[MAXDHT],         // ac table number
       compId[MAXDHT],          // id of the component
       lastDCval[MAXDHT],       // last dc value of each component
       mcuHeight[MAXCOMP],      // number of blocks per MCU vertical
       mcuWidth[MAXCOMP],       // number of blocks per MCU horizontal
       mcuBlock[MAXCOMP],       // number of blocks of MCU 
       QT[MAXQT][MATSIZE],      // quatization tables
       colorSpace;              // color type of the image
   huffTable DChuffTab[MAXDHT], // huffman table for dc coeff
             AChuffTab[MAXDHT]; // huffman table for ac coeff

}

- initFromFile :(const char*) filename
        bitMap :(id *) bMap
          size :(NXSize *) bitMapSize
       mustSee :(BOOL) flag;

- initFromFile :(const char*) filename
         image :(id *) im
          size :(NXSize *) imageSize
       mustSee :(BOOL) flag;

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.