-
Notifications
You must be signed in to change notification settings - Fork 9
/
globals.h
179 lines (145 loc) · 4.62 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*************************************************************
Copyright (C) 1990, 1991, 1993 Andy C. Hung, all rights reserved.
PUBLIC DOMAIN LICENSE: Stanford University Portable Video Research
Group. If you use this software, you agree to the following: This
program package is purely experimental, and is licensed "as is".
Permission is granted to use, modify, and distribute this program
without charge for any purpose, provided this license/ disclaimer
notice appears in the copies. No warranty or maintenance is given,
either expressed or implied. In no event shall the author(s) be
liable to you or a third party for any special, incidental,
consequential, or other damages, arising out of the use or inability
to use the program for any purpose (or the loss of data), even if we
have been advised of such possibilities. Any public reference or
advertisement of this source code should refer to it as the Portable
Video Research Group (PVRG) code, and not by any author(s) (or
Stanford University) name.
*************************************************************/
/*
************************************************************
globals.h
Generic definitions globally known.
************************************************************
*/
#ifndef GLOBAL_DONE
#define GLOBAL_DONE
#include <stdio.h>
#include "mem.h"
#include "system.h"
#include "huffman.h"
#define BLOCKSIZE 64
#define BLOCKWIDTH 8
#define BLOCKHEIGHT 8
#define MAXIMUM_SOURCES 3 /* Should be 3 */
#define UMASK 0666 /* Octal */
#define BUFFERSIZE 256
#define sropen mropen
#define srclose mrclose
#define swopen mwopen
#define swclose mwclose
#define sgetb mgetb
#define sgetv mgetv
#define sputv mputv
#define swtell mwtell
#define srtell mrtell
#define swseek mwseek
#define srseek mrseek
#define READ_IOB 1
#define WRITE_IOB 2
/* P*64 flags */
#define P_DECODER 1
/* Image types */
#define IT_NTSC 0
#define IT_CIF 1
#define IT_QCIF 2
#define HUFFMAN_ESCAPE 0x1b01
#define IMAGE struct Image_Definition
#define FRAME struct Frame_Definition
#define FSTORE struct Fstore_Definition
#define STAT struct Statistics_Definition
#define RATE struct Rate_Control_Definition
#define MUTE 0
#define WHISPER 1
#define TALK 2
#define NOISY 3
#define SCREAM 4
/* Memory locations */
#define L_GQUANT 1
#define L_MQUANT 2
#define L_MQUANTENABLE 3
#define L_MTYPE 4
#define L_BD 5
#define L_DBD 6
#define L_VAROR 7
#define L_VAR 8
#define L_MWOR 9
#define L_RATE 10
#define L_BUFFERSIZE 11
#define L_BUFFERCONTENTS 12
#define L_QDFACT 13
#define L_QOFFS 14
#define ERROR_NONE 0
#define ERROR_BOUNDS 1 /*Input Values out of bounds */
#define ERROR_HUFFMAN_READ 2 /*Huffman Decoder finds bad code */
#define ERROR_HUFFMAN_ENCODE 3 /*Undefined value in encoder */
#define ERROR_MARKER 4 /*Error Found in Marker */
#define ERROR_INIT_FILE 5 /*Cannot initialize files */
#define ERROR_UNRECOVERABLE 6 /*No recovery mode specified */
#define ERROR_PREMATURE_EOF 7 /*End of file unexpected */
#define ERROR_MARKER_STRUCTURE 8 /*Bad Marker Structure */
#define ERROR_WRITE 9 /*Cannot write output */
#define ERROR_READ 10 /*Cannot write input */
#define ERROR_PARAMETER 11 /*System Parameter Error */
#define ERROR_MEMORY 12 /*Memory allocation failure */
typedef int iFunc();
typedef void vFunc();
#define GetFlag(value,flag) (((value) & (flag)) ? 1:0)
#define MAX(x,y) ((x > y) ? x:y)
#define MIN(x,y) ((x > y) ? y:x)
#define BEGIN(name) static char RoutineName[]= name
#define WHEREAMI() printf("F>%s:R>%s:L>%d: ",\
__FILE__,RoutineName,__LINE__)
/* InBounds is used to test whether a value is in or out of bounds. */
#define InBounds(var,lo,hi,str)\
{if (((var) < (lo)) || ((var) > (hi)))\
{WHEREAMI(); printf("%s in %d\n",(str),(var));ErrorValue=ERROR_BOUNDS;}}
#define BoundValue(var,lo,hi,str)\
{if((var)<(lo)){WHEREAMI();printf("Bounding %s to %d\n",str,lo);var=lo;}\
else if((var)>(hi)){WHEREAMI();printf("Bounding %s to %d\n",str,hi);var=hi;}}
#define MakeStructure(named_st) ((named_st *) malloc(sizeof(named_st)))
IMAGE {
char *StreamFileName;
int p64Mode;
int Height;
int Width;
};
FRAME {
int NumberComponents;
char ComponentFilePrefix[MAXIMUM_SOURCES][200];
char ComponentFileSuffix[MAXIMUM_SOURCES][200];
char ComponentFileName[MAXIMUM_SOURCES][200];
int Height[MAXIMUM_SOURCES];
int Width[MAXIMUM_SOURCES];
int hf[MAXIMUM_SOURCES];
int vf[MAXIMUM_SOURCES];
IOBUF *Iob[MAXIMUM_SOURCES];
};
FSTORE {
int NumberComponents;
IOBUF *fs[MAXIMUM_SOURCES];
};
STAT {
double mean;
double mse;
double mrsnr;
double snr;
double psnr;
double entropy;
};
RATE {
int position;
int size;
int baseq;
};
#include "prototypes.h"
#endif