1 /*************************************************************
2 Copyright (C) 1990, 1991, 1993 Andy C. Hung, all rights reserved.
3 PUBLIC DOMAIN LICENSE: Stanford University Portable Video Research
4 Group. If you use this software, you agree to the following: This
5 program package is purely experimental, and is licensed "as is".
6 Permission is granted to use, modify, and distribute this program
7 without charge for any purpose, provided this license/ disclaimer
8 notice appears in the copies.  No warranty or maintenance is given,
9 either expressed or implied.  In no event shall the author(s) be
10 liable to you or a third party for any special, incidental,
11 consequential, or other damages, arising out of the use or inability
12 to use the program for any purpose (or the loss of data), even if we
13 have been advised of such possibilities.  Any public reference or
14 advertisement of this source code should refer to it as the Portable
15 Video Research Group (PVRG) code, and not by any author(s) (or
16 Stanford University) name.
17 *************************************************************/
18 /*
19 ************************************************************
20 system.h
21 
22 This file contains the miscellaneous definitions for running
23 the JPEG coder.
24 
25 ************************************************************
26 */
27 
28 #ifndef SYSTEM_DONE
29 #define SYSTEM_DONE
30 /*#include <sys/file.h>*/
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <fcntl.h>
34 
35 #define IOB_BLOCK 0
36 #define IOB_LINE 1
37 #define IOB_OVERSAMPLEBLOCK 2
38 
39 #define BUFFER struct io_buffer
40 #define IOBUF struct io_buffer_list
41 
42 #define XHUFF struct huffman_standard_structure
43 #define EHUFF struct huffman_encoder
44 #define DHUFF struct huffman_decoder
45 
46 BUFFER {
47 unsigned int overflow;   /* The last buffer character on line overflow */
48 int data_linelast;       /* The last element read out for line buffering */
49 int disable;             /* Stream is disabled! */
50 int wsize;               /* Element word size in characters */
51 int size;                /* Size of buffer in characters */
52 long currentoffs;        /* Current offset from left edge of image */
53 long streamoffs;         /* Stream offset (the pixel index of left edge) */
54 unsigned char *space;    /* Space is the raw buffer pointer */
55 unsigned char *bptr;     /* Current base pointer of buffer */
56 unsigned char *tptr;     /* Current top pointer of buffer */
57 IOBUF *iob;              /* References own IOB */
58 };
59 
60 
61 IOBUF {
62 int type;                     /* Iob type */
63 int num;                      /* Number of buffers */
64 int wsize;                    /* Element word size in characters */
65 int hpos;                     /* Current block position in image */
66 int vpos;
67 int hor;                      /* Sampling frequency */
68 int ver;
69 int width;                    /* Width and height of image */
70 int height;
71 int file;                     /* File descriptor */
72 int flags;                    /* File mode flags */
73 int linelastdefault;          /* Last line element default */
74 BUFFER **blist;               /* A list of buffers */
75 };
76 
77 /* XHUFF contains all the information that needs be transmitted */
78 /* EHUFF and DHUFF are derivable from XHUFF */
79 
80 XHUFF {
81 int bits[36];          /* Bit-length frequency (indexed on length  */
82 int huffval[257];      /* Huffman value index */
83 };
84 
85 /* Encoder tables */
86 
87 EHUFF {
88 int ehufco[257];      /* Encoder huffman code indexed on code word */
89 int ehufsi[257];      /* Encoder huffman code-size indexed on code word */
90 };
91 
92 /* Decoder tables */
93 
94 DHUFF {
95 int ml;               /* Maximum length */
96 int maxcode[36];      /* Max code for a given bit length -1 if no codes */
97 int mincode[36];      /* Min code for a given bit length */
98 int valptr[36];       /* First index (of min-code) for a given bit-length */
99 };
100 
101 
102 #endif
103